public static bool Export(PwExportInfo pwExportInfo, IStatusLogger slLogger) { if (pwExportInfo == null) { throw new ArgumentNullException("pwExportInfo"); } if (pwExportInfo.DataGroup == null) { throw new ArgumentException(); } if (!AppPolicy.Try(AppPolicyId.Export)) { return(false); } ExchangeDataForm dlg = new ExchangeDataForm(); dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup); if (dlg.ShowDialog() == DialogResult.OK) { FileFormatProvider ffp = dlg.ResultFormat; if (ffp == null) { Debug.Assert(false); return(false); } if (ffp.RequiresFile) { if (dlg.ResultFiles.Length != 1) { Debug.Assert(false); return(false); } if (dlg.ResultFiles[0] == null) { Debug.Assert(false); return(false); } if (dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); return(false); } } Application.DoEvents(); // Redraw parent window IOConnectionInfo iocOutput = (ffp.RequiresFile ? IOConnectionInfo.FromPath( dlg.ResultFiles[0]) : null); try { return(Export(pwExportInfo, dlg.ResultFormat, iocOutput, slLogger)); } catch (Exception ex) { MessageService.ShowWarning(ex); } } return(false); }
public static bool Export(PwExportInfo pwExportInfo, IStatusLogger slLogger) { if (pwExportInfo == null) { throw new ArgumentNullException("pwExportInfo"); } if (pwExportInfo.DataGroup == null) { throw new ArgumentException(); } if (!AppPolicy.Try(AppPolicyId.Export)) { return(false); } ExchangeDataForm dlg = new ExchangeDataForm(); dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup); bool bResult = false; if (dlg.ShowDialog() == DialogResult.OK) { FileFormatProvider ffp = dlg.ResultFormat; if (ffp == null) { Debug.Assert(false); goto ExpZRet; } if (ffp.RequiresFile) { if (dlg.ResultFiles.Length != 1) { Debug.Assert(false); goto ExpZRet; } if (dlg.ResultFiles[0] == null) { Debug.Assert(false); goto ExpZRet; } if (dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); goto ExpZRet; } } IOConnectionInfo iocOutput = (ffp.RequiresFile ? IOConnectionInfo.FromPath( dlg.ResultFiles[0]) : null); Application.DoEvents(); // Redraw parent window bResult = Export(pwExportInfo, ffp, iocOutput, slLogger); } ExpZRet: UIUtil.DestroyForm(dlg); return(bResult); }
public static void Export(PwExportInfo pwExportInfo, IStatusLogger slLogger) { if (pwExportInfo == null) { throw new ArgumentNullException("pwExportInfo"); } if (pwExportInfo.DataGroup == null) { throw new ArgumentException(); } if (!AppPolicy.Try(AppPolicyId.Export)) { return; } ExchangeDataForm dlg = new ExchangeDataForm(); dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.ResultFormat == null) { Debug.Assert(false); return; } if (dlg.ResultFiles.Length != 1) { Debug.Assert(false); return; } if (dlg.ResultFiles[0] == null) { Debug.Assert(false); return; } if (dlg.ResultFiles[0].Length == 0) { Debug.Assert(false); return; } Application.DoEvents(); // Redraw parent window try { PerformExport(pwExportInfo, dlg.ResultFormat, dlg.ResultFiles[0], slLogger); } catch (Exception ex) { MessageService.ShowWarning(ex); } } }
public static bool?Import(PwDatabase pwStorage, out bool bAppendedToRootOnly, Form fParent) { bAppendedToRootOnly = false; if (pwStorage == null) { throw new ArgumentNullException("pwStorage"); } if (!pwStorage.IsOpen) { return(null); } if (!AppPolicy.Try(AppPolicyId.Import)) { return(null); } ExchangeDataForm dlgFmt = new ExchangeDataForm(); dlgFmt.InitEx(false, pwStorage, pwStorage.RootGroup); if (UIUtil.ShowDialogNotValue(dlgFmt, DialogResult.OK)) { return(null); } Debug.Assert(dlgFmt.ResultFormat != null); if (dlgFmt.ResultFormat == null) { MessageService.ShowWarning(KPRes.ImportFailed); UIUtil.DestroyForm(dlgFmt); return(false); } bAppendedToRootOnly = dlgFmt.ResultFormat.ImportAppendsToRootGroupOnly; FileFormatProvider ffp = dlgFmt.ResultFormat; List <IOConnectionInfo> lConnections = new List <IOConnectionInfo>(); foreach (string strSelFile in dlgFmt.ResultFiles) { lConnections.Add(IOConnectionInfo.FromPath(strSelFile)); } UIUtil.DestroyForm(dlgFmt); return(Import(pwStorage, ffp, lConnections.ToArray(), false, null, false, fParent)); }
public static void ImportInto(PwDatabase pwStorage, out bool bAppendedToRootOnly) { bAppendedToRootOnly = false; if (pwStorage == null) { throw new ArgumentNullException("pwStorage"); } if (!pwStorage.IsOpen) { return; } if (!AppPolicy.Try(AppPolicyId.Import)) { return; } ExchangeDataForm dlgFmt = new ExchangeDataForm(); dlgFmt.InitEx(false, pwStorage, pwStorage.RootGroup); if (dlgFmt.ShowDialog() == DialogResult.OK) { Debug.Assert(dlgFmt.ResultFormat != null); if (dlgFmt.ResultFormat == null) { MessageService.ShowWarning(KPRes.ImportFailed); return; } bAppendedToRootOnly = dlgFmt.ResultFormat.ImportAppendsToRootGroupOnly; List <IOConnectionInfo> lConnections = new List <IOConnectionInfo>(); foreach (string strSelFile in dlgFmt.ResultFiles) { lConnections.Add(IOConnectionInfo.FromPath(strSelFile)); } PerformImport(pwStorage, dlgFmt.ResultFormat, lConnections.ToArray(), false, null, false); } }
public static bool Export(PwExportInfo pwExportInfo, IStatusLogger slLogger) { if (pwExportInfo == null) { throw new ArgumentNullException("pwExportInfo"); } if (pwExportInfo.DataGroup == null) { throw new ArgumentException(); } if (!AppPolicy.Try(AppPolicyId.Export)) { return(false); } ExchangeDataForm dlg = new ExchangeDataForm(); dlg.InitEx(true, pwExportInfo.ContextDatabase, pwExportInfo.DataGroup); dlg.ExportInfo = pwExportInfo; bool bStatusActive = false; try { if (dlg.ShowDialog() == DialogResult.OK) { FileFormatProvider ffp = dlg.ResultFormat; if (ffp == null) { Debug.Assert(false); return(false); } IOConnectionInfo ioc = null; if (ffp.RequiresFile) { string[] vFiles = dlg.ResultFiles; if (vFiles == null) { Debug.Assert(false); return(false); } if (vFiles.Length == 0) { Debug.Assert(false); return(false); } Debug.Assert(vFiles.Length == 1); string strFile = vFiles[0]; if (string.IsNullOrEmpty(strFile)) { Debug.Assert(false); return(false); } ioc = IOConnectionInfo.FromPath(strFile); } if (slLogger != null) { slLogger.StartLogging(KPRes.ExportingStatusMsg, true); bStatusActive = true; } Application.DoEvents(); // Redraw parent window return(Export(pwExportInfo, ffp, ioc, slLogger)); } } catch (Exception ex) { MessageService.ShowWarning(ex); } finally { UIUtil.DestroyForm(dlg); if (bStatusActive) { slLogger.EndLogging(); } } return(false); }