Exemplo n.º 1
0
        protected override void OnResponse(ResponseType pResponse)
        {
            try
            {
                if (pResponse == ResponseType.Ok)
                {
                    bool changed = false;

                    foreach (var item in _dictionaryObjectBag)
                    {
                        changed = Utils.CheckIfFieldChanged(item.Key.Value, item.Value.EntryValidation.Text);
                        //_log.Debug(string.Format("FieldDb:[{0}], FieldInput:[{1}], changed: [{2}]", item.Key.Value, item.Value.EntryValidation.Text, changed));
                        if (changed)
                        {
                            item.Key.Value = item.Value.EntryValidation.Text;
                            item.Key.Save();
                        }
                    }

                    //entryBoxSelect: COMPANY_COUNTRY
                    //Assign and Save Country and Country Code 2 From entryBoxSelectCustomerCountry
                    cfg_configurationpreferenceparameter configurationPreferenceParameterCompanyCountry = (FrameworkUtils.GetXPGuidObjectFromCriteria(typeof(cfg_configurationpreferenceparameter), string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (Token = '{0}')", "COMPANY_COUNTRY")) as cfg_configurationpreferenceparameter);
                    configurationPreferenceParameterCompanyCountry.Value = _entryBoxSelectSystemCountry.Value.Designation;
                    configurationPreferenceParameterCompanyCountry.Save();
                    //entryBoxSelect: COMPANY_COUNTRY_CODE2
                    cfg_configurationpreferenceparameter configurationPreferenceParameterCompanyCountryCode2 = (FrameworkUtils.GetXPGuidObjectFromCriteria(typeof(cfg_configurationpreferenceparameter), string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (Token = '{0}')", "COMPANY_COUNTRY_CODE2")) as cfg_configurationpreferenceparameter);
                    configurationPreferenceParameterCompanyCountryCode2.Value = _entryBoxSelectSystemCountry.Value.Code2;
                    configurationPreferenceParameterCompanyCountryCode2.Save();
                    //entryBoxSelect: SYSTEM_CURRENCY
                    cfg_configurationpreferenceparameter configurationPreferenceParameterSystemCurrency = (FrameworkUtils.GetXPGuidObjectFromCriteria(typeof(cfg_configurationpreferenceparameter), string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (Token = '{0}')", "SYSTEM_CURRENCY")) as cfg_configurationpreferenceparameter);
                    configurationPreferenceParameterSystemCurrency.Value = _entryBoxSelectSystemCurrency.Value.Acronym;
                    configurationPreferenceParameterSystemCurrency.Save();
                    //entryBoxSelect: COMPANY_COUNTRY_OID
                    cfg_configurationpreferenceparameter configurationPreferenceParameterCompanyCountryOid = (FrameworkUtils.GetXPGuidObjectFromCriteria(typeof(cfg_configurationpreferenceparameter), string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (Token = '{0}')", "COMPANY_COUNTRY_OID")) as cfg_configurationpreferenceparameter);
                    configurationPreferenceParameterCompanyCountryOid.Value = _entryBoxSelectSystemCountry.Value.Oid.ToString();
                    configurationPreferenceParameterCompanyCountryOid.Save();
                    //entryBoxSelect: SYSTEM_CURRENCY_OID
                    cfg_configurationpreferenceparameter configurationPreferenceParameterSystemCurrencyOid = (FrameworkUtils.GetXPGuidObjectFromCriteria(typeof(cfg_configurationpreferenceparameter), string.Format("(Disabled IS NULL OR Disabled  <> 1) AND (Token = '{0}')", "SYSTEM_CURRENCY_OID")) as cfg_configurationpreferenceparameter);
                    configurationPreferenceParameterSystemCurrencyOid.Value = _entryBoxSelectSystemCurrency.Value.Oid.ToString();
                    configurationPreferenceParameterSystemCurrencyOid.Save();

                    //Proccess Country Scripts
                    string commandSeparator = ";";
                    Dictionary <string, string> replaceables = logicpos.DataLayer.GetReplaceables(GlobalFramework.DatabaseType);
                    string directoryCountry = FrameworkUtils.OSSlash(string.Format(@"{0}/{1}", SettingsApp.FileDatabaseOtherCommonCountry, _entryBoxSelectSystemCountry.Value.Code2));
                    logicpos.DataLayer.ProcessDumpDirectory(GlobalFramework.SessionXpo, directoryCountry, commandSeparator, replaceables);
                    //Proccess Country Plugin Scripts
                    directoryCountry = FrameworkUtils.OSSlash(string.Format(@"{0}/{1}", SettingsApp.FileDatabaseOtherCommonPluginsSoftwareVendorOtherCommonCountry, _entryBoxSelectSystemCountry.Value.Code2));
                    logicpos.DataLayer.ProcessDumpDirectory(GlobalFramework.SessionXpo, directoryCountry, commandSeparator, replaceables);

                    //Change Configuration : Currently only working outside Debugger, to prevent errors changing config with VS using app.config
                    //System.ArgumentException: O nome de ficheiro 'c:\svn\logicpos\trunk\src\logicpos\bin\debug\logicpos.exe.config' é inválido porque o mesmo nome de ficheiro já é referido pela hierarquia de configuração aberta
                    Dictionary <string, string> configurationValues = new Dictionary <string, string>();
                    configurationValues.Add("xpoOidConfigurationCountrySystemCountry", _entryBoxSelectSystemCountry.Value.Oid.ToString());
                    configurationValues.Add("xpoOidConfigurationCountrySystemCountryCountryCode2", _entryBoxSelectSystemCountry.Value.Code2);
                    configurationValues.Add("xpoOidConfigurationCurrencySystemCurrency", _entryBoxSelectSystemCurrency.Value.Oid.ToString());
                    Utils.AddUpdateSettings(configurationValues);

                    //Require to assign to SettingsApp Singleton : Now Working in InitPlataformParameters() to prevent save to config catch and this code is never be executed
                    //SettingsApp.ConfigurationSystemCountry = _entryBoxSelectSystemCountry.Value;
                    //SettingsApp.ConfigurationSystemCurrency = _entryBoxSelectSystemCurrency.Value;

                    //UNDER CONSTRUCTION
                    //Call SaveSystemProtection() Here
                    //Utils.SaveSystemProtection();
                }
                else if (pResponse == ResponseType.Apply)
                {
                    this.Destroy();
                    PosEditCompanyDetails dialog   = new PosEditCompanyDetails(this, DialogFlags.DestroyWithParent | DialogFlags.Modal, true);
                    ResponseType          response = (ResponseType)dialog.Run();
                    dialog.Destroy();
                }
                else
                {
                    //Prevent ESC
                    this.Run();
                }
            }
            catch (Exception ex)
            {
                // This Error Occurs only id Debugger is Attached
                _log.Error(ex.Message, ex);
            }
        }