Exemple #1
0
 public void OnCanvasClick(object sender, MouseButtonEventArgs e)
 {
     if (PerAddNEvent == true)
     {
         ConfigEvent ne = AddNewEvent(NewEventType);
         ne.SetPos((int)e.GetPosition((Canvas)sender).X - 75, (int)e.GetPosition((Canvas)sender).Y - 35);
         designer.Client.Children.Add(ne.GetShowItem());
         PerAddNEvent = false;
         Proj.win_main.AddNEvent.IsChecked = false;
         Proj.win_main.AddSEvent.IsChecked = false;
     }
 }
Exemple #2
0
        public void InitStartAndEnd()
        {
            //start
            ConfigEvent newSE = new ConfigEvent("StartEvent");

            newSE.name        = "Start";
            newSE.description = "Start";
            newSE.OnSelected += this.Proj.win_main.OnConfigItem_Selected;
            newSE.SetPos(50, 50);
            wf_itmes.Add(newSE);
            this.designer.Client.Children.Add(newSE.GetShowItem());

            //end
            ConfigEvent newEE = new ConfigEvent("EndEvent");

            newEE.name        = "End";
            newEE.description = "End";
            newEE.OnSelected += this.Proj.win_main.OnConfigItem_Selected;
            newEE.SetPos(50, 150);
            wf_itmes.Add(newEE);
            this.designer.Client.Children.Add(newEE.GetShowItem());
        }
Exemple #3
0
        public bool LoadWorkFlow(XmlElement source)
        {
            //params
            XmlElement  pars_xml = (XmlElement)source.SelectSingleNode("params");
            XmlNodeList parss    = pars_xml.SelectNodes("param");

            foreach (XmlNode xn in parss)
            {
                XmlElement xe   = (XmlElement)xn;
                bool       flag = false;

                foreach (param pa in params_table)
                {
                    if (pa.Name == xe.GetAttribute("name"))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag == false)
                {
                    params_table.Add(new param()
                    {
                        Name = xe.GetAttribute("name"),
                        Type = xe.GetAttribute("type"),
                        Desc = xe.GetAttribute("desc")
                    });
                }
            }

            //ConfigItem
            XmlElement items_xml = (XmlElement)source.SelectSingleNode("configitems");

            foreach (XmlNode xn1 in items_xml.SelectNodes("item"))
            {
                XmlElement xe1 = (XmlElement)xn1;
                if (xe1.GetAttribute("item_type") == "event")
                {
                    ConfigEvent ce = AddNewEvent(xe1.GetAttribute("event_type"));
                    ce.authority = xe1.GetAttribute("authority");
                    ce.GetShowItem().Margin = new Thickness(
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[0]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]),
                        Convert.ToDouble(((XmlElement)xe1.SelectSingleNode("shape")).GetAttribute("margin").Split(',')[1]));
                    ce.CurrentAction = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("currentaction");

                    XmlElement ba = (XmlElement)(xe1.SelectSingleNode("actions").SelectSingleNode("beforeaction"));
                    XmlElement aa = (XmlElement)(xe1.SelectSingleNode("actions").SelectSingleNode("afteraction"));
                    if (ba != null) //新版本
                    {
                        ce.BeforeAction.url = ba.GetAttribute("url");
                        XmlNodeList act_pars = ba.SelectSingleNode("action_params").SelectNodes("param");
                        ce.BeforeAction.action_params.Clear();
                        foreach (XmlNode parxn in act_pars)
                        {
                            ce.BeforeAction.action_params[((XmlElement)parxn).GetAttribute("name")] = ((XmlElement)parxn).InnerText;
                        }


                        ce.AfterAction.url = aa.GetAttribute("url");
                        XmlNodeList act_pars1 = aa.SelectSingleNode("action_params").SelectNodes("param");
                        ce.AfterAction.action_params.Clear();
                        foreach (XmlNode parxn in act_pars1)
                        {
                            ce.AfterAction.action_params[((XmlElement)parxn).GetAttribute("name")] = ((XmlElement)parxn).InnerText;
                        }
                    }
                    else
                    {
                        ce.BeforeAction.url = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("beforeaction");
                        ce.AfterAction.url  = ((XmlElement)xe1.SelectSingleNode("actions")).GetAttribute("afteraction");
                    }

                    XmlNodeList parsss = xn1.SelectSingleNode("link_params").SelectNodes("param");
                    foreach (XmlNode xn2 in parsss)
                    {
                        ce.LinkParams.Add(((XmlElement)xn2).GetAttribute("name"), ((XmlElement)xn2).GetAttribute("app_reserve"));
                    }
                    ce.name        = xe1.GetAttribute("name");
                    ce.description = xe1.GetAttribute("desc");

                    //time_out
                    XmlNode time_out = xn1.SelectSingleNode("time_out");
                    if (time_out != null)
                    {
                        Dictionary <string, object> timeout_setting = (ce.Time_Out as Dictionary <string, object>);
                        XmlNode time_start = time_out.SelectSingleNode("start");
                        if (time_start == null)
                        {
                            timeout_setting["start"] = "";
                        }
                        else
                        {
                            timeout_setting["start"] = time_start.InnerText;
                        }

                        XmlNode time_offset = time_out.SelectSingleNode("offset");
                        if (time_offset == null || time_offset.InnerText == "")
                        {
                            timeout_setting["offset"] = (null as TimeSpan?);
                        }
                        else
                        {
                            TimeSpan?ts = TimeSpan.Parse(time_offset.InnerText);
                            timeout_setting["offset"] = ts;
                        }

                        XmlNode time_exact = time_out.SelectSingleNode("exact");
                        if (time_exact == null || time_exact.InnerText == "")
                        {
                            timeout_setting["exact"] = (null as DateTime?);
                        }
                        else
                        {
                            DateTime?dt = DateTime.Parse(time_exact.InnerText);
                            timeout_setting["exact"] = dt;
                        }

                        XmlNode time_action = time_out.SelectSingleNode("action");
                        if (time_action == null)
                        {
                            timeout_setting["action"] = "";
                        }
                        else
                        {
                            timeout_setting["action"] = time_action.InnerText;
                        }

                        XmlNode time_callback = time_out.SelectSingleNode("callback");
                        if (time_callback == null)
                        {
                            timeout_setting["callback"] = "";
                        }
                        else
                        {
                            timeout_setting["callback"] = time_callback.InnerText;
                        }
                    }

                    if (ce.GetType().Name == "ConfigSubEvent")
                    {
                        ((ConfigSubEvent)ce).SetWorkModel(((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).GetAttribute("model"));
                        ((ConfigSubEvent)ce).LinkWorkFLow = ((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).GetAttribute("name");

                        XmlNodeList param_transfer = ((XmlElement)xe1.SelectSingleNode("LinkWorkflow")).SelectNodes("ParamTransfer");
                        foreach (XmlNode pt in param_transfer)
                        {
                            ((ConfigSubEvent)ce).ParamTransfer.Add(new paramtransfer_item()
                            {
                                parent    = ((XmlElement)pt).GetAttribute("source"),
                                child     = ((XmlElement)pt).GetAttribute("dest"),
                                direction = ((XmlElement)pt).GetAttribute("direction") == "from" ? transfer_direction.from : transfer_direction.to
                            });
                        }
                    }

                    if (ce.GetType().Name == "ConfigLoopEvent")
                    {
                        ((ConfigLoopEvent)ce).LoopCondition = (xe1.SelectSingleNode("LoopSetting").SelectSingleNode("condition") as XmlElement).InnerText;
                        ((ConfigLoopEvent)ce).TimeWaiting   = (xe1.SelectSingleNode("LoopSetting").SelectSingleNode("waiting_time") as XmlElement).InnerText;
                    }

                    designer.Client.Children.Add(ce.GetShowItem());
                }
            }

            //flow
            foreach (XmlNode xn3 in items_xml.SelectNodes("item"))
            {
                XmlElement xe2 = (XmlElement)xn3;
                if (xe2.GetAttribute("item_type") == "flow")
                {
                    ConfigFlow cf = new ConfigFlow();
                    foreach (ConfigItem ci in wf_itmes)
                    {
                        if ((ci.GetType().Name == "ConfigEvent" || ci.GetType().Name == "ConfigSubEvent" || ci.GetType().Name == "ConfigLoopEvent") &&
                            ci.name == ((XmlElement)xe2.SelectSingleNode("shape")).GetAttribute("source"))
                        {
                            cf.Start = (ConfigEvent)ci;
                            ((ConfigEvent)ci).AttachFlows(cf);
                        }
                        if ((ci.GetType().Name == "ConfigEvent" || ci.GetType().Name == "ConfigSubEvent" || ci.GetType().Name == "ConfigLoopEvent") &&
                            ci.name == ((XmlElement)xe2.SelectSingleNode("shape")).GetAttribute("dest"))
                        {
                            cf.End = (ConfigEvent)ci;
                            ((ConfigEvent)ci).AttachFlows(cf);
                        }
                    }
                    cf.Express          = xe2.GetAttribute("condition");
                    cf.OnSelected      += this.Proj.win_main.OnConfigItem_Selected;
                    cf.OnRightButtonUp += ((MainWindow)Application.Current.MainWindow).pop_itemmenu;
                    designer.Client.Children.Add(cf.GetShowItem());
                    cf.Connect();
                    wf_itmes.Add(cf);
                }
            }
            for_events = Convert.ToInt32(((XmlElement)source.SelectSingleNode("for_events")).GetAttribute("value"));
            return(true);
        }