public override Hashtable GetUserList(int iPage) { Hashtable lst = new Hashtable(); m_Client.Referer = ForumPath + "/index.php?act=Login&CODE=01"; m_Response = m_Client.DownloadString(m_sForumPath + "/index.php?&name_box=&sort_key=members_display_name&sort_order=asc&filter=ALL&act=members&max_results=20&aim=&yahoo=&icq=&msn=&posts=&joined=&lastpost=&lastvisit=&signature=&homepage=&name=&photoonly=&st=" + ((int)(iPage*20)).ToString()); Match mc1 = Regex.Match(m_Response, "showuser\\=(\\d*)"); Match mc2 = Regex.Match(m_Response, "showuser\\=\\d*\"\\>(.*)\\<\\/a"); while (mc1.Success && mc2.Success) { try { Pair2<int, string> pp = new Pair2<int, string>(int.Parse(mc1.Groups[1].Value), mc2.Groups[1].Value); if(!lst.Contains(int.Parse(mc1.Groups[1].Value))) lst.Add(int.Parse(mc1.Groups[1].Value),mc2.Groups[1].Value); } catch (System.Exception e) { Console.WriteLine("GetUserList ForumBotIPB error: " + e.Message); } mc1 = mc1.NextMatch(); mc2 = mc2.NextMatch(); } return lst; }
static public Vector2List GetPoints(Vector2List list, float distance) { if (list.Count() < 2) { return(list); } Vector2List result = list.Copy(); float directionA = list.points[0].Atan2(list.points[1]); float directionB = list.points[list.points.Count - 2].Atan2(list.points[list.points.Count - 1]); Vector2 pointA = list.points[0]; Vector2 pointB = list.points[list.points.Count - 1]; pointA.Push(directionA, distance); pointB.Push(directionB, -distance); Slicer2D slicerA = Slicer2D.PointInSlicerComponent(list.points[0].ToVector2D()); Slicer2D slicerB = Slicer2D.PointInSlicerComponent(list.points[list.points.Count - 1].ToVector2D()); Pair2 thresholdPairA = new Pair2(list.points[0], pointA); Pair2 thresholdPairB = new Pair2(list.points[list.points.Count - 1], pointB); Vector2D resultA = null; Vector2D resultB = null; if (slicerA != null) { List <Vector2D> pointsA = slicerA.shape.GetWorld().GetListLineIntersectPoly(thresholdPairA.ToPair2D()); if (pointsA.Count > 0) { pointsA = Vector2DList.GetListSortedToPoint(pointsA, pointA.ToVector2D()); resultA = pointsA[pointsA.Count - 1]; resultA.Push(directionA, 0.05f); } } if (slicerB != null) { List <Vector2D> pointsB = slicerB.shape.GetWorld().GetListLineIntersectPoly(thresholdPairB.ToPair2D()); if (pointsB.Count > 0) { pointsB = Vector2DList.GetListSortedToPoint(pointsB, pointB.ToVector2D()); resultB = pointsB[pointsB.Count - 1]; resultB.Push(directionB, -0.05f); } } if (resultA != null) { result.Insert(0, resultA.ToVector2()); } if (resultB != null) { result.Add(resultB.ToVector2()); } return(result); }
public ResList allResults() { ResItem resElem = new ResItem(); ResList allR = new ResList(); Pair2 moyG = new Pair2(1, gm()); Pair2 moyA = new Pair2(1, am()); Pair2 moyARisk = new Pair2(0, am_risk()); Pair2 ec = new Pair2(1, gsd()); Pair2 fracD = new Pair2(1, frac()); Pair2 fracDRisk = new Pair2(0, frac_risk()); Pair2 cc = new Pair2(1, perc()); Pair2 ccRisk = new Pair2(0, perc_risk()); if (SEGModel) { if (DistributionLogNormale) { resElem.Add(new Pair1(Properties.Resources.GeomMean, moyG)); resElem.Add(new Pair1(Properties.Resources.GeomSD, ec)); resElem.Add(new Pair1(Properties.Resources.Exceedance + " (%)", fracD)); resElem.Add(new Pair1(Properties.Resources.Exceedance + " - " + Properties.Resources.OverExpoRiskPerc, fracDRisk)); resElem.Add(new Pair1(Properties.Resources.CritPercentile, cc)); resElem.Add(new Pair1(Properties.Resources.CritPercentile + " - " + Properties.Resources.OverExpoRiskPerc, ccRisk)); resElem.Add(new Pair1(Properties.Resources.ArithMean, moyA)); resElem.Add(new Pair1(Properties.Resources.ArithMean + " - " + Properties.Resources.OverExpoRiskPerc, moyARisk)); } else { resElem.Add(new Pair1(Properties.Resources.ArithMean, moyA)); resElem.Add(new Pair1(Properties.Resources.ArithSD, ec)); resElem.Add(new Pair1(Properties.Resources.ArithMean + " - " + Properties.Resources.OverExpoRiskPerc, moyARisk)); resElem.Add(new Pair1(Properties.Resources.Exceedance + " (%)", fracD)); resElem.Add(new Pair1(Properties.Resources.Exceedance + " - " + Properties.Resources.OverExpoRiskPerc, fracDRisk)); resElem.Add(new Pair1(Properties.Resources.CritPercentile, cc)); resElem.Add(new Pair1(Properties.Resources.CritPercentile + " - " + Properties.Resources.OverExpoRiskPerc, ccRisk)); } resElem.Add(new Pair1(Properties.Resources.MarcovChainsCSV, new Pair2(2, dumpChainesMarkov()))); if (BurninChains.Count > 0) { resElem.Add(new Pair1(Properties.Resources.BurnInChainsCSV, new Pair2(2, dumpChainesMarkov(true)))); } allR.Add("RES", resElem); } else { if (MuWorkerChains == null) { Pair2 ec2 = new Pair2(1, gsd(true)); Pair2 rhoo = new Pair2(1, rho()); Pair2 probRhoOva = new Pair2(0, probRhoOverX()); Pair2 rratio = new Pair2(1, Rratio()); if (DistributionLogNormale) { resElem.Add(new Pair1(Properties.Resources.GroupGeomMean, moyG)); resElem.Add(new Pair1(Properties.Resources.GeomSD + "(" + Properties.Resources.BetweenWorkers + ")", ec)); resElem.Add(new Pair1(Properties.Resources.GeomSD + "(" + Properties.Resources.WithinWorkers + ")", ec2)); resElem.Add(new Pair1("rho", rhoo)); resElem.Add(new Pair1("Prob.rho." + Properties.Resources.ProbGreaterThan + "X(%)", probRhoOva)); resElem.Add(new Pair1("R.ratio", rratio)); resElem.Add(new Pair1("Prob.R." + Properties.Resources.ProbGreaterThan + ".2 (%)", new Pair2(0, probRRatioOverX(2)))); resElem.Add(new Pair1("Prob.R." + Properties.Resources.ProbGreaterThan + ".10 (%)", new Pair2(0, probRRatioOverX(10)))); } else { resElem.Add(new Pair1(Properties.Resources.GroupArithMean, moyG)); resElem.Add(new Pair1(Properties.Resources.ArithSD + "(" + Properties.Resources.BetweenWorkers + ")", ec)); resElem.Add(new Pair1(Properties.Resources.ArithSD + "(" + Properties.Resources.BetweenWorkers + ")", ec2)); resElem.Add(new Pair1("rho", rhoo)); resElem.Add(new Pair1("Prob.rho." + Properties.Resources.ProbGreaterThan + "X (%)", probRhoOva)); resElem.Add(new Pair1("R.diff", new Pair2(1, Rdiff()))); } resElem.Add(new Pair1("Prob.ind." + Properties.Resources.OverExpo + ".perc", new Pair2(1, probIndOverexpoPerc()))); resElem.Add(new Pair1("Prob.ind." + Properties.Resources.OverExpo + ".perc." + Properties.Resources.ProbGreaterThan + "X (%)", new Pair2(0, probIndOverexpoPercOverX()))); resElem.Add(new Pair1("Prob.ind." + Properties.Resources.OverExpo + ".am", new Pair2(1, probIndOverexpoAM()))); resElem.Add(new Pair1("Prob.ind." + Properties.Resources.OverExpo + ".am." + Properties.Resources.ProbGreaterThan + "X (%)", new Pair2(0, probIndOverexpoAMOverX()))); resElem.Add(new Pair1(Properties.Resources.MarcovChainsCSV, new Pair2(2, dumpChainesMarkov()))); if (BurninChains.Count > 0) { resElem.Add(new Pair1(Properties.Resources.BurnInChainsCSV, new Pair2(2, dumpChainesMarkov(true)))); } allR.Add("RES", resElem); } else { foreach (string wid in MuWorkerChains.Keys) { ResItem riWorker = new ResItem(); if (DistributionLogNormale) { riWorker.Add(new Pair1(Properties.Resources.GeomMean, new Pair2(1, gm(wid)))); riWorker.Add(new Pair1(Properties.Resources.GeomSD, new Pair2(1, gsdw()))); riWorker.Add(new Pair1(Properties.Resources.Exceedance, new Pair2(1, frac(wid)))); riWorker.Add(new Pair1(Properties.Resources.Exceedance + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, frac_risk(wid)))); riWorker.Add(new Pair1(Properties.Resources.CritPercentile, new Pair2(1, perc(wid)))); riWorker.Add(new Pair1(Properties.Resources.CritPercentile + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, perc_risk(wid)))); riWorker.Add(new Pair1(Properties.Resources.ArithMean, new Pair2(1, am(wid)))); riWorker.Add(new Pair1(Properties.Resources.ArithMean + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, am_risk(wid)))); } else { riWorker.Add(new Pair1(Properties.Resources.ArithMean, new Pair2(1, gm(wid)))); riWorker.Add(new Pair1(Properties.Resources.ArithSD, new Pair2(1, gsdw()))); riWorker.Add(new Pair1(Properties.Resources.ArithMean + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, am_risk(wid)))); riWorker.Add(new Pair1(Properties.Resources.Exceedance, new Pair2(1, frac(wid)))); riWorker.Add(new Pair1(Properties.Resources.Exceedance + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, frac_risk(wid)))); riWorker.Add(new Pair1(Properties.Resources.CritPercentile, new Pair2(1, perc(wid)))); riWorker.Add(new Pair1(Properties.Resources.CritPercentile + " - " + Properties.Resources.OverExpoRiskPerc, new Pair2(0, perc_risk(wid)))); } riWorker.Add(new Pair1(Properties.Resources.MarcovChainsCSV, new Pair2(2, dumpChainesMarkov(false, wid)))); allR.Add(wid, riWorker); } } } return(allR); }
public async Task <ActionResult> ShowStatistics() { ApplicationDbContext ctx = ApplicationDbContext.Create(); string id = User.Identity.GetUserId(); var locationToShow = new Location(); var locationId = ctx.Database.SqlQuery <String>("select MyLocationId from AspNetUsers where id = '" + id + "'").FirstOrDefault(); Guid idLoc = new Guid(locationId); List <Location> allLocations = new List <Location>(); var projections = ctx.Database.SqlQuery <Projection>("select * from Projections where Location_Id = '" + idLoc + "'").ToList(); allLocations = ctx.Locations.ToList(); foreach (Location loc in allLocations) { if (loc.Id.Equals(locationId)) { locationToShow = loc; } } locationToShow.ProjectionsList = projections; List <Ticket> tickets = new List <Ticket>(); List <Ticket> ticketsToCalculate = new List <Ticket>(); tickets = ctx.Reservations.ToList(); Ticket ticket = new Ticket(); foreach (Ticket t in tickets) { ticket = await ctx.Reservations.Include(x => x.Projection).FirstOrDefaultAsync(x => x.Id == t.Id); HallTimeProjection pr = new HallTimeProjection(); pr = await ctx.HallTimeProjection.Include(x => x.Hall).FirstOrDefaultAsync(x => x.Id == ticket.Projection.Id); if (pr.Hall.ParentLocation.Id.Equals(new Guid(locationId))) { ticketsToCalculate.Add(ticket); } } List <Pair> parovi = new List <Pair>(); foreach (Ticket t in ticketsToCalculate) { Pair par = new Pair(); par.date = t.Projection.Time.ToString(); par.date = par.date.Split(' ')[0]; DateTime dt = DateTime.Now; int trenutnidan = dt.DayOfYear; int trenutnagod = dt.Year; par.numberofday = t.Projection.Time.DayOfYear; par.year = t.Projection.Time.Year; par.number = 0; if (t.Projection.Time.DayOfYear < 105) { int k = 8; } int ima = 1; for (int i = 0; i < parovi.Count; i++) { if (parovi[i].numberofday.Equals(par.numberofday) && parovi[i].year.Equals(par.year) && trenutnidan - par.numberofday < 7 && trenutnagod - par.year == 0) { ima = 0; } } if (ima == 1) { if (trenutnidan - par.numberofday < 7) { parovi.Insert(0, par); } } ima = 1; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < parovi.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(parovi[i].numberofday) && t.Projection.Time.Year.Equals(parovi[i].year)) { parovi[i].number++; break; } } } List <Pair> nedeljno = new List <Pair>(); int b = 0; for (int i = 0; i < 12; i++) { Pair par = new Pair(); int p = b + 2; par.date = b + "-" + p; par.number = 0; DateTime now = DateTime.Now; par.year = now.Year; par.numberofday = now.DayOfYear; nedeljno.Add(par); b += 2; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < nedeljno.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(nedeljno[i].numberofday) && t.Projection.Time.Year.Equals(nedeljno[i].year)) { int donja = 44; int.TryParse(nedeljno[i].date.Split('-')[0], out donja); int gornja = 44; int.TryParse(nedeljno[i].date.Split('-')[1], out gornja); if (t.Projection.Time.Hour >= donja && t.Projection.Time.Hour < gornja) { nedeljno[i].number++; break; } } } } List <Pair2> mesecno = new List <Pair2>(); foreach (Ticket t in ticketsToCalculate) { Pair2 par = new Pair2(); par.date = t.Projection.Time.ToString(); par.date = par.date.Split(' ')[0]; DateTime dt = DateTime.Now; int trenutnidan = dt.DayOfYear; int trenutnagod = dt.Year; par.numberofday = t.Projection.Time.DayOfYear; par.numberofmonth = t.Projection.Time.Month; int trenutnimesec = dt.Month; par.year = t.Projection.Time.Year; par.number = 0; int ima = 1; for (int i = 0; i < mesecno.Count; i++) { if (mesecno[i].numberofday.Equals(par.numberofday) && mesecno[i].year.Equals(par.year) && trenutnimesec - par.numberofmonth == 0 && trenutnagod - par.year == 0) { ima = 0; } } if (ima == 1) { if (trenutnimesec - par.numberofmonth == 0) { mesecno.Insert(0, par); } } ima = 1; } foreach (Ticket t in ticketsToCalculate) { for (int i = 0; i < mesecno.Count; i++) { if (t.Projection.Time.DayOfYear.Equals(mesecno[i].numberofday) && t.Projection.Time.Year.Equals(mesecno[i].year)) { mesecno[i].number++; break; } } } GraphicViewModel graph = new GraphicViewModel { loc = locationToShow, pairs = parovi, nedeljni = nedeljno, mesecni = mesecno }; if (ViewBag.prihod == null) { ViewBag.prihod = 0; } return(View("ShowStatistics", graph)); }
///// POINT ////// public void GeneratePoint(Pair2 linearPair, Transform transform, float lineWidth, float zPosition) { CreateLine(linearPair, transform.localScale, lineWidth, zPosition); }
private void WorkerShown_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e = null) { String val = ""; TextBlock textBlock1 = new TextBlock(); textBlock1.Inlines.Add(new Bold(new Run(Properties.Resources.NumRes + " (" + Properties.Resources.WorkerC + " : "))); Bold b2 = new Bold(new Italic(new Run(WorkerShown.SelectedValue as String))); b2.Foreground = Brushes.Red; textBlock1.Inlines.Add(b2); textBlock1.Inlines.Add(new Bold(new Run(")"))); textBlock1.FontSize = 20; BlockUIContainer uic = new BlockUIContainer(textBlock1); TableCell tc = new TableCell(uic); tc.ColumnSpan = 2; tc.TextAlignment = TextAlignment.Center; TableRow heading = new TableRow(); heading.Background = Brushes.SkyBlue; heading.Cells.Add(tc); TableRowGroup rg = new TableRowGroup(); rg.Rows.Add(heading); foreach (Pair1 p in resList[WorkerShown.SelectedValue as String]) { String lbl = p.Key; Pair2 p2 = p.Value; bool isFileLink = false; if (p2.Key == 0) { val = MainWindow.ShowDouble(p2.Value); } else if (p2.Key == 2) { val = p2.Value.ToString(); isFileLink = true; } else { Dict dict = p2.Value as Dict; bool ok = false; try { ok = dict.TryGetValue("est", out double v); ok = dict.TryGetValue("lcl", out double v1); ok = dict.TryGetValue("ucl", out double v2); val = MainWindow.ShowDouble(v) + " [" + MainWindow.ShowDouble(v1) + " - " + MainWindow.ShowDouble(v2) + "]"; } catch (ArgumentNullException) { } } TableRow tr = new TableRow(); tr.Cells.Add(new TableCell(new Paragraph(new Run(lbl)))); Run run2 = new Run(val); if (isFileLink) { Hyperlink fileLink = new Hyperlink(run2); fileLink.Click += openFile_Click; fileLink.NavigateUri = new Uri(val); tr.Cells.Add(new TableCell(new Paragraph(fileLink))); } else { tr.Cells.Add(new TableCell(new Paragraph(run2))); } rg.Rows.Add(tr); } tableauResultats.RowGroups[0] = rg; }
private Dictionary <Tuple <string, string>, IPvModel> GenerateScenariosFxFx(IPvModel model) { var o = new Dictionary <Tuple <string, string>, IPvModel>(); var axisLength = NScenarios * 2 + 1; var results = new KeyValuePair <Tuple <string, string>, IPvModel> [axisLength * axisLength]; ParallelUtils.Instance.For(-NScenarios, NScenarios + 1, 1, (i) => { var thisShiftFx1 = i * ShiftSizeAsset; var thisLabelAsset = Pair1.ToString() + "~" + thisShiftFx1; var assetIx = i + NScenarios; IPvModel shifted; if (thisShiftFx1 == 0) { shifted = model; } else { switch (ShiftType) { case MutationType.FlatShift: shifted = FlatShiftMutator.FxSpotShift(Pair1, thisShiftFx1, model); break; default: throw new Exception($"Unable to process shift type {ShiftType}"); } } for (var ifx = -NScenarios; ifx < NScenarios + 1; ifx++) { var fxIx = ifx + NScenarios; var thisShiftFx = ifx * ShiftSizeFx; var thisLabelFx = Pair2.ToString() + "~" + thisShiftFx; IPvModel shiftedFx; if (thisShiftFx == 0) { shiftedFx = shifted; } else { shiftedFx = FlatShiftMutator.FxSpotShift(Pair2, thisShiftFx, shifted); } results[assetIx * axisLength + fxIx] = new KeyValuePair <Tuple <string, string>, IPvModel>( new Tuple <string, string>(thisLabelAsset, thisLabelFx), shiftedFx); } }).Wait(); foreach (var kv in results) { o.Add(kv.Key, kv.Value); } return(o); }
static public void DrawProjection(DayLightCollider2D id, Vector2 offset) { if (id.mainShape.shadowType != DayLightCollider2D.ShadowType.SpriteProjection) { return; } if (id.InAnyCamera() == false) { return; } Material material = Lighting2D.materials.GetSpriteShadow(); material.color = Color.black; foreach (DayLightColliderShape shape in id.shapes) { SpriteRenderer spriteRenderer = shape.spriteShape.GetSpriteRenderer(); if (spriteRenderer == null) { continue; } virtualSpriteRenderer.sprite = spriteRenderer.sprite; virtualSpriteRenderer.flipX = spriteRenderer.flipX; virtualSpriteRenderer.flipY = spriteRenderer.flipY; Sprite sprite = virtualSpriteRenderer.sprite; if (virtualSpriteRenderer.sprite == null) { continue; } float sunHeight = Lighting2D.DayLightingSettings.height; float rot = Lighting2D.DayLightingSettings.direction * Mathf.Deg2Rad; Vector2 pos = new Vector2(id.transform.position.x + offset.x, id.transform.position.y + offset.y); Vector2 scale = new Vector2(id.transform.lossyScale.x, id.transform.lossyScale.y); SpriteTransform spriteTransform = new SpriteTransform(virtualSpriteRenderer, pos, scale, id.transform.rotation.eulerAngles.z); Rect uv = spriteTransform.uv; float pivotY = (float)sprite.pivot.y / sprite.texture.height; pivotY = uv.y + pivotY; float pivotX = (float)sprite.pivot.x / sprite.texture.width; Pair2 pair = Pair2.Zero(); pair.A = pos + pair.A.Push(-rot + Mathf.PI / 2, id.shadowThickness); pair.B = pos + pair.B.Push(-rot - Mathf.PI / 2, id.shadowThickness); if (Lighting2D.DayLightingSettings.direction < 180) { float uvx = uv.x; uv.x = uv.width; uv.width = uvx; } Vector2 v1 = pair.A; Vector2 v2 = pair.A; Vector2 v3 = pair.B; Vector2 v4 = pair.B; v2 = v2.Push(-rot, id.shadowDistance * sunHeight); v3 = v3.Push(-rot, id.shadowDistance * sunHeight); material.mainTexture = virtualSpriteRenderer.sprite.texture; material.SetPass(0); GL.Begin(GL.QUADS); GL.Color(GLExtended.color); GL.TexCoord3(uv.x, pivotY, 0); GL.Vertex3(v1.x, v1.y, 0); GL.TexCoord3(uv.x, uv.height, 0); GL.Vertex3(v2.x, v2.y, 0); GL.TexCoord3(uv.width, uv.height, 0); GL.Vertex3(v3.x, v3.y, 0); GL.TexCoord3(uv.width, pivotY, 0); GL.Vertex3(v4.x, v4.y, 0); GL.End(); } material.color = Color.white; }