//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Static Helpers //UI Helper to Request Acronym for Terminal Series public static logicpos.Utils.ResponseText PosConfirmAcronymSeriesDialog(Window pSourceWindow, FIN_DocumentFinanceYears pDocumentFinanceYear, DataTable pTerminals, string pInitialValue) { logicpos.Utils.ResponseText result = new Utils.ResponseText(); FrameworkCallsResult frameworkCallsResult; try { string fileWindowIcon = FrameworkUtils.OSSlash(GlobalFramework.Path["images"] + @"Icons\Windows\icon_window_input_text_default.png"); PosInputTextDialog dialog = new PosInputTextDialog( pSourceWindow, DialogFlags.Modal, new System.Drawing.Size(800, 600), Resx.window_title_series_create_series, fileWindowIcon, Resx.global_acronym, pInitialValue, SettingsApp.RegexDocumentSeriesAcronym, true ); //Initialize EntryBoxValidationMultiLine EntryBoxValidationMultiLine entryBoxValidationMultiLine = new EntryBoxValidationMultiLine(pSourceWindow, Resx.global_preview); entryBoxValidationMultiLine.HeightRequest = 420; entryBoxValidationMultiLine.EntryMultiline.TextView.WrapMode = WrapMode.Word; entryBoxValidationMultiLine.EntryMultiline.TextView.Sensitive = false; //Start with Preview frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, pTerminals, dialog.EntryBoxValidation.EntryValidation.Text, true); entryBoxValidationMultiLine.EntryMultiline.TextView.Buffer.Text = frameworkCallsResult.Output; //Pack Widgets dialog.VBoxContent.PackStart(entryBoxValidationMultiLine, true, true, 0); dialog.VBoxContent.ShowAll(); dialog.EntryBoxValidation.EntryValidation.Changed += delegate { if (dialog.EntryBoxValidation.EntryValidation.Validated) { frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, pTerminals, dialog.EntryBoxValidation.EntryValidation.Text, true); entryBoxValidationMultiLine.EntryMultiline.TextView.Buffer.Text = frameworkCallsResult.Output; } }; ResponseType responseType = (ResponseType)dialog.Run(); result.ResponseType = responseType; if (responseType == ResponseType.Ok) { result.Text = dialog.Value; } dialog.Destroy(); } catch (Exception ex) { _log.Error(ex.Message, ex); } return(result); }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //FinanceDocumentPayments public static fin_documentfinancepayment PersistFinanceDocumentPayment() { //All Documents, usefull to Split into Invoices and CreditNotes List <Guid> listDocuments = new List <Guid>(); List <fin_documentfinancemaster> listInvoices = new List <fin_documentfinancemaster>(); List <fin_documentfinancemaster> listCreditNotes = new List <fin_documentfinancemaster>(); //listDocuments.Add(new Guid("a067b55b-09b5-4a48-a386-e9d04777540b"));//NC NCCKOQ5R5012016S001/1 //listDocuments.Add(new Guid("92c5c809-0387-4d1f-93c6-afeb6f291149"));//FT FTCKOQ5R5012016S001/1 //Used listDocuments.Add(new Guid("e00cde4c-2218-4c03-ac4b-161b2b89032b")); //NC NCCKOQ5R5012016S001/2 listDocuments.Add(new Guid("ed8e5198-f253-4198-be18-fff188a7d3b4")); //NC NCCKOQ5R5012016S001/3 listDocuments.Add(new Guid("dc4b8170-2b61-4ed4-ad8b-77aaf8a4c695")); //FT FTCKOQ5R5012016S001/3 listDocuments.Add(new Guid("36e49eb1-5e94-47e4-9467-8365ec71e099")); //FT FTCKOQ5R5012016S001/4 listDocuments.Add(new Guid("529f5d2d-4202-4207-b15f-2d58d56c4ebe")); //FT FTCKOQ5R5012016S001/6 //Force Errors : Invalid Documents listDocuments.Add(new Guid("41ba3dfa-8afa-48bd-aa56-1b51015e7c0c")); //GT GTCKOQ5R5012016S001/1 Mário Fernandes invalid document + diferent customer listDocuments.Add(new Guid("a067b55b-09b5-4a48-a386-e9d04777540b")); //NC NCCKOQ5R5012016S001/1 Carlos Fernandes Payed listDocuments.Add(new Guid("92c5c809-0387-4d1f-93c6-afeb6f291149")); //FT FTCKOQ5R5012016S001/1 Carlos Fernandes Payed listDocuments.Add(new Guid("2813d769-3065-44fb-b48f-a8f7a42a0456")); //FT FTCKOQ5R5012016S001/5 Carlos DocumentStatusStatus = A //Other Parameters //decimal paymentAmount = 28.17m;//Euro decimal paymentAmount = 517.06m;//Kwanza string paymentNotes = "$#%#$&%»»'@£§€"; //Prepare listInvoices and listCreditNotes foreach (Guid item in listDocuments) { fin_documentfinancemaster documentFinanceMaster = (fin_documentfinancemaster)GlobalFramework.SessionXpo.GetObjectByKey(typeof(fin_documentfinancemaster), item); if (documentFinanceMaster.DocumentType.Credit) { listInvoices.Add(documentFinanceMaster); } else { listCreditNotes.Add(documentFinanceMaster); } } fin_documentfinancepayment documentFinancePayment = ProcessFinanceDocument.PersistFinanceDocumentPayment(listInvoices, listCreditNotes, SettingsApp.XpoOidDocumentCustomer, SettingsApp.XpoOidDocumentPaymentMethod, SettingsApp.XpoOidDocumentCurrency, paymentAmount, paymentNotes); if (documentFinancePayment != null) { Console.WriteLine(string.Format("documentFinancePayment.PaymentRefNo: [{0}]", documentFinancePayment.PaymentRefNo)); sys_configurationprinterstemplates template = ProcessFinanceDocumentSeries.GetDocumentFinanceYearSerieTerminal(GlobalFramework.SessionXpo, documentFinancePayment.DocumentType.Oid).Template; //TK016249 - Impressoras - Diferenciação entre Tipos PrintRouter.PrintFinanceDocumentPayment(GlobalFramework.LoggedTerminal.ThermalPrinter, documentFinancePayment); } return(documentFinancePayment); }
void TreeViewDocumentFinanceYears_RecordAfterInsert(object sender, EventArgs e) { try { //Get References to TreeViewDocumentFinanceSeries and TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceSeries treeViewDocumentFinanceSeries = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceSeries"].Content as TreeViewDocumentFinanceSeries); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; //Refresh TreeViews after Insert Record, and Hide old Series Refresh(); treeViewDocumentFinanceSeries.Refresh(); if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } //Apply Permissions ButtonCreateDocumentFinanceSeries treeViewDocumentFinanceSeries.ButtonCreateDocumentFinanceSeries.Sensitive = FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCESERIES_MANAGE_SERIES"); //Request Create Series for all Type of Finance Documents ResponseType responseType = Utils.ShowMessageTouch( _sourceWindow, DialogFlags.Modal, new Size(600, 400), MessageType.Question, ButtonsType.YesNo, Resx.window_title_series_create_series, Resx.dialog_message_series_create_document_type_series ); if (responseType == ResponseType.Yes) { //Get Current Active FinanceYear FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); bool result = TreeViewDocumentFinanceSeries.UICreateDocumentFinanceYearSeriesTerminal(_sourceWindow, currentDocumentFinanceYear); } } catch (Exception ex) { _log.Error(ex.Message, ex); } }
void TreeViewDocumentFinanceYears_RecordBeforeInsert(object sender, EventArgs e) { try { //Get Current Active FinanceYear FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); //If has Active FiscalYear, Show Warning Request to Close/Open if (currentDocumentFinanceYear != null) { ResponseType responseType = Utils.ShowMessageTouch( GlobalApp.WindowStartup, DialogFlags.Modal, new Size(600, 400), MessageType.Question, ButtonsType.YesNo, Resx.window_title_series_fiscal_year_close_current, string.Format(Resx.dialog_message_series_fiscal_year_close_current, currentDocumentFinanceYear.Designation) ); //Override Insert CRUD ShowDialog using SkipRecordInsert, this prevent create Record _skipRecordInsert = (responseType == ResponseType.No); if (responseType == ResponseType.Yes) { //Disable All Related Year Series and TerminalSeries bool resultDisableFiscalYear = ProcessFinanceDocumentSeries.DisableActiveYearSeriesAndTerminalSeries(currentDocumentFinanceYear); //Now we can disable currentDocumentFinanceYear if (resultDisableFiscalYear) { //Disable Object currentDocumentFinanceYear.Disabled = true; currentDocumentFinanceYear.Save(); } } } } catch (Exception ex) { _log.Error(ex.Message, ex); } }
//XpoMode public TreeViewDocumentFinanceSeries(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default) { //Assign Parameters to Members _sourceWindow = pSourceWindow; //Init Vars Type xpoGuidObjectType = typeof(FIN_DocumentFinanceSeries); //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView FIN_DocumentFinanceSeries defaultValue = (pDefaultValue != null) ? pDefaultValue as FIN_DocumentFinanceSeries : null; //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogDocumentFinanceSeries); //Configure columnProperties List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>(); columnProperties.Add(new GenericTreeViewColumnProperty("FiscalYear") { Title = Resx.global_fiscal_year, ChildName = "Designation", MinWidth = 160 }); columnProperties.Add(new GenericTreeViewColumnProperty("DocumentType") { Title = Resx.global_documentfinanceseries_documenttype, ChildName = "Designation", Expand = true }); columnProperties.Add(new GenericTreeViewColumnProperty("Designation") { Title = Resx.global_designation, Expand = true }); columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt") { Title = Resx.global_record_date_updated, MinWidth = 150, MaxWidth = 150 }); //Configure Criteria/XPCollection/Model : Use Default Filter CriteriaOperator criteria = (ReferenceEquals(pXpoCriteria, null)) // Generate Default Criteria ? CriteriaOperator.Parse("(Disabled = 0 OR Disabled IS NULL)") // Add to Parameter Criteria : CriteriaOperator.Parse(string.Format("(Disabled = 0 OR Disabled IS NULL) AND ({0})", pXpoCriteria.ToString())) ; XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria); //Call Base Initializer base.InitObject( pSourceWindow, //Pass parameter defaultValue, //Pass parameter pGenericTreeViewMode, //Pass parameter pGenericTreeViewNavigatorMode, //Pass parameter columnProperties, //Created Here xpoCollection, //Created Here typeDialogClass //Created Here ); //Add Extra Button to Navigator _buttonCreateDocumentFinanceSeries = Navigator.GetNewButton("touchButtonCreateDocumentFinanceSeries_DialogActionArea", Resx.pos_button_create_series, @"Icons/icon_pos_nav_new.png"); //_buttonCreateDocumentFinanceSeries.WidthRequest = 110; //Check if Has an Active Year Open before apply Permissions FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); //Apply Permissions _buttonCreateDocumentFinanceSeries.Sensitive = (currentDocumentFinanceYear != null && FrameworkUtils.HasPermissionTo("BACKOFFICE_MAN_DOCUMENTFINANCESERIES_MANAGE_SERIES")); //Event _buttonCreateDocumentFinanceSeries.Clicked += buttonCreateDocumentFinanceSeries_Clicked; //Add to Extra Slot Navigator.ExtraSlot.PackStart(_buttonCreateDocumentFinanceSeries, false, false, 0); }
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Shared UI Helper to Request Selected Terminals to send to ProcessFinanceDocumentSeries (Framework) public static bool UICreateDocumentFinanceYearSeriesTerminal(Window pSourceWindow, FIN_DocumentFinanceYears pDocumentFinanceYear) { bool result = false; try { //Refresh Terminal XPO Object XPCollection xpcConfigurationPlaceTerminal = new XPCollection(GlobalFramework.SessionXpo, typeof(POS_ConfigurationPlaceTerminal)); xpcConfigurationPlaceTerminal.Reload(); //Get Terminals DataTable dataTableSelectedTerminals = PosSelectRecordDialog <DataTable, DataRow, TreeViewTerminalSeries> .GetSelected(pSourceWindow); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceSeries treeViewDocumentFinanceSeries = ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceSeries")) ? ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceSeries"].Content as TreeViewDocumentFinanceSeries) : null; //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((pSourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; if (dataTableSelectedTerminals != null && dataTableSelectedTerminals.Rows.Count > 0) { //Request Acronym //string initialValue = string.Format("{0}{1}", pDocumentFinanceYear.Acronym, "01"); string initialValue = pDocumentFinanceYear.Acronym; logicpos.Utils.ResponseText resultAcronym = TreeViewDocumentFinanceSeries.PosConfirmAcronymSeriesDialog(pSourceWindow, pDocumentFinanceYear, dataTableSelectedTerminals, initialValue); // Protect to Skip Cancel if (resultAcronym.ResponseType == ResponseType.Ok) { int sqlCheckExistingSeriesResultInt = 0; string sqlCheckExistingSeries = "SELECT COUNT(*) AS Count FROM fin_documentfinanceseries WHERE (Disabled = 0 OR Disabled IS NULL);"; object sqlCheckExistingSeriesResult = GlobalFramework.SessionXpo.ExecuteScalar(sqlCheckExistingSeries); if (sqlCheckExistingSeriesResult != null) { sqlCheckExistingSeriesResultInt = Convert.ToInt16(sqlCheckExistingSeriesResult); } //Request User Confirmation if already has working Series ResponseType responseType = ResponseType.No; if (resultAcronym.ResponseType == ResponseType.Ok && sqlCheckExistingSeriesResultInt > 0) { responseType = Utils.ShowMessageTouch( GlobalApp.WindowStartup, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, Resx.window_title_series_create_series, Resx.dialog_message_series_create_confirmation_text ); } else { //Auto Yes, if dont have series, assumes Yes responseType = ResponseType.Yes; } if (responseType == ResponseType.Yes) { //Get Result FrameworkCallsResult frameworkCallsResult = ProcessFinanceDocumentSeries.CreateDocumentFinanceYearSeriesTerminal(pDocumentFinanceYear, dataTableSelectedTerminals, resultAcronym.Text, false); //Prepare Result result = frameworkCallsResult.Result; //Refresh Child Trees DocumentFinanceYearSerieTerminal if (result) { //Refresh TreeViewDocumentFinanceSeries (If Visible/Enabled) if (treeViewDocumentFinanceSeries != null) { treeViewDocumentFinanceSeries.Refresh(); } //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } } //Show Error to User, Outside of Framework (Non UI) else { Utils.ShowMessageTouch( pSourceWindow, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Resx.global_error, string.Format("{0}{1}{1}{2}", string.Format(Resx.dialog_message_series_create_error, resultAcronym.Text), Environment.NewLine, frameworkCallsResult.Exception.InnerException.Message ) ); } } } } } catch (Exception ex) { _log.Error(ex.Message, ex); } return(result); }
private void buttonCreateDocumentFinanceSeries_Clicked(object sender, EventArgs e) { try { //Refresh Terminal XPO Object XPCollection xpcDocumentFinanceYears = new XPCollection(GlobalFramework.SessionXpo, typeof(FIN_DocumentFinanceYears)); xpcDocumentFinanceYears.Reload(); //Store Reference to BackOffice TreeViewDocumentFinanceYearSerieTerminal TreeViewDocumentFinanceYearSerieTerminal treeViewDocumentFinanceYearSerieTerminal = ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs.ContainsKey("DocumentFinanceYearSerieTerminal")) ? ((_sourceWindow as BackOfficeMainWindow).Accordion.Nodes["TopMenuDocuments"].Childs["DocumentFinanceYearSerieTerminal"].Content as TreeViewDocumentFinanceYearSerieTerminal) : null; //Internal Shared Action to Refresh Components var internalMethodRefreshComponents = new System.Action(() => { //Refresh Current Tree Model Refresh(); //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } }); //Get Current Active FinanceYear FIN_DocumentFinanceYears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); //If has Active FiscalYear, Show Warning Request to Close/Open if (currentDocumentFinanceYear != null) { //Call Create Series UI bool result = UICreateDocumentFinanceYearSeriesTerminal(_sourceWindow, currentDocumentFinanceYear); //Refresh Current Tree Model if (result) { //Refresh Current Tree Model Refresh(); //Refresh TreeViewDocumentFinanceYearSerieTerminal (If Visible/Enabled) if (treeViewDocumentFinanceYearSerieTerminal != null) { treeViewDocumentFinanceYearSerieTerminal.Refresh(); } } } else { ResponseType responseType = Utils.ShowMessageTouch( _sourceWindow, DialogFlags.Modal, new Size(600, 400), MessageType.Error, ButtonsType.Close, Resx.window_title_series_create_series, Resx.dialog_message_series_create_document_type_series_miss_year ); //Disable Button, Extra protection for deleted year outside App _buttonCreateDocumentFinanceSeries.Sensitive = false; } } catch (Exception ex) { _log.Error(ex.Message, ex); } }
public static bool PrintFinanceDocument(Session pSession, FIN_DocumentFinanceMaster pDocumentFinanceMaster, List <int> pCopyNames, bool pSecondCopy, string pMotive) { bool result = false; try { //Finish Payment with Print Job + Open Drawer (If Not TableConsult) FIN_DocumentFinanceYearSerieTerminal xDocumentFinanceYearSerieTerminal = ProcessFinanceDocumentSeries.GetDocumentFinanceYearSerieTerminal(pSession, pDocumentFinanceMaster.DocumentType.Oid); PrintFinanceDocument(GlobalFramework.LoggedTerminal.Printer, pDocumentFinanceMaster, pCopyNames, pSecondCopy, pMotive); //Open Door if Has Valid Payment if (pDocumentFinanceMaster.PaymentMethod != null) { OpenDoor(GlobalFramework.LoggedTerminal.Printer); } result = true; } catch (Exception ex) { _log.Warn(ex.Message, ex); throw new Exception(ex.Message); } return(result); }
public static bool Restore(Window pSourceWindow, DataBaseRestoreFrom pRestoreFrom) { try { //FrameworkUtils.ShowWaitingCursor(); Init(); bool restoreResult = false; string sql = string.Empty; string fileName = string.Empty; string fileNamePacked = string.Empty; //default pathBackups from Settings, can be Overrided in ChooseFromFilePickerDialog Mode string pathBackups = _pathBackups; DataBaseBackupFileInfo fileInfo = null; Guid systemBackupGuid = Guid.Empty; //Required to assign current FileName and FileNamePacked after restore, else name will be the TempName ex acegvpls.soj & n2sjiamk.32o sys_systembackup systemBackup = null; string currentFileName = string.Empty, currentFileNamePacked = string.Empty, currentFilePath = string.Empty, currentFileHash = string.Empty; sys_userdetail currentUserDetail = null; switch (pRestoreFrom) { case DataBaseRestoreFrom.SystemBackup: fileInfo = GetSelectRecordFileName(pSourceWindow); //Equal to Filename not FileNamePacked fileNamePacked = fileInfo.FileNamePacked; if (_debug) { _log.Debug(string.Format("RestoreBackup: FileNamePacked:[{0}], FileHashDB:[{1}], FileHashFile:[{2}] FileHashValid:[{3}]", fileInfo.FileNamePacked, fileInfo.FileHashDB, fileInfo.FileHashFile, fileInfo.FileHashValid)); } if (fileInfo.Response != ResponseType.Cancel && !fileInfo.FileHashValid) { //#EQUAL#1 string message = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_database_restore_error_invalid_backup_file"), fileNamePacked); Utils.ShowMessageTouch(pSourceWindow, DialogFlags.Modal, new Size(600, 300), MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), message); return(false); } break; case DataBaseRestoreFrom.ChooseFromFilePickerDialog: FileFilter fileFilterBackups = Utils.GetFileFilterBackups(); PosFilePickerDialog dialog = new PosFilePickerDialog(pSourceWindow, DialogFlags.DestroyWithParent, fileFilterBackups, FileChooserAction.Open); ResponseType response = (ResponseType)dialog.Run(); if (response == ResponseType.Ok) { fileNamePacked = dialog.FilePicker.Filename; //Override Default pathBackups pathBackups = string.Format("{0}/", Path.GetDirectoryName(fileNamePacked)); dialog.Destroy(); } else { /* IN009164 */ dialog.Destroy(); return(false); } break; default: break; } if (GlobalFramework.DatabaseType != DatabaseType.MSSqlServer) { fileName = Path.ChangeExtension(fileNamePacked, _fileExtension); } else { //Require to assign filename and packed filename from fileInfo fileName = fileInfo.FileName; fileNamePacked = fileInfo.FileName; } if (fileName != string.Empty) { if (_debug) { _log.Debug(string.Format("Restore Filename:[{0}] to pathBackups[{1}]", fileNamePacked, pathBackups)); } if (GlobalFramework.DatabaseType != DatabaseType.MSSqlServer) { // Old Method before PluginSoftwareVendor Implementation //restoreResult = Utils.ZipUnPack(fileNamePacked, pathBackups, true); restoreResult = GlobalFramework.PluginSoftwareVendor.RestoreBackup(SettingsApp.SecretKey, fileNamePacked, pathBackups, true); if (_debug) { _log.Debug(string.Format("RestoreBackup: unpackResult:[{0}]", restoreResult)); } } if (restoreResult || GlobalFramework.DatabaseType == DatabaseType.MSSqlServer) { //Get properties from SystemBackup Object before Restore, to Assign Properties after Restore (FilePath,FileHash,User,Terminal) sql = string.Format("SELECT Oid FROM sys_systembackup WHERE fileNamePacked = '{0}';", Path.GetFileName(fileNamePacked)); systemBackupGuid = FrameworkUtils.GetGuidFromQuery(sql); if (systemBackupGuid != Guid.Empty) { systemBackup = (sys_systembackup)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(sys_systembackup), systemBackupGuid); currentFileName = systemBackup.FileName; currentFileNamePacked = systemBackup.FileNamePacked; currentFilePath = systemBackup.FilePath; currentFileHash = systemBackup.FileHash; currentUserDetail = systemBackup.User; } //Send fileNamePacked only to show its name in success dialog if (Restore(pSourceWindow, fileName, fileNamePacked, systemBackup)) { //Audit DATABASE_RESTORE FrameworkUtils.Audit("DATABASE_RESTORE", string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "audit_message_database_restore"), fileNamePacked)); //Required to DropIdentity before get currentDocumentFinanceYear Object, else it exists in old non restored Session GlobalFramework.SessionXpo.DropIdentityMap(); //Get Current Active FinanceYear fin_documentfinanceyears currentDocumentFinanceYear = ProcessFinanceDocumentSeries.GetCurrentDocumentFinanceYear(); //Disable all Active FinanceYear Series and SeriesTerminal if Exists if (currentDocumentFinanceYear != null) { ProcessFinanceDocumentSeries.DisableActiveYearSeriesAndTerminalSeries(currentDocumentFinanceYear); } //Restore SystemBackup properties else it keeps temp names after Restore acegvpls.soj & n2sjiamk.32o, empty hash etc if (systemBackupGuid != Guid.Empty) { //ReFresh UserDetail from Repository currentUserDetail = (currentUserDetail != null) ? (sys_userdetail)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(sys_userdetail), currentUserDetail.Oid) : null; //Get Current Restored systemBackup Object systemBackup = (sys_systembackup)FrameworkUtils.GetXPGuidObject(GlobalFramework.SessionXpo, typeof(sys_systembackup), systemBackupGuid); systemBackup.FileName = currentFileName; systemBackup.FileNamePacked = currentFileNamePacked; systemBackup.FilePath = currentFilePath; systemBackup.FileHash = currentFileHash; systemBackup.User = currentUserDetail; systemBackup.Save(); } //If Cant get Record, because works on ChooseFromFilePickerDialog, we must recreate Record from file, only in the case of record with miss fileNamePacked else { sql = "DELETE FROM sys_systembackup WHERE FilePath IS NULL AND FileHash IS NULL AND User IS NULL;"; GlobalFramework.SessionXpo.ExecuteNonQuery(sql); } //Audit FrameworkUtils.Audit("APP_CLOSE"); //Call QuitWithoutConfirmation without Audit LogicPos.QuitWithoutConfirmation(false); return(true); } else { return(false); } } else { //#EQUAL#1 string message = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "dialog_message_database_restore_error_invalid_backup_file"), fileNamePacked); Utils.ShowMessageTouch(pSourceWindow, DialogFlags.Modal, new Size(600, 300), MessageType.Error, ButtonsType.Ok, resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_error"), message); return(false); } } else { return(false); } } catch (Exception ex) { _log.Error(ex.Message, ex); return(false); } finally { //FrameworkUtils.HideWaitingCursor(); } }