123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Data;
- using Logs;
- namespace cuidian.Common
- {
- public class Utils
- {
- public static string GetColData(DataRow dr, string col)
- {
- if (dr.IsNull(col)) return null;
- if (dr[col].GetType() == typeof(bool))
- {
- bool o = Convert.ToBoolean(dr[col]);
- return o ? "1" : "0";
- }
- else
- {
- if (dr[col].ToString() == string.Empty) return null;
- }
- //if (dr[col].ToString() == string.Empty) return null;
- return dr[col].ToString().Replace("&", "&").Replace("'", "'").Replace(">", ">").Replace("<", "<").Replace(""", "\"") ;
- }
- /// <summary>
- /// 获得百分比
- /// </summary>
- /// <param name="current"></param>
- /// <param name="total"></param>
- /// <returns></returns>
- public static int GetPrecent(int current, int total)
- {
- int max = 100;
- int precent = Convert.ToInt16(((float)current / (float)total) * 100);
- precent = (precent >= max) ? max : precent;
- return precent;
- }
- /// <summary>
- /// 建立日志目录
- /// </summary>
- public static void CreateLogDirectory()
- {
- string path = Environment.CurrentDirectory;
- path = path + "\\logs";
- if (!Directory.Exists(path))
- {
- LogHelper.Debug("创建日志目录:" + path);
- Directory.CreateDirectory(path);
- }
- }
- }
- }
|