public static bool CheckIfSureDoingChange(RepositoryItemBase item, string changeType) { RepositoryItemUsagePage usagePage = null; usagePage = new RepositoryItemUsagePage(item, true); if (usagePage.RepoItemUsages.Count > 0)//TODO: check if only one instance exist for showing the pop up for better performance { if (Reporter.ToUser(eUserMsgKey.AskIfWantsToChangeeRepoItem, item.GetNameForFileName(), usagePage.RepoItemUsages.Count, changeType) == Amdocs.Ginger.Common.eUserMsgSelection.Yes) { return(true); } else { return(false); } } return(true); }
private void FindUsages() { try { //TODO: check that retrieve also sub folder business flows ObservableList <BusinessFlow> BizFlows = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>(); foreach (BusinessFlow BF in BizFlows) { string businessFlowName = Amdocs.Ginger.Common.GeneralLib.General.RemoveInvalidFileNameChars(BF.Name); if (mRepoItem is Activity) { foreach (Activity a in BF.Activities) { if (a.ParentGuid == mRepoItem.Guid || a.Guid == mRepoItem.Guid || (mRepoItem.ExternalID != null && mRepoItem.ExternalID != string.Empty && mRepoItem.ExternalID != "0" && a.ExternalID == mRepoItem.ExternalID)) { //skip original if not needed if (!mIncludeOriginal) { if (a.Guid == mOriginalItem.Guid) { continue; } } Ginger.Repository.RepositoryItemUsage.eUsageTypes type; if (a.Guid == mRepoItem.Guid) { type = RepositoryItemUsage.eUsageTypes.Original; } else { type = RepositoryItemUsage.eUsageTypes.Instance; } RepositoryItemUsage itemUsage = new RepositoryItemUsage() { HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, businessFlowName), UsageItem = a, UsageItemName = a.ActivityName, UsageExtraDetails = "Number of Actions: " + a.Acts.Count().ToString(), UsageItemType = type, Selected = true, Status = RepositoryItemUsage.eStatus.NotUpdated }; itemUsage.SetItemPartesFromEnum(typeof(eItemParts)); RepoItemUsages.Add(itemUsage); } } } else if (mRepoItem is ActivitiesGroup) { foreach (ActivitiesGroup a in BF.ActivitiesGroups) { if (a.ParentGuid == mRepoItem.Guid || a.Guid == mRepoItem.Guid || (mRepoItem.ExternalID != null && mRepoItem.ExternalID != string.Empty && mRepoItem.ExternalID != "0" && a.ExternalID == mRepoItem.ExternalID)) { //skip original if not needed if (!mIncludeOriginal) { if (a.Guid == mOriginalItem.Guid) { continue; } } Ginger.Repository.RepositoryItemUsage.eUsageTypes type; if (a.Guid == mRepoItem.Guid) { type = RepositoryItemUsage.eUsageTypes.Original; } else { type = RepositoryItemUsage.eUsageTypes.Instance; } RepositoryItemUsage itemUsage = new RepositoryItemUsage() { HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, businessFlowName), UsageItem = a, UsageItemName = a.Name, UsageExtraDetails = "Number of " + GingerDicser.GetTermResValue(eTermResKey.Activities) + ": " + a.ActivitiesIdentifiers.Count().ToString(), UsageItemType = type, Selected = true, Status = RepositoryItemUsage.eStatus.NotUpdated }; itemUsage.SetItemPartesFromEnum(typeof(ActivitiesGroup.eItemParts)); RepoItemUsages.Add(itemUsage); } } } else if (mRepoItem is Act) { foreach (Activity activity in BF.Activities) { foreach (Act a in activity.Acts) { if (a.ParentGuid == mRepoItem.Guid || a.Guid == mRepoItem.Guid || (mRepoItem.ExternalID != null && mRepoItem.ExternalID != string.Empty && mRepoItem.ExternalID != "0" && a.ExternalID == mRepoItem.ExternalID)) { //skip original if not needed if (!mIncludeOriginal) { if (a.Guid == mOriginalItem.Guid) { continue; } } Ginger.Repository.RepositoryItemUsage.eUsageTypes type; if (a.Guid == mRepoItem.Guid) { type = RepositoryItemUsage.eUsageTypes.Original; } else { type = RepositoryItemUsage.eUsageTypes.Instance; } RepositoryItemUsage itemUsage = new RepositoryItemUsage() { HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, businessFlowName), HostActivity = activity, HostActivityName = activity.ActivityName, UsageItem = a, UsageItemName = a.Description, UsageExtraDetails = "", UsageItemType = type, Selected = true, Status = RepositoryItemUsage.eStatus.NotUpdated }; itemUsage.SetItemPartesFromEnum(typeof(Act.eItemParts)); RepoItemUsages.Add(itemUsage); } } } } else if (mRepoItem is VariableBase) { //search on Bus Flow level foreach (VariableBase a in BF.Variables) { if (a.ParentGuid == mRepoItem.Guid || a.Guid == mRepoItem.Guid || (mRepoItem.ExternalID != null && mRepoItem.ExternalID != string.Empty && mRepoItem.ExternalID != "0" && a.ExternalID == mRepoItem.ExternalID)) { //skip original if not needed if (!mIncludeOriginal) { if (a.Guid == mOriginalItem.Guid) { continue; } } Ginger.Repository.RepositoryItemUsage.eUsageTypes type; if (a.Guid == mRepoItem.Guid) { type = RepositoryItemUsage.eUsageTypes.Original; } else { type = RepositoryItemUsage.eUsageTypes.Instance; } RepositoryItemUsage itemUsage = new RepositoryItemUsage() { HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, businessFlowName), UsageItem = a, UsageItemName = a.Name, UsageExtraDetails = "Current Value: " + a.Value, UsageItemType = type, Selected = true, Status = RepositoryItemUsage.eStatus.NotUpdated }; itemUsage.SetItemPartesFromEnum(typeof(VariableBase.eItemParts)); RepoItemUsages.Add(itemUsage); } } //search on Activities level foreach (Activity activity in BF.Activities) { foreach (VariableBase a in activity.Variables) { if (a.ParentGuid == mRepoItem.Guid || a.Guid == mRepoItem.Guid || (mRepoItem.ExternalID != null && mRepoItem.ExternalID != string.Empty && mRepoItem.ExternalID != "0" && a.ExternalID == mRepoItem.ExternalID)) { //skip original if not needed if (!mIncludeOriginal) { if (a.Guid == mOriginalItem.Guid) { continue; } } Ginger.Repository.RepositoryItemUsage.eUsageTypes type; if (a.Guid == mRepoItem.Guid) { type = RepositoryItemUsage.eUsageTypes.Original; } else { type = RepositoryItemUsage.eUsageTypes.Instance; } RepositoryItemUsage itemUsage = new RepositoryItemUsage() { HostBusinessFlow = BF, HostBizFlowPath = Path.Combine(BF.ContainingFolder, businessFlowName), HostActivity = activity, HostActivityName = activity.ActivityName, UsageItem = a, UsageItemName = a.Name, UsageExtraDetails = "Current Value: " + a.Value, UsageItemType = type, Selected = true, Status = RepositoryItemUsage.eStatus.NotUpdated }; itemUsage.SetItemPartesFromEnum(typeof(VariableBase.eItemParts)); RepoItemUsages.Add(itemUsage); } } } } } } catch (Exception ex) { Reporter.ToUser(eUserMsgKey.GetRepositoryItemUsagesFailed, mRepoItem.GetNameForFileName(), ex.Message); } }