Example #1
0
        public CallContext ProfileSettingSave(ProfileSetting entity, CallContext resultContext)
        {
            resultContext.securitySettings = ETEMEnums.SecuritySettings.ProfilesSave;
            CallContext resContext = new ProfileSettingBL().EntitySave <ProfileSetting>(entity, resultContext);

            return(resContext);
        }
Example #2
0
        private void LoadSettings(List <ProfileSetting> settings)
        {
            foreach (EngineSetting engineSetting in ActiveEngine.Settings)
            {
                // Get user value and update engine
                ProfileSetting setting = settings.FirstOrDefault(s => s.Name == engineSetting.Name);
                if (setting != null)
                {
                    if (engineSetting is EngineSettingCombobox engineSettingCombobox &&
                        setting is ProfileSettingInteger profileSettingInteger)
                    {
                        engineSettingCombobox.Value = profileSettingInteger.Value;
                    }

                    if (engineSetting is EngineSettingFolderBrowser engineSettingFolder &&
                        setting is ProfileSettingString profileSettingString)
                    {
                        engineSettingFolder.Value = profileSettingString.Value;
                    }

                    if (engineSetting is EngineSettingCheckbox engineSettingCheckbox &&
                        setting is ProfileSettingBoolean profileSettingBoolean)
                    {
                        engineSettingCheckbox.Value = profileSettingBoolean.Value;
                    }

                    if (engineSetting is EngineSettingTextbox engineSettingTextbox &&
                        setting is ProfileSettingString profileSettingString2)
                    {
                        engineSettingTextbox.Value = profileSettingString2.Value;
                    }
                }
            }
        }
        public AddProfile(IEnumerable <DeviceFullInfo> playbacks, IEnumerable <DeviceFullInfo> recordings, SettingsForm settingsForm)
        {
            InitializeComponent();
            _settingsForm = settingsForm;
            Icon          = Resources.profile;

            _profile = new ProfileSetting();

            LocalizeForm();
            InitRecordingPlaybackComboBoxes(playbacks, recordings);
            InitBindings();

            try
            {
                //Only let user on Windows 10 change the switch also default device
                //Since the feature isn't available on Windows 7
                if (Environment.OSVersion.Version.Major >= 10)
                {
                    programTextBox.TextChanged += programTextBox_TextChanged;
                }
            }
            catch (Exception)
            {
                programTextBox.TextChanged += programTextBox_TextChanged;
            }
        }
Example #4
0
        public bool Verify(out string message)
        {
            message = null;
            if (Option == null)
            {
                return(true);                //setting no longer exists, constraints are irrelevant?
            }
            var pItem   = Sys.ActiveProfile.ActiveItems.Find(pi => pi.ModID.Equals(ModID));
            var inst    = Sys.Library.GetItem(pItem.ModID);
            var setting = pItem.Settings.Find(s => s.ID.Equals(Setting, StringComparison.InvariantCultureIgnoreCase));

            if (setting == null)
            {
                setting = new ProfileSetting()
                {
                    ID = Setting, Value = Option.Default
                };
                pItem.Settings.Add(setting);
            }

            string modsList = String.Join("\n", ParticipatingMods.Select(p => $"{p.Value} | ({p.Key})")); // list of mods participating in constraint

            if (Require.Any() && (Require.Min() != Require.Max()))
            {
                message = String.Format("Mod {0}, setting {1} - no compatible option can be found. The following mods all restrict how it can be configured:\n\n{2}", inst.CachedDetails.Name, Option.Name, modsList);
                return(false);
            }

            if (Require.Any() && Forbid.Contains(Require[0]))
            {
                message = String.Format("Mod {0}, setting {1} - no compatible option can be found. The following mods all restrict how it can be configured:\n\n{2}", inst.CachedDetails.Name, Option.Name, modsList);
                return(false);
            }
            if (Option.Values.All(o => Forbid.Contains(o.Value)))
            {
                message = String.Format("Mod {0}, setting {1} - no compatible option can be found. The following mods all restrict how it can be configured:\n\n{2}", inst.CachedDetails.Name, Option.Name, modsList);
                return(false);
            }
            if (Require.Any() && (setting.Value != Require[0]))
            {
                var opt = Option.Values.Find(v => v.Value == Require[0]);
                if (opt == null)
                {
                    message = String.Format("Mod {0}, setting {1} - no compatible option can be found. The following mods all restrict how it can be configured:\n\n{2}", inst.CachedDetails.Name, Option.Name, modsList);
                    return(false);
                }
                setting.Value = Require[0];
                message       = String.Format("Mod {0} - changed setting {1} to {2}", inst.CachedDetails.Name, Option.Name, opt.Name);
            }
            else if (Forbid.Contains(setting.Value))
            {
                setting.Value = Option.Values.First(v => !Forbid.Contains(v.Value)).Value;
                var opt = Option.Values.Find(v => v.Value == setting.Value);
                message = String.Format("Mod {0} - changed setting {1} to {2}", inst.CachedDetails.Name, Option.Name, opt.Name);
            }
            return(true);
        }
Example #5
0
        public async Task <IActionResult> SaveProfileSettings([FromForm] ProfileSetting profileSetting)
        {
            var result = await _settingsRepository.SaveProfileSettings(profileSetting);

            if (result)
            {
                return(Ok(result));
            }
            return(BadRequest());
        }
 public void AcceptProfileSetting(ProfileSetting target)
 {
     selectionProfile = ProfileSettings.IndexOf(target);
     MessageBox.Show(
         "変更は、アプリケーションを再起動するまで適用されません。",
         "情報",
         MessageBoxButton.OK,
         MessageBoxImage.Information
         );
 }
Example #7
0
        public AddProfile(IEnumerable <DeviceFullInfo> playbacks, IEnumerable <DeviceFullInfo> recordings, SettingsForm settingsForm)
        {
            InitializeComponent();
            _settingsForm = settingsForm;
            Icon          = Resources.profile;

            _profile = new ProfileSetting();

            LocalizeForm();
            InitRecordingPlaybackComboBoxes(playbacks, recordings);
            InitBindings();
        }
        public async Task <bool> SaveProfileSettings(ProfileSetting setting)
        {
            var existingProfileSetting = await FindProfileSetting();

            if (existingProfileSetting == null)
            {
                using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    try
                    {
                        var profileSetting = await ProcessProfileSettingsModel(setting);

                        var data = new Settings
                        {
                            SettingKey = SettingKey.Profile,
                            Value      = JsonConvert.SerializeObject(profileSetting)
                        };

                        await _unitOfWork.Repository <Settings>().AddAsync(data);

                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        _unitOfWork.Rollback();
                        throw ex;
                    }
                }
            }
            else
            {
                using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
                {
                    try
                    {
                        var profileSetting = await ProcessProfileSettingsModel(setting);

                        existingProfileSetting.Value = JsonConvert.SerializeObject(profileSetting);

                        await _unitOfWork.Repository <Settings>().UpdateAsync(existingProfileSetting);

                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        _unitOfWork.Rollback();
                        throw ex;
                    }
                }
            }

            return(true);
        }
Example #9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!__bPropertyCompleted)
            {
                MessageBox.Show(__sMessageContent_001, __sMessageHeader_001, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (__cProfile == null)
            {
                __cProfile = new ProfileSetting();
                __cProfile.ChartProperty = __cChartProperty;
                __cProfile.ProfileId     = Guid.NewGuid().ToString();
                __cProfile.Script        = __cScriptSetting;
                __cProfile.ScriptName    = __sScriptName;
                __cProfile.ScriptType    = __cScriptType;
                __cProfile.Window        = new WindowStatus()
                {
                    IsDock = true
                };

                ProfileManager.Manager.AddProfile(__cProfile);
            }
            else
            {
                int iCount = __cScriptSetting.DataRequests.Count;
                __bModifyDataRequest = iCount > __iPrevDataRequestCount || __cModifyRemoveItems.Count > 0;

                if (__bModifyDataRequest)
                {
                    if (__cBeforeCompletedCallback != null)
                    {
                        __cBeforeCompletedCallback();
                    }

                    __cModifyRemoveItems.Sort();

                    iCount = __cModifyRemoveItems.Count;
                    if (iCount > 0)
                    {
                        List <RequestSetting> cDataRequests = __cScriptSetting.DataRequests;
                        for (int i = iCount - 1; i >= 0; i--)
                        {
                            int iIndex = __cModifyRemoveItems[i];
                            __cCharts.RemoveAt(iIndex);
                            cDataRequests.RemoveAt(iIndex);
                        }
                    }
                }
            }
            this.DialogResult = DialogResult.OK;
        }
        private Profile CreateProfileForExport(IntPtr hSession, string profileName, bool includePredefined)
        {
            var result = new Profile();

            var hProfile = GetProfileHandle(hSession, profileName);

            if (hProfile != IntPtr.Zero)
            {
                var settings = GetProfileSettings(hSession, hProfile);
                if (settings.Count > 0)
                {
                    result.ProfileName = profileName;

                    var apps = GetProfileApplications(hSession, hProfile);
                    foreach (var app in apps)
                    {
                        result.Executeables.Add(app.appName);
                    }

                    foreach (var setting in settings)
                    {
                        var isPredefined     = setting.isCurrentPredefined == 1;
                        var isDwordSetting   = setting.settingType == NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE;
                        var isCurrentProfile = setting.settingLocation ==
                                               NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION;

                        if (isDwordSetting && isCurrentProfile)
                        {
                            if (!isPredefined || includePredefined)
                            {
                                var profileSetting = new ProfileSetting()
                                {
                                    SettingNameInfo = setting.settingName,
                                    SettingId       = setting.settingId,
                                    SettingValue    = setting.currentValue.dwordValue,
                                };
                                result.Settings.Add(profileSetting);
                            }
                        }
                    }
                }
            }

            return(result);
        }
Example #11
0
        internal frmFormatObject(ProfileSetting profile = null, Action beforeCompletedCallback = null)
        {
            __cModifyRemoveItems       = new List <int>(16);
            __cBeforeCompletedCallback = beforeCompletedCallback;

            if (profile == null)
            {
                __cCharts = new List <ChartSetting>(4);

                ChartProperty cDefaultProperty = GlobalSettings.ChartProfile.DefaultProperty;
                __cChartProperty                   = new ChartProperty();
                __cChartProperty.AxisFont          = cDefaultProperty.AxisFont;
                __cChartProperty.LegendFont        = cDefaultProperty.LegendFont;
                __cChartProperty.TextFont          = cDefaultProperty.TextFont;
                __cChartProperty.TitleFont         = cDefaultProperty.TitleFont;
                __cChartProperty.TitleFont         = cDefaultProperty.TitleFont;
                __cChartProperty.AxisColor         = cDefaultProperty.AxisColor;
                __cChartProperty.BackgroundColor   = cDefaultProperty.BackgroundColor;
                __cChartProperty.DrawAideLineColor = cDefaultProperty.DrawAideLineColor;
                __cChartProperty.ForeColor         = cDefaultProperty.ForeColor;
                __cChartProperty.GridColor         = cDefaultProperty.GridColor;
                __cChartProperty.TradeLineColor    = cDefaultProperty.TradeLineColor;
                __cChartProperty.TradeSymbolColor  = cDefaultProperty.TradeSymbolColor;
                __cChartProperty.DrawingSource     = cDefaultProperty.DrawingSource;
                __cChartProperty.IsShowGrid        = true;
                __cChartProperty.ChartSettings     = __cCharts;
            }
            else
            {
                __cProfile       = profile;
                __cChartProperty = profile.ChartProperty;
                __cCharts        = __cChartProperty.ChartSettings;
                __cScriptSetting = profile.Script;

                __iPrevDataRequestCount = __cScriptSetting.DataRequests.Count;
                __bPropertyCompleted    = true;
                __bFormatObjectModify   = true;
            }

            InitializeComponent();
            InitializeSourceGrid();
        }
Example #12
0
        public async Task <ResultBase> profile_setting(ProfileSetting profileSetting)
        {
            if (profileSetting == null)
            {
                throw new ArgumentNullException(nameof(profileSetting));
            }

            var form        = JsonConvert.DeserializeObject <Dictionary <string, string> >(JsonConvert.SerializeObject(profileSetting));
            var postContent = new FormUrlEncodedContent(form);

            using (var client = CreateHttpClient())
            {
                var url      = GetUrl("profile_setting");
                var response = await client.PostAsync(url, postContent);

                var json = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <ResultBase>(json));
            }
        }
        public void RemoveProfileSetting(ProfileSetting target)
        {
            var index = ProfileSettings.IndexOf(target);

            if (selectionProfile == index)
            {
                MessageBox.Show(
                    "選択中のプロファイルを削除することはできません。",
                    "エラー",
                    MessageBoxButton.OK,
                    MessageBoxImage.Error
                    );
                return;
            }

            if (selectionProfile > index)
            {
                selectionProfile--;
            }

            ProfileSettings.RemoveAt(index);
        }
Example #14
0
        internal static void Create(DockPanel dockPanel, ProfileSetting profile)
        {
            frmSignalViewer frmSignalViewer = new frmSignalViewer();

            frmSignalViewer.SetProfileSetting(profile);

            WindowStatus cWindow = profile.Window;

            if (cWindow.IsDock)
            {
                frmSignalViewer.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document);
            }
            else
            {
                frmSignalViewer.Show(dockPanel, new System.Drawing.Rectangle(cWindow.Left, cWindow.Top, cWindow.Width, cWindow.Height));
            }

            if (!__bCustomsLoaded)                //自訂繪圖工具是否已經載入
            {
                __bCustomsLoaded = true;
                frmMain frmMain = dockPanel.Parent as frmMain;
                frmMain.SetCustomDrawTools(frmSignalViewer.Chart.CustomDrawTools);
            }
        }
Example #15
0
        internal static void Create(WeifenLuo.WinFormsUI.Docking.DockPanel dockPanel, ScriptInformation script)
        {
            frmFormatObject frmFormatObject = new frmFormatObject();

            frmFormatObject.SetScriptInformation(script);

            DialogResult cResult = frmFormatObject.ShowDialog();

            frmFormatObject.Dispose();

            if (cResult == DialogResult.OK)
            {
                ProfileSetting cProfile = frmFormatObject.Profile;
                switch (cProfile.ScriptType)
                {
                case ScriptType.Script:
                    break;

                case ScriptType.Signal:
                    frmSignalViewer.Create(dockPanel, cProfile);
                    break;
                }
            }
        }
        private async Task <ProfileSetting> ProcessProfileSettingsModel(ProfileSetting setting)
        {
            var profileSetting = new ProfileSetting
            {
                JobTitle   = setting.JobTitle,
                ShortIntro = setting.ShortIntro,
                UserName   = setting.UserName,
                StorePath  = null
            };

            if (setting.Avatar != null)
            {
                var fileName  = $"{RandomString.GenerateRandomString(AppEnum.MinGeneratedAssetName)}.{setting.Avatar.ContentType.Split("/")[1]}";
                var storePath = Path.Combine(_assetSettings.Value.StorePath, fileName);
                using (var stream = new FileStream(storePath, FileMode.Create))
                {
                    await setting.Avatar.CopyToAsync(stream);
                }

                profileSetting.StorePath = $"./assets/{fileName}";
            }

            return(profileSetting);
        }
        private IEnumerable<SelectListItem> GetAvailableFoodEntryTypes(ProfileSetting profileSettings)
        {
            if (profileSettings.DietPlanId.HasValue)
            {
                using (var context = new DietJournalEntities())
                {
                    var dietPlan = context.DietPlans.FirstOrDefault(d => d.Id == profileSettings.DietPlanId.Value);

                    var foodEntryTypes = (from t in context.FoodEntryTypes
                                          where t.DietPlanId == profileSettings.DietPlanId.Value
                                                ||
                                                (dietPlan.ParentId.HasValue && t.DietPlanId == dietPlan.ParentId.Value)
                                          select t).ToList();

                    var availableFoodEntryTypes = foodEntryTypes.Select(t => new SelectListItem
                                                                                 {
                                                                                     Value = t.Id.ToString(),
                                                                                     Text = t.Name
                                                                                 }).ToList();

                    availableFoodEntryTypes.Insert(0, new SelectListItem {Text = "--Select Entry Type--", Value = ""});

                    return availableFoodEntryTypes;
                }
            }

            return null;
        }
Example #18
0
        public void SaveCurrentProfileSetting(ProfileSetting setting, string value, bool skipIsDataSync = false)
        {
            try
            {
                ProfileTableEntity profile      = this.CurrentProfile;
                string             oldProfileId = profile.ProfileId;
                switch (setting)
                {
                case ProfileSetting.ProfileId:
                    profile.ProfileId = value;
                    break;

                case ProfileSetting.MobileNumber:
                    profile.MobileNumber = value;
                    break;

                case ProfileSetting.LocationServicePref:
                    profile.LocationConsent = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.PostLocationServicePref:
                    profile.PostLocationConsent = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.SosStatusSynced:
                    profile.IsSOSStatusSynced = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.TrackingStatusSynced:
                    profile.IsTrackingStatusSynced = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.MapView:
                    profile.MapView = (MapCartographicMode)Enum.Parse(typeof(MapCartographicMode), value, true);
                    break;

                case ProfileSetting.MessageTemplatePref:
                    profile.MessageTemplate = value;
                    break;

                case ProfileSetting.CanSendSMS:
                    profile.CanSMS = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CanSendEmail:
                    profile.CanEmail = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CanSendFBPost:
                    profile.CanFBPost = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.FBGroupId:
                    profile.FBGroupId = value;
                    break;

                case ProfileSetting.FBGroupName:
                    profile.FBGroupName = value;
                    break;

                case ProfileSetting.SessionToken:
                    profile.SessionToken = value;
                    break;

                case ProfileSetting.SetPrimeBuddy:
                    App.MyBuddies.SetPrimeBuddy(profile.ProfileId, value);
                    break;

                case ProfileSetting.TrackingStatus:
                    if (!Convert.ToBoolean(value) && !this.CurrentProfile.IsSOSOn)
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;
                    }
                    else
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
                    }

                    profile.IsTrackingOn = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.SOSStatus:
                    if (!Convert.ToBoolean(value) && !this.CurrentProfile.IsTrackingOn)
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;
                    }
                    else
                    {
                        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
                    }
                    profile.IsSOSOn = Convert.ToBoolean(value);
                    break;

                case ProfileSetting.CountryCode:
                    profile.CountryCode = value;
                    break;

                case ProfileSetting.PoliceContact:
                    profile.PoliceContact = value;
                    break;

                case ProfileSetting.AmbulanceContact:
                    profile.AmbulanceContact = value;
                    break;

                case ProfileSetting.FireContact:
                    profile.FireContact = value;
                    break;

                case ProfileSetting.CountryName:
                    profile.CountryName = value;
                    break;

                case ProfileSetting.MaxPhonedigits:
                    profile.MaxPhonedigits = value;
                    break;

                case ProfileSetting.NotificationUri:
                    profile.NotificationUri = value;
                    break;

                default:
                    break;
                }

                // Update the local storage with the new setting value
                this.UpdateProfile(oldProfileId, profile);

                // Set DataSyncedToServer status to false, if the key is not in the below list
                if (Globals.IsRegisteredUser &&
                    !(setting == ProfileSetting.ProfileId || setting == ProfileSetting.PostLocationServicePref ||
                      setting == ProfileSetting.MapView || setting == ProfileSetting.SessionToken ||
                      setting == ProfileSetting.TrackingStatus || setting == ProfileSetting.SOSStatus ||
                      setting == ProfileSetting.MessageTemplatePref ||   //TODO: Remove, if message is configurable by user.
                      setting == ProfileSetting.TrackingStatusSynced || setting == ProfileSetting.SosStatusSynced ||
                      skipIsDataSync))
                {
                    UpdateIsDataSynced(false);
                }
            }
            catch (Exception)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToSaveSettingText, "basicWrap", "Oops!"));
            }
        }
Example #19
0
 internal void SetProfileSetting(ProfileSetting profile)
 {
     __cProfile = profile;
 }
Example #20
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            //update на снимката
            if (!string.IsNullOrEmpty(this.hdnRowMasterKey.Value) && this.hdnRowMasterKey.Value != Constants.INVALID_ID_STRING)
            {
                string idProfile = this.hdnRowMasterKey.Value;
                this.currentEntity = this.ownerPage.CostCalculationRef.GetProfileSettingById(this.hdnRowMasterKey.Value);

                //създава и отваря ресурсна папка с име - idProfileSetting
                string folderName          = this.hdnRowMasterKey.Value;
                string resourcesFolderName = GeneralPage.GetSettingByCode(ETEMEnums.AppSettings.ResourcesFolderName).SettingValue + @"\ProfileSetting\";

                //ID с което започва папката за импорт. Пример C:\Resources_ETEM\DieFormula\198
                string idStartFolder = folderName.Split('_')[0].ToString();

                DirectoryInfo folder = new DirectoryInfo(resourcesFolderName);

                //Винаги изтриваме целевата папка за да не се пълни с всяка следваща снимка
                if (folder.Exists)
                {
                    DirectoryInfo[] directories = folder.GetDirectories();

                    foreach (var file in directories)
                    {
                        if (file.Name.StartsWith(idStartFolder))
                        {
                            FileInfo[] filesToDelete = file.GetFiles();

                            foreach (var delFile in filesToDelete)
                            {
                                File.Delete(delFile.FullName);
                            }

                            break;
                        }
                    }
                }

                //и отново създаваме потребителската директория
                folder = new DirectoryInfo(resourcesFolderName + folderName);

                if (!folder.Exists)
                {
                    folder = Directory.CreateDirectory(resourcesFolderName + folderName);
                }


                //ако сме избрали нещо
                if (!string.IsNullOrEmpty(FileUpload1.FileName))
                {
                    //записваме картинката в папката
                    string pathToSave = (folder.FullName.EndsWith("\\") ? folder.FullName : folder.FullName + "\\") + FileUpload1.FileName;

                    FileUpload1.SaveAs(pathToSave);

                    //update Person
                    if (this.currentEntity != null)
                    {
                        string imagePath = GeneralPage.GetSettingByCode(ETEMEnums.AppSettings.WebResourcesFolderName).SettingValue + "/ProfileSetting/" + folderName + "/" + FileUpload1.FileName;
                        this.imgBtnProfileSetting.ImageUrl = imagePath;
                        this.currentEntity.ImagePath       = imagePath;
                        this.currentEntity.idModifyUser    = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                        this.currentEntity.dModify         = DateTime.Now;

                        CallContext resultPersontContext = new CallContext();
                        resultPersontContext.CurrentConsumerID = idProfile;
                        resultPersontContext = this.ownerPage.CostCalculationRef.ProfileSettingSave(this.currentEntity, resultPersontContext);
                    }
                }

                this.CurrentEntityMasterID = idProfile;
            }

            this.pnlAddProfileSettingImage.Visible = false;
        }
Example #21
0
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            loadInitControls();

            this.hdnRowMasterKey.Value = this.CurrentEntityMasterID;

            if (this.CurrentEntityMasterID != Constants.INVALID_ID_STRING && !string.IsNullOrEmpty(this.CurrentEntityMasterID))
            {
                this.currentEntity = this.ownerPage.CostCalculationRef.GetProfileSettingById(this.CurrentEntityMasterID);

                this.tbxProfile.Text    = this.currentEntity.ProfileName;
                this.tbxProfileSAP.Text = this.currentEntity.ProfileNameSAP;
                this.ddlProfileCategory.SelectedValue   = this.currentEntity.idProfileCategory.ToString();
                this.ddlProfileType.SelectedValue       = this.currentEntity.idProfileType.ToString();
                this.ddlProfileComplexity.SelectedValue = this.currentEntity.idProfileComplexity.ToString();
                this.tbxDiameterFormula.Text            = this.currentEntity.DiameterFormula;

                foreach (ListItem listItem in chBxValue.Items)
                {
                    if (listItem.Text.StartsWith("A"))
                    {
                        listItem.Selected = this.currentEntity.hasA;
                    }
                    else if (listItem.Text.StartsWith("B"))
                    {
                        listItem.Selected = this.currentEntity.hasB;
                    }
                    else if (listItem.Text.StartsWith("C"))
                    {
                        listItem.Selected = this.currentEntity.hasC;
                    }
                    else if (listItem.Text.StartsWith("D"))
                    {
                        listItem.Selected = this.currentEntity.hasD;
                    }
                    else if (listItem.Text.StartsWith("s"))
                    {
                        listItem.Selected = this.currentEntity.hasS;
                    }
                }


                this.gvValidation.DataSource = this.ownerPage.CostCalculationRef.GetProfileSettingValidationByIDProfile(Int32.Parse(this.CurrentEntityMasterID));
                this.gvValidation.DataBind();

                if (!string.IsNullOrEmpty(currentEntity.ImagePath))
                {
                    this.imgBtnProfileSetting.ImageUrl = currentEntity.ImagePath;
                }
                else
                {
                    this.imgBtnProfileSetting.ImageUrl = @"~/Images/imageFormula.png";
                }

                this.btnAddValidation.Enabled    = true;
                this.btnRemoveValidation.Enabled = true;
            }
            else
            {
                SetEmptyValues();
            }

            this.pnlProfile.Visible = true;
            this.pnlProfile.Focus();
        }
Example #22
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!this.ownerPage.CheckUserActionPermission(ETEMEnums.SecuritySettings.ProfilesSave, false))
            {
                return;
            }

            if (ddlProfileCategory.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileCategory"));
                return;
            }
            if (ddlProfileType.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileType"));
                return;
            }
            if (ddlProfileComplexity.SelectedValue == Constants.INVALID_ID_STRING)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Please_add_ProfileComplexity"));
                return;
            }

            this.CurrentEntityMasterID = this.hdnRowMasterKey.Value;
            ProfileSetting profileSetting = new ProfileSetting();

            //редакция
            if (this.CurrentEntityMasterID != Constants.INVALID_ID_STRING && !string.IsNullOrEmpty(this.CurrentEntityMasterID))
            {
                profileSetting = this.ownerPage.CostCalculationRef.GetProfileSettingById(this.CurrentEntityMasterID);
                profileSetting.idModifyUser = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                profileSetting.dModify      = DateTime.Now;
            }
            //нов документ
            else
            {
                profileSetting.idCreateUser = Convert.ToInt32(this.ownerPage.UserProps.IdUser);
                profileSetting.dCreate      = DateTime.Now;
            }

            profileSetting.ProfileName         = this.tbxProfile.Text;
            profileSetting.ProfileNameSAP      = this.tbxProfileSAP.Text;
            profileSetting.idProfileType       = this.ddlProfileType.SelectedValueINT;
            profileSetting.idProfileCategory   = this.ddlProfileCategory.SelectedValueINT;
            profileSetting.idProfileComplexity = this.ddlProfileComplexity.SelectedValueINT;
            profileSetting.DiameterFormula     = this.tbxDiameterFormula.Text;

            foreach (ListItem listItem in chBxValue.Items)
            {
                if (listItem.Text.StartsWith("A"))
                {
                    profileSetting.hasA = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("B"))
                {
                    profileSetting.hasB = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("C"))
                {
                    profileSetting.hasC = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("D"))
                {
                    profileSetting.hasD = listItem.Selected;
                }
                else if (listItem.Text.StartsWith("s"))
                {
                    profileSetting.hasS = listItem.Selected;
                }
            }

            this.ownerPage.CallContext = this.ownerPage.CostCalculationRef.ProfileSettingSave(profileSetting, this.ownerPage.CallContext);

            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.CurrentEntityMasterID = profileSetting.EntityID.ToString();

                UserControlLoad();

                RefreshParent();

                EvaluateExpressionHelper eval = new EvaluateExpressionHelper();

                Dictionary <string, string> vals = new Dictionary <string, string>();


                vals.Add("A", "100");
                vals.Add("B", "100");
                vals.Add("C", "100");
                vals.Add("D", "100");
                vals.Add("s", "4");

                try
                {
                    eval.EvalExpression(this.tbxDiameterFormula.Text, vals).ToString();
                }
                catch (Exception ex)
                {
                    this.ownerPage.ShowMSG(ex.Message.Replace("'", "\""));
                }
            }



            CheckIfResultIsSuccess(this.lbResultContext);
            lbResultContext.Text = this.ownerPage.CallContext.Message;
        }