/// <summary> /// Draw all available Bullets. /// </summary> private void DrawBullets() { foreach (var bullet in _cache.GetBulletsInFlight()) { DrawPolygon(bullet.PolygonPoints, RandomizeHelper.GetRandomFireColor()); } }
/// <summary> /// Draws an explosion to the canvas. /// </summary> private void DrawExplosion(Explosion explosion) { foreach (var point in explosion.Points) { DrawVector(new Point(point.X, point.Y), 1, 1, RandomizeHelper.GetRandomFireColor()); } }
public PostReportRemarks CreateReport(PostReport report) { var objReturn = new PostReportRemarks(); var reportNo = "R" + RandomizeHelper.GenerateRandomString(7); var draft = GetDraftReport(report.reported_by_email); if (draft.report_no != null) { reportNo = draft.report_no; objReturn = new PostReportRemarks { report_no = reportNo, remarks = "You have a pending report!", subject = "Report" }; } else { using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection())) { con.Open(); var cmd = new MySqlCommand("INSERT INTO reportit_report (report_no, user, ip, reported_by, reported_by_email, reported_by_phone, reported_on, status) VALUES(@report_no, @user, @ip, @reported_by, @reported_by_email, @reported_by_phone, @reported_on, @status)", con); cmd.Parameters.AddWithValue("@report_no", reportNo); cmd.Parameters.AddWithValue("@user", report.reported_by_email); cmd.Parameters.AddWithValue("@ip", "EEC Mobility"); cmd.Parameters.AddWithValue("@reported_by", report.reported_by); cmd.Parameters.AddWithValue("@reported_by_email", report.reported_by_email); cmd.Parameters.AddWithValue("@reported_by_phone", report.reported_by_phone); cmd.Parameters.AddWithValue("@reported_on", DateTime.Now); cmd.Parameters.AddWithValue("@status", "Draft"); if (cmd.ExecuteNonQuery() > 0) { objReturn = new PostReportRemarks { report_no = reportNo, remarks = "Successfully created new report!", subject = "Report" }; } else { objReturn = new PostReportRemarks { remarks = "Error on creation of new report!", subject = "Error" }; } } } return(objReturn); }
public void GetRandomStringTest() { for (int i = 0; i < 5; i++) { var randomString = RandomizeHelper.GetRandomString(i); Assert.AreEqual(randomString.Length, i); } }
/// <summary> /// Draw the Flying Saucer and Missile. /// </summary> private void DrawSaucer() { if (_cache.Saucer?.IsAlive != true) { return; } //Draw the saucer DrawPolygon(_cache.SaucerPoints, "#33ff33"); //Draw its missile if (_cache.MissilePoints?.Any() != true) { return; } DrawPolygon(_cache.MissilePoints, "#FF0000"); //Draw flame for the missile var thrustPoints = new List <Point> { Capacity = 3 }; var pt1 = _cache.MissilePoints[Missile.PointThrust1]; var pt2 = _cache.MissilePoints[Missile.PointThrust2]; thrustPoints.Add(pt1); thrustPoints.Add(pt2); // random thrust effect int size = RandomizeHelper.Random.Next(50) + 50; var radians = _cache.Saucer.Missile.GetRadians(); thrustPoints.Add(new Point( (pt1.X + pt2.X) / 2 + (int)(size * Math.Sin(radians)), (pt1.Y + pt2.Y) / 2 + (int)(-size * Math.Cos(radians)) )); // Draw thrust directly to ScreenCanvas; it's not part of the object DrawPolygon(thrustPoints, RandomizeHelper.GetRandomFireColor()); }
/// <summary> /// Draw Ship. /// </summary> private void DrawShip() { if (!_cache.Ship.IsAlive) { return; } DrawPolygon(_cache.ShipPoints, "#b8b894"); //Draw flame if thrust is on if (_cache.Ship.IsThrustOn) { // We have points transformed so we know where the bottom of the ship is var thrustPoints = new List <Point> { Capacity = 3 }; var pt1 = _cache.ShipPoints[Ship.PointThrust1]; var pt2 = _cache.ShipPoints[Ship.PointThrust2]; thrustPoints.Add(pt1); thrustPoints.Add(pt2); // random thrust effect int size = RandomizeHelper.Random.Next(200) + 100; var radians = _cache.Ship.GetRadians(); thrustPoints.Add(new Point( (pt1.X + pt2.X) / 2 + (int)(size * Math.Sin(radians)), (pt1.Y + pt2.Y) / 2 + (int)(-size * Math.Cos(radians)) )); // Draw thrust directly to ScreenCanvas; it's not part of the object DrawPolygon(thrustPoints, RandomizeHelper.GetRandomFireColor()); } }
public PostReportRemarks SaveConcern(PostConcern concern) { var objReturn = new PostReportRemarks(); try { var ticket_no = "T" + RandomizeHelper.GenerateRandomString(7); var concern_no = "C" + RandomizeHelper.GenerateRandomString(7); string img1 = string.Empty, img2 = string.Empty, img3 = string.Empty; if (concern.image1 != null) { img1 = "../imageReport/" + concern.report_no + "/" + concern_no + "_img1.png"; } if (concern.image2 != null) { img2 = "../imageReport/" + concern.report_no + "/" + concern_no + "_img2.png"; } if (concern.image3 != null) { img3 = "../imageReport/" + concern.report_no + "/" + concern_no + "_img3.png"; } using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection())) { try { con.Open(); var cmd = new MySqlCommand("INSERT INTO reportit_concern (report_no, ticket_no, concern_no, description, floor, segment, specific_location, comment, image1, image2, image3, imagesLocation, status) VALUES(@report_no, @ticket_no, @concern_no, @description, @floor, @segment, @specific_location, @comment, @image1, @image2, @image3, @imagesLocation, @status)", con); cmd.Parameters.AddWithValue("@report_no", concern.report_no); cmd.Parameters.AddWithValue("@ticket_no", ticket_no); cmd.Parameters.AddWithValue("@concern_no", concern_no); cmd.Parameters.AddWithValue("@description", concern.description); cmd.Parameters.AddWithValue("@floor", concern.floor); cmd.Parameters.AddWithValue("@segment", concern.segment); cmd.Parameters.AddWithValue("@specific_location", concern.specific_location); cmd.Parameters.AddWithValue("@comment", concern.comment); cmd.Parameters.AddWithValue("@image1", img1); cmd.Parameters.AddWithValue("@image2", img2); cmd.Parameters.AddWithValue("@image3", img3); cmd.Parameters.AddWithValue("@imagesLocation", "imageReport/" + concern.report_no); cmd.Parameters.AddWithValue("@date_created", DateTime.Now); cmd.Parameters.AddWithValue("@status", "Draft"); if (cmd.ExecuteNonQuery() > 0) { var path = @"C:\xampp\htdocs\reportit\imageReport\" + concern.report_no; //var path = AppDomain.CurrentDomain.BaseDirectory + concern.report_no; bool exists = Directory.Exists(path); if (!exists) { System.IO.Directory.CreateDirectory(path); } if (concern.image1 != null) { using (var ms = new MemoryStream(concern.image1)) { var img = Image.FromStream(ms); var bm = new Bitmap(500, 500); var g = Graphics.FromImage(bm); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(img, 0, 0, 500, 500); g.Dispose(); img = bm; var i2 = new Bitmap(img); i2.Save(path + @"\" + concern_no + "_img1.png", System.Drawing.Imaging.ImageFormat.Png); } } if (concern.image2 != null) { using (var ms = new MemoryStream(concern.image2)) { var img = Image.FromStream(ms); var bm = new Bitmap(500, 500); var g = Graphics.FromImage(bm); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(img, 0, 0, 500, 500); g.Dispose(); img = bm; img.Save(path + @"\" + concern_no + "_img2.png", System.Drawing.Imaging.ImageFormat.Png); } } if (concern.image3 != null) { using (var ms = new MemoryStream(concern.image3)) { var img = Image.FromStream(ms); var bm = new Bitmap(500, 500); var g = Graphics.FromImage(bm); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(img, 0, 0, 500, 500); g.Dispose(); img = bm; img.Save(path + @"\" + concern_no + "_img3.png", System.Drawing.Imaging.ImageFormat.Png); } } objReturn = new PostReportRemarks { remarks = "Successfully added new concern!", subject = "Concern" }; } else { objReturn = new PostReportRemarks { remarks = "Error on adding of new concern!", subject = "Error" }; } } catch (Exception e) { objReturn = new PostReportRemarks { remarks = e.InnerException.ToString(), subject = "Error" }; } } } catch (Exception ex) { objReturn = new PostReportRemarks { remarks = ex.InnerException.ToString(), subject = "Error" }; } return(objReturn); }
public RequestRemarks CreateUpdateRequest(PostRequest newRequest) { var objReturn = new RequestRemarks(); var eecEmployee = new EECEmployee(); var employeeInfo = eecEmployee.SearchOnDirectory(newRequest.emp_id); var info = employeeInfo.Count != 0 ? employeeInfo[0] : null; if (info != null) { if (IsTripValid(newRequest.trip_id)) { if (newRequest.seat_no >= 0 && newRequest.seat_no <= 6) { if (!IsSeatAvailable(newRequest.trip_id, newRequest.seat_no)) { objReturn = new RequestRemarks { remarks = "Seat selected is no longer available!", subject = "Already Taken" }; } else { if (IsUpdateSeat(info.emp_ID, newRequest.trip_id, newRequest.seat_no)) { if (IsRandomCodeValid(newRequest.trip_id, newRequest.random)) { using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection())) { con.Open(); var cmd = new MySqlCommand("UPDATE seat SET seat=@seat,date_submit=@date_submit WHERE pax_id=@pax_id AND trip_id=@trip_id", con); cmd.Parameters.AddWithValue("@seat", newRequest.seat_no); cmd.Parameters.AddWithValue("@date_submit", DateTime.Now); cmd.Parameters.AddWithValue("@trip_id", newRequest.trip_id); cmd.Parameters.AddWithValue("@pax_id", info.emp_ID); if (cmd.ExecuteNonQuery() > 0) { objReturn = new RequestRemarks { remarks = "You have updated your reserved seat!", subject = "Updated" }; AppendLog(info.e_Mail.Split('@')[0], " updated to " + newRequest.seat_no + " on ", newRequest.trip_id); } } } else { objReturn = new RequestRemarks { remarks = "Trip not found.", subject = "Notice" }; } } else { var tripDetails = new TripDetails(); var details = tripDetails.GetTripDetails(newRequest.trip_id); using (var con = new MySqlConnection(ConnectionHelper.ServicesConnection())) { con.Open(); var cmd = new MySqlCommand("INSERT INTO seat ( trip_id, trip, pax_name, gender, pax_email, pax_id, seat, cost_center, ip, date_submit, code, random) VALUES(@trip_id,@trip,@pax_name,@gender,@pax_email,@pax_id,@seat,@cost_center,@ip,@date_submit,@code,@random)", con); cmd.Parameters.AddWithValue("@trip_id", newRequest.trip_id); cmd.Parameters.AddWithValue("@trip", details.trip_date); cmd.Parameters.AddWithValue("@pax_name", info.employee_Name_English); cmd.Parameters.AddWithValue("@gender", info.gender); cmd.Parameters.AddWithValue("@pax_email", info.e_Mail); cmd.Parameters.AddWithValue("@pax_id", info.emp_ID); cmd.Parameters.AddWithValue("@seat", newRequest.seat_no); cmd.Parameters.AddWithValue("@cost_center", info.cost_Center); cmd.Parameters.AddWithValue("@ip", "EEC Mobility"); cmd.Parameters.AddWithValue("@date_submit", DateTime.Now); cmd.Parameters.AddWithValue("@code", 1); cmd.Parameters.AddWithValue("@random", RandomizeHelper.GenerateRandomString()); if (cmd.ExecuteNonQuery() > 0) { objReturn = new RequestRemarks { remarks = "You have reserved a seat!", subject = "Reserved" }; AppendLog(info.e_Mail.Split('@')[0], " reserved " + newRequest.seat_no + " on ", newRequest.trip_id); } } } } } else { objReturn = new RequestRemarks { remarks = "Seat not found.", subject = "Notice" }; } } else { objReturn = new RequestRemarks { remarks = "Trip not found.", subject = "Notice" }; } } else { objReturn = new RequestRemarks { remarks = "Request should be initiated by an EEC Employee.", subject = "Notice" }; } return(objReturn); }
public void GetRandomValueTest() { var maxMinValueZero = RandomizeHelper.GetRandomValue(0); Assert.AreEqual(maxMinValueZero, 0); }
public List <int> Create() { var buffsCount = _random.Next(_config.settings.buffCountMin, _config.settings.buffCountMax); return(RandomizeHelper.Randomize(_config.buffs.Length, buffsCount, _config.settings.allowDuplicateBuffs)); }