Esempio n. 1
0
        public static IEnumerable<CompteRenduActivite> UpdateCra(CompteRenduActivite compteRenduActivite)
        {
            using (var entity = new StaffingModelContainer())
            {
                entity.CompteRenduActiviteTable.Single(o => o.ID == compteRenduActivite.Id).Update(compteRenduActivite);
                entity.SaveChanges();
            }

            switch (compteRenduActivite.Status)
            {
                case ItemStatus.Waiting:
                    Mail.Send(compteRenduActivite.ConsultantId, MailType.CRASubmited, compteRenduActivite);
                    break;
                case ItemStatus.Refused:
                    Mail.Send(compteRenduActivite.ConsultantId, MailType.CRARefused, compteRenduActivite);
                    break;
                case ItemStatus.Validate:
                    Mail.Send(compteRenduActivite.ConsultantId, MailType.CRAValidated, compteRenduActivite);
                    break;
            }

            return GetCra(null, null, null);
        }
Esempio n. 2
0
        public IEnumerable<CompteRenduActivite> UpdateCRA(CompteRenduActivite compteRenduActivite, string token)
        {
            if (!IsConnected(token))
            {
                throw new NotConnectedException();
            }
            CRAPDFGenerator.GeneratePDF(compteRenduActivite);
            var cra = ActivityDal.UpdateCra(compteRenduActivite);


            return cra;
        }
Esempio n. 3
0
        public static void GeneratePDF(CompteRenduActivite cra)
        {
            var activities = ActivityDal.GetActivities(cra.Id);

            var days = new List<List<string>>();
            for (var i = 0; i < 6; i++)
            {
                var week = new List<string>();
                for (int j = 0; j < 14; j++)
                {
                    week.Add(string.Empty);
                }

                days.Add(week);
            }

            var weeks = 0;
            foreach (var activityWeek in activities)
            {
                foreach (var day in activityWeek.Activities)
                {
                    var dayPosition = 0;
                    switch (day.Date.DayOfWeek)
                    {
                        case DayOfWeek.Monday:
                            break;
                        case DayOfWeek.Tuesday:
                            dayPosition = 1;
                            break;
                        case DayOfWeek.Wednesday:
                            dayPosition = 2;
                            break;
                        case DayOfWeek.Thursday:
                            dayPosition = 3;
                            break;
                        case DayOfWeek.Friday:
                            dayPosition = 4;
                            break;
                        case DayOfWeek.Saturday:
                            dayPosition = 5;
                            break;
                        case DayOfWeek.Sunday:
                            dayPosition = 6;
                            break;
                    }

                    days[weeks][2 * dayPosition] = string.Format("{0} : {1}", day.Date.ToString("dd"),
                                                               day.MorningActivity.ConvertToFile());
                    days[weeks][2 * dayPosition + 1] = string.Format("{0} : {1}", day.Date.ToString("dd"),
                                                               day.AfternoonActivity.ConvertToFile());
                }

                weeks++;
            }

            Document doc = null;
            string path = string.Empty;
            try
            {
                doc = new Document(PageSize.A4.Rotate(), 20, 20, 20, 20);

                var consultant = ConsultantDAL.GetConsultants().Single(o => o.Id == cra.ConsultantId);
                path = string.Format("{0}\\Files\\{1}{2}_{3}_{4}.pdf", HttpContext.Current.Server.MapPath("."),
                                         cra.Year, cra.Month.ToString("00"), consultant.Nom, consultant.Prenom);

                PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create));
                doc.Open();

                var page = doc.PageSize;

                var table = new PdfPTable(6) { TotalWidth = page.Width };
                CreateImageCell(string.Format("{0}\\Files\\Image\\Logo_Blanc_312_114.jpg", HttpContext.Current.Server.MapPath(".")), table);
                CreateSpaceCell(4, 5, table);
                CreateCRAInformationCell(string.Format("{0} {1}", consultant.Prenom, consultant.Nom), 4, table);

                var culture = new CultureInfo("fr-Fr");
                CreateCRAInformationCell(string.Format("CRA {0} {1}", culture.DateTimeFormat.GetMonthName(cra.Month), cra.Year), 4, table);
                CreateCRAInformationCell(string.Format("{0}", consultant.Email), 4, table);
                CreateSpaceCell(6, 10, table);

                for (var i = 0; i < 7; i++)
                {
                    foreach (var day in days)
                    {
                        CreateDayCell(day[2 * i], table);
                    }

                    foreach (var day in days)
                    {
                        CreateDayCell(day[2 * i + 1], table);
                    }

                    CreateSpaceCell(6, 10, table);
                }

                CreateSpaceCell(6, 10, table);
                CreateCommentCell(table);
                CreateSpaceCell(6, 10, table);
                CreateSignaturesCells(table);
                doc.Add(table);
            }
            finally
            {
                if (doc != null)
                {
                    doc.Close();

                }
            }
        }
Esempio n. 4
0
 internal static void Update(this CompteRenduActiviteTable oldCRA, CompteRenduActivite newCRA)
 {
     oldCRA.ConsultantTableID = newCRA.ConsultantId;
     oldCRA.Month = newCRA.Month;
     oldCRA.Status = (int)newCRA.Status;
     oldCRA.Year = newCRA.Year;
 }
Esempio n. 5
0
 private static string GetCRAPdfPath(int? consultantId, CompteRenduActivite cra)
 {
     Consultant consultant = ConsultantDAL.GetConsultants().Single(o => o.Id == consultantId);
     return string.Format("{0}\\Files\\{1}{2}_{3}_{4}.pdf", WebServiceRootPath,
                                     cra.Year, cra.Month.ToString("00"), consultant.Nom, consultant.Prenom);
 }