public void AddFlowToMenu(ActionFlow af) { MenuItem mi = new MenuItem(); mi.Header = af.Name; mi.Name = af.ID; mi.Command = ExecuteFlowCommand; mi.CommandParameter = af; Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items.Add(mi); }
public void RunActionFlow(string name, bool notifyDone) { actionBuilderEditor1.CommitData(); ActionFlow af = (from c in _actionFlows where c.Name == name select c).FirstOrDefault(); if (af != null) { RunActionFlow(af, notifyDone); } actionBuilderEditor1.UpdateLabels(); }
public void RemoveFlowFromMenu(ActionFlow af) { MenuItem mi; for (int i = 0; i < Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items.Count; i++ ) { mi = Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items[i] as MenuItem; if (mi != null && mi.Name==af.ID) { Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items.RemoveAt(i); break; } } }
public void RenameFlow(ActionFlow af, string newName) { af.Name = newName; MenuItem mi; for (int i = 0; i < Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items.Count; i++) { mi = Core.ApplicationData.Instance.MainWindow.actbuildermnu.Items[i] as MenuItem; if (mi != null && mi.Name == af.ID) { mi.Header = newName; break; } } }
private ActionFlow CopyAs(ActionFlow fq, string newName) { ActionFlow target = new ActionFlow(); target.Name = newName; target.Actions = new List <ActionImplementation>(); Hashtable renamedIds = new Hashtable(); foreach (ActionImplementation ai in fq.Actions) { Type t = ai.GetType(); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); obj.ID = Guid.NewGuid().ToString("N"); obj.Location = new System.Windows.Point(ai.Location.X, ai.Location.Y); obj.Values.AddRange(ai.Values); renamedIds.Add(ai.ID, obj.ID); target.Actions.Add(obj); } foreach (ActionImplementation ai in fq.Actions) { string actId = (string)renamedIds[ai.ID]; ActionImplementation act = (from a in target.Actions where a.ID == actId select a).FirstOrDefault(); List <ActionImplementation.OutputConnectionInfo> srcCons = ai.GetOutputConnections(); List <ActionImplementation.OutputConnectionInfo> dstCons = act.GetOutputConnections(); foreach (ActionImplementation.OutputConnectionInfo con in srcCons) { if (con.ConnectedAction != null) { ActionImplementation.OutputConnectionInfo nCon = new ActionImplementation.OutputConnectionInfo(); nCon.OutputOperator = con.OutputOperator; string conToActId = renamedIds[con.ConnectedAction.ID] as string; if (conToActId != null) { nCon.ConnectedAction = (from a in target.Actions where a.ID == conToActId select a).FirstOrDefault(); } else { nCon.ConnectedAction = con.ConnectedAction; } dstCons.Add(nCon); } } } return(target); }
private void RunActionFlow(ActionFlow flow, bool notifyDone) { try { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { //flows can call eachother, initialize them all foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.PrepareRun(); } } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; if (notifyDone) { //first start startAction.PrepareFlow(); } foreach (Framework.Data.Geocache gc in Core.Geocaches) { startAction.Run(gc); } //wrap up foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.FinalizeRun(); } } } if (notifyDone && PluginSettings.Instance.ShowFlowCompletedMessage) { using (ExecutionCompletedForm dlg = new ExecutionCompletedForm()) { dlg.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button5_Click(object sender, EventArgs e) { ActionFlow fq = _activeFlow; if (fq != null) { ActionFlow target = CopyAs(fq, textBox1.Text); _actionFlows.Add(target); (this.OwnerPlugin as ActionBuilder).AddNewAction(target.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", target.Name); comboBox1.Items.Add(target); comboBox1.SelectedIndex = comboBox1.Items.Count - 1; } }
private void button2_Click(object sender, EventArgs e) { ActionFlow af = new ActionFlow(); af.Name = textBox1.Text; af.Actions = new List <ActionImplementation>(); var obj = new ActionStart(Core); obj.ID = Guid.NewGuid().ToString("N"); af.Actions.Add(obj); _actionFlows.Add(af); (this.OwnerPlugin as ActionBuilder).AddNewAction(af.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", af.Name); comboBox1.Items.Add(af); comboBox1.SelectedIndex = comboBox1.Items.Count - 1; }
private void button13_Click(object sender, EventArgs e) { ActionFlow fq = _activeFlow; if (fq != null) { (this.OwnerPlugin as ActionBuilder).DeleteAction(fq.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.RemoveAction(OwnerPlugin, "Action builder", fq.Name); fq.Name = textBox1.Text; (this.OwnerPlugin as ActionBuilder).AddNewAction(fq.Name); main.AddAction(OwnerPlugin, "Action builder", fq.Name); typeof(ComboBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, comboBox1, new object[] { }); checkButtonStates(); } }
private void checkButtonStates() { //new / rename if (textBox1.Text.Length == 0) { button2.Enabled = false; button13.Enabled = false; } else { ActionFlow fq = (from f in _actionFlows where f.Name == textBox1.Text select f).FirstOrDefault(); button2.Enabled = (fq == null); button13.Enabled = (fq == null && _activeFlow != null); } button1.Enabled = (_activeFlow != null); button12.Enabled = (_activeFlow != null); panel3.Enabled = (_activeFlow != null); panel5.Enabled = (_activeFlow != null); }
public async Task <IActionResult> Sample_Main(InputModel inputModel) { OuputModel outputModel = null; try { if (inputModel == null) { return(BadRequest(outputModel)); } ActionFlow actionFlow = new ActionFlow(); outputModel = await actionFlow.SampleActionFlow(inputModel); } catch (Exception ex) { throw ex; } return(Ok(outputModel)); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _activeFlow = comboBox1.SelectedItem as ActionFlow; if (_activeFlow == null) { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(null); } else { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(_activeFlow.Actions); ActionImplementation startAction = (from a in _activeFlow.Actions where a is ActionStart select a).FirstOrDefault(); if (startAction != null) { if (startAction.UIActionControl != null) { startAction.UIActionControl.Title.Content = string.Format("{0}\r\n{1}", Utils.LanguageSupport.Instance.GetTranslation(STR_START), _activeFlow.Name); } } } checkButtonStates(); }
public async Task RunActionFow(ActionFlow af) { SqlStatementsOfLastExecutedFlow = ""; await Task.Run(() => { var sw = new System.Diagnostics.Stopwatch(); sw.Start(); try { var fn = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3"); if (System.IO.File.Exists(fn)) { using (var db = new Database.DBConSqlite(fn)) { try { RunFlow(af, db); } finally { SqlStatementsOfLastExecutedFlow = string.Join("\r\n", db.ExecutedSqlQueries); } } } sw.Stop(); ApplicationData.Instance.StatusText = string.Format(Localization.TranslationManager.Instance.Translate("FlowFinishedIn") as string, af.Name, sw.Elapsed.TotalSeconds.ToString("0.0")); } catch (Exception e) { sw.Stop(); ApplicationData.Instance.StatusText = string.Format("{0}: {1}", Localization.TranslationManager.Instance.Translate("Error"), e.Message); } }); #if DEBUG System.IO.File.WriteAllText(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper", "sqlstatements.log"), SqlStatementsOfLastExecutedFlow); #endif }
public void RunFlow(ActionFlow flow, Database.DBCon db) { List<ActionImplementation> orderedActions = null; try { ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("StartingFlow"), flow.Name); orderedActions = flow.Actions.OrderByDescending(x => x.Priority).ToList(); int id = 0; foreach (ActionImplementation ai in orderedActions) { id++; ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("PreparingAction"), Localization.TranslationManager.Instance.Translate(ai.Name)); ai.PrepareRun(db, string.Format("gskwrp{0}", id)); } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; startAction.Run(null); } finally { foreach (ActionImplementation ai in orderedActions) { ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("FinishingAction"), Localization.TranslationManager.Instance.Translate(ai.Name)); ai.FinalizeRun(); } } ApplicationData.Instance.StatusText = string.Format("{0} {1}", Localization.TranslationManager.Instance.Translate("FinishedFlow"), flow.Name); }
private void runFlow(ActionFlow flow) { try { foreach (ActionImplementation ai in flow.Actions) { ai.PrepareRun(); } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; List<Core.Data.Geocache> gcList = startAction.PrepareFlow(); DateTime nextUpdate = DateTime.Now.AddSeconds(1); int index = 0; bool canceled = false; using (Utils.ProgressBlock prog = new Utils.ProgressBlock("ActionBuilder", "Executing", gcList.Count, 0, true)) { foreach (Core.Data.Geocache gc in gcList) { startAction.Run(gc); index++; if (DateTime.Now>=nextUpdate) { if (!prog.Update("Executing", gcList.Count, index)) { canceled = true; break; } nextUpdate = DateTime.Now.AddSeconds(1); } } } if (!canceled) { //wrap up foreach (ActionImplementation ai in flow.Actions) { ai.FinalizeRun(); } } } catch (Exception e) { Core.ApplicationData.Instance.Logger.AddLog(this, e); } }
private void getActionFlowsFromXml(XmlDocument doc) { List<ActionImplementation> allActionImpl = new List<ActionImplementation>(); XmlNodeList nl = doc.SelectNodes("/flows/flow"); foreach (XmlNode n in nl) { ActionFlow af = new ActionFlow(); af.Name = n.Attributes["name"].Value; af.ID = n.Attributes["id"].Value; af.Actions = new List<ActionImplementation>(); XmlNodeList al = n.SelectNodes("action"); foreach (XmlNode a in al) { Type t = Type.GetType(a.Attributes["type"].Value); ConstructorInfo constructor = t.GetConstructor(Type.EmptyTypes); ActionImplementation obj = (ActionImplementation)constructor.Invoke(null); obj.ID = a.Attributes["id"].Value; obj.Location = new System.Windows.Point((double)int.Parse(a.Attributes["x"].Value), (double)int.Parse(a.Attributes["y"].Value)); af.Actions.Add(obj); allActionImpl.Add(obj); XmlNodeList vl = a.SelectNodes("values/value"); foreach (XmlNode v in vl) { obj.Values.Add(v.InnerText); } } ActionFlows.Add(af); } //all actions are created, now we can match the ID's for the connections. nl = doc.SelectNodes("/flows/flow/action"); foreach (XmlNode n in nl) { ActionImplementation ai = (from ac in allActionImpl where ac.ID == n.Attributes["id"].Value select ac).FirstOrDefault(); XmlNodeList conl; ActionImplementation.Operator op = ai.AllowOperators; if ((op & ActionImplementation.Operator.Equal) != 0) { conl = n.SelectNodes("Equal/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Equal); } } if ((op & ActionImplementation.Operator.Larger) != 0) { conl = n.SelectNodes("Larger/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Larger); } } if ((op & ActionImplementation.Operator.LargerOrEqual) != 0) { conl = n.SelectNodes("LargerOrEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LargerOrEqual); } } if ((op & ActionImplementation.Operator.Less) != 0) { conl = n.SelectNodes("Less/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Less); } } if ((op & ActionImplementation.Operator.LessOrEqual) != 0) { conl = n.SelectNodes("LessOrEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LessOrEqual); } } if ((op & ActionImplementation.Operator.NotEqual) != 0) { conl = n.SelectNodes("NotEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.NotEqual); } } } }
private ActionFlow CopyAs(ActionFlow fq, string newName) { ActionFlow target = new ActionFlow(); target.Name = newName; target.Actions = new List<ActionImplementation>(); Hashtable renamedIds = new Hashtable(); foreach (ActionImplementation ai in fq.Actions) { Type t = ai.GetType(); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); obj.ID = Guid.NewGuid().ToString("N"); obj.Location = new System.Windows.Point(ai.Location.X, ai.Location.Y); obj.Values.AddRange(ai.Values); renamedIds.Add(ai.ID, obj.ID); target.Actions.Add(obj); } foreach (ActionImplementation ai in fq.Actions) { string actId = (string)renamedIds[ai.ID]; ActionImplementation act = (from a in target.Actions where a.ID == actId select a).FirstOrDefault(); List<ActionImplementation.OutputConnectionInfo> srcCons = ai.GetOutputConnections(); List<ActionImplementation.OutputConnectionInfo> dstCons = act.GetOutputConnections(); foreach (ActionImplementation.OutputConnectionInfo con in srcCons) { if (con.ConnectedAction != null) { ActionImplementation.OutputConnectionInfo nCon = new ActionImplementation.OutputConnectionInfo(); nCon.OutputOperator = con.OutputOperator; string conToActId = renamedIds[con.ConnectedAction.ID] as string; if (conToActId != null) { nCon.ConnectedAction = (from a in target.Actions where a.ID == conToActId select a).FirstOrDefault(); } else { nCon.ConnectedAction = con.ConnectedAction; } dstCons.Add(nCon); } } } return target; }
public async Task RunActionFow(ActionFlow af) { if (Core.ApplicationData.Instance.ActiveDatabase!=null) { using (Utils.DataUpdater upd = new Utils.DataUpdater(Core.ApplicationData.Instance.ActiveDatabase)) { await Task.Run(() => { runFlow(af); }); } } }
private void RunActionFlow(ActionFlow flow) { RunActionFlow(flow, false); }
private void RunActionFlow(ActionFlow flow, bool notifyDone) { try { using (Utils.FrameworkDataUpdater upd = new Utils.FrameworkDataUpdater(Core)) { //flows can call eachother, initialize them all foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.PrepareRun(); } } //find start and run ActionStart startAction = (from a in flow.Actions where a is ActionStart select a).FirstOrDefault() as ActionStart; if (notifyDone) { //first start startAction.PrepareFlow(); } foreach (Framework.Data.Geocache gc in Core.Geocaches) { startAction.Run(gc); } //wrap up foreach (ActionFlow af in _actionFlows) { foreach (ActionImplementation ai in af.Actions) { ai.FinalizeRun(); } } } if (notifyDone && PluginSettings.Instance.ShowFlowCompletedMessage) { using (ExecutionCompletedForm dlg = new ExecutionCompletedForm()) { dlg.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _activeFlow = comboBox1.SelectedItem as ActionFlow; if (_activeFlow==null) { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(null); } else { actionBuilderEditor1.CommitData(); actionBuilderEditor1.Clear(_activeFlow.Actions); ActionImplementation startAction = (from a in _activeFlow.Actions where a is ActionStart select a).FirstOrDefault(); if (startAction != null) { if (startAction.UIActionControl != null) { startAction.UIActionControl.Title.Content = string.Format("{0}\r\n{1}", Utils.LanguageSupport.Instance.GetTranslation(STR_START), _activeFlow.Name); } } } checkButtonStates(); }
private void button2_Click(object sender, EventArgs e) { ActionFlow af = new ActionFlow(); af.Name = textBox1.Text; af.Actions = new List<ActionImplementation>(); var obj = new ActionStart(Core); obj.ID = Guid.NewGuid().ToString("N"); af.Actions.Add(obj); _actionFlows.Add(af); (this.OwnerPlugin as ActionBuilder).AddNewAction(af.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", af.Name); comboBox1.Items.Add(af); comboBox1.SelectedIndex = comboBox1.Items.Count - 1; }
private List <ActionFlow> GetActionFlowsFromXml(XmlDocument doc) { List <ActionFlow> result = new List <ActionFlow>(); List <ActionImplementation> allActionImpl = new List <ActionImplementation>(); XmlNodeList nl = doc.SelectNodes("/flows/flow"); foreach (XmlNode n in nl) { ActionFlow af = new ActionFlow(); af.Name = n.Attributes["name"].Value; af.Actions = new List <ActionImplementation>(); XmlNodeList al = n.SelectNodes("action"); foreach (XmlNode a in al) { Type t = Type.GetType(a.Attributes["type"].Value); ConstructorInfo constructor = t.GetConstructor(new Type[] { typeof(Framework.Interfaces.ICore) }); object[] parameters = new object[] { Core }; ActionImplementation obj = (ActionImplementation)constructor.Invoke(parameters); obj.ID = a.Attributes["id"].Value; obj.Location = new System.Windows.Point((double)int.Parse(a.Attributes["x"].Value), (double)int.Parse(a.Attributes["y"].Value)); af.Actions.Add(obj); allActionImpl.Add(obj); XmlNodeList vl = a.SelectNodes("values/value"); foreach (XmlNode v in vl) { obj.Values.Add(v.InnerText); } } result.Add(af); } //all actions are created, now we can match the ID's for the connections. nl = doc.SelectNodes("/flows/flow/action"); foreach (XmlNode n in nl) { ActionImplementation ai = (from ac in allActionImpl where ac.ID == n.Attributes["id"].Value select ac).FirstOrDefault(); XmlNodeList conl; ActionImplementation.Operator op = ai.AllowOperators; if ((op & ActionImplementation.Operator.Equal) != 0) { conl = n.SelectNodes("Equal/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Equal); } } if ((op & ActionImplementation.Operator.Larger) != 0) { conl = n.SelectNodes("Larger/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Larger); } } if ((op & ActionImplementation.Operator.LargerOrEqual) != 0) { conl = n.SelectNodes("LargerOrEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LargerOrEqual); } } if ((op & ActionImplementation.Operator.Less) != 0) { conl = n.SelectNodes("Less/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Less); } } if ((op & ActionImplementation.Operator.LessOrEqual) != 0) { conl = n.SelectNodes("LessOrEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LessOrEqual); } } if ((op & ActionImplementation.Operator.NotEqual) != 0) { conl = n.SelectNodes("NotEqual/ID"); foreach (XmlNode con in conl) { ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.NotEqual); } } } return(result); }
private void RunActionFlow(ActionFlow flow) { RunActionFlow(flow, false); }
public bool ImportXmlFlow(string xmlDoc) { bool result = false; try { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlDoc); List <ActionFlow> flows = GetActionFlowsFromXml(doc); if (flows != null && flows.Count > 0) { //for now assume 1 ActionFlow naf = flows[0]; //check for ID and name ActionImplementation startAction = (from sa in naf.Actions where sa is ActionStart select sa).FirstOrDefault(); if (startAction != null) { ActionFlow found = null; foreach (var af in _actionFlows) { ActionImplementation startAct = (from sa in af.Actions where sa is ActionStart select sa).FirstOrDefault(); if (startAct != null) { if (startAct.ID == startAction.ID) { found = af; break; } } } if (found != null) { //ask overwrite DialogResult dr = MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_OVERWRITE), Utils.LanguageSupport.Instance.GetTranslation(STR_WARNING), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (dr == System.Windows.Forms.DialogResult.Cancel) { return(result); } else if (dr == System.Windows.Forms.DialogResult.Yes) { //remove old comboBox1.Items.Remove(found); _actionFlows.Remove(found); (this.OwnerPlugin as ActionBuilder).DeleteAction(found.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.RemoveAction(OwnerPlugin, "Action builder", found.Name); //insert new //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); comboBox1_SelectedIndexChanged(this, EventArgs.Empty); result = true; } else { //copy and add //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } naf = CopyAs(naf, naf.Name); _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); result = true; } } else { //add //but first check name int index = 0; while ((from a in _actionFlows where a.Name.ToLower() == naf.Name.ToLower() select a).Count() > 0) { index++; naf.Name = string.Format("{0}{1}", naf.Name, index); } _actionFlows.Add(naf); (this.OwnerPlugin as ActionBuilder).AddNewAction(naf.Name); Framework.Interfaces.IPluginUIMainWindow main = (from Framework.Interfaces.IPluginUIMainWindow a in Core.GetPlugin(Framework.PluginType.UIMainWindow) select a).FirstOrDefault(); main.AddAction(OwnerPlugin, "Action builder", naf.Name); comboBox1.Items.Add(naf); result = true; } } button14_Click(this, EventArgs.Empty); } } catch { MessageBox.Show(Utils.LanguageSupport.Instance.GetTranslation(STR_ERRORIMPORTINGFLOW), Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public string GetFlowXml(ActionFlow flow) { string result = null; try { XmlDocument doc = createFlowXml(new List<ActionFlow>() { flow }); StringBuilder sb = new StringBuilder(); System.IO.TextWriter tr = new System.IO.StringWriter(sb); XmlTextWriter wr = new XmlTextWriter(tr); wr.Formatting = Formatting.None; doc.Save(wr); wr.Close(); result = sb.ToString(); } catch { } return result; }
public static void AddAction <T>(this ActionFlow actionFlow, T action) { if (actionFlow.Actions == null) { actionFlow.Actions = new HashSet <Pdf4meAction>(); } var pdf4meAction = new Pdf4meAction() { ActionConfig = JsonConvert.SerializeObject(action), }; if (action is OptimizeAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Optimize; } if (action is ConvertToPdfAction) { pdf4meAction.ActionType = Pdf4meActionActionType.ConvertToPdf; } //if (action is ConvertAction) // pdf4meAction.ActionType = Pdf4meActionActionType.Converter; //if (action is CreateBarcodeAction) // pdf4meAction.ActionType = Pdf4meActionActionType.CreateBarcode; if (action is ReadBarcodeAction) { pdf4meAction.ActionType = Pdf4meActionActionType.ReadBarcode; } if (action is ExtractAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Extract; } if (action is ExtractResourcesAction) { pdf4meAction.ActionType = Pdf4meActionActionType.ExtractResources; } if (action is ImageAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Image; } if (action is MergeAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Merge; } if (action is OcrAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Ocr; } if (action is PdfAAction) { pdf4meAction.ActionType = Pdf4meActionActionType.PdfA; } if (action is ProtectAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Protect; } if (action is RepairAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Repair; } if (action is RotateAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Rotate; } if (action is SignAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Sign; } if (action is SplitAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Split; } if (action is StampAction) { pdf4meAction.ActionType = Pdf4meActionActionType.Stamp; } //if (action is CreateThumbnailAction) // pdf4meAction.ActionType = Pdf4meActionActionType.Thumbnail; //if (action is UserAction) // pdf4meAction.ActionType = Pdf4meActionActionType.User; actionFlow.Actions.Add(pdf4meAction); }