protected void Page_Load(object sender, EventArgs e)
        {
            List <FleetVisionWorkOrder>    workOrders = new List <FleetVisionWorkOrder>();
            FleetVisionWorkOrderRepository repository = new FleetVisionWorkOrderRepository();

            workOrders = repository.GetAll();

            List <FleetVisionWorkOrder> wo_CreatedToday      = repository.GetWorkOrdersCreatedDuring(DateTime.Today, DateTime.Now);
            List <FleetVisionWorkOrder> wo_CreatedYesterday  = repository.GetWorkOrdersCreatedDuring(DateTime.Today.AddDays(-1), DateTime.Today);
            List <FleetVisionWorkOrder> wo_CreatedLast7Days  = repository.GetWorkOrdersCreatedDuring(DateTime.Today.AddDays(-7), DateTime.Now);
            List <FleetVisionWorkOrder> wo_CreatedLast30Days = repository.GetWorkOrdersCreatedDuring(DateTime.Today.AddDays(-30), DateTime.Now);

            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = "application/json; charset=utf-8";
            Response.Write("{\n");

            Response.Write("\"WorkOrders\": {\n");
            Response.Write("\"Total\": " + workOrders.Count + ",\n");
            Response.Write("\"Open\": " + workOrders.Count(wo => !wo.IsClosed) + ",\n");
            Response.Write("\"Closed\": " + workOrders.Count(wo => wo.IsClosed) + ",\n");

            Response.Write("\"CreatedToday\": " + wo_CreatedToday.Count() + ",\n");
            Response.Write("\"CreatedYesterday\": " + wo_CreatedYesterday.Count() + ",\n");
            Response.Write("\"CreatedLast7Days\": " + wo_CreatedLast7Days.Count() + ",\n");
            Response.Write("\"CreatedLast30Days\": " + wo_CreatedLast30Days.Count() + "\n");


            Response.Write("}\n");

            Response.Write("}\n");
            Response.End();
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <FleetVisionWorkOrder> workOrders = new List <FleetVisionWorkOrder>();

            FleetVisionWorkOrderRepository repository = new FleetVisionWorkOrderRepository();

            workOrders = repository.GetRecentIncomplete(50).Where(wo => wo.Vehicle != null).Where(wo => wo.OutDateTime == DateTime.MinValue).Where(wo => wo.InDateTime <= DateTime.Today.AddDays(1).AddMinutes(-1)).OrderBy(wo => wo.PrioritySortOrder).ThenBy(wo => wo.VehicleNumberForSorting).ToList();

            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = "application/json; charset=utf-8";
            Response.Write("{\n");
            Response.Write("\"Total\" : " + workOrders.Count + ",\n");
            Response.Write("\"WorkOrders\": [\n");

            for (int x = 0; x < workOrders.Count; x++)
            {
                if (workOrders[x].Vehicle != null)
                {
                }
                Response.Write("{");
                Response.Write("\"RecordID\" : \"" + workOrders[x].RecordID + "\",");
                Response.Write("\"number\" : \"" + workOrders[x].WorkOrderNumber + "\",");
                Response.Write("\"createdby\" : \"" + workOrders[x].CreatedBy + "\",");
                Response.Write("\"status\" : \"" + workOrders[x].Status + "\",");
                Response.Write("\"indate\" : \"" + workOrders[x].InDateTime + "\",");
                Response.Write("\"outdate\" : \"" + workOrders[x].OutDateTime + "\",");
                Response.Write("\"timesince\" : \"" + Helpers.TimeSince(workOrders[x].DateCreated) + "\",");
                Response.Write("\"priority\" : \"" + CommonFunctions.escapeCharacters(workOrders[x].Priority) + "\",");
                Response.Write("\"status\" : \"" + CommonFunctions.escapeCharacters(workOrders[x].Status) + "\",");
                Response.Write("\"workrequested\" : \"" + CommonFunctions.escapeCharacters(workOrders[x].WorkRequested.Replace("\r\n", ", ")) + "\",");

                string vehicle = "NONE";
                string plate   = string.Empty;
                string vin     = string.Empty;

                if (workOrders[x].Vehicle != null)
                {
                    vehicle = workOrders[x].Vehicle.VehicleNumber;
                    plate   = workOrders[x].Vehicle.Plate;
                    vin     = workOrders[x].Vehicle.VIN;
                }
                Response.Write("\"vehicleID\" : \"" + CommonFunctions.escapeCharacters(workOrders[x].VehicleRecordID.ToString()) + "\",");
                Response.Write("\"vehicle\" : \"" + CommonFunctions.escapeCharacters(vehicle) + "\",");
                Response.Write("\"licenseplate\" : \"" + CommonFunctions.escapeCharacters(plate) + "\",");
                Response.Write("\"vin\" : \"" + CommonFunctions.escapeCharacters(vin) + "\"");

                Response.Write("}");

                if (!(x + 1 >= workOrders.Count))
                {
                    Response.Write(",");
                }

                Response.Write("\n");
            }

            Response.Write("]\n");
            Response.Write("}\n");
            Response.End();
        }