public SavedRouteClass(DataRow dr, DataRow[] syslist) { this.Id = (long)dr["id"]; this.Name = (string)dr["name"]; if (dr["start"] != DBNull.Value) this.StartDate = (DateTime?)dr["start"]; if (dr["end"] != DBNull.Value) this.EndDate = (DateTime?)dr["end"]; this.Systems = syslist.Select(s => (string)s["systemname"]).ToList(); }
public void GenerateCheckReports(string gardenName, DateTime[] dates, Action notify) { var dt = new ClassesDataAccess().GetClassAndGrade(); var rows = new DataRow[dt.Rows.Count]; dt.Rows.CopyTo(rows, 0); foreach (var date in dates) { KillProcess(); var dir = excelPath + @"report\成长记录报表\" + date.ToString("yyyy"); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); var checkInDays = new UtilDataAccess().GetAttendDays(date, date.AddMonths(1).AddDays(-1)); var hierarchy = new GrowUpReportDataAccess().GetGrowUpCheckReports(rows.Select(r => r["info_className"].ToString()).ToArray(), date); GenerateCheckReportsPersonByPerson(gardenName, hierarchy, checkInDays, date, dir, notify); GenerateCheckReportsClassByClass(gardenName, hierarchy, checkInDays, date, dir, notify); GenerateCheckReportsGradeByGrade(gardenName, hierarchy, checkInDays, date, dir, notify); } }
/// <summary> /// 生成查询语句 /// </summary> /// <param name="conStr">数据库连接</param> /// <param name="tableName">表名</param> /// <param name="owner">表来源</param> /// <param name="drs">数据</param> /// <returns></returns> public static string CreateSearchSql(string conStr, string tableName, string owner, DataRow[] drs) { if (drs.Length > 0) { //TableSchema st = new TableSchema(new DatabaseSchema(new SqlSchemaProvider(), conStr), tableName, owner, DateTime.MinValue); DataTable st = new DBHelper(conStr).ExecuteTable(string.Format(ConfigurationSettings.AppSettings["ColumnSearchSql"], tableName)); return string.Format("select * from {0} where ({1})", tableName, string.Join(") or (", drs.Select(c => string.Join(" and ", st.AsEnumerable().Where(d => d["pk"].ToString() == "0").ToArray().Select(d => string.Format(" {0}='{1}' ", d["name"], c[d["name"].ToString()])).ToArray())).ToArray())); } else return string.Empty; }
/// <summary> /// Utility function used to transpose the DataRow array's returned /// by calls to the ADO.NET functionality from PowerShell. /// </summary> /// <param name="adoData"></param> /// <returns></returns> public static List<string> ColumnNameToList(DataRow[] adoData) { var colNameList = new List<string>(); if(adoData== null || adoData.Length <= 0) return colNameList;//empty list, match the ctor colNameList.AddRange( adoData.Select(dr => dr[Qry.Catalog.COLUMN_NAME].ToString()) .Where(colName => !string.IsNullOrWhiteSpace(colName))); return colNameList; }
/// <summary> /// 生成查询语句 /// </summary> /// <param name="tableName">表名</param> /// <param name="primaryKey">主键</param> /// <param name="drs">数据</param> /// <returns></returns> public static string CreateSearchSql(string tableName, string primaryKey, DataRow[] drs) { return string.Format("select * from {0} where {1} in ('{2}')", tableName, primaryKey, string.Join("','", drs.Select(c => c[primaryKey].ToString()).ToArray())); }