/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "kpi-report-113"); var result = HttpRuntime.Cache[cacheKey] as List <Report113Entity>; if (result == null) { result = AddDataToCache(); } if (result == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var colNames = e.ExtraParams["ColumnNames"]; var names = new XmlDocument(); names.LoadXml(colNames); var datas = new XmlDocument(); var root = datas.CreateElement("records"); datas.AppendChild(root); for (int i = 0; i < result.Count; i++) { var parent_Node = datas.CreateElement("record"); root.AppendChild(parent_Node); var ID_Node = datas.CreateElement("ID"); ID_Node.InnerText = (i + 1).ToString(); parent_Node.AppendChild(ID_Node); var LscID_Node = datas.CreateElement("LscID"); LscID_Node.InnerText = result[i].LscID.ToString(); parent_Node.AppendChild(LscID_Node); var LscName_Node = datas.CreateElement("LscName"); LscName_Node.InnerText = result[i].LscName; parent_Node.AppendChild(LscName_Node); var ThisCount_Node = datas.CreateElement("ThisCount"); ThisCount_Node.InnerText = result[i].ThisCount.ToString(); parent_Node.AppendChild(ThisCount_Node); var LastCount_Node = datas.CreateElement("LastCount"); LastCount_Node.InnerText = result[i].LastCount.ToString(); parent_Node.AppendChild(LastCount_Node); var Rate_Node = datas.CreateElement("Rate"); Rate_Node.InnerText = String.Format("{0:P2}", result[i].LastCount != 0 ? (double)result[i].ThisCount / (double)result[i].LastCount : 1); parent_Node.AppendChild(Rate_Node); } var fileName = "KPI-Report113.xls"; var sheetName = "关键监控测点接入率"; var title = "动力环境监控中心系统 关键监控测点接入率报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportNodesToExcel(fileName, sheetName, title, subTitle, names, datas, false); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "kpi-report-004"); var result = HttpRuntime.Cache[cacheKey] as List <Report004Entity>; if (result == null) { result = AddDataToCache(); } if (result == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var colNames = e.ExtraParams["ColumnNames"]; var names = new XmlDocument(); names.LoadXml(colNames); var datas = new XmlDocument(); var root = datas.CreateElement("records"); datas.AppendChild(root); for (int i = 0; i < result.Count; i++) { var fm = 0d; var interval = 0d; if (result[i].LscID == -100) { fm = result[i].Roads * result[i].EndTime.Subtract(result[i].BeginTime).TotalMinutes; interval = result.Sum(r => r.Alarms.Sum(alarm => (alarm.EndTime == WebUtility.DefaultDateTime ? result[i].EndTime : alarm.EndTime).Subtract(alarm.StartTime).TotalMinutes)) / (result.Count - 1); } else { fm = result[i].Roads * result[i].EndTime.Subtract(result[i].BeginTime).TotalMinutes; interval = result[i].Alarms.Sum(alarm => (alarm.EndTime == WebUtility.DefaultDateTime ? result[i].EndTime : alarm.EndTime).Subtract(alarm.StartTime).TotalMinutes); } var parent_Node = datas.CreateElement("record"); root.AppendChild(parent_Node); var ID_Node = datas.CreateElement("ID"); ID_Node.InnerText = (i + 1).ToString(); parent_Node.AppendChild(ID_Node); var LscID_Node = datas.CreateElement("LscID"); LscID_Node.InnerText = result[i].LscID.ToString(); parent_Node.AppendChild(LscID_Node); var LscName_Node = datas.CreateElement("LscName"); LscName_Node.InnerText = result[i].LscName; parent_Node.AppendChild(LscName_Node); var Area2Name_Node = datas.CreateElement("Area2Name"); Area2Name_Node.InnerText = result[i].Area2Name; parent_Node.AppendChild(Area2Name_Node); var Area3Name_Node = datas.CreateElement("Area3Name"); Area3Name_Node.InnerText = result[i].Area3Name; parent_Node.AppendChild(Area3Name_Node); var StaName_Node = datas.CreateElement("StaName"); StaName_Node.InnerText = result[i].StaName; parent_Node.AppendChild(StaName_Node); var LuCnt_Node = datas.CreateElement("LuCnt"); LuCnt_Node.InnerText = result[i].Roads.ToString(); parent_Node.AppendChild(LuCnt_Node); var Interval_Node = datas.CreateElement("Interval"); Interval_Node.InnerText = Math.Round(interval, 2).ToString(); parent_Node.AppendChild(Interval_Node); var Rate_Node = datas.CreateElement("Rate"); Rate_Node.InnerText = String.Format("{0:P2}", fm != 0 ? (1 - interval / fm) : 1); parent_Node.AppendChild(Rate_Node); } var fileName = "KPI-Report004.xls"; var sheetName = "市电可用度"; var title = "动力环境监控中心系统 市电可用度报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportNodesToExcel(fileName, sheetName, title, subTitle, names, datas, false); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "kpi-report-101"); var result = HttpRuntime.Cache[cacheKey] as List <Report101Entity>; if (result == null) { result = AddDataToCache(); } if (result == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var colNames = e.ExtraParams["ColumnNames"]; var names = new XmlDocument(); names.LoadXml(colNames); var datas = new XmlDocument(); var root = datas.CreateElement("records"); datas.AppendChild(root); for (int i = 0; i < result.Count; i++) { var parent_Node = datas.CreateElement("record"); root.AppendChild(parent_Node); var ID_Node = datas.CreateElement("ID"); ID_Node.InnerText = (i + 1).ToString(); parent_Node.AppendChild(ID_Node); var LscID_Node = datas.CreateElement("LscID"); LscID_Node.InnerText = result[i].Station.LscID.ToString(); parent_Node.AppendChild(LscID_Node); var LscName_Node = datas.CreateElement("LscName"); LscName_Node.InnerText = result[i].Station.LscName; parent_Node.AppendChild(LscName_Node); var Area1Name_Node = datas.CreateElement("Area1Name"); Area1Name_Node.InnerText = result[i].Station.Area1Name; parent_Node.AppendChild(Area1Name_Node); var Area2Name_Node = datas.CreateElement("Area2Name"); Area2Name_Node.InnerText = result[i].Station.Area2Name; parent_Node.AppendChild(Area2Name_Node); var Area3ID_Node = datas.CreateElement("Area3ID"); Area3ID_Node.InnerText = result[i].Station.Area3Name; parent_Node.AppendChild(Area3ID_Node); var Area3Name_Node = datas.CreateElement("Area3Name"); Area3Name_Node.InnerText = result[i].Station.Area3Name; parent_Node.AppendChild(Area3Name_Node); var BuildingID_Node = datas.CreateElement("BuildingID"); BuildingID_Node.InnerText = result[i].Station.BuildingID.ToString(); parent_Node.AppendChild(BuildingID_Node); var BuildingName_Node = datas.CreateElement("BuildingName"); BuildingName_Node.InnerText = result[i].Station.BuildingName == WebUtility.DefaultString ? "--" : result[i].Station.BuildingName; parent_Node.AppendChild(BuildingName_Node); var BuildingFH_Node = datas.CreateElement("BuildingFH"); BuildingFH_Node.InnerText = Math.Round(result[i].FH, 2).ToString(); parent_Node.AppendChild(BuildingFH_Node); var BuildingCDFH_Node = datas.CreateElement("BuildingCDFH"); BuildingCDFH_Node.InnerText = Math.Round(result[i].CDFH, 2).ToString(); parent_Node.AppendChild(BuildingCDFH_Node); var DesignCapacity_Node = datas.CreateElement("DesignCapacity"); DesignCapacity_Node.InnerText = result[i].DesignCapacity.ToString(); parent_Node.AppendChild(DesignCapacity_Node); var Rate_Node = datas.CreateElement("Rate"); Rate_Node.InnerText = String.Format("{0:P2}", result[i].DesignCapacity != 0 ? (result[i].FH + result[i].CDFH) / result[i].DesignCapacity : 1); parent_Node.AppendChild(Rate_Node); } var fileName = "KPI-Report101.xls"; var sheetName = "高低压配电系统负载率"; var title = "动力环境监控中心系统 高低压配电系统负载率报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportNodesToExcel(fileName, sheetName, title, subTitle, names, datas, false); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "his-ai-static-values"); var nodes = HttpRuntime.Cache[cacheKey] as List <AIStaticGridInfo>; if (nodes == null) { nodes = AddDataToCache(); } if (nodes == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var colNames = e.ExtraParams["ColumnNames"]; var names = new XmlDocument(); names.LoadXml(colNames); var datas = new XmlDocument(); var root = datas.CreateElement("records"); datas.AppendChild(root); for (int i = 0; i < nodes.Count; i++) { var parent_Node = datas.CreateElement("record"); root.AppendChild(parent_Node); var ID_Node = datas.CreateElement("ID"); ID_Node.InnerText = (i + 1).ToString(); parent_Node.AppendChild(ID_Node); var LscName_Node = datas.CreateElement("LscName"); LscName_Node.InnerText = nodes[i].LscName; parent_Node.AppendChild(LscName_Node); var Area1Name_Node = datas.CreateElement("Area1Name"); Area1Name_Node.InnerText = nodes[i].Area1Name; parent_Node.AppendChild(Area1Name_Node); var Area2Name_Node = datas.CreateElement("Area2Name"); Area2Name_Node.InnerText = nodes[i].Area2Name; parent_Node.AppendChild(Area2Name_Node); var Area3Name_Node = datas.CreateElement("Area3Name"); Area3Name_Node.InnerText = nodes[i].Area3Name; parent_Node.AppendChild(Area3Name_Node); var StaName_Node = datas.CreateElement("StaName"); StaName_Node.InnerText = nodes[i].StaName; parent_Node.AppendChild(StaName_Node); var NodeName_Node = datas.CreateElement("NodeName"); NodeName_Node.InnerText = nodes[i].NodeName; parent_Node.AppendChild(NodeName_Node); var TypeName_Node = datas.CreateElement("TypeName"); TypeName_Node.InnerText = nodes[i].TypeName; parent_Node.AppendChild(TypeName_Node); var ProdName_Node = datas.CreateElement("ProdName"); ProdName_Node.InnerText = nodes[i].ProdName; parent_Node.AppendChild(ProdName_Node); var Unit_Node = datas.CreateElement("Remark"); Unit_Node.InnerText = nodes[i].Remark; parent_Node.AppendChild(Unit_Node); var BeginTime_Node = datas.CreateElement("BeginTime"); BeginTime_Node.InnerText = WebUtility.GetDateString(nodes[i].BeginTime); parent_Node.AppendChild(BeginTime_Node); var EndTime_Node = datas.CreateElement("EndTime"); EndTime_Node.InnerText = WebUtility.GetDateString(nodes[i].EndTime); parent_Node.AppendChild(EndTime_Node); var AvgValue_Node = datas.CreateElement("AvgValue"); AvgValue_Node.InnerText = nodes[i].AvgValue.ToString(); parent_Node.AppendChild(AvgValue_Node); var MaxValue_Node = datas.CreateElement("MaxValue"); MaxValue_Node.InnerText = nodes[i].MaxValue.ToString(); parent_Node.AppendChild(MaxValue_Node); var MinValue_Node = datas.CreateElement("MinValue"); MinValue_Node.InnerText = nodes[i].MinValue.ToString(); parent_Node.AppendChild(MinValue_Node); var MaxTime_Node = datas.CreateElement("MaxTime"); MaxTime_Node.InnerText = WebUtility.GetDateString(nodes[i].MaxTime); parent_Node.AppendChild(MaxTime_Node); var MinTime_Node = datas.CreateElement("MinTime"); MinTime_Node.InnerText = WebUtility.GetDateString(nodes[i].MinTime); parent_Node.AppendChild(MinTime_Node); } var fileName = "HisAIStaticNodes.xls"; var sheetName = "HisAIStaticNodes"; var title = "动力环境监控中心系统 历史测值报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportNodesToExcel(fileName, sheetName, title, subTitle, names, datas, false); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }
/// <summary> /// Save Button Click /// </summary> protected void SaveBtn_Click(object sender, DirectEventArgs e) { try { var cacheKey = WebUtility.GetCacheKeyName(UserData, "ai-node-values"); var nodes = HttpRuntime.Cache[cacheKey] as List <NodeInfo>; if (nodes == null) { nodes = AddDataToCache(); } if (nodes == null) { WebUtility.ShowMessage(EnmErrType.Warning, "获取数据时发生错误,导出失败!"); return; } var colNames = e.ExtraParams["ColumnNames"]; var names = new XmlDocument(); names.LoadXml(colNames); var datas = new XmlDocument(); var root = datas.CreateElement("records"); datas.AppendChild(root); for (int i = 0; i < nodes.Count; i++) { var parent_Node = datas.CreateElement("record"); root.AppendChild(parent_Node); var ID_Node = datas.CreateElement("ID"); ID_Node.InnerText = (i + 1).ToString(); parent_Node.AppendChild(ID_Node); var LscName_Node = datas.CreateElement("LscName"); LscName_Node.InnerText = nodes[i].LscName; parent_Node.AppendChild(LscName_Node); var Area2Name_Node = datas.CreateElement("Area2Name"); Area2Name_Node.InnerText = nodes[i].Area2Name; parent_Node.AppendChild(Area2Name_Node); var Area3Name_Node = datas.CreateElement("Area3Name"); Area3Name_Node.InnerText = nodes[i].Area3Name; parent_Node.AppendChild(Area3Name_Node); var StaName_Node = datas.CreateElement("StaName"); StaName_Node.InnerText = nodes[i].StaName; parent_Node.AppendChild(StaName_Node); var DevName_Node = datas.CreateElement("DevName"); DevName_Node.InnerText = nodes[i].DevName; parent_Node.AppendChild(DevName_Node); var DevTypeName_Node = datas.CreateElement("DevTypeName"); DevTypeName_Node.InnerText = nodes[i].DevTypeName; parent_Node.AppendChild(DevTypeName_Node); var NodeID_Node = datas.CreateElement("NodeID"); NodeID_Node.InnerText = nodes[i].NodeID.ToString(); parent_Node.AppendChild(NodeID_Node); var NodeName_Node = datas.CreateElement("NodeName"); NodeName_Node.InnerText = nodes[i].NodeName; parent_Node.AppendChild(NodeName_Node); var ValueName_Node = datas.CreateElement("NodeValue"); ValueName_Node.InnerText = String.Format("{0} {1}", nodes[i].Value.ToString("0.000"), nodes[i].Remark); parent_Node.AppendChild(ValueName_Node); var Status_Node = datas.CreateElement("Status"); Status_Node.InnerText = ((int)nodes[i].Status).ToString(); parent_Node.AppendChild(Status_Node); } var fileName = "NodeValues.xls"; var sheetName = "NodeValues"; var title = "动力环境监控中心系统 实时测值报表"; var subTitle = String.Format("值班员:{0} 日期:{1}", Page.User.Identity.Name, WebUtility.GetDateString(DateTime.Now)); var xls = WebUtility.ExportNodesToExcel(fileName, sheetName, title, subTitle, names, datas, true); if (xls != null) { xls.Send(); } } catch (Exception err) { WebUtility.WriteLog(EnmSysLogLevel.Error, EnmSysLogType.Exception, err.ToString(), Page.User.Identity.Name); WebUtility.ShowMessage(EnmErrType.Error, err.Message); } }