Ejemplo n.º 1
0
        public ActionResult TaskExecutorNewCost(TaskExecutorNewCostViewModel c, string FieldToPreventTwoSubmission, string returnUrl, string returnCodTypeOfTask)
        {

            var taskExecutor = taskExecutorRepository.GetSingle(c.CodTaskExecutor);
            TaskEstimatedOn tskEst = null;
            String retView = String.Empty;

            ViewBag.ReturnUrl = returnUrl;
            ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;


            //if cost is just selected (to prevent two submissions)
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count() != 0)
                return RedirectToAction("TaskExecutorCost", new { id = c.CodTaskExecutor });


            if (taskExecutor.CodTypeOfTask == null || !taskExecutor.CodTypeOfTask.StartsWith("STAMPA"))
            {
                // var optionTypeOfTaskList = typeOfTaskRepository.GetSingle(taskExecutor.CodTypeOfTask).OptionTypeOfTasks;

                // foreach (var item in optionTypeOfTaskList.Except(optionTypeOfTaskList.Where(x => x.CodOptionTypeOfTask == taskExecutor.CodTypeOfTask + "_NO")))
                {
                    switch (c.TypeTaskExecutorEstimatedOn)
                    {
                        case TaskEstimatedOn.EstimatedOnType.OnRun:
                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                            {
                                tskEst = new DigitalOnRun();
                                retView = "DigitalOnRun";
                            }
                            else
                            {
                                tskEst = new TaskEstimatedOnRun();
                                retView = "TaskEstimatedOnRun";
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.OnTime:

                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                            {
                                tskEst = new DigitalOnTime();
                                retView = "DigitalOnTime";
                            }
                            else
                            {
                                if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.ControlTableRoll)
                                {
                                    tskEst = new ControlTableRollEstimatedOnTime();
                                    retView = "ControlTableRollEstimatedOnTime";
                                }
                                else
                                {
                                    tskEst = new TaskEstimatedOnTime();
                                    retView = "TaskEstimatedOnTime";
                                }
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.OnMq:

                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterRoll ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterSheet)
                            {
                                tskEst = new PlotterOnMq();
                                retView = "PlotterOnMq";
                            }
                            else
                            {
                                tskEst = new TaskEstimatedOnMq();
                                retView = "TaskEstimatedOnMq";
                            }
                            break;
                        case TaskEstimatedOn.EstimatedOnType.BindingOnTime:
                            break;
                        case TaskEstimatedOn.EstimatedOnType.BindingOnRun:
                            break;
                        default:
                            break;
                    }

                    //     tskEst.CodOptionTypeOfTask = item.CodOptionTypeOfTask;
                    taskExecutor.SetTaskExecutorEstimatedOn.Add(tskEst);

                }
            }
            else
            {
                switch (c.TypeTaskExecutorEstimatedOn)
                {
                    case TaskEstimatedOn.EstimatedOnType.OnRun:
                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                        {
                            tskEst = new DigitalOnRun();
                            retView = "DigitalOnRun";
                        }
                        else
                        {
                            tskEst = new TaskEstimatedOnRun();
                            retView = "TaskEstimatedOnRun";
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.OnTime:

                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalSheet)
                        {
                            tskEst = new DigitalOnTime();
                            retView = "DigitalOnTime";
                        }
                        else
                        {
                            if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo ||
                                taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll)
                            {
                                tskEst = new RollEstimatedOnTime();
                                retView = "RollEstimatedOnTime";
                            }
                            else
                                if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.ControlTableRoll)
                                {
                                    tskEst = new ControlTableRollEstimatedOnTime();
                                    retView = "ControlTableRollEstimatedOnTime";
                                }
                                else
                                {
                                    if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.FlatRoll)
                                    {
                                        tskEst = new FlatRollEstimatedOnTime();
                                        retView = "FlatRollEstimatedOnTime";
                                    }
                                    else
                                    {
                                        tskEst = new TaskEstimatedOnTime();
                                        retView = "TaskEstimatedOnTime";
                                    }
                                }
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.OnMq:

                        if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterRoll ||
                            taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.PlotterSheet)
                        {
                            tskEst = new PlotterOnMq();
                            retView = "PlotterOnMq";
                        }
                        else
                        {
                            tskEst = new TaskEstimatedOnMq();
                            retView = "TaskEstimatedOnMq";
                        }
                        break;
                    case TaskEstimatedOn.EstimatedOnType.BindingOnTime:
                        break;
                    case TaskEstimatedOn.EstimatedOnType.BindingOnRun:
                        break;
                    default:
                        break;
                }

                //Attenzione nella stampa manca l'optiontypeoftask
                taskExecutor.SetTaskExecutorEstimatedOn.Add(tskEst);

            }


            //se diverso da stampa allora devo creare un numero di costi pari alle opzioni di TypeOfTask

            taskExecutorRepository.Edit(taskExecutor);
            taskExecutorRepository.Save();

            GenEmptyStep(taskExecutor);

            ViewBag.ActionMethod = retView;

            //if there are more than one cost return different model and different view
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count > 1)
            {
                ViewBag.ActionMethod = ViewBag.ActionMethod + "s";
                return View("TaskEstimatedOn", taskExecutor.SetTaskExecutorEstimatedOn.ToList());
            }
            else
            {
                return View(ViewBag.ActionMethod, tskEst);
            }

        }
Ejemplo n.º 2
0
        public ActionResult TaskExecutorCost(string id, string returnUrl, string returnCodTypeOfTask)
        {
            var c = new TaskExecutorNewCostViewModel();
            //load from database taskexecutor

            var taskExecutor = taskExecutorRepository.GetSingle(id);
            c.TaskExecutorName = taskExecutor.TaskExecutorName;

            //serve per il ritorno al punto giusto
            ViewBag.ReturnCodTypeOfTask = returnCodTypeOfTask;
            ViewBag.ReturnUrl = returnUrl;

            c.CodTaskExecutor = taskExecutor.CodTaskExecutor;

            ViewBag.TypeCost = "";

            //if cost is not defined we have to redirect to choice page
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count == 0)
            {
                switch (taskExecutor.TypeOfExecutor)
                {
                    case TaskExecutor.ExecutorType.LithoSheet:
                        ViewBag.TypeCost = "RunTime";
                        break;
                    case TaskExecutor.ExecutorType.LithoRoll:
                        ViewBag.TypeCost = "RunTime";
                        break;
                    case TaskExecutor.ExecutorType.DigitalSheet:
                        ViewBag.TypeCost = "RunTime";
                        break;
                    case TaskExecutor.ExecutorType.DigitalRoll:
                        ViewBag.TypeCost = "RunTime";
                        break;
                    case TaskExecutor.ExecutorType.PlotterRoll:
                        ViewBag.TypeCost = "Mq";
                        break;
                    case TaskExecutor.ExecutorType.PlotterSheet:
                        ViewBag.TypeCost = "Mq";
                        break;
                    case TaskExecutor.ExecutorType.PrePostPress:
                        ViewBag.TypeCost = "RunTimeMq";
                        break;
                    case TaskExecutor.ExecutorType.Binding:
                        ViewBag.TypeCost = "RunTime";
                        break;
                    case TaskExecutor.ExecutorType.FlatRoll:
                        ViewBag.TypeCost = "Time";
                        break;
                    default:
                        ViewBag.TypeCost = "RunTimeMq";
                        break;
                }

                return View("TaskExecutorNewCost", c);
            }

            GenEmptyStep(taskExecutor);

            var tskEst = taskExecutor.SetTaskExecutorEstimatedOn.First();
            switch (tskEst.TypeOfEstimatedOn)
            {
                case TaskEstimatedOn.EstimatedOnType.OnRun:
                    ViewBag.ActionMethod = "TaskEstimatedOnRun";
                    if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo ||
                        taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll)
                    {
                        throw new NotImplementedException();
                        ViewBag.ActionMethod = "RollEstimatedOnRun";
                    }
                    break;

                case TaskEstimatedOn.EstimatedOnType.RollEstimatedOnTime:
                    ViewBag.ActionMethod = "RollEstimatedOnTime";
                    break;

                case TaskEstimatedOn.EstimatedOnType.FlatRollEstimatedOnTime:
                    ViewBag.ActionMethod = "FlatRollEstimatedOnTime";
                    break;

                case TaskEstimatedOn.EstimatedOnType.ControlTableRollEstimatedOnTime:
                    ViewBag.ActionMethod = "ControlTableRollEstimatedOnTime";
                    break;

                case TaskEstimatedOn.EstimatedOnType.OnTime:
                    ViewBag.ActionMethod = "TaskEstimatedOnTime";
                    if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo ||
                        taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.DigitalRoll)
                    {
                        throw new NotImplementedException();
                        ViewBag.ActionMethod = "RollEstimatedOnTime";
                    }
                    if (taskExecutor.TypeOfExecutor == TaskExecutor.ExecutorType.ControlTableRoll)
                    {
                        ViewBag.ActionMethod = "ControlTableRollEstimatedOnTime";
                    }
                    break;


                case TaskEstimatedOn.EstimatedOnType.OnMq:
                    ViewBag.ActionMethod = "TaskEstimatedOnMq";
                    break;
                case TaskEstimatedOn.EstimatedOnType.DigitalOnTime:
                    ViewBag.ActionMethod = "DigitalOnTime";
                    break;
                case TaskEstimatedOn.EstimatedOnType.DigitalOnRun:
                    ViewBag.ActionMethod = "DigitalOnRun";
                    break;
                case TaskEstimatedOn.EstimatedOnType.PlotterOnMq:
                    ViewBag.ActionMethod = "PlotterOnMq";
                    break;
                case TaskEstimatedOn.EstimatedOnType.BindingOnTime:
                    break;

                case TaskEstimatedOn.EstimatedOnType.BindingOnRun:
                    break;

                default:
                    break;
            }

            //if there are more than one cost return different model and different view
            if (taskExecutor.SetTaskExecutorEstimatedOn.Count > 1)
            {
                ViewBag.ActionMethod = (string)ViewBag.ActionMethod + "s";
                return View("TaskEstimatedOn", taskExecutor.SetTaskExecutorEstimatedOn.ToList());
            }
            else
            {
                var s = (string)ViewBag.ActionMethod;
                Console.Write(s);
                return View(ViewBag.ActionMethod, tskEst);
            }
        }