PublicFunctions公共方法类

一、类名Class

类名:PublicFunctions.PublicFunctions

 

二、属性Properties

 

三、方法Methods

1、根据出生日期计算年龄

函数:public static int CalculateAge(Object birthdateobject)

birthdateobject:生日日期

返回: int

 

2、根据出生日期判断星座

函数:public static string GetConstellation(Object birthdateobject)

返回: string

 

3、根据日期获得中文星期几

函数:public static string GetWeekDayCN(DateTime date)

返回: string

 

4、根据任意类及实例生成(字段-值)Dictionary

函数:public static Dictionary<string, string> ParseObject(Type type, Object instance)

返回: Dictionary<string, string>

 

5、获取任意对象的属性值

函数:public static Dictionary<string, string> GetObjectValue<T>(T instance, bool IsRestoreData = true)

返回: Dictionary<string, string>

 

6、设置任意对象的属性值

函数:public static void SetObjectValue(Type type, Object instance, Dictionary<string, string> ValueDictionary)

返回: 无

 

7、设置任意对象的属性值(重载)

函数:public static void SetObjectValue(Type type, Object instance, Dictionary<string, Object> ValueDictionary)

返回: string

 

8、修正小于10的月份,前面加0,如1月显示为01

函数:public static string FixMonthString(object monthobject)

返回: string

 

9、修正小于1000的数字

函数:public static string FixLessThousandNumberString(object monthobject)

返回: string

 

10、生成“全选/反选”链接

函数:public static string GetSelectAllLink(string CSSClassName)

返回: string

 

11、生成全选的CHECKBOX

函数:public static string GetCheckAllObject(string CSSClassName, bool NeedText = true)

返回: string

 

12、从Dictionary<string,string>中获得指定值

函数:public static string GetDataFromDictionary(string Key, ref Dictionary<string, string> MyDictionary, string DefaultValue = "", bool RemoveKey = false)

返回: string

 

13、从Dictionary<string,string>中获得指定值(重载)

函数:public static string GetDataFromDictionary(string Key, Dictionary<string, string> MyDictionary, string DefaultValue = "", bool RemoveKey = false)

返回: string

 

14、从Dictionary<string,string>中获得指定值(重载)

函数:public static object GetDataFromDictionary(string Key, ref Dictionary<string, object> MyDictionary, string DefaultValue = "", bool RemoveKey = false)

返回: object

 

15、从Dictionary<string,string>中获得指定值(重载)

函数:public static object GetDataFromDictionary(string Key, Dictionary<string, object> MyDictionary, string DefaultValue, bool RemoveKey = false)

返回: object

 

16、从Dictionary<string,string>中获得指定值(重载)

函数:public static int GetDataFromDictionary(string Key, Dictionary<string, int> MyDictionary, int DefaultValue, bool RemoveKey = false)

返回: int

 

17、从Dictionary<string,string>中获得指定值(重载)(泛型)

函数:public static T GetDataFromDictionaryGeneric<T>(string Key, Dictionary<string, T> MyDictionary, bool RemoveKey = false)

返回: T

 

18、从Dictionary<string,string>中获得指定值(重载)(泛型)

函数:public static T GetDataFromDictionaryGeneric<T>(string Key, Dictionary<string, T> MyDictionary, T DefaultValue, bool RemoveKey = false)

返回: T

 

19、将数据字典中的数据拆分成单个表的字典的集合

函数:public static Dictionary<string, Dictionary<string, string>> SplitDataDictionary(Dictionary<string, string> dic, bool IsHtmlControlFormPostData = false, params string[] RestrictFormKey)

返回: Dictionary<string, Dictionary<string, string>>

 

20、反转Dictionary<T,V>的结构,变为Dictionary<V,T>

函数:public static Dictionary<V, T> ReverseDictionaryStruct<T, V>(Dictionary<T, V> dic)

返回: Dictionary<V, T>

 

21、将数字转换成大写金额

函数:public static string GetChineseMoney(decimal mvarOrDollar)

返回: string

 

22、获得年月日控件

函数:public static string GetYearMonthDaySelectObject(int MinYear, int MaxYear, string PrefixOjbectID, string CurrentValue, string CSSClassName, bool IsRestrictMode, string OptionText, bool ShowDay = true)

返回: string

 

23、从Dictionary<T, V>中删除指定的KEY

函数:public static void RemoveKeys<T, V>(Dictionary<T, V> dic, bool IsFuzzyMatch = false, params T[] KeyList)

返回: 无

 

24、克隆对象

函数:public static T CloneObject<T>(T obj, out string ErrorMsg)

返回: T

 

25、从Dictionary<T,V>中获得指定值的KEY

函数:public static T GetKeyFromDictionary<T, V>(Dictionary<T, V> dic, V SearchValue)

返回: T

 

26、生成任意一个随机数

函数:public static string GenerateRandom()

返回: string

 

27、从当前的上下文中获得Request.QueryString及Request.Form的字典

函数:public static Dictionary<string, string> GetHttpContextRequestDictonary(FormActionEnum type)

返回: Dictionary<string, string>

 

28、获得网站的域名

函数:public static string GetDomainName()

返回: string

 

29、进行空值替换

函数:public static Dictionary<T, string> ReplaceNullDisplayValue<T>(Dictionary<T, string> dic)

返回: Dictionary<T, string>

 

30、进行空值替换(重载)

函数:public static string ReplaceNullDisplayValue(string value)

返回: string

 

31、PING一个IP地址是否存在

函数:public static bool PingIsExsit(string HostNameOrAddress)

返回: true/false

 

32、根据PageSize,PageNumber获得当页List<T>

函数:public static List<T> GetCustomPageDataList<T>(List<T> DataSoureList, ref int pageno, int pagesize, ref int TotalPage)

返回: List<T>

 

33、计算总的页数

函数:public static int GetTotalPage(int pagesize, int TotalResult)

返回: int

 

34、生成Metro风格的页码列表

函数:public static string GetMetroStylePageList(int pagesize, int pageno, int TotalResult, int TotalPage, string ChangePageSizeJSFunction, string ChangePageNoJSFunction, string PrefixParameters = "", string AdditionalParameters = "", bool ApplyMinMaxShowPageNo = true)

返回: string

 

35、GetFileNameFromPath从一个路径中获得文件名

函数:public static string GetFileNameFromPath(string path)

返回: string

 

36、RemoveEmptyFields删除值为空的字段

函数:public static void RemoveEmptyFields(ref Dictionary<string, string> dic)

返回: 无

 

37、GetInsertSQL生成插入行的SQL语句

函数:public static string GetInsertSQL(string TableName, Dictionary<string, string> dic)

返回: string

 

38、GetInsertSQL生成插入行的SQL语句(重载)

函数:public static string GetInsertSQL(string TableName, Dictionary<string, string> dic, bool ReplaceData)

返回: string

 

39、GetUpdateSQL生成执行更新操作的SQL语句

函数:public static string GetUpdateSQL(string TableName, Dictionary<string, string> dic, string StrWhere)

返回: string

 

40、GetUpdateSQL生成执行更新操作的SQL语句(重载)

函数:public static string GetUpdateSQL(string TableName, Dictionary<string, string> dic, string StrWhere, bool ReplaceData)

返回: string

 

41、隐藏电话号码(只显示前三位和最后一位)

函数:public static string HidePhoneNumber(string PhoneNumber)

返回: string

 

42、ApplyPageLayoutTemplateHTML应用界面布局模板的内容

函数:public static string ApplyPageLayoutTemplateHTML(string PageLayoutTemplateHTML, Dictionary<string, string> VariableControlDictionary = null)

返回: string

 

43、ApplyPageLayoutTemplateHTML应用界面布局模板的内容(重载)

函数: public static string ApplyPageLayoutTemplateHTML(Service.ServiceDataModel ServiceData, bool IsMobile, bool ApplyCommonChildDataTable, string PageLayoutTemplateHTML, out string Script, Dictionary<string, string> VariableControlDictionary = null, Dictionary<string, string> ParentTableDictionary = null)

返回: string

 

44、ApplyPageLayoutTemplateHTML应用界面布局模板的内容(重载)

函数: public static string ApplyPageLayoutTemplateHTML(Service.ServiceDataModel ServiceData, bool IsMobile, bool IsMobileV5, bool ApplyCommonChildDataTable, string PageLayoutTemplateHTML, out string Script, Dictionary<string, string> VariableControlDictionary = null, Dictionary<string, string> ParentTableDictionary = null)

返回: string

 

45、ApplyPageLayoutTemplateHTMLByValueDictionary应用界面布局模板的内容(非变量字典)

函数: public static string ApplyPageLayoutTemplateHTMLByValueDictionary(string PageLayoutTemplateHTML, Dictionary<string, string> ValueDictonary = null)

与上面的区别是ValueDictonary;上面的需要传入格式VariableControlDictionary["<$name$>"]="张三";本函数传入:VariableControlDictionary["name"]="张三",系统替换变量时会自动加上<$$>

返回: string

 

46、GetCOMMONYEARDictionary获得“COMMONYEAR”的字典

函数:public static Dictionary<string, string> GetCOMMONYEARDictionary()

返回: Dictionary<string, string>

 

47、GetCOMMONMONTHDictionary获得“COMMONMONTH”的字典

函数:public static Dictionary<string, string> GetCOMMONMONTHDictionary()

返回: Dictionary<string, string>

 

48、GetUserIcon获得一个用户的头像地址

函数:public static string GetUserIcon(string UserGuid)

返回: string

 

49、SplitList按数量分割列表

函数:public static List<List<T>> SplitList<T>(List<T> source, int size)

返回: List<List<T>>

 

50、SplitWordLine分割内容行

函数:public static string SplitWordLine(string content, int MaxLengthPerLine)

返回: string

 

51、IsEqualList判断两个List是否相同

函数:public static bool IsEqualList<T>(List<T> list1, List<T> list2)

返回: true/false

 

52、GetVariableList获得变量列表

函数:public static List<string> GetVariableList(string value)

返回: List<string>

 

53、GetTimeStamp生成一个时间戳

函数:public static string GetTimeStamp()

返回: string

 

54、GetDateTimeByTimeStamp根据时间戳获得日期

函数:public static DateTime GetDateTimeByTimeStamp(int timeStamp)

返回: DateTime