private UploadItemSelection CreateUploadItem(RepositoryItemBase item)
        {
            string strComment = "";
            UploadItemSelection uploadItem = new UploadItemSelection();

            uploadItem.Selected = true;

            UploadItemSelection.eExistingItemType existingItemType = UploadItemSelection.eExistingItemType.NA;
            RepositoryItemBase existingItem = ExistingItemCheck(item, ref strComment, ref existingItemType);

            if (existingItem != null)
            {
                uploadItem.ItemUploadType   = UploadItemSelection.eItemUploadType.Overwrite;
                uploadItem.ExistingItem     = existingItem;
                uploadItem.ExistingItemType = existingItemType;
                uploadItem.Comment          = strComment;
            }
            else
            {
                uploadItem.ItemUploadType = UploadItemSelection.eItemUploadType.New;
            }

            if (item is Activity)
            {
                Activity activity = (Activity)item;

                if (activity.ActivitiesGroupID != null && activity.ActivitiesGroupID != string.Empty)
                {
                    ActivitiesGroup group = (ActivitiesGroup)Context.BusinessFlow.ActivitiesGroups.Where(x => x.Name == activity.ActivitiesGroupID).FirstOrDefault();
                    if (group != null)
                    {
                        ObservableList <ActivitiesGroup> repoGroups = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>();
                        ActivitiesGroup repoGroup = repoGroups.Where(x => (x.Guid == group.Guid) || (x.Guid == group.ParentGuid) || (group.ExternalID != null &&
                                                                                                                                     group.ExternalID != string.Empty && x.ExternalID == group.ExternalID)).FirstOrDefault();
                        if (repoGroup == null)
                        {
                            uploadItem.Comment = "It is recommended to also add parent activity group: " + group.ItemName + " to repository";
                        }
                    }
                }
            }

            uploadItem.ItemName = item.ItemName;
            uploadItem.ItemGUID = item.Guid;
            uploadItem.SetItemPartesFromEnum(GetTypeOfItemParts(item));
            uploadItem.UsageItem = item;

            return(uploadItem);
        }
        public RepositoryItem ExistingItemCheck(object item, ref string strComment, ref UploadItemSelection.eExistingItemType existingItemType)
        {
            IEnumerable <object> existingRepoItems = new ObservableList <RepositoryItem>();
            bool   existingItemIsExternalID        = false;
            bool   existingItemIsParent            = false;
            string existingItemFileName            = string.Empty;

            if (item is ActivitiesGroup)
            {
                existingRepoItems = (IEnumerable <object>)App.LocalRepository.GetSolutionRepoActivitiesGroups();
            }
            else if (item is Activity)
            {
                existingRepoItems = (IEnumerable <object>)App.LocalRepository.GetSolutionRepoActivities();
            }
            else if (item is Act)
            {
                existingRepoItems = (IEnumerable <object>)App.LocalRepository.GetSolutionRepoActions();
            }
            else if (item is VariableBase)
            {
                existingRepoItems = (IEnumerable <object>)App.LocalRepository.GetSolutionRepoVariables();
            }

            RepositoryItem exsitingItem = App.LocalRepository.GetMatchingRepoItem((RepositoryItem)item, existingRepoItems, ref existingItemIsExternalID, ref existingItemIsParent);

            if (exsitingItem != null)
            {
                existingItemFileName = exsitingItem.FileName;

                if (existingItemIsExternalID)
                {
                    strComment       = "Item with Same External Id Exist. Back up of existing item will be saved in PrevVersion folder.Change the item upload type if you want to upload it as new item";
                    existingItemType = UploadItemSelection.eExistingItemType.ExistingItemIsExternalID;
                }
                else if (existingItemIsParent)
                {
                    strComment       = "Parent item exist in repository. Back up of existing item will be saved in PrevVersion folder.Change the item upload type if you want to upload it as new item";
                    existingItemType = UploadItemSelection.eExistingItemType.ExistingItemIsParent;
                }
                else
                {
                    strComment       = "Item already exist in repository. Back up of existing item will be saved in PrevVersion folder.Change the item upload type if you want to upload it as new item";
                    existingItemType = UploadItemSelection.eExistingItemType.ExistingItemIsDuplicate;
                }
            }
            return(exsitingItem);
        }