Example #1
0
        /// <summary>
        /// 获得流程编码选择控件脚本地址
        /// </summary>
        /// <param name="Page"></param>
        /// <returns></returns>
        public static string GetWorkflowCodeScriptPath(System.Web.UI.Page Page)
        {
            string path = "~/WFRes/Scripts/WorkflowSelector.js";

            return(Page.ResolveUrl(path));
            // return System.IO.Path.Combine(PortalRoot, path).Replace('\\', '/');
        }
Example #2
0
        static string GetFileWithSuffix(string path, System.Web.UI.Page page)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(path);
            }
            // If path is absolute then return.
            if (IsAbsoluteLink(path))
            {
                return(path);
            }
            var resolvedPath = page.ResolveUrl(path);
            // Check if path contains query.
            var index = resolvedPath.IndexOf('?');

            if (index > -1)
            {
                resolvedPath = resolvedPath.Substring(0, index);
            }
            var localPath = page.MapPath(resolvedPath);
            var fi        = new System.IO.FileInfo(localPath);

            if (fi.Exists)
            {
                var v = string.Format("v={0:yyyyMMddHHmmss}", fi.LastWriteTime);
                if (path.Contains(v))
                {
                    return(path);
                }
                path += (index > -1 ? "&" : "?") + v;
            }
            return(path);
        }
Example #3
0
    }       // eo ctor

    // Resolve Url
    public string ResolveUrl(string _url)
    {
        // Resolve the URL appropriately
        string resolved = m_Page.ResolveUrl(_url);

        // Add our arguments on to the Url.  This assumes that they have NOT been
        // put on the query string manually.
        Uri           uri     = new Uri(resolved);
        StringBuilder builder = new StringBuilder(uri.Query);

        if (uri.Query.Length > 0)
        {
            builder.Append("&");
        }
        int counter = 0;

        foreach (KeyValuePair <string, string> pair in m_Params)
        {
            builder.AppendFormat("{0}={1}", pair.Key, pair.Value);
            ++counter;
            if (counter < m_Params.Count)
            {
                builder.Append("&");
            }
        }
        ;

        return(string.Concat(resolved, builder.ToString()));
    }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        //public string renderMessage(System.Web.UI.Page page)  //test SISC
        public virtual string renderMessage(System.Web.UI.Page page)
        {
            System.Text.StringBuilder s = new System.Text.StringBuilder("<ul>");

            foreach (message m in messageList)
            {
                string icon  = string.Empty;
                string style = string.Empty;
                switch (m.tipo)
                {
                case LivelloMessaggio.ERROR:
                    icon  = "<img src='" + page.ResolveUrl("~/App_Themes/Delta/images/message/error.png") + "' alt='' />";
                    style = "style='font-size:medium; font-weight:bold; color:Red'";
                    break;

                case LivelloMessaggio.WARNING:
                    icon  = "<img src='" + page.ResolveUrl("~/App_Themes/Delta/images/message/alert.png") + "' alt='' />";
                    style = "style='font-size:medium; font-weight:bold; color:#000'";
                    break;

                case LivelloMessaggio.INFO:
                    icon  = "<img src='" + page.ResolveUrl("~/App_Themes/Delta/images/message/info.png") + "' alt='' />";
                    style = "style='font-size:medium; font-weight:bold; color:Blue'";
                    break;

                case LivelloMessaggio.DETAILS:
                    icon  = "<img src='" + page.ResolveUrl("~/App_Themes/Delta/images/message/info.png") + "' alt='' />";
                    style = "style='font-size:medium; font-weight:bold; color:Blue'";
                    break;

                case LivelloMessaggio.OK:
                    icon  = "<img src='" + page.ResolveUrl("~/App_Themes/Delta/images/message/accept.png") + "' alt='' />";
                    style = "style='font-size:medium; font-weight:bold; color:#000'";
                    break;

                default:
                    break;
                }
                s.Append("<li " + style + ">").Append(icon + " " + m.msg).Append("</li>");
            }

            s.Append("</ul>");
            return(s.ToString());
        }
Example #5
0
        /// <summary>
        /// 包含JS引用。
        /// </summary>
        /// <param name="filePaths"></param>
        public static void Include(params string[] filePaths)
        {
            HttpContext context = HttpContext.Current;

            if (null == context)
            {
                throw new Exception("HttpContext为空。");
            }

            System.Web.UI.Page p = context.CurrentHandler as System.Web.UI.Page;
            if (null == p)
            {
                throw new Exception("HttpContext.CurrentHandler不是Page。");
            }

            IList <string> jss = GetIncludedJavaScript();
            string         resolveUrl;

            foreach (string filePath in filePaths)
            {
                resolveUrl = p.ResolveUrl(filePath);
                if (!jss.Contains(resolveUrl))
                {
                    jss.Add(p.ResolveUrl(resolveUrl));
                    System.Web.UI.HtmlControls.HtmlGenericControl script = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
                    script.Attributes.Add("type", "text/javascript");
                    script.Attributes.Add("src", filePath);
                    if (p.Header != null)
                    {
                        p.Header.Controls.Add(script);
                    }
                    else
                    {
                        throw new Exception("页面中没有 runat=server 的header对象存在。");
                    }
                }
            }
            HttpContext.Current.Items["IncludedJavaScript"] = jss;
        }
Example #6
0
        public override void OnPreInit(System.Web.UI.Page page, ContentItem item)
        {
            if (string.IsNullOrEmpty(page.MasterPageFile))
            {
                return;
            }

            if (!string.IsNullOrEmpty(configuredMasterPagePath))
            {
                page.MasterPageFile = configuredMasterPagePath;
            }

            var defaultUrl   = page.ResolveUrl(page.MasterPageFile);
            var alternateUrl = engine.ResolveAdapter <RequestAdapter>(item).ResolveTargetingUrl(defaultUrl);

            if (!string.Equals(alternateUrl, defaultUrl, System.StringComparison.InvariantCultureIgnoreCase))
            {
                page.MasterPageFile = alternateUrl;
            }
        }
Example #7
0
 /// <summary>
 /// 加载javascript脚本文件
 /// </summary>
 public static string JS(string jsPath, System.Web.UI.Page p)
 {
     return(@"<script type=""text/javascript"" src=""" + p.ResolveUrl(jsPath) + @"""></script>" + "\r\n");
 }
Example #8
0
 /// <summary>
 /// 加载CSS样式文件
 /// </summary>
 public static string CSS(string cssPath, System.Web.UI.Page p)
 {
     return(@"<link href=""" + p.ResolveUrl(cssPath) + @""" rel=""stylesheet"" type=""text/css"" />" + "\r\n");
 }
        /// <summary>
        /// Need IF anothermenu page
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pinnumber"></param>
        /// <returns></returns>
        public static string GetPageMenu(System.Web.UI.Page page, string pinnumber)
        {
            if (page != null)
            {
                string menu = string.Empty;

                Collection <BOMenu> menuCollection = GetMenuCollection(page.Request.Url.AbsolutePath, 1, pinnumber);

                if (menuCollection.Count > 0)
                {
                    foreach (BOMenu model in menuCollection)
                    {
                        // menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<div class='menu-panel'><div class='menu-header'>{0}</div><div class='menu_lst_scroll'><ul>", model.MenuText);

                        string ss = "<div class='menu-panel'><div class='menu-header'><li class='block'>" +
                                    "<input type='checkbox' name='item' id='item1' />" +
                                    "<label for='item1'><i aria-hidden='true' class='icon-users'></i> " + model.MenuText + " <span>124</span></label><ul class='options'>";

                        menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, ss);



                        Collection <BOMenu> childMenus = GetMenuCollection(model.MenuId, 2, pinnumber);

                        if (childMenus.Count > 0)
                        {
                            foreach (BOMenu childMenu in childMenus)
                            {
                                string cls = "block";


                                menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<li><a href='{0}' title='{1}'>{1}<i aria-hidden='true' class='icon-search'></i>" + childMenu.MenuText + "</a></li>", page.ResolveUrl(childMenu.Url), childMenu.MenuText);
                            }
                        }

                        menu += "</ul></li></div></div>";
                    }
                }

                menu += "<div style='clear:both;'></div>";
                return(menu);
            }

            return(null);
        }
Example #10
0
 public string ConvertRelativeUrlToAbsoluteUrl(string relativeUrl, HttpRequest Request, System.Web.UI.Page page)
 {
     if (Request.IsSecureConnection)
     {
         return(string.Format("https://{0}{1}{2}", Request.Url.Host, ":" + Request.Url.Port, page.ResolveUrl(relativeUrl)));
     }
     else
     {
         return(string.Format("http://{0}{1}{2}", Request.Url.Host, ":" + Request.Url.Port, page.ResolveUrl(relativeUrl)));
     }
 }
Example #11
0
 /// <summary>
 /// Registers the script.
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="scriptKey">The script key.</param>
 /// <param name="scriptFile">The script file.</param>
 public static void RegisterScript(System.Web.UI.Page page, String scriptKey, String scriptFile)
 {
     if (!page.ClientScript.IsClientScriptBlockRegistered(typeof(DynamicListBoxResourceHandler), scriptKey))
     {
         String script = "";
         //if ( IsRegistered ) {
         script = "<script language='javascript' type='text/javascript' src='" + page.ResolveUrl("~/scripts/" + scriptFile) + "'></script>";
         //} else {
         //	script = "<script language='javascript' type='text/javascript'>\r\n<!--\r\n" + GetScript(page.Cache, scriptFile) + "\r\n// -->\r\n</script>";
         //}
         page.ClientScript.RegisterClientScriptBlock(typeof(DynamicListBoxResourceHandler), scriptKey, script);
     }
 }
Example #12
0
        /// <summary>
        /// 获得日期控件脚本的地址
        /// </summary>
        /// <param name="Page"></param>
        /// <returns></returns>
        public static string GetCalendarScriptPath(System.Web.UI.Page Page)
        {
            string path = "~/WFRes/_Scripts/Calendar/WdatePicker.js";

            return(Page.ResolveUrl(path));
        }
Example #13
0
        //TODO: these should be resources living in THIS project
        /// <summary>
        /// Adds all the required client script to a page at runtime
        /// </summary>
        /// <param name="Page"></param>
        public static void AddRequiredScripts(System.Web.UI.Page Page)
        {
            string script = "var NWTD = NWTD||{};";

            script += string.Format("NWTD.BaseURL='{0}';", System.Web.HttpUtility.UrlEncode(Page.ResolveUrl("~/")));
            script += string.Format("NWTD.CurrentUserID='{0}';", Mediachase.Commerce.Profile.ProfileContext.Current.UserId.ToString());

            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.JQUERY_JS);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_UTILITIES_JS);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_WEB_UI_COOKIE);
            Page.ClientScript.RegisterClientScriptResource(typeof(OakTree.Web.UI.ControlResources), OakTree.Web.UI.ControlResources.OAKTREE_WEB_UI_WEBCONTROLS_JS);

            Page.ClientScript.RegisterClientScriptInclude(typeof(OakTree.Web.UI.ControlResources), "NWTD_js", CommerceHelper.GetAbsolutePath("Structure/User/NWTDControls/Scripts/NWTD.js"));
            Page.ClientScript.RegisterClientScriptBlock(typeof(OakTree.Web.UI.ControlResources), "NWTD_global_js", script, true);
        }
Example #14
0
        public static string GetPageMenu(System.Web.UI.Page page)
        {
            if (page != null)
            {
                string menu = string.Empty;

                Collection <MixERP.Net.Common.Models.Core.Menu> menuCollection = MixERP.Net.BusinessLayer.Core.Menu.GetMenuCollection(page.Request.Url.AbsolutePath, 1);

                if (menuCollection.Count > 0)
                {
                    foreach (MixERP.Net.Common.Models.Core.Menu model in menuCollection)
                    {
                        menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<div class='menu-panel'><div class='menu-header'>{0}</div><ul>", model.MenuText);

                        Collection <MixERP.Net.Common.Models.Core.Menu> childMenus = MixERP.Net.BusinessLayer.Core.Menu.GetMenuCollection(model.MenuId, 2);

                        if (childMenus.Count > 0)
                        {
                            foreach (MixERP.Net.Common.Models.Core.Menu childMenu in childMenus)
                            {
                                menu += string.Format(System.Threading.Thread.CurrentThread.CurrentCulture, "<li><a href='{0}' title='{1}'>{1}</a></li>", page.ResolveUrl(childMenu.Url), childMenu.MenuText);
                            }
                        }

                        menu += "</ul></div>";
                    }
                }

                menu += "<div style='clear:both;'></div>";
                return(menu);
            }

            return(null);
        }