public ActionResult Create(string name)
        {
            ResourceLocalization model = new ResourceLocalization();

            model.Name = name;
            var Entity    = GeneratorBase.MVC.ModelReflector.Entities.Where(p => !p.IsAdminEntity && !p.IsDefault).FirstOrDefault(p => p.Name == name);
            var filepath  = System.Web.HttpContext.Current.Server.MapPath("~/ResourceFiles/");
            var fileexist = System.IO.File.Exists(filepath + name + ".resx");

            if (fileexist)
            {
                using (System.Resources.ResourceSet resxSet = new System.Resources.ResourceSet(filepath + name + ".resx"))
                {
                    ColumnMapping entobj = new ColumnMapping();
                    entobj.source = name;
                    entobj.target = resxSet.GetString(name);
                    model.columnmapping.Add(entobj);

                    foreach (var item in Entity.Properties.OrderBy(p => p.DisplayName))
                    {
                        if (item.Name == "DisplayValue")
                        {
                            continue;
                        }
                        var           result = resxSet.GetString(item.Name);
                        ColumnMapping obj    = new ColumnMapping();
                        obj.source = item.Name;
                        obj.target = result;
                        model.columnmapping.Add(obj);
                    }
                }
            }
            else
            {
                ColumnMapping entobj = new ColumnMapping();
                entobj.source = name;
                entobj.target = Entity.DisplayName;
                model.columnmapping.Add(entobj);
                foreach (var item in Entity.Properties.OrderBy(p => p.DisplayName))
                {
                    if (item.Name == "DisplayValue")
                    {
                        continue;
                    }
                    ColumnMapping obj = new ColumnMapping();
                    obj.source = item.Name;
                    obj.target = item.DisplayName;
                    model.columnmapping.Add(obj);
                }
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get message from resource
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="screen"></param>
        /// <param name="module"></param>
        /// <param name="code"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static MessageModel GetMessageForScreen(string controller, string screen, string module, string code, params string[] param)
        {
            MessageModel msg = new MessageModel();

            msg.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
            msg.Code        = code;

            try
            {
                string assembly = string.Format("{0}.{1}.dll", CommonValue.MESSAGE_ASSEMBLY, module);

                CommonUtil util = new CommonUtil();
                System.Resources.ResourceSet rs = util.GetResource(assembly, CommonValue.MESSAGE_NAMESPACE);

                MessageUtil m      = new MessageUtil();
                string[]    nparam = m.ConvertParameters(controller, screen, param);
                msg.Message = string.Format(rs.GetString(code), nparam);
            }
            catch
            {
                msg.Message = CommonValue.MESSAGE_NOTFOUND;
            }

            return(msg);
        }
Ejemplo n.º 3
0
        static string Lookup(string key, string resourcename, string defaultvalue)
        {
            var result = defaultvalue;

            try
            {
                var filepath  = System.Web.HttpContext.Current.Server.MapPath("~/ResourceFiles/");
                var fileexist = System.IO.File.Exists(filepath + resourcename);
                if (fileexist)
                {
                    using (System.Resources.ResourceSet resxSet = new System.Resources.ResourceSet(filepath + resourcename))
                    {
                        result = resxSet.GetString(key);
                        if (string.IsNullOrEmpty(result))
                        {
                            result = defaultvalue;
                        }
                    }
                }
            }
            catch
            {
                return(defaultvalue); // fallback
            }
            return(result);
        }
Ejemplo n.º 4
0
 private void RadioButton_Click(object sender, EventArgs e)
 {
     try {
         txtMusicString.Text = _resourceSet.GetString((string)((RadioButton)sender).Tag);
         PBScore.Tune        = QabcIronyParser.Instance.Parse(txtMusicString.Text);
         //         this.gridCompileErrors = QabcIronyParser.First.Errors;
         InvokeBouncingBall(0, 1);
         StartHighlighter(_qabcParser);
     } finally {; }
 }
Ejemplo n.º 5
0
 public static string GetResource(Type t, string name, string lang)
 {
     if (string.IsNullOrEmpty(name))
     {
         return(string.Empty);
     }
     System.Resources.ResourceManager rm = new System.Resources.ResourceManager(t);
     System.Resources.ResourceSet     rs = rm.GetResourceSet(new System.Globalization.CultureInfo(lang), true, true);
     return(rs.GetString(name));
 }
Ejemplo n.º 6
0
        private static string GetResourceString(string name, Assembly assembly)
        {
            var names = assembly.GetManifestResourceNames();

            for (int i = 0; i < names.Length; i++)
            {
                using var stream   = assembly.GetManifestResourceStream(names[i]);
                using var resource = new System.Resources.ResourceSet(stream);

                var value = resource.GetString(name);

                if (value != null)
                {
                    return(value);
                }
            }

            return(name);
        }
Ejemplo n.º 7
0
        protected void Page_Load(System.Object sender, System.EventArgs args)
        {
            // Prevent caching, so can't be viewed offline
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            if (!this.IsPostBack)
            {
                //Localized resources for this session
                System.Resources.ResourceSet rs = (System.Resources.ResourceSet)Session["resources"];
                // Set labels localized texts
                loginWindowTitle.Text     = rs.GetString("loginWindowTitle") + ": " + Application["sharpwebmail/login/title"].ToString();
                loginWindowHeadTitle.Text = Application["sharpwebmail/general/title"].ToString();
                loginWindowUsername.Text  = rs.GetString("loginWindowUsername");
                loginWindowPassword.Text  = rs.GetString("loginWindowPassword");
                loginButton.Text          = rs.GetString("loginButton");
                errorMsgLogin.Text        = rs.GetString("errorMsgLogin");
                switch ((int)Application["sharpwebmail/login/mode"])
                {
                case 2:
                    loginWindowUsername.Text = rs.GetString("loginWindowUsername2");
                    this.usernameValidator.ValidationExpression = ".+";
                    break;

                case 3:
                    this.usernameValidator.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.local_part + "(@" + anmar.SharpMimeTools.ABNF.domain + "$){0,1}";
                    break;

                case 1:
                default:
                    this.usernameValidator.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.addr_spec + "$";
                    break;
                }
                rs = null;
                if ((bool)Application["sharpwebmail/login/enablequerystringlogin"])
                {
                    System.String username = Request.QueryString["username"];
                    System.String password = Request.QueryString["password"];
                    if (username != null)
                    {
                        this.username.Value = username;
                        if (password != null)
                        {
                            this.password.Value = password;
                            this.Validate();
                            this.Login_Click(sender, args);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public string GetConclusion(int row, int col, System.Globalization.CultureInfo culture, bool bStrict)
        {
            System.Resources.ResourceManager rm = GetResourceManager();
            if (null != rm)
            {
                string stringId = GetStringId(row, col);
                string result   = null;

                if (bStrict)
                {
                    System.Resources.ResourceSet rs = rm.GetResourceSet(culture, true, false);
                    if (null != rs)
                    {
                        result = rs.GetString(stringId);
                    }
                    else
                    {
                        _log.Debug($"ResourceSet could not be acquired for culture '{culture}' (strict).");
                    }
                }
                else
                {
                    result = rm.GetString(stringId, culture);
                }

                if ((null == result) || (0 == result.Length))
                {
                    _log.Debug($"No string with id='{stringId}' found for culture '{culture}'. ResourceManager: {rm.BaseName}");
                    return(string.Empty);
                }

                return(result);
            }
            else
            {
                _log.Debug("Resource manager not acquired.");
            }
            return(string.Empty);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Get message from resource
        /// </summary>
        /// <param name="module"></param>
        /// <param name="code"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static MessageModel GetMessage(string module, string code, params string[] param)
        {
            MessageModel msg = new MessageModel();

            msg.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
            msg.Code        = code;

            try
            {
                string assembly = string.Format("{0}.{1}.dll", CommonValue.MESSAGE_ASSEMBLY, module);

                CommonUtil util = new CommonUtil();
                System.Resources.ResourceSet rs = util.GetResource(assembly, CommonValue.MESSAGE_NAMESPACE);

                msg.Message = string.Format(rs.GetString(code), param == null ? new string[] { "" } : param);
            }
            catch
            {
                msg.Message = CommonValue.MESSAGE_NOTFOUND;
            }

            return(msg);
        }
Ejemplo n.º 10
0
 protected void Page_PreRender(System.Object sender, System.EventArgs args)
 {
     System.Collections.Specialized.ListDictionary addressbook = GetAddressbook(addressbookselect.Value, Application["sharpwebmail/send/addressbook"]);
     if (addressbook != null && !addressbook["type"].Equals("none"))
     {
         this.AddressBookDataGrid.PageSize = (int)addressbook["pagesize"];
         System.Data.DataTable data = GetDataSource(addressbook, false, Session["client"] as anmar.SharpWebMail.IEmailClient);
         if (data != null)
         {
             if (this._sort_expression != null && this._sort_expression.Length > 0)
             {
                 if (this._sort_expression.IndexOf("[NameColumn]") != -1)
                 {
                     this._sort_expression = this._sort_expression.Replace("[NameColumn]", addressbook["NameColumn"].ToString());
                 }
                 else if (this._sort_expression.IndexOf("[EmailColumn]") != -1)
                 {
                     this._sort_expression = this._sort_expression.Replace("[EmailColumn]", addressbook["EmailColumn"].ToString());
                 }
                 else
                 {
                     this._sort_expression = null;
                 }
                 if (this._sort_expression != null)
                 {
                     data.DefaultView.Sort = this._sort_expression;
                 }
             }
             this.AddressBookDataGrid.DataSource = data.DefaultView;
         }
         // Full Page Mode
         if (this.SharpUI != null)
         {
             bool allowupdate = (bool)addressbook["allowupdate"];
             // Editable columns?
             if (this.AddressBookDataGrid.Columns.Count > 1)
             {
                 this.AddressBookDataGrid.Columns[this.AddressBookDataGrid.Columns.Count - 1].Visible = allowupdate;
                 this.AddressBookDataGrid.Columns[this.AddressBookDataGrid.Columns.Count - 2].Visible = allowupdate;
             }
             // Editable links?
             System.Web.UI.HtmlControls.HtmlAnchor link = (System.Web.UI.HtmlControls.HtmlAnchor) this.SharpUI.FindControl("addressbookEntryInsert");
             if (link != null)
             {
                 link.HRef    = System.String.Concat("addressbook_edit.aspx?book=", System.Web.HttpUtility.UrlEncode(this.addressbookselect.Value));
                 link.Visible = allowupdate;
             }
             // Editable links?
             link = (System.Web.UI.HtmlControls.HtmlAnchor) this.SharpUI.FindControl("addressbookImportExport");
             if (link != null)
             {
                 link.HRef    = System.String.Concat("addressbook_data.aspx?book=", System.Web.HttpUtility.UrlEncode(this.addressbookselect.Value));
                 link.Visible = allowupdate;
             }
         }
     }
     System.Resources.ResourceSet resources = (System.Resources.ResourceSet)Session["resources"];;
     // Pop-up mode
     if (this.SharpUI == null)
     {
         this.AddressBookDataGrid.Columns[0].HeaderText = resources.GetString("addressbookNameLabel");
     }
     this.AddressBookDataGrid.Columns[0].HeaderStyle.Wrap = false;
     this.AddressBookDataGrid.DataBind();
 }
Ejemplo n.º 11
0
        public static string GetString(this string text)
        {
            var t = resourceSet.GetString(text);

            return(string.IsNullOrEmpty(t) ? null : t.Replace("\\n", Environment.NewLine));
        }
Ejemplo n.º 12
0
        public static DateTime ConvertDate(string xDateString, DateFormat xDateFormat, bool isMutiLang)
        {
            if (string.IsNullOrEmpty(xDateString))
            {
                return(DateTime.MinValue);
            }
            switch (xDateFormat)
            {
            case DateFormat.ddMMyyyys:
                string[] dateInfo = xDateString.Split('/');
                string   dd       = string.Empty;
                string   MM       = string.Empty;
                string   yyyy     = string.Empty;
                if (dateInfo.Length == 3)
                {
                    dd = dateInfo[0].Trim();
                    if (dd.Length != 2)
                    {
                        if (dd.Length > 2)
                        {
                            dd = dd.Substring(0, 2);
                        }
                        else if (dd.Length == 1 && dd != "0")
                        {
                            dd = "0" + dd;
                        }
                        else
                        {
                            dd = "01";
                        }
                    }
                    else if (dd == "00")
                    {
                        dd = "01";
                    }
                    MM = dateInfo[1].Trim();
                    if (MM.Length != 2)
                    {
                        if (MM.Length > 2)
                        {
                            MM = MM.Substring(0, 2);
                        }
                        else if (MM.Length == 1)
                        {
                            MM = "0" + MM;
                        }
                        else
                        {
                            MM = "01";
                        }
                    }
                    else if (MM == "00")
                    {
                        MM = "01";
                    }
                    yyyy = dateInfo[2].Trim();
                    if (yyyy.Length == 2)
                    {
                        yyyy += "20";
                    }
                    else if (yyyy.Length != 4)
                    {
                        if (yyyy.Length > 4)
                        {
                            yyyy = yyyy.Substring(0, 4);
                        }
                        else
                        {
                            yyyy = DateTime.Now.ToString("yyyy");
                        }
                    }
                    else if (yyyy == "0000")
                    {
                        yyyy = DateTime.Now.ToString("yyyy");
                    }
                }
                else
                {
                    return(DateTime.MinValue);
                }
                xDateString = string.Format("{0}/{1}/{2}", dd, MM, yyyy);
                break;

            case DateFormat.ddMMyyyyn:
                break;

            case DateFormat.ddMMyyyysp:
                break;

            case DateFormat.ddMMyyyyd:
                break;

            case DateFormat.ddMMMyyyys:
                break;

            case DateFormat.ddMMMyyyyn:
                break;

            case DateFormat.ddMMMyyyysp:
                break;

            case DateFormat.ddMMMyyyyd:
                break;

            case DateFormat.MMMddyyyyspcm:
                break;

            case DateFormat.ddMMMyyyyspwt:
                break;

            case DateFormat.ddMMMyyyyHHmm:
                break;

            case DateFormat.yyyyMMMdd:
                break;

            case DateFormat.yyyyMMdd:
                break;

            case DateFormat.yyMMddHHmm:
                break;

            case DateFormat.MMMdd:
                break;

            case DateFormat.ddMMMyyyyddd:
                break;

            case DateFormat.ddMMMyyyyml:
                break;

            default:
                break;
            }
            MutiLanguage.Languages lang = MutiLanguage.GetCultureType();
            lang = isMutiLang ? lang : MutiLanguage.Languages.en_us;
            string langstr = isMutiLang ? MutiLanguage.EnumToString(lang) : MutiLanguage.EnumToString(MutiLanguage.Languages.en_us);

            System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Date));
            System.Resources.ResourceSet     rs = rm.GetResourceSet(new System.Globalization.CultureInfo(langstr), true, true);
            return(DateTime.ParseExact(xDateString, rs.GetString(xDateFormat.ToString()), System.Globalization.DateTimeFormatInfo.InvariantInfo));
        }