Example #1
0
        public override RepositoryItemBase GetUpdatedRepoItem(RepositoryItemBase itemToUpload, RepositoryItemBase existingRepoItem, string itemPartToUpdate)
        {
            Activity updatedActivity = null;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(eItemParts), itemPartToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:

            case eItemParts.Details:
                updatedActivity = (Activity)itemToUpload.CreateCopy(false);

                if (ePartToUpdate == eItemParts.Details)
                {
                    updatedActivity.Acts      = ((Activity)existingRepoItem).Acts;
                    updatedActivity.Variables = ((Activity)existingRepoItem).Variables;
                }

                break;

            case eItemParts.Actions:
                updatedActivity      = (Activity)existingRepoItem.CreateCopy(false);
                updatedActivity.Acts = ((Activity)itemToUpload).Acts;
                break;

            case eItemParts.Variables:
                updatedActivity           = (Activity)existingRepoItem.CreateCopy(false);
                updatedActivity.Variables = ((Activity)itemToUpload).Variables;
                break;
            }

            return(updatedActivity);
        }
Example #2
0
        public override RepositoryItemBase GetUpdatedRepoItem(RepositoryItemBase itemToUpload, RepositoryItemBase existingRepoItem, string itemPartToUpdate)
        {
            ActivitiesGroup updatedGroup = null;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(eItemParts), itemPartToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:
            case eItemParts.Details:
                updatedGroup = (ActivitiesGroup)itemToUpload.CreateCopy(false);

                if (ePartToUpdate == eItemParts.Details)
                {
                    updatedGroup.ActivitiesIdentifiers = ((ActivitiesGroup)existingRepoItem).ActivitiesIdentifiers;
                }

                break;

            case eItemParts.Activities:
                updatedGroup = (ActivitiesGroup)existingRepoItem.CreateCopy(false);
                updatedGroup.ActivitiesIdentifiers = ((ActivitiesGroup)itemToUpload).ActivitiesIdentifiers;
                break;
            }

            return(updatedGroup);
        }
        public Boolean UploadItemToRepository(Context context, UploadItemSelection itemToUpload)
        {
            try
            {
                RepositoryItemBase item         = itemToUpload.UsageItem;
                string             itemFileName = string.Empty;
                RepositoryItemBase itemCopy     = null;
                bool isOverwrite = false;
                if (itemToUpload.ItemUploadType == UploadItemSelection.eItemUploadType.Overwrite)
                {
                    isOverwrite = true;
                    itemCopy    = GetItemToOverrite(itemToUpload);
                }
                else
                {
                    itemCopy = (RepositoryItemBase)item.CreateCopy(false);
                }

                itemCopy.UpdateItemFieldForReposiotryUse();



                bool blockingIssuesHandled = HandleItemValidationIssues(context, itemToUpload, itemCopy, ref isOverwrite);

                if (blockingIssuesHandled == false)
                {
                    itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.FailedToUpload;
                    return(false);
                }

                if (isOverwrite)
                {
                    WorkSpace.Instance.SolutionRepository.MoveSharedRepositoryItemToPrevVersion(itemToUpload.ExistingItem);

                    RepositoryFolderBase repositoryFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryFolderByPath(itemToUpload.ExistingItem.ContainingFolderFullPath);
                    repositoryFolder.AddRepositoryItem(itemCopy);
                }
                else
                {
                    WorkSpace.Instance.SolutionRepository.AddRepositoryItem(itemCopy);
                }

                itemToUpload.UsageItem.IsSharedRepositoryInstance = true;

                if (itemToUpload.ExistingItemType == UploadItemSelection.eExistingItemType.ExistingItemIsParent && itemToUpload.ItemUploadType == UploadItemSelection.eItemUploadType.New)
                {
                    itemToUpload.UsageItem.ParentGuid = Guid.Empty;
                }

                itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.Uploaded;
                return(true);
            }
            catch (Exception e)
            {
                Reporter.ToLog(eLogLevel.ERROR, "failed to upload the repository item", e);
                itemToUpload.ItemUploadStatus = UploadItemSelection.eItemUploadStatus.FailedToUpload;
                return(false);
            }
        }
Example #4
0
        public override RepositoryItemBase GetUpdatedRepoItem(RepositoryItemBase itemToUpload, RepositoryItemBase existingRepoItem, string itemPartToUpdate)
        {
            VariableBase updatedVariable = null;

            //update required part
            eItemParts ePartToUpdate = (eItemParts)Enum.Parse(typeof(VariableBase.eItemParts), itemPartToUpdate);

            switch (ePartToUpdate)
            {
            case eItemParts.All:
                updatedVariable = (VariableBase)itemToUpload.CreateCopy(false);

                break;
            }

            return(updatedVariable);
        }
Example #5
0
        private void DirtyFileAutoSave(RepositoryItemBase itemToSave)
        {
            try
            {
                RepositoryItemBase itemCopy = itemToSave.CreateCopy(false);

                //create similar folders structure
                string itemAutoSavePath   = itemToSave.FilePath.Replace(WorkSpace.Instance.Solution.Folder, mAutoSaveFolderPath);
                string itemAutoSaveFolder = Path.GetDirectoryName(itemAutoSavePath);
                if (!Directory.Exists(itemAutoSaveFolder))
                {
                    Directory.CreateDirectory(itemAutoSaveFolder);
                }

                //save item
                itemCopy.RepositorySerializer.SaveToFile(itemCopy, itemAutoSavePath);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("AutoSave: Failed to AutoSave the item:'{0}'", itemToSave.ItemName), ex);
            }
        }
Example #6
0
        private void DirtyFileAutoSave(RepositoryItemBase itemToSave)
        {
            try
            {
                RepositoryItemBase itemCopy = itemToSave.CreateCopy(false);

                //create smiliar folders structure
                string ItemOriginalpath     = itemToSave.ContainingFolderFullPath;
                string ItemContainingfolder = itemToSave.ContainingFolder;
                string itemAutoSavePath     = ItemOriginalpath.Replace(ItemOriginalpath, mAutoSaveFolderPath);
                itemAutoSavePath = Path.Combine(itemAutoSavePath, ItemContainingfolder);
                if (!Directory.Exists(itemAutoSavePath))
                {
                    Directory.CreateDirectory(itemAutoSavePath);
                }

                //save item
                itemCopy.SaveToFile(Path.Combine(itemAutoSavePath, itemCopy.FileName.ToString()));
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, string.Format("AutoSave: Failed to AutoSave the item:'{0}'", itemToSave.ItemName), ex);
            }
        }