// GET: Auditeur public ActionResult Index() { List <Delegation> demandes = ServiceDelegation.getDemandesDelegation(ServiceUser.getAuditeurUser(User.Identity.Name)); List <Delegation> offres = ServiceDelegation.getoffresDelegation(ServiceUser.getAuditeurUser(User.Identity.Name)); List <Auditeur> auditeurs = ServiceAuditeur.GetAllAuditeurs();// GetAllAuditeursexceptloggedin(User.Identity.Name); List <SelectListItem> auditeursselectlist = new List <SelectListItem>(); foreach (var item in auditeurs.Where(a => a.AuditeurId != ServiceUser.getAuditeurUser(User.Identity.Name)).ToList()) { auditeursselectlist.Add(new SelectListItem { Value = item.AuditeurId.ToString(), Text = item.Nom + " " + item.Prenom }); } List <Audit> thisweekaudits = ServiceAudit.Getmyauditsthisweek(User.Identity.Name); List <Audit> lastweekmissingaudits = ServiceAudit.Getmymissedauditslastweek(User.Identity.Name); InterfaceAuditeurViewModel vm = new InterfaceAuditeurViewModel { audits = thisweekaudits, auditsderniersemaine = lastweekmissingaudits, auditeursselectlist = auditeursselectlist, offres = offres, demandes = demandes }; return(View(vm)); }
// GET: Delegation public ActionResult demanderdelegation([Bind] DelagationViewModel vm) { Delegation delegation = new Delegation(); delegation.Delegate = ServiceAuditeur.GetAuditeur(vm.audit); delegation.Concernedaudit = ServiceAudit.getAuditdetached(vm.AuditId); delegation.Delegator = ServiceAuditeur.GetAuditeur(ServiceUser.getAuditeurUser(User.Identity.Name)); delegation.semaine = ServiceSemaine.getCurrentSemaine(); ServiceDelegation.addDelegation(delegation); return(RedirectToAction("Index", "Auditeur")); }
public static void createReport() { List <Zone> zones = ServiceZone.GetAllZones(); // descending order of zones by level List <ZoneWithLevel> ZonesdescLevel = descStars(zones); string reportemailbody = ""; if (ZonesdescLevel.Count != 0) { reportemailbody = builddescStars(reportemailbody, ZonesdescLevel); // descending order of zones by Note List <ZoneWithNote> ZonesdescNote = descNotes(zones); reportemailbody = builddescNotes(reportemailbody, ZonesdescNote); } // ascending order of zones by Progress List <ZoneWithProgress> ZonesascProgress = ascProgress(zones); if (ZonesascProgress.Count != 0) { reportemailbody = buildascProgress(reportemailbody, ZonesascProgress); } //gettin zones non auditées List <Audit> auditsnonaccompli = getzonesnonauditées(); reportemailbody = buildnonauditées(reportemailbody, auditsnonaccompli); if (ZonesdescLevel.Count != 0) { //getting audieurs to calculate how much they gave points List <Auditeur> auditeurs = ServiceAuditeur.GetAllAuditeursWD(); reportemailbody = buildauditeurpoints(reportemailbody, auditeurs); } ServiceEmail.sendHTMLEmail("*****@*****.**", "Report Five Stars", reportemailbody); }
public void Assign() { Semaine semaineactuelle = ServiceSemaine.getLastSemaine(); if (!semaineactuelle.isCurrent) { semaineactuelle.isCurrent = true; ServiceSemaine.updateSemaine(semaineactuelle); } else { //Getting this week ready this is abdallah semaineactuelle = new Semaine(); semaineactuelle.isCurrent = true; semaineactuelle.Datedebut = DateTime.Now; semaineactuelle.Datefin = semaineactuelle.Datedebut.AddDays(6); ServiceSemaine.addSemaine(semaineactuelle); } List <Semaine> Allsemaines = ServiceSemaine.getAllsem(); Allsemaines = Allsemaines.Where(s => s.SemaineId != semaineactuelle.SemaineId).ToList(); foreach (var item in Allsemaines) { item.isCurrent = false; ServiceSemaine.updateSemaine(item); } //I'm going to get the number of "zones" and "auditeurs" //and make sure that I don't choose the same person twice //if there is an other zone to audit and there are auditeurs //that were not yet assigned to any zone //GG dude //modified by abdallah //PS!!!: if i forget to mention it directly always go through the services //see the Services folders and u will instantly get it //and encapsulate the repository inside a Using //so that the repository gets disposed of //thats very critical dude to get rid of the DbContext object //thats a nasty object man its messes every thing when it gets tangled with its own kind dude //They are Jhon Snows they are LONE WOLVES :p List <Zone> zones = ServiceZone.GetAllZones(); int numZones = zones.Count; //same here List <Auditeur> auditeurs = ServiceAuditeur.GetAllAuditeurs(); int numAuditeurs = auditeurs.Count; List <int> auditeursPris = new List <int>(numAuditeurs); for (int i = 0; i < numAuditeurs; i++) { auditeursPris.Add(0); } Random rand = new Random(); int r; int numAssignments = 0; for (int i = 0; i < numZones; i++) { if (numAssignments == numAuditeurs) { auditeursPris.Clear(); for (int j = 0; j < numAuditeurs; j++) { auditeursPris.Add(0); } numAssignments = 0; } r = rand.Next(0, numAuditeurs); while (auditeursPris[r] != 0 && numAssignments < numAuditeurs) { r = rand.Next(0, numAuditeurs); } numAssignments++; auditeursPris[r] = 1; //Adding Audits. this is abdallah Audit audittemp = new Audit(); audittemp.TypeAudit = "Regulier"; audittemp.semaine = semaineactuelle; audittemp.auditeur = auditeurs[r]; audittemp.zone = zones[i]; audittemp.AuditDay = semaineactuelle.Datedebut.AddDays(rand.Next(2, 6)); audittemp.isInProgress = false; audittemp.isCompleted = false; ServiceAudit.addAudit(audittemp); Console.WriteLine("l'auditeur " + auditeurs[r].Nom + " est affecté à la zone" + zones[i].NomZone); //Sending mail to Auditeur //ServiceEmail.sendEmail(auditeurs[r].Mail, "Information sur un prochain Audit", " La zone " + zones[i].NomZone + " sera auditée le jour J par l’auditeur " + auditeurs[r].Nom + " " + auditeurs[r].Prenom + ", merci de vous fixer l’heure de l’audit "); //sending mail To Audité aka pilote zone its not provided //ServiceEmail.sendEmail("no access to company emails", "Information sur un Audit cette semaine", " La zone " + zones[i].NomZone + " sera auditée le jour J par l’auditeur " + auditeurs[r].Nom + " " + auditeurs[r].Prenom + ", merci de vous fixer l’heure de l’audit "); } }