如何使用OTA从QC获取历史信息

时间:2015-12-23 11:22:42

标签: c# ota qc

在我的代码下方,从QC获取Bug历史信息。

我有问题

不过滤的AuditPropertyFactoryFilter。 AuditPropertyFactory有超过一千行。

如果我评论 var changesList = auditPropertyFactory.NewList(changesHistoryFilter.Text);并取消注释 下一行,auditPropertyFactory只有几行,但我没有根据需要进行过滤。

有人可以得到一些建议吗?

  public List<QCBugHistory> retrieveHistoryFromBug(string bugId)
    {
        List<QCBugHistory> history = new List<QCBugHistory>();
        try
        {
            TDConnection qcConnection = new TDConnection();
            qcConnection.InitConnectionEx(qcUrl);
            qcConnection.ConnectProjectEx(qcDomain, qcProject, qcLogin);
            if (qcConnection.Connected)
            {
                AuditRecordFactory auditFactory = qcConnection.AuditRecordFactory as AuditRecordFactory;
                TDFilter historyFilter = auditFactory.Filter;
                historyFilter["AU_ENTITY_TYPE"] = "BUG";
                historyFilter["AU_ENTITY_ID"] = bugId;
                historyFilter["AU_ACTION"] = "Update";
                historyFilter.Order["AU_TIME"] = 1;
                historyFilter.OrderDirection["AU_TIME"] = 1;
                var auditRecordList = auditFactory.NewList(historyFilter.Text);
                log.Info("кол-во в истории " + auditRecordList.Count);

                if (auditRecordList.Count > 0)
                {
                    foreach (AuditRecord audit in auditRecordList)
                    {
                        QCBugHistory bugHistory = new QCBugHistory();
                        bugHistory.actionType = audit["AU_ACTION"];
                        bugHistory.changeDate = audit["AU_TIME"];

                        AuditPropertyFactory auditPropertyFactory = audit.AuditPropertyFactory;

                        var changesHistoryFilter = auditPropertyFactory.Filter;
                        changesHistoryFilter["AP_PROPERTY_NAME"] = "Status";

                        var changesList = auditPropertyFactory.NewList(changesHistoryFilter.Text);
                        //var changesList = auditPropertyFactory.NewList("");
                        if (changesList.Count > 0)
                        {
                            foreach (AuditProperty prop in changesList)
                            {
                                //prop.EntityID
                                if (prop["AP_PROPERTY_NAME"] == "Status")
                                {
                                    bugHistory.oldValue = prop["AP_OLD_VALUE"];
                                    bugHistory.newValue = prop["AP_NEW_VALUE"];
                                    history.Add(bugHistory);
                                }
                            }
                        }

                    }
                }
            }
        }
        catch (Exception e)
        {
            log.Error("Проблема соединения и получения данных из QC ", e);
        }

        return history;
    }      

1 个答案:

答案 0 :(得分:0)

试试这个(在C#中):

1)只有BUG ID参数( BUGID ):

BugFactory bgFact = TDCONNECTION.BugFactory;
TDFilter bgFilt = bgFact.Filter;
bgFilt["BG_BUG_ID"] = BUGID; // This is a STRING

List bugs = bgFilt.NewList();

Bug bug = bugs[1]; // is 1-based
bug.History;

2)拥有Bug对象本身,只需执行:

bug.History;