static async Task Main(string[] args)
        {
            var config = CreateConfiguration();

            OpenLogger(config);

            string apiKey = File.ReadAllText(config["finnhubkeypath"]);
            var    client = new FinnhubClient(apiKey);

            var dbContext = new StockContext();

            var exchangeConnector = new ExchangeConnector(client, dbContext);
            //await exchangeConnector.GetExchanges();

            var stockConnector = new StockConnector(client, dbContext);
            //await stockConnector.GetSymbols("AX");

            var fileConnector = new FileConnector(config["filepath"] + "20200428splits.csv", "Splits");

            fileConnector.ImportToStockDB(dbContext);



            CloseLogger();
        }
示例#2
0
        public DataCollection ReadFile(string fileName, string format = null)
        {
            IFileConnector exporter = null;

            if (format != null)
            {
                exporter = PluginProvider.GetObjectInstance <IFileConnector>(format);
            }
            else
            {
                exporter = FileConnector.SmartGetExport(fileName);
            }

            if (exporter == null)
            {
                return(null);
            }
            exporter.FileName = fileName;


            fileName = exporter.FileName;

            ControlExtended.SafeInvoke(
                () => AddDataCollection(exporter.ReadFile(), Path.GetFileNameWithoutExtension(fileName)), LogType.Important);
            return(GetCollection(fileName));
        }
示例#3
0
        public static void InitializeConnection(DatabaseType db, DatabaseType f)
        {
            SqlConnector sql = new SqlConnector();

            Connection = sql;

            FileConnector file = new FileConnector();

            FileConnection = file;
        }
示例#4
0
 private static void Main(string[] args)
 {
     var connector = new FileConnector(new FileSessionConfig() { BothIdleTime =20});
     connector.MessageReceived += Connector_MessageReceived;
     connector.SessionCreated += Connector_SessionCreated;
     connector.SessionOpened += Connector_SessionOpened;
     connector.SessionIdle += Connector_SessionIdle;
     connector.SessionConfig.BothIdleTime = 10;
     connector.Connect(new FileEndPoint("ams", @"F:\AmsData\1.txt"));
     Console.Read();
 }
示例#5
0
        public override IEnumerable <IFreeDocument> Execute(IEnumerable <IFreeDocument> documents)
        {
            var tableName = TableNames.SelectItem;

            if (ExecuteType == EntityExecuteType.OnlyInsert)
            {
                if (ConnectorSelector.SelectItem is FileManager)
                {
                    var connector = FileConnector.SmartGetExport(tableName);

                    return(connector.WriteData(documents));
                }
                return
                    (documents.BatchDo(InitTable, (list, columns) =>
                {
                    var first = list.FirstOrDefault();
                    if (first == null)
                    {
                        return;
                    }
                    tableName = first.Query(tableName);
                    ConnectorSelector.SelectItem.BatchInsert(list, (List <string>)columns, tableName);
                    XLogSys.Print.Debug(string.Format(GlobalHelper.Get("key_350"), ConnectorSelector.SelectItem.Name, tableName, list.Count));
                }));
            }
            return
                (documents.Init(d =>
            {
                var result = InitTable(new List <IFreeDocument>()
                {
                    d
                });
                return result.Count > 0;
            }).Select(
                     document =>
            {
                var v = document[Column];
                if (v == null || tableName == null)
                {
                    return document;
                }

                ConnectorSelector.SelectItem.SaveOrUpdateEntity(document, tableName,
                                                                new Dictionary <string, object> {
                    { Column, v }
                }, ExecuteType);
                return document;
            }));
        }
示例#6
0
        public async Task GenarateTransactionReportAsync(IEnumerable <string> lines)
        {
            await Task.Run(() =>
            {
                FileConnector.CheckFolder(FinTimApplication.AppSettings.ReportFolderPath);
                string path = FileConnector.CombineFolderAndFilePath(FinTimApplication.AppSettings.ReportFolderPath, $"{DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}.csv");
                FileConnector.WriteListOfLines(path, lines);

                string fullPath = Path.GetFullPath(path);

                string cmd = "explorer.exe";
                string arg = "/select, " + fullPath;
                Process.Start(cmd, arg);
            });
        }
示例#7
0
        private static void Main(string[] args)
        {
            var connector = new FileConnector(new FileSessionConfig()
            {
                BothIdleTime = 20
            });

            connector.MessageReceived           += Connector_MessageReceived;
            connector.SessionCreated            += Connector_SessionCreated;
            connector.SessionOpened             += Connector_SessionOpened;
            connector.SessionIdle               += Connector_SessionIdle;
            connector.SessionConfig.BothIdleTime = 10;
            connector.Connect(new FileEndPoint("ams", @"F:\AmsData\1.txt"));
            Console.Read();
        }
示例#8
0
        public static IConnection GetDestinationTypeInstance(string destinationType)
        {
            IConnection _connection = null;

            switch (destinationType)
            {
            case DestinationType.MSSQL:
                _connection = new SqlConnector();
                break;

            case DestinationType.FILE:
                _connection = new FileConnector();
                break;
            }
            return(_connection);
        }
示例#9
0
        public void TestExecutePSScriptSuccess()
        {
            var scriptFile = "";
            var connector  = new FileConnector(new FileStream(scriptFile, FileMode.Open));

            using (var client = PowerShellClient.Create(connector))
            {
                var result = client.ExecuteNonQuery(
                    new List <PowershellCommand>
                {
                    new PowershellCommand {
                        IsScript = true, CommandText = connector.ScriptText
                    }
                });

                Assert.Equals(result.Status, StatusCode.SUCCESS);
            }
        }
示例#10
0
        public void SaveFile(DataCollection dataCollection, string path = null, string format = null)
        {
            IFileConnector exporter = null;

            if (format != null)
            {
                exporter = PluginProvider.GetObjectInstance <IFileConnector>(format);
            }
            else
            {
                exporter = FileConnector.SmartGetExport(path);
            }

            if (exporter == null)
            {
                return;
            }
            var data = dataCollection.ComputeData;


            exporter.FileName = path;
            processManager.CurrentProcessTasks.Add(
                TemporaryTask <FreeDocument> .AddTempTask(dataCollection + GlobalHelper.Get("key_252"),
                                                          exporter.WriteData(data), null, result =>
            {
                if (MainDescription.IsUIForm && string.IsNullOrEmpty(exporter.FileName) == false)
                {
                    if (
                        MessageBox.Show(GlobalHelper.Get("key_253"), GlobalHelper.Get("key_99"),
                                        MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        try
                        {
                            System.Diagnostics.Process.Start(exporter.FileName);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(GlobalHelper.Get("key_254") + ex.Message);
                        }
                    }
                }
            }, data.Count, notifyInterval: 1000));
        }
示例#11
0
文件: DbEx.cs 项目: yxddxs/Hawk
        public override IEnumerable <IFreeDocument> Execute(IEnumerable <IFreeDocument> documents)
        {
            var con = TableName;

            if (ExecuteType == EntityExecuteType.OnlyInsert)
            {
                if (ConnectorSelector.SelectItem is FileManager)
                {
                    var connector = FileConnector.SmartGetExport(con);

                    return(connector.WriteData(documents.Select(d => d as IFreeDocument)).Select(d => d as IFreeDocument));
                }
                return
                    (documents.Select(
                         document =>
                {
                    ConnectorSelector.SelectItem.SaveOrUpdateEntity(document, con, null, ExecuteType);
                    return document;
                }));
            }
            return
                (documents.Select(
                     document =>
            {
                var v = document[Column];
                if (v == null || TableName == null)
                {
                    return document;
                }

                ConnectorSelector.SelectItem.SaveOrUpdateEntity(document, con,
                                                                new Dictionary <string, object> {
                    { Column, v }
                }, ExecuteType);
                return document;
            }));
        }
示例#12
0
        public override IEnumerable <IFreeDocument> Execute(IEnumerable <IFreeDocument> documents)
        {
            var tableName = TableNames.SelectItem;

            if (ExecuteType == EntityExecuteType.OnlyInsert)
            {
                if (ConnectorSelector.SelectItem is FileManager)
                {
                    var connector = FileConnector.SmartGetExport(tableName);

                    return(connector.WriteData(documents));
                }
                return
                    (documents.BatchDo(InitTable, list =>
                {
                    ConnectorSelector.SelectItem.BatchInsert(list, tableName);
                    XLogSys.Print.Info(string.Format(GlobalHelper.Get("key_350"), ConnectorSelector.SelectItem.Name, TableNames.SelectItem, list.Count));
                }));
            }
            return
                (documents.Init(InitTable).Select(
                     document =>
            {
                var v = document[Column];
                if (v == null || tableName == null)
                {
                    return document;
                }

                ConnectorSelector.SelectItem.SaveOrUpdateEntity(document, tableName,
                                                                new Dictionary <string, object> {
                    { Column, v }
                }, ExecuteType);
                return document;
            }));
        }
示例#13
0
        public override bool Init()
        {
            if (MainDescription.IsUIForm)
            {
                DataCollections = new SafeObservable <DataCollection>();
                dockableManager = MainFrmUI as IDockableManager;

                var view        = PluginProvider.GetObjectInstance <ICustomView>("系统状态视图");
                var userControl = view as UserControl;
                if (userControl != null)
                {
                    userControl.DataContext = MainFrmUI;
                    dockableManager.AddDockAbleContent(FrmState.Mini, view, "系统状态视图");
                }
            }

            else
            {
                DataCollections = new ObservableCollection <DataCollection>();
            }

            processManager = MainFrmUI.PluginDictionary["模块管理"] as IProcessManager;


            commands = new List <ICommand>();
            var dbaction = new BindingAction();

            dbaction.ChildActions.Add(new Command("配置连接",
                                                  obj =>
            {
                Window w = PropertyGridFactory.GetPropertyWindow(obj);
                w.ShowDialog();
            },
                                                  obj => obj != null));
            dbaction.ChildActions.Add(
                new Command("刷新", obj => RefreshConnect(obj as IDataBaseConnector), obj => obj != null));
            dbaction.ChildActions.Add(
                new Command("执行查询", obj =>
            {
                var query          = new QueryEntity();
                query.Connector    = obj as IDataBaseConnector;
                query.GetQueryFunc = d =>
                {
                    if (d == null)
                    {
                        return;
                    }
                    if (d.Any() == false)
                    {
                        return;
                    }

                    AddDataCollection(d, GetNewName());
                };
                propertyGridWindow.SetObjectView(query);
            }, obj => obj != null));
            dbaction.ChildActions.Add(
                new Command("删除连接", obj =>
            {
                if (MessageBox.Show("确定要删除该连接吗?", "提示信息", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
                {
                    var con = obj as DBConnectorBase;
                    _dbConnections.Remove(con);
                }
            }, obj => obj != null));
            var dataaction = new BindingAction();


            var tableAction = new BindingAction();

            tableAction.ChildActions.Add(new Command(
                                             "查看",
                                             async obj =>
            {
                var items = obj as TableInfo;
                List <IFreeDocument> dataAll = null;
                try
                {
                    dataAll = await
                              GetDataFromDB(items.Connector, items.Name, true,
                                            items.Connector is FileManager ? -1 : 200);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("文件打开失败" + ex.Message);
                    return;
                }


                if (dataAll == null || dataAll.Count == 0)
                {
                    XLogSys.Print.Warn("没有在表中的发现可用的数据");
                    return;
                }
                if (items.Connector is FileManager)
                {
                    string file = (items.Connector as FileManager).LastFileName;
                    var name    = Path.GetFileNameWithoutExtension(file);
                    AddDataCollection(dataAll, name);
                    return;
                }
                var excel = PluginProvider.GetObjectInstance <IDataViewer>("可编辑列表");
                if (excel == null)
                {
                    return;
                }
                object view = excel.SetCurrentView(dataAll.Select(d => d as IFreeDocument).ToList());

                if (ControlExtended.DockableManager != null)
                {
                    ControlExtended.DockableManager.AddDockAbleContent(
                        FrmState.Custom, view, items.Name);
                }
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             "添加到数据集",
                                             async obj =>
            {
                var items = obj as TableInfo;
                List <IFreeDocument> datas = await GetDataFromDB(items.Connector, items.Name, true);
                if (datas == null)
                {
                    return;
                }
                AddDataCollection(datas, items.Name);
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             "添加虚拟数据集",
                                             obj =>
            {
                var con = obj as TableInfo;
                ReadCollection(con.Connector, con.Name, true);
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             "删除表",
                                             obj =>
            {
                var items = obj as TableInfo;

                DropTable(items.Connector, items.Name);
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             "查看属性",
                                             obj =>
            {
                Window w = PropertyGridFactory.GetPropertyWindow(obj);
                w.ShowDialog();
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             "执行查询",
                                             obj =>
            {
                var query          = new QueryEntity();
                query.TableInfo    = obj as TableInfo;
                query.Connector    = query.TableInfo.Connector;
                query.GetQueryFunc = d =>
                {
                    if (d == null)
                    {
                        return;
                    }
                    if (d.Any() == false)
                    {
                        return;
                    }

                    AddDataCollection(d, GetNewName());
                };
                propertyGridWindow.SetObjectView(query);
            }, obj => obj != null));


            var visitData = new BindingAction("浏览方式");

            IEnumerable <Command> visitCommands = PluginProvider.GetPluginCollection(typeof(IDataViewer)).Select(
                d =>
            {
                var comm     = new Command(d.Name);
                comm.Execute = d2 =>
                {
                    var data = d2 as DataCollection;

                    if (data.Count == 0)
                    {
                        MessageBox.Show("不存在任何数据", "提示信息");
                        return;
                    }


                    ControlExtended.UIInvoke(() =>
                    {
                        var view = PluginProvider.GetObjectInstance <IDataViewer>(d.Name);

                        object r = view.SetCurrentView(data.ComputeData);

                        if (ControlExtended.DockableManager != null)
                        {
                            ControlExtended.DockableManager.AddDockAbleContent(
                                FrmState.Float, r, data.Name + " " + d.Name);
                        }
                    });
                };
                return(comm);
            });

            visitData.Execute = obj => visitCommands.FirstOrDefault(d => d.Text == "可编辑列表").Execute(obj);
            foreach (Command visitCommand in visitCommands)
            {
                visitData.ChildActions.Add(visitCommand);
            }

            dataaction.ChildActions.Add(new Command(
                                            "数据清洗", obj =>
            {
                DataCollection collection = GetCollection(obj);
                if (collection == null)
                {
                    return;
                }

                var plugin        = processManager.GetOneInstance("SmartETLTool", true, true) as SmartETLTool;
                dynamic generator = PluginProvider.GetObjectByType <IColumnProcess>("TableGE");
                generator.TableSelector.SelectItem = collection;
                plugin.CurrentETLTools.Add(generator);
                plugin.RefreshSamples(true);
                ControlExtended.DockableManager.ActiveModelContent(plugin);
            }, obj => true, "new"));
            dataaction.ChildActions.Add(new Command(
                                            "拷贝", obj =>
            {
                DataCollection collection = GetCollection(obj);
                if (collection == null)
                {
                    return;
                }
                DataCollection n = collection.Clone(true);
                n.Name           = GetNewName(collection.Name);
                DataCollections.Add(n);
            }, obj => true, "page_new"));
            var saveData = new Command("另存为", d =>
            {
                DataCollection collection = GetCollection(d);
                if (collection == null)
                {
                    return;
                }
                var ofd = new SaveFileDialog {
                    Filter = FileConnector.GetDataFilter(), DefaultExt = "*"
                };

                ofd.FileName = collection.Name + ".xlsx";
                if (ofd.ShowDialog() == true)
                {
                    string filename = ofd.FileName;
                    SaveFile(collection.Name, filename);
                }
            }, obj => true, "save");

            dataaction.ChildActions.Add(saveData);
            dataaction.ChildActions.Add(visitData);
            dataaction.ChildActions.Add(new Command(
                                            "新建",
                                            obj =>
                                            DataCollections.Add(new DataCollection(new List <IFreeDocument>())
            {
                Name = GetNewName("新建数据集")
            }), obj => true, "box"));
            dataaction.ChildActions.Add(new Command(
                                            "配置", obj =>
            {
                DataCollection collection = GetCollection(obj);
                if (collection != null)
                {
                    propertyGridWindow.SetObjectView(collection);
                }
            }, obj => true, "settings"));
            dataaction.ChildActions.Add(new Command(
                                            "删除", obj =>
            {
                DataCollection collection = GetCollection(obj);
                if (collection != null)
                {
                    DataCollections.Remove(collection);
                }
            }, obj => true, "delete"));

            var convert = new BindingAction("转换表类型");

            dataaction.ChildActions.Add(convert);
            convert.ChildActions.Add(new Command("转为非虚拟数据集", obj =>
            {
                DataCollection coll = GetCollection(obj);
                if (coll.Count > 500000)
                {
                    if (
                        MessageBox.Show("本集合数据量较大,转换可能会占用较高的内存和导致程序崩溃,确定继续吗?", "提示信息", MessageBoxButton.YesNoCancel) !=
                        MessageBoxResult.Yes)
                    {
                        return;
                    }
                }
                var docuts = new List <IFreeDocument>();
                var task   = TemporaryTask.AddTempTask("转为非虚拟数据集", coll.ComputeData, d =>
                {
                    if (d != null)
                    {
                        docuts.Add(d as IFreeDocument);
                    }
                }, result =>
                {
                    var collection = new DataCollection(docuts)
                    {
                        Name = coll.Name + '1'
                    };
                    AddDataCollection(collection);
                    this.DataCollections.Remove(coll);
                });
                processManager.CurrentProcessTasks.Add(task);
            }));
            var insertdb = new BindingAction("保存到数据库");

            insertdb.SetChildActionSource(() =>
            {
                return(_dbConnections.Select(dataBaseConnector => new Command(dataBaseConnector.Name, obj =>
                {
                    var data = obj as DataCollection;
                    processManager.CurrentProcessTasks.Add(TemporaryTask.AddTempTask(data.Name + "插入到数据库", dataBaseConnector.InserDataCollection(data), result => dataBaseConnector.RefreshTableNames(), count: data.Count / 1000));
                })).Cast <ICommand>().ToList());
            });


            dataaction.ChildActions.Add(insertdb);
            var otherDataAction = new BindingAction();

            otherDataAction.ChildActions.Add(new Command("清空数据", obj => CleanData(), obj => DataCollections.Count > 0));


            commands.Add(dbaction);
            commands.Add(tableAction);
            commands.Add(dataaction);
            commands.Add(otherDataAction);
            var dblistAction = new BindingAction("数据库管理");

            var addnew = new BindingAction("增加新连接");

            dblistAction.ChildActions.Add(addnew);
            foreach (XFrmWorkAttribute item in PluginProvider.GetPluginCollection(typeof(IDataBaseConnector)))
            {
                addnew.ChildActions.Add(new Command(item.Name)
                {
                    Execute = obj =>
                    {
                        var con  = PluginProvider.GetObjectInstance(item.MyType) as DBConnectorBase;
                        con.Name = item.Name;

                        _dbConnections.Add(con);
                    }
                });
            }
            commands.Add(dblistAction);


            dockableManager = MainFrmUI as IDockableManager;
            if (processManager?.CurrentProject != null)

            {
                LoadDataConnections();
            }
            processManager.OnCurrentProjectChanged += (s, e) => LoadDataConnections();

            ConfigUI = PropertyGridFactory.GetInstance(_dbConnections.FirstOrDefault());


            propertyGridWindow = MainFrmUI.PluginDictionary["属性配置器"] as XFrmWorkPropertyGrid;
            var changed = DataCollections as INotifyCollectionChanged;

            changed.CollectionChanged += (s, e) => OnDataSourceChanged(new EventArgs());

            return(true);
        }
示例#14
0
        public override bool Init()
        {
            if (MainDescription.IsUIForm)
            {
                DataCollections = new SafeObservable <DataCollection>();
                dockableManager = MainFrmUI as IDockableManager;
                var views = "223:Mini 794:Middle";
                foreach (var item in views.Split(' '))
                {
                    var item2   = item.Split(':');
                    var name    = item2[0];
                    var control = FrmState.Mini;
                    Enum.TryParse(item2[1], out control);
                    var itemName = "key_" + name;
                    itemName = GlobalHelper.Get(itemName);
                    var view        = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get(itemName));
                    var userControl = view as UserControl;
                    if (userControl != null)
                    {
                        if (name == "223")
                        {
                            dynamic dcontrol = userControl;
                            dataListBox = dcontrol.dataListBox as ListBox;
                        }
                        userControl.DataContext = MainFrmUI;
                        dockableManager.AddDockAbleContent(control, view, itemName);
                    }
                }
            }

            else
            {
                DataCollections = new ObservableCollection <DataCollection>();
            }

            processManager = MainFrmUI.PluginDictionary["DataProcessManager"] as IProcessManager;


            commands = new List <ICommand>();
            var dbaction = new BindingAction();

            dbaction.ChildActions.Add(new Command(GlobalHelper.Get("key_224"),
                                                  obj =>
            {
                var w = PropertyGridFactory.GetPropertyWindow(obj);
                w.ShowDialog();
            },
                                                  obj => obj != null, "edit"));
            dbaction.ChildActions.Add(
                new Command(GlobalHelper.Get("key_142"), obj => RefreshConnect(obj as IDataBaseConnector),
                            obj => obj != null, "refresh"));
            dbaction.ChildActions.Add(
                new Command(GlobalHelper.Get("key_213"), obj =>
            {
                var query          = new QueryEntity();
                query.Connector    = obj as IDataBaseConnector;
                query.GetQueryFunc = d =>
                {
                    if (d == null)
                    {
                        return;
                    }
                    if (d.Any() == false)
                    {
                        return;
                    }

                    AddDataCollection(d, GetNewName());
                };
                PropertyGridFactory.GetPropertyWindow(query).ShowDialog();
            }, obj => obj != null, "magnify"));
            dbaction.ChildActions.Add(
                new Command(GlobalHelper.Get("key_225"), obj =>
            {
                if (
                    MessageBox.Show(GlobalHelper.Get("key_226"), GlobalHelper.Get("key_99"),
                                    MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
                {
                    var con = obj as DBConnectorBase;
                    _dbConnections.Remove(con);
                }
            }, obj => obj != null, "delete"));
            var dataaction = new BindingAction();


            var tableAction = new BindingAction();

            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("view"),
                                             async obj =>
            {
                var items = obj as TableInfo;
                List <IFreeDocument> dataAll = null;
                try
                {
                    dataAll = await
                              GetDataFromDB(items.Connector, items.Name, true,
                                            items.Connector is FileManager ? -1 : 200);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(GlobalHelper.Get("key_228") + ex.Message);
                    return;
                }


                if (dataAll == null || dataAll.Count == 0)
                {
                    XLogSys.Print.Warn(GlobalHelper.Get("key_229"));
                    return;
                }
                if (items.Connector is FileManager)
                {
                    var file = (items.Connector as FileManager).LastFileName;
                    var name = Path.GetFileNameWithoutExtension(file);
                    AddDataCollection(dataAll, name, isCover: true);
                    return;
                }
                var excel = PluginProvider.GetObjectInstance <IDataViewer>(GlobalHelper.Get("key_230"));
                if (excel == null)
                {
                    return;
                }
                var view = excel.SetCurrentView(dataAll.Select(d => d).ToList());

                if (ControlExtended.DockableManager != null)
                {
                    ControlExtended.DockableManager.AddDockAbleContent(
                        FrmState.Custom, view, items.Name);
                }
            },
                                             obj => obj != null));
            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("key_231"),
                                             async obj =>
            {
                var items = obj as TableInfo;
                var datas = await GetDataFromDB(items.Connector, items.Name, true);
                if (datas == null)
                {
                    return;
                }
                AddDataCollection(datas, items.Name);
            },
                                             obj => obj != null, "add"));
            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("key_232"),
                                             obj =>
            {
                var con = obj as TableInfo;
                ReadCollection(con.Connector, con.Name, true);
            },
                                             obj => obj != null, "layer_add"));
            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("key_233"),
                                             obj =>
            {
                var items = obj as TableInfo;

                DropTable(items.Connector, items.Name);
            },
                                             obj => obj != null, "delete"));
            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("key_234"),
                                             obj =>
            {
                var w = PropertyGridFactory.GetPropertyWindow(obj);
                w.ShowDialog();
            },
                                             obj => obj != null, "edit"));
            tableAction.ChildActions.Add(new Command(
                                             GlobalHelper.Get("key_213"),
                                             obj =>
            {
                var query          = new QueryEntity();
                query.TableInfo    = obj as TableInfo;
                query.Connector    = query.TableInfo.Connector;
                query.GetQueryFunc = d =>
                {
                    if (d == null)
                    {
                        return;
                    }
                    if (d.Any() == false)
                    {
                        return;
                    }

                    AddDataCollection(d, GetNewName());
                };
                PropertyGridFactory.GetPropertyWindow(query).ShowDialog();
            }, obj => obj != null, "magnify"));


            var visitData = new BindingAction(GlobalHelper.Get("key_235"));

            var visitCommands = PluginProvider.GetPluginCollection(typeof(IDataViewer)).Select(
                d =>
            {
                var comm     = new Command(d.Name);
                comm.Execute = d2 =>
                {
                    var data = d2 as DataCollection;

                    if (data.Count == 0)
                    {
                        MessageBox.Show(GlobalHelper.Get("key_236"), GlobalHelper.Get("key_99"));
                        return;
                    }


                    ControlExtended.UIInvoke(() =>
                    {
                        var view = PluginProvider.GetObjectInstance <IDataViewer>(d.Name);

                        var r = view.SetCurrentView(data.ComputeData);

                        if (ControlExtended.DockableManager != null)
                        {
                            var window = new Window {
                                Title = data.Name + " " + d.Name
                            };
                            window.WindowState = WindowState.Maximized;
                            window.Content     = r;
                            window.Activate();
                            window.ShowDialog();
                        }
                    });
                };
                return(comm);
            });

            visitData.Execute =
                obj => visitCommands.FirstOrDefault(d => d.Text == GlobalHelper.Get("key_230")).Execute(obj);
            foreach (var visitCommand in visitCommands)
            {
                visitData.ChildActions.Add(visitCommand);
            }

            dataaction.ChildActions.Add(new Command(
                                            GlobalHelper.Get("smartetl_name"), obj =>
            {
                var collection = GetSelectedCollection(obj).FirstOrDefault();
                if (collection == null)
                {
                    return;
                }

                var plugin = processManager.GetOneInstance("SmartETLTool", true, true, true) as SmartETLTool;

                dynamic generator = PluginProvider.GetObjectByType <IColumnProcess>("TableGE");
                generator.Father  = plugin;

                generator.TableSelector.SelectItem = collection.Name;
                plugin.CurrentETLTools.Add(generator);
                plugin.ETLMount++;
                plugin.Init();

                //plugin.RefreshSamples(true);
                ControlExtended.DockableManager.ActiveModelContent(plugin);
            }, obj => true, "new"));

            var saveData = new Command(GlobalHelper.Get("key_237"), d =>
            {
                var collection = GetSelectedCollection(d).FirstOrDefault();
                if (collection == null)
                {
                    return;
                }
                var ofd = new SaveFileDialog {
                    Filter = FileConnector.GetDataFilter(), DefaultExt = "*"
                };

                ofd.FileName = collection.Name + ".xlsx";
                if (ofd.ShowDialog() == true)
                {
                    var filename = ofd.FileName;
                    SaveFile(collection.Name, filename);
                }
            }, obj => true, "save");

            dataaction.ChildActions.Add(saveData);
            dataaction.ChildActions.Add(visitData);
            dataaction.ChildActions.Add(new Command(
                                            GlobalHelper.Get("key_238"),
                                            obj =>
            {
                if (obj != null)
                {
                    foreach (var collection in GetSelectedCollection(obj))
                    {
                        if (collection == null)
                        {
                            return;
                        }
                        var n  = collection.Clone(true);
                        n.Name = GetNewName(collection.Name);
                        DataCollections.Add(n);
                    }
                }
                else
                {
                    DataCollections.Add(new DataCollection(new List <IFreeDocument>())
                    {
                        Name = GetNewName(GlobalHelper.Get("key_239"))
                    });
                }
                ;
            }, obj => true, "add"));
            dataaction.ChildActions.Add(new Command(
                                            GlobalHelper.Get("key_240"), obj =>
            {
                var collection = GetSelectedCollection(obj).ToList();

                if (!collection.Any())
                {
                    return;
                }
                PropertyGridFactory.GetPropertyWindow(collection.FirstOrDefault()).ShowDialog();
            }, obj => true, "settings"));
            dataaction.ChildActions.Add(new Command(
                                            GlobalHelper.Get("key_169"), obj =>
            {
                foreach (var collection  in GetSelectedCollection(obj))
                {
                    if (collection != null)
                    {
                        DataCollections.Remove(collection);
                    }
                }
            }, obj => true, "delete"));

            var convert = new BindingAction(GlobalHelper.Get("key_241"));

            dataaction.ChildActions.Add(convert);
            convert.ChildActions.Add(new Command(GlobalHelper.Get("key_242"), obj =>
            {
                var coll = GetSelectedCollection(obj).FirstOrDefault();
                if (coll == null)
                {
                    return;
                }
                if (coll.Count > 500000)
                {
                    if (
                        MessageBox.Show(GlobalHelper.Get("key_243"), GlobalHelper.Get("key_99"),
                                        MessageBoxButton.YesNoCancel) !=
                        MessageBoxResult.Yes)
                    {
                        return;
                    }
                }
                var docuts = new List <IFreeDocument>();
                var task   = TemporaryTask <FreeDocument> .AddTempTaskSimple(GlobalHelper.Get("key_242"), coll.ComputeData, d =>
                {
                    if (d != null)
                    {
                        docuts.Add(d);
                    }
                }, result =>
                {
                    var collection = new DataCollection(docuts)
                    {
                        Name = coll.Name + '1'
                    };
                    AddDataCollection(collection);
                    DataCollections.Remove(coll);
                });
                processManager.CurrentProcessTasks.Add(task);
            }));
            var insertdb = new BindingAction(GlobalHelper.Get("key_244"));

            insertdb.SetChildActionSource(() =>
            {
                return(_dbConnections.Select(dataBaseConnector => new Command(dataBaseConnector.Name, obj =>
                {
                    var data = obj as DataCollection;
                    processManager.CurrentProcessTasks.Add(
                        TemporaryTask <FreeDocument> .AddTempTaskSimple(data.Name + GlobalHelper.Get("key_245"),
                                                                        dataBaseConnector.InserDataCollection(data), null, continueAction: (a) => dataBaseConnector.RefreshTableNames(),
                                                                        count: data.Count / 1000));
                }, obj => dataBaseConnector.IsUseable, icon: "database")).Cast <ICommand>().ToList());
            });


            dataaction.ChildActions.Add(insertdb);
            var otherDataAction = new BindingAction();

            otherDataAction.ChildActions.Add(new Command(GlobalHelper.Get("key_132"), obj => CleanData(),
                                                         obj => DataCollections.Count > 0,
                                                         "clear"));


            commands.Add(dbaction);
            commands.Add(tableAction);
            commands.Add(dataaction);
            commands.Add(otherDataAction);
            var dblistAction = new BindingAction(GlobalHelper.Get("key_246"));

            var addnew = new BindingAction(GlobalHelper.Get("key_247"))
            {
                Icon = "add"
            };

            dblistAction.ChildActions.Add(addnew);
            foreach (var item in PluginProvider.GetPluginCollection(typeof(IDataBaseConnector)))
            {
                addnew.ChildActions.Add(new Command(item.Name)
                {
                    Execute = obj =>
                    {
                        var con  = PluginProvider.GetObjectInstance(item.MyType) as DBConnectorBase;
                        con.Name = item.Name;

                        _dbConnections.Add(con);
                    },
                    Icon = "connect"
                });
            }
            commands.Add(dblistAction);


            dockableManager = MainFrmUI as IDockableManager;
            if (processManager?.CurrentProject != null)

            {
                LoadDataConnections(processManager.CurrentProject.DBConnections);
            }

            if (MainDescription.IsUIForm)
            {
                ConfigUI = PropertyGridFactory.GetInstance(_dbConnections.FirstOrDefault());
            }

            var changed = DataCollections as INotifyCollectionChanged;

            changed.CollectionChanged += (s, e) => OnDataSourceChanged(new EventArgs());

            return(true);
        }