Пример #1
0
        public IActionResult Put([FromBody] TrendViewModel model)
        {
            // return a generic HTTP Status 500 (Server Error)
            // if the client payload is invalid.
            if (model == null)
            {
                return(new StatusCodeResult(500));
            }

            // map the ViewModel to the Model
            var trend = model.Adapt <Trend>();

            //override properties that should be set in the client side
            //the fields shown below are required.
            //trend.StoreId = model.StoreId;
            trend.Text  = model.Text;
            trend.Notes = model.Notes;
            trend.Views = model.Views;

            // override those properties
            // that should be set from the server-side only
            trend.CreatedDate      = DateTime.Now;
            trend.LastModifiedDate = trend.CreatedDate;

            // add the new trend
            DbContext.Trends.Add(trend);
            // persist the changes into the Database.
            DbContext.SaveChanges();

            // return the newly-created Result to the client.
            return(new JsonResult(trend.Adapt <TrendViewModel>(), JsonSettings));
        }
Пример #2
0
        public Trend()
        {
            DataContext = ViewModel = new TrendViewModel();
            CompositionTarget.Rendering += CompositionTargetRendering;

            InitializeComponent();
        }
Пример #3
0
        public Trend()
        {
            SetLanguageDictionary();
            InitializeComponent();

            viewModel = this.FindResource("viewModel") as TrendViewModel;
        }
Пример #4
0
        public void TestStartRealTimeOrMixedModeCharting01()
        {
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);

            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
Пример #5
0
        public async Task <ActionResult> Create()
        {
            var viewModel = new TrendViewModel()
            {
                Trend = new Trend()
            };

            return(View(viewModel));
        }
Пример #6
0
        public void TestUpdateChartForRealTimeOrMixedMode03()
        {
            //same as TestUpdateChartForRealTimeOrMixedMode01,but Eval(tempString) throw exception
            DateTime fromTime = new DateTime(2013, 1, 10);
            DateTime toTime   = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;
            TrendViewModel trendViewModel = new TrendViewModel();

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            //stub:
            //OPCServerProxy.GetInstance().IsOPCServerConnected() == true

            //make sure series has contents:
            List <EtyDataPoint> dpList = new List <EtyDataPoint>();
            EtyDataPoint        etyDP  = new EtyDataPoint();

            etyDP.DPColor   = "-32704";
            etyDP.DPName    = TestConst.DP_NAME;
            etyDP.DPEnabled = true;
            etyDP.DPServer  = "TransActiveDataSource";
            etyDP.DPType    = LineType.Line;
            etyDP.DPVisible = true;
            etyDP.DPHost    = "127.0.0.1";
            dpList.Add(etyDP);
            List <EtyFormula> formulaList = new List <EtyFormula>();
            EtyFormula        formula     = new EtyFormula();

            formula.DPColor   = "-32704";
            formula.DPEnabled = true;
            formula.DPLblName = "formulaLblName";
            formula.DPType    = LineType.Line;
            formulaList.Add(formula);
            trendView.InitializeChartForRealTime(dpList, formulaList);

            // (mixedModeCb.Checked && m_startDateRealTime.Date != DateTime.Now.Date)
            CheckBox cb = (CheckBox)viewAccessor.GetField("mixedModeCb");

            cb.Checked = true;
            viewAccessor.SetField("mixedModeCb", cb);
            DateTime dt = new DateTime(2011, 1, 1);

            viewAccessor.SetField("m_startDateRealTime", dt);
            trendView.UpdateChartForRealTimeOrMixedMode(histDPLogMap);
        }
        public async Task <IActionResult> Save([FromBody] TrendViewModel tv)
        {
            try
            {
                var result = await eventsRepo.Update(tv);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new EmaintenanceMessage(ex.Message)));
            }
        }
Пример #8
0
        // GET: Trend/View/{id}
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //var result = await _mobileBusinessService.RetrieveMobile(id.Value);
            var viewModel = new TrendViewModel
            {
                TrendId = id.Value
            };

            return(View(viewModel));
        }
Пример #9
0
        public async Task <ActionResult> GetCountryTrend([FromBody] TrendViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Claims.First(x => x.Type == "UserID").Value;
                var user   = await _userRepo.GetUserById(userId);

                APIDetails details  = _contextRepo.GetAPIDetails(user);
                long       newWoeid = long.Parse(model.WoeID);
                var        trends   = _helper.GetTrendsFromPlace(newWoeid, details);

                return(Ok(new
                {
                    location = trends.woeIdLocations,
                    trending = trends.Trends
                }));
            }
            return(BadRequest("Woe ID is empty"));
        }
Пример #10
0
        public void TestStartRealTimeOrMixedModeCharting02()
        { //stub:IsOPCServerConnected = true
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);

            System.Windows.Forms.CheckBox cb = (System.Windows.Forms.CheckBox)viewAccessor.GetField("mixedModeCb");
            cb.Checked = false;
            viewAccessor.SetField("mixedModeCb", cb);

            //stub: OPCServerProxy.GetInstance().IsOPCServerConnected() == true:
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);

            //mixedModeCb.Checked==true:
            cb.Checked = true;
            viewAccessor.SetField("mixedModeCb", cb);
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
Пример #11
0
        public async Task <ActionResult> Create(TrendViewModel trendViewModel)
        {
            if (ModelState.IsValid)
            {
                //Create Trend
                trendViewModel.Trend.CreatedDateTime = DateTime.UtcNow;
                var result = await _trendBusinessService.CreateTrend(trendViewModel.Trend);

                if (result.Succeeded)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError("", result.Exception);
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError("", error);
                }
            }
            return(View(trendViewModel));
        }
Пример #12
0
        public async Task<IEnumerable<dynamic>> Update([FromBody] TrendViewModel evm)
        {
            string sql = "";
            using (var conn = util.MasterCon())
            {
                try
                {
                    return await (conn.QueryAsync<dynamic>(sql, new
                    {
                        evm.time,
                        evm.monitorId,
                        evm.jsonavg,
                        evm.jsonmin


                    }, commandType: CommandType.StoredProcedure));
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save Or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }
Пример #13
0
        public void TestDrawHistoryChart()
        {
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;
            histDP.DPColor         = "-32704";

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.Mixed, histDPLogMap);

            logList = new List <EtyDataLogDPLogTrend>();
            EtyDataLogDPLogTrend log = new EtyDataLogDPLogTrend();

            logList.Add(log);
            histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();
            histDPLogMap.Add(histDP, logList);
            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.Mixed, histDPLogMap);

            viewAccessor.Call("DrawHistoryChart", DrawHistoryMode.NotMixed, histDPLogMap);
        }
Пример #14
0
        public void TestStartRealTimeOrMixedModeCharting04()
        {
            //stub:IsOPCServerConnected = false
            ////RemoveAllOPCItem throw Exception
            DataPointListModel  dataPointListModel = new DataPointListModel();
            List <EtyDataPoint> dpList             = dataPointListModel.GetDPListByGrp(TestConst.GROUP_NAME);

            TrendViewModel trendViewModel = new TrendViewModel();
            DateTime       fromTime       = new DateTime(2013, 1, 10);
            DateTime       toTime         = new DateTime(2013, 1, 12);

            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = TestConst.HIST_DP_NAME;
            histDP.DPServer        = TestConst.SERVER;
            histDP.DPStartDateTime = fromTime;
            histDP.DPEndDateTime   = toTime;
            histDP.DPEnabled       = true;
            histDP.DPHost          = TestConst.HOST;
            histDP.DPType          = LineType.Line;

            List <EtyDataLogDPLogTrend> logList = trendViewModel.GetHistDPLogList(histDP, fromTime, toTime);
            Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> > histDPLogMap = new Dictionary <EtyHistDataPoint, List <EtyDataLogDPLogTrend> >();

            histDPLogMap.Add(histDP, logList);

            MarkerListModel  markerListModel = new MarkerListModel();
            List <EtyMarker> markerList      = markerListModel.GetMarkerListByGrp(TestConst.MARK_GROUP_NAME);

            FormulaListModel  formulaListModel = new FormulaListModel();
            List <EtyFormula> formulaList      = formulaListModel.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME);


            //stub: OPCServerProxy.GetInstance().IsOPCServerConnected()==true  //OPC server connected
            // OPCServerProxy.GetInstance().RemoveAllOPCItem() throw System.Exception
            trendView.StartRealTimeOrMixedModeCharting(dpList, formulaList, markerList, histDPLogMap);
        }
Пример #15
0
        public IActionResult Post([FromBody] TrendViewModel model)
        {
            // return a generic HTTP Status 500 (Server Error)
            // if the client payload is invalid.
            if (model == null)
            {
                return(new StatusCodeResult(500));
            }

            // retrieve the result to edit
            var trend = DbContext.Trends.Where(q => q.Id == model.Id).FirstOrDefault();

            // handle requests asking for non-existing trends
            if (trend == null)
            {
                return(NotFound(new
                {
                    Error = String.Format("Trend ID {0} has not been found", model.Id)
                }));
            }
            // handle the update (without object-mapping)
            // by manually assigning the properties
            // we want to accept from the request
            trend.StoreId = model.StoreId;
            trend.Text    = model.Text;
            trend.Notes   = model.Notes;
            trend.Views   = model.Views;

            // properties set from server-side
            trend.LastModifiedDate = trend.CreatedDate;

            // persist the changes into the Database.
            DbContext.SaveChanges();
            // return the updated Quiz to the client.
            return(new JsonResult(trend.Adapt <TrendViewModel>(), JsonSettings));
        }
 public override void AttachCallBack(IModel model, IView view)
 {
     m_Model = (TrendViewModel)model;
     m_View  = (TrendViewer.View.TrendView)view;
     OPCServerProxy.GetInstance().AddObserver(this);
 }
        public IView CreateView(string type, string id)
        {
            IView       view       = null;
            IController controller = null;
            IModel      model      = null;

            switch (type)
            {
            case  TrendViewConst.About:
                view          = new About();
                view.ViewType = TrendViewConst.About;
                break;

            case TrendViewConst.TrendView:
                view          = new TrendView();
                view.ViewType = TrendViewConst.TrendView;
                controller    = new TrendViewController();
                model         = new TrendViewModel();
                controller.Attach(model, view);
                break;

            // marker related:
            case TrendViewConst.MarkerList:
                view          = new MarkerList();
                view.ViewType = TrendViewConst.MarkerList;
                controller    = new MarkerListController();
                model         = new MarkerListModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.LoadConfigMarker:
                view       = new MarkerGroup();
                controller = new MarkerGroupController();
                model      = new MarkerGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.SaveConfigMarker:
                view       = new MarkerGroup();
                controller = new MarkerGroupController();
                model      = new MarkerGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.AddMarkerData:
                view       = new MarkerData();
                controller = new MarkerDataController();
                model      = new MarkerDataModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.EditMarkerData:
                view       = new MarkerData();
                controller = new MarkerDataController();
                model      = new MarkerDataModel();
                controller.Attach(model, view);
                break;

            // formula related:
            case TrendViewConst.FormulaList:
                view          = new FormulaList();
                view.ViewType = TrendViewConst.FormulaList;
                controller    = new FormulaListController();
                model         = new FormulaListModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.LoadConfigFormula:
                view       = new FormulaGroup();
                controller = new FormulaGroupController();
                model      = new FormulaGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.SaveConfigFormula:
                view       = new FormulaGroup();
                controller = new FormulaGroupController();
                model      = new FormulaGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.AddFormulaData:
                view       = new FormulaData();
                controller = new FormulaDataController();
                model      = new FormulaDataModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.EditFormulaData:
                view       = new FormulaData();
                controller = new FormulaDataController();
                model      = new FormulaDataModel();
                controller.Attach(model, view);
                break;

            // DP related:
            case TrendViewConst.DataPointList:
                view          = new DataPointList();
                view.ViewType = TrendViewConst.DataPointList;
                controller    = new DataPointListController();
                model         = new DataPointListModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.LoadConfigDataPoint:
                view       = new DataPointGroup();
                controller = new DataPointGroupController();
                model      = new DataPointGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.SaveConfigDataPoint:
                view       = new DataPointGroup();
                controller = new DataPointGroupController();
                model      = new DataPointGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.AddDataPointData:
                view       = new DataPointData();
                controller = new DataPointDataController();
                model      = new DataPointDataModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.EditDataPointData:
                view       = new DataPointData();
                controller = new DataPointDataController();
                model      = new DataPointDataModel();
                controller.Attach(model, view);
                break;

            //Hist DP related:
            case TrendViewConst.HistDataPointList:
                view          = new HistDataPointList();
                view.ViewType = TrendViewConst.HistDataPointList;
                controller    = new HistDataPointListController();
                model         = new HistDataPointListModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.LoadConfigHistDataPoint:
                view       = new HistDataPointGroup();
                controller = new HistDataPointGroupController();
                model      = new HistDataPointGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.SaveConfigHistDataPoint:
                view       = new HistDataPointGroup();
                controller = new HistDataPointGroupController();
                model      = new HistDataPointGroupModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.AddHistDataPointData:
                view       = new HistDataPointData();
                controller = new HistDataPointDataController();
                model      = new HistDataPointDataModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.EditHistDataPointData:
                view       = new HistDataPointData();
                controller = new HistDataPointDataController();
                model      = new HistDataPointDataModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.OPCDataSelector:
                view       = new OPCDataSelector();
                controller = new OPCDataSelectorController();
                model      = new OPCDataSelectorModel();
                controller.Attach(model, view);
                break;

            case TrendViewConst.ChangeTrendTitle:
                view       = new EditChartTitle();
                controller = new ChangeTrendTitleController();
                model      = null;
                controller.Attach(model, view);
                break;

            default:
                break;
            }
            view.ViewID = id;
            return(view);
        }