/// <summary> /// Get changed BUGs from last modified time /// </summary> /// <param name="LastModifiedTime"></param> /// <returns></returns> public DatastoreItems GetBugListStartingFrom(DateTime LastModifiedTime) { string psQueryXml = "<Query>"; psQueryXml += "<Group GroupOperator='And'>"; psQueryXml += "<Expression Column='Changed Date' Operator='equalsGreater'><DateTime>" + LastModifiedTime.ToUniversalTime().ToString() + "</DateTime></Expression>"; //psQueryXml += "<Expression Column='Status' Operator='notequals'><String>Closed</String></Expression>"; psQueryXml += "</Group>"; psQueryXml += "</Query>"; DatastoreItemList psDataList = null; try { Query psQuery = new Query(); psQuery.CountOnly = false; psQuery.SelectionCriteria = psQueryXml; psDataList = new DatastoreItemList(); psDataList.Query = psQuery; psDataList.Datastore = this.psDataStore; psDataList.Execute(); } catch (Exception e) { throw new Exception(String.Format("Failed to Query bugs."), e); } return(psDataList.DatastoreItems); }
//------------------------------------------------------------------------------------ /// <summary> /// Executes the given query against this data store. Returns false if a cancellation /// request is detected via the given taskWorker. /// </summary> //------------------------------------------------------------------------------------ public BackgroundTaskResult ExecuteQuery(IRepository repository, BaseQuery query, ShouldRefresh shouldRefresh, BackgroundTask taskWorker, bool deferItemCreation) { DatastoreItemList storeItemList = GetStoreItemList(); FieldDefinitions fieldDefs = storeItemList.Datastore.FieldDefinitions; // Set up a query, using QueryDefinition to define the query XML ProductStudio.Query psQuery = new ProductStudio.Query(); psQuery.CountOnly = false; psQuery.DatastoreItemType = PsDatastoreItemTypeEnum.psDatastoreItemTypeBugs; psQuery.SelectionCriteria = query.QueryXml; psQuery.QueryFields.Clear(); psQuery.QuerySortFields.Clear(); psQuery.QuerySortFields.Add(fieldDefs["ID"], PsSortTypeEnum.psSortTypeDescending); // Execute the query try { storeItemList.Query = psQuery; storeItemList.Execute(); } catch (Exception e) { return(new BackgroundTaskResult { ResultType = ResultType.Failed, ResultMessage = e.Message }); } Planner.Instance.WriteToEventLog(StoreName + ": Query results count: " + storeItemList.DatastoreItems.Count.ToString()); repository.ReceiveDSItems(this, storeItemList.DatastoreItems, shouldRefresh, deferItemCreation); return(new BackgroundTaskResult { ResultType = ResultType.Completed }); }
/// <summary> /// Get changed BUGs from last modified time /// </summary> /// <param name="LastModifiedTime"></param> /// <returns></returns> public DatastoreItems GetBugListStartingFrom(DateTime LastModifiedTime) { string psQueryXml = "<Query>"; psQueryXml += "<Group GroupOperator='And'>"; psQueryXml += "<Expression Column='Changed Date' Operator='equalsGreater'><DateTime>" + LastModifiedTime.ToUniversalTime().ToString() + "</DateTime></Expression>"; //psQueryXml += "<Expression Column='Status' Operator='notequals'><String>Closed</String></Expression>"; psQueryXml += "</Group>"; psQueryXml += "</Query>"; DatastoreItemList psDataList = null; try { Query psQuery = new Query(); psQuery.CountOnly = false; psQuery.SelectionCriteria = psQueryXml; psDataList = new DatastoreItemList(); psDataList.Query = psQuery; psDataList.Datastore = this.psDataStore; psDataList.Execute(); } catch (Exception e) { throw new Exception(String.Format("Failed to Query bugs."), e); } return psDataList.DatastoreItems; }