示例#1
0
        public static List <IFreeDocument> ReadGroupDataFile(string path)
        {
            IFileConnector json = SmartGetExport(path);

            json.FileName = path;
            return(json.ReadFile().ToList());
        }
示例#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 SaveDataFile(string filename, IEnumerable <IFreeDocument> items)
        {
            IFileConnector json = SmartGetExport(filename);

            json.FileName = filename;

            json.WriteAll(items);
        }
示例#4
0
        public static IFreeDocument ReadDataFile(string path)
        {
            IFileConnector json = SmartGetExport(path);

            json.FileName = path;
            IFreeDocument r = json.ReadFile().LastOrDefault();

            return(r);
        }
示例#5
0
文件: FileEx.cs 项目: colinye/Hawk-1
        public static void WriteAll(this IFileConnector connector, IEnumerable <IFreeDocument> data)
        {
            Monitor.Enter(connector);//锁定,保持同步


            var r = connector.WriteData(data).LastOrDefault();

            Monitor.Exit(connector);//锁定,保持同步
            Thread.Sleep(200);
        }
示例#6
0
        public static void SaveDataFile(string filename, IFreeDocument item)
        {
            IFileConnector json = SmartGetExport(filename);

            json.FileName = filename;
            var datas = new List <IFreeDocument> {
                item
            };

            json.WriteAll(datas);
        }
示例#7
0
        public virtual void ReadConfig(string path = null)
        {
            if (path == null)
            {
                path = SavePath;
            }
            IFileConnector json = FileConnector.SmartGetExport(path);

            json.FileName = path;
            IDictionarySerializable da = json.ReadFile().FirstOrDefault();

            DictDeserialize(da.DictSerialize());
        }
示例#8
0
        public virtual void SaveConfig(string path = null)
        {
            if (path == null)
            {
                path = SavePath;
            }
            IFileConnector json = FileConnector.SmartGetExport(path);

            var Datas = new List <IFreeDocument> {
                DictSerialize()
            };

            json.WriteAll(Datas);
        }
示例#9
0
        public static string GetCollectionString(IEnumerable <IFreeDocument> datas, string format = "xml")
        {
            IFileConnector connector = null;

            switch (format)
            {
            case "xml":
                connector = new FileConnectorXML();
                break;

            case "json":
                connector = new FileConnectorXML();
                break;
            }
            return(connector.GetString(datas));

            ;
        }
示例#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
        public static bool CheckFilePath(this IFileConnector connector, FileOperate readOrWrite)
        {
            if (connector.FileName == null && MainDescription.IsUIForm)
            {
                if (readOrWrite == FileOperate.Read)
                {
                    var ofd = new OpenFileDialog();

                    ofd.DefaultExt = connector.ExtentFileName;
                    ofd.Filter     = String.Join("|", connector.ExtentFileName.Split(' ').Select(d => string.Format("(*{0})|*{0}", d)));

                    if (ofd.ShowDialog() == true)
                    {
                        connector.FileName = ofd.FileName;
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    var ofd = new SaveFileDialog();
                    ofd.FileName   = connector.FileName;
                    ofd.DefaultExt = connector.ExtentFileName.Split(' ')[0];
                    ofd.Filter     = String.Join("|", connector.ExtentFileName.Split(' ').Select(d => string.Format("(*{0})|*{0}", d)));

                    if (ofd.ShowDialog() == true)
                    {
                        connector.FileName = ofd.FileName;
                    }
                    else
                    {
                        return(false);
                    }
                }
            }


            return(true);
        }
示例#12
0
 public NtfsCrawlJob(IIntegrationCoordinatorService integrationCoordinatorService, IJobService jobService, IFileConnector fileConnector)
     : base(integrationCoordinatorService, jobService)
 {
     _fileConnector = fileConnector;
 }
示例#13
0
 public static void WriteAll(this IFileConnector connector, IEnumerable <IFreeDocument> data)
 {
     var r = connector.WriteData(data).LastOrDefault();
 }