private void TreeViewConfigurationPreferenceParameter_RecordAfterUpdate(object sender, EventArgs e) { // Get ConfigurationPreferenceParameter Reference cfg_configurationpreferenceparameter configurationPreferenceParameter = (_dataSourceRow as cfg_configurationpreferenceparameter); try { // We Must Modify GlobalFramework.PreferenceParameters after user Change Value, if Value is Changed, this will Update in Memory GlobalFramework.PreferenceParameters Dictionary if (GlobalFramework.PreferenceParameters[configurationPreferenceParameter.Token] == null || !GlobalFramework.PreferenceParameters[configurationPreferenceParameter.Token].Equals(configurationPreferenceParameter.Value) ) { if (_debug) { _log.Debug($"TreeViewConfigurationPreferenceParameter: Previous Value: [{GlobalFramework.PreferenceParameters[configurationPreferenceParameter.Token]}]"); } GlobalFramework.PreferenceParameters[configurationPreferenceParameter.Token] = configurationPreferenceParameter.Value; if (_debug) { _log.Debug($"TreeViewConfigurationPreferenceParameter: Current Value: [{GlobalFramework.PreferenceParameters[configurationPreferenceParameter.Token]}]"); } } } catch (Exception ex) { _log.Error(ex.Message, ex); } }
public DialogConfigurationPreferenceParameter(Window pSourceWindow, GenericTreeViewXPO pTreeView, DialogFlags pFlags, DialogMode pDialogMode, XPGuidObject pXPGuidObject) : base(pSourceWindow, pTreeView, pFlags, pDialogMode, pXPGuidObject) { this.Title = Utils.GetWindowTitle(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "window_title_edit_configurationpreferenceparameter")); cfg_configurationpreferenceparameter dataSourceRow = (cfg_configurationpreferenceparameter)_dataSourceRow; // Default windowHeight, InputTypes can Override this in Switch _windowHeight = _windowHeightForTextComponent; InitUI(); SetSizeRequest(_windowWidth, _windowHeight); InitNotes(); ShowAll(); }
//XpoMode public TreeViewConfigurationPreferenceParameter(Window pSourceWindow, XPGuidObject pDefaultValue, CriteriaOperator pXpoCriteria, Type pDialogType, GenericTreeViewMode pGenericTreeViewMode = GenericTreeViewMode.Default, GenericTreeViewNavigatorMode pGenericTreeViewNavigatorMode = GenericTreeViewNavigatorMode.Default) { //Init Vars Type xpoGuidObjectType = typeof(cfg_configurationpreferenceparameter); //Override Default Value with Parameter Default Value, this way we can have diferent Default Values for GenericTreeView cfg_configurationpreferenceparameter defaultValue = (pDefaultValue != null) ? pDefaultValue as cfg_configurationpreferenceparameter : null; //Override Default DialogType with Parameter Dialog Type, this way we can have diferent DialogTypes for GenericTreeView Type typeDialogClass = (pDialogType != null) ? pDialogType : typeof(DialogConfigurationPreferenceParameter); //Configure columnProperties List <GenericTreeViewColumnProperty> columnProperties = new List <GenericTreeViewColumnProperty>(); columnProperties.Add(new GenericTreeViewColumnProperty("ResourceString") { Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_designation"), Expand = true, ResourceString = true }); columnProperties.Add(new GenericTreeViewColumnProperty("Value") { Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_value"), Expand = true }); columnProperties.Add(new GenericTreeViewColumnProperty("UpdatedAt") { Title = resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_date_updated"), MinWidth = 150, MaxWidth = 150 }); //Configure Criteria/XPCollection/Model : pXpoCriteria Parameter sent by BO CriteriaOperator criteria = pXpoCriteria; XPCollection xpoCollection = new XPCollection(GlobalFramework.SessionXpo, xpoGuidObjectType, criteria); this.RecordAfterUpdate += TreeViewConfigurationPreferenceParameter_RecordAfterUpdate; //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 ); }
private void InitUI() { BOWidgetBox boxValue = null; BOWidgetBox ComboboxValue = null; try { cfg_configurationpreferenceparameter dataSourceRow = (cfg_configurationpreferenceparameter)_dataSourceRow; //Define Label for Value string valueLabel = (resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], dataSourceRow.ResourceString) != null) ? resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], dataSourceRow.ResourceString) : "LABEL NOT DEFINED IN Field [ResourceString]"; //Define RegEx for Value string valueRegEx = "REGULAR EXPRESSION NOT DEFINED IN Field [RegEx]"; if (dataSourceRow.RegEx != null) { //Try to get Value object objectValueRegEx = FrameworkUtils.GetFieldValueFromType(typeof(SettingsApp), dataSourceRow.RegEx); if (objectValueRegEx != null) { valueRegEx = objectValueRegEx.ToString(); } } //Define Label for Value bool valueRequired = (dataSourceRow.Required) ? dataSourceRow.Required : false; //Override Db Regex with ConfigurationSystemCountry RegExZipCode and RegExFiscalNumber if (dataSourceRow.Token == "COMPANY_POSTALCODE") { valueRegEx = SettingsApp.ConfigurationSystemCountry.RegExZipCode; } if (dataSourceRow.Token == "COMPANY_FISCALNUMBER") { valueRegEx = SettingsApp.ConfigurationSystemCountry.RegExFiscalNumber; } //Tab1 VBox vboxTab1 = new VBox(false, _boxSpacing) { BorderWidth = (uint)_boxSpacing }; //Ord Entry entryOrd = new Entry(); BOWidgetBox boxLabel = new BOWidgetBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_order"), entryOrd); vboxTab1.PackStart(boxLabel, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxLabel, _dataSourceRow, "Ord", SettingsApp.RegexIntegerGreaterThanZero, true)); //Code Entry entryCode = new Entry(); BOWidgetBox boxCode = new BOWidgetBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_code"), entryCode); vboxTab1.PackStart(boxCode, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxCode, _dataSourceRow, "Code", SettingsApp.RegexIntegerGreaterThanZero, true)); //Token Entry entryToken = new Entry(); BOWidgetBox boxToken = new BOWidgetBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_token"), entryToken); vboxTab1.PackStart(boxToken, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxToken, _dataSourceRow, "Token", SettingsApp.RegexAlfaNumericExtended, true)); //Get InputType PreferenceParameterInputType inputType = (PreferenceParameterInputType)Enum.Parse(typeof(PreferenceParameterInputType), dataSourceRow.InputType.ToString(), true); Entry entryValue = new Entry(); switch (inputType) { case PreferenceParameterInputType.Text: case PreferenceParameterInputType.TextPassword: boxValue = new BOWidgetBox(valueLabel, entryValue); vboxTab1.PackStart(boxValue, false, false, 0); // Turn entry into a TextPassword, curently we not use it, until we can turn Visibility = false into TreeView Cell if (inputType.Equals(PreferenceParameterInputType.TextPassword)) { entryValue.Visibility = false; } _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxValue, _dataSourceRow, "Value", valueRegEx, valueRequired)); // ValueTip if (!string.IsNullOrEmpty(dataSourceRow.ValueTip)) { entryValue.TooltipText = string.Format(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_prefparam_value_tip_format"), dataSourceRow.ValueTip); } break; case PreferenceParameterInputType.Multiline: EntryMultiline entryMultiline = new EntryMultiline(); entryMultiline.Value.Text = dataSourceRow.Value; entryMultiline.ScrolledWindow.BorderWidth = 1; entryMultiline.HeightRequest = 122; Label labelMultiline = new Label(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_notes")); boxValue = new BOWidgetBox(valueLabel, entryMultiline); vboxTab1.PackStart(boxValue, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxValue, _dataSourceRow, "Value", valueRegEx, valueRequired)); // Override Default Window Height _windowHeight = _windowHeightForTextComponent + 100; break; case PreferenceParameterInputType.CheckButton: CheckButton checkButtonValue = new CheckButton(valueLabel); vboxTab1.PackStart(checkButtonValue, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(checkButtonValue, _dataSourceRow, "Value")); // Override Default Window Height _windowHeight = _windowHeightForTextComponent - 20; break; //Mudar a lingua da Aplicação - Não é genérico //IN009296 BackOffice - Mudar a língua da aplicação case PreferenceParameterInputType.ComboBox: string getCultureFromDB; try { string sql = "SELECT value FROM cfg_configurationpreferenceparameter where token = 'CULTURE';"; getCultureFromDB = GlobalFramework.SessionXpo.ExecuteScalar(sql).ToString(); } catch { getCultureFromDB = GlobalFramework.Settings["customCultureResourceDefinition"]; } string[] getCulturesValues = new string[8]; getCulturesValues[0] = "pt-PT"; getCulturesValues[1] = "pt-AO"; getCulturesValues[2] = "pt-BR"; getCulturesValues[3] = "pt-MZ"; getCulturesValues[4] = "en-GB"; getCulturesValues[5] = "en-US"; getCulturesValues[6] = "fr-FR"; getCulturesValues[7] = "es-ES"; string[] getCulturesLabels = new string[8]; getCulturesLabels[0] = "Português(Portugal)"; getCulturesLabels[1] = "Português(Angola)"; getCulturesLabels[2] = "Português(Brasil)"; getCulturesLabels[3] = "Português(Moçambique)"; getCulturesLabels[4] = "English(GB)"; getCulturesLabels[5] = "English(USA)"; getCulturesLabels[6] = "Françes"; getCulturesLabels[7] = "Espanol"; TreeIter iter; TreeStore store = new TreeStore(typeof(string), typeof(string)); for (int i = 0; i < getCulturesLabels.Length; i++) { iter = store.AppendValues(getCulturesValues.GetValue(i), getCulturesLabels.GetValue(i)); } ComboBox xpoComboBoxInputType = new ComboBox(getCulturesLabels); xpoComboBoxInputType.Model.GetIterFirst(out iter); int cbox = 0; do { GLib.Value thisRow = new GLib.Value(); xpoComboBoxInputType.Model.GetValue(iter, 0, ref thisRow); //if ((thisRow.Val as string).Equals(getCultureFromDB)) if (getCulturesValues[cbox] == getCultureFromDB) { xpoComboBoxInputType.SetActiveIter(iter); break; } cbox++; } while (xpoComboBoxInputType.Model.IterNext(ref iter)); ComboboxValue = new BOWidgetBox(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_language"), xpoComboBoxInputType); vboxTab1.PackStart(ComboboxValue, false, false, 0); entryValue.Text = getCulturesValues[xpoComboBoxInputType.Active]; entryValue.Visibility = false; xpoComboBoxInputType.Changed += delegate { entryValue.Text = getCulturesValues[xpoComboBoxInputType.Active]; //GlobalFramework.CurrentCulture = new System.Globalization.CultureInfo(getCulturesValues[xpoComboBoxInputType.Active]); //GlobalFramework.Settings["customCultureResourceDefinition"] = getCulturesValues[xpoComboBoxInputType.Active]; //CustomResources.UpdateLanguage(getCulturesValues[xpoComboBoxInputType.Active]); //_crudWidgetList.Add(new GenericCRUDWidgetXPO(boxValue, _dataSourceRow, "Value", string.Empty, false)); }; boxValue = new BOWidgetBox(valueLabel, entryValue); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxValue, _dataSourceRow, "Value", string.Empty, false)); break; case PreferenceParameterInputType.FilePicker: case PreferenceParameterInputType.DirPicker: //FilePicker FileChooserAction fileChooserAction = (inputType.Equals(PreferenceParameterInputType.FilePicker)) ? FileChooserAction.Open : FileChooserAction.SelectFolder; FileChooserButton fileChooser = new FileChooserButton(string.Empty, fileChooserAction) { HeightRequest = 23 }; if (inputType.Equals(PreferenceParameterInputType.FilePicker)) { fileChooser.SetFilename(dataSourceRow.Value); fileChooser.Filter = Utils.GetFileFilterImages(); } else { fileChooser.SetCurrentFolder(dataSourceRow.Value); } boxValue = new BOWidgetBox(valueLabel, fileChooser); vboxTab1.PackStart(boxValue, false, false, 0); _crudWidgetList.Add(new GenericCRUDWidgetXPO(boxValue, _dataSourceRow, "Value", string.Empty, false)); break; default: break; } //Append Tab _notebook.AppendPage(vboxTab1, new Label(resources.CustomResources.GetCustomResources(GlobalFramework.Settings["customCultureResourceDefinition"], "global_record_main_detail"))); //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: //Disable Components entryToken.Sensitive = false; //Protect PreferenceParameterInputType : Disable if is COMPANY_FISCALNUMBER or Other Sensitive Data cfg_configurationpreferenceparameter parameter = (_dataSourceRow as cfg_configurationpreferenceparameter); if (entryValue != null) { entryValue.Sensitive = ( parameter.Token != "COMPANY_NAME" && parameter.Token != "COMPANY_BUSINESS_NAME" && parameter.Token != "COMPANY_COUNTRY" && parameter.Token != "COMPANY_COUNTRY" && parameter.Token != "COMPANY_COUNTRY_CODE2" && parameter.Token != "COMPANY_FISCALNUMBER" && parameter.Token != "SYSTEM_CURRENCY" //&& parameter.Token != "COMPANY_CIVIL_REGISTRATION" //&& parameter.Token != "COMPANY_CIVIL_REGISTRATION_ID" ); } } catch (System.Exception ex) { _log.Error(ex.Message, ex); } }
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); } }