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(""", "\"") ; } /// /// 获得百分比 /// /// /// /// 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; } /// /// 建立日志目录 /// public static void CreateLogDirectory() { string path = Environment.CurrentDirectory; path = path + "\\logs"; if (!Directory.Exists(path)) { LogHelper.Debug("创建日志目录:" + path); Directory.CreateDirectory(path); } } } }