0

Below My Code that gets info of Bug history from QC. I have problem with

AuditPropertyFactoryFilter which does not filter. AuditPropertyFactory has more than thousand rows.

If I comment var changesList = auditPropertyFactory.NewList(changesHistoryFilter.Text); and uncomment next line, auditPropertyFactory has several rows only but it isn't filtered as i need.

Can anyone get some advice?

  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;
    }      
Ilya
  • 141
  • 2
  • 14
  • I'm sorry for my pure description. To filter AuditPropertyFactory I use this condition if (prop["AP_PROPERTY_NAME"] == "Status") instead of using Filter class – Ilya Dec 23 '15 at 11:56

1 Answers1

0

Try this (in C#):


1) Having only BUG ID param (BUGID below):

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) Having the Bug object itself, just do:

bug.History;
icalvo
  • 111
  • 1
  • 3
  • My concern is the filter "changesHistoryFilter["AP_PROPERTY_NAME"]" doesn't work. i have to use if statement to get data that I need. I wanted use the filter above and string "var changesList = auditPropertyFactory.NewList("");" to get needed data, but it doesn't work. – Ilya May 22 '16 at 06:57