public DashboardModule() : base("/api") { this.RequiresAuthentication(); Get["{term}/dashboard"] = _ => { string s = _.term; Guid g = Guid.Parse(_.term); var loc = s.Replace("-", ""); var cs = ConfigurationTransfer.GetData(loc); var co = new ConfigurationObject { ActualCountY = cs.ActualCountY != "" ? Convert.ToInt32(cs.ActualCountY) : 0, ActualCountR = cs.ActualCountR != "" ? Convert.ToInt32(cs.ActualCountR) : 0, ImgCountY = cs.ImgCountY != "" ? Convert.ToDouble(cs.ImgCountY) : 0.0, ImgCountR = cs.ImgCountR != "" ? Convert.ToDouble(cs.ImgCountR) : 0.0, FlowRateY = cs.FlowRateY != "" ? Convert.ToInt32(cs.FlowRateY) : 0, FlowRateR = cs.FlowRateR != "" ? Convert.ToInt32(cs.FlowRateR) : 0, OffsetValue = cs.OffsetValue != "" ? Convert.ToInt32(cs.OffsetValue) : 0 }; var d = DashboardTransfer.GetData(g); var final = d.Where(x => x.TimePeriodStart <= DateTime.Now.AddMinutes(-co.OffsetValue)).OrderByDescending(x => x.TimePeriodStart).ToList(); var dashboardList = final.Select(o => new DashboardColours { PassengerCount = o.PassengerCount, HrFlow = o.HrFlow, ImgPP = o.ImgPP, PassengerForecast = o.PassengerForecast, QueueTime = o.QueueTime, TimePeriodStart = o.TimePeriodStart, TrayCount = o.TrayCount, TrayRejectCount = o.TrayRejectCount, Variance = o.Variance, ImgPPColour = DashboardTransfer.GetPpColour(o.ImgPP, co.ImgCountR, co.ImgCountY), ActualPAXColour = DashboardTransfer.GetActualColour(o.PassengerCount, o.PassengerForecast, co.ActualCountR, co.ActualCountY), HrFlowColour = DashboardTransfer.GetFlowColour(o.PassengerCount, o.PassengerForecast, co.FlowRateR, co.FlowRateY) }).ToList(); return Response.AsJson(dashboardList); }; }
public ConfigurationModule() : base("/api") { this.RequiresAuthentication(); Get["{Location}/settings"] = _ => { string s = _.Location; var loc = s.Replace("-", ""); var cs = ConfigurationTransfer.GetData(loc); var co = new ConfigurationObject { ActualCountY = cs.ActualCountY != "" ? Convert.ToInt32(cs.ActualCountY) : 0, ActualCountR = cs.ActualCountR != "" ? Convert.ToInt32(cs.ActualCountR) : 0, ImgCountY = cs.ImgCountY != "" ? Convert.ToDouble(cs.ImgCountY) : 0.0, ImgCountR = cs.ImgCountR != "" ? Convert.ToDouble(cs.ImgCountR) : 0.0, FlowRateY = cs.FlowRateY != "" ? Convert.ToInt32(cs.FlowRateY) : 0, FlowRateR = cs.FlowRateR != "" ? Convert.ToInt32(cs.FlowRateR) : 0, OffsetValue = cs.OffsetValue != "" ? Convert.ToInt32(cs.OffsetValue) : -1 }; if (co.OffsetValue == -1) { Configuration.CreateDboConfigSetting("ContempoBI", "OffsetValue_" + loc, "0", "This is the offset value for the main dashboard page"); co.OffsetValue = 0; } if (co.ActualCountY == 0) { Configuration.CreateDboConfigSetting("ContempoBI", "ActualCountY_" + loc, "10", "This is the yellow threshold for the actual passenger count"); co.ActualCountY = Convert.ToInt32(Configuration.GetDboConfig("ContempoBI", "ActualCountY_" + loc)); } if (co.ActualCountR == 0) { Configuration.CreateDboConfigSetting("ContempoBI", "ActualCountR_" + loc, "30", "This is the red threshold for the actual passenger count"); co.ActualCountR = Convert.ToInt32(Configuration.GetDboConfig("ContempoBI", "ActualCountR_" + loc)); } if (co.ImgCountY == 0.0) { Configuration.CreateDboConfigSetting("ContempoBI", "ImgCountY_" + loc, "0.8", "This is the yellow threshold for the images per pax"); co.ImgCountY = Convert.ToDouble(Configuration.GetDboConfig("ContempoBI", "ImgCountY_" + loc)); } if (co.ImgCountR == 0.0) { Configuration.CreateDboConfigSetting("ContempoBI", "ImgCountR_" + loc, "1.9", "This is the red threshold for the images per pax"); co.ImgCountR = Convert.ToDouble(Configuration.GetDboConfig("ContempoBI", "ImgCountR_" + loc)); } if (co.FlowRateY == 0) { Configuration.CreateDboConfigSetting("ContempoBI", "FlowRateY_" + loc, "75", "This is the yellow threshold for the flow rate"); co.ImgCountY = Convert.ToDouble(Configuration.GetDboConfig("ContempoBI", "FlowRateY_" + loc)); } if (co.FlowRateR == 0) { Configuration.CreateDboConfigSetting("ContempoBI", "FlowRateR_" + loc, "25", "This is the red threshold for the flowrate"); co.ImgCountR = Convert.ToDouble(Configuration.GetDboConfig("ContempoBI", "FlowRateR_" + loc)); } return Response.AsJson(co); }; Post["settingspost/{Location}"] = _ => { string s = _.Location; var loc = s.Replace("-", ""); var posts = this.Bind<ConfigurationObject>(); Configuration.UpdateDboConfigSetting("ContempoBI", "ActualCountY_" + loc, posts.ActualCountY.ToString(), "This is the yellow threshold for the actual passenger count"); Configuration.UpdateDboConfigSetting("ContempoBI", "ActualCountR_" + loc, posts.ActualCountR.ToString(), "This is the red threshold for the actual passenger count"); Configuration.UpdateDboConfigSetting("ContempoBI", "ImgCountY_" + loc, posts.ImgCountY.ToString(), "This is the yellow threshold for the images per pax"); Configuration.UpdateDboConfigSetting("ContempoBI", "ImgCountR_" + loc, posts.ImgCountR.ToString(), "This is the red threshold for the images per pax"); Configuration.UpdateDboConfigSetting("ContempoBI", "FlowRateY_" + loc, posts.FlowRateY.ToString(), "This is the yellow threshold for the flow rate"); Configuration.UpdateDboConfigSetting("ContempoBI", "FlowRateR_" + loc, posts.FlowRateR.ToString(), "This is the red threshold for the flow rate"); Configuration.UpdateDboConfigSetting("ContempoBI", "OffsetValue_" + loc, posts.OffsetValue.ToString(), "This is the offset value for the main dashboard page"); return HttpStatusCode.OK; }; }