【问题标题】:how to get history info from QC using OTA如何使用 OTA 从 QC 获取历史信息
【发布时间】:2015-12-23 11:22:41
【问题描述】:

在我的代码下方,从 QC 获取错误历史信息。我有问题

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;
    }      

【问题讨论】:

  • 对不起我的纯粹描述。为了过滤 AuditPropertyFactory,我使用这个条件 if (prop["AP_PROPERTY_NAME"] == "Status") 而不是使用 Filter 类

标签: c# ota hp-quality-center


【解决方案1】:

试试这个(在 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;

【讨论】:

  • 我担心过滤器“changesHistoryFilter["AP_PROPERTY_NAME"]”不起作用。我必须使用 if 语句来获取我需要的数据。我想使用上面的过滤器和字符串 "var changesList = auditPropertyFactory.NewList("");"获取所需的数据,但它不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多