public ControllerTypeMapping(string type, ControllerDef controller) { this.Type = type; this.Controller = controller; }
public static LogRecord ReadInquiryConfigurationColumnSetting(string InquiryConfigurationColumnSettingFileName, string Suite, ref List <ConfigurationColumnSettingDefinition> ConfigurationColumnList, string controllerParamDefFileName = null) { DateTime start = DateTime.Now; string status = "Success"; string error = ""; try { ExcelPackage excelFile = EPPlusExcel.openExcel(InquiryConfigurationColumnSettingFileName); List <string> excelFileSheetNames = new List <string>(); foreach (var worksheet1 in excelFile.Workbook.Worksheets) { excelFileSheetNames.Add(worksheet1.Name); } if (excelFileSheetNames.FirstOrDefault(s => s == Suite) == null) { LogRecord lr = new LogRecord(start, "Skip", string.Format("Read Inquiry Configuration Column Setting Excel for {0}", Suite), InquiryConfigurationColumnSettingFileName, string.Format("{0} column setting is not available", Suite)); return(lr); } var worksheet = excelFile.Workbook.Worksheets[Suite]; var ControllerParamDefList = new List <ControllParamDef>(); if (File.Exists(controllerParamDefFileName)) { ControllerParamDefList = JsonConvert.DeserializeObject <List <ControllParamDef> >(File.ReadAllText(controllerParamDefFileName)); } #region readdata for (int row = 2; row <= worksheet.Dimension.End.Row; row++) { ConfigurationColumnSettingDefinition ss = new ConfigurationColumnSettingDefinition { Field = "", Included = "Y", IsDummy = "N", YesNoPresentation = "N", OverridePrList = "", FieldAlias = "", TableName = "", IsFilterable = "Y", IsSortable = "Y", SortFieldsStr = "", IsDrilldown = "N", IsGroupBy = "N", Controller_Type = "", Controller_SrceAppl = "", Controller_SrceApplList = "", Controller_AreaList = "", Controller_ControllerList = "", Controller_TypeList = "", Controller_ActionList = "", ParameterName = "", ParameterField = "", AggregatesStr = "", LicenceCheck = "", }; for (int col = 1; col <= worksheet.Dimension.End.Column; col++) { if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Field") { ss.Field = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "IsDummy" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.IsDummy = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Included" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Included = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "YesNoPresentation" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.YesNoPresentation = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "OverridePrList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.OverridePrList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "FieldAlias" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.FieldAlias = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Label" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Captions.Add(new Translation("ENG", EPPlusExcel.excelCellValue(worksheet, row, col))); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "LabelFra" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Captions.Add(new Translation("FRA", EPPlusExcel.excelCellValue(worksheet, row, col))); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "LabelEsn" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Captions.Add(new Translation("ESN", EPPlusExcel.excelCellValue(worksheet, row, col))); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "LabelChn" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Captions.Add(new Translation("CHN", EPPlusExcel.excelCellValue(worksheet, row, col))); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "LabelCht" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Captions.Add(new Translation("CHT", EPPlusExcel.excelCellValue(worksheet, row, col))); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "TableName") { ss.TableName = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "IsFilterable" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.IsFilterable = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "IsSortable" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.IsSortable = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "SortFieldsStr" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.SortFieldsStr = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "IsGroupBy" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.IsGroupBy = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Aggregation" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.AggregatesStr = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "LicenceCheck" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.LicenceCheck = EPPlusExcel.excelCellValue(worksheet, row, col); } // Drilldown Controller & Parameters if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "IsDrilldown" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.IsDrilldown = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-AreaList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_AreaList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-ControllerList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_ControllerList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-TypeList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_TypeList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-Type" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_Type = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-SrceApplList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_SrceApplList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-SrceAppl" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_SrceAppl = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-ActionList" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.Controller_ActionList = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-ParamName" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.ParameterName = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "Controller-ParamField" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.ParameterField = EPPlusExcel.excelCellValue(worksheet, row, col); } #region ReadDrilldownCondition if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DrilldownCondition-Field" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DrilldownCondition.Field = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DrilldownCondition-Value" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DrilldownCondition.Value = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DrilldownCondition-Operator" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DrilldownCondition.Operator = EPPlusExcel.excelCellValue(worksheet, row, col); } #endregion #region ReadDisplayCondition if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DisplayCondition-Field" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DisplayCondition.Field = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DisplayCondition-Value" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DisplayCondition.Value = EPPlusExcel.excelCellValue(worksheet, row, col); } if (EPPlusExcel.excelCellValue(worksheet, 1, col) == "DisplayCondition-Operator" && EPPlusExcel.excelCellValue(worksheet, row, col) != "") { ss.DisplayCondition.Operator = EPPlusExcel.excelCellValue(worksheet, row, col); } #endregion } #region ProcessDrillDownURL //ss.DrilldownUrl = new DrillDownURL(); if (ss.IsDrilldown == "Y") { ss.DrilldownUrl = new DrillDownURL(); // Process controller only if isDrillDown is set to "Y" ss.DrilldownUrl.TypeField = ss.Controller_Type; ss.DrilldownUrl.SrceApplField = ss.Controller_SrceAppl; string[] areaList = ss.Controller_AreaList.Split(','); string[] controllerList = ss.Controller_ControllerList.Split(','); string[] typeList = ss.Controller_TypeList.Split(','); string[] srceapplList = ss.Controller_SrceApplList.Split(','); string[] actionList = ss.Controller_ActionList.Split(','); List <Param> parameters = new List <Param>(); if (ss.ParameterField != string.Empty && ss.ParameterName != string.Empty && ss.ParameterField != null && ss.ParameterName != null) { string[] paramNameList = ss.ParameterName.Split(','); string[] paramFieldList = ss.ParameterField.Split(','); for (int k = 0; k < paramNameList.Count(); k++) { parameters.Add(new Param(paramNameList[k], paramFieldList[k])); } } if (controllerList.Count() > 1 && controllerList.Count() == typeList.Count() && controllerList.Count() == areaList.Count() && controllerList.Count() == actionList.Count()) { // more than one controller are defined, and the document type are defined for (int cnt = 0; cnt < controllerList.Count(); cnt++) { ControllerDef c = new ControllerDef(areaList[cnt], controllerList[cnt], actionList[cnt]); // find the controller param list from the Controller Param Def file ControllParamDef cpf = new ControllParamDef(); if (ControllerParamDefList.Exists(cp => (cp.Area == areaList[cnt] && cp.Controller == controllerList[cnt]))) { cpf = ControllerParamDefList.First(cp => (cp.Area == areaList[cnt] && cp.Controller == controllerList[cnt])); } // GVG - 20181026 // If the Controller Param Def file didn't exist, // we need to do this check. // This will prevent the previously encountered exceptions from being generated. if (cpf.parameters != null) { var paramNameList = cpf.parameters.Split(','); foreach (string pn in paramNameList) { if (parameters.Exists(p => p.Name == pn)) { c.parameters.Add(parameters.First(p => p.Name == pn)); } } } //c.parameters = parameters; ControllerTypeMapping ctm = new ControllerTypeMapping(typeList[cnt], c); if (srceapplList.Count() == typeList.Count()) { ctm.SrceAppl = srceapplList[cnt]; } ss.DrilldownUrl.ControllerList.Add(ctm); if (ss.DrilldownCondition.Field != "") { ss.DrilldownUrl.DrilldownCondition = ss.DrilldownCondition; } else { ss.DrilldownUrl.DrilldownCondition = null; } } } else if (controllerList.Count() == 1) { ControllerDef c = new ControllerDef(areaList[0], controllerList[0], actionList[0]); c.parameters = parameters; ControllerTypeMapping ctm = new ControllerTypeMapping("-1", c); ss.DrilldownUrl.ControllerList.Add(ctm); if (ss.DrilldownCondition.Field != "") { ss.DrilldownUrl.DrilldownCondition = ss.DrilldownCondition; } else { ss.DrilldownUrl.DrilldownCondition = null; } } } #endregion ConfigurationColumnList.Add(ss); } #endregion excelFile.Dispose(); } catch (Exception evt) { status = "Fail"; error = evt.Message; } LogRecord logrec = new LogRecord(start, status, string.Format("Read Inquiry Configuration Column Setting Excel for {0}", Suite), InquiryConfigurationColumnSettingFileName, error); return(logrec); }