static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); //string titleArgument = commandLine.GetArgument("title"); string packagePath = commandLine.GetArgument("package"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); string autorun = commandLine.GetArgument("autorun"); string merge = commandLine.GetArgument("merge"); try { Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog M = null; Project destinationProject = null; View destinationView = null; Epi.ImportExport.DataMergeType mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; if (!string.IsNullOrEmpty(merge)) { switch (merge.ToLower()) { case "1": mergeType = Epi.ImportExport.DataMergeType.UpdateOnly; break; case "2": mergeType = Epi.ImportExport.DataMergeType.AppendOnly; break; default: mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; break; } } M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(); if (!string.IsNullOrEmpty(projectPath) && !(string.IsNullOrEmpty(viewName))) { destinationProject = new Project(projectPath); if (destinationProject.Views.Contains(viewName)) { destinationView = destinationProject.Views[viewName]; } } if (!string.IsNullOrEmpty(packagePath) && destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, packagePath, mergeType); } else if(destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, mergeType); } if (!string.IsNullOrEmpty(autorun) && autorun.ToLower().Equals("true") && M != null) { M.CloseOnFinish = true; M.StartImportPackage(); } //if (!string.IsNullOrEmpty(projectPath)) //{ // Project p = new Project(projectPath); // M.FireOpenViewEvent(p.Views[viewName]); //} //else //{ if (!M.IsDisposed) { M.Show(); if (M.WindowState == FormWindowState.Minimized) { M.WindowState = FormWindowState.Normal; } M.Activate(); } //} System.Windows.Forms.Application.Run(M); M = null; } catch (Exception ex) { //MsgBox.ShowError(SharedStrings.WARNING_APPLICATION_RUNNING); MsgBox.ShowError(string.Format("Error: \n {0}", ex.ToString())); } finally { } } }
static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); if (LoadConfiguration(args)) { Configuration.Environment = ExecutionEnvironment.WindowsApplication; ICommandLine commandLine = new CommandLine(args); //string titleArgument = commandLine.GetArgument("title"); string packagePath = commandLine.GetArgument("package"); string projectPath = commandLine.GetArgument("project"); string viewName = commandLine.GetArgument("view"); string autorun = commandLine.GetArgument("autorun"); string merge = commandLine.GetArgument("merge"); try { Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog M = null; Project destinationProject = null; View destinationView = null; Epi.ImportExport.DataMergeType mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; if (!string.IsNullOrEmpty(merge)) { switch (merge.ToLowerInvariant()) { case "1": mergeType = Epi.ImportExport.DataMergeType.UpdateOnly; break; case "2": mergeType = Epi.ImportExport.DataMergeType.AppendOnly; break; default: mergeType = Epi.ImportExport.DataMergeType.UpdateAndAppend; break; } } M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(); if (!string.IsNullOrEmpty(projectPath) && !(string.IsNullOrEmpty(viewName))) { destinationProject = new Project(projectPath); if (destinationProject.Views.Contains(viewName)) { destinationView = destinationProject.Views[viewName]; } } if (!string.IsNullOrEmpty(packagePath) && destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, packagePath, mergeType); } else if (destinationView != null) { M = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView, mergeType); } if (!string.IsNullOrEmpty(autorun) && autorun.ToLowerInvariant().Equals("true") && M != null) { M.CloseOnFinish = true; M.StartImportPackage(); } //if (!string.IsNullOrEmpty(projectPath)) //{ // Project p = new Project(projectPath); // M.FireOpenViewEvent(p.Views[viewName]); //} //else //{ if (!M.IsDisposed) { M.Show(); if (M.WindowState == FormWindowState.Minimized) { M.WindowState = FormWindowState.Normal; } M.Activate(); } //} System.Windows.Forms.Application.Run(M); M = null; } catch (Exception ex) { //MsgBox.ShowError(SharedStrings.WARNING_APPLICATION_RUNNING); MsgBox.ShowError(string.Format("Error: \n {0}", ex.ToString())); } finally { } } }
/// <summary> /// Imports data from a similar form that was contained in a data package (EDP file) /// </summary> /// <param name="destinationView">The view that will accept the incoming data</param> private void ImportFormDataFromPackage(View destinationView) { if (destinationView.IsRelatedView) { Epi.Windows.MsgBox.ShowInformation(SharedStrings.ERROR_IMPORT_PACKAGE_RELATED_FORM); return; } Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog importDataForm = new Epi.Windows.ImportExport.Dialogs.ImportEncryptedDataPackageDialog(destinationView); DialogResult result = importDataForm.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { if (this.View != null) { if (IsRecordCloseable == false) { return; } if (CloseView() == false) { return; } } this.view = destinationView; Project project = view.Project; if (!project.CollectedData.TableExists(view.TableName)) { MsgBox.ShowError("Something that should never fail has failed."); } if (this.OpenViewEvent != null) { this.OpenViewEvent(this, new Epi.Windows.Enter.PresentationLogic.OpenViewEventArgs(view)); } } }