Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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;
            }));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
Archivo: DbEx.cs Proyecto: 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;
            }));
        }
Ejemplo n.º 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 =>
                {
                    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;
            }));
        }