示例#1
0
        public AsyncObservableCollection <AllowedValue> GetDependentFieldAllowedValues(string dependentProp, string dependsOnProp, object dependsOnValue)
        {
            DatastoreItem dsItem = CreateDSItem();

            SetFieldValue(dsItem, dependsOnProp, dependsOnValue);
            return(GetFieldAllowedValues(dsItem, dependentProp));
        }
示例#2
0
 public void SaveImageFileAttachment(DatastoreItem dsItem, string propName, MemoryStream stream)
 {
     if (stream != null)
     {
         SaveFileAttachment(dsItem, propName + ".jpg", stream);
     }
 }
示例#3
0
        public string GetFullPathToFileAttachment(StoreItem item, string fileName)
        {
            try
            {
                DatastoreItem dsItem = item.DSItem;
                OpenForRead(dsItem);
                ProductStudio.Files files = dsItem.Files;
                foreach (ProductStudio.File file in files)
                {
                    if (StringUtils.StringsMatch(fileName, file.FileName))
                    {
                        string tempFile = FileUtils.GetFullPathToTempFile(file.FileName);
                        file.SaveToFile(tempFile, true);
                        return(tempFile);
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                item.CommitErrorState = CommitErrorStates.ErrorAccessingAttachmentShare;
                Planner.Instance.HandleStoreItemException(item, e);
                return(null);
            }
        }
示例#4
0
        //------------------------------------------------------------------------------------
        /// <summary>
        ///  Opens the associated file using the OS shell.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void ShowFile(StoreItem item, string filename)
        {
            DatastoreItem dsItem       = item.DSItem;
            string        tempFullPath = Path.Combine(Path.GetTempPath(), filename);

            try
            {
                OpenForRead(dsItem);
                foreach (ProductStudio.File file in dsItem.Files)
                {
                    if (StringUtils.StringsMatch(filename, file.FileName))
                    {
                        file.SaveToFile(tempFullPath, true);
                        if (System.IO.File.Exists(tempFullPath))
                        {
                            System.Diagnostics.Process.Start(tempFullPath);
                            break;
                        }
                    }
                }
            }

            catch (Exception e)
            {
                UserMessage.Show("Couldn't access the attached file: " + tempFullPath + " - " + e.Message);
            }
        }
示例#5
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a list of all the allowed values for the given Product Studio field, given
        /// the current state of the given item.
        /// </summary>
        //------------------------------------------------------------------------------------
        public virtual AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(StoreItem item, string propName)
        {
            DatastoreItem dsItem = null;

            if (item.DSItem == null)
            {
                if (item.StoreItemType == ItemTypeID.WorkItem)
                {
                    dsItem = GetDSItemOfType(ItemTypeID.WorkItem);
                }
                else if (item.StoreItemType == ItemTypeID.BacklogItem)
                {
                    dsItem = GetDSItemOfType(ItemTypeID.BacklogItem);
                }
                else
                {
                    dsItem = CreateDSItem();
                }
            }
            else
            {
                dsItem = item.DSItem;
            }

            OpenForRead(dsItem);
            return(GetFieldAllowedValues(dsItem, propName));
        }
示例#6
0
 private void ResetDSItem(DatastoreItem dsItem)
 {
     if (dsItem.ID > 0 && dsItem.IsOpenForEdit)
     {
         dsItem.Reset(true);
     }
 }
示例#7
0
        private void DeferStoreItem(Datastore store, DatastoreItem dsItem, IsRefresh isRefreshedItem)
        {
            DeferredStoreItem deferredItem = new DeferredStoreItem(store, dsItem, isRefreshedItem);

            m_deferredStoreItems.Add(deferredItem);
            DeferredItemCount++;
        }
示例#8
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a list of strings recapping the description change history for the given
        /// bug.
        /// </summary>
        //------------------------------------------------------------------------------------
        public string GetItemDescriptionHistory(StoreItem storeItem)
        {
            if (storeItem.IsNew)
            {
                return(null);
            }

            DatastoreItem dsItem = storeItem.DSItem;

            OpenForRead(dsItem);
            StringBuilder historyBuilder = new StringBuilder(2048);

            if (dsItem != null)
            {
                historyBuilder.Append(String.Format("{0}\n{1}", dsItem.TagLine, dsItem.TagContent));
                ProductStudio.DatastoreItemHistory history = dsItem.History;

                for (int i = 0; i < history.Count; ++i)
                {
                    historyBuilder.Append(String.Format("\n{0}\n{1}", history[i].TagLine, history[i].TagContent));
                }
            }

            return(historyBuilder.ToString());
        }
示例#9
0
 public DeferredStoreItem(Datastore itemStore, DatastoreItem dsItem, IsRefresh isRefreshedItem)
 {
     m_id            = -1;
     m_storeKey      = null;
     ItemStore       = itemStore;
     DSItem          = dsItem;
     IsRefreshedItem = isRefreshedItem;
 }
示例#10
0
        //------------------------------------------------------------------------------------
        private ItemTypeID GetDSItemType(DatastoreItem dsItem)
        {
            object typeValue    = dsItem.Fields[PropNameType].Value;
            object subtypeValue = PropSubTypeName == null ? null : dsItem.Fields[PropSubTypeName].Value;

            string subtype = subtypeValue == null ? null : subtypeValue.ToString();

            return(GetItemTypeID(typeValue.ToString(), subtype));
        }
示例#11
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Detects the item type represented by the given dsItem, and then creates a new
        /// StoreItem of the appropriate class, based on that dsItem.
        /// </summary>
        //------------------------------------------------------------------------------------
        public StoreItem CreateAndInitializeItemFromDS(DatastoreItem dsItem)
        {
            StoreItem storeItem = CreateItemOfTypeFromDS(dsItem);

            storeItem.PersistState = PersistStates.PersistedToStore;
            storeItem.DSItem       = dsItem;
            storeItem.StoreID      = StoreID;

            return(storeItem);
        }
示例#12
0
        public void ImportMgmtInfo(string dbName)
        {
            List <DatastoreItem> items = new List <DatastoreItem>();
            DatastoreItem        item  = new DatastoreItem();

            item.name = dbName;
            items.Add(item);

            writer.CreateDataStoreMgmtDB(items);
            Console.WriteLine("Imported Datastore management info to MongoDB!");
        }
示例#13
0
 //------------------------------------------------------------------------------------
 /// <summary>
 /// Internal help function to set a backing value in the given blank dsItem directly.
 /// </summary>
 //------------------------------------------------------------------------------------
 private void SetFieldValue(DatastoreItem dsItem, string dsPropName, object value)
 {
     if (dsItem != null)
     {
         Field field = dsItem.Fields[dsPropName];
         if (!field.IsReadOnly)
         {
             field.Value = value;
         }
     }
 }
示例#14
0
        public object GetItemValue(DatastoreItem dsItem, string dsPropName, string publicPropName)
        {
            object value;

            if (!CompositeRegistry.GetValueFromComposite(dsItem, dsPropName, publicPropName, out value))
            {
                value = GetBackingValue(dsItem, dsPropName);
            }

            return(value);
        }
示例#15
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);
        }
示例#16
0
        public HashSet <string> GetFieldAllowedValuesSet(string propName)
        {
            HashSet <string> valueSet = new HashSet <string>();
            DatastoreItem    dsItem   = CreateDSItem();

            ProductStudio.Field  field  = dsItem.Fields[propName];
            ProductStudio.Values values = field.ValidValues;
            foreach (object value in values)
            {
                valueSet.Add(value as string);
            }

            return(valueSet);
        }
示例#17
0
        public bool GetValueFromComposite(DatastoreItem dsItem, string dsPropName, string publicPropName, out object value)
        {
            value = null;
            if (!IsValueRegistered(dsPropName, publicPropName))
            {
                return(false);
            }

            CompositeIdentifier compositeID = m_registry[dsPropName][publicPropName];
            string compositeText            = TypeUtils.GetStringValue(Store.GetBackingValue(dsItem, compositeID.DSPropName));

            value = StringUtils.GetSubstring(compositeText, compositeID.Index, '^');
            return(true);
        }
示例#18
0
        private void SaveFileAttachment(DatastoreItem dsItem, string fileName, MemoryStream stream)
        {
            string fullFilePath = FileUtils.GetFullPathToTempFile(fileName);

            using (FileStream fStream = new FileStream(fullFilePath, FileMode.Create, FileAccess.Write))
            {
                stream.WriteTo(fStream);
                fStream.Close();
            }

            RemoveAttachedFile(dsItem, fullFilePath);
            dsItem.Files.AddEx(fullFilePath);
            Debug.WriteLine("dsItem.Files.AddEx: " + fullFilePath);
        }
示例#19
0
        public void QueueAttachedFileForRemoval(StoreItem item, string filename)
        {
            DatastoreItem dsItem = item.DSItem;
            int           index  = 0;

            foreach (ProductStudio.File file in dsItem.Files)
            {
                if (StringUtils.StringsMatch(filename, file.FileName))
                {
                    dsItem.Files.Remove(index);
                    break;
                }

                index++;
            }
        }
示例#20
0
        public AsyncObservableCollection <FileAttachment> GetAttachedFiles(StoreItem storeItem)
        {
            AsyncObservableCollection <FileAttachment> files = new AsyncObservableCollection <FileAttachment>();
            DatastoreItem dsItem = storeItem.DSItem;

            OpenForRead(dsItem);
            foreach (ProductStudio.File file in dsItem.Files)
            {
                if (!IsInternalAttachedFile(file.FileName))
                {
                    files.Add(new FileAttachment(file));
                }
            }

            return(files);
        }
示例#21
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the file names of all the attached files for this item.
        /// </summary>
        //------------------------------------------------------------------------------------
        public AsyncObservableCollection <string> GetAttachedFileNames(StoreItem storeItem)
        {
            AsyncObservableCollection <string> filenames = new AsyncObservableCollection <string>();
            DatastoreItem dsItem = storeItem.DSItem;

            OpenForRead(dsItem);
            foreach (ProductStudio.File file in dsItem.Files)
            {
                // Exclude internal-use-only attached files.
                if (!IsInternalAttachedFile(file.FileName))
                {
                    filenames.Add(file.FileName);
                }
            }

            return(filenames);
        }
示例#22
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Detects the item type represented by the given dsItem, and then creates a new
        /// StoreItem of the appropriate class, based on that dsItem.
        /// </summary>
        //------------------------------------------------------------------------------------
        private StoreItem CreateItemOfTypeFromDS(DatastoreItem dsItem)
        {
            ItemTypeID typeID = GetDSItemType(dsItem);

            switch (typeID)
            {
            case ItemTypeID.ProductGroup:
                return(new ProductGroupItem());

            case ItemTypeID.Train:
                return(new TrainItem());

            case ItemTypeID.ScrumTeam:
                return(new ScrumTeamItem());

            case ItemTypeID.Pillar:
                return(new PillarItem());

            case ItemTypeID.GroupMember:
                return(new GroupMemberItem());

            case ItemTypeID.BacklogItem:
                return(new BacklogItem());

            case ItemTypeID.WorkItem:
                return(new WorkItem());

            case ItemTypeID.OffTime:
                return(new OffTimeItem());

            case ItemTypeID.Experience:
                return(new ExperienceItem());

            case ItemTypeID.Persona:
                return(new PersonaItem());

            case ItemTypeID.PlannerBug:
                return(new PlannerBugItem());

            case ItemTypeID.HelpContent:
                return(new HelpContentItem());

            default:
                throw new ApplicationException("No CreateStoreItemOfTypeFromDS handler for the requested item type!");
            }
        }
示例#23
0
        public bool AddDataStore(string datastoreName)
        {
            if (IsDataStoreExist(datastoreName))
            {
                return(false);
            }

            DatastoreItem item = new DatastoreItem();

            item.name = datastoreName;

            IMongoDatabase db = client.GetDatabase(this.mgmtDatabaseName);
            IMongoCollection <DatastoreItem> collection = db.GetCollection <DatastoreItem>("DataStores");

            collection.InsertOne(item);

            return(true);
        }
示例#24
0
        /// <summary>
        /// Clone Bug
        /// </summary>
        /// <param name="bugId"></param>
        /// <param name="targetConnectDomain"></param>
        /// <param name="targetProductName"></param>
        public void CloneBug(int bugId, string targetConnectDomain, string targetProductName)
        {
            DatastoreItem psItem      = null;
            DatastoreItem psCloneItem = null;

            ProductStudio.Directory psTargetDirectory = null;
            Product   psTargetProduct   = null;
            Datastore psTargetDataStore = null;

            try
            {
                if (targetConnectDomain != null && targetProductName != null)
                {
                    psTargetDirectory = new ProductStudio.Directory();
                    psTargetDirectory.Connect(targetConnectDomain, "", "");
                    psTargetProduct   = psTargetDirectory.GetProductByName(targetProductName);
                    psTargetDataStore = psTargetProduct.Connect("", "", "");
                }
                else
                {
                    psTargetDataStore = this.psDataStore;
                }

                psItem = this.psDataStore.GetDatastoreItem(PsDatastoreItemTypeEnum.psDatastoreItemTypeBugs, bugId, null);

                psItem.Edit(PsItemEditActionEnum.psDatastoreItemEditActionReadOnly, null, PsApplyRulesMask.psApplyRulesAll);
                // Clone the item to the targetDataStore
                psCloneItem = psItem.Clone(psTargetDataStore);
                // Save the new item
                psCloneItem.Save(true);
            }
            catch (Exception e)
            {
                throw new Exception(String.Format("Failed to clone bug {0} to {1} database.",
                                                  bugId, targetProductName), e);
            }
            finally
            {
                if (psTargetDirectory != null)
                {
                    psTargetDirectory.Disconnect();
                }
            }
        }
示例#25
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns a list of all the allowed values for the given Product Studio field, given
        /// the current state of the given item.
        /// </summary>
        //------------------------------------------------------------------------------------
        private AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(DatastoreItem dsItem, string propName)
        {
            AsyncObservableCollection <AllowedValue> valueList = new AsyncObservableCollection <AllowedValue>();

            if (dsItem != null)
            {
                ProductStudio.Field  field  = dsItem.Fields[propName];
                ProductStudio.Values values = field.ValidValues;
                foreach (object value in values)
                {
                    valueList.Add(new AllowedValue {
                        Value = value
                    });
                }

                ResetDSItem(dsItem);
            }

            return(valueList);
        }
示例#26
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// If an attached file exists in the given item with the filename given in the
        /// specified full path, this routine removes it.
        /// </summary
        //------------------------------------------------------------------------------------
        private void RemoveAttachedFile(DatastoreItem dsItem, string fullFilePath)
        {
            string fileName = Path.GetFileName(fullFilePath);

            if (dsItem != null)
            {
                ProductStudio.Files files = dsItem.Files;

                int indexToRemove = 0;
                foreach (ProductStudio.File file in files)
                {
                    if (file.FileName == fileName)
                    {
                        dsItem.Files.Remove(indexToRemove);
                        return;
                    }

                    indexToRemove++;
                }
            }
        }
示例#27
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the value of the given property directly from the backing store.
        /// </summary>
        //------------------------------------------------------------------------------------
        public object GetBackingValue(DatastoreItem dsItem, string dsPropName)
        {
            if (dsItem == null)
            {
                return(null);
            }

            //try
            {
                if (MustBeOpenToRead(dsPropName))
                {
                    OpenForRead(dsItem);
                }

                return(dsItem.Fields[dsPropName].Value);
            }
            //catch (Exception exception)
            //{
            //    Planner.ApplicationManager.HandleException(exception);
            //    return null;
            //}
        }
示例#28
0
        public bool IsPropertyReadOnly(string propName)
        {
            if (ReadOnlyPropStates == null)
            {
                ReadOnlyPropStates = new Dictionary <string, bool>();
            }

            if (!ReadOnlyPropStates.ContainsKey(propName))
            {
                bool          isReadOnly = false;
                DatastoreItem dsItem     = CreateDSItem();
                Field         field      = dsItem.Fields[propName];
                if (field != null && field.IsReadOnly)
                {
                    isReadOnly = true;
                }

                ReadOnlyPropStates.Add(propName, isReadOnly);
            }

            return(ReadOnlyPropStates[propName]);
        }
示例#29
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Called when this item has been refreshed from the backing store.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void SyncItemFromStore(DatastoreItem dsItem)
        {
            // First, set the secondary backing store cache to the one just received.
            DSItem = dsItem;

            foreach (KeyValuePair <string, ItemProperty> kvp in ItemProperties)
            {
                // If our value hasn't changed, accept the value from the back-end store
                // if it's different from ours.
                ItemProperty itemProperty = kvp.Value;
                if (!itemProperty.IsValueChanged())
                {
                    SyncPropertyFromStore(itemProperty);
                }

                // Otherwise, put our in-memory changed value into the new backing store cache, so
                // that our value will still get persisted on the next commit operation.
                else
                {
                    Store.SetItemBackingValue(this, itemProperty.DSPropName, itemProperty.PublicPropName, itemProperty.CurrentValue);
                }
            }
        }
示例#30
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Pulls the StoreItem with the given store key from the backing store represented
        /// by that key.
        /// </summary>
        //------------------------------------------------------------------------------------
        public static StoreItem GetStoreItem(string storeKey)
        {
            if (string.IsNullOrWhiteSpace(storeKey))
            {
                return(null);
            }

            string store = StoreItem.GetStoreNameFromKey(storeKey);
            int    id    = StoreItem.GetIDFromKey(storeKey);

            Datastore datastore = null;

            if (!string.IsNullOrWhiteSpace(store) && id > 0)
            {
                if (StringUtils.StringsMatch(store, ScheduleStore.Instance.StoreName))
                {
                    datastore = ScheduleStore.Instance;
                }
                else if (StringUtils.StringsMatch(store, HostItemStore.Instance.StoreName))
                {
                    datastore = HostItemStore.Instance;
                }
            }

            if (datastore != null)
            {
                DatastoreItem dsItem = datastore.DSItemByID(id);
                if (dsItem != null)
                {
                    StoreItem item = datastore.CreateAndInitializeItemFromDS(dsItem);
                    item.ID = id;
                    return(item);
                }
            }

            return(null);
        }