public DownloadResponse FormExcelExport(string Instance, string SessionId, DepartureFormFilterDetails DepartureFormFilterDetails) { DownloadResponse DownloadResponse = new DownloadResponse(); BusinessUtil ObjBusinessUtil = new BusinessUtil(); SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "FormExcelExport", "Start "); try { string FilePath = string.Empty; string FileLink = string.Empty; string FileName = string.Empty; ObjBusinessUtil.GetFormsExcelExportFilePath(Instance, ref FilePath, ref FileLink, ref FileName); DownloadResponse.ReturnCode = 1; DownloadResponse.ReturnMessage = "Downloaded Started"; DownloadResponse.FileLink = FileLink; DownloadResponse.FileName = FileName; Task.Factory.StartNew(delegate { this.DownloadDataInBackground(SessionId, DepartureFormFilterDetails, FilePath); }); } catch (System.Exception Ex) { DownloadResponse.ReturnCode = -1; DownloadResponse.ReturnMessage = "Error in Function "; SICTLogger.WriteException(DownloadBusiness.CLASS_NAME, "FormExcelExport", Ex); } SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "FormExcelExport", "FormExcelExportEnd"); return(DownloadResponse); }
private void DownloadDataInBackground(string SessionId, DepartureFormFilterDetails DepartureFormFilterDetails, string FilePath) { DownloadResponse DownloadResponse = new DownloadResponse(); SICTLogger.WriteInfo(DownloadBusiness.CLASS_NAME, "DownloadDataInBackground", "Start "); try { DepartureFormBusiness ObjDepartureFormBusiness = new DepartureFormBusiness(); DataAccessLayer.DataAccessLayer DBLayer = new DataAccessLayer.DataAccessLayer(); System.Collections.Generic.List <DepartureFormDetails> DepartureFormDetails = new System.Collections.Generic.List <DepartureFormDetails>(); string OrderByCondition = string.Empty; string WhereCondition = string.Empty; Workbook Wb = new Workbook(); Worksheet DataSheet = null; this.AddDataSheetToWorkBook(ref Wb, ref DataSheet, "Forms"); this.InsertFormFilterstoWorkBook(ref DataSheet, DepartureFormFilterDetails); ObjDepartureFormBusiness.BuildOrderByandWhereConditions(DepartureFormFilterDetails, ref OrderByCondition, ref WhereCondition); int RecordsPerLoop = System.Convert.ToInt32(ConfigurationManager.AppSettings[BusinessConstants.UPLOAD_ROWS_CNT].ToString()); int StartIndex = 0; int Count = 0; bool IsFirstRecord = true; int DataRow = 1; do { DataSet DSCardDetails = new DataSet(); DSCardDetails = DBLayer.GetGlobalDepartureFormDetailst(SessionId, StartIndex, RecordsPerLoop, OrderByCondition, WhereCondition, DepartureFormFilterDetails.AirportId, DepartureFormFilterDetails.IsDepartureForm, false, 0L, 0L); if (DSCardDetails.Tables.Count == 2) { if (IsFirstRecord) { Count = System.Convert.ToInt32(DSCardDetails.Tables[0].Rows[0][BusinessConstants.FORM_TOTALRECORDS].ToString()); IsFirstRecord = false; } this.InsertFormDataToWorksheet(DSCardDetails.Tables[1], ref DataSheet, ref DataRow); StartIndex += RecordsPerLoop; if (StartIndex < Count && StartIndex + RecordsPerLoop > Count) { RecordsPerLoop = Count - StartIndex; } } }while (StartIndex < Count); Wb.Save(FilePath, new OoxmlSaveOptions(SaveFormat.Xlsx)); } catch (System.Exception Ex) { DownloadResponse.ReturnCode = -1; DownloadResponse.ReturnMessage = "Error in Function "; SICTLogger.WriteException(DownloadBusiness.CLASS_NAME, "DownloadDataInBackground", Ex); } }
public FinalDepartureFormDetails GetDepartureFormDetails(string Instance, string SessionId, string Version, DepartureFormFilterDetails DepartureFormFilterDetails) { FinalDepartureFormDetails finalDepartureFormDetails = new FinalDepartureFormDetails(); SICTLogger.WriteInfo(DepartureFormServices.CLASS_NAME, "GetDepartureFormDetails", "Start"); try { UserDetailsBusiness userDetailsBusiness = new FactoryBusiness().GetUserDetailsBusiness(BusinessConstants.VERSION_BASE); if (userDetailsBusiness.IsSessionIdValid(SessionId, false)) { DepartureFormBusiness departureFormBusiness = new FactoryBusiness().GetDepartureFormBusiness(Version); finalDepartureFormDetails = departureFormBusiness.GetDepartureFormDetails(Instance, SessionId, DepartureFormFilterDetails); } else { finalDepartureFormDetails.ReturnCode = 0; finalDepartureFormDetails.ReturnMessage = "Invalid session"; SICTLogger.WriteWarning(DepartureFormServices.CLASS_NAME, "GetDepartureFormDetails", "Invalid session "); } } catch (Exception ex) { finalDepartureFormDetails.ReturnCode = -1; finalDepartureFormDetails.ReturnMessage = "Error in API Execution"; SICTLogger.WriteException(DepartureFormServices.CLASS_NAME, "GetDepartureFormDetails", ex); } SICTLogger.WriteInfo(DepartureFormServices.CLASS_NAME, "GetDepartureFormDetails", "End"); return(finalDepartureFormDetails); }
private void InsertFormFilterstoWorkBook(ref Worksheet DataSheet, DepartureFormFilterDetails DepartureFormFilterDetails) { DataAccessLayer.DataAccessLayer DBLayer = new DataAccessLayer.DataAccessLayer(); try { int HeaderRow = 0; int HeaderCol = 0; this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ID); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_AIRPORT_ID); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 14, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_DATE); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_INTERVIEWER_ID); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_AIRLINES_ID); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_DEPTARR); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_DEPT_ID); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_FLIGHT_NUMBER); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_LANG1); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_STARTCODE1); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ENDCODE1); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_LANG2); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_STARTCODE2); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ENDCODE2); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_LANG3); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_STARTCODE3); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ENDCODE3); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_LANG4); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_STARTCODE4); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ENDCODE4); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_LANG5); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_STARTCODE5); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_ENDCODE5); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 0, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_BUSS_CLASS); this.SetExcelCellStyle(ref DataSheet, HeaderRow, HeaderCol, 12, System.Drawing.Color.White, false, false, 22, false); DataSheet.Cells[HeaderRow, HeaderCol++].PutValue(BusinessConstants.FORM_DOWNLOAD_CHANGE_TIME); } catch (System.Exception Ex) { SICTLogger.WriteException(DownloadBusiness.CLASS_NAME, "InsertFormFilterstoWorkBook", Ex); } }
public DownloadResponse DownloadFormDetails(string Instance, string SessionId, string Version, DepartureFormFilterDetails FormFilterDetails) { const string FUNCTION_NAME = "DownloadFormDetails"; DownloadResponse DownloadResponse = new DownloadResponse(); SICTLogger.WriteInfo(CLASS_NAME, FUNCTION_NAME, "Start"); try { UserDetailsBusiness ObjSessionValidation = new FactoryBusiness().GetUserDetailsBusiness(BusinessConstants.VERSION_BASE); if (ObjSessionValidation.IsSessionIdValid(SessionId)) { DownloadBusiness ObjDownloadBusiness = new FactoryBusiness().GetDownloadBusiness(Version); DownloadResponse = ObjDownloadBusiness.FormExcelExport(Instance, SessionId, FormFilterDetails); } else { DownloadResponse.ReturnCode = 0; DownloadResponse.ReturnMessage = "Invalid session"; SICTLogger.WriteWarning(CLASS_NAME, FUNCTION_NAME, "Invalid session "); } } catch (Exception ex) { DownloadResponse.ReturnCode = -1; DownloadResponse.ReturnMessage = "Error in API Execution"; SICTLogger.WriteException(CLASS_NAME, FUNCTION_NAME, ex); } SICTLogger.WriteInfo(CLASS_NAME, FUNCTION_NAME, "End"); return(DownloadResponse); }