private void clearMemory() { if (null == this.areas || this.areas.Count > 0) { this.areas = new List <Area>(); } if (null != this.pmcPoint) { this.pmcPoint = null; } //生成一次点文件,清空一次dtStationAlarm,否则再次读取的时候讲出现一些冗余信息。 if (this.dtStationAlarm.Rows.Count > 0) { this.dtStationAlarm.Clear(); } }
private BasePoint getPMCPointDataType(string pointType) { BasePoint pmcPoint = null; switch (pointType) { case Constant.POINT_TYPE_ALARM: pmcPoint = new AlarmPoint(this, this.mainFormOperation, this.interfaceType); break; case Constant.POINT_TYPE_PROD: pmcPoint = new ProdStationPoint(this, this.mainFormOperation, this.interfaceType); break; case Constant.POINT_TYPE_NOT_PROD: pmcPoint = new NotProdStationPoint(this, this.mainFormOperation, this.interfaceType); break; default: break; } return(pmcPoint); }
private bool generate(string path, out string result) { result = ""; bool flag = false; string errString = null; try { if (this.dtStationAlarm.Rows.Count <= Constant.CONFIG_ALARM_DETAILS_MAX) { fillAreaDatas(this.areas, this.dtStationInfo, this.dtStationAlarm); } else { //当条数超过大约9000条后,this.mian对象被释放,导致后续状态错误,所以必须限制。+时间开发。 result = Constant.CONFIG_STATION_ALARM + "超过了" + Constant.CONFIG_ALARM_DETAILS_MAX + "条,生成点文件受限,解锁限制请联系管理员!"; return(false); } if (null == this.pmcPoint) { this.pmcPoint = getPMCPointDataType(this.mainFormOperation.Point_type); } DataTable dt = pmcPoint.generateCSVData(areas); if (null != dt) { //进度条 string status = "生成文件中..."; startProgressBar(5); setProgressBarValue(1, status); object[,] obj = OtherUtils.convertDataTabelToArray(dt); setProgressBarValue(2, status); flag = FileUtils.createExcel(obj, Excel.XlFileFormat.xlCSV, path, out errString); setProgressBarValue(4, status); if (!flag) { MessageBox.Show(errString); } stopProgressBar(); flag = true; } } catch (Exception e) { flag = false; result = e.Message; OtherUtils.writeMsgByByte(Constant.LOG_PATH, result + "\r\n" + e.ToString()); } finally { clearMemory(); } return(flag); }