public JsonResult TransferC10(string reportDate) { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.C10ExcelName)) { fileName = (string)Cache.Get(CacheList.C10ExcelName); //從Cache 抓資料Name } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); return(Json(result)); } string path = Path.Combine(projectFile, fileName); List <C10ViewModel> dataModel = new List <C10ViewModel>(); DateTime dt = DateTime.MinValue; DateTime.TryParse(reportDate, out dt); string errorMessage = string.Empty; using (FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read)) { string pathType = path.Split('.')[1]; //抓副檔名 var data = C0Repository.getExcel(pathType, stream, dt); dataModel = data.Item2; errorMessage = data.Item1; } if (!errorMessage.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = errorMessage; return(Json(result)); } #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.C10TransferTxtLog; //預設txt名稱 string configTxtName = ConfigurationManager.AppSettings["txtLogC0Name"]; if (!string.IsNullOrWhiteSpace(configTxtName)) { txtpath = configTxtName; //有設定webConfig且不為空就取代 } #endregion txtlog 檔案名稱 #region save C10 MSGReturnModel resultC10 = C0Repository.saveC10(dataModel, reportDate); //save to DB int v = 0; ///上傳檔案,版本皆為0 bool C10Log = CommonFunction.saveLog(Table_Type.C10, fileName, SetFile.ProgramName, resultC10.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name, v, dt); //寫sql Log TxtLog.txtLog(Table_Type.C10, resultC10.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save C10 result.RETURN_FLAG = resultC10.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.C10.ToString()); if (!result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.save_Fail .GetDescription(Table_Type.C10.ToString(), resultC10.DESCRIPTION); } } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
public ActionResult UploadTranLoadFile() { try { HttpPostedFileBase fb = Request.Files[0]; string tempGuid = Guid.NewGuid().ToString(); string folderPath = Server.MapPath(CHubConstValues.ChubTempFolder); FileInfo folder = new FileInfo(folderPath); if (!Directory.Exists(folder.FullName)) { Directory.CreateDirectory(folder.FullName); } //fb.filename - to get short file name parse string string errorLogName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + tempGuid + ".txt"; string errorLogWebName = "/temp/" + errorLogName; string errorLogFullName = folder.FullName + errorLogName; TxtLog txtLog = new TxtLog(); StringBuilder errorMsg = new StringBuilder(); errorMsg.AppendLine(string.Format("Current User:{0}", Session[CHubConstValues.SessionUser].ToString())); string fileFullName = folder.FullName + tempGuid + ".xlsx"; fb.SaveAs(fileFullName); NPOIExcelHelper excelHelper = new NPOIExcelHelper(fileFullName); DataTable dt = excelHelper.ExcelToDataTable(); //LogHelper.WriteLog("DT data:"+dt.Rows[0][3].ToString() +"|"+ dt.Rows[0][4].ToString() + "|" + dt.Rows[0][5].ToString()); //Delete temp file System.IO.File.Delete(fileFullName); if (dt == null || dt.Rows.Count == 0) { return(Json(new RequestResult(false, "No data in excel"))); } //DataTable dt = ExcelHelper.GetDTFromExcel(fileFullName); List <ITT_TRAN_LOAD> modelList = ClassConvert.ConvertDT2List <ITT_TRAN_LOAD>(dt); if (modelList == null || modelList.Count == 0) { return(Json(new RequestResult(false, "wrong excel struct"))); } int successCount = 0; int failCount = 0; foreach (var item in modelList) { if (item.INVOICE_NO != null && item.INVOICE_NO.Contains("/")) { string[] invoiceArray = item.INVOICE_NO.Split('/'); foreach (var inNo in invoiceArray) { ITT_TRAN_LOAD model = new ITT_TRAN_LOAD(); ClassConvert.DrawObj(item, model); model.INVOICE_NO = inNo.Trim(); string msgInside = SaveTranLoadAction(model); if (string.IsNullOrEmpty(msgInside)) { successCount++; LogHelper.WriteLog(string.Format("willBillNo:{0},Data:{1}", item.WILL_BILL_NO, JsonConvert.SerializeObject(item))); } else { failCount++; LogHelper.WriteErrorLog(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msgInside, JsonConvert.SerializeObject(item))); errorMsg.AppendLine(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msgInside, JsonConvert.SerializeObject(item))); //txtLog.log(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msgInside, JsonConvert.SerializeObject(item)), errorLogFullName); } } } else { //If no invoce no , do a prefill ation if (string.IsNullOrEmpty(item.INVOICE_NO)) { TranLoadPreFill result = PreFillTranLoadAction(item.WILL_BILL_NO); if (!string.IsNullOrEmpty(result.Msg)) { failCount++; LogHelper.WriteErrorLog(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, result.Msg, JsonConvert.SerializeObject(item))); errorMsg.AppendLine(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, result.Msg, JsonConvert.SerializeObject(item))); continue; } else { //prefill action item.INVOICE_NO = result.InvoiceNo; item.TRAN_TYPE = result.TranType; item.FROM_SYSTEM = result.FromSystem; } } string msg = SaveTranLoadAction(item); if (string.IsNullOrEmpty(msg)) { successCount++; LogHelper.WriteLog(string.Format("willBillNo:{0},Data:{1}", item.WILL_BILL_NO, JsonConvert.SerializeObject(item))); } else { failCount++; LogHelper.WriteErrorLog(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item))); errorMsg.AppendLine(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item))); } } } bool success = true; if (failCount > 0) { txtLog.log(errorMsg.ToString(), errorLogFullName); success = false; } return(Json(new RequestResult(success, string.Format("Total Lines:{0}, Success items:{1}, Fail items:{2}", modelList.Count, successCount, failCount), errorLogWebName))); } catch (Exception ex) { LogHelper.WriteLog("UploadTranLoadFile", ex); return(Json(new RequestResult(false, ex.Message))); } }
public JsonResult Transfer() { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 DateTime startTime = DateTime.Now; string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.A59ExcelName)) { fileName = (string)Cache.Get(CacheList.A59ExcelName); //從Cache 抓資料 } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); return(Json(result)); } string path = Path.Combine(projectFile, fileName); string pathType = path.Split('.')[1]; //抓副檔名 List <A59ViewModel> dataModel = new List <A59ViewModel>(); var A59result = A5Repository.getA59Excel(pathType, path, "Transfer"); if (A59result.Item1.IsNullOrWhiteSpace()) { dataModel = A59result.Item2; } else { result.RETURN_FLAG = false; result.DESCRIPTION = A59result.Item1; return(Json(result)); } #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.A59TransferTxtLog; //預設txt名稱 #endregion txtlog 檔案名稱 #region save 資料 #region save A59(A59=>A57=>A58) MSGReturnModel resultA59 = A5Repository.saveA59(dataModel); //save to DB bool A59Log = CommonFunction.saveLog(Table_Type.A59, fileName, SetFile.ProgramName, resultA59.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name, 0); //寫sql Log TxtLog.txtLog(Table_Type.A59, resultA59.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save A59(A59=>A57=>A58) result = resultA59; #endregion save 資料 } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.save_Fail .GetDescription(null, ex.Message); } return(Json(result)); }
public static Dictionary <string, Item> SearchAll(string status, string reqName, bool isnum_iid, string strMainWord, string sellerCat, SellerInfoEntity sellerinfo, int useplatform) { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "===" + status + " ::" + sellerinfo.top_session); Dictionary <string, Item> itemDic = new Dictionary <string, Item>(); StringBuilder strbNumIid = new StringBuilder(); long totalResults = 0; //宝贝总数 int pageNo = 0; //api查询页码 int pageNo2 = 0; //api查询页码 status = status == "3" ? null : status; if (string.IsNullOrWhiteSpace(status)) { #region 获取出售中的商品 do { pageNo++; ItemsOnsaleGetRequest req = new ItemsOnsaleGetRequest(); req.Fields = reqName; req.PageSize = 200L; req.PageNo = Convert.ToInt64(pageNo); req.OrderBy = "list_time:asc"; if (strMainWord.Length > 0) { req.Q = strMainWord; } if (sellerCat.Trim().Length > 0) { req.SellerCids = sellerCat; } ItemsOnsaleGetResponse response = TopClient.Execute <ItemsOnsaleGetResponse>(req, sellerinfo.top_session, (TopClient.CrmPlatForm)useplatform); if (response.IsError) { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:" + response.Body); } else { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:" + response.Body); totalResults = response.TotalResults; foreach (Item item in response.Items.Where(item => !itemDic.ContainsKey(item.NumIid.ToString()))) { if (isnum_iid) { strbNumIid.Append(item.NumIid.ToString() + ","); } else { itemDic.Add(item.NumIid.ToString(), item); } } } } while (totalResults > pageNo * 200); #endregion #region 获取仓库中的商品 do { pageNo2++; ItemsInventoryGetRequest req = new ItemsInventoryGetRequest { Fields = reqName, PageSize = 200, PageNo = pageNo2 }; if (strMainWord.Length > 0) { req.Q = strMainWord; } if (sellerCat.Trim().Length > 0) { req.SellerCids = sellerCat; } ItemsInventoryGetResponse response = TopClient.Execute(req, sellerinfo.top_session, (TopClient.CrmPlatForm)useplatform); if (response.IsError) { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:" + response.Body); } else { totalResults = response.TotalResults; foreach (Item item in response.Items.Where(item => !itemDic.ContainsKey(item.NumIid.ToString()))) { if (isnum_iid) { strbNumIid.Append(item.NumIid.ToString() + ","); } else { itemDic.Add(item.NumIid.ToString(), item); } } } } while (totalResults > pageNo2 * 200); #endregion } else { if (status == "0") { #region 获取出售中的商品 do { pageNo++; ItemsOnsaleGetRequest req = new ItemsOnsaleGetRequest(); req.Fields = reqName; req.PageSize = 200L; req.PageNo = Convert.ToInt64(pageNo); req.OrderBy = "list_time:asc"; if (strMainWord.Length > 0) { req.Q = strMainWord; } if (sellerCat.Trim().Length > 0) { req.SellerCids = sellerCat; } ItemsOnsaleGetResponse response = TopClient.Execute <ItemsOnsaleGetResponse>(req, sellerinfo.top_session, (TopClient.CrmPlatForm)useplatform); if (response.IsError) { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:" + response.Body); } else { totalResults = response.TotalResults; foreach (Item item in response.Items.Where(item => !itemDic.ContainsKey(item.NumIid.ToString()))) { if (isnum_iid) { strbNumIid.Append(item.NumIid.ToString() + ","); } else { itemDic.Add(item.NumIid.ToString(), item); } } } } while (totalResults > pageNo * 200); #endregion } else if (status == "1") { #region 获取仓库中的商品 do { pageNo++; ItemsInventoryGetRequest req = new ItemsInventoryGetRequest { Fields = reqName, PageSize = 200, PageNo = pageNo }; if (strMainWord.Length > 0) { req.Q = strMainWord; } if (sellerCat.Trim().Length > 0) { req.SellerCids = sellerCat; } ItemsInventoryGetResponse response = TopClient.Execute(req, sellerinfo.top_session, (TopClient.CrmPlatForm)useplatform); if (response.IsError) { TxtLog.WriteLine("getItemListErrorLog", sellerinfo.strUserNick + ":" + sellerinfo.strUserId + "=== :出现异常:" + response.Body); } else { totalResults = response.TotalResults; foreach (Item item in response.Items.Where(item => !itemDic.ContainsKey(item.NumIid.ToString()))) { if (isnum_iid) { strbNumIid.Append(item.NumIid.ToString() + ","); } else { itemDic.Add(item.NumIid.ToString(), item); } } } } while (totalResults > pageNo * 200); #endregion } } if (isnum_iid) { itemDic = SearchNumIid(strbNumIid.ToString(), sellerinfo, reqName, useplatform); } return(itemDic); }
public JsonResult Transfer(string reportDate, string version) { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 DateTime startTime = DateTime.Now; string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.A41ExcelName)) { fileName = (string)Cache.Get(CacheList.A41ExcelName); //從Cache 抓資料 } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); } string path = Path.Combine(projectFile, fileName); FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read); string pathType = path.Split('.')[1]; //抓副檔名 List <A41ViewModel> dataModel = A4Repository.getExcel(pathType, stream); //Excel轉成 Exhibit10Model #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.A41TransferTxtLog; //預設txt名稱 string configTxtName = ConfigurationManager.AppSettings["txtLogA4Name"]; if (!string.IsNullOrWhiteSpace(configTxtName)) { txtpath = configTxtName; //有設定webConfig且不為空就取代 } #endregion txtlog 檔案名稱 #region save Bond_Account_Info(A41) MSGReturnModel resultA41 = A4Repository.saveA41(dataModel, reportDate, version); //save to DB bool A41Log = CommonFunction.saveLog(Table_Type.A41, fileName, SetFile.ProgramName, resultA41.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A41, resultA41.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Bond_Account_Info(A41) result.RETURN_FLAG = resultA41.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.A41.ToString()); if (!result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.save_Fail .GetDescription(Table_Type.A41.ToString(), resultA41.DESCRIPTION); } } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.Message; } return(Json(result)); }
public JsonResult Transfer() { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 DateTime startTime = DateTime.Now; string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.A71ExcelName)) { fileName = (string)Cache.Get(CacheList.A71ExcelName); //從Cache 抓資料 } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); } string path = Path.Combine(projectFile, fileName); FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read); string pathType = path.Split('.')[1]; //抓副檔名 List <Exhibit29Model> dataModel = A7Repository.getExcel(pathType, stream); //Excel轉成 Exhibit29Model #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.A71TransferTxtLog; //預設txt名稱 string configTxtName = ConfigurationManager.AppSettings["txtLogA7Name"]; if (!string.IsNullOrWhiteSpace(configTxtName)) { txtpath = configTxtName; //有設定webConfig且不為空就取代 } #endregion txtlog 檔案名稱 #region save 資料 #region save Moody_Tm_YYYY(A71) MSGReturnModel resultA71 = A7Repository.saveA71(dataModel); //save to DB bool A71Log = CommonFunction.saveLog(Table_Type.A71, fileName, SetFile.ProgramName, resultA71.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A71, resultA71.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Moody_Tm_YYYY(A71) #region save Tm_Adjust_YYYY(A72) MSGReturnModel resultA72 = A7Repository.saveA72(); //save to DB bool A72Log = CommonFunction.saveLog(Table_Type.A72, fileName, SetFile.ProgramName, resultA72.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A72, resultA72.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Tm_Adjust_YYYY(A72) #region save GM_YYYY(A73) MSGReturnModel resultA73 = A7Repository.saveA73(); //save to DB bool A73Log = CommonFunction.saveLog(Table_Type.A73, fileName, SetFile.ProgramName, resultA73.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A73, resultA73.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save GM_YYYY(A73) #region save Grade_Moody_Info(A51) MSGReturnModel resultA51 = A7Repository.saveA51(); //save to DB bool A51Log = CommonFunction.saveLog(Table_Type.A51, fileName, SetFile.ProgramName, resultA51.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A51, resultA51.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Grade_Moody_Info(A51) result.RETURN_FLAG = resultA71.RETURN_FLAG && resultA72.RETURN_FLAG && resultA73.RETURN_FLAG && resultA51.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription( string.Format("{0},{1},{2},{3}", Table_Type.A71.ToString(), Table_Type.A72.ToString(), Table_Type.A73.ToString(), Table_Type.A51.ToString() )); if (!result.RETURN_FLAG) { List <string> errs = new List <string>(); if (!resultA71.RETURN_FLAG) { errs.Add(resultA71.DESCRIPTION); } if (!resultA72.RETURN_FLAG) { errs.Add(resultA72.DESCRIPTION); } if (!resultA73.RETURN_FLAG) { errs.Add(resultA73.DESCRIPTION); } if (!resultA51.RETURN_FLAG) { errs.Add(resultA51.DESCRIPTION); } result.DESCRIPTION = Message_Type.save_Fail .GetDescription(null, string.Join("\n", errs)); } #endregion save 資料 } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.save_Fail .GetDescription(null, ex.Message); } return(Json(result)); }
private void ServiceControlWindow_Load(object sender, EventArgs e) { ServiceLogger.Instance.Logger = m => TxtLog.AppendText(m + Environment.NewLine); BtnRefresh_Click(null, null); }
protected override void PageLoad() { base.PageLoad(); base.Title = "最小学习量达成分析表"; base.CheckUserPower("ReadEMSReport", PowerCheckType.Single); string logPath = ServerHelper.MapPath(@"\Log\"); TxtLog log = new TxtLog(logPath); Stopwatch time2 = new Stopwatch(); time2.Start(); if (CompanyID < 0) { CompanyID = base.UserCompanyID; } CompanyInfo company = CompanyBLL.ReadCompany(CompanyID); PostList = PostBLL.ReadPostListByPostId(company.Post); if (base.ExistsSonCompany) { userGroupList = AdminGroupBLL.ReadAdminGroupList(CompanyID, UserBLL.ReadUserGroupIDByCompanyID(base.SonCompanyID)); } else { userGroupList = AdminGroupBLL.ReadAdminGroupList(CompanyID, UserBLL.ReadUserGroupIDByCompanyID(CompanyID.ToString())); } //设置默认岗位(去除待考岗位) //if (string.IsNullOrEmpty(PostIdCondition)) PostIdCondition = StringHelper.SubString(company.Post, "197"); //if (string.IsNullOrEmpty(StudyPostIdCondition)) StudyPostIdCondition = StringHelper.SubString(company.Post, "197"); //用户权限组默认给考试人员 if (string.IsNullOrEmpty(groupID)) { groupID = "36"; } if (Action == "Search") { if (EndDate == DateTime.MinValue) { EndDate = DateTime.Today; } EndDate = ShopCommon.SearchEndDate(EndDate); if (base.CompareUserPower("ManageGroupCompany", PowerCheckType.Single) && base.IsGroupCompany(company.GroupId)) { List <CompanyInfo> sonCompanyList = base.SonCompanyList; //减少使用递归方法的频率 if (CompanyID != base.UserCompanyID) { sonCompanyList = CompanyBLL.ReadCompanyListByCompanyId(CompanyBLL.ReadCompanyIdList(CompanyID.ToString())); } GroupResult.Add(company.CompanySimpleName + "合计"); GroupResult.Add(0); GroupResult.Add(0); GroupResult.Add(0); GroupResult.Add(""); GroupResult.Add(""); StringBuilder TotalTable = new StringBuilder(); TotalTable.AppendLine("<table class=\"evaluation_sheet\">"); TotalTable.AppendLine("<tr>"); TotalTable.AppendLine("<th colspan=\"5\">" + company.CompanySimpleName + " [" + StartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d") + "]"); TotalTable.Append("</th>"); TotalTable.AppendLine("</tr>"); TotalTable.AppendLine("<tr>"); TotalTable.AppendLine("<th>公司名</th>"); TotalTable.AppendLine("<th>参加岗位考试人数</th>"); TotalTable.AppendLine("<th>最小学习量<br />学习达标人数</th>"); TotalTable.AppendLine("<th>最小学习量<br />学习未达标人数</th>"); TotalTable.AppendLine("<th>最小学习量<br />学习达成率</th>"); TotalTable.AppendLine("</tr>"); foreach (CompanyInfo info in sonCompanyList) { if (info.CompanyId != CompanyID && !string.IsNullOrEmpty(info.PostStartDate.ToString()) && Convert.ToDateTime(info.PostStartDate) < EndDate) { TotalTable.Append(HtmlOut1(info, "TotalTable")); } } TotalTable.AppendLine("<tr>"); TotalTable.AppendLine("<td>" + GroupResult[0] + "</td>"); TotalTable.AppendLine("<td>" + GroupResult[1] + "</td>"); TotalTable.AppendLine("<td>" + GroupResult[2] + "</td>"); TotalTable.AppendLine("<td>" + GroupResult[3] + "</td>"); TotalTable.AppendLine("<td>" + (double.Parse(GroupResult[2].ToString()) / double.Parse(GroupResult[1].ToString())).ToString("P") + "</td>"); TotalTable.AppendLine("</tr>"); TotalTable.AppendLine("</table>"); TotalTable.Append("<div style=\"line-height:25px; text-align:left; font-size:14px;\"><p style=\"text-align:left; font-size:14px; line-heigh:30px; margin-top:20px;\">4S店每人每周完成1-2小时的基础学习,将带动公司提升“百年老店”运营,建议高标为100%,低标为70%。"); if (!string.IsNullOrEmpty(GroupResult[4].ToString())) { TotalTable.Append("<br /><br />目前:<span style=\"color:#00b050;\">" + GroupResult[4] + "</span> 达至 <span style=\"color:#00b050;\">100%</span> ,表现良好,予以肯定。"); } if (!string.IsNullOrEmpty(GroupResult[5].ToString())) { TotalTable.Append("<br /><br /><span style=\"color:#FF0000;\">" + GroupResult[5] + "</span> 达成率尚不足 <span style=\"color:#FF0000;\">70%</span> ,请相关部门领导关注下属自主学习时间的妥善安排。"); } TotalTable.Append("</p></div>\r\n"); ReportContentHtml = TotalTable.ToString(); } else { ReportContentHtml = HtmlOut1(company, ""); } } time2.Stop(); log.Write("总执行时间为:" + time2.Elapsed.TotalSeconds); }
public JsonResult TransferA96() { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.A96ExcelName)) { fileName = (string)Cache.Get(CacheList.A96ExcelName); //從Cache 抓資料 } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); return(Json(result)); } string path = Path.Combine(projectFile, fileName); List <A96ViewModel> dataModel = new List <A96ViewModel>(); string errorMessage = string.Empty; using (FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read)) { //Excel轉成 Exhibit10Model string pathType = path.Split('.')[1]; //抓副檔名 var data = A9Repository.getA96Excel(pathType, stream); dataModel = data.Item2; errorMessage = data.Item1; } if (!errorMessage.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = errorMessage; return(Json(result)); } #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.A96TransferTxtLog; //預設txt名稱 #endregion txtlog 檔案名稱 #region save Bond_Spread_Info(A96) MSGReturnModel resultA96 = A9Repository.saveA96(dataModel); //save to DB CommonFunction.saveLog(Table_Type.A96, fileName, SetFile.ProgramName, resultA96.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name); //寫sql Log TxtLog.txtLog(Table_Type.A96, resultA96.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Bond_Spread_Info(A96) result.RETURN_FLAG = resultA96.RETURN_FLAG; result.DESCRIPTION = Message_Type.save_Success.GetDescription(Table_Type.A96.ToString()); if (!result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.save_Fail .GetDescription(Table_Type.A96.ToString(), resultA96.DESCRIPTION); } } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = ex.exceptionMessage(); } return(Json(result)); }
private void SaveWindows() { mWindowsParams = new List <WindowParams>(); EnumWindows(new EnumWindowsProc(EnumTheWindows), IntPtr.Zero); // Has now hWindList TxtLog.Clear(); // mWindowsParams = new List<WindowParams>(); String txt = "SAVE:" + Environment.NewLine; txt += "Num windows: " + mWindowsParams.Count + Environment.NewLine; //var processlist = Process.GetProcesses() // .Where(p => p.MainWindowHandle != IntPtr.Zero); //foreach (Process process in processlist) //{ foreach (WindowParams winParam in mWindowsParams) { //if (!String.IsNullOrEmpty(process.MainWindowTitle)) //{ //IntPtr hwnd = process.MainWindowHandle; //GetWindowRect(winParam.hWndPtr, out Rectangle rect); //if (winParam.rect.Top == 0 && winParam.rect.Left == 0) // continue; //if (process.ProcessName == "ApplicationFrameHost") // continue; //if (winParam.rect.Top > -1000) // Else assumed minimized //{ //txt += String.Format("Saving process '{0}' (id {1})(title '{2}': ", // process.ProcessName, // process.Id, // process.MainWindowTitle); txt += "Title '" + winParam.title + "': "; txt += "Top=" + winParam.rect.Top; txt += ",Left=" + winParam.rect.Left; txt += ",Height=" + winParam.rect.Height; txt += ",Width=" + winParam.rect.Width; txt += ",winState=" + winParam.windowState; txt += Environment.NewLine; //mWindowsParams.Add(new WindowParams() //{ // hWndPtr = hwnd, // processName = "", // processId = 0, // top = rect.Top, // left = rect.Left, // width = rect.Width, // height = rect.Height //}); //} //} } TxtLog.Text = txt; }
private void BtnClearLog_Click(object sender, RoutedEventArgs e) { TxtLog.Clear(); }
public ActionResult AddUser() { StreamReader reader = new StreamReader(Request.InputStream); reader.DiscardBufferedData(); reader.BaseStream.Seek(0, SeekOrigin.Begin); reader.BaseStream.Position = 0; string json = HttpUtility.UrlDecode(reader.ReadToEnd()); var jo = (JObject)JsonConvert.DeserializeObject(json); string openid = (string)jo["openid"]; TxtLog log = new TxtLog(Server.MapPath("/apilog/")); log.Write(json); //JObject jo = JsonConvert.DeserializeObject(userinfo) as JObject; if (jo != null) { var checkuser = UserBLL.Read(openid); int userid = checkuser.Id; if (checkuser.Id <= 0) { //string UserName = jo["userInfo"]["nickName"].ToString(); checkuser = new UserInfo() { //UserName = UserName, UserName = openid, UserPassword = StringHelper.Password("123123", PasswordType.MD532), //Photo = jo["userInfo"]["avatarUrl"].ToString(), RegisterDate = DateTime.Now, LastLoginDate = DateTime.Now, LoginTimes = 1, RegisterIP = ClientHelper.IP, LastLoginIP = ClientHelper.IP, FindDate = RequestHelper.DateNow, Status = (int)UserStatus.Normal, //性别默认保密 Sex = 3, //Sex = Convert.ToInt32(jo["userInfo"]["gender"].ToString()), OpenId = openid, // 推荐人 默认为0,进入小程序首页再更新 Recommend_UserId = 0, //如果开启了需要审核成为分销商则分销状态=》待审核,否则=》正常 Distributor_Status = ShopConfig.ReadConfigInfo().CheckToBeDistributor == 0?(int)Distributor_Status.Normal:(int)Distributor_Status.WaitCheck, //总佣金 Total_Commission = 0, //总提现 Total_Withdraw = 0 }; userid = UserBLL.Add(checkuser); #region 注册赠送优惠券(限新人领取1次) /* * int count = 0; * var couponlist = CouponBLL.SearchList(1, 1, new CouponSearchInfo { Type = (int)CouponKind.RegisterGet, CanUse = 1 }, ref count); * if (couponlist.Count > 0) * { * UserCouponInfo userCoupon = UserCouponBLL.ReadLast(couponlist[0].Id); * int startNumber = 0; * if (userCoupon.Id > 0) * { * string tempNumber = userCoupon.Number.Substring(3, 5); * while (tempNumber.Substring(0, 1) == "0") * { * tempNumber = tempNumber.Substring(1); * } * startNumber = Convert.ToInt32(tempNumber); * } * startNumber++; * int cpid = UserCouponBLL.Add(new UserCouponInfo * { * UserId = userid, * //UserName = UserName, * UserName = openid, * CouponId = couponlist[0].Id, * GetType = (int)CouponType.RegisterGet, * Number = ShopCommon.CreateCouponNo(couponlist[0].Id, startNumber), * Password = ShopCommon.CreateCouponPassword(startNumber), * IsUse = (int)BoolType.False, * OrderId = 0 * * }); * //领取成功,改变usr表标识 * if (cpid > 0) * { * Dictionary<string, object> dict = new Dictionary<string, object>(); * dict.Add("[HasRegisterCoupon]", 1); * UserBLL.UpdatePart("[usr]", dict, userid); * } * } */ #endregion } var vuser = new { id = userid, name = checkuser.UserName, avatar = checkuser.Photo, status = checkuser.Status }; return(Json(new { flag = true, userinfo = vuser, thesessionid = Session.SessionID })); } else { return(Json(new { flag = false, msg = "json 转换错误" })); } }
public JsonResult autoTransfer(string datepicker, string version) { string sType = "原始投資信評"; string portfolio = "All"; string search = "Miss"; string from = ""; string to = ""; string bondNumber = ""; MSGReturnModel result_searchA58 = new MSGReturnModel(); MSGReturnModel result_getA59 = new MSGReturnModel(); MSGReturnModel result_saveA59Excel = new MSGReturnModel(); MSGReturnModel result_autoTransfer = new MSGReturnModel(); result_searchA58.RETURN_FLAG = false; result_getA59.RETURN_FLAG = false; result_autoTransfer.RETURN_FLAG = false; #region 找A58缺漏 var A58Data = A5Repository.GetA58(datepicker, sType, from, to, bondNumber, version, search, portfolio); result_searchA58.RETURN_FLAG = A58Data.Item1; #endregion #region 轉入寶碩信評資料 if (!A58Data.Item1) { result_searchA58.DESCRIPTION = Message_Type.not_Find_Any.GetDescription(); return(Json(result_searchA58)); } var A59Data = A5Repository.getA59(A58Data.Item2, datepicker); if (!A59Data.Item1) { result_getA59.DESCRIPTION = Message_Type.not_Find_CounterPartyCreditRating.GetDescription(); GetCheckDataToCache(); return(Json(result_getA59)); } #region 產excel出來 var A59Filled = Excel_DownloadName.A59Filled.ToString(); var fileName = string.Format("{0}.{1}", Excel_DownloadName.A59Filled.GetDescription(), "xlsx"); //固定轉成此名稱 //檢查資料夾是否存在 string projectFile = Server.MapPath("~/" + SetFile.FileUploads); //專案資料夾 string path = Path.Combine(projectFile, fileName); FileRelated.createFile(projectFile); //檢查是否有FileUploads資料夾,如果沒有就新增 result_saveA59Excel = A5Repository.SaveA59Excel(A59Filled, path, A59Data.Item2); //儲存excel失敗不用中止,只要記錄就好 DateTime startTime = DateTime.Now; DateTime reportdate = DateTime.MinValue; DateTime.TryParse(datepicker, out reportdate); bool A59Log = CommonFunction.saveLog(Table_Type.A59, fileName, SetFile.ProgramName, result_saveA59Excel.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now, AccountController.CurrentUserInfo.Name, Convert.ToInt32(version), reportdate); //寫sql Log #endregion 測試產excel出來看 #endregion #region 更新A57、A58 #region txtlog 檔案名稱 string txtpath = SetFile.A59TransferTxtLog; //預設txt名稱 #endregion txtlog 檔案名稱 #region save A59(A59=>A57=>A58) DateTime st_saveA59 = DateTime.Now; result_autoTransfer = A5Repository.saveA59(A59Data.Item2); A5Repository.SaveA59TransLog(result_autoTransfer, datepicker, st_saveA59, Convert.ToInt32(version)); TxtLog.txtLog(Table_Type.A59Trans, result_autoTransfer.RETURN_FLAG, st_saveA59, txtLocation(txtpath)); //寫txt Log #endregion save A59(A59=>A57=>A58) #endregion 更新A57、A58 #region 執行檢核 A5Repository.GetA58TransferCheck(reportdate, Convert.ToInt32(version)); GetCheckDataToCache(); #endregion 執行檢核 return(Json(result_autoTransfer)); }
public ActionResult UploadCustLoadFile() { try { HttpPostedFileBase fb = Request.Files[0]; string tempGuid = Guid.NewGuid().ToString(); string folderPath = Server.MapPath(CHubConstValues.ChubTempFolder); FileInfo folder = new FileInfo(folderPath); if (!Directory.Exists(folder.FullName)) { Directory.CreateDirectory(folder.FullName); } //fb.filename - to get short file name parse string string errorLogName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + tempGuid + ".txt"; string errorLogWebName = "/temp/" + errorLogName; string errorLogFullName = folder.FullName + errorLogName; TxtLog txtLog = new TxtLog(); StringBuilder errorMsg = new StringBuilder(); errorMsg.AppendLine(string.Format("Current User:{0}", Session[CHubConstValues.SessionUser].ToString())); string fileFullName = folder.FullName + tempGuid + ".xlsx"; fb.SaveAs(fileFullName); NPOIExcelHelper excelHelper = new NPOIExcelHelper(fileFullName); DataTable dt = excelHelper.ExcelToDataTable(); //Delete temp file System.IO.File.Delete(fileFullName); if (dt == null || dt.Rows.Count == 0) { return(Content("No data in excel")); } //DataTable dt = ExcelHelper.GetDTFromExcel(fileFullName); List <ITT_CUST_LOAD> modelList = ClassConvert.ConvertDT2List <ITT_CUST_LOAD>(dt); if (modelList == null || modelList.Count == 0) { return(Content("wrong excel strut")); } int successCount = 0; int failCount = 0; foreach (var item in modelList) { string msg = SaveCustLoadAction(item); if (string.IsNullOrEmpty(msg)) { successCount++; LogHelper.WriteLog(string.Format("willBillNo:{0},data:{1}", item.WILL_BILL_NO, JsonConvert.SerializeObject(item))); } else { failCount++; LogHelper.WriteErrorLog(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item))); errorMsg.AppendLine(string.Format("willBillNo:{0},message:{1},data:{2}", item.WILL_BILL_NO, msg, JsonConvert.SerializeObject(item))); } } bool success = true; if (failCount > 0) { txtLog.log(errorMsg.ToString(), errorLogFullName); success = false; } return(Json(new RequestResult(success, string.Format("Total Lines:{0}, Success items:{1}, Fail items:{2}", modelList.Count, successCount, failCount), errorLogWebName))); //return Content(string.Format("Total Lines:{0}, Success items:{1}, Fail items:{2}", modelList.Count, successCount, failCount)); } catch (Exception ex) { LogHelper.WriteLog("save Cust load", ex); return(Json(new RequestResult(false, ex.Message))); } }
/// <summary> /// 受信文字の解読 /// </summary> /// <param name="text"></param> private void text_parser(string text) { try { text = text.Replace("\r", ""); string[] split_str = text.Split(','); //描画タスク BeginInvoke((Action) delegate() { UInt32 r; double d; if (!double.TryParse(split_str[0], out d) && !UInt32.TryParse(split_str[0], NumberStyles.AllowHexSpecifier, new CultureInfo("en-US"), out r)) { if (split_str[0].Equals("READ_TEMP")) { TempLabel.Text = double.Parse(split_str[1]).ToString("F3") + "℃"; } else if (split_str[0].Equals("PAGE_DUMP")) { int j = 0; for (int i = 2; i < split_str.Length; i++) { this.dataGridView1.Rows.Add(new Object[] { split_str[1], "0x" + j.ToString("X2"), split_str[i] }); j += 2; } } else if (split_str[0].StartsWith("ERROR") || split_str[0].StartsWith("ERR")) { if (split_str[0].StartsWith("ERROR_PRODUCT_ID_INCORRECT")) { Disconnect(); DialogResult result = MessageBox.Show(Resources.Sens_Inco_Str, Resources.Error_Str, MessageBoxButtons.OK); } else if (split_str[0].Equals("ERR_NONE_CMD") || split_str[0].Equals("ERROR_NONE_CMD")) { if (split_str[1].Equals("DUMP_PARAM")) { Disconnect(); DialogResult result = MessageBox.Show(Resources.Old_firm_Str, Resources.Error_Str, MessageBoxButtons.OK); } } else if (split_str[0].Equals("ERROR_GET_FORMAT")) { Disconnect(); DialogResult result = MessageBox.Show(Resources.Format_Err_Str, Resources.Error_Str, MessageBoxButtons.OK); } } else if (split_str[0].Equals("DUMP_PARAM")) { VersionLabel.Text = split_str[1]; Kp_val.Value = (decimal)double.Parse(split_str[2]); Ki_val.Value = (decimal)double.Parse(split_str[3]); SendCycleNum.Value = (decimal)double.Parse(split_str[4]); StartupTimeNum.Value = (decimal)double.Parse(split_str[5]); } else if (split_str[0].Equals("GET_FORMAT")) { lines.Clear(); myPlotModel.Series.Clear(); csv_format = ""; for (int i = 0; i < split_str.Length - 1; i++) { LineSeries myLine = new LineSeries(); myLine.Title = split_str[i + 1]; myPlotModel.Series.Add(myLine); lines.Add(myLine); csv_format += split_str[i + 1] + ","; } Debug.WriteLine("軸数:" + myPlotModel.Series.Count); } else if (split_str[0].Equals("GET_PROD_ID")) { ProductIdLabel.Text = split_str[1]; } else if (split_str[0].Equals("GET_SENSI")) { Gyro_Sensi = double.Parse(split_str[1]); Acc_Sensi = double.Parse(split_str[2]); } else if (split_str[0].Equals("SET_SEND_CYCLE")) { SendCycleNum.Value = (decimal)double.Parse(split_str[1]); } else if (split_str[0].Equals("SET_STARTUP_TIME")) { StartupTimeNum.Value = (decimal)double.Parse(split_str[1]); } else if (split_str[0].Equals("GET_BOARD_NAME")) { BoardNameLabel.Text = split_str[1]; } else if (split_str[0].Equals("GET_VERSION")) { VersionLabel.Text = split_str[1]; } else if (split_str[0].Equals("GET_STATUS")) { if (split_str[1].Equals("AutoBiasUpdating")) { int time = int.Parse(split_str[2]); StatusLabel.Text = Resources.Bias_Updating_Str + time + Resources.Sec_Str; StatusUpdateTimer.Start(); StartBtn.Enabled = false; StopBtn.Enabled = false; } else if (split_str[1].Equals("Ready")) { StatusLabel.Text = Resources.Ready_Str; StatusUpdateTimer.Stop(); StartBtn.Enabled = true; StopBtn.Enabled = false; } else if (split_str[1].Equals("Running")) { StatusLabel.Text = Resources.Running_Str; StatusUpdateTimer.Stop(); StartBtn.Enabled = false; StopBtn.Enabled = true; } } else { } TxtLog.AppendText(text + "\r\n"); } else { recv_cnt++; int dat_len = SAMPLING_CNT;//サンプル数(X軸) List <double> dat_list = new List <double>(); if (UInt32.TryParse(split_str[0], NumberStyles.AllowHexSpecifier, new CultureInfo("en-US"), out r)) { for (int i = 0; i < 3; i++) { UInt32 result; UInt32.TryParse(split_str[i], NumberStyles.AllowHexSpecifier, new CultureInfo("en-US"), out result); dat_list.Add((double)((Int32)result / Gyro_Sensi * Math.PI / 180.0)); } for (int i = 3; i < 6; i++) { UInt32 result; UInt32.TryParse(split_str[i], NumberStyles.AllowHexSpecifier, new CultureInfo("en-US"), out result); dat_list.Add((double)((Int32)result * 9.80665 / Acc_Sensi)); } dat_list.Add(0); //CSUM } else { for (int i = 0; i < split_str.Length; i++) { dat_list.Add(double.Parse(split_str[i])); } } //エラー回避 if (lines.Count != dat_list.Count) { return; } //X軸の限界数以下であれば普通に保存する if (lines[0].Points.Count < dat_len) { for (int i = 0; i < dat_list.Count; i++) { lines[i].Points.Add(new OxyPlot.DataPoint(lines[i].Points.Count, dat_list[i])); } } else //X軸の限界数を上回ろうとしたら最後尾のデータを消して先頭に最新データを入れる。 { //先頭にデータが格納できるようにデータをズラす for (int i = 1; i < dat_len; i++) { for (int j = 0; j < dat_list.Count; j++) { lines[j].Points[i - 1] = new OxyPlot.DataPoint(lines[j].Points[i].X - 1, lines[j].Points[i].Y); } } //最後尾のデータを削除して、最新データを入力していく for (int i = 0; i < dat_list.Count; i++) { lines[i].Points.RemoveAt(dat_len - 1); lines[i].Points.Add(new OxyPlot.DataPoint(lines[i].Points.Count, dat_list[i])); } } plotView1.Invalidate(); // --(2) , ここでデータの変更が反映され、PlotViewが更新される myPlotModel.InvalidatePlot(true); // -- (3) , ここで軸設定が反映され、PlotViewが更新される if (LogFile != null) { LogFile.WriteLine(text); } } }); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void BtnAdd_Click(object sender, EventArgs e) { Animal animal = Animal.make(CbKinds.SelectedItem.ToString(), TxtName.Text); TxtLog.AppendText(animal.ToString() + Environment.NewLine); }
void WriteLog(string Msg) { TxtLog.AppendText(Msg); TxtLog.AppendText(Environment.NewLine); }
protected string HtmlOut1(CompanyInfo company, string Type) { int WeekNum = 0, ColNum = 10, PeoperNum = 0; string logPath = ServerHelper.MapPath(@"\Log\"); TxtLog log = new TxtLog(logPath); Stopwatch time1 = new Stopwatch(); time1.Start(); StringBuilder TextOut = new StringBuilder(); string CompanyBrandId = company.BrandId; DateTime PostPlanStartDate = DateTime.MinValue; if (string.IsNullOrEmpty(company.PostStartDate.ToString())) { PostPlanStartDate = Convert.ToDateTime("2013-7-1"); } else { PostPlanStartDate = Convert.ToDateTime(company.PostStartDate.ToString()); } string rowspan = string.Empty; TextOut.Append("<table class=\"evaluation_sheet\">"); TextOut.Append("<tr>"); if (StartDate != DateTime.MinValue) { WeekNum = (EndDate - StartDate).Days / 7; if ((EndDate - StartDate).Days % 7 > 0) { WeekNum = WeekNum + 1; } TextOut.Append("<th colspan=\"" + (ColNum + WeekNum * 3) + "\">" + company.CompanySimpleName + " [" + StartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d") + "]"); rowspan = " rowspan=\"3\""; } else { TextOut.Append("<th colspan=\"" + ColNum + "\">" + company.CompanySimpleName + " [ 截止到:" + EndDate.AddDays(-1).ToString("d") + " ]"); rowspan = " rowspan=\"3\""; } TextOut.Append("</th></tr>\r\n"); TextOut.Append("<tr>\r\n"); TextOut.Append("<th" + rowspan + " class=\"id\">序号</th>"); //if (base.IsGroupCompany(company.GroupId)) TextOut.Append("<th" + rowspan + ">公司名</th>"); TextOut.Append("<th" + rowspan + " class=\"name\">姓名</th>"); TextOut.Append("<th" + rowspan + " class=\"post\">工作岗位</th>"); TextOut.Append("<th" + rowspan + " class=\"post\">学习岗位</th>"); TextOut.Append("<th colspan=\"" + (WeekNum * 3).ToString() + "\">学习已通过</th>"); TextOut.Append("<th colspan=\"3\">合计<br />("); if (StartDate != DateTime.MinValue) { TextOut.Append(StartDate.ToString("d") + "—" + EndDate.AddDays(-1).ToString("d")); } else { TextOut.Append("截止到:" + EndDate.AddDays(-1).ToString("d")); StartDate = PostPlanStartDate; } TextOut.Append(")</th>"); TextOut.Append("<th colspan=\"3\">从项目启动开始</th>"); TextOut.Append("</tr>\r\n"); TextOut.Append("<tr>\r\n"); for (int j = 1; j <= WeekNum; j++) { TextOut.Append("<th colspan=\"3\">第" + j.ToString() + "周<br>" + StartDate.AddDays(7 * (j - 1)).ToString("M-d") + "—"); if (j == WeekNum) { TextOut.Append(EndDate.AddDays(-1).ToString("M-d") + "</th>"); } else { TextOut.Append(StartDate.AddDays((7 * j) - 1).ToString("M-d") + "</th>"); } } TextOut.Append("<th rowspan=\"2\" class=\"total\">累计学习<br />考试次数</th>"); TextOut.Append("<th rowspan=\"2\" class=\"total\">考试通过<br />课程数量</th>"); TextOut.Append("<th rowspan=\"2\" class=\"total\">课程考试<br />通过率</th>"); TextOut.Append("<th rowspan=\"2\" class=\"total\">累计<br>完成总数</th>"); TextOut.Append("<th rowspan=\"2\" class=\"total\">目标<br>完成总数<br>(实际数)</th>"); TextOut.Append("<th rowspan=\"2\" class=\"total\">学习进度<br>达成分析<br>(超前/落后)</th>"); TextOut.Append("</tr>\r\n"); TextOut.Append("<tr class=\"listTableHead\">\r\n"); for (int j = 1; j <= WeekNum; j++) { TextOut.Append("<th class=\"total\">累计学习<br />考试次数</th>"); TextOut.Append("<th class=\"total\">考试通过<br />课程数量</th>"); TextOut.Append("<th class=\"total\">课程考试<br />通过率</th>"); } TextOut.Append("</tr>\r\n"); //统计目标课程数 int TargetNum = 0, CompanyDelayNum = 0; //统计通过课程数量第一的数据信息 string PassCourseFirstUser = string.Empty, GoodStudent = string.Empty; int FirstPassCourseNum = 0; //单个岗位的岗位计划开始时间 DateTime PostStartDate = DateTime.MinValue; int PostSign = 0; //是否重新计算岗位总数的标记 int PostCourseNum = 0; //岗位课程数 string AllPostPlan = "0"; //岗位下所有级别的岗位课程 int RedNum = 0, YellowNum = 0, GreenNum = 0; //增加通过率所用补丁部分 TestPaperInfo TestPaperModel = new TestPaperInfo(); if (!string.IsNullOrEmpty(company.PostStartDate.ToString())) { TestPaperModel.TestMinDate = Convert.ToDateTime(company.PostStartDate); } TestPaperModel.TestMaxDate = EndDate; TestPaperModel.CompanyIdCondition = company.CompanyId.ToString(); TestPaperModel.Condition = "[UserID] in (select [ID] from [_User] where [companyID]=" + company.CompanyId.ToString() + " and [status]=" + (int)UserState.Normal; if (!string.IsNullOrEmpty(groupID)) { TestPaperModel.Condition += " and [GroupID] in (" + groupID + ")"; } if (!string.IsNullOrEmpty(PostIdCondition)) { TestPaperModel.Condition += " and [WorkingPostID] in (" + PostIdCondition + ")"; } if (!string.IsNullOrEmpty(StudyPostIdCondition)) { TestPaperModel.Condition += " and [StudyPostId] in (" + StudyPostIdCondition + ")"; } TestPaperModel.Condition += ")"; List <TestPaperInfo> TestPaperList = TestPaperBLL.NewReadList(TestPaperModel); UserSearchInfo userSearch = new UserSearchInfo(); userSearch.Status = (int)UserState.Normal; userSearch.InWorkingPostID = PostIdCondition; //if (base.IsGroupCompany(company.GroupId)) //{ // userSearch.InCompanyID = CompanyBLL.ReadCompanyIdList(company.CompanyId.ToString()); // ColNum = 11; // userSearch.InStudyPostID = "45";//集团打开默认显示学习岗位 //} //else { userSearch.InCompanyID = company.CompanyId.ToString(); userSearch.InStudyPostID = StudyPostIdCondition; //只显示该学习岗位下的人员 } userSearch.InGroupID = groupID; List <UserInfo> userList = UserBLL.SearchReportUserList(userSearch); //记录岗位课程ID串 Dictionary <int, string[]> postCourseDic = new Dictionary <int, string[]>(); time1.Stop(); log.Write("执行到会员开始循环的时间为:" + time1.Elapsed.TotalSeconds); time1.Reset(); foreach (UserInfo Info in userList) { time1.Reset(); time1.Start(); int PostId = int.MinValue, PerPassCourseNum = 0, PerCourseNum = 0; PostId = Info.StudyPostID; PostInfo PostModel = PostBLL.ReadPost(PostId); if (PostModel != null) //排除掉没有设置岗位的人 { //筛选出当前用户ID的成绩列表 List <TestPaperInfo> currentUserPaperList = TestPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.UserId == Info.ID); }); List <TestPaperInfo> currentUserPassPaperList = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.IsPass == 1); }); int ResidueCourseNum = 0;//岗位内剩余岗位课程数 if (!postCourseDic.ContainsKey(PostId)) { //岗位数据信息 1:岗位课程ID串;2:岗位课程数量;3:岗位开始时间;4:目标课程数量 string[] postData = { "0", "0", DateTime.MinValue.ToString(), "0" }; AllPostPlan = PostBLL.ReadPostCourseID(company.CompanyId, PostId); postData[0] = AllPostPlan; if (!string.IsNullOrEmpty(AllPostPlan)) { PostCourseNum = AllPostPlan.Split(',').Length; postData[1] = PostCourseNum.ToString(); } //公司有事耽误的数量 由于岗位不一样,岗位计划开始的时间也不一样,所以有事耽误的数量也是不一致的,按岗位计算 PostStartDate = CompanyPostPlanBLL.ReadCompanyPostPlan(company.CompanyId, PostId); //如果没有设置岗位开始时间或者岗位开始时间比公司开始时间早,统一使用公司开始时间 if (PostStartDate == DateTime.MinValue || PostStartDate < PostPlanStartDate) { PostStartDate = PostPlanStartDate; } //根据统一的岗位开始时间调取数据 CompanyDelayNum = ChangeNumBLL.CompanyChangeNum(company.CompanyId, PostId, PostStartDate, EndDate); TargetNum = CompanyRuleBLL.GetCourseNum(company.CompanyId, PostId, PostStartDate, EndDate); //理论值是每周两门 TargetNum = TargetNum - CompanyDelayNum; postData[2] = PostStartDate.ToString(); postData[3] = TargetNum.ToString(); postCourseDic.Add(PostId, postData); } else { AllPostPlan = postCourseDic[PostId][0]; PostCourseNum = int.Parse(postCourseDic[PostId][1]); PostStartDate = Convert.ToDateTime(postCourseDic[PostId][2]); TargetNum = int.Parse(postCourseDic[PostId][3]); } //如果员工是后来的,要以员工进来的时间为起始点 if (PostStartDate < Info.PostStartDate)//Info.RegisterDate { PostStartDate = Info.PostStartDate; CompanyDelayNum = ChangeNumBLL.CompanyChangeNum(company.CompanyId, PostId, PostStartDate, EndDate); TargetNum = CompanyRuleBLL.GetCourseNum(company.CompanyId, PostId, PostStartDate, EndDate); //理论值是每周两门 TargetNum = TargetNum - CompanyDelayNum; } TargetNum = TargetNum - ChangeNumBLL.UserChangeNum(Info.ID, PostStartDate, EndDate); //PassCateId 跨岗位通过的课程 PostResidueCourse 岗位内剩余课程 string PassCateId = string.Empty, NoPassCateId = string.Empty, PostResidueCourse = string.Empty; if (!string.IsNullOrEmpty(company.PostStartDate.ToString())) { PassCateId = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= PostStartDate && TempModel.TestDate <= EndDate); })); PostResidueCourse = StringHelper.SubString(AllPostPlan, TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate <= EndDate); }))); } else { PassCateId = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate <= EndDate); })); PostResidueCourse = StringHelper.SubString(AllPostPlan, PassCateId); } //跨岗位通过的课程数(全岗位计划开始后,累计完成的课程数) int AllPassCourseNum = 0; if (!string.IsNullOrEmpty(PassCateId)) { AllPassCourseNum = PassCateId.Split(',').Length; } //获取岗位内剩余课程数 if (!string.IsNullOrEmpty(PostResidueCourse)) { ResidueCourseNum = PostResidueCourse.Split(',').Length; } string PastPassCourse = string.Empty; PeoperNum = PeoperNum + 1; TextOut.Append("<tr>\r\n"); TextOut.Append("<td>" + PeoperNum + "</td>"); //if (base.IsGroupCompany(company.GroupId)) TextOut.Append("<td>" + CompanyBLL.ReadCompany(Info.CompanyID).CompanySimpleName + "</td>"); TextOut.Append("<td>" + Info.RealName + "</td>"); if (!string.IsNullOrEmpty(Info.PostName)) { TextOut.Append("<td>" + Info.PostName + "</td>"); } else { TextOut.Append("<td>" + PostBLL.ReadPost(Info.WorkingPostID).PostName + "</td>"); } TextOut.Append("<td>" + PostModel.PostName + "</td>"); for (int j = 1; j <= WeekNum; j++) { int WeekCourseNum = 0; DateTime _StartDate = StartDate.AddDays(7 * (j - 1)); DateTime _EndDate = StartDate.AddDays(7 * j); if (j == WeekNum) { _EndDate = EndDate; } if (_StartDate < PostStartDate) { _StartDate = PostStartDate; } if (_EndDate > PostStartDate) { PastPassCourse = TestPaperBLL.ReadCourseIDStr(currentUserPassPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= _StartDate && TempModel.TestDate <= _EndDate); })); WeekCourseNum = currentUserPaperList.FindAll(delegate(TestPaperInfo TempModel) { return(TempModel.TestDate >= _StartDate && TempModel.TestDate <= _EndDate); }).Count; } int PastPassCourseNum = 0; if (!string.IsNullOrEmpty(PastPassCourse)) { PastPassCourseNum = PastPassCourse.Split(',').Length; } PerPassCourseNum += PastPassCourseNum; PerCourseNum += WeekCourseNum; TextOut.Append("<td>" + WeekCourseNum + "</td>"); TextOut.Append("<td>" + (PastPassCourseNum) + "</td>"); if (PastPassCourseNum == 0) { TextOut.Append("<td>0</td>"); } else { TextOut.Append("<td>" + ((double)PastPassCourseNum / (double)WeekCourseNum).ToString("P") + "</td>"); } } //统计好学生 学习课程超过30门的人 if (PerCourseNum >= 30) { GoodStudent += " " + Info.RealName; } //统计通过课程数量第一的数据 if (PerPassCourseNum > 0 && PerPassCourseNum >= FirstPassCourseNum) { if (PerPassCourseNum > FirstPassCourseNum) { PassCourseFirstUser = Info.RealName; FirstPassCourseNum = PerPassCourseNum; } else { PassCourseFirstUser = PassCourseFirstUser + " " + Info.RealName; } } TextOut.Append("<td>" + PerCourseNum + "</td>"); TextOut.Append("<td>" + PerPassCourseNum + "</td>"); if (PerCourseNum <= 0) { TextOut.Append("<td>0</td>"); } else { TextOut.Append("<td>" + ((double)PerPassCourseNum / (double)PerCourseNum).ToString("P") + "</td>"); } TextOut.Append("<td>" + (AllPassCourseNum) + "</td>"); TextOut.Append("<td>" + (TargetNum) + "</td>"); TargetNum = AllPassCourseNum - TargetNum; TextOut.Append("<td style=\""); if (TargetNum > 0) { TextOut.Append("background: #00b050;"); GreenNum += 1; } else if (TargetNum < 0) { TextOut.Append("background: #ff0000;"); RedNum += 1; } else { TextOut.Append("background: #ffff00;"); YellowNum += 1; } TextOut.Append(" color:#000;\">" + (TargetNum) + "</td>"); TextOut.Append("</tr>\r\n"); currentUserPaperList = null; currentUserPassPaperList = null; } PostModel = null; time1.Stop(); log.Write(Info.RealName + "执行时间为:" + time1.Elapsed.Milliseconds); } TestPaperList = null; if (FirstPassCourseNum > 0) { TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">课程考试通过数量最多的学霸为: <font color=red>" + PassCourseFirstUser + "</font> ,数量为: <font color=red>" + FirstPassCourseNum.ToString() + "</font> 。</th></tr>"); } if (!string.IsNullOrEmpty(GoodStudent)) { TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">月度考试数量超过30门的为好学生,此次好学生为: <font color=red>" + GoodStudent + "</font> 。</th></tr>"); } TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 刚好达标人数:" + YellowNum.ToString() + " 超越目标人数:" + GreenNum.ToString() + "</th></tr>"); TextOut.Append("<tr><th colspan=\"" + (ColNum + WeekNum * 3) + "\">未达标人数:" + RedNum.ToString() + " 达标人数:" + (YellowNum + GreenNum).ToString() + " 达成率:" + ((double)(YellowNum + GreenNum) / (double)PeoperNum).ToString("P") + "</th></tr>"); TextOut.Append("</table>"); if (string.IsNullOrEmpty(Type)) { return(TextOut.ToString()); } else { GroupResult[1] = (int)GroupResult[1] + PeoperNum; GroupResult[2] = (int)GroupResult[2] + (YellowNum + GreenNum); GroupResult[3] = (int)GroupResult[3] + RedNum; if (((double)(YellowNum + GreenNum) / (double)PeoperNum) == 1.0) { GroupResult[4] = GroupResult[4] + "<span style=\"margin:0px 10px;\">" + company.CompanySimpleName + "</span>"; } else if (((double)(YellowNum + GreenNum) / (double)PeoperNum) < 0.7) { GroupResult[5] = GroupResult[5] + "<span style=\"margin:0px 10px;\">" + company.CompanySimpleName + "</span>"; } //GroupResult[4] += ((double)(YellowNum + GreenNum) / (double)PeoperNum); return("<tr><td>" + company.CompanySimpleName + "</td><td>" + PeoperNum + "</td><td>" + (YellowNum + GreenNum).ToString() + "</td><td>" + RedNum.ToString() + "</td><td>" + ((double)(YellowNum + GreenNum) / (double)PeoperNum).ToString("P") + "</td></tr>"); } }
public void ShowLog(string inf) { TxtLog.AppendText(inf); TxtLog.ScrollToEnd(); }
public JsonResult Transfer() { MSGReturnModel result = new MSGReturnModel(); try { #region 抓Excel檔案 轉成 model // Excel 檔案位置 DateTime startTime = DateTime.Now; string projectFile = Server.MapPath("~/" + SetFile.FileUploads); string fileName = string.Empty; if (Cache.IsSet(CacheList.A62ExcelName)) { fileName = (string)Cache.Get(CacheList.A62ExcelName); //從Cache 抓資料 } if (fileName.IsNullOrWhiteSpace()) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.time_Out.GetDescription(); } string path = Path.Combine(projectFile, fileName); FileStream stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read); string pathType = path.Split('.')[1]; //抓副檔名 List <Exhibit7Model> dataModel = A6Repository.getExcel(pathType, stream); //Excel轉成 Exhibit7Model #endregion 抓Excel檔案 轉成 model #region txtlog 檔案名稱 string txtpath = SetFile.A62TransferTxtLog; //預設txt名稱 string configTxtName = ConfigurationManager.AppSettings["txtLogA6Name"]; if (!string.IsNullOrWhiteSpace(configTxtName)) { txtpath = configTxtName; //有設定webConfig且不為空就取代 } #endregion txtlog 檔案名稱 #region save 資料 #region save Tm_Adjust_YYYY(A62) MSGReturnModel resultA62 = A6Repository.saveA62(dataModel); //save to DB bool A62Log = CommonFunction.saveLog(Table_Type.A62, fileName, SetFile.ProgramName, resultA62.RETURN_FLAG, Debt_Type.B.ToString(), startTime, DateTime.Now); //寫sql Log TxtLog.txtLog(Table_Type.A62, resultA62.RETURN_FLAG, startTime, txtLocation(txtpath)); //寫txt Log #endregion save Tm_Adjust_YYYY(A62) result = resultA62; #endregion save 資料 } catch (Exception ex) { result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.save_Fail .GetDescription(null, ex.Message); } return(Json(result)); }
public void CreateWeatherGenFolderWiseTxtFile() { string Folder; string root, ProjectName, ProjectFolder; //string DirPcp, DirTmp, DirSolar, DirRH, DirWnd; string DirPcp; int TotalStations = Convert.ToInt32(TxtSubbasinNo.Text); //creating directory //string ImagePath = Environment.CurrentDirectory + "\\CRAWFORD" + DateTime.Now.ToString("yyyyMMddTHHmmss") + ".png"; Folder = TxtDirectoryPath.Text; if (Folder == "") { Folder = Environment.CurrentDirectory; TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Folder Path set to " + Folder); TxtLog.AppendText(Environment.NewLine); TxtLog.AppendText("-------------------------------------------------------------------------------"); TxtLog.AppendText(Environment.NewLine); } ProjectName = TxtProjectName.Text; if (ProjectName == "") { ProjectName = "New Project_" + DateTime.Now.ToString("yyyyMMddTHHmmss") + "_"; TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Project Name set to " + ProjectName); TxtLog.AppendText(Environment.NewLine); TxtLog.AppendText("-------------------------------------------------------------------------------"); TxtLog.AppendText(Environment.NewLine); } ProjectFolder = Folder + "\\" + ProjectName; if (!Directory.Exists(ProjectFolder)) { Directory.CreateDirectory(ProjectFolder); } root = ProjectFolder + "\\Weather Data"; DirPcp = root + "\\Precipitation"; //DirTmp = root + "\\Temperature"; //DirSolar = root + "\\Solar"; //DirRH = root + "\\RH"; //DirWnd = root + "\\Wind"; if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } if (!Directory.Exists(DirPcp)) { Directory.CreateDirectory(DirPcp); } /*if (!Directory.Exists(DirTmp)) * { * Directory.CreateDirectory(DirTmp); * } * if (!Directory.Exists(DirSolar)) * { * Directory.CreateDirectory(DirSolar); * } * if (!Directory.Exists(DirRH)) * { * Directory.CreateDirectory(DirRH); * } * if (!Directory.Exists(DirWnd)) * { * Directory.CreateDirectory(DirWnd); * } */ //creating files in directory string txtFile, SYear, MainFile, TempName; int StepColumn; SYear = TxtStartYear.Text + "0101"; // precipitation Application.DoEvents(); TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to Precipitation files..."); TxtLog.AppendText(Environment.NewLine); StepColumn = 0; MainFile = DirPcp + "\\" + "Pcp" + ".txt"; //TextWriter MainwriterP = new StreamWriter(MainFile); //MainwriterP.Write("ID,NAME,LAT,LONG,ELEVATION"); for (int i = 0; i < TotalStations; i++) //TotalStations is equal to Total number of subbasin { txtFile = DirPcp + "\\" + dataGridViewSubbasinSummary.Rows[i].Cells[1].Value + ".txt"; TempName = "Pcp_" + dataGridViewSubbasinSummary.Rows[i].Cells[1].Value; //subbasin name //for main pcp file containing records of pcp stations //MainwriterP.Write(Environment.NewLine); /*MainwriterP.Write((i + 1).ToString() + "," + TempName + "," + dataGridViewStation.Rows[i].Cells[2].Value + "," + dataGridViewStation.Rows[i].Cells[3].Value + "," + dataGridViewStation.Rows[i].Cells[4].Value);*/ TextWriter writer = new StreamWriter(txtFile); //writing to each files writer.Write(SYear); for (int j = 0; j < TotalNumberofDailyData; j++) { writer.Write(Environment.NewLine); writer.Write(dataGridView5.Rows[j].Cells[2 + i].Value); } //StepColumn += EachStationColumn; writer.Close(); TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Finished writing to file : " + txtFile); TxtLog.AppendText(Environment.NewLine); TxtLog.AppendText("................................................................................"); TxtLog.AppendText(Environment.NewLine); } //MainwriterP.Close(); /* //tmp mx, tmp mn * Application.DoEvents(); * TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to Temperature files..."); * TxtLog.AppendText(Environment.NewLine); * StepColumn = 0; * MainFile = DirTmp + "\\" + "Tmp" + ".txt"; * TextWriter MainwriterT = new StreamWriter(MainFile); * MainwriterT.Write("ID,NAME,LAT,LONG,ELEVATION"); * for (int i = 0; i < TotalStations; i++) * { * txtFile = DirTmp + "\\" + "Tmp_" + dataGridViewStation.Rows[i].Cells[1].Value + ".txt"; * * TempName = "Tmp_" + dataGridViewStation.Rows[i].Cells[1].Value; * MainwriterT.Write(Environment.NewLine); * MainwriterT.Write((i + 1).ToString() + "," + TempName + "," + dataGridViewStation.Rows[i].Cells[2].Value + "," + dataGridViewStation.Rows[i].Cells[3].Value + "," + dataGridViewStation.Rows[i].Cells[4].Value); + + TextWriter writer = new StreamWriter(txtFile); + writer.Write(SYear); + for (int j = 0; j < TotalNumberofDailyData; j++) + { + writer.Write(Environment.NewLine); + writer.Write(dataGridViewMusking.Rows[j].Cells[3 + StepColumn].Value + "," + dataGridViewMusking.Rows[j].Cells[4 + StepColumn].Value); + } + StepColumn += EachStationColumn; + writer.Close(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Finished writing to file : " + txtFile); + TxtLog.AppendText(Environment.NewLine); + TxtLog.AppendText("................................................................................"); + TxtLog.AppendText(Environment.NewLine); + } + MainwriterT.Close(); + + //solar + Application.DoEvents(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to Solar files..."); + TxtLog.AppendText(Environment.NewLine); + StepColumn = 0; + MainFile = DirSolar + "\\" + "Solar" + ".txt"; + TextWriter MainwriterS = new StreamWriter(MainFile); + MainwriterS.Write("ID,NAME,LAT,LONG,ELEVATION"); + for (int i = 0; i < TotalStations; i++) + { + txtFile = DirSolar + "\\" + "Solar_" + dataGridViewStation.Rows[i].Cells[1].Value + ".txt"; + + TempName = "Solar_" + dataGridViewStation.Rows[i].Cells[1].Value; + MainwriterS.Write(Environment.NewLine); + MainwriterS.Write((i + 1).ToString() + "," + TempName + "," + dataGridViewStation.Rows[i].Cells[2].Value + "," + dataGridViewStation.Rows[i].Cells[3].Value + "," + dataGridViewStation.Rows[i].Cells[4].Value); + + TextWriter writer = new StreamWriter(txtFile); + writer.Write(SYear); + for (int j = 0; j < TotalNumberofDailyData; j++) + { + writer.Write(Environment.NewLine); + writer.Write(dataGridViewMusking.Rows[j].Cells[5 + StepColumn].Value); + } + StepColumn += EachStationColumn; + writer.Close(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Finished writing to file : " + txtFile); + TxtLog.AppendText(Environment.NewLine); + TxtLog.AppendText("................................................................................"); + TxtLog.AppendText(Environment.NewLine); + } + MainwriterS.Close(); + + //Relative Humidity + Application.DoEvents(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to Relative Humidity files..."); + TxtLog.AppendText(Environment.NewLine); + StepColumn = 0; + MainFile = DirRH + "\\" + "RH" + ".txt"; + TextWriter MainwriterR = new StreamWriter(MainFile); + MainwriterR.Write("ID,NAME,LAT,LONG,ELEVATION"); + for (int i = 0; i < TotalStations; i++) + { + txtFile = DirRH + "\\" + "RH_" + dataGridViewStation.Rows[i].Cells[1].Value + ".txt"; + + TempName = "RH_" + dataGridViewStation.Rows[i].Cells[1].Value; + MainwriterR.Write(Environment.NewLine); + MainwriterR.Write((i + 1).ToString() + "," + TempName + "," + dataGridViewStation.Rows[i].Cells[2].Value + "," + dataGridViewStation.Rows[i].Cells[3].Value + "," + dataGridViewStation.Rows[i].Cells[4].Value); + + TextWriter writer = new StreamWriter(txtFile); + writer.Write(SYear); + for (int j = 0; j < TotalNumberofDailyData; j++) + { + writer.Write(Environment.NewLine); + writer.Write(dataGridViewMusking.Rows[j].Cells[6 + StepColumn].Value); + } + StepColumn += EachStationColumn; + writer.Close(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Finished writing to file : " + txtFile); + TxtLog.AppendText(Environment.NewLine); + TxtLog.AppendText("................................................................................"); + TxtLog.AppendText(Environment.NewLine); + } + MainwriterR.Close(); + + //Wind + Application.DoEvents(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to Wind files..."); + TxtLog.AppendText(Environment.NewLine); + StepColumn = 0; + MainFile = DirWnd + "\\" + "Wind" + ".txt"; + TextWriter MainwriterW = new StreamWriter(MainFile); + MainwriterW.Write("ID,NAME,LAT,LONG,ELEVATION"); + for (int i = 0; i < TotalStations; i++) + { + txtFile = DirWnd + "\\" + "Wind_" + dataGridViewStation.Rows[i].Cells[1].Value + ".txt"; + + TempName = "Wind_" + dataGridViewStation.Rows[i].Cells[1].Value; + MainwriterW.Write(Environment.NewLine); + MainwriterW.Write((i + 1).ToString() + "," + TempName + "," + dataGridViewStation.Rows[i].Cells[2].Value + "," + dataGridViewStation.Rows[i].Cells[3].Value + "," + dataGridViewStation.Rows[i].Cells[4].Value); + + TextWriter writer = new StreamWriter(txtFile); + writer.Write(SYear); + for (int j = 0; j < TotalNumberofDailyData; j++) + { + writer.Write(Environment.NewLine); + writer.Write(dataGridViewMusking.Rows[j].Cells[6 + StepColumn].Value); + } + StepColumn += EachStationColumn; + writer.Close(); + TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Finished writing to file : " + txtFile); + TxtLog.AppendText(Environment.NewLine); + TxtLog.AppendText("................................................................................"); + TxtLog.AppendText(Environment.NewLine); + } + MainwriterW.Close();*/ TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Writing to all files completed"); TxtLog.AppendText(Environment.NewLine); TxtLog.AppendText(DateTime.Now.ToString("hh:mm:ss") + " ==> Files written to " + root); TxtLog.AppendText(Environment.NewLine); TxtLog.AppendText("-------------------------------------------------------------------------------"); TxtLog.AppendText(Environment.NewLine); }
private void TxtLog_TextChanged(object sender, EventArgs e) { // 设置日志显示在最底端 TxtLog.SelectionStart = TxtLog.Text.Length; TxtLog.ScrollToCaret(); }
public void Log(string text) { string timestamp = "[" + DateTime.Now + "]"; TxtLog.AppendText(timestamp + " " + text + Environment.NewLine); }