public static Guid AddReleveSituation(ag_upsideo_ClientReleveSituation relveSituation)
 {
     using (var context = new UpsilabEntities())
     {
         try
         {
             context.ag_upsideo_ClientReleveSituation.AddObject(relveSituation);
             context.SaveChanges();
             return relveSituation.idAgregClientReleveSituation;
         }
         catch (Exception e)
         {
             Log.Log.AppendException(e);
             context.Connection.Close();
             throw new Exception("SavingError");
         }
     }
     return Guid.Empty;
 }
 public static Guid UpdateReleveSituation(ag_upsideo_ClientReleveSituation relveSituation)
 {
     using (var context = new UpsilabEntities())
     {
         try
         {
             context.ag_upsideo_ClientReleveSituation.Attach(relveSituation);
             context.ObjectStateManager.ChangeObjectState(relveSituation, System.Data.EntityState.Modified);
             context.SaveChanges();
             return relveSituation.idAgregClientReleveSituation;
         }
         catch (Exception e)
         {
             Log.Log.AppendException(e);
             throw new Exception("SavingError");
         }
     }
     return Guid.Empty;
 }
        public ActionResult MassGenerationFiltrer(string idlisteClient, string releveType)
        {
            var result = new { Result = "ok", Erreur = string.Empty };
            try
            {
                List<string> listeClient = new List<string>();
                if (!string.IsNullOrEmpty(idlisteClient))
                {
                    string[] arrayclient = idlisteClient.Split(',');
                    foreach (string id in arrayclient)
                    {
                        listeClient.Add(id);
                    }
                }
                if (listeClient.Any())
                {
                    ag_upsideo_ClientReleveSituation clientReleve;
                    foreach (string idclient in listeClient)
                    {
                        clientReleve = new ag_upsideo_ClientReleveSituation()
                        {
                            Status = AgregClientReleveSituation.StatusEnum.InProgress.ToString(),
                            idAgregCgp = new Guid(SessionManager.GetUserSession().idAgregCGP.Value.ToString()),
                            idAgregClient = new Guid(idclient),
                            pathfile = string.Empty,
                            DateCreated = DateTime.Now,
                            DateUpdated = DateTime.Now,
                            idAgregClientReleveSituation = Guid.NewGuid(),
                            releveType = int.Parse(releveType)
                        };
                        AgregClientReleveSituationBL.AddReleveSituation(clientReleve);                        
                    }

                }
            }
            catch (Exception ex)
            {
                result = new { Result = "ko", Erreur = ex.Message };
            }
            return Json(result, JsonRequestBehavior.AllowGet);
        }
 public ActionResult MassGeneration(List<string> idlist)
 {
     var result = new {Result = "ok", Erreur = string.Empty};
     try
     {
         if (idlist.Any())
         {
             ag_upsideo_ClientReleveSituation clientReleve;
             foreach (string idclient in idlist)
             {
                 clientReleve = new ag_upsideo_ClientReleveSituation()
                 {
                     Status = AgregClientReleveSituation.StatusEnum.InProgress.ToString(),
                     idAgregCgp = new Guid(SessionManager.GetUserSession().idAgregCGP.Value.ToString()),
                     idAgregClient = new Guid(idclient),
                     pathfile = string.Empty,
                     DateCreated = DateTime.Now,
                     DateUpdated = DateTime.Now,
                     idAgregClientReleveSituation = Guid.NewGuid()
                 };
                 AgregClientReleveSituationBL.AddReleveSituation(clientReleve);
                 //AgregClientService.GenererReleveSituation(SessionManager.GetUserSession().idAgregCGP.Value.ToString(), idclient, string.Empty, true);
             }
      
         }
     }
     catch (Exception ex)
     {
         result = new { Result = "ko", Erreur = ex.Message };
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }