///-------------------------------------------------------------------------------- /// <summary>This method applies spectemplate deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteSpecTemplatePerformed(SpecTemplateEventArgs data) { try { #region protected if (data != null && data.SpecTemplate != null) { SpecTemplateViewModel template = RemoveTemplate(data.SpecTemplate.TemplateID); if (template != null && System.IO.File.Exists(template.SpecTemplate.FilePath)) { // delete file System.IO.File.Delete(template.SpecTemplate.FilePath); } else { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } #endregion protected } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
///-------------------------------------------------------------------------------- /// <summary>This method processes the new spectemplate command.</summary> ///-------------------------------------------------------------------------------- public void ProcessNewSpecTemplateCommand() { SpecTemplateEventArgs message = new SpecTemplateEventArgs(); message.SpecTemplate = new SpecTemplate(); message.SpecTemplate.TemplateID = Guid.NewGuid(); message.SpecTemplate.SolutionID = Solution.SolutionID; message.SpecTemplate.Solution = Solution; message.SolutionID = Solution.SolutionID; message.SpecTemplate.Solution = Solution; message.Solution = Solution; message.WorkspaceID = WorkspaceID; #region protected message.SpecTemplate.SpecificationDirectory = SpecificationDirectory; if (String.IsNullOrEmpty(message.SpecTemplate.SpecificationDirectory)) { message.SpecTemplate.SpecificationDirectory = Solution.SpecTemplatesDirectory; } if (TemplateModelNode == ModelContextTypeCode.Solution.ToString()) { message.SpecTemplate.NodeName = SpecModelContextTypeCode.SpecificationSource.ToString(); } else { ModelContextTypeCode modelContextType = ModelContextTypeCode.None; Enum.TryParse <ModelContextTypeCode>(TemplateModelNode, out modelContextType); if (modelContextType != ModelContextTypeCode.None) { message.SpecTemplate.NodeName = modelContextType.ToString(); } else { SpecModelContextTypeCode specModelContextType = SpecModelContextTypeCode.None; Enum.TryParse <SpecModelContextTypeCode>(TemplateModelNode, out specModelContextType); if (specModelContextType != SpecModelContextTypeCode.None) { message.SpecTemplate.NodeName = specModelContextType.ToString(); } } } #endregion protected Mediator.NotifyColleagues <SpecTemplateEventArgs>(MediatorMessages.Command_EditSpecTemplateRequested, message); }
///-------------------------------------------------------------------------------- /// <summary>This method applies spectemplate updates.</summary> ///-------------------------------------------------------------------------------- public void ProcessEditSpecTemplatePerformed(SpecTemplateEventArgs data) { try { #region protected try { if (data != null && data.SpecTemplate != null) { data.SpecTemplate.SaveTemplateFile(); data.SpecTemplate.HasErrors = false; if (!String.IsNullOrEmpty(data.SpecTemplate.TemplateContent)) { data.SpecTemplate.ParseContent(false); } if (!String.IsNullOrEmpty(data.SpecTemplate.TemplateOutput)) { data.SpecTemplate.ParseOutput(false); } RemoveTemplate(data.SpecTemplate.TemplateID, false); // new template view model SpecTemplateViewModel template = new SpecTemplateViewModel(data.SpecTemplate, Solution); AddTemplate(template); template.ShowInTreeView(); } } catch (System.Exception ex) { ShowException(ex); } #endregion protected } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }
///-------------------------------------------------------------------------------- /// <summary>This method applies solution deletes.</summary> ///-------------------------------------------------------------------------------- public void ProcessDeleteSolutionPerformed(SolutionEventArgs data) { try { bool isItemMatch = false; if (data != null && data.Solution != null) { foreach (SolutionViewModel item in Solutions.ToList <SolutionViewModel>()) { if (item.Solution.SolutionID == data.Solution.SolutionID) { // remove item from tabs, if present WorkspaceEventArgs message = new WorkspaceEventArgs(); message.ItemID = item.Solution.SolutionID; Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message); // delete children for (int i = item.Items.Count - 1; i >= 0; i--) { if (item.Items[i] is ViewViewModel) { ViewViewModel child = item.Items[i] as ViewViewModel; ViewEventArgs childMessage = new ViewEventArgs(); childMessage.View = child.View; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ViewsFolder.ProcessDeleteViewPerformed(childMessage); } if (item.Items[i] is DatabaseSourceViewModel) { DatabaseSourceViewModel child = item.Items[i] as DatabaseSourceViewModel; DatabaseSourceEventArgs childMessage = new DatabaseSourceEventArgs(); childMessage.DatabaseSource = child.DatabaseSource; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.SpecificationSourcesFolder.ProcessDeleteDatabaseSourcePerformed(childMessage); } if (item.Items[i] is XmlSourceViewModel) { XmlSourceViewModel child = item.Items[i] as XmlSourceViewModel; XmlSourceEventArgs childMessage = new XmlSourceEventArgs(); childMessage.XmlSource = child.XmlSource; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.SpecificationSourcesFolder.ProcessDeleteXmlSourcePerformed(childMessage); } if (item.Items[i] is ProjectViewModel) { ProjectViewModel child = item.Items[i] as ProjectViewModel; ProjectEventArgs childMessage = new ProjectEventArgs(); childMessage.Project = child.Project; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ProjectsFolder.ProcessDeleteProjectPerformed(childMessage); } if (item.Items[i] is FeatureViewModel) { FeatureViewModel child = item.Items[i] as FeatureViewModel; FeatureEventArgs childMessage = new FeatureEventArgs(); childMessage.Feature = child.Feature; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.FeaturesFolder.ProcessDeleteFeaturePerformed(childMessage); } if (item.Items[i] is WorkflowViewModel) { WorkflowViewModel child = item.Items[i] as WorkflowViewModel; WorkflowEventArgs childMessage = new WorkflowEventArgs(); childMessage.Workflow = child.Workflow; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.WorkflowsFolder.ProcessDeleteWorkflowPerformed(childMessage); } if (item.Items[i] is ModelViewModel) { ModelViewModel child = item.Items[i] as ModelViewModel; ModelEventArgs childMessage = new ModelEventArgs(); childMessage.Model = child.Model; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.ModelsFolder.ProcessDeleteModelPerformed(childMessage); } if (item.Items[i] is DiagramViewModel) { DiagramViewModel child = item.Items[i] as DiagramViewModel; DiagramEventArgs childMessage = new DiagramEventArgs(); childMessage.Diagram = child.Diagram; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.DiagramsFolder.ProcessDeleteDiagramPerformed(childMessage); } if (item.Items[i] is AuditPropertyViewModel) { AuditPropertyViewModel child = item.Items[i] as AuditPropertyViewModel; AuditPropertyEventArgs childMessage = new AuditPropertyEventArgs(); childMessage.AuditProperty = child.AuditProperty; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.AuditPropertiesFolder.ProcessDeleteAuditPropertyPerformed(childMessage); } if (item.Items[i] is SpecTemplateViewModel) { SpecTemplateViewModel child = item.Items[i] as SpecTemplateViewModel; SpecTemplateEventArgs childMessage = new SpecTemplateEventArgs(); childMessage.SpecTemplate = child.SpecTemplate; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.SpecTemplatesFolder.ProcessDeleteSpecTemplatePerformed(childMessage); } if (item.Items[i] is CodeTemplateViewModel) { CodeTemplateViewModel child = item.Items[i] as CodeTemplateViewModel; CodeTemplateEventArgs childMessage = new CodeTemplateEventArgs(); childMessage.CodeTemplate = child.CodeTemplate; childMessage.SolutionID = item.Solution.SolutionID; childMessage.Solution = Solution; childMessage.WorkspaceID = child.WorkspaceID; item.CodeTemplatesFolder.ProcessDeleteCodeTemplatePerformed(childMessage); } } // delete item isItemMatch = true; Solutions.Remove(item); Items.Remove(item); OnUpdated(this, null); break; } } if (isItemMatch == false) { ShowIssue(DisplayValues.Issue_DeleteItemNotFound); } } } catch (Exception ex) { ShowIssue(ex.Message + ex.StackTrace); } }