【问题标题】:How to find the Field names in Defects in HP ALM?如何在 HP ALM 的缺陷中查找字段名称?
【发布时间】:2014-06-20 09:04:19
【问题描述】:

我正在从 HP ALM 检索字段。但是在这里我很难获得字段名称。

 BugFactory bf = (BugFactory)qcc.BugFactory;
 List bugs = (List)bf.NewList(bf.Filter.Text); 

string b5 = Convert.ToString(bg["BG_PROJECT"]); 
string b6 = Convert.ToString(bg["BG_STATUS"]);
string b7 = Convert.ToString(bg["BG_TARGET_CYCLE"]); 

前两个可以得到结果,最后一个语句显示 Invalid field name 错误。

请告诉我获取字段名称的正确方法。

谢谢。

【问题讨论】:

    标签: c# hp-quality-center alm


    【解决方案1】:

    查看我对这个问题的回答:

    HP Quality Center field names

    它有一些示例代码,展示了如何以编程方式确定给定工厂对象的字段。您拥有 BugFactory 对象,这是一个完美的开始。

    【讨论】:

      【解决方案2】:

      你可以使用工厂的Filter,例如下一个是AuditRecord你可以和BugFactory一样使用

      AuditRecordFactory auditLog = this.ALMConnection.AuditRecordFactory as AuditRecordFactory;
      var auditLogFilter = auditLog.Filter as ITDFilter;
      //Get the field list
      List fieldList= auditLogFilter.Fields;
      

      更新:我在这里找到了完整的答案 https://stackoverflow.com/a/24368561/3915468 :)

      @TheArtTrooper 使用下一个方法提供了一个很好的答案

      private void ExploreFactoryFieldDefinitions(IBaseFactory factory)
          {
              List fields = factory.Fields;
      
              foreach (TDField field in fields)
              {
                  FieldProperty field_property = (FieldProperty)field.Property;
      
                  if (field_property.IsRequired)
                  {
                      Log(String.Format("User Label: {0}\n", field_property.UserLabel));
                      Log(String.Format("User Column Type: {0}\n", field_property.UserColumnType));
                      Log(String.Format("DB Column Name: {0}\n", field_property.DBColumnName));
                      Log(String.Format("DB Column Type: {0}\n", field_property.DBColumnType));
                      Log(String.Format("DB Table Name: {0}\n", field_property.DBTableName));
                  }
              }
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多