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); }
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)); }
public static void WriteAll(this IFileConnector connector, IEnumerable <IFreeDocument> data) { var r = connector.WriteData(data).LastOrDefault(); }