zoukankan      html  css  js  c++  java
  • 备用代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web.Security;
    using System.Web;
    using System.Web.UI;
    using CSharpLib.Entity;
    using System.IO;
    using System.Web.Script.Serialization;
    
    
    namespace CSharpLib.Common
    {
        public class Utility
        {
            public static string Substring(string text, int index)
            {
                return text.Length > index ? text.Substring(0, index) + "..." : text;
            }
    
            public static WebSiteEntities OpenConnect()
            {
                return new WebSiteEntities();
            }
    
            public static string Substring(string text, int index, string strEnding)
            {
                return text.Length > index ? text.Substring(0, index) + strEnding : text;
            }
    
            public static void MessageShow(Page pInstance, string msg)
            {
                ClientScriptManager csm = pInstance.ClientScript;
    
                csm.RegisterStartupScript(pInstance.GetType(), "message", "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
            }
    
            public static void MessageShowUrl(Page pInstance, string strMessage, string strFileName)
            {
    
                ClientScriptManager csm = pInstance.ClientScript;
    
                string strContent = string.Format("<script language=javascript>alert('{0}');window.location.replace('{1}')</script>", strMessage, strFileName);
    
                csm.RegisterStartupScript(pInstance.GetType(), "message", strContent);
            }
    
            public static string GetClientIP()
            {
                string result = String.Empty;
    
                result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (null == result || result == String.Empty)
                {
                    result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
                }
    
                if (null == result || result == String.Empty)
                {
                    result = HttpContext.Current.Request.UserHostAddress;
                }
    
                if (null == result || result == String.Empty)
                {
                    return "0.0.0.0";
                }
    
                return result;
            }
    
            public static string EncryptPassword(string strPassword)
            {
                return FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "sha1").Substring(0, 32).ToString();
            }
    
    
            public static string JsonSerializer(object obj)
            {
                JavaScriptSerializer json = new JavaScriptSerializer();
    
                return json.Serialize(obj);
            }
    
            public static void SendJson(string data)
            {
                HttpContext.Current.Response.Write(data);
    
                HttpContext.Current.Response.End();
            }
    
            //public static ICacheManager GetCacheNode()
            //{
            //    return CacheFactory.GetCacheManager();
            //}
        }
    }
  • 相关阅读:
    Python之Django rest_Framework(3)
    django 之补充
    Python之Django rest_Framework(3)
    Python之Django rest_Framework(2)
    Python之Django rest_Framework补充
    Python之Django rest_Framework框架认证源码分析
    Python之Django rest_Framework
    Python算法——二叉树
    Python之数据结构基础
    Python之算法
  • 原文地址:https://www.cnblogs.com/ytjjyy/p/2453449.html
Copyright © 2011-2022 走看看