public async Task <IWorkflow> AddDefaultWorkflow() { var w = await Workflow.Create(this, "New Workflow"); // Workflows.Add(w); return(w); }
private async void onNew(object item) { try { if (item is Views.WFDesigner) { var designer = (Views.WFDesigner)item; Workflow workflow = Workflow.Create(designer.Project, "New Workflow"); onOpenWorkflow(workflow); return; } else { string Name = Microsoft.VisualBasic.Interaction.InputBox("Name?", "Name project", "New project"); if (string.IsNullOrEmpty(Name)) { return; } Project project = await Project.Create(Extensions.projectsDirectory, Name); Workflow workflow = project.Workflows.First(); workflow.Project = project; Projects.Add(project); onOpenWorkflow(workflow); } } catch (Exception ex) { Log.Error(ex, ""); MessageBox.Show(ex.Message); } }
public static async Task <Project> Create(string Path, string Name) { var basePath = System.IO.Path.Combine(Path, Name); var Filepath = System.IO.Path.Combine(Path, Name, Name.Replace(" ", "_").Replace(".", "") + ".rpaproj"); if (string.IsNullOrEmpty(Filepath)) { bool isUnique = false; int counter = 1; while (!isUnique) { if (counter == 1) { Filepath = System.IO.Path.Combine(Path, Name, Name.Replace(" ", "_").Replace(".", "") + ".rpaproj"); } else { Filepath = System.IO.Path.Combine(Path, Name, Name.Replace(" ", "_").Replace(".", "") + counter.ToString() + ".rpaproj"); } if (!System.IO.File.Exists(Filepath)) { isUnique = true; } counter++; } } if (!System.IO.Directory.Exists(basePath)) { System.IO.Directory.CreateDirectory(basePath); } if (System.IO.Directory.GetFiles(basePath).Count() > 0) { throw new Exception(basePath + " is not empty"); } Project p = new Project(); p._type = "project"; p.name = Name; p.Path = System.IO.Path.GetDirectoryName(Filepath); p.Filename = System.IO.Path.GetFileName(Filepath); p.Workflows = new System.Collections.ObjectModel.ObservableCollection <Workflow>(); await p.Save(); var w = Workflow.Create(p, "New Workflow"); p.Workflows.Add(w); await w.Save(); return(p); }