zoukankan      html  css  js  c++  java
  • 工具类

    /// <summary>
            /// md5加密方式
            /// </summary>
            /// <param name="str">原字符串</param>
            /// <param name="code">16,32 位</param>
            /// <returns>加密后的字符串</returns>
            public static string MD5(string str, int code)
            {
                if (code == 16)
                {
                    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToLower().Substring(8, 16);
                }
                if (code == 32)
                {
                    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();
                }
                return str;
            }
    
            // 返回指定字符串的值
    
            public static string TagVal(string Tag, string TagName)
            {
                string[] strArray = Tag.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    Regex regex = new Regex(@"(?<Keyword>w+)s*=s*(?<Value>.*)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    for (Match match = regex.Match(strArray[i]); match.Success; match = match.NextMatch())
                    {
                        if (match.Groups["Keyword"].ToString().ToLower().IndexOf(TagName.ToLower()) != -1)
                        {
                            return match.Groups["Value"].ToString();
                        }
                    }
                }
                return "";
            }
    
    
            /// <summary>
            /// 弹出消息框
            /// </summary>
            /// <param name="message">消息内容</param>
            public static void Alert(string message, System.Web.UI.Page page)
            {
                string js = "<script language=javascript>alert('{0}');</script>";
                if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertAndRedirect"))
                {
                    page.ClientScript.RegisterStartupScript(page.GetType(), "Alert", string.Format(js, message));
                }
            }
    
    
    
    
            /// <summary>
            /// 重写URL,分页函数
            /// </summary>
            /// <param name="RecordCount">记录总数</param>
            /// <param name="PageSize">分页大小</param>
            /// <param name="PageIndex">当前页</param>
            /// <param name="PageList">循环页码个数</param>
            /// <param name="strWhere">参数</param>
            /// <param name="cssClass">页面</param>
            /// <returns>分页字符串</returns>
            public static string GetPageListManage(string url, int RecordCount, int PageSize, int PageIndex, int PageList, string strWhere)
            {
                StringBuilder strPage = new StringBuilder();
                if (PageSize <= 0) PageSize = 1;
                int PageCount = (RecordCount + PageSize - 1) / PageSize;
                int PageTemp = 0;
                if (PageIndex > PageCount)
                {
                    PageIndex = PageCount;
                }
                else if (PageIndex <= 0)
                {
                    PageIndex = 1;
                }
    
                //新的分页
                strPage.AppendFormat("<div class="bigPage">");
                strPage.AppendFormat("<a href="" + url + "?page={0}" onfocus="this.blur()" class="previous" beginpage="1">上一页</a>", PageIndex - 1 <= 0 ? 1 : PageIndex - 1, strWhere);
                PageTemp = ((PageIndex - 1) / PageList) * PageList + 1;
                int i = 1;
                while (i <= PageList && PageTemp <= PageCount)
                {
                    i++;
                    strPage.AppendFormat(PageTemp == PageIndex ? "<a class="hover">{0}</a>" : "<a style='margin-left:5px;margin-right:5px;' href="" + url + "?page={0}" onfocus="this.blur()">{0}</a>", PageTemp++);
                }
    
                if (PageCount > 10)
                {
                    strPage.AppendFormat("<span>...</span>");
                }
    
                strPage.AppendFormat("<a href="" + url + "?page={0}" class="previous" onfocus="this.blur()">下一页</a>", PageIndex + 1 > PageCount ? PageCount : PageIndex + 1, strWhere);
                strPage.AppendFormat(" </div>");
                return strPage.ToString();
            }
    

      

  • 相关阅读:
    python并发之concurrent.futures
    Twisted 简介
    Python进程、线程、协程的对比
    协程的优点(Python)
    python concurrent.futures
    gevent 协程 使用
    python高性能代码之多线程优化
    python并发编程之多进程、多线程、异步和协程
    Java——动态代理
    NHibernate之旅(14):探索NHibernate中使用视图
  • 原文地址:https://www.cnblogs.com/Aamir-Ye/p/4544379.html
Copyright © 2011-2022 走看看