private bool HandleItemValidationIssues(Context context, UploadItemSelection selectedItem, RepositoryItemBase itemCopy, ref bool isOverwrite)
        {
            bool blockingIssuesHandled           = true;
            List <ItemValidationBase> itemIssues = ItemValidationBase.GetAllIssuesForItem(selectedItem);

            if (itemIssues != null && itemIssues.Count > 0)
            {
                foreach (ItemValidationBase issue in itemIssues)
                {
                    switch (issue.mIssueType)
                    {
                    case ItemValidationBase.eIssueType.MissingVariables:
                        if (issue.Selected)
                        {
                            foreach (string missingVariableName in issue.missingVariablesList)
                            {
                                VariableBase missingVariable = context.BusinessFlow.GetHierarchyVariableByName(missingVariableName);

                                if (missingVariable != null)
                                {
                                    ((Activity)itemCopy).Variables.Add(missingVariable);
                                }
                            }

                            selectedItem.Comment = "Missing " + GingerDicser.GetTermResValue(eTermResKey.Variable) + " added to " + GingerDicser.GetTermResValue(eTermResKey.Activity);
                        }
                        else
                        {
                            selectedItem.Comment = "Uploaded without adding missing " + GingerDicser.GetTermResValue(eTermResKey.Variables);
                        }
                        break;

                    case ItemValidationBase.eIssueType.DuplicateName:
                        if (issue.Selected)
                        {
                            isOverwrite          = false;
                            itemCopy.ItemName    = issue.ItemNewName;
                            selectedItem.Comment = "Uploaded with new newm" + issue.ItemNewName;
                        }
                        else
                        {
                            selectedItem.Comment  = "Can not upload the item with same name";
                            blockingIssuesHandled = false;    // if user do not accept new name, upload can not proceed for the item
                        }
                        break;
                    }
                }
            }
            return(blockingIssuesHandled);
        }
Beispiel #2
0
        public static void Validate(UploadItemSelection selectedItem)
        {
            bool isDuplicateFound = CheckForItemWithDuplicateName(selectedItem);

            if (isDuplicateFound)
            {
                ItemValidationBase VA = ItemValidationBase.CreateNewIssue((RepositoryItemBase)selectedItem.UsageItem);
                VA.IssueDescription = "Item with same name already exists";
                VA.mIssueType       = ItemValidationBase.eIssueType.DuplicateName;
                VA.ItemNewName      = GetUniqueItemName(selectedItem);
                VA.IssueResolution  = "Item will be uploaded with new name: " + VA.ItemNewName;
                VA.Selected         = true;
                ItemValidationBase.mIssuesList.Add(VA);
            }
            switch (selectedItem.UsageItem.GetType().Name)
            {
            case "Activity":
                ValidateActivity.Validate((Activity)selectedItem.UsageItem);
                break;
            }
        }