コード例 #1
0
        protected override void BuildQueryXML()
        {
            BeginQuery();
            BeginAndGroup();
            BeginOrGroup();
            foreach (ItemTypeID itemType in TypeList)
            {
                ItemTypeKey typeKey = Store.GetItemTypeKey(itemType);
                AddClause(Store.PropNameType, "Equals", typeKey.TypeName);

                if (Store.PropSubTypeName != null && typeKey.SubTypeName != Constants.c_Any)
                {
                    AddClause(Store.PropSubTypeName, "Equals", typeKey.SubTypeName);
                }
            }
            EndGroup();

            if (!string.IsNullOrEmpty(m_productGroupKey))
            {
                AddClause(Datastore.PropNameParentProductGroupKey, "Equals", m_productGroupKey);
            }

            if (!AddRefreshDateFilterClause(ShouldRefresh, RefreshType))
            {
                AddClause(Datastore.PropNameStatus, "Equals", StatusValues.Active);
            }

            EndGroup();
            EndQuery();
        }
コード例 #2
0
        private DatastoreItem GetDSItemOfType(ItemTypeID itemType)
        {
            DatastoreItem dsItem  = CreateDSItem();
            ItemTypeKey   typeKey = GetItemTypeKey(itemType);

            dsItem.Fields[PropNameType].Value = typeKey.TypeName;
            if (PropSubTypeName != null && typeKey.SubTypeName != Constants.c_Any)
            {
                dsItem.Fields[PropSubTypeName].Value = typeKey.SubTypeName;
            }

            return(dsItem);
        }
コード例 #3
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// returns the string used to represent the given ItemTypeID, as defined for this
        /// Datastore.
        /// </summary>
        //------------------------------------------------------------------------------------
        public ItemTypeKey GetItemTypeKey(ItemTypeID typeID)
        {
            foreach (KeyValuePair <string, Dictionary <string, ItemTypeID> > kvp in ItemTypes)
            {
                Dictionary <string, ItemTypeID> typeDict = kvp.Value;
                foreach (KeyValuePair <string, ItemTypeID> innerkvp in typeDict)
                {
                    if (innerkvp.Value == typeID)
                    {
                        ItemTypeKey key = new ItemTypeKey();
                        key.TypeName    = kvp.Key;
                        key.SubTypeName = innerkvp.Key;
                        return(key);
                    }
                }
            }

            ItemTypeKey unknownKey = new ItemTypeKey();

            unknownKey.TypeName = ItemTypeID.Unknown.ToString();
            return(unknownKey);
        }
コード例 #4
0
        BackgroundTaskResult CommitItemWorker(StoreItem item, List <StoreItem> newCommittedItems)
        {
            //try
            {
                Datastore store = item.Store;
                switch (item.ChangeAction)
                {
                case StoreChangeAction.Default:
                    if (item.IsNew)
                    {
                        item.DSItem = store.CreateDSItem();

                        ItemTypeKey typeKey = store.GetItemTypeKey(item.StoreItemType);
                        item.DSItem.Fields[store.PropNameType].Value = typeKey.TypeName;

                        if (store.PropSubTypeName != null && typeKey.SubTypeName != Constants.c_Any)
                        {
                            item.DSItem.Fields[store.PropSubTypeName].Value = typeKey.SubTypeName;
                        }

                        store.SaveItemWorker(item);
                        store.FinalizeAfterSave(item);
                        item.PersistState = PersistStates.PersistedToStore;
                        newCommittedItems.Add(item);
                    }
                    else
                    {
                        store.SaveItemWorker(item);
                        store.FinalizeAfterSave(item);
                    }
                    break;

                case StoreChangeAction.ResolveItem:
                    item.Status = StatusValues.Active;
                    store.ResolveStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.ResolveAndCloseItem:
                    store.ResolveStoreItemWorker(item);
                    store.CloseStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.CloseItem:
                    store.CloseStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;

                case StoreChangeAction.ActivateItem:
                    store.ActivateStoreItemWorker(item);
                    store.FinalizeAfterSave(item);
                    break;
                }

                return(new BackgroundTaskResult {
                    ResultType = ResultType.Completed
                });
            }

            //catch (Exception exception)
            //{
            //    Planner.ApplicationManager.HandleException(exception);
            //    return new BackgroundTaskResult { ResultType = ResultType.Failed, ResultMessage = exception.Message };
            //}
        }
コード例 #5
0
ファイル: HostItemQuery.cs プロジェクト: gvhung/OPlanner-2.0
        protected override void BuildQueryXML()
        {
            BeginQuery();
            BeginAndGroup();

            BeginOrGroup();
            foreach (ItemTypeID itemType in TypeList)
            {
                BeginAndGroup();
                ItemTypeKey typeKey = Store.GetItemTypeKey(itemType);
                AddClause(Store.PropNameType, "Equals", typeKey.TypeName);

                if (Store.PropSubTypeName != null && typeKey.SubTypeName != Constants.c_Any)
                {
                    AddClause(Store.PropSubTypeName, "Equals", typeKey.SubTypeName);
                }
                EndGroup();
            }
            EndGroup();

            if (Trains != null)
            {
                BeginOrGroup();
                foreach (TrainItem train in Trains)
                {
                    AddClause(Datastore.PropNameFixBy, "Equals", train.Title);
                }
                EndGroup();
            }


            if (GroupMembers.Count > 0)
            {
                BeginOrGroup();
                foreach (string alias in GroupMembers)
                {
                    AddClause(Datastore.PropNameAssignedTo, "Equals", alias);
                    AddClause(Datastore.PropNameResolvedBy, "Equals", alias);
                }

                if (TreeIDs != null && TreeIDs.Count > 0)
                {
                    foreach (int treeID in TreeIDs)
                    {
                        AddTreeIDUnderClause(treeID);
                    }
                }

                EndGroup();
            }

            // If this is a standard refresh, query only for items that have changed since
            // the last time the query was executed.
            if (!AddRefreshDateFilterClause(ShouldRefresh, RefreshType))
            {
                BeginOrGroup();
                AddClause(Datastore.PropNameStatus, "Equals", StatusValues.Active);
                //AddClause("Resolution", "Equals", "Fixed");
                EndGroup();
            }

            EndGroup();
            EndQuery();
        }