public static List <PrestSante> NormalizeGroupGarantyLabelsInPrestaTable(List <PrestSante> myPrestData) { try { List <PrestSante> prestaNormalized = new List <PrestSante>(); //Pre-load Groups and Garanties for all Assureurs that are found in the Presta Table List <string> assList = myPrestData.OrderBy(p => p.AssureurName).Select(p => p.AssureurName).Distinct().ToList(); List <GroupGarantySante> groupSanteListForAssureur = new List <GroupGarantySante>(); List <GroupGarantySante> groupSanteListAll = GroupGarantySante.GetGroupsAndGarantiesForAssureur(C.cDEFAULTASSUREUR); foreach (string assurName in assList) { //int assurId = Assureur.GetAssIdForAssName(assurName); if (assurName != C.cDEFAULTASSUREUR) { groupSanteListForAssureur = GroupGarantySante.GetGroupsAndGarantiesForAssureur(assurName); groupSanteListAll.AddRange(groupSanteListForAssureur); } } List <Assureur> myAssurList = Assureur.GetAllAssureurs(); foreach (PrestSante prest in myPrestData) { //get Garanty Label //int assureurId = Assureur.GetAssIdForAssName(prest.AssureurName); //int assureurId = myAssurList.Where(a => a.Name == prest.AssureurName).Select(a => a.Id).First(); string codeActe = prest.CodeActe; string assurName = prest.AssureurName; //if (assureurId == C.cINVALIDID) // throw new Exception("CollectPrestaData:: No AssureurId was found for the AssureurName: " + prest.AssureurName); if (String.IsNullOrEmpty(assurName)) { throw new Exception("NormalizeGroupGarantyLabelsInPrestaTable:: No Assureur Name was provided!"); } if (String.IsNullOrEmpty(codeActe)) { throw new Exception("NormalizeGroupGarantyLabelsInPrestaTable:: No CodeActe was provided!"); } GenericClasses ggPair = BLGroupsAndGaranties.GetNormalizedGroupGarantyPair(assurName, codeActe, groupSanteListAll); prest.GroupName = ggPair.GroupName; prest.GarantyName = ggPair.GarantyName; prestaNormalized.Add(prest); //Console.WriteLine(prestaNormalized.Count); } return(prestaNormalized); } catch (Exception ex) { log.Error(ex.Message); throw ex; } }
protected void cmdExport_Click(object sender, EventArgs e) { string uploadPath = ""; try { string assurName = lbAssur.SelectedItem.Text.ToString(); List <GroupGarantySante> groupsSante = GroupGarantySante.GetGroupsAndGarantiesForAssureur(assurName); ExcelPackage pack = BLGroupsAndGaranties.ExportGroupsGarantiesSanteForAssureur(assurName); uploadPath = Path.Combine(Request.PhysicalApplicationPath, C.uploadFolder); uploadPath = Path.Combine(uploadPath, User.Identity.Name + "_" + assurName + "_GroupsEtGuarantees.xlsx"); pack.SaveAs(new FileInfo(uploadPath)); UICommon.DownloadFile(this.Page, uploadPath); } catch (Exception ex) { if (ex.Message != "Thread was being aborted.") { log.Error(ex.Message); } var myCustomValidator = new CustomValidator(); myCustomValidator.IsValid = false; myCustomValidator.ErrorMessage = ex.Message; Page.Validators.Add(myCustomValidator); } }
public static ExcelPackage ExportGroupsGarantiesSanteForAssureur(string assureurName) { try { List <GroupGarantySante> groupGaranties = GroupGarantySante.GetGroupsAndGarantiesForAssureur(assureurName); ExcelPackage pck = new ExcelPackage(); var ws = pck.Workbook.Worksheets.Add(assureurName); //write the header ws.Cells[1, 1].Value = "GroupName"; ws.Cells[1, 2].Value = "GarantyName"; ws.Cells[1, 3].Value = "CodeActe"; ws.Cells[1, 4].Value = "OrderNumber"; int row = 2; foreach (GroupGarantySante ggs in groupGaranties) { ws.Cells[row, 1].Value = ggs.GroupName; ws.Cells[row, 2].Value = ggs.GarantyName; ws.Cells[row, 3].Value = ggs.CodeActe; ws.Cells[row, 4].Value = ggs.OrderNumber; row++; } return(pck); } catch (Exception ex) { log.Error(ex.Message); throw ex; } }
private void UpdateTreeView(string assureurName) { try { tvGaranties.Nodes.Clear(); List <GroupGarantySante> ggs = GroupGarantySante.GetGroupsAndGarantiesForAssureur(assureurName); // add all notes for Sante TreeNode nodeSante = new TreeNode("Groups et garanties pour : " + assureurName, ""); nodeSante.SelectAction = TreeNodeSelectAction.Expand; tvGaranties.Nodes.Add(nodeSante); //get all groups List <string> allGroups = ggs.OrderBy(g => g.GroupName).Select(g => g.GroupName).Distinct().ToList(); foreach (string group in allGroups) { if (!string.IsNullOrWhiteSpace(group)) { TreeNode groupNode = new TreeNode(group, ""); //get garanties for group List <string> garanties = ggs.Where(g => g.GroupName == group).OrderBy(g => g.GarantyName).Select(g => g.GarantyName).Distinct().ToList(); foreach (string gar in garanties) { if (!string.IsNullOrWhiteSpace(gar)) { TreeNode garantyNode = new TreeNode(gar, ""); groupNode.ChildNodes.Add(garantyNode); } } groupNode.Expand(); nodeSante.ChildNodes.Add(groupNode); } } nodeSante.Expand(); } catch (Exception ex) { log.Error(ex.Message); var myCustomValidator = new CustomValidator(); myCustomValidator.IsValid = false; myCustomValidator.ErrorMessage = ex.Message; Page.Validators.Add(myCustomValidator); } }