Beispiel #1
0
        public ActionResult Parts(TechnicianWorkOrderDetailsModel model, string selectedSort, string sortDirection, string submitButton, FormCollection formValues)
        {
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            var mobileWorkOrderFactory = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(), Session[Constants.Security.ConnectionStringSessionVariableName].ToString()));

            //determine if we need to add parts or update values for parts
            //check the other submit buttons and act on them, or continue
            switch (submitButton)
            {
            case "Add":
                //add the available part to the work order as a work order part
                //get the selectd part ID
                long partID;
                //poart will be PartId | PartName
                var  partIdentifier = model.SelectedPart.Split('|');
                bool parsed         = long.TryParse(partIdentifier[0], out partID);
                if (parsed)
                {
                    mobileWorkOrderFactory.AddPartToWorkOrder(partID, model.WorkOrderId, model.PartNote);
                }
                break;

            case "Save":
                //rebuild the model with the work order parts and quantities passed in from the forms colleciton
                model = RebuildTechnicianWorkOrderDetailsModel(model, formValues);
                //now pass it to the factory to update part quantities
                //save all of the part values and then send them back to this page again
                mobileWorkOrderFactory.UpdateWorkOrderPartQuantities(model);
                break;
            }
            //now send them back to this page so the user can see the modifications
            return(RedirectToAction("Parts", new { workOrderId = model.WorkOrderId, selectedSort, sortDirection }));
        }
Beispiel #2
0
        public ActionResult RejectWorkOrder(TechnicianWorkOrderDetailsModel model, string selectedSort, string sortDirection, string submitButton)
        {
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            var mobileWorkOrderFactory = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(), Session[Constants.Security.ConnectionStringSessionVariableName].ToString()));

            //get the two
            mobileWorkOrderFactory.UpdateNotes(model.WorkOrderId, model.Notes);
            //check the other submit buttons and act on them, or continue
            switch (submitButton)
            {
            case "Reject":
                mobileWorkOrderFactory.RejectWorkOrder(model.WorkOrderId);
                //now send them back to the details.
                return(RedirectToAction("WorkOrders", new { selectedSort, sortDirection }));

                break;
            }

            //if we got this far, something failed. add error to model and display to user
            ModelState.AddModelError(Constants.ViewData.ModelStateStatusKey, (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.StatusMessage, "An error occurred. Try again."));
            var techWorkOrder = mobileWorkOrderFactory.GetWorkOrderDetails(model.WorkOrderId, CurrentCity.Id, CurrentCity.LocalTime);

            return(View("RejectWorkOrder", techWorkOrder));
        }
Beispiel #3
0
        public ActionResult Images(TechnicianWorkOrderDetailsModel model, string selectedSort, string sortDirection, IEnumerable <HttpPostedFileBase> files)
        {
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            var mobileWorkOrderFactory = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(), Session[Constants.Security.ConnectionStringSessionVariableName].ToString()));

            //now we need to add the images to the work order (if there are any)
            if (files != null)
            {
                foreach (var file in files)
                {
                    mobileWorkOrderFactory.CreateWorkOrderImage(model.WorkOrderId, ImageFactory.StreamToByteArray(file.InputStream), CurrentCity.LocalTime);
                }
            }
            return(RedirectToAction("ResolveWorkOrder", new { model.WorkOrderId, selectedSort, sortDirection }));
        }
Beispiel #4
0
        public ActionResult ResolveWorkOrder(TechnicianWorkOrderDetailsModel model, string selectedSort, string sortDirection, string submitButton, string ddlVandalism)
        {
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            var mobileWorkOrderFactory = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(), Session[Constants.Security.ConnectionStringSessionVariableName].ToString()));

            //get the two
            mobileWorkOrderFactory.UpdateNotes(model.WorkOrderId, model.Notes);
            //check the other submit buttons and act on them, or continue
            switch (submitButton)
            {
            case "Parts":
                return(RedirectToAction("Parts", new { workOrderId = model.WorkOrderId, selectedSort, sortDirection }));

            case "Images":
                return(RedirectToAction("Images", new { workOrderId = model.WorkOrderId, selectedSort, sortDirection }));

            case "Close":
                //have to get hte vandalism flag and the resolution code from the user selections
                int resCode;
                int.TryParse(model.SelectedRepairDescription, out resCode);
                bool vandalism = ddlVandalism == "Yes";
                mobileWorkOrderFactory.ResolveWorkOrder(model.WorkOrderId, resCode, vandalism);

                //check to see if the work order evetns closed correctly.
                if (!string.IsNullOrEmpty(mobileWorkOrderFactory.ErrorMessage))
                {
                    //if we got this far, something failed. add error to model and display to user
                    ModelState.AddModelError(Constants.ViewData.ModelStateStatusKey, (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.StatusMessage, mobileWorkOrderFactory.ErrorMessage));
                    var tWorkOrder = mobileWorkOrderFactory.GetWorkOrderDetails(model.WorkOrderId, CurrentCity.Id, CurrentCity.LocalTime);
                    return(View("ResolveWorkOrder", tWorkOrder));
                }

                //now send them back to the details.
                return(RedirectToAction("WorkOrders", new { selectedSort, sortDirection }));
            }

            //if we got this far, something failed. add error to model and display to user
            ModelState.AddModelError(Constants.ViewData.ModelStateStatusKey, (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.StatusMessage, "An error occurred. Try again."));

            var techWorkOrder = mobileWorkOrderFactory.GetWorkOrderDetails(model.WorkOrderId, CurrentCity.Id, CurrentCity.LocalTime);

            return(View("ResolveWorkOrder", techWorkOrder));
        }
Beispiel #5
0
        public ActionResult WorkSiteSafe(TechnicianWorkOrderDetailsModel model, string selectedSort, string sortDirection, string submitButton, IEnumerable <HttpPostedFileBase> files)
        {
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            var mobileWorkOrderFactory = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(), Session[Constants.Security.ConnectionStringSessionVariableName].ToString()));

            //get the two
            //check the other submit buttons and act on them, or continue
            //update the notes for this work order
            mobileWorkOrderFactory.UpdateNotes(model.WorkOrderId, model.Notes);
            //now we need to add the images to the work order (if there are any)
            if (files != null)
            {
                foreach (var file in files)
                {
                    mobileWorkOrderFactory.CreateWorkOrderImage(model.WorkOrderId, ImageFactory.StreamToByteArray(file.InputStream), CurrentCity.LocalTime);
                }
            }

            switch (submitButton)
            {
            case "Next":
                //send them to the work order details page
                return(RedirectToAction("WorkOrderDetails", new { model.WorkOrderId, selectedSort, sortDirection }));

            case "Suspend":
                //put it back in the unassigned pool
                mobileWorkOrderFactory.SuspendWorkOrder(model.WorkOrderId);
                ////now send them back to the listing page
                return(RedirectToAction("WorkOrders", new { selectedSort, sortDirection }));

                break;
            }

            //if we got this far, something failed. add error to model and display to user
            ModelState.AddModelError(Constants.ViewData.ModelStateStatusKey, (new ResourceFactory()).GetLocalizedTitle(ResourceTypes.StatusMessage, "An error occurred. Try again."));

            var techWorkOrder = mobileWorkOrderFactory.GetWorkOrderDetails(model.WorkOrderId, CurrentCity.Id, CurrentCity.LocalTime);

            return(View("WorkSiteSafe", techWorkOrder));
        }
Beispiel #6
0
        private TechnicianWorkOrderDetailsModel RebuildTechnicianWorkOrderDetailsModel(TechnicianWorkOrderDetailsModel model, FormCollection formValues)
        {
            // Prep the Model.Coins class
            if (model.WorkOrderParts == null)
            {
                model.WorkOrderParts = new List <WorkOrderPart>();
            }

            // Walk the form fields and set any values in the model to values reflected by
            // the form fields.
            foreach (var formValueKey in formValues.Keys)
            {
                string[] tokens    = formValueKey.ToString().Split(model.Separator);
                var      formValue = formValues[formValueKey.ToString()];


                //token is going to be "partId_" then the id of the part
                if (tokens.Length < 2)
                {
                    continue;
                }
                // Get model id
                int woPartId = int.Parse(tokens[1]);

                if (tokens[0].Equals(TechnicianWorkOrderDetailsModel.PartIdPrefix))
                {
                    //this is a textbox that represents a number (quantity). try to part it as an int.
                    int quantity;
                    var parsed = int.TryParse(formValue, out quantity);
                    if (parsed)
                    {
                        //create a work order part and add it to the list
                        var woPart = new WorkOrderPart();
                        woPart.WorkOrderPartId = woPartId;
                        woPart.Quantity        = quantity;
                        model.WorkOrderParts.Add(woPart);
                    }
                    else
                    {
                        //if we cant parse it, they either didnt put anything there, or put a nonsensical value (a), so set it to 0 so we can remove it.
                        var woPart = new WorkOrderPart();
                        woPart.WorkOrderPartId = woPartId;
                        woPart.Quantity        = 0;
                        model.WorkOrderParts.Add(woPart);
                    }
                }
            }
            return(model);
        }
 /// <summary>
 /// Updates work order part quantities on all of the work order parts for a work order.
 /// The only data fora work order part that it is expecting is workOrderPartId and Quantity for a work order part.
 /// </summary>
 /// <param name="model"></param>
 public void UpdateWorkOrderPartQuantities(TechnicianWorkOrderDetailsModel model)
 {
     UpdatePartQuantities(model.WorkOrderParts, model.WorkOrderId);
 }
        /// <summary>
        /// Gets the mobile version of the work order details screen
        /// </summary>
        /// <param name="workOrderId"></param>
        /// <param name="customerId"></param>
        /// <param name="localTime"></param>
        /// <returns></returns>
        public TechnicianWorkOrderDetailsModel GetWorkOrderDetails(long workOrderId, int customerId, DateTime localTime)
        {
            var model = new TechnicianWorkOrderDetailsModel();
            //get the work order
            var workOrder = MaintenanceEntities.FMWorkOrders.FirstOrDefault(x => x.WorkOrderId == workOrderId);

            if (workOrder != null)
            {
                //convert it to our enetity
                model.Deadline     = workOrder.SLADue;
                model.Location     = workOrder.Location;
                model.Status       = workOrder.WorkOrderStatu.WorkOrderStatusDesc;
                model.WorkOrderId  = workOrder.WorkOrderId;
                model.Notes        = workOrder.Notes;
                model.CreationDate = workOrder.CreateDateTime;
                model.CrossStreet  = workOrder.CrossStreet;
                //create the asset for this work order
                model.WorkOrderAsset = MakeWorkOrderAsset(workOrder, customerId);

                //create a list of images
                model.WorkOrderImages = MakeWorkOrderImages(workOrder.WorkOrderImages);

                //create a list of events
                model.WorkOrderEvents = MakeWorkOrderEvents(workOrder.WorkOrderEvents);

                //Repair Descriptions (used for closing the work order)
                model.RepairDescriptions = GetRepairDescriptions();

                //available parts for this work order (based ont he asset id - metergroup of hte work order)
                model.AvailableParts = GetAvailableParts(workOrder.MeterGroup, workOrder.Mechanism);

                //list of parts assigned to this work order
                model.WorkOrderParts = MakeWorkOrderParts(workOrder.WorkOrderParts);

                //highest severity of all the work order events
                model.Priority = workOrder.HighestSeverity;

                //fix up alarm tier (priority) display - have to go back to pems for this info.
                var tier = PemsEntities.AlarmTiers.FirstOrDefault(x => x.Tier == workOrder.HighestSeverity);
                model.PriorityDisplay = tier != null ? tier.TierDesc : HttpContext.Current.GetLocaleResource(ResourceTypes.Label, "Minor");

                //list of all past work orders inthe last 14 days (this migh have to be configurable per client todo)
                var pastDatetime   = localTime.AddDays(-14);
                var pastWorkOrders =
                    MaintenanceEntities.FMWorkOrders.Where(
                        x => x.MeterId == workOrder.MeterId && x.WorkOrderId != workOrderId && x.CreateDateTime >= pastDatetime);
                model.PastWorkOrders = pastWorkOrders.Any()? pastWorkOrders.Count().ToString(): "0";


                //set the flag based on the current customer to determine if they need to close the entire work order out or per events
                var settingFactory             = new SettingsFactory();
                var workOrderCloseEventSetting = settingFactory.GetValue("CloseWorkOrderEvents", customerId);
                //if it doenst exist, create it
                if (workOrderCloseEventSetting == null)
                {
                    settingFactory.Set(customerId, "CloseWorkOrderEvents", false.ToString());
                }
                workOrderCloseEventSetting = settingFactory.GetValue("CloseWorkOrderEvents", customerId);
                model.CloseWorkOrderEvents = bool.Parse(workOrderCloseEventSetting);
            }
            return(model);
        }