Exemplo n.º 1
0
        private void ToolRunClick(object sender, EventArgs e)
        {
            procedure.Save();
            if (procedure.ProcedureType == ProcedureTypes.Source || procedure.ProcedureType == ProcedureTypes.Assembly)
            {
                var args = new ExecuteArgs();
                var obj  = procedure.CreateObject(args);

                if (obj is Window)
                {
                    ((Window)obj).TransientFor = ParentWindow;
                    ((Window)obj).Show();
                }
                else if (obj is Widget)
                {
                    var window = new ToolWindow
                    {
                        Mode   = ToolShowMode.Dialog,
                        Target = (Widget)obj,
                        Title  = procedure.Name
                    };
                    window.Show(this, Point.Zero);
                }
                else
                {
                    object result = procedure.ExecuteObject(obj, args);
                    MessageDialog.ShowMessage(ParentWindow, result == null ? "Succesfull!" : result.ToString(), "Execute complete!");
                }
            }
            else if (procedure.ProcedureType == ProcedureTypes.Query)
            {
                var form = new PQueryView {
                    Procedure = procedure
                };

                var window = new ToolWindow
                {
                    Mode   = ToolShowMode.Dialog,
                    Target = form,
                    Title  = procedure.Name
                };
                window.Show(this, Point.Zero);
                //window.Dispose();
            }
            else
            {
                var args = new ExecuteArgs {
                    Parameters = ProcedureProgress.CreateParam(procedure)
                };
                var    obj    = procedure.CreateObject(args);
                object result = procedure.ExecuteObject(obj, args);
                MessageDialog.ShowMessage(ParentWindow, result == null ? "Succesfull!" : result.ToString(), "Execute complete!");
            }
        }
Exemplo n.º 2
0
 public static bool ExecuteDocumentsProcedure(DBProcedure proc, IEnumerable documents)
 {
     if (proc.ProcedureType == ProcedureTypes.Assembly || proc.ProcedureType == ProcedureTypes.Source)
     {
         var type = proc.GetObjectType();
         if (type.GetInterface("IDocuments") != null)
         {
             object result = proc.CreateObject();
             if (result is IDocuments)
             {
                 ((IDocuments)result).Documents = documents;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
        public object ExecuteDocumentProcedure(DBProcedure proc, Document document, bool callback)
        {
            document.Save();
            var    args   = new ExecuteArgs(document);
            object result = null;

            try
            {
                result = proc.CreateObject(args);
                if (TypeHelper.IsBaseType(result.GetType(), typeof(Widget)))
                {
                    result = proc.ExecuteObject(result, args);
                }
                else
                {
                    var task = proc.GetExecutor(result, args);

                    if (GuiService.Main != null)
                    {
                        if (callback)
                        {
                            task.Callback += TaskCallback;
                        }
                        GuiService.Main.AddTask(this, task);
                        result = null;
                    }
                    else
                    {
                        result = task.Execute();
                    }
                }
            }
            catch (Exception ex)
            {
                result = ex;
            }
            return(result);
        }