示例#1
0
        public void CreateDashboardAndWidgets_Test()
        {
            var newDash = new CustomDashboard
            {
                CreatedBy   = 4,
                DateCreated = DateTime.Now,
                Name        = "New Dash",
                IsPublic    = false,
                Widgets     = new List <Widget>
                {
                    new Widget
                    {
                        ControlName = "Widget1.cshtml",
                        DisplayName = "Widget 1"
                    },
                    new Widget
                    {
                        ControlName = "Widget2.cshtml",
                        DisplayName = "Widget 2"
                    },
                    new Widget
                    {
                        ControlName = "Widget3.cshtml",
                        DisplayName = "Widget 3"
                    }
                }
            };

            var result = service.CreateDashboard(newDash);

            Assert.IsTrue(result > 0);
        }
        /// <summary>
        /// Add By Nandish Shah
        /// Get Custom Report List
        /// </summary>
        /// <returns>List<CurrencyModel.ClientCurrency></returns>
        public ActionResult GetCustomReport(string DashboardId = "", string ConnectionString = "")
        {
            Custom_Dashboard model = new Custom_Dashboard();
            CustomDashboard  cd    = new CustomDashboard();

            if (!string.IsNullOrEmpty(DashboardId))
            {
                int DashId = int.Parse(DashboardId.ToString());
                model = cd.GetMainDashBoardInfo(DashId);

                string regularConnectionString = ConnectionString;

                string ReportDBConnString = string.Empty;
                if (!string.IsNullOrEmpty(Convert.ToString(regularConnectionString)))
                {
                    ReportDBConnString = Convert.ToString(regularConnectionString.ToString().Replace(@"\", @"\\"));
                }

                string AuthorizedReportAPIUserName = string.Empty;
                if (ConfigurationManager.AppSettings.Count > 0)
                {
                    if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIUserName"])))
                    {
                        AuthorizedReportAPIUserName = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIUserName");
                    }
                }

                string AuthorizedReportAPIPassword = string.Empty;
                if (ConfigurationManager.AppSettings.Count > 0)
                {
                    if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["AuthorizedReportAPIPassword"])))
                    {
                        AuthorizedReportAPIPassword = System.Configuration.ConfigurationManager.AppSettings.Get("AuthorizedReportAPIPassword");
                    }
                }
                string ApiUrl = string.Empty;
                if (ConfigurationManager.AppSettings.Count > 0)
                {
                    if (!string.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["IntegrationApi"])))
                    {
                        ApiUrl = System.Configuration.ConfigurationManager.AppSettings.Get("IntegrationApi");
                    }
                }

                ViewBag.ReportDBConnString          = ReportDBConnString;
                ViewBag.AuthorizedReportAPIUserName = AuthorizedReportAPIUserName;
                ViewBag.AuthorizedReportAPIPassword = AuthorizedReportAPIPassword;
                ViewBag.ApiUrl = ApiUrl;
            }

            return(View("Index", model));
        }
示例#3
0
        public void CreateDashboard_Test()
        {
            var widgets = service.GetAllWidgets();

            var newDash = new CustomDashboard
            {
                CreatedBy   = 1,
                DateCreated = DateTime.Now,
                Name        = "Custom Dash 2",
                IsPublic    = true,
                Widgets     = widgets.ToList()
            };

            var result = service.CreateDashboard(newDash);

            Assert.IsTrue(result > 0);
        }
示例#4
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            int PageSize   = 1000;
            int PageNumber = 1;

            if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
            {
                CustomDashboard CustomOutPut = new CustomDashboard();
                CustomOutPut.KotakEmpat      = new RekapKotakEmpatOutputModel();
                CustomOutPut.PurchaseAndBook = new List <ReportPurchaseAndBookOutputModel>();
                CustomOutPut.Chard           = new ChardModel();
                CustomOutPut.SiteProblem     = new List <ReportProblemListOutputModel>();

                ReportKotaEmpatInputModel       filter1 = new ReportKotaEmpatInputModel();
                ReportPurchaseAndBookInputModel filter2 = new ReportPurchaseAndBookInputModel();
                ReportProblemListInputModel     filter3 = new ReportProblemListInputModel();
                if (HttpContext.Session.GetString(SessionKeyRole) != "ADM" && HttpContext.Session.GetString(SessionKeyRole) != "SPV")
                {
                    filter1.UserID   = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
                    filter2.UserName = HttpContext.Session.GetString(SessionKeyName);
                }
                filter2.PageSize   = PageSize;
                filter2.PageNumber = PageNumber;
                filter3.isToSPV    = true;
                filter3.PageSize   = PageSize;
                filter3.PageNumber = PageNumber;
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(BaseAPI + "Dashboard/");
                    var responseTask = client.PostAsJsonAsync <ReportKotaEmpatInputModel>("ReportRekapBox", filter1);
                    responseTask.Wait();

                    var result = responseTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var content = result.Content.ReadAsStringAsync();
                        RekapKotakEmpatResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <RekapKotakEmpatResponseModel>(content.Result);
                        if (resutl.data != null)
                        {
                            CustomOutPut.KotakEmpat.TotalUseSite = resutl.data.TotalUseSite;
                            CustomOutPut.KotakEmpat.TotalSite    = resutl.data.TotalSite;
                            CustomOutPut.KotakEmpat.Revenue      = resutl.data.Revenue;
                            CustomOutPut.KotakEmpat.TotalRevenue = resutl.data.TotalRevenue;
                            CustomOutPut.KotakEmpat.TotalBooking = resutl.data.TotalBooking;
                            CustomOutPut.KotakEmpat.TotalOrder   = resutl.data.TotalOrder;
                        }
                    }
                    else                     //web api sent error response
                    {
                        //log response status here..
                        ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                    }
                }
                using (var client1 = new HttpClient())
                {
                    client1.BaseAddress = new Uri(BaseAPI + "Dashboard/");
                    var responseTask1 = client1.PostAsJsonAsync <ReportPurchaseAndBookInputModel>("ReportPurchaseAndBook", filter2);
                    responseTask1.Wait();

                    var result1 = responseTask1.Result;
                    if (result1.IsSuccessStatusCode)
                    {
                        var content = result1.Content.ReadAsStringAsync();
                        ReportPurchaseAndModelResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportPurchaseAndModelResponseModel>(content.Result);
                        CustomOutPut.PurchaseAndBook = resutl.data;
                    }
                    else                     //web api sent error response
                    {
                        //log response status here..
                        ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                    }
                }
                using (var client2 = new HttpClient())
                {
                    client2.BaseAddress = new Uri(BaseAPI + "Dashboard/");
                    var responseTask1 = client2.PostAsync("ReportChartBookPerMonth", null);
                    responseTask1.Wait();

                    var result1 = responseTask1.Result;
                    if (result1.IsSuccessStatusCode)
                    {
                        var content = result1.Content.ReadAsStringAsync();
                        ChardResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ChardResponseModel>(content.Result);
                        CustomOutPut.Chard = resutl.data;
                    }
                    else                     //web api sent error response
                    {
                        //log response status here..
                        ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                    }
                }
                using (var client3 = new HttpClient())
                {
                    client3.BaseAddress = new Uri(BaseAPI + "Admin/");
                    var responseTask1 = client3.PostAsJsonAsync <ReportProblemListInputModel>("ViewReportProblemSiteList", filter3);
                    responseTask1.Wait();

                    var result1 = responseTask1.Result;
                    if (result1.IsSuccessStatusCode)
                    {
                        var content = result1.Content.ReadAsStringAsync();
                        ReportProblemListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportProblemListResponseModel>(content.Result);
                        CustomOutPut.SiteProblem = resutl.data;
                    }
                    else                     //web api sent error response
                    {
                        //log response status here..
                        ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                    }
                }

                return(View(CustomOutPut));
            }
            else
            {
                TempData["CustomError"] = "Silakan masuk sebelum menggunakan situs web.";
                //if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV")
                //{
                //	return RedirectToAction("AdminLogon", "Login");
                //}
                //else if (HttpContext.Session.GetString(Loginfrom) == "MDO")
                //{
                //	return RedirectToAction("OwnerLogon", "Login");
                //}
                //else
                //{
                //	return RedirectToAction("OwnerLogon", "Login");
                //}
                return(RedirectToAction("Logon", "Login"));
            }
        }
 public int DeleteDashboard(CustomDashboard dashboard)
 {
     settingsUOW.DashboardRepository.Delete(dashboard);
     return(settingsUOW.Commit());
 }
 public int UpdateDashboard(CustomDashboard dashboard)
 {
     settingsUOW.DashboardRepository.AttachForUpdate(dashboard);
     settingsUOW.UpdateEntityState(dashboard, EntityState.Modified);
     return(settingsUOW.Commit());
 }
 public int CreateDashboard(CustomDashboard dashboard)
 {
     settingsUOW.DashboardRepository.Add(dashboard);
     return(settingsUOW.Commit());
 }
示例#8
0
文件: MainForm.cs 项目: x893/OBDwiz
        public MainForm(string[] arguments)
        {
            m_loading = true;
            Visible = false;
            m_prefences = new Preferences(getPreferencesPath);
            Localization.SetCulture(m_prefences.General.Culture);

            InitializeComponent();

            m_Port_ECU_Status = new MainForm.UltraStatusBarEx(m_statusPortECU);

            this.Icon = OCTech.OBD2.Applications.Properties.Resources.Application;
            this.Text = MainForm.ApplicationName;
            string titleBarCompany = Localization.GetTitleBarCompany(m_prefences.General.Culture);
            if (!string.IsNullOrEmpty(titleBarCompany))
                Text = string.Format("{0} - {1}", Text, titleBarCompany);
            m_statusErrorECU = Localization.GetStatusBarBanner(m_prefences.General.Culture);

            m_mainForm = (Form)this;
            processCommandOptions(arguments);

            this.Disposed += new EventHandler(mainForm_Disposed);

            Version version = m_scanTool.GetType().Assembly.GetName().Version;
            int unlock = version.Major ^ version.Minor ^ version.Build ^ version.Revision;
            m_scanTool.Unlock(unlock);

            FileUtility.PathResolverReplacements.Add("[ApplicationName]", MainForm.ApplicationName);

            LoggableItem.RegisterLoggableItem(
                typeof(PIDLoggableItem),
                new LoggableItemXmlReader(PIDLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(FuelLoggableItem),
                new LoggableItemXmlReader(FuelLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(UserPIDLoggableItem),
                new LoggableItemXmlReader(UserPIDLoggableItem.FromXml)
                );
            LoggableItem.RegisterLoggableItem(
                typeof(PIDPluginLoggableItem),
                new LoggableItemXmlReader(PIDPluginLoggableItem.FromXml)
                );

            if (m_prefences.Layout.TouchScreenSize)
            {
                customListView.ItemSpacing = ListViewItemSpacing.Small;
                toolStripContainer.TopToolStripPanelVisible = false;
            }

            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.SetupPageName,
                "Setup",
                OCTech.OBD2.Applications.Properties.Resources.p000075
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.DiagPageName,
                "Diagnostics",
                OCTech.OBD2.Applications.Properties.Resources.p000026
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.MonitorsPageName,
                "Monitors",
                OCTech.OBD2.Applications.Properties.Resources.p000045
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.DashboardPageName,
                "Dashboard",
                OCTech.OBD2.Applications.Properties.Resources.p000015
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.LogsPageName,
                "Logs",
                OCTech.OBD2.Applications.Properties.Resources.p000043
                );
            customListView.Add(
                OCTech.OBD2.Applications.Properties.Resources.ExitText,
                "Exit",
                OCTech.OBD2.Applications.Properties.Resources.p000032,
                true
                );

            customListView.ItemSelected += new EventHandler<CustomListViewItemSelectedEventArgs>(customListView_ItemSelected);
            customListView.Font = this.Font;

            CurrentOperationStatus = OCTech.OBD2.Applications.Properties.Resources.SystemReadyText;
            ConnectedStatus = ConnectionStatus.NotConnected;

            if (m_prefences.Layout.SelectedPageKey == "Exit"
            || !m_prefences.Layout.RememberLastPageOnStartup
            || string.IsNullOrEmpty(m_prefences.Layout.SelectedPageKey)
                )
                m_prefences.Layout.SelectedPageKey = "Setup";

            m_scanTool.CommunicationErrorOccurred += new EventHandler<MessageEventArgs>(m_scanTool_CommunicationErrorOccurred);
            m_scanTool.SelectECU += new EventHandler<SelectedECUEventArgs>(m_scanTool_SelectECU);
            m_scanTool.ConnectionChanged += new EventHandler(m_scanTool_ConnectionChanged);
            m_scanTool.ConnectionStatusChanged += new EventHandler<ConnectionStatusChangedEventArgs>(m_scanTool_ConnectionStatusChanged);

            m_pidMonitor = new PIDMonitor(m_scanTool);
            m_pidMonitor.SetCulture(m_prefences.General.Culture);
            m_pidMonitor.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);
            m_pidMonitor.NewPIDResponseArrived += new EventHandler<PIDResponseEventArgs>(m_pidMonitor_NewPIDResponseArrived);
            m_pidMonitor.NewPIDTimingAvailable += new EventHandler<PIDMonitorTimingEventArgs>(m_pidMonitor_NewPIDTimingAvailable);
            m_pidMonitor.Playback.RecordedPlaybackChanged += new EventHandler<RecordedDataPlayBackEventArgs>(m_pidMonitor_RecordedPlaybackChanged);

            FuelCalculator fuelCalculator = new FuelCalculator(m_pidMonitor, m_scanTool);
            fuelCalculator.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);

            vehicleManagement = new VehicleManagement(this, m_scanTool, m_pidMonitor, fuelCalculator, this, MainForm.MyDocumentsPath);

            m_context = new AppContext(m_prefences, this, m_scanTool, m_pidMonitor, fuelCalculator, MainForm.MyDocumentsPath, MainForm.ApplicationDataDirectory, m_messageDispatcher, this, this, vehicleManagement);
            MainForm.m_StaticContext = m_context;

            TripManager.Initialize(m_context.ScanTool, m_context.PidMonitor, m_context.FuelCalculator, MainForm.ApplicationDataDirectory);
            TripManager.ErrorOccurred += new EventHandler<OCTech.Utilities.ExceptionEventArgs>(utilities_ErrorOccurred);

            pluginInitialize();

            sensorCalibration = new SensorCalibration();
            sensorCalibration.Initialize(m_context);

            DispatchPID.Initialize(m_context);

            m_setupPage = new SetupPage(m_context);
            m_setupPage.ColorModeChanged += new EventHandler<ColorModeChangedEventArgs>(m_setupPage_ColorModeChanged);

            m_diagnostic = new DiagnosticsPage(m_context);
            m_monitors = new MonitorsPage(m_context);
            m_dashboard = new CustomDashboard(m_context);
            m_logs = new LogsPage(m_context);

            m_TabPages.Add("Setup", m_setupPage);
            m_TabPages.Add("Diagnostics", m_diagnostic);
            m_TabPages.Add("Monitors", m_monitors);
            m_TabPages.Add("Dashboard", m_dashboard);
            m_TabPages.Add("Logs", m_logs);

            pagePanel.SuspendLayout();

            addPageToPanel(m_setupPage);
            addPageToPanel(m_diagnostic);
            addPageToPanel(m_monitors);
            addPageToPanel(m_dashboard);
            addPageToPanel(m_logs);

            pagePanel.ResumeLayout();

            m_StripMenus.Add("Setup", setupToolStripMenuItem);
            m_StripMenus.Add("Diagnostics", diagnosticsToolStripMenuItem);
            m_StripMenus.Add("Monitors", monitorsToolStripMenuItem);
            m_StripMenus.Add("Dashboard", dashboardToolStripMenuItem);
            m_StripMenus.Add("Logs", logsToolStripMenuItem);

            setControlsText();
            setConnectButtonState();

            loadOCTechPlugins();
            if (m_PluginsInfo.Plugins.Count == 0 && !PIDPluginController.AreAnyPIDPluginAssembliesLoaded)
                pluginManagerToolStripMenuItem.Visible = false;

            if (!m_TabPages.ContainsKey(m_prefences.Layout.SelectedPageKey))
                m_prefences.Layout.SelectedPageKey = "Setup";
            switchPageByName(m_prefences.Layout.SelectedPageKey);
            customListView.SelectItem(m_prefences.Layout.SelectedPageKey);
            loadDataDashboard(getDataPath);

            try
            {
                m_pidMonitor.LoadSettings(MainForm.ApplicationDataDirectory);
            }
            catch { }

            m_setupPage.m001d9a(m_PluginsInfo);

            setColorTheme(ActiveTheme);
            m_scanTool.DebugEnabled = true;

            Gauge.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            PowerBar.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            RoundedLabel.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
            LinearGauge.ErrorOccurred += new EventHandler<Controls.ExceptionEventArgs>(controls_ErrorOccurred);
        }