public void AChildSpan() { var tracer = new MockTracer(); var mongoClient = new OpenTracing.Contrib.Mongo.TracingMongoClient(tracer, _fixture.TestMongoDb.ConnectionString); var doughnutCollection = _fixture.GetDoughnutCollection(mongoClient); using (var scope = tracer.BuildSpan("parentSpan").StartActive(true)) { var doughnut = new Doughnut { Price = 3, Color = "gold" }; doughnutCollection.InsertOne(doughnut); } var insertSpan = tracer.FinishedSpans().FirstOrDefault(span => span.OperationName.Equals("mongodb.insert")); insertSpan.Should().NotBeNull(); var parentSpan = tracer.FinishedSpans().FirstOrDefault(span => span.OperationName.Equals("parentSpan")); parentSpan.Should().NotBeNull(); insertSpan.ParentId.Should().Be(parentSpan.Context.SpanId); }
public ActionResult Search(int Id) { Doughnut donut = new Doughnut(DoughnutDAL.GetDonut(Id)); ViewBag.Donut = donut; return(View()); }
public void TwoDistinctSpans() { var tracer = new MockTracer(); var mongoClient = new OpenTracing.Contrib.Mongo.TracingMongoClient(tracer, _fixture.TestMongoDb.ConnectionString); var doughnutCollection = _fixture.GetDoughnutCollection(mongoClient); var doughnutRed = new Doughnut { Price = 1, Color = "red" }; doughnutCollection.InsertOne(doughnutRed); var doughnutGreen = new Doughnut { Price = 2, Color = "green" }; doughnutCollection.InsertOne(doughnutGreen); var firstSpan = tracer.FinishedSpans().Last(); var lastSpan = tracer.FinishedSpans().First(); firstSpan.Should().NotBeNull(); lastSpan.Should().NotBeNull(); firstSpan.ParentId.Should().BeNullOrEmpty(); lastSpan.ParentId.Should().BeNullOrEmpty(); }
public IHttpActionResult Create([FromBody] Doughnut doughnut) { db.Doughnut.Add(doughnut); db.SaveChanges(); return(Ok(doughnut)); }
public void ASpanWithDefaultFields() { var tracer = new MockTracer(); var mongoClient = new OpenTracing.Contrib.Mongo.TracingMongoClient(tracer, _fixture.TestMongoDb.ConnectionString); var doughnutCollection = _fixture.GetDoughnutCollection(mongoClient); var doughnut = new Doughnut { Price = 12, Color = "red" }; doughnutCollection.InsertOne(doughnut); var insertSpan = tracer.FinishedSpans().FirstOrDefault(sp => sp.OperationName.StartsWith("mongodb.")); insertSpan.Should().NotBeNull(); insertSpan.OperationName.Should().StartWith("mongodb."); insertSpan.Tags.Count.Should().Be(7); insertSpan.Tags.Should().ContainKey(Tags.SpanKind.Key); insertSpan.Tags.Should().ContainKey(Tags.Component.Key); insertSpan.Tags.Should().ContainKey(Tags.DbStatement.Key); insertSpan.Tags.Should().ContainKey(Tags.DbInstance.Key); insertSpan.Tags.Should().ContainKey(Tags.DbType.Key); insertSpan.Tags.Should().ContainKey("mongodb.reply"); insertSpan.Tags.Should().ContainKey("db.host"); }
public ActionResult Create(string message = "") { Sample.Domain.Doughnut model = new Doughnut(); ViewBag.Title = "Create Doughnut"; ViewBag.ResponseMessage = message; return(View("Edit", model)); }
// GET: Doughnut/Delete public ActionResult Delete(int?id) { // Ensure the id is not null if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Find doughnut in database by id Doughnut doughnut = db.Doughnuts.Find(id); if (doughnut == null) { return(HttpNotFound()); } // Remove doughnut from flavor and flavor from database if no doughnuts are attached to it Flavor flavor = doughnut.Flavor; flavor.Doughnuts.Remove(doughnut); if (flavor.Doughnuts.Count() == 0) { db.Flavors.Remove(flavor); db.Entry(flavor).State = EntityState.Deleted; } // Remove doughnut from database db.Doughnuts.Remove(doughnut); db.Entry(doughnut).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Index", "Doughnut")); }
private void doughnutTimer_Tick(object sender, EventArgs e) { Doughnut aDoughnut = new Doughnut(this.Flavor); mDoughnuts.Add(aDoughnut); DoughnutComplete(); }
private void ApplyRebate(Doughnut item) { if (_rebateProvider != null) { item.Rebate = _rebateProvider.FindRebate(item); } }
public ActionResult Search(int Id) { // GET DONUT COUNT string donutCount = "https://grandcircusco.github.io/demo-apis/donuts.json"; HttpWebRequest request = WebRequest.CreateHttp(donutCount); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader rd = new StreamReader(response.GetResponseStream()); string APIText = rd.ReadToEnd(); JToken jsonDonutCount = JToken.Parse(APIText); int count = (int)jsonDonutCount["count"]; if (Id < 1 || Id > count) { ViewBag.Message = "That donut doesn't exist. Try again."; return(View("Index")); } // GET DONUT string donutURL = $"https://grandcircusco.github.io/demo-apis/donuts/{Id}.json"; request = WebRequest.CreateHttp(donutURL); response = (HttpWebResponse)request.GetResponse(); rd = new StreamReader(response.GetResponseStream()); APIText = rd.ReadToEnd(); JToken jsonDonut = JToken.Parse(APIText); Doughnut d = new Doughnut(); d.Name = jsonDonut["name"].ToString(); d.Calories = (int)jsonDonut["calories"]; if (jsonDonut["photo"] != null) { d.PhotoURL = jsonDonut["photo"].ToString(); } List <JToken> a = jsonDonut["extras"].ToList(); List <string> listDonuts = new List <string>(); if (a != null) { foreach (JToken jt in a) { listDonuts.Add(jt.ToString()); } d.Extras = listDonuts.ToArray(); } ViewBag.Donut = d; return(View(d)); }
public IHttpActionResult Update([FromBody] Doughnut newDoughnut) { Doughnut doughnut = db.Doughnut.Find(newDoughnut.Id); doughnut.Update(newDoughnut); db.SaveChanges(); return(Ok(doughnut)); }
public void Update(Doughnut doughnut, string id) { _doughnutCollection.UpdateOne( Builders <Doughnut> .Filter.Eq("_id", new ObjectId(id)), Builders <Doughnut> .Update .Set(a => a.Color, doughnut.Color) .Set(a => a.Price, doughnut.Price) .Set(a => a.OwnerId, doughnut.OwnerId)); }
public IHttpActionResult Delete(int id) { Doughnut doughnut = db.Doughnut.Find(id); db.Doughnut.Remove(doughnut); db.SaveChanges(); return(Ok()); }
public async Task <ActionResult> Delete(int Id) { using (var sampleContext = new SampleContext()) { Doughnut existingDoughnut = sampleContext.Doughnuts.FirstOrDefault(x => x.Id == Id); if (existingDoughnut != null) { sampleContext.Doughnuts.Remove(existingDoughnut); await sampleContext.SaveChangesAsync(); } } return(RedirectToAction("Index")); }
public void ScanItem(string itemCode) { if (_items.ContainsKey(itemCode)) { var itemAlreadyInList = _items[itemCode]; itemAlreadyInList.Quantity += 1; } else { _items[itemCode] = new Doughnut { Code = itemCode, Quantity = 1, Price = GetItemPrice(itemCode) }; } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Doughnuts = await _context.Doughnuts.FirstOrDefaultAsync(m => m.ID == id); if (Doughnuts == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Doughnut = await _context.Doughnuts.FindAsync(id); if (Doughnut != null) { _context.Doughnuts.Remove(Doughnut); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private void PopulateDetails(string equipment) { txtEquipment = FindViewById <TextView>(Resource.Id.txtEquipment); txtEquipment.Text = equipment; txtLot = FindViewById <TextView>(Resource.Id.txtLot); txtLot.Text = "1610950DDAA"; txtProductName = FindViewById <TextView>(Resource.Id.txtProductName); txtProductName.Text = "1770TKC-000"; txtTotalQuantity = FindViewById <TextView>(Resource.Id.txtTotalQuantity); txtTotalQuantity.Text = "5000"; txtRecipe = FindViewById <TextView>(Resource.Id.txtRecipe); txtRecipe.Text = "P9179TSL-TSL8038"; txtPkgGroup = FindViewById <TextView>(Resource.Id.txtPkgGroup); txtPkgGroup.Text = "K-Matrix"; txtProductLine = FindViewById <TextView>(Resource.Id.txtProductLine); txtProductLine.Text = "TKC"; txtPkgDev = FindViewById <TextView>(Resource.Id.txtPkgDev); txtPkgDev.Text = "1770TKC"; txtSpecsName = FindViewById <TextView>(Resource.Id.txtSpecsName); txtSpecsName.Text = "2200 BELLY BRAND / RECODE"; txtInProgressQuantity = FindViewById <TextView>(Resource.Id.txtInProgressQuantity); txtInProgressQuantity.Text = "5000"; txtInProgressPercentage = FindViewById <TextView>(Resource.Id.txtInProgressPercentage); txtInProgressPercentage.Text = "100%"; txtYieldPercentage = FindViewById <TextView>(Resource.Id.txtYieldPercentage); txtYieldPercentage.Text = "N / A"; linearPie = FindViewById <LinearLayout>(Resource.Id.linearLayoutPieHolder); View vwOEE = Doughnut.OEE(this, 100, 0, UIControl.GetColorCodeStatus("IDLE"), UIControl.GetColorCodePie()); linearPie.AddView(vwOEE); }
public void ASpanWhenMongoEventIsNotWhitelisted() { var tracer = new MockTracer(); var mongoClient = new OpenTracing.Contrib.Mongo.TracingMongoClient(tracer, _fixture.TestMongoDb.ConnectionString, options => { options.WhitelistedEvents = new[] { "update", "delete" }; }); var doughnutCollection = _fixture.GetDoughnutCollection(mongoClient); var doughnut = new Doughnut { Price = 12, Color = "red" }; doughnutCollection.InsertOne(doughnut); tracer.FinishedSpans().Should().BeEmpty(); }
// GET: Doughnut/Edit public ActionResult Edit(int?id) { // Ensure the id is not null if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Find doughnut in database by id Doughnut doughnut = db.Doughnuts.Find(id); if (doughnut == null) { return(HttpNotFound()); } // Return view with doughnut model if doughnut is found return(View(doughnut)); }
public ActionResult CreatePost() { // Get values that were posted by doughnut creation form string doughnutName = Request.Form["doughnutName"]; string flavorName = Request.Form["flavorName"]; // Ensure neither values are null if (doughnutName == "" || flavorName == "") { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Flavor newFlavor; // Check to see if database already contains flavor newFlavor = (from Flavor flav in db.Flavors where flav.Name.ToLower() == flavorName.ToLower() select flav).FirstOrDefault <Flavor>(); // If flavor was not found in database, create new flavor entity if (newFlavor == null) { newFlavor = new Flavor() { Name = flavorName }; db.Flavors.Add(newFlavor); } //Create new doughnut entity Doughnut newDoughnut = new Doughnut() { Name = doughnutName, Flavor = newFlavor }; db.Doughnuts.Add(newDoughnut); db.SaveChanges(); // Return to list of doughnuts return(RedirectToAction("Index", "Doughnut")); }
public void ASpanForDefaultMongoEvent() { var tracer = new MockTracer(); var mongoClient = new OpenTracing.Contrib.Mongo.TracingMongoClient(tracer, _fixture.TestMongoDb.ConnectionString); var doughnutCollection = _fixture.GetDoughnutCollection(mongoClient); var doughnut = new Doughnut { Price = 12, Color = "red" }; doughnutCollection.InsertOne(doughnut); var insertSpan = tracer.FinishedSpans().FirstOrDefault(sp => sp.OperationName == "mongodb.insert"); insertSpan.Should().NotBeNull(); insertSpan.OperationName.Should().Be("mongodb.insert"); }
//[HttpPost] public ActionResult Search(int Id) { string donutURL = $"https://grandcircusco.github.io/demo-apis/donuts/{Id}.json"; HttpWebRequest request = WebRequest.CreateHttp(donutURL); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader rd = new StreamReader(response.GetResponseStream()); string APIText = rd.ReadToEnd(); JToken donutToken = JToken.Parse(APIText); Doughnut d = new Doughnut(); d.Name = donutToken["name"].ToString(); d.Calories = (int)donutToken["calories"]; if (donutToken["photo"] != null) { d.PhotoURL = donutToken["photo"].ToString(); } List <JToken> jt = new List <JToken>(); List <string> donutExtras = new List <string>(); if (donutToken["extras"] != null) { foreach (JToken j in donutToken["extras"]) { donutExtras.Add(j.ToString()); } d.Extras = donutExtras.ToArray(); } ViewBag.Donut = d; return(View(d)); }
public async Task <ActionResult> SaveDoughnut(Doughnut doughnut) { bool success = false; if (ModelState.IsValid) { using (SampleContext sampleContext = new SampleContext()) { if (doughnut.Id == 0) { if (!DoesDoughnutExist(sampleContext, doughnut.Name, doughnut.Id)) { sampleContext.Doughnuts.Add(doughnut); success = true; } } else { Doughnut existingDoughnut = sampleContext.Doughnuts.Include("Flavor").FirstOrDefault(x => x.Id == doughnut.Id); if (!DoesDoughnutExist(sampleContext, doughnut.Name, doughnut.Id)) { existingDoughnut.Name = doughnut.Name; existingDoughnut.FlavorId = doughnut.FlavorId; success = true; } } await sampleContext.SaveChangesAsync(); } if (!success) { return(RedirectToAction("Edit", new { Id = doughnut.Id, message = $"The doughnut {doughnut.Name} already exists. Please enter a different name." })); } } return(RedirectToAction("Index")); }
public DoughnutState(Doughnut stateMachine) { this.stateMachine = stateMachine; }
public ActionResult EditPost() { // Get values that were posted by doughnut creation form int? doughnutId = int.Parse(Request.Form["doughnutId"]); string doughnutName = Request.Form["doughnutName"]; string flavorName = Request.Form["flavorName"]; // Ensure no values are null if (doughnutId == null || doughnutName == "" || flavorName == "") { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // Find doughnut in database by id Doughnut doughnut = db.Doughnuts.Find(doughnutId); if (doughnut == null) { return(HttpNotFound()); } Flavor flavor = doughnut.Flavor; // If flavor name has changed... if (flavor.Name != flavorName) { // Remove doughnut entity from Flavor.Doughnuts and then delete flavor if no doughnuts are attached flavor.Doughnuts.Remove(doughnut); if (flavor.Doughnuts.Count() == 0) { db.Flavors.Remove(flavor); db.Entry(flavor).State = EntityState.Deleted; } // Check to see if database already contains new flavor flavor = (from Flavor flav in db.Flavors where flav.Name.ToLower() == flavorName.ToLower() select flav).FirstOrDefault <Flavor>(); // If flavor was not found in database, create new flavor entity if (flavor == null) { flavor = new Flavor() { Name = flavorName }; db.Flavors.Add(flavor); } } if (doughnut.Name != doughnutName) { // If doughnut name has changed... // Remove doughnut from database db.Doughnuts.Remove(doughnut); db.Entry(doughnut).State = EntityState.Deleted; //Create new doughnut entity Doughnut newDoughnut = new Doughnut() { Name = doughnutName, Flavor = flavor }; db.Doughnuts.Add(newDoughnut); } else { // If doughnut name has not changed // Set doughnut.Flavor to flovor in case flavor was modified doughnut.Flavor = flavor; db.Entry(doughnut).State = EntityState.Modified; } db.SaveChanges(); // Return to list of doughnuts return(RedirectToAction("Index", "Doughnut")); }
public async void buildTranscripts() { Courses.Children.Clear(); Courses c = new Courses(); List <Models.Record> courses = await c.CheckForCourses(); if (courses.Count() > 0) { foreach (Models.Record course in courses) { Frame card; Models.Record courseRecord = await App.Database.GetCourseByID(course.CourseID); card = new MaterialFrame { ClassId = "course_" + course.CourseID }; Label title = new Label { Text = course.CourseName, Style = (Style)Application.Current.Resources["headerStyle"] }; string htmlText = @"<html> <head> <meta name='viewport' content='width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;'/> <style type='text/css'> body{font-family:Segoe UI, Helvetica Neue,'Lucida Sans Unicode', Skia, sans-serif; border:0px;padding:0px;margin:0px; background-color:transparent; overflow:hidden; } </style> </head> <body>" + HttpUtility.HtmlDecode(course.CourseDescription) + "</body></html>"; var description = new CustomWebview { HeightRequest = 300, Source = new HtmlWebViewSource { Html = htmlText }, Style = (Style)Application.Current.Resources["descriptionWebView"] }; Grid chartGrid = new Grid() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Padding = 0, Margin = 0 }; chartGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100) }); chartGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); chartGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); string completion = (course.CompletionStatus == "") ? (course.CompletionStatus == "unknown") ? "In Progress" : "Not Attempted" : course.CompletionStatus; string success = (course.SuccessStatus == "" || course.SuccessStatus == "unknown") ? "" : "/" + course.SuccessStatus; string score; float score_a = 0; float score_b = 0; float perc_complete; float perc_incomplete; if (String.IsNullOrEmpty(course.ProgressMeasure)) { perc_complete = (course.CompletionStatus == "") ? 0 : (course.CompletionStatus == "Completed") ? 100 : 50; perc_incomplete = 100 - perc_complete; } else { perc_complete = (float.Parse(courseRecord.ProgressMeasure) < 0) ? float.Parse(courseRecord.ProgressMeasure) * 100 : float.Parse(courseRecord.ProgressMeasure); perc_incomplete = 100 - perc_complete; } bool hasScore = false; if (!String.IsNullOrEmpty(course.ScoreRaw) && String.IsNullOrEmpty(course.Score)) { int raw = Convert.ToInt32(course.ScoreRaw); int max = Convert.ToInt32(course.ScoreMax); int min = Convert.ToInt32(course.ScoreMin); int scaled = ((raw - min) / (max - min)) * 100; score = scaled.ToString(); score_a = scaled; score_b = (scaled < 100) ? 100 - score_a : 0; hasScore = true; } else { if (!String.IsNullOrEmpty(course.Score)) { score = (course.Score == "") ? "" : " " + Math.Round(double.Parse(course.Score)).ToString() + "%"; score_a = (double.Parse(course.Score) < 1) ? (float)Math.Round(double.Parse(course.Score) * 100, 0, MidpointRounding.AwayFromZero) : (float)double.Parse(course.Score); score_b = ((Math.Round(score_a)) < 100) ? 100 - score_a : 0; hasScore = true; } } Doughnut doughnut = new Doughnut(); Grid doughnutContainer = (hasScore == false) ? null : doughnut.CompletionChart("Score", (float)Math.Round(score_a, 0, MidpointRounding.AwayFromZero), score_b); Label status = new Label { Text = completion + success, Style = (Style)Application.Current.Resources["headerStyle"] }; Doughnut completeDoughnut = new Doughnut(); Grid completeDoughnutContainer = completeDoughnut.CompletionChart("Complete", (float)Math.Round(perc_complete, 0, MidpointRounding.AwayFromZero), perc_incomplete); if (doughnutContainer != null) { doughnutContainer.VerticalOptions = LayoutOptions.CenterAndExpand; doughnutContainer.HorizontalOptions = LayoutOptions.CenterAndExpand; chartGrid.Children.Add(doughnutContainer, 0, 0); } StackLayout layout = new StackLayout(); card.Content = layout; layout.Children.Add(title); completeDoughnutContainer.VerticalOptions = LayoutOptions.CenterAndExpand; completeDoughnutContainer.HorizontalOptions = LayoutOptions.CenterAndExpand; chartGrid.Children.Add(completeDoughnutContainer, 1, 0); layout.Children.Add(chartGrid); Courses.Children.Add(card); } } else { Label message = new Label { Text = "You have not started any courses on this device.", Style = (Style)Application.Current.Resources["headerStyle"] }; Courses.Children.Add(message); } }
private void createOnline(LinearLayout LinearParent, string equipment, string LotNo, bool isVisible) { LinearLayout linearDetails = new LinearLayout(this); linearDetails.Orientation = Orientation.Vertical; if (isVisible == true) { linearDetails.Visibility = ViewStates.Visible; } else { linearDetails.Visibility = ViewStates.Gone; } UIControl.AddControl(this, linearDetails, "linearOnline_" + equipment); linearDetails.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) { LeftMargin = Common.convertDPtoPixel(5), BottomMargin = Common.convertDPtoPixel(5), Weight = Common.convertDPtoPixel(100) }; LinearParent.AddView(linearDetails); TextView txtLot = new TextView(this); txtLot.Text = LotNo; txtLot.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtLot.SetTypeface(null, TypefaceStyle.Bold); txtLot.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); UIControl.AddControl(this, txtLot, "txtLotOnline_" + equipment); txtLot.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { LeftMargin = Common.convertDPtoPixel(5), TopMargin = Common.convertDPtoPixel(5), Weight = Common.convertDPtoPixel(10) }; linearDetails.AddView(txtLot); RelativeLayout relLayout = new RelativeLayout(this); relLayout.SetMinimumHeight(Common.convertDPtoPixel(25)); relLayout.SetMinimumWidth(Common.convertDPtoPixel(25)); relLayout.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, Common.convertDPtoPixel(170)) { Weight = Common.convertDPtoPixel(60), TopMargin = Common.convertDPtoPixel(5) }; linearDetails.AddView(relLayout); LinearLayout linearPie = new LinearLayout(this); linearPie.Orientation = Orientation.Vertical; linearPie.SetMinimumHeight(Common.convertDPtoPixel(25)); linearPie.SetMinimumWidth(Common.convertDPtoPixel(25)); linearPie.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, Common.convertDPtoPixel(138)) { TopMargin = Common.convertDPtoPixel(23) }; relLayout.AddView(linearPie); var pie = Doughnut.OEE(this, 100, 0, UIControl.GetColorCodeStatus("ONLINE"), UIControl.GetColorCodePie()); linearPie.AddView(pie); ImageView imgView = new ImageView(this); imgView.LayoutParameters = new RelativeLayout.LayoutParams(Common.convertDPtoPixel(125), Common.convertDPtoPixel(125)) { TopMargin = Common.convertDPtoPixel(30), LeftMargin = Common.convertDPtoPixel(98) }; imgView.SetBackgroundResource(Resource.Drawable.oval); relLayout.AddView(imgView); TextView txt100 = new TextView(this); txt100.SetTextAppearance(this, Android.Resource.Style.TextAppearanceSmall); txt100.Text = "100"; txt100.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); var param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(3) }; txt100.LayoutParameters = param; txt100.Gravity = GravityFlags.Center; relLayout.AddView(txt100); TextView txt50 = new TextView(this); txt50.SetTextAppearance(this, Android.Resource.Style.TextAppearanceSmall); txt50.Text = "50"; txt50.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(161) }; txt50.LayoutParameters = param; txt50.Gravity = GravityFlags.Center; relLayout.AddView(txt50); TextView txt75 = new TextView(this); txt75.SetTextAppearance(this, Android.Resource.Style.TextAppearanceSmall); txt75.Text = "75"; txt75.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(81), RightMargin = Common.convertDPtoPixel(160) }; txt75.LayoutParameters = param; txt75.Gravity = GravityFlags.Center; txt75.Rotation = 270; relLayout.AddView(txt75); TextView txt25 = new TextView(this); txt25.SetTextAppearance(this, Android.Resource.Style.TextAppearanceSmall); txt25.Text = "25"; txt25.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); param = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(81), LeftMargin = Common.convertDPtoPixel(160) }; txt25.LayoutParameters = param; txt25.Gravity = GravityFlags.Center; txt25.Rotation = 90; relLayout.AddView(txt25); TextView txtYieldTitle = new TextView(this); txtYieldTitle.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtYieldTitle.Text = "Yield"; txtYieldTitle.SetTextColor(Color.ParseColor(UIControl.GetColorCodeStatus("ONLINE"))); txtYieldTitle.SetTypeface(null, TypefaceStyle.Bold); txtYieldTitle.SetTextSize(Android.Util.ComplexUnitType.Sp, 15); param = new RelativeLayout.LayoutParams(Common.convertDPtoPixel(100), ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(65), LeftMargin = Common.convertDPtoPixel(111) }; txtYieldTitle.LayoutParameters = param; txtYieldTitle.Gravity = GravityFlags.Center; relLayout.AddView(txtYieldTitle); TextView txtYield = new TextView(this); txtYield.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtYield.Text = "100%"; txtYield.SetTypeface(null, TypefaceStyle.Bold); txtYield.SetTextSize(Android.Util.ComplexUnitType.Dip, 20); txtYield.SetTextColor(Color.ParseColor(UIControl.GetColorCodeStatus("ONLINE"))); UIControl.AddControl(this, txtYield, "txtYieldOnline_" + equipment); param = new RelativeLayout.LayoutParams(Common.convertDPtoPixel(100), ViewGroup.LayoutParams.WrapContent) { LeftMargin = Common.convertDPtoPixel(111), TopMargin = Common.convertDPtoPixel(82) }; txtYield.LayoutParameters = param; txtYield.Gravity = GravityFlags.Center; relLayout.AddView(txtYield); Button btn = new Button(this); btn.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); btn.SetTypeface(null, TypefaceStyle.Bold); btn.SetTextSize(Android.Util.ComplexUnitType.Sp, 25); btn.LayoutParameters = new RelativeLayout.LayoutParams(70, 70) { LeftMargin = Common.convertDPtoPixel(245) }; btn.Click += delegate { GoToAlarmPage(equipment); }; btn.SetBackgroundResource(Resource.Drawable.notification); var result = HttpHandler.GetAlarms(GlobalVariable.userID, equipment); int alarmCount = 0; try { alarmCount = result.Count; } catch { alarmCount = 0; } if (alarmCount > 999) { btn.Text = "999+"; } else { btn.Text = alarmCount.ToString(); } if (alarmCount == 0) { btn.Visibility = ViewStates.Gone; } else { btn.Visibility = ViewStates.Visible; } UIControl.AddControl(this, btn, "btnAlarmOnline_" + equipment); relLayout.AddView(btn); //In Progress LinearLayout linearInProgress = new LinearLayout(this); linearInProgress.Orientation = Orientation.Horizontal; linearInProgress.SetGravity(GravityFlags.Center); linearInProgress.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { TopMargin = Common.convertDPtoPixel(185) }; relLayout.AddView(linearInProgress); TextView txtInProgressTitle = new TextView(this); txtInProgressTitle.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtInProgressTitle.Text = "In Progress: "; txtInProgressTitle.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtInProgressTitle.SetTypeface(null, TypefaceStyle.Bold); txtInProgressTitle.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtInProgressTitle); TextView txtInProgressCurrent = new TextView(this); txtInProgressCurrent.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtInProgressCurrent.Text = "5000"; txtInProgressCurrent.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtInProgressCurrent.SetTypeface(null, TypefaceStyle.Bold); txtInProgressCurrent.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; UIControl.AddControl(this, txtInProgressCurrent, "txtInProgressCurrentOnline_" + equipment); linearInProgress.AddView(txtInProgressCurrent); TextView txtSlash = new TextView(this); txtSlash.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtSlash.Text = " / "; txtSlash.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtSlash.SetTypeface(null, TypefaceStyle.Bold); txtSlash.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtSlash); TextView txtInProgressTotal = new TextView(this); txtInProgressTotal.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtInProgressTotal.Text = "5000"; txtInProgressTotal.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtInProgressTotal.SetTypeface(null, TypefaceStyle.Bold); UIControl.AddControl(this, txtInProgressTotal, "txtInProgressTotalOnline_" + equipment); txtInProgressTotal.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtInProgressTotal); TextView txtFiller = new TextView(this); txtFiller.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtFiller.Text = " [ "; txtFiller.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtFiller.SetTypeface(null, TypefaceStyle.Bold); txtFiller.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtFiller); TextView txtPercentage = new TextView(this); txtPercentage.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtPercentage.Text = "100%"; txtPercentage.SetTextColor(Color.ParseColor(UIControl.GetColorCodeStatus("ONLINE"))); txtPercentage.SetTypeface(null, TypefaceStyle.Bold); UIControl.AddControl(this, txtPercentage, "txtPercentageOnline_" + equipment); txtPercentage.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtPercentage); TextView txtFiller2 = new TextView(this); txtFiller2.SetTextAppearance(this, Android.Resource.Style.TextAppearanceMedium); txtFiller2.Text = " ]"; txtFiller2.SetTextColor(Color.ParseColor(UIControl.GetColorCodePie())); txtFiller2.SetTypeface(null, TypefaceStyle.Bold); txtFiller2.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { }; linearInProgress.AddView(txtFiller2); }
public DoughnutIdleState(Doughnut stateMachine) : base(stateMachine) { }
public IHttpActionResult Get(int id) { Doughnut doughnut = db.Doughnut.Find(id); return(Ok(doughnut)); }