Ejemplo n.º 1
0
        public void SaveTask(IDataProcess process, bool haveui)
        {
            var task = CurrentProject.Tasks.FirstOrDefault(d => d.Name == process.Name);

            if (haveui == false ||
                MessageBox.Show(
                    GlobalHelper.Get("key_311") +
                    (task == null ? GlobalHelper.Get("key_312") : GlobalHelper.Get("key_313")),
                    GlobalHelper.Get("key_99"),
                    MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                configDocument = (process as IDictionarySerializable).DictSerialize();
                if (task == null)
                {
                    task = new ProcessTask
                    {
                        Name        = process.Name,
                        Description = GlobalHelper.Get("key_314")
                    };

                    CurrentProject.Tasks.Add(task);
                }

                task.ProcessToDo = configDocument;
                // XLogSys.Print.Warn(string.Format(GlobalHelper.Get("key_315"),task.Name));
            }
        }
Ejemplo n.º 2
0
        public override void DictDeserialize(IDictionary <string, object> docu, Scenario scenario = Scenario.Database)
        {
            base.DictDeserialize(docu);
            var doc = docu as FreeDocument;

            if (doc.Children != null)
            {
                var items = doc.Children;

                foreach (var item in items)
                {
                    var proces = new ProcessTask();
                    proces.Project = this;
                    proces.DictDeserialize(item);

                    Tasks.Add(proces);
                }
            }

            if (docu["DBConnections"] != null)
            {
                var items = docu["DBConnections"] as FreeDocument;

                if (items?.Children != null)
                {
                    foreach (var item in items.Children)
                    {
                        var type = item["TypeName"].ToString();
                        var conn = PluginProvider.GetObjectByType <IDataBaseConnector>(type) as DBConnectorBase;
                        if (conn == null)
                        {
                            continue;
                        }
                        conn.DictDeserialize(item);

                        DBConnections.Add(conn);
                    }
                }
            }
            if (DBConnections.FirstOrDefault(d => d.TypeName == "文件管理") == null)
            {
                var filemanager = new FileManager()
                {
                    Name = "最近打开的文件"
                };
                DBConnections.Add(filemanager);
            }
            if (DBConnections.FirstOrDefault(d => d.TypeName == "MongoDB") == null)
            {
                var mongo = new MongoDBConnector()
                {
                    Name = "MongoDB连接器"
                };
                mongo.DBName = "hawk";
                DBConnections.Add(mongo);
            }
        }
Ejemplo n.º 3
0
        private void SetCurrentTask(ProcessTask task)
        {
            var process = ProcessCollection.FirstOrDefault(d => d.Name == task.Name);

            if (process == null)
            {
                return;
            }
            var configDocument = (process as IDictionarySerializable).DictSerialize();

            task.ProcessToDo = configDocument;
            XLogSys.Print.Info("已经成功覆盖任务");
        }
Ejemplo n.º 4
0
        public override void DictDeserialize(IDictionary <string, object> docu, Scenario scenario = Scenario.Database)
        {
            base.DictDeserialize(docu);
            var doc = docu as FreeDocument;

            if (doc.Children != null)
            {
                var items = doc.Children;

                foreach (var item in items)
                {
                    var proces = new ProcessTask();
                    proces.Project = this;
                    proces.DictDeserialize(item);

                    Tasks.Add(proces);
                }
            }

            if (docu["DBConnections"] != null)
            {
                var items = docu["DBConnections"] as FreeDocument;

                if (items?.Children == null)
                {
                    return;
                }
                foreach (var item in items.Children)
                {
                    var type = item["TypeName"].ToString();
                    var conn = PluginProvider.GetObjectByType <IDataBaseConnector>(type) as DBConnectorBase;
                    if (conn == null)
                    {
                        continue;
                    }
                    conn.DictDeserialize(item);

                    DBConnections.Add(conn);
                }
            }
        }
Ejemplo n.º 5
0
        private void SaveTask(IDataProcess process, bool haveui)
        {
            var task = CurrentProject.Tasks.FirstOrDefault(d => d.Name == process.Name);

            if (haveui == false || MessageBox.Show("是否确定保存任务?" + (task == null ? "将新建任务" : "存在同名任务,将覆盖该任务"), "提示信息",
                                                   MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                configDocument = (process as IDictionarySerializable).DictSerialize();
                if (task == null)
                {
                    task = new ProcessTask
                    {
                        Name        = process.Name,
                        Description = "任务描述",
                    };

                    CurrentProject.Tasks.Add(task);
                }

                task.ProcessToDo = configDocument;
            }
        }
Ejemplo n.º 6
0
        public override void DictDeserialize(IDictionary <string, object> docu, Scenario scenario = Scenario.Database)
        {
            base.DictDeserialize(docu);
            var doc = docu as FreeDocument;

            if (doc.Children != null)
            {
                var items = doc.Children;

                foreach (var item in items)
                {
                    var proces = new ProcessTask();
                    proces.Project = this;
                    proces.DictDeserialize(item);

                    Tasks.Add(proces);
                }
            }

            if (docu["DBConnections"] != null)
            {
                var items = docu["DBConnections"] as FreeDocument;

                if (items?.Children != null)
                {
                    foreach (var item in items.Children)
                    {
                        var type = item["TypeName"].ToString();
                        var conn = PluginProvider.GetObjectByType <IDataBaseConnector>(type) as DBConnectorBase;
                        if (conn == null)
                        {
                            continue;
                        }
                        conn.DictDeserialize(item);

                        DBConnections.Add(conn);
                    }
                }
            }
            if (docu["RunningTasks"] != null)
            {
                var tasks = docu["RunningTasks"] as FreeDocument;


                SavedRunningTasks = tasks?.Children;
            }

            if (docu["Parameters"] != null)
            {
                var tasks = docu["Parameters"] as FreeDocument;

                if (tasks != null)
                {
                    Parameters.AddRange(tasks?.Children?.Select(d =>
                    {
                        var param = new ParameterItem();
                        param.UnsafeDictDeserialize(d);
                        return(param);
                    }));
                }
            }

            ConfigSelector.SelectItem =
                docu["ParameterName"].ToString();

            if (DBConnections.FirstOrDefault(d => d.TypeName == GlobalHelper.Get("FileManager")) == null)
            {
                var filemanager = new FileManager {
                    Name = GlobalHelper.Get("recent_file")
                };
                DBConnections.Add(filemanager);
            }
            if (DBConnections.FirstOrDefault(d => d.TypeName == "MongoDB") == null)
            {
                var mongo = new MongoDBConnector {
                    Name = "MongoDB连接器"
                };
                mongo.DBName = "hawk";
                DBConnections.Add(mongo);
            }
            if (DBConnections.FirstOrDefault(d => d.TypeName == GlobalHelper.Get("SQLiteDatabase")) == null)
            {
                var sqlite = new SQLiteDatabase {
                    Name = GlobalHelper.Get("SQLiteDatabase")
                };
                sqlite.DBName = "hawk-sqlite";
                DBConnections.Add(sqlite);
            }
        }
Ejemplo n.º 7
0
 private void SetCurrentTask(ProcessTask task)
 {
     var process = ProcessCollection.FirstOrDefault(d => d.Name == task.Name);
     if (process == null)
         return;
     var configDocument = (process as IDictionarySerializable).DictSerialize();
     task.ProcessToDo = configDocument;
     XLogSys.Print.Info("已经成功覆盖任务");
 }
Ejemplo n.º 8
0
        private void SaveTask(IDataProcess process, bool haveui)
        {
            var task = CurrentProject.Tasks.FirstOrDefault(d => d.Name == process.Name);

            if (haveui == false || MessageBox.Show("是否确定保存任务?" + (task == null ? "将新建任务" : "存在同名任务,将覆盖该任务"), "提示信息",
                MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                configDocument = (process as IDictionarySerializable).DictSerialize();
                if (task == null)
                {
                    task = new ProcessTask
                    {
                        Name = process.Name,
                        Description = "任务描述",
                        CreateTime = DateTime.Now
                    };

                    CurrentProject.Tasks.Add(task);
                }

                task.ProcessToDo = configDocument;
            }
        }