Пример #1
0
        public HttpResponseMessage GetMachineToolsViewModel(FilterViewModel filters)
        {
            if (filters.period != null)
            {
                _contextService.SetActualPeriod(filters.period.start, filters.period.end);
                _contextService.SetActualMachineGroup(filters.machineGroup);
            }

            var context = _contextService.GetContext();
            var tools   = _toolsViewService.GetTools(context);

            return(Request.CreateResponse(HttpStatusCode.OK, tools, MediaTypeHeaderValue.Parse("application/json")));
        }
Пример #2
0
        public MachineViewModel GetMachine(ContextModel context)
        {
            MachineViewModel machine = new MachineViewModel();

            machine.MachinePanels = _messagesService.GetMachinePanels(context);

            var timeZone = context.User.TimeZone;

            if (context.User.Role == enRole.Customer && context.ActualMachine.TimeZone != null)
            {
                timeZone = context.ActualMachine.TimeZone;
            }

            //prendo come data di lastupdate quella del currentstate

            /*var lastState = _messagesService.GetCurrentStateModel(context.ActualMachine.Id);
             * if (lastState != null)
             * {
             *  context.ActualMachine.LastUpdate = lastState.LastUpdated;
             * }*/

            machine.LastUpdate = new DataUpdateModel()
            {
                DateTime = (DateTime)context.ActualMachine.LastUpdate,
                TimeZone = timeZone
            };
            context.ActualPeriod.LastUpdate.DateTime = machine.LastUpdate.DateTime;
            context.ActualPeriod.LastUpdate.TimeZone = machine.LastUpdate.TimeZone;
            machine.Efficiency     = _efficiencyViewService.GetEfficiency(context);
            machine.Productivity   = _productivityViewService.GetProductivity(context);
            machine.Messages       = _messagesViewService.GetMessages(context);
            machine.Jobs           = _jobsViewService.GetJobs(context);
            machine.PanelParameter = _panelParametersViewService.GetParameters(context);
            machine.Tools          = _toolsViewService.GetTools(context);
            machine.MachineInfo    = new MachineInfoViewModel
            {
                model       = context.ActualMachine.Model.Name,
                mtype       = context.ActualMachine.Type.Name,
                id_mtype    = context.ActualMachine.Type.Id,
                machineName = context.ActualMachine.MachineName,
                timeZone    = context.ActualMachine.TimeZone,
                modelCode   = context.ActualMachine.Model.ModelCodev997
            };

            machine.XTools      = _xToolsViewService.GetXTools(context);
            machine.Maintenance = _maintenanceViewService.GetMessages(context);

            return(machine);
        }