public InterviewResults TestExcelInterviewResultData() { InterviewResults interviewResults = new InterviewResults(); InterviewResult interviewResult = new InterviewResult { Appointment = "錄用", Results_Remark = "say\nsomthing\nsay\nsomthing\nsay\nsomthing\nsay\nsomthing" }; interviewResults.InterviewResult = interviewResult; List <InterviewComments> interviewCommentsList = new List <InterviewComments>(); InterviewComments interviewComments = new InterviewComments { Interviewer = "國基", Result = "嘎U" }; interviewCommentsList.Add(interviewComments); interviewCommentsList.Add(interviewComments); interviewResults.InterviewCommentsList = interviewCommentsList; return(interviewResults); }
/// <summary> /// 面談結果 /// </summary> /// <param name="interviewResults"></param> /// <param name="sheet"></param> /// <returns></returns> private Worksheet CreateInterviewResualtSheet(InterviewResults interviewResults, Worksheet sheet) { int rowCount = 11; ////任用評定 InterviewResult interviewResult = interviewResults.InterviewResult; switch (interviewResult.Appointment) { case "錄用": sheet.Range["B5"].Text = "■" + interviewResult.Appointment; break; case "不錄用": sheet.Range["B6"].Text = "■" + interviewResult.Appointment; break; case "暫保留": sheet.Range["B7"].Text = "■" + interviewResult.Appointment; break; } ////面談評語 List <InterviewComments> interviewCommentsList = interviewResults.InterviewCommentsList; if (interviewCommentsList.Count == 0) { rowCount += 2; } for (int i = 0; i < interviewCommentsList.Count; i++) { rowCount += 2; sheet.Range["B" + rowCount].Text = "面談者"; sheet.Range["B" + rowCount].Style.HorizontalAlignment = HorizontalAlignType.Left; sheet.Range["C" + rowCount + ":D" + rowCount].Merge(); sheet.Range["C" + rowCount + ":D" + rowCount].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Double; sheet.Range["C" + rowCount].Style.HorizontalAlignment = HorizontalAlignType.Left; sheet.Range["C" + rowCount].Text = interviewCommentsList[i].Interviewer; sheet.Range["F" + rowCount].Text = "面談結果"; sheet.Range["F" + rowCount].Style.HorizontalAlignment = HorizontalAlignType.Left; sheet.Range["G" + rowCount + ":L" + rowCount].Merge(); sheet.Range["G" + rowCount + ":L" + rowCount].Style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Double; sheet.Range["G" + rowCount].Style.HorizontalAlignment = HorizontalAlignType.Left; sheet.Range["G" + rowCount].Text = interviewCommentsList[i].Result; } rowCount++; sheet.Range["B" + (rowCount - interviewCommentsList.Count - 2) + ":M" + rowCount].BorderAround(LineStyleType.Medium); rowCount += 2; sheet.Range["B" + rowCount + ":C" + (rowCount + 1)].Merge(); sheet.Range["B" + rowCount].Text = "備註"; sheet.Range["B" + rowCount + ":C" + (rowCount + 1)].BorderAround(LineStyleType.Medium); rowCount += 3; sheet.Range["B" + rowCount + ":M" + (rowCount + 2)].Merge(); sheet.Range["B" + rowCount].Style.HorizontalAlignment = HorizontalAlignType.Left; sheet.Range["B" + rowCount].Text = string.IsNullOrEmpty(interviewResult.Results_Remark) ? string.Empty : interviewResult.Results_Remark; sheet.Range["B" + rowCount + ":M" + (rowCount + 2)].BorderAround(LineStyleType.Medium); return(sheet); }
/// <summary> /// 根據聯繫ID匯出面談資料 /// </summary> /// <param name="contactIdList"></param> /// <param name="path"></param> /// <returns></returns> public string ExportInterviewDataByContactId(List <string> contactIdList, string path) { bool isAllExport = true; ////紀錄是否有資料沒有面談資料 try { for (int i = 0; i < contactIdList.Count; i++) { List <InterviewData> interviewDataList = new List <InterviewData>(); ///面談資料清單 DataSet ds = Talent.GetInstance().SelectContactSituationDataById(contactIdList[i]); List <string> interviewIdList = new List <string>(); foreach (DataRow dr in ds.Tables[4].Rows) { interviewIdList.Add(dr[0].ToString()); } ////代表沒有面談資料 if (interviewIdList.Count == 0) { isAllExport = false; continue; } foreach (string interviewId in interviewIdList) { InterviewResults interviewResults = new InterviewResults(); InterviewData interviewData = new InterviewData(); DataSet interviewDataSet = Talent.GetInstance().SelectInterviewDataById(interviewId); List <InterviewInfo> interviewInfo = interviewDataSet.Tables[0].DataTableToList <InterviewInfo>(); ////面談基本資料 List <InterviewComments> interviewCommentsList = interviewDataSet.Tables[1].DataTableToList <InterviewComments>(); ////面談評語 List <InterviewResult> interviewResult = interviewDataSet.Tables[2].DataTableToList <InterviewResult>(); ////面談結果(任用評定與備註) interviewResults.InterviewResult = interviewResult[0]; interviewResults.InterviewCommentsList = interviewCommentsList; List <ProjectExperience> projectExperienceList = interviewDataSet.Tables[3].DataTableToList <ProjectExperience>(); ////專案經驗 interviewData.InterviewInfo = interviewInfo[0]; interviewData.InterviewResults = interviewResults; interviewData.ProjectExperienceList = projectExperienceList; interviewDataList.Add(interviewData); } string msg = ExcelHelper.GetInstance().ExportInterviewData(interviewDataList, path, i + 1); if (msg != "匯出成功") { return("匯出失敗"); } } if (!isAllExport) { return("匯出成功,但有些資料沒有面談資料"); } return("匯出成功"); } catch (Exception ex) { LogInfo.WriteErrorInfo(ex); return("匯出失敗"); } }
/// <summary> /// 根據聯繫ID匯出所有資料 /// </summary> /// <param name="contactIdList"></param> /// <param name="path"></param> /// <returns></returns> public string ExportAllDataByContactId(List <string> contactIdList, string path) { try { for (int i = 0; i < contactIdList.Count; i++) { List <ContactSituation> ContactSituationList = new List <ContactSituation>(); ////聯繫狀況資料 List <InterviewData> interviewDataList = new List <InterviewData>(); ///面談資料清單 ContactSituation contactSituation = new ContactSituation(); DataSet ds = Talent.GetInstance().SelectContactSituationDataById(contactIdList[i]); contactSituation.Info = ds.Tables[0].DBNullToEmpty().DataTableToList <ContactInfo>()[0]; contactSituation.Status = ds.Tables[1].DataTableToList <ContactStatus>(); string codeList = string.Empty; foreach (DataRow dr in ds.Tables[2].Rows) { codeList += dr[0].ToString() + "\n"; } contactSituation.Code = codeList; ContactSituationList.Add(contactSituation); List <string> interviewIdList = new List <string>(); foreach (DataRow dr in ds.Tables[4].Rows) { interviewIdList.Add(dr[0].ToString()); } foreach (string interviewId in interviewIdList) { InterviewResults interviewResults = new InterviewResults(); InterviewData interviewData = new InterviewData(); DataSet interviewDataSet = Talent.GetInstance().SelectInterviewDataById(interviewId); List <InterviewInfo> interviewInfo = interviewDataSet.Tables[0].DataTableToList <InterviewInfo>(); ////面談基本資料 List <InterviewComments> interviewCommentsList = interviewDataSet.Tables[1].DataTableToList <InterviewComments>(); ////面談評語 List <InterviewResult> interviewResult = interviewDataSet.Tables[2].DataTableToList <InterviewResult>(); ////面談結果(任用評定與備註) interviewResults.InterviewResult = interviewResult[0]; interviewResults.InterviewCommentsList = interviewCommentsList; List <ProjectExperience> projectExperienceList = interviewDataSet.Tables[3].DataTableToList <ProjectExperience>(); ////專案經驗 interviewData.InterviewInfo = interviewInfo[0]; interviewData.InterviewResults = interviewResults; interviewData.ProjectExperienceList = projectExperienceList; interviewDataList.Add(interviewData); } string msg = ExcelHelper.GetInstance().ExportAllData(ContactSituationList, interviewDataList, path, i + 1); if (msg != "匯出成功") { return("匯出失敗"); } } return("匯出成功"); } catch (Exception ex) { LogInfo.WriteErrorInfo(ex); return("匯出失敗"); } }