Пример #1
0
        public static MvcHtmlString PasswordGroupFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var htmlAttributes = HtmlHelperExtension.MergeAttributes(inputHtmlAttributes,
                                                                     new { type = "password" });

            return(helper.InputGroupFor(expression, wrapperHtmlAttributes, htmlAttributes));
        }
Пример #2
0
        public static MvcHtmlString DateTimeGroupFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var htmlAttributes = HtmlHelperExtension.MergeAttributes(inputHtmlAttributes,
                                                                     new { @class = "datepicker", type = "text" });

            return(helper.InputGroupFor(expression, wrapperHtmlAttributes, htmlAttributes));
        }
Пример #3
0
        public static MvcHtmlString FileGroupFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var htmlAttributes = HtmlHelperExtension.MergeAttributes(inputHtmlAttributes,
                                                                     new { type   = "file",
                                                                           accept = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel",
                                                                           id     = "file", name = "file" });

            return(helper.InputGroupFor(expression, wrapperHtmlAttributes, htmlAttributes));
        }
        public DropDownItemControl(HtmlHelper htmlHelper, string actionName, string controllerName, string areaName)
        {
            _htmlHelper     = htmlHelper;
            _actionName     = actionName;
            _controllerName = controllerName;
            _areaName       = areaName;

            // Basic Style
            HtmlAttributes = HtmlHelperExtension.AddCssClass(HtmlAttributes, CssHelper <ButtonControl> .ControlTypeAbbr);
        }
Пример #5
0
        public void EnvironmentNone()
        {
            mockConfigurationManager.Setup(m => m.AppSettings.Get("Environment")).Returns("");


            HtmlHelper html   = null;
            var        result = HtmlHelperExtension.Environment(html).ToString();

            Assert.IsTrue(string.IsNullOrEmpty(result));
        }
Пример #6
0
        public ButtonControlAjax(AjaxHelper ajaxHelper, string actionName, string controllerName, string areaName)
        {
            _ajaxHelper     = ajaxHelper;
            _actionName     = actionName;
            _controllerName = controllerName;
            _areaName       = areaName;

            // Basic Style
            HtmlAttributes = HtmlHelperExtension.AddCssClass(HtmlAttributes, CssHelper <ButtonControlAjax> .ControlTypeAbbr);
        }
        /// <summary>
        ///     Get simple Html string of a single class object with only new lines
        /// </summary>
        /// <param name="Class">Any entity object , can be null.</param>
        /// <param name="additionalStylesWithTable"></param>
        /// <param name="additionalStylesWithRow"></param>
        /// <param name="additionalStylesWithCell"></param>
        /// <returns>
        ///     Returns property and value string combination, returns empty string if class is null or doesn't have any valid
        ///     properties to display.
        /// </returns>
        public static string AsHtmlTable(object Class,
                                         string additionalStylesWithTable = "",
                                         string additionalStylesWithRow   = "",
                                         string additionalStylesWithCell  = "")
        {
            if (Class != null)
            {
                var properties =
                    Class.GetType()
                    .GetProperties(TypeOfPropertise)
                    .Where(p => p.Name != "EntityKey" && p.Name != "EntityState")
                    .ToList();
                var sb      = new StringBuilder(properties.Count * 3 + 20);
                var styles  = CssStyle.GetCommonStyles("#74DA74", "black", null, "8px 20px 16px", "4px");
                var styles2 = CssStyle.GetCommonStyles(null, null, null, null, null, "bolder");
                sb.Append("<table ");
                sb.Append("style='" + styles + additionalStylesWithTable + "'>");
                sb.Append("<thead>");
                //sb.Append(HtmlHelperExtension.GetTag("caption", "Entity Title : " + anyObject.ToString()));
                sb.Append("<tr ");
                sb.Append("style='" + styles2 + additionalStylesWithRow + "'>");
                sb.Append(HtmlHelperExtension.GetTag("td", "", additionalStylesWithCell));
                sb.Append(HtmlHelperExtension.GetTag("td", "", additionalStylesWithCell));
                sb.Append(HtmlHelperExtension.GetTag("td", "", additionalStylesWithCell));
                //sb.Append(HtmlHelperExtension.GetTag("td", "Properties"));
                //sb.Append(HtmlHelperExtension.GetTag("td", ""));
                //sb.Append(HtmlHelperExtension.GetTag("td", "Values"));
                sb.Append("</tr>");
                sb.Append("</thead>");
                sb.Append("<tbody>");

                foreach (var prop in properties)
                {
                    var val = prop.GetValue(Class, null);
                    sb.Append("<tr ");
                    sb.Append("style='" + additionalStylesWithRow + "'>");
                    if (TypeChecker.IsPrimitiveOrGuid(val))
                    {
                        sb.Append(HtmlHelperExtension.GetTag("td", prop.Name, additionalStylesWithCell));
                        sb.Append(":");
                        sb.Append(HtmlHelperExtension.GetTag("td", val.ToString(), additionalStylesWithCell));
                    }
                    sb.Append("</tr>");
                }
                sb.Append("</tbody>");
                sb.Append("</table>");
                var output = sb.ToString();
                sb = null;
                GC.Collect();
                return(output);
            }
            return("");
        }
Пример #8
0
        public void EnvironmentWks()
        {
            mockConfigurationManager.Setup(m => m.AppSettings.Get("Environment")).Returns("WKS");


            HtmlHelper html   = null;
            var        result = HtmlHelperExtension.Environment(html).ToString();

            Assert.IsFalse(string.IsNullOrEmpty(result));
            Assert.IsTrue(result.Contains("enviroWks"));
            Assert.IsTrue(result.Contains("Local workstation"));
        }
Пример #9
0
        public void EnvironmentDevFix()
        {
            mockConfigurationManager.Setup(m => m.AppSettings.Get("Environment")).Returns("DEVFIX");


            HtmlHelper html   = null;
            var        result = HtmlHelperExtension.Environment(html).ToString();

            Assert.IsFalse(string.IsNullOrEmpty(result));
            Assert.IsTrue(result.Contains("enviroDevFix"));
            Assert.IsTrue(result.Contains("Development fix environment"));
        }
Пример #10
0
        public void EnvironmentPreProd()
        {
            mockConfigurationManager.Setup(m => m.AppSettings.Get("Environment")).Returns("PREPROD");


            HtmlHelper html   = null;
            var        result = HtmlHelperExtension.Environment(html).ToString();

            Assert.IsFalse(string.IsNullOrEmpty(result));
            Assert.IsTrue(result.Contains("enviroPreProd"));
            Assert.IsTrue(result.Contains("Pre-Production environment"));
        }
Пример #11
0
 /// <summary>
 /// app start
 /// </summary>
 protected void Application_Start()
 {
     // area kayıt
     AreaRegistration.RegisterAllAreas();
     // route kayıt
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     // bundle create
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     // herkesi offline yap bir seferlik
     HtmlHelperExtension.PutUsersOffline();
     // remove the MVC header
     MvcHandler.DisableMvcResponseHeader = true;
 }
Пример #12
0
        private static MvcHtmlString GenerateDropDownListGroupFor <TModel, TValue>(HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, IEnumerable <SelectListItem> selectList, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var htmlAttributes = HtmlHelperExtension.AddCssClass(inputHtmlAttributes, "form-control");

            var label         = helper.LabelFor(expression, htmlAttributes: new { @class = "control-label" });
            var input         = helper.DropDownListFor(expression, selectList, "", htmlAttributes);
            var validationMsg = helper.ValidationMessageFor(expression, "", new { @class = "text-danger" });

            var div2 = new DivControl(input + validationMsg.ToHtmlString());
            var div1 = new DivControl(label + div2.ToHtmlString()).AddCssClass("form-group").MergeAttributes(wrapperHtmlAttributes);

            return(MvcHtmlString.Create(div1.ToHtmlString()));
        }
Пример #13
0
        private static MvcHtmlString InputGroupFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var htmlAttributes = HtmlHelperExtension.AddCssClass(inputHtmlAttributes, "form-control");

            var label         = helper.LabelFor(expression, htmlAttributes: new { @class = "control-label" });
            var input         = helper.EditorFor(expression, new { htmlAttributes = htmlAttributes });
            var validationMsg = helper.ValidationMessageFor(expression, "", new { @class = "text-danger" });

            var div2 = new DivControl(input + validationMsg.ToHtmlString());
            var div1 = new DivControl(label + div2.ToHtmlString()).AddCssClass("form-group").MergeAttributes(wrapperHtmlAttributes);

            return(MvcHtmlString.Create(div1.ToHtmlString()));
        }
        protected override string Render()
        {
            // CSS: SetColor & SetSize
            this.AddCssClass(CssHelper <ButtonControl> .ControlTypeAbbr);
            this.AddCssClass(CssHelper <ButtonControl> .ConvertToCss(BackgroundColor));
            this.AddCssClass(CssHelper <ButtonControl> .ConvertToCss(Size));
            this.AddCssClass(ConstantHelper.CssDropDownList);

            // Route values
            RouteValues = HtmlHelperExtension.AddRouteValue(RouteValues, new { area = _areaName });

            String actionLinkStr = _htmlHelper.ActionLink(Text, _actionName, _controllerName, RouteValues, HtmlAttributes).ToString();

            return(actionLinkStr);
        }
Пример #15
0
        public static MvcHtmlString CheckBoxGroupFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, bool> > expression, object wrapperHtmlAttributes = null, object inputHtmlAttributes = null)
        {
            var    expression1 = (MemberExpression)expression.Body;
            string name        = expression1.Member.Name;

            var htmlAttributes = HtmlHelperExtension.AddCssClass(inputHtmlAttributes, "form-control");

            var label    = helper.LabelFor(expression);
            var checkBox = new CheckBoxControl().SetId(name).SetColor(ColorOptions.Primary).SetAttributes(htmlAttributes);

            var div2 = new DivControl(checkBox.ToHtmlString()).AddCssClass(" ctm-checkbox");
            var div1 = new DivControl(label + div2.ToHtmlString()).AddCssClass("form-group").MergeAttributes(wrapperHtmlAttributes);

            return(MvcHtmlString.Create(div1.ToHtmlString()));
        }
Пример #16
0
        private MvcForm GenerateForm(AjaxHelper helper, string actionName, string areaName, object routeValues, object htmlAttributes, string formBody)
        {
            var form = helper.BeginForm(
                actionName,
                ControllerName,
                HtmlHelperExtension.AddRouteValue(routeValues, new { area = areaName }),
                new AjaxOptions
            {
                HttpMethod = "POST"
            },
                HtmlHelperExtension.ConvertHtmlAttributesToIDictionary(htmlAttributes));

            var htmlHelper = new HtmlHelper(helper.ViewContext, helper.ViewDataContainer);

            string token = htmlHelper.AntiForgeryToken().ToHtmlString();

            helper.ViewContext.Writer.Write(token + formBody);
            return(form);
        }
Пример #17
0
        protected override string Render()
        {
            // Data
            var ajaxOptions = new AjaxOptions
            {
                HttpMethod       = (IsPost ? "POST" : "GET"),
                InsertionMode    = InsertionMode.Replace,
                UpdateTargetId   = UpdateTargetId,
                LoadingElementId = LoadingElementId,
                OnSuccess        = "new function(){" + OnSuccessFun?.Replace("\"", "\'") + "}"
            };

            RouteValues = HtmlHelperExtension.AddRouteValue(RouteValues, new { area = _areaName });

            // Style
            HtmlAttributes = HtmlHelperExtension.AddCssClass(HtmlAttributes, CssHelper <ButtonControlAjax> .ConvertToCss(BackgroundColor));
            HtmlAttributes = HtmlHelperExtension.AddCssClass(HtmlAttributes, CssHelper <ButtonControlAjax> .ConvertToCss(Size));

            // Id
            if (Id != null)
            {
                HtmlAttributes.Add("id", Id);
            }

            string innerHtmlOrText = string.Empty;

            if (!string.IsNullOrEmpty(MaterialIcon))
            {
                innerHtmlOrText = string.Format(base.RenderMaterialIcon(MaterialIcon));
            }
            else
            {
                innerHtmlOrText = Text ?? string.Empty;
            }

            // Reference:http://stackoverflow.com/questions/12008899/create-ajax-actionlink-with-html-elements-in-the-link-text
            var replacedText = Guid.NewGuid().ToString();
            var actionLink   = _ajaxHelper.ActionLink(replacedText, _actionName, _controllerName, RouteValues,
                                                      ajaxOptions, HtmlAttributes);

            return(actionLink.ToString().Replace(replacedText, innerHtmlOrText));
        }
Пример #18
0
        /// <summary>
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <param name="method"></param>
        /// <param name="entitySingleObject"></param>
        public void GenerateErrorBody(Exception ex, ref string subject, ref string body, string method = "",
                                      object entitySingleObject = null)
        {
            var isUserExist = HttpContext.Current != null && HttpContext.Current.User.Identity.IsAuthenticated;

            var sb = new StringBuilder(30);

            if (body == null)
            {
                body = "";
            }

            sb.Append(GetErrorMsgHtml(ex, method));

            if (string.IsNullOrEmpty(subject))
            {
                subject = string.Format("[{0}] [Error] on [{1}] method at {2}", Config.ApplicationName, method,
                                        DateTime.UtcNow);
            }
            if (isUserExist)
            {
                sb.Append("<hr />");
                var loggedUserStyle = CssStyle.GetCommonStyles("Green", "White", "0 0 5px 0", "8px", "3px", "bolder");
                sb.Append(HtmlHelperExtension.GetTag("div", "Logged in user : "******"<hr/>");
                sb.Append(HtmlHelperExtension.GetTag("h3", "Entity Title : " + entitySingleObject));
                try {
                    var entityString = EntityToString.GetHtmlOfSingleClassAsTable(entitySingleObject);
                    sb.Append(entityString);
                } catch (Exception ex2) {
                    sb.Append("<div style='color:red'> Error Can't Read Entity: " + ex2.Message + "</div>");
                }
            }
            sb.Append("<hr />");
            sb.Append("<div style='background-color:#FFFFD1" + Config.CommonStyles + "> Stack Trace: " + ex.StackTrace + "</div>");
            body = sb.ToString();
        }
Пример #19
0
        /// <summary>
        /// send message
        /// </summary>
        public void SendMessage(string userName, string usersend, string message)
        {
            using (var db = new WMSEntities())
            {
                var kişi = db.Users.Where(m => m.Kod == userName).FirstOrDefault();
                var guid = HtmlHelperExtension.ImageAddressOrDefault(kişi.Guid.ToString());
                if (usersend != "")
                {
                    // sadece bir kişiye mesaj gönderiyor
                    db.Messages.Add(new Message()
                    {
                        MesajTipi = ComboItems.KişiselMesaj.ToInt32(),
                        Tarih     = DateTime.Now,
                        Kimden    = userName,
                        Kime      = usersend,
                        Mesaj     = message
                    });
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Logger(ex, "HUB/SendMessage/1", userName);
                    }

                    // online ise hemen gönder
                    var pmConnection = db.Connections.Where(x => x.UserName.ToLower() == usersend && x.IsOnline).SingleOrDefault();
                    if (pmConnection != null)
                    {
                        Clients.Clients(new List <string> {
                            Context.ConnectionId, pmConnection.ConnectionId
                        }).UpdateChat(userName, usersend, message, kişi.AdSoyad, guid);
                        return;
                    }
                }
                else
                {
                    // herkese mesaj gönderiyor
                    db.Messages.Add(new Message()
                    {
                        MesajTipi = ComboItems.GrupMesajı.ToInt32(),
                        Tarih     = DateTime.Now,
                        Kimden    = userName,
                        Kime      = "",
                        Mesaj     = message
                    });
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Logger(ex, "HUB/SendMessage/All", userName);
                    }

                    // online ise hemen gönder
                    Clients.All.UpdateChat(userName, usersend, message, kişi.AdSoyad, guid);
                }
            }
        }
Пример #20
0
 private object GetRouteValuesByPage(int page)
 {
     return
         (HtmlHelperExtension.AddRouteValue(RouteValues, new { Page = page }));
 }
Пример #21
0
 public static MvcHtmlString CheckBoxForStatus <TModel>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, int> > expression, string labelText = null, object htmlAttributes = null)
 {
     // Status: -1:逻辑删除, 0:禁用, 1:启用.
     return(HtmlHelperExtension.CheckBoxFor <TModel>(htmlHelper, expression, 1, labelText, htmlAttributes));
 }