InitEx() public method

public InitEx ( bool bExport, KeePassLib.PwDatabase pwDatabaseInfo, PwGroup pgRootInfo ) : void
bExport bool
pwDatabaseInfo KeePassLib.PwDatabase
pgRootInfo PwGroup
return void
コード例 #1
0
ファイル: ExportUtil.cs プロジェクト: ComradeP/KeePass-2.x
		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;
		}
コード例 #2
0
ファイル: ImportUtil.cs プロジェクト: ComradeP/KeePass-2.x
		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(dlgFmt.ShowDialog() == DialogResult.OK)
			{
				Debug.Assert(dlgFmt.ResultFormat != null);
				if(dlgFmt.ResultFormat == null)
				{
					MessageService.ShowWarning(KPRes.ImportFailed);
					return false;
				}

				bAppendedToRootOnly = dlgFmt.ResultFormat.ImportAppendsToRootGroupOnly;

				List<IOConnectionInfo> lConnections = new List<IOConnectionInfo>();
				foreach(string strSelFile in dlgFmt.ResultFiles)
					lConnections.Add(IOConnectionInfo.FromPath(strSelFile));

				return Import(pwStorage, dlgFmt.ResultFormat, lConnections.ToArray(),
					false, null, false, fParent);
			}

			return null;
		}
コード例 #3
0
ファイル: ExportUtil.cs プロジェクト: jonbws/strengthreport
        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);
                }
            }
        }