Пример #1
0
 public JsonResult SaveOrUpdate(LinesPlanApiModel model, string pass, bool doAppendPlan)
 {
     if (pass != HARDCODED_PASS)
     {
         return(MakeBadRequest(DEBS.Translate("Message.PasswordInvalid")));
     }
     using (var l = new tblLinesPlanLogic()) {
         if (doAppendPlan)
         {
             var tlp = l.GetFirstByLine(model.LineId) ??
                       new tblLinesPlan {
                 LineId = model.LineId
             };
             model.UpdateDBModelShallow(tlp);
             l.Save(tlp);
         }
         else
         {
             var tlp = l.GetFirstByLine(model.LineId);
             if (tlp != null)
             {
                 l.Remove(tlp);
             }
         }
     }
     return(MakeSuccesResult());
 }
Пример #2
0
 static string DirectionToString(int dirValue)
 {
     return(dirValue == ((int)LineDirection.Bouth) ?
            DEBS.Translate("General.Bouth") :
            dirValue == ((int)LineDirection.To) ?
            DEBS.Translate("General.To") :
            DEBS.Translate("General.From"));
 }
Пример #3
0
        ///<summary>
        ///returns next spare row number
        ///</summary>
        public static int AddLinesSummaryStatisticToSheet(IXLWorksheet toSheet, int startRow, List <LinesTotalStatisticDto> data)
        {
            //Table Header
            toSheet.Cell(startRow, 1).Value = DEBS.Translate("Line.SummaryReport");
            RowStyle_H2(toSheet.Row(startRow));
            startRow++;
            int colIndex = 1;

            toSheet.Cell(startRow, colIndex).Value     = DEBS.Translate("Report.Month");
            toSheet.Cell(startRow + 1, colIndex).Value = DEBS.Translate("Report.linesCount");
            toSheet.Cell(startRow + 2, colIndex).Value = DEBS.Translate("Report.totalStudents");
            toSheet.Cell(startRow + 3, colIndex).Value = DEBS.Translate("Report.totalPrice");
            colIndex++;
            for (int i = 0; i < data.Count; i++)
            {
                toSheet.Cell(startRow, colIndex + i).Value     = i + 1;
                toSheet.Cell(startRow + 1, colIndex + i).Value = data[i].linesCount;
                toSheet.Cell(startRow + 2, colIndex + i).Value = data[i].totalStudents;
                toSheet.Cell(startRow + 3, colIndex + i).Value = data[i].totalPrice;
            }
            return(startRow + 4);
        }
Пример #4
0
        public HttpResponseMessage GetReportXL(DateTime startDate, DateTime endDate, int summaryYear)
        {
            using (var l = new LineLogic()) {
                var      data        = l.GetAllLinesPeriodActivities(startDate, endDate);
                DateTime date        = new DateTime(summaryYear, 1, 1);
                var      dataSummary = new List <LinesTotalStatisticDto>();
                for (int i = 0; i < 12; i++)
                {
                    dataSummary.Add(l.GetLinesTotalStatistic(date.AddMonths(i), date.AddMonths(i + 1)));
                }

                var book  = ExcellWriter.NewBook();
                var sheet = ExcellWriter.NewReportSheet(book, DEBS.Translate("Lines.Report"), "Lines Report from " + startDate.ToString("dd-MM-yyyy") + " to " + endDate.ToString("dd-MM-yyyy"), 2);
                int row   = ExcellWriter.AddLinesPeriodStatisticToSheet(sheet, 4,
                                                                        l.GetAllLinesPeriodActivities(startDate, endDate),
                                                                        l.GetLineTotalStatisticByDays(startDate, endDate)
                                                                        );
                ExcellWriter.AddLinesSummaryStatisticToSheet(sheet, row + 1, dataSummary);
                return(ExcellWriter.BookToHTTPResponseMsg(
                           book,
                           "Lines Report (" + startDate.ToString("dd-MM-yyyy") + " - " + endDate.ToString("dd-MM-yyyy") + ")"
                           ));
            }
        }
Пример #5
0
        ///<summary>
        ///returns next spare row number
        ///</summary>
        public static int AddLinesPeriodStatisticToSheet(IXLWorksheet toSheet, int startRow, List <LinePeriodStatisticDto> data, List <LinesDatedTotalStatisticDto> footerData)
        {
            var dates = data[0].DayDate;

            toSheet.Cell(startRow, 1).Value = DEBS.Translate("Line.ReportByDays");
            RowStyle_H2(toSheet.Row(startRow));
            startRow += 1;
            toSheet.Cell(startRow, 1).Value = DEBS.Translate("Line.LineNumber");

            for (int i = 0; i < dates.Count; i++)
            {
                toSheet.Cell(startRow, 2 + i).Value = dates[i].ToString(@"ddd dd/MM/yyyy");
            }
            startRow++;
            for (int i = 0; i < data.Count; i++)
            {
                //Pure Row
                toSheet.Cell(startRow, 1).Value = data[i].LineNumber;
                toSheet.Row(startRow).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
                MakeBottomBorder(toSheet.Row(startRow));
                for (int colomn = 0; colomn < dates.Count; colomn++)
                {
                    var  c         = toSheet.Cell(startRow, 2 + colomn);
                    bool scheduled = data[i].DayScheduleData[colomn] != LinePeriodStatisticDto.DayScheduleData_INACTIVE;
                    c.Value = scheduled ? data[i].DayScheduleData[colomn] : "-";
                    if (scheduled)
                    {
                        c.Style.Fill.BackgroundColor = XLColor.SeaGreen;
                    }
                }
                startRow++;
                //Info
                var infoRowStart = startRow;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Line.Name");
                toSheet.Cell(startRow, 3).Value = data[i].LineName;
                startRow++;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Line.Direction");
                toSheet.Cell(startRow, 3).Value = DirectionToString(data[i].Direction);
                startRow++;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Line.totalStudents");
                toSheet.Cell(startRow, 3).Value = data[i].totalStudents;
                startRow++;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Bus.CompanyName");
                toSheet.Cell(startRow, 3).Value = data[i].BusCompanyName;
                startRow++;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Bus.seats");
                toSheet.Cell(startRow, 3).Value = data[i].seats;
                startRow++;
                toSheet.Cell(startRow, 2).Value = DEBS.Translate("Bus.price");
                toSheet.Cell(startRow, 3).Value = data[i].price;
                //styling and collapsing
                FoldRows(toSheet.Rows(infoRowStart, startRow));
                startRow++;
            }
            toSheet.CollapseRows(1);
            //Footer
            toSheet.Cell(startRow, 1).Value = DEBS.Translate("Lines.totalPrice");
            toSheet.Row(startRow).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
            MakeFooterStyle(toSheet.Row(startRow));
            for (int colomn = 0; colomn < dates.Count; colomn++)
            {
                var c = toSheet.Cell(startRow, 2 + colomn);
                c.Value = footerData[colomn].totalPrice;
            }
            startRow++;
            return(startRow);
        }