Ejemplo n.º 1
0
 public void SetPreferredLanguage(LanguageKey key)
 {
     if (this._cookieRep.HasElement(CookieKey.UserLanguage))
     {
         this._cookieRep.UpdateElement(CookieKey.UserLanguage, key.ToString());
     }
     else
     {
         this._cookieRep.AddElement(CookieKey.UserLanguage, key.ToString());
     }
 }
Ejemplo n.º 2
0
        public static Encoding GetEncoding(this LanguageKey key)
        {
            switch (key)
            {
            case LanguageKey.FR:
            case LanguageKey.EN:
            case LanguageKey.ES:
                return(Encoding.GetEncoding(1252));

            case LanguageKey.DE:
            case LanguageKey.PL:
            case LanguageKey.IT:
            case LanguageKey.CZ:
                return(Encoding.GetEncoding(1250));

            case LanguageKey.TR:
                return(Encoding.GetEncoding(1254));

            default:
                throw new ArgumentOutOfRangeException(nameof(key), key, null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 转换中英文(动态绑定到UI,切换语言)
        /// </summary>
        /// <param name="txtId"></param>
        /// <returns></returns>
        public static string GetTxtById(LanguageKey txtId)
        {
            string text = txtId.ToString();

            switch (Current)
            {
            case "zh-CN":
                if (Chinese.Zh_Resource.ContainsKey(txtId))
                {
                    text = Chinese.Zh_Resource[txtId];
                }
                break;

            default:
                if (English.En_Resource.ContainsKey(txtId))
                {
                    text = English.En_Resource[txtId];
                }
                break;
            }
            return(text);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Builds the language key list
        /// </summary>
        /// <param name="languageKeyTemplate">Template for a language key</param>
        /// <param name="languageKeys">Language keys</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Language Key list</returns>
        private string BuildLanguageKeyList(string languageKeyTemplate, List <LanguageKey> languageKeys, ExportSettings exportSettings)
        {
            string listContent = string.Empty;

            for (int curLanguagekey = 0; curLanguagekey < languageKeys.Count; ++curLanguagekey)
            {
                LanguageKey languageKey = languageKeys[curLanguagekey];

                string keyCode = ExportUtil.RenderPlaceholderIfTrue(languageKeyTemplate, Placeholder_LanguageKeys_IsFirst_Start, Placeholder_LanguageKeys_IsFirst_End, curLanguagekey == 0);
                keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsNotFirst_Start, Placeholder_LanguageKeys_IsNotFirst_End, curLanguagekey != 0);
                keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsLast_Start, Placeholder_LanguageKeys_IsLast_End, curLanguagekey >= languageKeys.Count - 1);
                keyCode = ExportUtil.RenderPlaceholderIfTrue(keyCode, Placeholder_LanguageKeys_IsNotLast_Start, Placeholder_LanguageKeys_IsNotLast_End, curLanguagekey < languageKeys.Count - 1);

                keyCode = ExportUtil.BuildPlaceholderRegex(Placeholder_LanguageKey_Key).Replace(keyCode, languageKey.LangKey);
                string escapedText = ExportUtil.EscapeCharacters(languageKey.Value, exportSettings.LanguageEscapeCharacter, exportSettings.LanguageCharactersNeedingEscaping, exportSettings.LanguageNewlineCharacter);
                keyCode = ExportUtil.BuildPlaceholderRegex(Placeholder_LanguageKey_Text).Replace(keyCode, escapedText);

                listContent += keyCode;
            }

            return(listContent);
        }
Ejemplo n.º 5
0
        // GET: AccessControl/Login
        public ActionResult Index(string str_Language = "en")
        {
            ClearSelectionCriteriaFromViewData();

            LanguageKey temp = LanguageKey.en;

            Enum.TryParse <LanguageKey>(str_Language, out temp);

            TempData[StaticContent.LanguageKey] = temp;

            Thread.CurrentThread.CurrentCulture       =
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(LangPack.GetLanugage(temp));

            if (TempData[ActionMessageKey] != null)
            {
                ViewBag.ActionMessage = TempData[ActionMessageKey];
            }

            initLanguageComboBox(str_Language);

            return(View());
        }
Ejemplo n.º 6
0
    int ImportExcel()
    {
        if (fuExcel.FileName.Length > 3)
        {
            if (fuExcel.FileName.Substring(fuExcel.FileName.Length - 3, 3) == "xls")
            {
                try
                {
                    //Nhập dữ liệu từ file excel vào dataset
                    DataSet ds = new DataSet();
                    ds = ExcelExtension.ImportExcelXLS(fuExcel.PostedFile, true);

                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        //Thêm thông tin vào csdl
                        // ds.Tables[0].Rows[i][].ToString()
                        if (ds.Tables[0].Rows[i][0].ToString().Length > 0)
                        {
                            LanguageKey.InsertLanguageKeyProc(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][1].ToString());
                        }
                    }
                    return(0);
                }
                catch
                {
                    return(2);
                }
            }
            else
            {
                return(1);
            }
        }
        else
        {
            return(1);
        }
    }
Ejemplo n.º 7
0
    protected void RpListLanguageNationals_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string c = e.CommandName.Trim();
        string p = e.CommandArgument.ToString().Trim();

        switch (c)
        {
            #region delete
        case "delete":
            //Xoá ảnh
            DeleteLanguageItemImage(p);
            LanguageKey.DeleteLanguageKeyAndLanguageItem(p);
            GetListCodesLanguageKey();

            #region Logs
            string logAuthor     = CookieExtension.GetCookies("LoginSetting");
            string logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", p, logAuthor, "", logCreateDate + ": " + logAuthor + " xóa một từ khóa (id: " + p + ")");
            #endregion
            break;
            #endregion

            #region edit
        case "edit":
            Response.Redirect(LinkUpdate(p));
            GetListCodesLanguageKey();

            #region Logs
            logAuthor     = CookieExtension.GetCookies("LoginSetting");
            logCreateDate = DateTime.Now.ToString();
            Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", p, logAuthor, "", logCreateDate + ": " + logAuthor + " thay đổi trạng thái một từ khóa (id: " + p + ")");
            #endregion
            break;
            #endregion
        }
    }
        public RedisDataAccessProvider()
            : base()
        {
            base.Configuration.Host           = "localhost";
            base.Configuration.Port           = 6379;
            base.Configuration.ReceiveTimeout = -1;
            RenewConnectionPeriod             = 20;

            List = new LanguageItemCollection <LanguageList>()
            {
                Provider = this
            };
            Set = new LanguageItemCollection <LanguageSet>()
            {
                Provider = this
            };
            SortedSet = new LanguageItemCollection <LanguageSortedSet>()
            {
                Provider = this
            };
            Hash = new LanguageItemCollection <LanguageHash>()
            {
                Provider = this
            };
            this.Strings = new LanguageItemCollection <LanguageString>()
            {
                Provider = this
            };
            Key         = new LanguageKey();
            Transaction = new LanguageTransactions();
            Messaging   = new LanguageMessaging();

            ((ILanguageItem)Key).Configure(string.Empty, this);
            ((ILanguageItem)Transaction).Configure(string.Empty, this);
            ((ILanguageItem)Messaging).Configure(string.Empty, this);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 设置语言类型到Cookie中
 /// </summary>
 public void SetToCookie(LanguageKey lanKey)
 {
     SetToCookie(lanKey.ToString());
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取多语言节点值
 /// </summary>
 /// <param name="lanID">Xml节点ID</param>
 /// <param name="lanEnum">获取的语言</param>
 /// <returns></returns>
 public string Get(object lanID, LanguageKey lanEnum)
 {
     XmlNode node = helper.GetByID(Convert.ToString(lanID));
     if (node != null)
     {
         switch (lanEnum)
         {
             case LanguageKey.Chinese:
                 return node.InnerXml.Trim('\r', '\n').Trim();
             default:
                 string key = lanEnum.ToString().ToLower().Substring(0, 3);
                 if (node.Attributes[key] != null)
                 {
                     return node.Attributes[key].Value.Trim('\r', '\n').Trim();
                 }
                 else
                 {
                     return node.InnerXml.Trim('\r', '\n').Trim();
                 }
         }
     }
     return Convert.ToString(lanID);
 }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gameEventListener"></param>
        /// <param name="sceneMgr"></param>
        /// <param name="viewport"></param>
        /// <param name="camera"></param>
        /// <param name="startFromBottom"></param>
        /// <param name="speed"></param>
        public LanguageDebugScreen(GameEventListener gameEventListener,
                                   IFrameWork framework, Viewport viewport, Camera camera, bool startFromBottom, float speed) :
            base(gameEventListener, framework, viewport, camera, startFromBottom, speed)
        {
            this.fontSize = (uint)(0.63f * fontSize); // mniejsza czcionka

            List <String> arr     = new List <String>();
            List <String> arrFull = new List <String>();

            String[]      keys       = LanguageKey.GetAllLanguageKyes();
            StringBuilder fullString = new StringBuilder();

            foreach (string key in keys)
            {
                totalStrings++;
                arr.Add("" + key + ":");
                if (String.Empty.Equals(LanguageResources.GetString(key)))
                {
                    arr.Add("!!!");
                }
                else
                {
                    translatedStrings++;

                    IEnumerable <string> multiline = LanguageResources.SplitByLength(LanguageResources.GetString(key), charsLimitPerLine);

                    foreach (string line in multiline)
                    {
                        arr.Add(line);
                    }

                    fullString.Append(LanguageResources.GetString(key));
                }
                arr.Add(""); // new line
            }


            // all possible chars
            arrFull.Add(LanguageResources.GetString(LanguageKey.PossibleCharacters));
            char[] allchars = LanguageResources.BuildCharmap(fullString.ToString());


            Array.Sort(allchars);
            string output = "";

            foreach (char c in allchars)
            {
                output += c;
                arrFull.Add("Char U" + Convert.ToInt32(c) + "=" + c);
            }

            //    IEnumerable<string> lines = LanguageResources.SplitByLength(new string(allchars), charsLimitPerLine);

            //  foreach (string line in lines)
            //   {
            //       arrFull.Add(line);
            //    }
            arrFull.Add(""); arrFull.Add("");
            arrFull.AddRange(arr);

            names = arrFull.ToArray();
        }
Ejemplo n.º 12
0
        private List <LanguageKey> GetStandardLanguages(StandardComponent standard)
        {
            var languages = new List <LanguageKey>();

            var standardName = new LanguageKey
            {
                Key   = $"standardComponents.{standard.Name}.options.displayName",
                Value = standard.DisplayName
            };

            languages.Add(standardName);

            if (standard.Controls != null && standard.Controls.Count > 0)
            {
                foreach (var control in standard.Controls)
                {
                    if (control.Options.First(a => a.Key == "hidden").Value != "true")
                    {
                        // Control options
                        var labelLang = new LanguageKey
                        {
                            Key   = $"standardComponents.{standard.Name}.{control.Name}.options.label",
                            Value = control.Options.First(a => a.Key == "label").Value
                        };

                        var placeholderLang = new LanguageKey
                        {
                            Key   = $"standardComponents.{standard.Name}.{control.Name}.options.placeholder",
                            Value = control.Options.First(a => a.Key == "placeholder").Value
                        };

                        languages.Add(labelLang);
                        languages.Add(placeholderLang);
                        // Control validators
                        foreach (var validator in control.Validators)
                        {
                            if (validator.IsActive)
                            {
                                var validatorLang = new LanguageKey
                                {
                                    Key   = $"standardComponents.{standard.Name}.{control.Name}.validators.{Enum.GetName(typeof(ValidatorType), validator.ValidatorType)}",
                                    Value = validator.ValidatorMessage
                                };

                                languages.Add(validatorLang);
                            }
                        }

                        // Control asyncValidators
                        foreach (var validator in control.AsyncValidators)
                        {
                            if (validator.IsActive)
                            {
                                var asyncValidatorLang = new LanguageKey
                                {
                                    Key   = $"standardComponents.{standard.Name}.{control.Name}.asyncValidators.{validator.ValidatorName}",
                                    Value = validator.ValidatorMessage
                                };
                                languages.Add(asyncValidatorLang);
                            }
                        }
                    }
                }
            }

            return(languages);
        }
Ejemplo n.º 13
0
 public TranslateResponse Translate(LanguageKey source, LanguageKey target, String text)
 {
     return(Translate(new TranslateRequest {
         Source = source, Target = target
     }));
 }
Ejemplo n.º 14
0
 public string GetLanguage(string key, LanguageKey language)
 {
     return(null);
 }
Ejemplo n.º 15
0
        public LUSerLoginResult Login(LoginUserVM entityInst, string str_Language, string str_IpAdd, string str_HostName)
        {
            try
            {
                LUSerLoginResult returnResult = new LUSerLoginResult();

                SysParmRespository entityRepository = new SysParmRespository();

                StaticContent.SystemInfoInst = entityRepository.RetrieveSystemInfo();

                LanguageKey languageKey_Input = LanguageKey.en;

                Enum.TryParse <LanguageKey>(str_Language, out languageKey_Input);

                // Login Name cannot be empty
                if (string.IsNullOrWhiteSpace(entityInst.LoginName))
                {
                    string str_E001 = MultilingualHelper.GetStringFromResource(languageKey_Input, "E001");
                    str_E001 = string.Format(str_E001, MultilingualHelper.GetStringFromResource(languageKey_Input, "LoginName"));
                    returnResult.StrList_Error.Add(str_E001);
                }

                // Login Password cannot be empty
                if (string.IsNullOrWhiteSpace(entityInst.LoginPwd))
                {
                    string str_E001 = MultilingualHelper.GetStringFromResource(languageKey_Input, "E001");
                    str_E001 = string.Format(str_E001, MultilingualHelper.GetStringFromResource(languageKey_Input, "LoginPwd"));
                    returnResult.StrList_Error.Add(str_E001);
                }

                if (!string.IsNullOrWhiteSpace(entityInst.LoginName) && !string.IsNullOrWhiteSpace(entityInst.LoginPwd))
                {
                    string str_E008 = MultilingualHelper.GetStringFromResource(languageKey_Input, "E008");
                    str_E008 = string.Format(str_E008, MultilingualHelper.GetStringFromResource(languageKey_Input, "LoginName"), MultilingualHelper.GetStringFromResource(languageKey_Input, "LoginPwd"));

                    string str_E009 = MultilingualHelper.GetStringFromResource(languageKey_Input, "E009");

                    string str_E018 = MultilingualHelper.GetStringFromResource(languageKey_Input, "E018");

                    CoolPrivilegeControlContext dbContext      = CoolPrivilegeControlContext.CreateContext();
                    LoginUserRespository        loginUserRespo = new LoginUserRespository(dbContext, null);

                    LoginUserVM entityVM_exist = loginUserRespo.GetLoginUserInfo(entityInst.LoginName);
                    if (entityVM_exist != null)
                    {
                        PwdPolicy pwdPolicy = new PwdPolicy();

                        if (!entityVM_exist.Status.HasValue || entityVM_exist.Status.Value == 2)
                        {
                            returnResult.StrList_Error.Add(str_E018);
                        }
                        else if (entityVM_exist.Status.HasValue && entityVM_exist.Status.Value == 3)
                        {
                            returnResult.StrList_Error.Add(str_E018);
                        }
                        else
                        {
                            if (entityVM_exist.LoginPwd == pwdPolicy.GetMD5(entityInst.LoginPwd))
                            {
                                DateTime?dt_LastPwdMDT = entityVM_exist.LastPwdMDT;
                                entityVM_exist.FailCount   = 0;
                                entityVM_exist.Status      = 1;
                                entityVM_exist.LastLoginDT = DateTime.Now;
                                entityInst.LastPwdMDT      = entityVM_exist.LastPwdMDT;
                                List <string> strList_UpdateLastLoginDt_Error = new List <string>();
                                loginUserRespo.UpdateLastLoginDt(entityVM_exist, languageKey_Input, ref strList_UpdateLastLoginDt_Error);
                                if (strList_UpdateLastLoginDt_Error.Count > 0)
                                {
                                    foreach (var item in strList_UpdateLastLoginDt_Error)
                                    {
                                        returnResult.StrList_Error.Add(item);
                                    }
                                }
                                else
                                {
                                    AuthorizedHistoryRespository authorityHistoryRespos = new AuthorizedHistoryRespository(dbContext, entityVM_exist.ID);

                                    string str_SaveAuthorizedHistory_Error = "";

                                    //Create Login History
                                    authorityHistoryRespos.Create(new AuthorizedHistoryVM(), languageKey_Input, out str_SaveAuthorizedHistory_Error);

                                    if (!string.IsNullOrWhiteSpace(str_SaveAuthorizedHistory_Error))
                                    {
                                        returnResult.StrList_Error.Add(str_SaveAuthorizedHistory_Error);
                                    }
                                    else
                                    {
                                        string      sessionKey         = Guid.NewGuid().ToString();
                                        BaseSession entity_BaseSession = new BaseSession();
                                        entity_BaseSession.ID              = entityVM_exist.ID;
                                        entity_BaseSession.SessionKey      = sessionKey;
                                        entity_BaseSession.IpAddress       = str_IpAdd;
                                        entity_BaseSession.LastOperationDt = DateTime.Now;

                                        WCFAuthInfoVM entity_WCFAuthInfoVM = new WCFAuthInfoVM(str_IpAdd, str_HostName, "", "", "", "", "");

                                        WCFSesssionPolicy wcfPolicy = new WCFSesssionPolicy();

                                        wcfPolicy.StoreWCFSession(entity_WCFAuthInfoVM, entity_BaseSession);

                                        #region [ Set Client Authorized Info ]
                                        SessionWUserInfo entity_SessionWUserInfo = loginUserRespo.GetLoginUserAccRight(entity_BaseSession.ID);

                                        if (entity_SessionWUserInfo != null)
                                        {
                                            entity_SessionWUserInfo.SessionKey      = Guid.NewGuid().ToString();
                                            entity_SessionWUserInfo.IpAddress       = entity_WCFAuthInfoVM.IpAddress;
                                            entity_SessionWUserInfo.LastOperationDt = DateTime.Now;
                                        }
                                        #endregion

                                        returnResult.Entity_SessionWUserInfo = entity_SessionWUserInfo;

                                        if (entityVM_exist.LastPwdMDT.HasValue)
                                        {
                                            returnResult.IsPWDExpire = entityVM_exist.LastPwdMDT.Value.AddDays(((SystemInfoVM)StaticContent.SystemInfoInst).Password_ExpireDays) <= DateTime.Now.Date;
                                        }

                                        returnResult.Str_ServerToken = entity_WCFAuthInfoVM.WCFAuthorizedKey;
                                    }
                                }
                            }
                            else
                            {
                                List <string> strList_UpdateFailCount_Error = new List <string>();
                                loginUserRespo.UpdateFailCount(entityVM_exist, languageKey_Input, ref strList_UpdateFailCount_Error);

                                returnResult.StrList_Error.Add(str_E008);

                                if (strList_UpdateFailCount_Error.Count > 0)
                                {
                                    foreach (var item in strList_UpdateFailCount_Error)
                                    {
                                        returnResult.StrList_Error.Add(item);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        returnResult.StrList_Error.Add(str_E008);
                    }
                }
                return(returnResult);
            }
            catch (Exception ex)
            {
                throw new FaultException <WCFErrorContract>(new WCFErrorContract(ex), ex.Message);
            }
        }
Ejemplo n.º 16
0
 public void SetLanguage(string key, string value, LanguageKey type)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
        private IEnumerable <LanguageKey> GetDynamicListLanguages(DynamicList dynamicList)
        {
            var langauges = new List <LanguageKey>();

            var dynamicListName = new LanguageKey
            {
                Key   = $"dynamicLists.{dynamicList.Name}.options.displayName",
                Value = dynamicList.DisplayName
            };

            langauges.Add(dynamicListName);

            if (dynamicList.ColumnsList != null && dynamicList.ColumnsList.ColumndDefs != null && dynamicList.ColumnsList.ColumndDefs.Count > 0)
            {
                foreach (var column in dynamicList.ColumnsList.ColumndDefs)
                {
                    if (!column.IsHidden)
                    {
                        var columnName = new LanguageKey
                        {
                            Key   = $"dynamicLists.{dynamicList.Name}.cols.{column.Name}.displayName",
                            Value = column.DisplayName
                        };

                        langauges.Add(columnName);
                    }
                }
            }

            if (dynamicList.CommandsList != null && dynamicList.CommandsList.CommandButtonsInList != null)
            {
                foreach (var command in dynamicList.CommandsList.CommandButtonsInList)
                {
                    var commandName = new LanguageKey
                    {
                        Key   = $"dynamicLists.{dynamicList.Name}.commands.{command.Name}.displayName",
                        Value = command.DisplayName
                    };

                    langauges.Add(commandName);

                    switch (command.ActionCommandOptions.ActionType)
                    {
                    case ActionType.Redirect:
                        break;

                    case ActionType.ExecuteDatabase:
                    case ActionType.CallHttpService:
                    default:
                        if (command.ActionCommandOptions.ConfirmationOptions != null)
                        {
                            var confirmationText = new LanguageKey
                            {
                                Key   = $"dynamicLists.{dynamicList.Name}.commands.{command.Name}.confirmation.text",
                                Value = command.ActionCommandOptions.ConfirmationOptions.ConfirmationText
                            };
                            langauges.Add(confirmationText);
                        }

                        if (command.ActionCommandOptions.NotificationOptions != null)
                        {
                            var notificationSuccess = new LanguageKey
                            {
                                Key   = $"dynamicLists.{dynamicList.Name}.commands.{command.Name}.notification.success",
                                Value = command.ActionCommandOptions.NotificationOptions.CompleteMessage
                            };
                            var notificationFailed = new LanguageKey
                            {
                                Key   = $"dynamicLists.{dynamicList.Name}.commands.{command.Name}.notification.failed",
                                Value = command.ActionCommandOptions.NotificationOptions.FailedMessage
                            };
                            langauges.Add(notificationSuccess);
                            langauges.Add(notificationFailed);
                        }
                        break;
                    }
                }
            }

            return(langauges);
        }
Ejemplo n.º 18
0
 public void SetLanguage(PlayerMessages key, string value, LanguageKey type)
 {
     GetSetByLanguageKey(type)[key] = value;
 }
Ejemplo n.º 19
0
        private IEnumerable <LanguageKey> GetPageLanguages(Page page)
        {
            var languages = new List <LanguageKey>();

            var pageName = new LanguageKey
            {
                Key   = $"pages.{page.Name}.options.displayName",
                Value = page.DisplayName
            };

            languages.Add(pageName);

            if (page.Builder != null &&
                page.Builder.Sections != null &&
                page.Builder.Sections.Count > 0)
            {
                foreach (var section in page.Builder.Sections)
                {
                    var sectionName = new LanguageKey
                    {
                        Key   = $"pages.{page.Name}.sections.{section.Name}.options.displayName",
                        Value = section.DisplayName
                    };

                    languages.Add(sectionName);
                }
            }

            if (page.Commands != null && page.Commands.Count > 0)
            {
                foreach (var command in page.Commands)
                {
                    var commandName = new LanguageKey
                    {
                        Key   = $"pages.{page.Name}.commands.{command.Name}.options.name",
                        Value = command.Name
                    };

                    languages.Add(commandName);
                    if (command.ButtonOptions.ActionCommandOptions.ConfirmationOptions != null &&
                        command.ButtonOptions.ActionCommandOptions.ConfirmationOptions.IsEnable)
                    {
                        var commandConfirmationName = new LanguageKey
                        {
                            Key   = $"pages.{page.Name}.commands.{command.Name}.options.confirmation",
                            Value = command.ButtonOptions.ActionCommandOptions.ConfirmationOptions.ConfirmationText
                        };

                        languages.Add(commandConfirmationName);
                    }

                    if (command.ButtonOptions.ActionCommandOptions.NotificationOptions != null)
                    {
                        var commandSuccessText = new LanguageKey
                        {
                            Key   = $"pages.{page.Name}.commands.{command.Name}.options.success",
                            Value = command.ButtonOptions.ActionCommandOptions.NotificationOptions.CompleteMessage
                        };

                        var commandFailedText = new LanguageKey
                        {
                            Key   = $"pages.{page.Name}.commands.{command.Name}.options.failed",
                            Value = command.ButtonOptions.ActionCommandOptions.NotificationOptions.FailedMessage
                        };
                        languages.Add(commandSuccessText);
                        languages.Add(commandFailedText);
                    }
                }
            }
            return(languages);
        }
Ejemplo n.º 20
0
 protected void BtnOk_Click(object sender, EventArgs e)
 {
     if (HdInsertUpdate == true)
     {
         //Kiểm tra xem mã từ khoá này có bị trùng không
         DataTable dt = new DataTable();
         dt = LanguageKey.GetLanguageKey("", LanguageKeyColumns.iLanguageKeyId, LanguageKeyTSql.GetBynLanguageKeyTitle(TbCode.Text), "");
         if (dt.Rows.Count > 0)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess",
                                                 "ThongBao(3000, 'Lỗi trùng từ khoá: " + TbCode.Text + "');", true);
             return;
         }
         else
         {
             LanguageKey.InsertLanguageKeyProc(TbCode.Text, tbDesc.Text);
             #region Logs
             string logAuthor     = CookieExtension.GetCookies("LoginSetting");
             string logCreateDate = DateTime.Now.ToString();
             Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", TbCode.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " tạo mới từ khóa " + TbCode.Text);
             #endregion
         }
     }
     else
     {
         //Kiểm tra xem mã từ khoá này có bị trùng không
         DataTable dt = new DataTable();
         dt = LanguageKey.GetLanguageKey("", LanguageKeyColumns.iLanguageKeyId, DataExtension.AndConditon(LanguageKeyTSql.GetBynLanguageKeyTitle(TbCode.Text), LanguageKeyColumns.iLanguageKeyId + "<>" + iLanguageKeyId), "");
         if (dt.Rows.Count > 0)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess",
                                                 "ThongBao(3000, 'Lỗi trùng từ khoá: " + TbCode.Text + "');", true);
             return;
         }
         else
         {
             LanguageKey.UpdateLanguageKey(iLanguageKeyId, TbCode.Text, tbDesc.Text);
             #region Logs
             string logAuthor     = CookieExtension.GetCookies("LoginSetting");
             string logCreateDate = DateTime.Now.ToString();
             Logs.InsertLogs(logCreateDate, Request.Url.ToString(), "", TbCode.Text, logAuthor, "", logCreateDate + ": " + logAuthor + " cập nhật từ khóa " + TbCode.Text);
             #endregion
         }
     }
     if (pnThemMaTuKhoa.Visible)
     {
         if (ckTiepTuc.Checked)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alertSuccess", "ThongBao(3000, 'Đã tạo: " + TbCode.Text + "');", true);
             TbCode.Text = "";
             tbDesc.Text = "";
         }
         else
         {
             Response.Redirect(LinkAdmin.GoAdminSubModul(CodeApplications.Language, "code"));
         }
     }
     else
     {
         Response.Redirect(LinkAdmin.GoAdminSubModul(CodeApplications.Language, "code"));
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 设置语言类型到Cookie中
 /// </summary>
 public void SetToCookie(string lanKey)
 {
     try
     {
         _LanKey = (LanguageKey)Enum.Parse(typeof(LanguageKey), lanKey);
     }
     catch
     {
         _LanKey = LanguageKey.None;
     }
     SetLanguageCookie(lanKey);
 }
Ejemplo n.º 22
0
 public RedirectToRouteResult SwitchLanguage(LanguageKey key)
 {
     this._languageStore.SetPreferredLanguage(key);
     return(RedirectToAction("Index", "Home"));
 }
Ejemplo n.º 23
0
 private void GetFromCookie()
 {
     if (HttpContext.Current != null)
     {
         HttpCookie myCookie = HttpContext.Current.Request.Cookies[AppConfig.XHtml.Domain + "_LanKey"];
         if (null != myCookie)
         {
             try
             {
                 _LanKey = (LanguageKey)Enum.Parse(typeof(LanguageKey), myCookie.Value);
             }
             catch
             {
                 _LanKey = LanguageKey.None;
             }
         }
     }
 }
Ejemplo n.º 24
0
 public RedirectToRouteResult SwitchLanguage(LanguageKey key)
 {
     this._languageStore.SetPreferredLanguage(key);
     return RedirectToAction("Index", "Home");
 }
Ejemplo n.º 25
0
 public string GetMessageFromKey(LanguageKey messageKey) => GetMessageFromKey(messageKey, null);
Ejemplo n.º 26
0
        public ActionResult Index(LoginUserVM loginUserVM)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle");

            ClearSelectionCriteriaFromViewData();

            #region [ Add data into language combo box ]
            if (TempData.Keys.Contains(StaticContent.LanguageKey))
            {
                LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]);

                initLanguageComboBox(temp.ToString());
            }
            else
            {
                initLanguageComboBox();
            }
            #endregion

            LUSerLoginResult entity_LUSerLoginResult = new LUSerLoginResult();
            //Define and Create channel factory in order to call the service
            entity_LUSerLoginResult = loginUserMgtHelper.Value.Login(loginUserVM, TempData[StaticContent.LanguageKey].ToString(), UserHostAddress, UserHostName);

            if (entity_LUSerLoginResult != null && entity_LUSerLoginResult.StrList_Error.Count == 0)
            {
                //Clear the cache.
                TempData[ActionMessageKey] = ViewBag.ActionMessage = null;

                //Save login user's authorized info to the cache.
                MVCSessionMgt.SaveServerSideSession(entity_LUSerLoginResult.Entity_SessionWUserInfo, StaticContent.SystemInfoInst.GetSessionTimeOutSeconds());

                //Save service authorized key and client side session key.
                ClientSessionInfo entity_ClientSessionInfo = new ClientSessionInfo();
                if (entity_LUSerLoginResult.Entity_SessionWUserInfo != null)
                {
                    entity_ClientSessionInfo.MVCSessionKey        = entity_LUSerLoginResult.Entity_SessionWUserInfo.SessionKey;
                    entity_ClientSessionInfo.ServiceAuthorizedKey = entity_LUSerLoginResult.Str_ServerToken;

                    Entity_ClientSessionInfo = entity_ClientSessionInfo;

                    TempData[Bootstrapper.UserClientSessionKey.ToString()]     =
                        ViewData[Bootstrapper.UserClientSessionKey.ToString()] = entity_ClientSessionInfo;
                }

                //Check the password is expire or not.
                if (entity_LUSerLoginResult.IsPWDExpire)
                {
                    return(Redirect("/AccessControl/Login/Reset"));
                }
                else
                {
                    return(Redirect("/Home/Index"));
                }
            }

            //Output error.
            MsgInfo errorMsgInfo = new MsgInfo();
            errorMsgInfo.MsgTitle = str_MsgBoxTitle;
            //Retrieve all error message.
            errorMsgInfo.MsgDesc       = string.Join("<br/>", entity_LUSerLoginResult.StrList_Error.ToArray());
            errorMsgInfo.MsgType       = MessageType.ValidationError;
            ViewBag.ActionMessage      = errorMsgInfo;
            TempData[ActionMessageKey] = errorMsgInfo;
            return(View(loginUserVM));
        }
Ejemplo n.º 27
0
 public string GetMessageFromKey(LanguageKey languageKey)
 {
     return(Session.GetMessageFromKey(languageKey));
 }
Ejemplo n.º 28
0
        public ActionResult Logout()
        {
            #region [ Add data into language combo box ]
            if (TempData.Keys.Contains(StaticContent.LanguageKey))
            {
                LanguageKey temp = (LanguageKey)(TempData[StaticContent.LanguageKey]);

                initLanguageComboBox(temp.ToString());
            }
            else
            {
                initLanguageComboBox();
            }
            #endregion

            string str_IpAddr   = this.HttpContext.Request.UserHostAddress;
            string str_HostName = this.HttpContext.Request.UserHostName;

            string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource("LoginScreentTitle");

            string strError = MultilingualHelper.GetStringFromResource("I003");

            string str_SaveAuthorizedHistory_Error = "";

            if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
            {
                ClientSessionInfo entity_ClientSessionInfo = null;
                if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                {
                    entity_ClientSessionInfo = (ClientSessionInfo)ViewData[Bootstrapper.UserClientSessionKey.ToString()];
                }

                if (entity_ClientSessionInfo != null)
                {
                    BaseSession entity_BaseSession = entity_SessionWUserInfo;

                    if (entity_BaseSession != null)
                    {
                        WebCommonHelper webCommonHelper = new WebCommonHelper();

                        webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
                        {
                            WCFReturnResult entity = loginUserMgtHelper.Value.Logout(entity_WCFAuthInfoVM);

                            if (!entity.IsSuccess)
                            {
                                str_SaveAuthorizedHistory_Error = string.Join("<br/>", entity.StrList_Error.ToArray());
                            }
                            else
                            {
                                MVCSessionMgt.RemoveServerSideSession(entity_BaseSession);
                            }
                        });
                    }

                    if (ViewData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                    {
                        ViewData.Remove(Bootstrapper.UserClientSessionKey.ToString());
                    }

                    if (TempData.ContainsKey(Bootstrapper.UserClientSessionKey.ToString()))
                    {
                        TempData.Remove(Bootstrapper.UserClientSessionKey.ToString());
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(str_SaveAuthorizedHistory_Error))
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc       = str_SaveAuthorizedHistory_Error;
                errorMsgInfo.MsgType       = MessageType.ValidationError;
                ViewBag.ActionMessage      = errorMsgInfo;
                TempData[ActionMessageKey] = errorMsgInfo;
            }
            else
            {
                MsgInfo errorMsgInfo = new MsgInfo();
                errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                errorMsgInfo.MsgDesc       = strError;
                errorMsgInfo.MsgType       = MessageType.Success;
                ViewBag.ActionMessage      = errorMsgInfo;
                TempData[ActionMessageKey] = errorMsgInfo;
            }
            return(View("Index"));
        }
 public ContextMenuDataModel(LanguageKey Key)
 {
     Text      = Setting_UI.reflection_eventtocore.SettingAndLanguage.GetTextLanguage(Key);
     this.Key  = Key;
     IsEnabled = true;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Read language
 /// </summary>
 /// <param name="Key"></param>
 /// <returns></returns>
 public string GetTextLanguage(LanguageKey Key)
 {
     return(EventGetTextLanguage(Key.ToString()));
 }
Ejemplo n.º 31
0
 /// <summary>
 /// 设置语言类型到Cookie中
 /// </summary>
 public void SetToCookie(LanguageKey lanKey)
 {
     SetToCookie(lanKey.ToString());
 }
Ejemplo n.º 32
0
        private static void Main(string[] args)
        {
            // string outputFile;
            // if (args.Length < 1)
            {
                Console.WriteLine("Usage: GenerateFontRanges.exe [languageCode]");
                Console.WriteLine("Generates font ranges used by the given language code.");
                Console.WriteLine("If languageCode is omitted all languages will be taken into consideration");

                //     return;
                //  }
                List <string> languageCodes = new List <string>();

                if (args.Length != 0)
                {
                    string inputLC = args[0];
                    if (!LanguageManager.AvailableLanguages.ContainsValue(inputLC))
                    {
                        Console.WriteLine("Error: language code: " + inputLC + " is not supported by the game. Example language code for Portuguese (Brasilian): pt-BR");
                        return;
                    }
                    languageCodes.Add(inputLC);
                }
                else
                {
                    languageCodes.AddRange(LanguageManager.AvailableLanguages.Values);
                }
                File.Delete(outputFile);
                StreamWriter writer          = null;
                string       oldLanguageCode = null;

                try{
                    writer          = File.AppendText(outputFile);
                    oldLanguageCode = LanguageManager.ActualLanguageCode;

                    foreach (String languageCode in languageCodes)
                    {
                        List <String> missingKeys = new List <string>();
                        LanguageManager.SetLanguage(languageCode);

                        Console.WriteLine("Generating font ranges for language: " + languageCode);

                        String[]      keys       = LanguageKey.GetAllLanguageKyes();
                        StringBuilder fullString = new StringBuilder();
                        foreach (string key in keys)
                        {
                            if (String.Empty.Equals(LanguageResources.GetString(key)))
                            {
                                missingKeys.Add(key);
                                // error
                            }
                            else
                            {
                                fullString.Append(LanguageResources.GetString(key));
                            }
                        }

                        // all possible chars
                        char[] allchars = LanguageResources.BuildCharmap(fullString.ToString());


                        // get all ranges
                        string rangeString = "";
                        int    lastValue = -1;
                        int    rangeFrom = -1, rangeTo = -1;
                        bool   firstRange  = true;
                        var    allcharsint = new List <int>();

                        int i = 0;
                        foreach (char c in allchars)
                        {
                            allcharsint.Add(Convert.ToInt32(c));
                        }

                        if (addStandardRange)
                        {
                            for (int k = 33; k <= 126; k++)
                            {
                                if (!allcharsint.Contains(k))
                                {
                                    allcharsint.Add(k);
                                }
                            }
                        }
                        allcharsint.Sort();

                        bool lastRange = false;
                        foreach (int value in allcharsint)
                        {
                            lastRange = (value == allcharsint[allcharsint.Count - 1]);
                            if (firstRange)
                            {
                                rangeFrom  = rangeTo = lastValue = value;
                                firstRange = false;
                                continue;
                            }

                            if (lastValue + 1 == value)
                            {
                                // kontynuacja
                                rangeTo = value;
                            }
                            else
                            {
                                // koniec range
                                rangeString += rangeFrom + "-" + rangeTo + " ";
                                rangeFrom    = rangeTo = value;
                            }
                            if (lastRange)
                            {
                                rangeString += rangeFrom + "-" + rangeTo + " ";
                            }
                            lastValue = value;
                        }


                        Console.WriteLine("Produced char range for language " + languageCode + ". Unique key codes:" + allcharsint.Count + ", missing keys: " + missingKeys.Count + ((missingKeys.Count > 0)? " - " + String.Join("; ", missingKeys.ToArray()) : ""));
                        writer.Write("\t/* " + languageCode + " - Unique key codes:" + allcharsint.Count + ", missing key codes: " + missingKeys.Count + ", generated at " + DateTime.Now.ToUniversalTime().ToString("u") + " */ " + Environment.NewLine + "\tcode_points " + rangeString + Environment.NewLine + Environment.NewLine);
                    }
                    Console.WriteLine("The output file is: " + outputFile);
                }
                finally
                {
                    if (oldLanguageCode != null)
                    {
                        LanguageManager.SetLanguage(oldLanguageCode);
                    }
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }



                /* if (!File.Exists(filename))
                 * {
                 *   MessageBox.Show("File '" + filename + "' does not exist");
                 *   return;
                 * }*/
                //   languageCode
            }
        }