public LocationsTreeViewModel(ObservableCollection<Location> locations) { Locations = new ObservableList<LocationNode>(); foreach (var location in locations) Locations.Add(new LocationNode(location)); locations.CollectionChanged += (s, e) => { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location)); break; case NotifyCollectionChangedAction.Remove: foreach (Location location in e.OldItems) { var item = Locations.FirstOrDefault(l => l.Location.Guid == location.Guid); if (item != null) Locations.Remove(item); } break; case NotifyCollectionChangedAction.Replace: foreach (Location location in e.OldItems) { var item = Locations.FirstOrDefault(l => l.Location.Guid == location.Guid); if (item != null) Locations.Remove(item); } foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location)); break; case NotifyCollectionChangedAction.Reset: Locations.Clear(); foreach (Location location in e.NewItems) Locations.Add(new LocationNode(location)); break; } }; LocationsTreeViewSource = new CollectionViewSource { Source = Locations }; LocationsTreeViewSource.SortDescriptions.Add(new SortDescription("Location.Name", ListSortDirection.Ascending)); }
public void AddOptionToFilterGroup(string groupID, string optionDisplay, string optionID) { var group = _FilterGroups.FirstOrDefault(g => string.Equals(g.ID, groupID, StringComparison.OrdinalIgnoreCase)); if (group != null) { group.AddItem(optionID, optionDisplay); } }
public override void Execute(ReportInfo RI) { if ((WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList != null) && (WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.Count > 0)) { Dictionary <Guid, Dictionary <string, string> > defectsForOpening = new Dictionary <Guid, Dictionary <string, string> >(); ObservableList <ALMDefectProfile> ALMDefectProfiles = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ALMDefectProfile>(); ALMDefectProfile defaultALMDefectProfile = new ALMDefectProfile(); if ((ALMDefectProfiles != null) && (ALMDefectProfiles.Count > 0)) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.ID == SelectedDefectsProfileID).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.IsDefault).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.FirstOrDefault(); } } } if (DefectsOpeningModeForMarked) { foreach (DefectSuggestion defectSuggestion in WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.Where(x => x.AutomatedOpeningFlag == true).ToList()) { Dictionary <string, string> currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.Description : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else if (DefectsOpeningModeForAll) { foreach (DefectSuggestion defectSuggestion in WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList) { Dictionary <string, string> currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.Description : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else { return; } var defectFields = defaultALMDefectProfile.ALMDefectProfileFields.Where(a => a.Mandatory || a.ToUpdate).ToList(); RepositoryItemHelper.RepositoryItemFactory.CreateNewALMDefects(defectsForOpening, defectFields); } }
public void PopulateExcelDBOptionalValuesForAPIParametersExcelDB(ObservableList <GlobalAppModelParameter> mGlobalParamterList, List <GlobalAppModelParameter> SelectedParametersGridList, Dictionary <string, List <string> > ParameterValuesByNameDic) { int UpdatedParameters = 0; bool IsUpdate; List <GlobalAppModelParameter> RelevantParameterList = new List <GlobalAppModelParameter>(); foreach (GlobalAppModelParameter prm in SelectedParametersGridList) { GlobalAppModelParameter pOriginal = mGlobalParamterList.FirstOrDefault(p => p.ItemName == prm.ItemName); if (pOriginal != null) { RelevantParameterList.Add(pOriginal); } } foreach (var tuple in SelectedParametersGridList.Zip(RelevantParameterList, (x, y) => (x, y))) { IsUpdate = false; if (tuple.x.RequiredAsInput)//selected { if (ParameterValuesByNameDic.ContainsKey(tuple.y.ItemName)) { string[] paramExistingvalues = tuple.y.OptionalValuesString.Split(',');; OptionalValue defaultValue = tuple.y.OptionalValuesList.FirstOrDefault(x => x.IsDefault); foreach (string val in ParameterValuesByNameDic[tuple.y.ItemName]) { bool ValueAlreadyExists = paramExistingvalues.Any(x => x == val); if ((paramExistingvalues != null && !ValueAlreadyExists) && (defaultValue == null || defaultValue.Value != val)) { OptionalValue OptionalValue = new OptionalValue() { Value = val }; if (tuple.y.OptionalValuesList.Count == 0) { OptionalValue.IsDefault = true; } tuple.y.OptionalValuesList.Add(OptionalValue); IsUpdate = true; } } } } if (IsUpdate) { tuple.y.SaveBackup(); UpdatedParameters++; } } if (ShowMessage) { Reporter.ToUser(eUserMsgKeys.ParameterOptionalValues, UpdatedParameters); } }
private void XManualMatchBtn_Click(object sender, RoutedEventArgs e) { DeltaAPIModel deltaAPI = null; deltaAPI = GetFrameElementDataContext(sender) as DeltaAPIModel; if (deltaAPI != null) { int indexOfCurrentDelta = xApisSelectionGrid.DataSourceList.IndexOf(deltaAPI); SingleItemTreeViewSelectionPage apiModelTreeSelectionPage = null; AppApiModelsFolderTreeItem apiRoot = new AppApiModelsFolderTreeItem(WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <ApplicationAPIModel>()); apiModelTreeSelectionPage = new SingleItemTreeViewSelectionPage("API Models", eImageType.APIModel, apiRoot, SingleItemTreeViewSelectionPage.eItemSelectionType.Single, true, new System.Tuple <string, string>(nameof(ApplicationAPIModel.APIType), deltaAPI.learnedAPI.APIType.ToString())); apiModelTreeSelectionPage.xTreeView.Tree.RefresTreeNodeChildrens(apiRoot); List <object> selectedList = apiModelTreeSelectionPage.ShowAsWindow("Matching API Models", (Window)AddAPIModelWizard.mWizardWindow); ApplicationAPIModel selectedAPIModel = null; if (selectedList != null) { selectedAPIModel = selectedList.FirstOrDefault() as ApplicationAPIModel; //deltaAPI.matchingAPIModel = selectedAPIModel; ObservableList <ApplicationAPIModel> selectedMatchingAPIList = new ObservableList <ApplicationAPIModel>() { selectedAPIModel }; ObservableList <ApplicationAPIModel> apiModelsListLearned = new ObservableList <ApplicationAPIModel>() { deltaAPI.learnedAPI }; ObservableList <DeltaAPIModel> comparisonOutputDelta = APIDeltaUtils.DoAPIModelsCompare(apiModelsListLearned, selectedMatchingAPIList); deltaAPI = comparisonOutputDelta.FirstOrDefault(); xApisSelectionGrid.DataSourceList[indexOfCurrentDelta] = deltaAPI; } } }
public ContentItemModel GetItemByID(string id) { return(_Content.FirstOrDefault(c => string.Equals(c.ID, id, StringComparison.OrdinalIgnoreCase))); }
public override void Execute(ReportInfo RI) { if ((App.RunsetExecutor.DefectSuggestionsList != null) && (App.RunsetExecutor.DefectSuggestionsList.Count > 0)) { Dictionary <Guid, Dictionary <string, string> > defectsForOpening = new Dictionary <Guid, Dictionary <string, string> >(); ObservableList <ALMDefectProfile> ALMDefectProfiles = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ALMDefectProfile>(); ALMDefectProfile defaultALMDefectProfile = new ALMDefectProfile(); if ((ALMDefectProfiles != null) && (ALMDefectProfiles.Count > 0)) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.ID == SelectedDefectsProfileID).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.IsDefault).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.FirstOrDefault(); } } } if (DefectsOpeningModeForMarked) { foreach (DefectSuggestion defectSuggestion in App.RunsetExecutor.DefectSuggestionsList.Where(x => x.AutomatedOpeningFlag == true).ToList()) { Dictionary <string, string> currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.Description : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else if (DefectsOpeningModeForAll) { foreach (DefectSuggestion defectSuggestion in App.RunsetExecutor.DefectSuggestionsList) { Dictionary <string, string> currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.Description : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else { return; } Dictionary <Guid, string> defectsOpeningResults; if ((defectsForOpening != null) && (defectsForOpening.Count > 0)) { defectsOpeningResults = ALMIntegration.Instance.CreateNewALMDefects(defectsForOpening); } else { return; } if ((defectsOpeningResults != null) && (defectsOpeningResults.Count > 0)) { foreach (KeyValuePair <Guid, string> defectOpeningResult in defectsOpeningResults) { if ((defectOpeningResult.Value != null) && (defectOpeningResult.Value != "0")) { App.RunsetExecutor.DefectSuggestionsList.Where(x => x.DefectSuggestionGuid == defectOpeningResult.Key).ToList().ForEach(z => { z.ALMDefectID = defectOpeningResult.Value; z.IsOpenDefectFlagEnabled = false; }); } } } } }
public RouterOutput GetOutput(int index) => outputs.FirstOrDefault(ro => (ro.Index == index));
public RouterInput GetInput(int index) => inputs.FirstOrDefault(ri => (ri.Index == index));
public CharacterGroup GroupContainingCharacterId(string characterId) { return(CharacterGroups.FirstOrDefault(g => g.CharacterIds.Contains(characterId))); }
private void ActionItemsDiscarded(object sender, DiscardedActionItemsEventArgs <IActionItem> e) { var actionsToRemove = e.ActionItems.Select(x => actionItems.FirstOrDefault(y => y.ActionItem.Identifier == x.Identifier)).ToList(); actionsToRemove.ForEach(x => actionItems.Remove(x)); }
public override void Execute(ReportInfo RI) { if ((WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList != null) && (WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.Count > 0)) { Dictionary <Guid, Dictionary <string, string> > defectsForOpening = new Dictionary <Guid, Dictionary <string, string> >(); ObservableList <ALMDefectProfile> ALMDefectProfiles = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ALMDefectProfile>(); ALMDefectProfile defaultALMDefectProfile = new ALMDefectProfile(); if ((ALMDefectProfiles != null) && (ALMDefectProfiles.Count > 0)) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.ID == SelectedDefectsProfileID).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.Where(z => z.IsDefault).ToList().FirstOrDefault(); if (defaultALMDefectProfile == null) { defaultALMDefectProfile = ALMDefectProfiles.FirstOrDefault(); } } } if (DefectsOpeningModeForMarked) { foreach (DefectSuggestion defectSuggestion in WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList.Where(x => x.AutomatedOpeningFlag == true).ToList()) { Dictionary <string, string> currentALMDefectFieldsValues = new Dictionary <string, string>(); try { currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.ErrorDetails : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); } catch (Exception ex) { currentALMDefectFieldsValues.Add("Summary", defectSuggestion.Summary); currentALMDefectFieldsValues.Add("description", defectSuggestion.ErrorDetails); } currentALMDefectFieldsValues.Add("screenshots", String.Join(",", defectSuggestion.ScreenshotFileNames)); currentALMDefectFieldsValues.Add("ActivityGroupExternalID", defectSuggestion.ActivityGroupExternalID); currentALMDefectFieldsValues.Add("ActivityExternalID", defectSuggestion.ActivityExternalID); currentALMDefectFieldsValues.Add("BFExternalID1", defectSuggestion.BFExternalID.Item1); currentALMDefectFieldsValues.Add("BFExternalID2", defectSuggestion.BFExternalID.Item2); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else if (DefectsOpeningModeForAll) { foreach (DefectSuggestion defectSuggestion in WorkSpace.Instance.RunsetExecutor.DefectSuggestionsList) { Dictionary <string, string> currentALMDefectFieldsValues = new Dictionary <string, string>(); try { currentALMDefectFieldsValues = defaultALMDefectProfile.ALMDefectProfileFields.Where(z => (z.SelectedValue != null && z.SelectedValue != string.Empty) || z.ExternalID == "description" || z.ExternalID == "Summary" || z.ExternalID == "name").ToDictionary(x => x.ExternalID, x => x.SelectedValue != null ? x.SelectedValue.Replace("&", "&") : x.SelectedValue = string.Empty) .ToDictionary(w => w.Key, w => w.Key == "description" ? defectSuggestion.ErrorDetails : w.Value) .ToDictionary(w => w.Key, w => w.Key == "Summary" ? defectSuggestion.Summary : w.Value) .ToDictionary(w => w.Key, w => w.Key == "name" ? defectSuggestion.Summary : w.Value); } catch (Exception ex) { currentALMDefectFieldsValues.Add("Summary", defectSuggestion.Summary); currentALMDefectFieldsValues.Add("description", defectSuggestion.ErrorDetails); } currentALMDefectFieldsValues.Add("screenshots", String.Join(",", defectSuggestion.ScreenshotFileNames)); currentALMDefectFieldsValues.Add("ActivityGroupExternalID", defectSuggestion.ActivityGroupExternalID); currentALMDefectFieldsValues.Add("ActivityExternalID", defectSuggestion.ActivityExternalID); currentALMDefectFieldsValues.Add("BFExternalID1", defectSuggestion.BFExternalID.Item1); currentALMDefectFieldsValues.Add("BFExternalID2", defectSuggestion.BFExternalID.Item2); defectsForOpening.Add(defectSuggestion.DefectSuggestionGuid, currentALMDefectFieldsValues); } } else { return; } var defectFields = defaultALMDefectProfile.ALMDefectProfileFields.Where(a => a.Mandatory || a.ToUpdate).ToList(); //update alm type to open defect RepositoryItemHelper.RepositoryItemFactory.CreateNewALMDefects(defectsForOpening, defectFields, defaultALMDefectProfile.AlmType); } }
/// <summary> /// Get an entity from the world by the given entity id. /// </summary> /// <typeparam name="T">The type of entity we fetched.</typeparam> /// <param name="id">THe Id we want to search for.</param> /// <returns>A entity or default(T).</returns> public T GetEntity <T>(ushort entityId) where T : Entity { return((T)Entities.FirstOrDefault(entity => entity.Id == entityId)); }