Esempio n. 1
0
        private DatastoreItemList GetStoreItemList(bool cacheStoreItemList = true)
        {
            try
            {
                if (m_storeItemList == null || ConnectionTime.Elapsed.Minutes > MaxConnectionMinutes)
                {
                    ConnectionTime.Reset();
                    ProductStudio.Directory psDir = new ProductStudio.Directory();
                    psDir.Connect();

                    ProductStudio.Product psProduct     = psDir.GetProductByName(StoreID.Name);
                    DatastoreItemList     storeItemList = new DatastoreItemList();
                    storeItemList.Datastore = psProduct.Connect();

                    // Simulate outdated Product Studio error
                    //if (storeItemList.Datastore == null || storeItemList.Datastore != null)
                    //{
                    //    throw new Exception("[Product Studio] 80044005. Access to this product requires updated client components.");
                    //}

                    ConnectionTime.Start();

                    FieldDefs = storeItemList.Datastore.FieldDefinitions;

                    if (cacheStoreItemList)
                    {
                        m_storeItemList = storeItemList;
                    }
                    else
                    {
                        return(storeItemList);
                    }
                }

                return(m_storeItemList);
            }

            catch (Exception exception)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Unable to connect to " + StoreID.Name);
                sb.AppendLine();
                sb.AppendLine(exception.Message);
                sb.AppendLine();
                Planner.Instance.WriteToEventLog(sb.ToString());

                throw new Exception(sb.ToString());
            }
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
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();
                }
            }
        }