예제 #1
0
        public JsonResult getNewWorkorder(string CID)
        {
            Helpers.CtxService service = new Helpers.CtxService(null, CID);
            int workorder = 0;

            try
            {
                workorder = service.getNewWorkoder();
            } finally
            {
                service.Dispose();
            }
            return(Json(workorder, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Index()
        {
            model.CID = getCID();

            if (model.CID.Trim().Length < 6)
            {
                return(RedirectToAction("Locations", "Manage"));
            }

            service = new Helpers.CtxService(null, model.CID);
            Helpers.ManagerService manageservice = new Helpers.ManagerService();
            try
            {
                model.MFB_Id        = getSelectedFlagboard();
                model.machines      = service.getMachines(model.MFB_Id);
                model.types         = service.getMaintenanceTypes();
                model.employees     = service.getEmployees();
                model.MS_Maint_Code = getMaintCode();
                model.schedule      = getSchedule();
                model.Location      = manageservice.getRecord(model.CID.Trim());
                model.flagboards    = service.getFlagBoards().ToArray();
                model.MFB_label     = getFBLabel(model.MFB_Id);
                model.UserName      = User.Identity.Name;
                UpdateCachedTimers(model.CID);

                model.ActiveTimers = GetActiveTimers(model.CID);
                model.isMobile     = isMobile();
                model.canDelete    = IsAdmin();
                model.ticketname   = ticketname;
            } finally
            {
                service.Dispose();
                model.schedule = filterSchedule(model.schedule);
            }

            if (service.error == true)
            {
                model.errorMessage = service.errorMessage;
            }

            if (model.CID.Length < 6)
            {
                return(RedirectToAction("Locations", "Manage"));
            }

            addLocationCookie(model.CID.Trim());

            return(View(model));
        }
예제 #3
0
        public JsonResult Refresh(short MS_Maint_Code, string hidecompleted, int MFB_Id, string CID, bool Forced)
        {
            //int cpuUsage = cpuPercentage();
            //if (cpuUsage > 80 && Forced == false)
            //    return Json("CPUERR", JsonRequestBehavior.AllowGet);

            Helpers.CtxService service = new Helpers.CtxService(null, CID);
            System.Web.Script.Serialization.JavaScriptSerializer jser = new System.Web.Script.Serialization.JavaScriptSerializer();
            string objSerialized = "";

            try
            {
                List <schedule> updated = new List <schedule>();
                updated = service.getSchedule();

                model.MS_Maint_Code = MS_Maint_Code;
                model.MFB_Id        = MFB_Id;
                updated             = filterSchedule(updated);
                if (hidecompleted == "true")
                {
                    List <schedule> uncompleted = new List <schedule>();
                    foreach (var item in updated)
                    {
                        if (item.MS_WOClosed_Timestamp.Trim().Length == 0)
                        {
                            uncompleted.Add(item);
                        }
                    }
                    objSerialized = jser.Serialize(uncompleted);
                    return(Json(objSerialized, JsonRequestBehavior.AllowGet));
                }

                objSerialized = jser.Serialize(updated);
            }
            catch (Exception ex)
            {
                objSerialized = "ERROR";
            }
            finally
            {
                service.Dispose();
            }
            return(Json(objSerialized, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        private List <Helpers.PageInput> getEditorInputs(string CID, int MFB_Id, int MS_Id = 0)
        {
            List <Helpers.PageInput> inputs = new List <Helpers.PageInput>();

            inputs.Add(getFlagboardDropdown(CID, MFB_Id));

            inputs.Add(getMachineDropdown(CID, MFB_Id));

            inputs.Add(getMTypesDropdown(CID));

            inputs.Add(getEmployeesDropdown(CID));

            if (MS_Id == 0)
            {
                foreach (var item in inputs[inputs.Count - 1].input.options)
                {
                    if (item.text == ". .")
                    {
                        inputs[inputs.Count - 1].input.value = item.value;
                        break;
                    }
                }
            }

            inputs.Add(new Helpers.PageInput("default", "Unscheduled Reason", "MS_Unscheduled_Reason", "MS_Unscheduled_Reason", ""));

            if (MS_Id == 0)
            {
                Helpers.CtxService service = new Helpers.CtxService(null, CID);
                try
                {
                    inputs.Add(new Helpers.PageInput("default", "WorkOrder Number", "MS_Workorder", "MS_Workorder", service.getNewWorkoder().ToString()));
                }
                finally
                {
                    service.Dispose();
                }
            }
            else
            {
                inputs.Add(new Helpers.PageInput("default", "WorkOrder Number", "MS_Workorder", "MS_Workorder", ""));
            }

            Helpers.PageInput lastDate = new Helpers.PageInput("default", "Last Maintenance Date", "MS_Last_Main_Date", "MS_Last_Main_Date", "");
            lastDate.function = "date";
            inputs.Add(lastDate);

            Helpers.PageInput nextDate = new Helpers.PageInput("default", "Next Maintenance Date", "MS_Next_Main_Date", "MS_Next_Main_Date", "");
            nextDate.function = "date";
            inputs.Add(nextDate);

            Helpers.PageInput completed = new Helpers.PageInput("default", "Completed by", "MS_Main_Comp_Date", "MS_Main_Comp_Date", "false");
            completed.function = "checkbox";
            inputs.Add(completed);

            inputs.Add(getMaintCodeDropdown());

            Helpers.PageInput timeAlotted = new Helpers.PageInput("default", "Time Alloted", "MS_Maint_Time_Alotted", "MS_Maint_Time_Alotted", "0");
            timeAlotted.function = "number";
            inputs.Add(timeAlotted);

            Helpers.PageInput timeRequired = new Helpers.PageInput("default", "Time Required", "MS_Maint_Time_Required", "MS_Maint_Time_Required", "0");
            timeRequired.function = "number";
            inputs.Add(timeRequired);

            Helpers.PageInput timeInterval = new Helpers.PageInput("default", "Time Interval", "MS_Frequency", "MS_Frequency", "0");
            timeInterval.function = "number";
            inputs.Add(timeInterval);

            Helpers.PageInput downtime = new Helpers.PageInput("timer", "Total Machine Downtime", "MS_Total_Machine_Downtime", "MS_Total_Machine_Downtime", "0");
            downtime.function = "timer";
            inputs.Add(downtime);

            Helpers.PageInput machineHours = new Helpers.PageInput("default", "Machine Hours", "MS_Machine_Hours", "MS_Machine_Hours", "0");
            machineHours.function = "number";
            inputs.Add(machineHours);

            inputs.Add(new Helpers.PageInput("default", "Notes", "MS_Notes", "MS_Notes", ""));

            return(inputs);
        }
예제 #5
0
        public JsonResult dispatch(string inputs, string type, string CID)
        {
            System.Web.Script.Serialization.JavaScriptSerializer jser = new System.Web.Script.Serialization.JavaScriptSerializer();
            Helpers.CtxService service     = new Helpers.CtxService(null, CID);
            string             userMessage = "";
            int msid = 0;

            if (inputs.Length == 0)
            {
                return(Json("Input Box Objects cannot be empty.", JsonRequestBehavior.AllowGet));
            }

            try
            {
                FlagBoard_mvc.Models.pageInputs[] inputObjects    = jser.Deserialize <FlagBoard_mvc.Models.pageInputs[]>(inputs);
                Helpers.jqGrid <FlagBoard_mvc.Models.schedule> jq = new Helpers.jqGrid <FlagBoard_mvc.Models.schedule>();
                FlagBoard_mvc.Models.schedule record = jq.mapToObjectProperty(inputObjects);
                switch (type)
                {
                case "edit":
                    if (record.MS_Unscheduled_Reason.Trim().Length > 50)
                    {
                        throw new Exception("Unscheduled Reason cannot be greater than 50 characters long.");
                    }

                    int rows = service.Update(record);
                    if (rows > 0 && record.MS_Maint_Code == 1 && record.MS_Main_Comp_Date == "True")
                    {
                        if (record.MS_Frequency < 1)
                        {
                            throw new Exception("Interval must be greater than 0");
                        }
                        AutoAddScheduledOrder(record, service);
                    }
                    userMessage = "true";
                    break;

                case "add":
                    if (record.MS_Unscheduled_Reason.Length > 50)
                    {
                        throw new Exception("Unscheduled Reason cannot be greater than 50 characters long.");
                    }

                    int rowsaff = service.Add(record);
                    service.Dispose();
                    if (rowsaff == 0)
                    {
                        throw new Exception("unknown error adding rows. ");
                    }
                    userMessage = "true";
                    msid        = service.rowKey;
                    break;

                case "delete":
                    service.delete(record.MS_Id);
                    userMessage = "true";
                    break;
                }
            } catch (Exception ex)
            {
                userMessage = "ERROR: " + ex.Message;
            } finally
            {
                service.Dispose();
                service.clearCache();
            }

            return(Json(new { message = userMessage, id = msid }, JsonRequestBehavior.AllowGet));
        }