public static void RecreateGroupsGarantiesSanteFromPresta()
        {
            try
            {
                //truncate table GroupGarantySante
                GroupGarantySante.TruncateTable();

                //get data from PrestSante
                List <GroupesGarantiesSante> GroupGarantyList = PrestSante.GetGroupGarantyList();

                //add data to GroupGarantySante
                // ### Paramètres par défaut
                foreach (GroupesGarantiesSante item in GroupGarantyList)
                {
                    int id = GroupGarantySante.InsertGroupGaranty(new GroupGarantySante
                    {
                        AssureurName = item.AssureurName,
                        GroupName    = item.GroupName,
                        GarantyName  = item.GarantyName,
                        CodeActe     = item.CodeActe,
                        OrderNumber  = 1
                    });
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }
예제 #2
0
        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;
            }
        }
        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;
            }
        }
        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);
            }
        }
        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);
            }
        }
        protected void cmdDelete_Click(object sender, EventArgs e)
        {
            try
            {
                //handle the delete event
                string assurName = lbAssur.SelectedItem.Text.ToString();

                Session["SelectedAssureurIndex"] = lbAssur.SelectedIndex;

                if (!string.IsNullOrWhiteSpace(assurName))
                {
                    GroupGarantySante.DeleteGroupsWithSpecificAssureurName(assurName);
                }
                else
                {
                    throw new Exception("Please select the name of the 'Assureur' for which you want to delete groups and guarantees!");
                }

                //refresh the tree
                lbAssur.DataBind();

                if (ItemExists(assurName))
                {
                    SelectItem(assurName);
                    UpdateTreeView(assurName);
                }
                else
                {
                    if (lbAssur.Items.Count > 0)
                    {
                        SelectItem(lbAssur.Items[0].Text);
                        UpdateTreeView(lbAssur.Items[0].Text);
                    }
                    else
                    {
                        tvGaranties.Nodes.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);

                var myCustomValidator = new CustomValidator();
                myCustomValidator.IsValid      = false;
                myCustomValidator.ErrorMessage = ex.Message;
                Page.Validators.Add(myCustomValidator);
            }
        }
        public static void ImportGroupsGarantiesSanteForAssureur(string assureurName, string excelFilePath, bool firstRowAsColumnNames)
        {
            try
            {
                string groupName;
                string garantyName;
                string codeActe;
                int    orderNumber;

                //read Excel file into datatable
                DataTable dt = G.ExcelToDataTable(excelFilePath, firstRowAsColumnNames);

                // delete all rows in DB Tables with the specified assurName
                GroupGarantySante.DeleteGroupsWithSpecificAssureurName(assureurName);

                foreach (DataRow row in dt.Rows)
                {
                    //### validate => all fields must be specified
                    groupName   = row[C.eExcelGroupsGaranties.GroupName.ToString()].ToString();
                    garantyName = row[C.eExcelGroupsGaranties.GarantyName.ToString()].ToString();
                    codeActe    = row[C.eExcelGroupsGaranties.CodeActe.ToString()].ToString();

                    if (!Int32.TryParse(row[C.eExcelGroupsGaranties.OrderNumber.ToString()].ToString(), out orderNumber))
                    {
                        orderNumber = 9999;
                    }

                    int id = GroupGarantySante.InsertGroupGaranty(new GroupGarantySante
                    {
                        AssureurName = assureurName,
                        GroupName    = groupName,
                        GarantyName  = garantyName,
                        CodeActe     = codeActe,
                        OrderNumber  = orderNumber
                    });
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                throw ex;
            }
        }