Ejemplo n.º 1
0
        public ResponsResult SaveSetting(SystemSettingModel model)
        {
            ResponsResult result = new ResponsResult();

            systemSettingService.SaveSettings(model);
            return(result);
        }
Ejemplo n.º 2
0
        private void BarcodePrintForm_Load(object sender, EventArgs e)
        {
            SystemSettingModel displayData = new SystemSettingModel();

            displayData = settingBLL.GetSettingData();
            string[] sectionType = displayData.SectionType.Split('|');
            foreach (string s in sectionType)
            {
                if (s.Equals("1"))
                {
                    chFront.Checked = true;
                }
                if (s.Equals("2"))
                {
                    chBack.Checked = true;
                }
                if (s.Equals("3"))
                {
                    chWarehouse.Checked = true;
                }
                if (s.Equals("4"))
                {
                    chFreshFood.Checked = true;
                }
            }
        }
Ejemplo n.º 3
0
 public IActionResult SystemSetting(SystemSettingModel system_setting)
 {
     if (system_setting != null)
     {
         string error_message = null;
         bool   saved         = false;
         Setting.Lock();
         try
         {
             error_message = Setting.ApplySystemSetting(system_setting);
             saved         = Setting.Save();
         }
         finally
         {
             Setting.Unlock();
         }
         if (saved == false)
         {
             ViewData["Alert"] = "設定の保存に失敗しました。";
         }
         else if (error_message != null)
         {
             ViewData["Alert"] = $"設定は保存されましたがエラーが発生しました。{error_message}";
         }
         else
         {
             ViewData["Alert"] = "設定は保存され、設定の有効性が確認されました。\\n一部の設定は再起動するまで反映されません。";
         }
     }
     return(SystemSetting());
 }
Ejemplo n.º 4
0
 private void DisplayData(SystemSettingModel dataForDisplay)
 {
     maxLoginFailTextBox.Text      = dataForDisplay.MaxLoginFail.ToString();
     comIDTextBox.Text             = dataForDisplay.ComID;
     comNameTextBox.Text           = dataForDisplay.ComName;
     countDateDateTimePicker.Value = dataForDisplay.CountDate;
     System.Threading.Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
     System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
     branch.Text = dataForDisplay.Branch;
     string[] sectionType = dataForDisplay.SectionType.Split('|');
     foreach (var sec in sectionType)
     {
         if (sec.Equals("1"))
         {
             chFront.Checked = true;
         }
         if (sec.Equals("2"))
         {
             chBack.Checked = true;
         }
         if (sec.Equals("3"))
         {
             chWareHouse.Checked = true;
         }
         if (sec.Equals("4"))
         {
             chFreshFood.Checked = true;
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 設定ファイルを読み込む
        /// </summary>
        /// <returns>読み込まれたらtrueを返す</returns>
        public static bool Load()
        {
            bool result;
            SystemSettingModel  system_setting;
            SpeakerSettingModel speaker_setting;

            try
            {
                using (Stream stream = new FileStream(Path, FileMode.Open, FileAccess.Read))
                {
                    var serializer = new DataContractJsonSerializer(typeof(SettingJson));
                    var setting    = (SettingJson)serializer.ReadObject(stream);
                    system_setting  = setting.System;
                    speaker_setting = setting.Speaker;
                }
                result = true;
            }
            catch (Exception)
            {
                // 初期値を返す
                system_setting  = new SystemSettingModel();
                speaker_setting = new SpeakerSettingModel();
                result          = false;
            }
            ApplySystemSetting(system_setting);
            ApplySpeakerSetting(speaker_setting);
            return(result);
        }
Ejemplo n.º 6
0
 public ActionResult System(SystemSettingModel model)
 {
     _settingService.SaveSetting(SystemSettingNames.SiteName, model.SiteName);
     _settingService.SaveSetting(SystemSettingNames.Description, model.Description);
     _settingService.SaveSetting(SystemSettingNames.Keywords, model.Keywords);
     _settingService.SaveSetting(SystemSettingNames.Tel, model.Tel);
     _settingService.SaveSetting(SystemSettingNames.Title, model.Title);
     model.Result = true;
     return(View(model));
 }
        //
        // GET: /Admin/SystemSetting/Create

        public ActionResult Create()
        {
            Title = "Thêm mới SystemSetting";
            ViewData["ToolbarTitle"] = Title;
            SystemSettingModel model = new SystemSettingModel();
            var statuses             = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum))
                                       select new { ID = (int)s, Name = s.ToString() };

            model.SystemSettingType = new SelectList(statuses, "Id", "Name", 1);
            return(View(model));
        }
        public ActionResult Create(SystemSettingModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    SystemSetting systemSetting = model.ToEntity();
                    systemSetting.SettingKey  = model.SettingKey;
                    systemSetting.Title       = model.Title;
                    systemSetting.Description = model.Description;
                    systemSetting.Type        = model.Type;
                    systemSetting.Value       = model.Value;

                    if (model.Type == 1 || model.Type == 2)
                    {
                        systemSetting.Options = "";
                    }
                    else
                    {
                        //List<object> myObj = new List<object>();
                        //string[] options = model.Options.Trim().Split('|');
                        //foreach (var s in options)
                        //{
                        //    string[] strOption = s.Trim().Split('=');
                        //    myObj.Add(new { id = strOption[0], text = strOption[1] });
                        //}
                        //JavaScriptSerializer serializer = new JavaScriptSerializer();
                        //systemSetting.Options = serializer.Serialize(myObj);
                        systemSetting.Options = model.Options;
                    }

                    systemSetting.IsRequired = model.IsRequired;

                    _systemSettingService.AddSystemSetting(systemSetting);
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    ErrorNotification(e);
                }
            }
            else
            {
                AddModelStateErrors();
            }
            Title = "Thêm mới SystemSetting";
            ViewData["ToolbarTitle"] = Title;
            var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum))
                           select new { ID = (int)s, Name = s.ToString() };

            model.SystemSettingType = new SelectList(statuses, "Id", "Name", 1);
            return(View(model));
        }
Ejemplo n.º 9
0
        public ActionResult System()
        {
            var model = new SystemSettingModel
            {
                SiteName    = _settingService.GetSettingByKey <string>(SystemSettingNames.SiteName),
                Description = _settingService.GetSettingByKey <string>(SystemSettingNames.Description),
                Keywords    = _settingService.GetSettingByKey <string>(SystemSettingNames.Keywords),
                Tel         = _settingService.GetSettingByKey <string>(SystemSettingNames.Tel),
                Title       = _settingService.GetSettingByKey <string>(SystemSettingNames.Title),
            };

            return(View(model));
        }
Ejemplo n.º 10
0
        public SystemSettingModel GetSettingData()
        {
            SystemSettingModel SettingData = new SystemSettingModel();
            Entities           dbContext   = new Entities();

            try
            {
                SettingData.MaxLoginFail = (from setting in dbContext.SystemSettings
                                            where setting.SettingKey.Equals("LoginFailLimit")
                                            select setting.ValueInt.Value).FirstOrDefault();
                SettingData.ComID = (from setting in dbContext.SystemSettings
                                     where setting.SettingKey.Equals("ComID")
                                     select setting.ValueString).FirstOrDefault();
                SettingData.ComName = (from setting in dbContext.SystemSettings
                                       where setting.SettingKey.Equals("ComName")
                                       select setting.ValueString).FirstOrDefault();
                SettingData.CountDate = (from setting in dbContext.SystemSettings
                                         where setting.SettingKey.Equals("CountDate")
                                         select setting.ValueDate.Value).FirstOrDefault();
                SettingData.SectionType = (from setting in dbContext.SystemSettings
                                           where setting.SettingKey.Equals("SectionType")
                                           select setting.ValueString).FirstOrDefault();
                SettingData.Branch = (from setting in dbContext.SystemSettings
                                      where setting.SettingKey.Equals("Branch")
                                      select setting.ValueString).FirstOrDefault();
                SettingData.PathSKUFile = (from setting in dbContext.SystemSettings
                                           where setting.SettingKey.Equals("PathSKUFile")
                                           select setting.ValueString).FirstOrDefault();
                SettingData.PathBarcodeFile = (from setting in dbContext.SystemSettings
                                               where setting.SettingKey.Equals("PathBarcodeFile")
                                               select setting.ValueString).FirstOrDefault();
                SettingData.PathPackBarcodeFile = (from setting in dbContext.SystemSettings
                                                   where setting.SettingKey.Equals("PathPackBarcodeFile")
                                                   select setting.ValueString).FirstOrDefault();
                SettingData.PathBrandFile = (from setting in dbContext.SystemSettings
                                             where setting.SettingKey.Equals("PathBrandFile")
                                             select setting.ValueString).FirstOrDefault();
                SettingData.RealTimeMode = (bool)(from setting in dbContext.SystemSettings
                                                  where setting.SettingKey.Equals("RealtimeMode")
                                                  select setting.ValueBoolean).FirstOrDefault();
                return(SettingData);
            }
            catch (Exception ex)
            {
                log.Error(String.Format("Exception : {0}", ex.StackTrace));
                return(SettingData);
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Put(int id, [FromBody] SystemSettingModel model)
        {
            var setting = this.systemSettingService.GetByKey <SystemSetting>(model.Name);

            if (setting != null && setting.Id == id)
            {
                setting.Value = model.Value;
                await this.systemSettingService.Update(setting);

                return(this.Ok(new { result = true }));
            }
            else
            {
                return(this.NotFound());
            }
        }
        //
        // GET: /Admin/SystemSetting/Edit/5

        public ActionResult Edit(string key)
        {
            SystemSetting systemSetting = _systemSettingService.GetSystemSetting(key);

            if (systemSetting == null)
            {
                ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn");
                return(RedirectToAction("Index"));
            }
            Title = "Chỉnh sửa SystemSetting";
            ViewData["ToolbarTitle"] = Title;

            SystemSettingModel model = systemSetting.ToCreateModel();

            if (model.Type != 1 && model.Type != 2)
            {
                if (model.Options != null)
                {
                    List <object> myObj   = new List <object>();
                    string[]      options = model.Options.Trim().Split('|');
                    foreach (var s in options)
                    {
                        string[] strOption = s.Trim().Split('=');
                        myObj.Add(new { Id = strOption[0], Name = strOption[1] });
                    }
                    model.ListOptions = new SelectList(myObj, "Id", "Name", model.Value);
                }
            }
            if (model.Type == 3)
            {
                string[]      arrValue = systemSetting.Value.Split(',');
                List <string> list     = new List <string>();
                for (int i = 0; i < arrValue.Length; i++)
                {
                    list.Add(arrValue[i]);
                }
                model.ListSelected = list;
            }
            var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum))
                           select new { ID = (int)s, Name = s.ToString() };

            model.SystemSettingType = new SelectList(statuses, "Id", "Name", model.Type);
            //JavaScriptSerializer serializer = new JavaScriptSerializer();
            //List<SelectListItem> dataObj = serializer.Deserialize<List<SelectListItem>>(model.Options);
            //model.ListOptions = new SelectList(dataObj, "Value", "Text", model.Value);
            return(View(model));
        }
Ejemplo n.º 13
0
        public string UpdateSettingData(SystemSettingModel newSettingData)
        {
            SystemSetting systemSetting = new SystemSetting();

            using (Entities DBcontext = new Entities())
            {
                using (var DBtransaction = DBcontext.Database.BeginTransaction())
                {
                    try
                    {
                        systemSetting          = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("LoginFailLimit")).First();
                        systemSetting.ValueInt = newSettingData.MaxLoginFail;

                        systemSetting             = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("ComID")).First();
                        systemSetting.ValueString = newSettingData.ComID;

                        systemSetting             = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("ComName")).First();
                        systemSetting.ValueString = newSettingData.ComName;

                        systemSetting           = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("CountDate")).First();
                        systemSetting.ValueDate = newSettingData.CountDate;

                        systemSetting             = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("SectionType")).First();
                        systemSetting.ValueString = newSettingData.SectionType;

                        systemSetting             = DBcontext.SystemSettings.Where(x => x.SettingKey.Equals("Branch")).First();
                        systemSetting.ValueString = newSettingData.Branch;

                        DBcontext.SaveChanges();

                        DBtransaction.Commit();

                        return("success");
                    }
                    catch (Exception ex)
                    {
                        DBtransaction.Rollback();
                        log.Error(String.Format("Exception : {0}", ex.StackTrace));
                        return("error");
                    }
                }
            }
        }
        public ActionResult EditValue(string key)
        {
            SystemSetting systemSetting = _systemSettingService.GetForUpdate(key);

            if (systemSetting == null)
            {
                ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn");
                return(RedirectToAction("Index"));
            }
            Title = "Chỉnh sửa SystemSetting";
            ViewData["ToolbarTitle"] = Title;

            SystemSettingModel model = systemSetting.ToCreateModel();

            if (model.Type != 1 && model.Type != 2)
            {
                if (model.Options != null)
                {
                    List <object> myObj   = new List <object>();
                    string[]      options = model.Options.Trim().Split('|');
                    foreach (var s in options)
                    {
                        string[] strOption = s.Trim().Split('=');
                        myObj.Add(new { Id = strOption[0], Name = strOption[1] });
                    }
                    model.ListOptions = new SelectList(myObj, "Id", "Name", model.Value);
                }
            }
            if (model.Type == 3)
            {
                string[]      arrValue = systemSetting.Value.Split(',');
                List <string> list     = new List <string>();
                for (int i = 0; i < arrValue.Length; i++)
                {
                    list.Add(arrValue[i]);
                }
                model.ListSelected = list;
            }
            return(View(model));
        }
Ejemplo n.º 15
0
        public string UpdateSetting(SystemSettingModel newDateSetting)
        {
            string result = settingDAO.UpdateSettingData(newDateSetting);

            return(result);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 新しいシステム設定値を適用する。
        /// </summary>
        /// <param name="setting">新しいシステム設定値</param>
        /// <returns>エラーメッセージ、もしくはnull</returns>
        public static string ApplySystemSetting(SystemSettingModel setting)
        {
            System        = setting;
            IconByteArray = null;
            try
            {
                // インストールディレクトリと実行ファイルの存在を確認する
                if (Directory.Exists(System.InstallPath) == false)
                {
                    return("インストールディレクトリが存在しません。");
                }
                string exe_path = $"{System.InstallPath}\\{System.VoiceroidEditorExe}";
                if (File.Exists(exe_path) == false)
                {
                    return("VOICEROID2エディタの実行ファイルが存在しません。");
                }

                // アイコンを取得する
                try
                {
                    using (var icon = Icon.ExtractAssociatedIcon(exe_path))
                        using (var bitmap = icon.ToBitmap())
                            using (var stream = new MemoryStream())
                            {
                                bitmap.Save(stream, ImageFormat.Png);
                                IconByteArray = stream.ToArray();
                            }
                }
                catch (Exception) { }

                // AITalkを初期化する
                AitalkWrapper.Initialize(System.InstallPath, System.AuthCodeSeed);

                // 言語ライブラリを読み込む
                if ((System.LanguageName != null) && (0 < System.LanguageName.Length))
                {
                    // 指定された言語ライブラリを読み込む
                    AitalkWrapper.LoadLanguage(System.LanguageName);
                }
                else
                {
                    // 未指定の場合、初めに見つけたものを読み込む
                    string language_name = AitalkWrapper.LanguageList.FirstOrDefault() ?? "";
                    AitalkWrapper.LoadLanguage(language_name);
                }

                // フレーズ辞書が指定されていれば読み込む
                if (File.Exists(System.PhraseDictionaryPath))
                {
                    AitalkWrapper.ReloadPhraseDictionary(System.PhraseDictionaryPath);
                }

                // 単語辞書が指定されていれば読み込む
                if (File.Exists(System.WordDictionaryPath))
                {
                    AitalkWrapper.ReloadWordDictionary(System.WordDictionaryPath);
                }

                // 記号ポーズ辞書が指定されていれば読み込む
                if (File.Exists(System.SymbolDictionaryPath))
                {
                    AitalkWrapper.ReloadSymbolDictionary(System.SymbolDictionaryPath);
                }

                return(null);
            }
            catch (AitalkException ex)
            {
                return(ex.Message);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
        public ActionResult EditValue(SystemSettingModel model)
        {
            string command = Request.Form["submit"].ToString();

            switch (command)
            {
            case "Save":
            case "SaveAndContinueEdit":
                if (ModelState.IsValid)
                {
                    try
                    {
                        SystemSetting systemSetting = _systemSettingService.GetForUpdate(model.SettingKey);
                        if (systemSetting == null)
                        {
                            ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn");
                            return(RedirectToAction("Index"));
                        }
                        if (systemSetting.Type == 3)
                        {
                            string value = "";
                            foreach (var item in model.ListSelected)
                            {
                                value += item + ",";
                            }
                            systemSetting.Value = value.Trim(',');
                        }
                        else
                        {
                            systemSetting.Value = model.Value;
                        }
                        _systemSettingService.UpdateSystemSetting(systemSetting);

                        SuccessNotification("Cập nhật SystemSetting thành công");

                        if (command == "SaveAndContinueEdit")
                        {
                            Title = "Chỉnh sửa SystemSetting ";
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (Exception e)
                    {
                        Title = "Chỉnh sửa SystemSetting";
                        ErrorNotification(e);
                    }
                }

                break;

            case "Delete":
                return(RedirectToAction("Delete", new { key = model.SettingKey }));

            default:
                ErrorNotification("Không rõ phương thức submit dữ liệu");
                return(RedirectToAction("Index"));
            }

            ViewData["ToolbarTitle"] = Title;
            var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum))
                           select new { ID = (int)s, Name = s.ToString() };

            model.SystemSettingType = new SelectList(statuses, "Id", "Name", 1);
            return(View(model));
        }
Ejemplo n.º 18
0
 public ResponsResult SaveSystemSetting([FromBody] SystemSettingModel model)
 {
     return(_commonService.SaveSetting(model));
 }
        public ActionResult Edit(SystemSettingModel model)
        {
            SystemSetting systemSetting = _systemSettingService.GetSystemSetting(model.SettingKey);

            if (systemSetting == null)
            {
                ErrorNotification("Không tìm thấy trang tĩnh nào thỏa mãn");
                return(RedirectToAction("Index"));
            }

            string command = Request.Form["submit"].ToString();

            switch (command)
            {
            case "Save":
            case "SaveAndContinueEdit":
                if (ModelState.IsValid)
                {
                    try
                    {
                        systemSetting.SettingKey  = model.SettingKey;
                        systemSetting.Title       = model.Title;
                        systemSetting.Description = model.Description;
                        //if (systemSetting.Type == 3)
                        //{
                        //    string value = "";
                        //    foreach (var item in model.ListSelected)
                        //    {
                        //        value += item + ",";
                        //    }
                        //    systemSetting.Value = value.Trim(',');
                        //}
                        //else
                        //    systemSetting.Value = model.Value;
                        systemSetting.Type = model.Type;
                        if (model.Type == 1 || model.Type == 2)
                        {
                            systemSetting.Options = "";
                        }
                        else
                        {
                            systemSetting.Options = model.Options;
                        }
                        systemSetting.IsRequired = model.IsRequired;

                        _systemSettingService.UpdateSystemSetting(systemSetting);

                        SuccessNotification("Cập nhật SystemSetting thành công");

                        if (command == "SaveAndContinueEdit")
                        {
                            Title = "Chỉnh sửa SystemSetting ";
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    catch (Exception e)
                    {
                        Title = "Chỉnh sửa SystemSetting ";
                        ErrorNotification(e);
                    }
                }

                break;

            case "Delete":
                return(RedirectToAction("Delete", new { key = model.SettingKey }));

            default:
                ErrorNotification("Không rõ phương thức submit dữ liệu");
                return(RedirectToAction("Index"));
            }

            if (model.Type != 1 && model.Type != 2)
            {
                if (model.Options != null)
                {
                    List <object> myObj   = new List <object>();
                    string[]      options = model.Options.Trim().Split('|');
                    foreach (var s in options)
                    {
                        string[] strOption = s.Trim().Split('=');
                        myObj.Add(new { Id = strOption[0], Name = strOption[1] });
                    }
                    model.ListOptions = new SelectList(myObj, "Id", "Name", model.Value);
                }
            }
            if (model.Type == 3)
            {
                string[]      arrValue = systemSetting.Value.Split(',');
                List <string> list     = new List <string>();
                for (int i = 0; i < arrValue.Length; i++)
                {
                    list.Add(arrValue[i]);
                }
                model.ListSelected = list;
            }
            var statuses = from SystemSettingcsEnum s in Enum.GetValues(typeof(SystemSettingcsEnum))
                           select new { ID = (int)s, Name = s.ToString() };

            model.SystemSettingType = new SelectList(statuses, "Id", "Name", model.Type);

            ViewData["ToolbarTitle"] = Title;
            return(View(model));
        }
Ejemplo n.º 20
0
 public SettingsForm()
 {
     InitializeComponent();
     displayData = settingBLL.GetSettingData();
     DisplayData(displayData);
 }
Ejemplo n.º 21
0
        public static IServiceCollection AddSystemSetting(this IServiceCollection services, SystemSettingModel systemSettingModel)
        {
            SystemSettingModel.Instance = systemSettingModel ?? new SystemSettingModel();

            return(services);
        }