//public static string GetLangJS(string KendoUrl)
        //{
        //    return "<script src=\"" + VirtualPathUtility.ToAbsolute(KendoUrl + "/cultures/kendo.culture." + SF.GetLangCodeThreading() + ".min.js") + "\"></script><script> kendo.culture(\"" + SF.GetLangCodeThreading() + "\");</script>";
        //}

        public static bool AdminIsRTL()
        {
            string        LangCode = SF.GetLangCodeThreading();
            List <string> rltList  = new List <string>()
            {
                "he-IL"
            };

            if (rltList.Contains(LangCode))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private int Tokenize(string SystemName, string ToEmail, IList <object> models)
        {
            if (_isGetTokensOnly)
            {
                tokens = new List <string>();
                foreach (var o in models)
                {
                    if (o == null)
                    {
                        continue;
                    }

                    var t          = o.GetType();
                    var properties = t.GetProperties();
                    foreach (var p in properties)
                    {
                        tokens.Add(string.Format("%{0}.{1}%", t.Name, p.Name)); // %Order.Total% -> $345.34
                    }
                }
                return(0);
            }
            var LanguageCode = SF.GetLangCodeThreading();
            var mailTemplate = _Context.EntityContext.MessageTemplates.FirstOrDefault(x => x.SystemName == SystemName && x.LanguageCode == LanguageCode);

            if (mailTemplate != null && mailTemplate.Active && !string.IsNullOrEmpty(ToEmail))
            {
                StringBuilder Subject = new StringBuilder(mailTemplate.Subject);
                StringBuilder Body    = new StringBuilder(mailTemplate.Body);

                string log = "";
                if (mailTemplate.SystemName == "Order.UserCantPay.EmailToAdmin")
                {
                    log += @"LOG mail template data
";
                }
                foreach (var o in models)
                {
                    if (o == null)
                    {
                        continue;
                    }

                    var t          = o.GetType();
                    var properties = t.GetProperties();
                    foreach (var p in properties)
                    {
                        string repl  = "";
                        var    value = p.GetValue(o);
                        if (value != null)
                        {
                            repl = value.ToString();
                        }
                        if (mailTemplate.SystemName == "Order.UserCantPay.EmailToAdmin")
                        {
                            log += string.Format("{0}.{1}", t.Name, p.Name) + @" = " + repl + @"
";
                        }
                        Subject.Replace(string.Format("%{0}.{1}%", t.Name, p.Name), repl); // %Order.Total% -> $345.34
                        Body.Replace(string.Format("%{0}.{1}%", t.Name, p.Name), repl);    // %Order.Total% -> $345.34
                    }
                }
                if (mailTemplate.SystemName == "Order.UserCantPay.EmailToAdmin")
                {
                    log += @"
template Body:
" + mailTemplate.Body;
                    log += @"
template Subject:
" + mailTemplate.Subject;

                    log += @"
result Body:
" + Body.ToString();
                    log += @"
result Subject:
" + Subject.ToString();

                    var acitvitylog = new ActivityLog()
                    {
                        CreateOn     = DateTime.Now,
                        FullText     = log,
                        UserID       = Guid.Empty,
                        ActivityType = ActivityType.Other
                    };
                    _Context.EntityContext.ActivityLogs.Add(acitvitylog);
                    _Context.EntityContext.SaveChanges();
                }
                var email = new OutEmail()
                {
                    Body    = Body.ToString(),
                    Subject = Subject.ToString(),
                    MailTo  = ToEmail,
                };

                _Context.EntityContext.OutEmails.Add(email);
                _Context.EntityContext.SaveChanges();
                return(email.ID);
            }
            if (mailTemplate == null)
            {
                //add to log or create automatic
                var template = new MessageTemplate()
                {
                    Active       = false,
                    Body         = "Auto generated, please change",
                    LanguageCode = SF.GetLangCodeThreading(),
                    Subject      = "Auto generated",
                    SystemName   = SystemName
                };
                _Context.EntityContext.MessageTemplates.Add(template);
                _Context.EntityContext.SaveChanges();
            }
            return(0);
        }