public void InitializeTest() { this.performances = new PerformanceDatabase(); this.performances.AddTheatre("Theatre Sofia"); this.performances.AddTheatre("Theatre 199"); // Theatre 199, Duende, 20.01.2015 20:00, 1:30, 14.5 this.performance1 = new Performance( "Theatre 199", "Duende", new DateTime(2015, 1, 19, 20, 0, 0), new TimeSpan(0, 1, 30, 0), 14.5M); // Theatre 199, Bella Donna, 20.01.2015 20:30, 1:00, 12) this.performance2 = new Performance( "Theatre 199", "Bella Donna", new DateTime(2015, 1, 20, 20, 30, 0), new TimeSpan(0, 1, 0, 0), 12.0M); // Theatre Sofia, Don Juan, 20.01.2015 20:31, 2:00, 14.60 this.performance3 = new Performance( "Theatre Sofia", "Don Juan", new DateTime(2015, 1, 20, 20, 31, 0), new TimeSpan(0, 2, 0, 0), 14.6M); }
public void AddPerformance( string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.sortedDictionaryStringSortedSetPermance.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.sortedDictionaryStringSortedSetPermance[theatreName]; var endDateTime = startDateTime + duration; if (PerformancesOverlap(performances, startDateTime, endDateTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance( theatreName, performanceTitle, startDateTime, duration, price); performances.Add(performance); }
public void WaterYear1931() { Performance p = new Performance(); string path = Globals.TestDataPath; //controlfile tempPath yyyy-mm-dd hh:mm yyyy-mm-dd hh:mm 1DAY -UxlsFileName=file.xls [-STrace=n]"); //-UxlsFileName=V:\PN6200\Models\BoiseRiverWare\BoiseModelData.xls -UDebugLevel=1 -UWaterYear=1943 -UFirstWaterYear=1919 List<string> args = new List<string>(); args.Add(path + "\\RiverWare\\snakeControl.txt"); args.Add("c:\\temp"); args.Add("1927-10-04");// start date for RiverWare args.Add("12:00"); args.Add("1928-07-01");// end date for riverware args.Add("12:00"); args.Add("1DAY"); args.Add("-UXlsFileName=" + path + "\\Riverware\\SnakeTestData.xls"); args.Add("-UWaterYear=1931"); // actual xls data begins 10/4/1930 (water year 1931) args.Add("-UFirstWaterYear=1928"); Reclamation.RiverwareDmi.Program.Main(args.ToArray()); string fn = @"c:\temp\Inflow.Jackson.txt"; TextFile tf = new TextFile(fn); File.Delete(fn); Assert.AreEqual("# import began on line index: 1113", tf[tf.IndexOf("# import")]); Assert.AreEqual("start_date: 1927-10-04 24:00", tf[tf.IndexOf("start_date")]); int idx = tf.IndexOf("start_date"); Assert.AreEqual(691.4, Convert.ToDouble(tf[idx+1]),.1); Assert.AreEqual(689.4, Convert.ToDouble(tf[idx + 2]), .1); Assert.AreEqual(689.4, Convert.ToDouble(tf[idx + 3]), .1); Assert.AreEqual(4211.4, Convert.ToDouble(tf[idx + 4]), .1); p.Report("completed FullDataDump()"); }
/// <summary>Initializes a new instance of the <see cref="T:OregonTrailDotNet.Module.Scoring.Highscore" /> class.</summary> /// <param name="name">The name.</param> /// <param name="points">The points.</param> public Highscore(string name, int points) { // PassengerLeader of party and total number of points. Name = name; Points = points; // Rank the players performance based on the number of points they have. if (points >= 7000) _rating = Performance.TrailGuide; else if ((points >= 3000) && (points < 7000)) _rating = Performance.Adventurer; else if (points < 3000) _rating = Performance.Greenhorn; }
private void Context() { BestTeamName = "Jetsons"; BestTeamWins = "20"; BestTeamLosses = "4"; var WorstTeamName = "No one"; var WorstTeamWins = "1"; var WorstTeamLosses = "24"; var bestTeamData = new Performance(BestTeamName, BestTeamWins, BestTeamLosses); var worstTeamData = new Performance(WorstTeamName, WorstTeamWins, WorstTeamLosses); LeaderBoard = new SportTeamLeaderBoard(bestTeamData, worstTeamData); }
/// <summary> /// Imports daily data from Hydromet into TimeSeriesDatabase /// </summary> /// <param name="db"></param> private static void ImportHydrometDaily(TimeSeriesDatabase db, DateTime t1, DateTime t2, string filter, string propertyFilter) { Performance perf = new Performance(); Console.WriteLine("ImportHydrometDaily"); int block = 1; foreach (string query in GetBlockOfQueries(db,TimeInterval.Daily,filter,propertyFilter)) { var table = HydrometDataUtility.ArchiveTable(HydrometHost.PN, query, t1, t2, 0); Console.WriteLine("Block " + block + " has " + table.Rows.Count + " rows "); Console.WriteLine(query); SaveTableToSeries(db, table, TimeInterval.Daily); block++; } perf.Report("Finished importing daily data"); // 15 seconds }
public void AddPerformance(string theatreName, string performanceTitle, DateTime date, TimeSpan duration, decimal price) { if (!this._theatrePerformances.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performancePerTheatre = this._theatrePerformances[theatreName]; var endTime = date + duration; if (PerformanceOverlap(performancePerTheatre, date, endTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatreName, performanceTitle, date, duration, price); performancePerTheatre.Add(performance); }
public void AddPerformance(string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.allTeaters.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.allTeaters[theatreName]; var endDateTime = startDateTime + duration; if (this.IsAvailableSlot(performances, startDateTime, endDateTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatreName, performanceTitle, startDateTime, duration, price); performances.Add(performance); }
public void AddPerformance(string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.sortedSetPerformances.ContainsKey(theatreName)) { throw new TheatreNotFoundException(Constants.TheatreDoesNotExistMsg); } var performances = this.sortedSetPerformances[theatreName]; var endDateTime = startDateTime + duration; if (IsOverlap(performances, startDateTime, endDateTime)) { throw new TimeDurationOverlapException(Constants.TimeOverlapMsg); } var performance = new Performance(theatreName, performanceTitle, startDateTime, duration, price); performances.Add(performance); }
public void AddPerformance(string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.theaters.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Error: Theatre does not exist"); } var overlaps = IsOverlapping(this.theaters[theatreName], startDateTime, startDateTime + duration); if (overlaps) { throw new TimeDurationOverlapException("Error: Time/duration overlap"); } var performanceToAdd = new Performance(performanceTitle, theatreName, startDateTime, duration, price); this.theaters[theatreName].Add(performanceToAdd); }
public void AddPerformance(string theatre, string name, DateTime start, TimeSpan duration, decimal price) { if (!this.performancesDatabase.ContainsKey(theatre)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.performancesDatabase[theatre]; DateTime performanceEnd = start + duration; if (CheckForPerformanceOverlapping(performances, start, performanceEnd)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatre, name, start, duration, price); performances.Add(performance); }
public void AddPerformance(string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.performanceByTheatre.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.performanceByTheatre[theatreName]; var endDateTime = startDateTime + duration; var hasOverlapping = CheckForOverlapping(performances, startDateTime, endDateTime); if (hasOverlapping) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatreName, performanceTitle, startDateTime, duration, price); performances.Add(performance); }
void IPerformanceDatabase.AddPerformance(string theatre, string performanceName, DateTime date, TimeSpan duration, decimal ticketPrice) { if (!this.db.ContainsKey(theatre)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.db[theatre]; var endDate = date + duration; if (isOverlap(performances, date, endDate)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var p = new Performance(theatre, performanceName, date, duration, ticketPrice); performances.Add(p); }
public void MultiYearTest() { Performance p = new Performance(); string path = Reclamation.Core.Globals.TestDataPath; for (int i = 1; i <= 2; i++) { string dir = @"C:\Temp\dmitest"; Directory.CreateDirectory(dir); List<string> args = new List<string>(); args.Add(path + "\\RiverWare\\boiseControl.txt"); args.Add(dir); args.Add("1927-10-04");// date for RiverWare args.Add("12:00"); args.Add("1928-07-01"); args.Add("12:00"); args.Add("-UXlsFileName=" + path + "\\RiverWare\\BoiseModelData.xls"); args.Add("-sTrace="+i); if( Directory.Exists(dir)) Directory.Delete(dir,true); Directory.CreateDirectory(dir); Reclamation.RiverwareDmi.Program.Main(args.ToArray()); string fn = dir + "\\Inflow.Anderson Ranch.txt"; TextFile tf = new TextFile(fn); int idx = tf.IndexOf("start_date"); if (i == 1) // 1918 { double val = Convert.ToDouble(tf[idx + 1]); Assert.AreEqual(429, val, .5); } if (i == 2) // 1919 { double val = Convert.ToDouble(tf[idx + 1]); Assert.AreEqual(348, val, .5); } Directory.Delete(dir, true); } }
public void AddPerformance(string theater, string performance, DateTime S2, TimeSpan duration, decimal ticketPrice) { if (!this.sorderPerformances.ContainsKey(theater)) { throw new TheatreNotFoundException("Theatre does not exist"); } var ps = this.sorderPerformances[theater]; var e2 = S2 + duration; if (Check(ps, S2, e2)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var p = new Performance(theater, performance, S2, duration, ticketPrice); ps.Add(p); }
public void AddPerformance(string theatreName, string performanceName, DateTime dateTime, TimeSpan duration, decimal price) { var isTheaterExist = this.theaterWithSortedPerformances.ContainsKey(theatreName); if (!isTheaterExist) { throw new TheatreNotFoundException("Theatre does not exist"); } var performances = this.theaterWithSortedPerformances[theatreName]; var endDateTime = dateTime + duration; var isOverlapping = IsPerformanceOverlapping(performances, dateTime, endDateTime); if (isOverlapping) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatreName, performanceName, dateTime, duration, price); performances.Add(performance); }
void IPerformanceDatabase.AddPerformance( string theatreName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.theathrePerformances.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var performancesPerTheatre = this.theathrePerformances[theatreName]; var endDateTime = startDateTime + duration; if (ArePerformancesOverlaped(performancesPerTheatre, startDateTime, endDateTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performance = new Performance(theatreName, performanceTitle, startDateTime, duration, price); this.theathrePerformances[theatreName].Add(performance); }
/// <summary> /// Loads xml version of MCF /// </summary> /// <param name="svr"></param> /// <returns></returns> public static McfDataSet GetDataSetFromCsvFiles( ) { Performance p = new Performance(); var ds = new McfDataSet(); // ds.EnforceConstraints = false; foreach (var item in tableNames) { var fn = FileUtility.GetFileReference(item + ".csv"); if (!File.Exists(fn)) { Logger.WriteLine("Error: file missing '" + fn + "'"); continue; } var csv = new CsvFile(fn); if( item == "site") FixLatLong(csv); // yakima has two extra columns. //if (item == "pcode" && csv.Columns.Contains("TAGTYPE")) // csv.Columns.Remove("TAGTYPE"); //if (item == "pcode" && csv.Columns.Contains("LOGORDER")) // csv.Columns.Remove("LOGORDER"); csv.TableName = item + "mcf"; try { ds.Merge(csv,true, MissingSchemaAction.Ignore); } catch (ConstraintException ce) { Console.WriteLine("Error in table "+item +"\n "+ce.Message); PrintTableErrors(csv); } } return ds; }
public override void HandleReceive(byte[] receiveBuffer, int offset, int count) { try { Performance.UpdateBytesReceived(count); Socks4Response socksServerResponse = Socks4Response.Parse(receiveBuffer); if (!socksServerResponse.Success) { HandleLocalDisconnect(); return; } _ClientConnection.SetObserver(new TransmissionRedirectConnectionObserver(_Client, true)); _Client.SetObserver(new TransmissionRedirectConnectionObserver(_ClientConnection, false)); _ClientConnection.BeginReceiving(); } catch (Exception exp) { HandleLocalDisconnect(); } }
public void AddPerformance(Guid directorId, Performance performance) { if (directorId == Guid.Empty) { throw new ArgumentNullException(nameof(directorId)); } var director = _context.Directors.SingleOrDefault(d => d.Guid == directorId); if (performance == null) { throw new ArgumentNullException(nameof(performance)); } if (PerformanceExists(directorId, performance)) { throw new ArgumentException("This performance already exists in database!"); } performance.DirectorId = director.Id; _context.Performances.Add(performance); }
public void ClientTxPerformanceIncrement(string command) { if (!Performance.IsPerformanceEnabled) { return; } Performance performance = null; if (!ClientTxPerformance.TryGetValue(command, out performance)) { try { performance = Performance.CreatePerformance("_Ctx" + command.ToUpper()); ClientTxPerformance[command] = performance; } catch { } } if (performance != null) { performance.Count(DateTime.Now.Ticks / 10000 / 1000); } }
private void updateSamples() { // Update timing samples timingData.Add(Performance.getAverageTimingValue()); timingPeekData.Add(Performance.getPeekTimingValue()); // Update usage samples for (int i = 0; i < ThreadManager.maxAllowedWorkerThreads; i++) { // Check for active thread if (i <= ThreadManager.maxAllowedWorkerThreads) { // Try to get the value float value = Performance.getUsageValue(i); // Add the usage data usageData[i].Add(value); } } // Move to next sample Performance.stepSample(); }
void IPerformanceDatabase.AddPerformance( string theatreName, string performanceName, DateTime performanceDateTime, TimeSpan performanceDuration, decimal ticketPrice) { if (!this.sortedDictionaryStringSortedSetPerformance.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var ps = this.sortedDictionaryStringSortedSetPerformance[theatreName]; var e2 = performanceDateTime + performanceDuration; if (PerformanceOverlapCheck(ps, performanceDateTime, e2)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var p = new Performance(theatreName, performanceName, performanceDateTime, performanceDuration, ticketPrice); ps.Add(p); }
public void AddPerformance( string theathre, string performance, DateTime startDate, TimeSpan duration, decimal ticketPrice) { if (!this.performances.ContainsKey(theathre)) { throw new TheatreNotFoundException("Theatre does not exist"); } var allPerformances = this.performances[theathre]; var endDate = startDate + duration; if (Check(allPerformances, startDate, endDate)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var theatrePerformance = new Performance(theathre, performance, startDate, duration, ticketPrice); allPerformances.Add(theatrePerformance); }
public void AddPerformance( string theatreName, string performanceName, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.sortedTheatresWithPerformances.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var sortedSetPerformances = this.sortedTheatresWithPerformances[theatreName]; var performanceEndTime = startDateTime + duration; if (this.CheckForIncorrectDuration(sortedSetPerformances, startDateTime, performanceEndTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var newPerformance = new Performance(theatreName, performanceName, startDateTime, duration, price); sortedSetPerformances.Add(newPerformance); }
public PlayInfoForm(PlaysListForm upperForm) { InitializeComponent(); UpperForm = upperForm; nameLabel.Text = UpperForm.ChosenPlay.PlayName; durationLabel.Text = UpperForm.ChosenPlay.PlayDuration + ""; castLabel.Text = UpperForm.ChosenPlay.PlayCast; pictureBox1.ImageLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, UpperForm.ChosenPlay.PictureString + ".jpg"); foreach (Performance performance in UpperForm.ChosenPlay.PlayPerformances) { listBox1.Items.Add(performance.PerformanceDate); } if (UpperForm.ChosenPlay.PlayPerformances.Count != 0) { ChosenPerformance = UpperForm.ChosenPlay.PlayPerformances[0]; listBox1.SelectedIndex = 0; } if (UpperForm.UpperForm.LoggedInUser != null) { this.label5.Text = "Logged in as: " + UpperForm.UpperForm.LoggedInUser.FirstName + " " + UpperForm.UpperForm.LoggedInUser.LastName; } this.Show(); }
private SpriteFrameData(SpriteResource resource) { MaxWidth = resource.MaxWidth; MaxHeight = resource.MaxHeight; Frames = new SpriteFrame[resource.FrameCount]; for (int i = 0; i < resource.FrameCount; i++) { Performance.Push("SetData"); WWTexture tex = WWTexture.FromRawData(resource.MaxWidth, resource.MaxHeight, resource.Frames[i].image_data); Performance.Pop(); Frames[i] = new SpriteFrame(); Frames[i].OffsetX = resource.Frames [i].disp_x; Frames[i].OffsetY = resource.Frames [i].disp_y; Frames[i].Width = resource.Frames [i].width; Frames[i].Height = resource.Frames [i].height; Performance.Push("FromDXTexture"); Frames[i].texture = tex; Performance.Pop(); } }
/// <summary> /// Author: Jacob Miller /// Created: 2019/1/22 /// This method takes a Performance object for simplicity and uniformality but will only use the ID /// </summary> /// <param name="perf">The performance to be deleted</param> public void DeletePerformance(Performance perf) { var conn = DBConnection.GetDbConnection(); string cmdText = @"sp_delete_performance"; var cmd = new SqlCommand(cmdText, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PerformanceID", SqlDbType.Int); cmd.Parameters["@PerformanceID"].Value = perf.ID; try { conn.Open(); cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { var reference = Guid.NewGuid().ToString(); Performance.Start(reference); int width = MeasureSpec.GetSize(widthMeasureSpec); int height; if (ParentHasUnevenRows) { SizeRequest measure = _view.Element.Measure(Context.FromPixels(width), double.PositiveInfinity, MeasureFlags.IncludeMargins); height = (int)Context.ToPixels(_viewCell.Height > 0 ? _viewCell.Height : measure.Request.Height); } else { height = (int)Context.ToPixels(ParentRowHeight == -1 ? BaseCellView.DefaultMinHeight : ParentRowHeight); } SetMeasuredDimension(width, height); Performance.Stop(reference); }
public static SizeRequest GetNativeSize(VisualElement view, double widthConstraint, double heightConstraint) { Performance.Start(out string reference); var renderView = GetRenderer(view); if (renderView == null || renderView.NativeView == null) { if (view is IView iView) { Application.Current?.FindMauiContext()?.CreateLogger <Platform>()?.LogWarning( "Someone called Platform.GetNativeSize instead of going through the Handler."); return(new SizeRequest(iView.Handler.GetDesiredSize(widthConstraint, heightConstraint))); } Performance.Stop(reference); return(new SizeRequest(Size.Zero)); } Performance.Stop(reference); return(renderView.GetDesiredSize(widthConstraint, heightConstraint)); }
// ------- public static void Initialize(Performance suggestion) { // verify that Unity Quality settings contains all settings which we are using... string[] names = QualitySettings.names; //Debug.Log("DeviceInfo.Initialize"); MFDebugUtils.Assert(System.Array.IndexOf(names, m_UnityQualityProfileName_UltraLow) >= 0); MFDebugUtils.Assert(System.Array.IndexOf(names, m_UnityQualityProfileName_Low) >= 0); MFDebugUtils.Assert(System.Array.IndexOf(names, m_UnityQualityProfileName_Medium) >= 0); MFDebugUtils.Assert(System.Array.IndexOf(names, m_UnityQualityProfileName_High) >= 0); MFDebugUtils.Assert(System.Array.IndexOf(names, m_UnityQualityProfileName_UltraHigh) >= 0); if (suggestion != Performance.Auto) { m_Performance = suggestion; SetPerformanceLevel(m_Performance); } else { Check(); } }
public bool CreatePerformance(PerformanceVM model) { var success = false; using (var db = new ManagementToolProjectEntities()) { var resp = new PerformanceRepository(db); var perf = new Performance { Date = DateTime.Parse(model.PerformanceDate), EventId = model.EventId, Price = model.Price, status = model.Cancelled, TotalTickets = model.AvailableTickets }; resp.Insert(perf); success = db.SaveChanges() > 0; } return(success); }
public ViewModel() { this.Performance = new ObservableCollection <Model>(); Performance.Add(new Model() { ServerLoad = 2005, Server1 = 4.5, Server2 = 10 }); Performance.Add(new Model() { ServerLoad = 2006, Server1 = 33, Server2 = 26 }); Performance.Add(new Model() { ServerLoad = 2007, Server1 = 15, Server2 = 20 }); Performance.Add(new Model() { ServerLoad = 2008, Server1 = 5, Server2 = 10 }); Performance.Add(new Model() { ServerLoad = 2009, Server1 = 20, Server2 = 30 }); Performance.Add(new Model() { ServerLoad = 2010, Server1 = 32, Server2 = 30 }); Performance.Add(new Model() { ServerLoad = 2011, Server1 = 18, Server2 = 27 }); Performance.Add(new Model() { ServerLoad = 2012, Server1 = 13, Server2 = 6 }); }
private static void CreatePerformances() { Console.WriteLine("Insert Performances "); IVenueDao venueDao = DALFactory.CreateVenueDao(DALFactory.CreateDatabase()); IPerformanceDao performanceDao = DALFactory.CreatePerformanceDao(DALFactory.CreateDatabase()); IArtistDao artistDao = DALFactory.CreateArtistDao(DALFactory.CreateDatabase()); int year = 2016; int month = 01; int day = 23; for (int i = 0; i < 3; i++) { int count = 1; int hour = 14; int min = 00; int second = 00; for (int j = 1; j <= 40; j++) { count++; if (count == 10) { hour = hour + 2; count = 1; } DateTime dt = new DateTime(year, month, day, hour, min, second); Venue venue = venueDao.findById(j); Artist artist = artistDao.findById(j); Performance p = new Performance(); p.Artist = artist; p.Venue = venue; p.StagingTime = dt; performanceDao.Insert(p); } day++; } }
public static bool InsertPerformance(Performance performance) { bool exito = false; if (DBConnection.dbconn != null) { NpgsqlCommand dbcmd = DBConnection.dbconn.CreateCommand(); try { string sql = string.Format("INSERT INTO start_performance (angle, game_session_id, movement_id) VALUES ({0}, {1}, '{2}');", performance.Angle, performance.Game_session_id, performance.Movement_id); Debug.Log(sql); dbcmd.CommandText = sql; dbcmd.ExecuteNonQuery(); //Debug.Log(""); exito = true; } catch (NpgsqlException ex) { Debug.Log(ex.Message); } // clean up dbcmd.Dispose(); dbcmd = null; } else { Debug.Log("Database connection not established"); } return(exito); }
public override void _Process(float delta) { if (FPS) { _fps.Text = Performance.GetMonitor(Performance.Monitor.TimeFps).ToString(); // Engine.GetFramesPerSecond().ToString(); } if (Process) { _process.Text = "Process:" + Mathf.RoundToInt(Performance.GetMonitor(Performance.Monitor.TimeProcess)).ToString(); } if (Physics_Process) { _physicsProcess.Text = "Physics Process:" + Mathf.RoundToInt(Performance.GetMonitor(Performance.Monitor.TimePhysicsProcess)).ToString(); } if (Mem) { _mem.Text = "Mem:" + Mathf.RoundToInt(Performance.GetMonitor(Performance.Monitor.MemoryStatic) / 1024).ToString(); // OS.GetStaticMemoryUsage() } if (Objects) { _objects.Text = "Objects:" + Performance.GetMonitor(Performance.Monitor.ObjectCount).ToString(); } if (Resources) { _resources.Text = "Resources:" + Performance.GetMonitor(Performance.Monitor.ObjectResourceCount).ToString(); } if (Nodes) { _nodes.Text = "Nodes:" + Performance.GetMonitor(Performance.Monitor.ObjectNodeCount).ToString(); } if (Drawcalls) { _drawcalls.Text = "Drawcalls:" + Performance.GetMonitor(Performance.Monitor.Render2dDrawCallsInFrame).ToString(); } _Update_Properties(); }
public void UpdateLayout() { Performance.Start(); VisualElement view = _renderer.Element; AView aview = _renderer.ViewGroup; var x = (int)_context.ToPixels(view.X); var y = (int)_context.ToPixels(view.Y); var width = (int)_context.ToPixels(view.Width); var height = (int)_context.ToPixels(view.Height); var formsViewGroup = aview as FormsViewGroup; if (formsViewGroup == null) { Performance.Start("Measure"); aview.Measure(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly)); Performance.Stop("Measure"); Performance.Start("Layout"); aview.Layout(x, y, x + width, y + height); Performance.Stop("Layout"); } else { Performance.Start("MeasureAndLayout"); formsViewGroup.MeasureAndLayout(MeasureSpecFactory.MakeMeasureSpec(width, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(height, MeasureSpecMode.Exactly), x, y, x + width, y + height); Performance.Stop("MeasureAndLayout"); } Performance.Stop(); //On Width or Height changes, the anchors needs to be updated UpdateAnchorX(); UpdateAnchorY(); }
protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context) { Performance.Start(); var cell = (ViewCell)item; var container = convertView as ViewCellContainer; if (container != null) { container.Update(cell); Performance.Stop(); return(container); } BindableProperty unevenRows = null, rowHeight = null; if (ParentView is TableView) { unevenRows = TableView.HasUnevenRowsProperty; rowHeight = TableView.RowHeightProperty; } else if (ParentView is ListView) { unevenRows = ListView.HasUnevenRowsProperty; rowHeight = ListView.RowHeightProperty; } IVisualElementRenderer view = Platform.CreateRenderer(cell.View); Platform.SetRenderer(cell.View, view); cell.View.IsPlatformEnabled = true; var c = new ViewCellContainer(context, view, cell, ParentView, unevenRows, rowHeight); Performance.Stop(); return(c); }
public void Update(GameTime gameTime) { Performance.Push("Game loop"); InputManager.UpdateInput(gameTime); lock (lockObj) { if (NextScene != null) { if (CurrentScene != null) { CurrentScene.Close(); } CurrentScene = NextScene; if (CurrentScene != null) { CurrentScene.Init(this); } NextScene = null; } if (CurrentScene != null) { if (CurrentScene.MouseCursor != null) { CurrentScene.MouseCursor.Position = InputManager.MousePosition; } CurrentScene.Update(gameTime); } } Performance.Pop(); }
private static void CalculateTotalPoints(Performance p, Scoring scoring) { int total = 0; total += p.Appearance ? scoring.Appearance : 0; total += p.Assists * scoring.Assist; total += p.CleanSheet ? scoring.CleanSheet : 0; total += p.Goals * scoring.GoalScored; if (p.GoalsConceeded > 1 && (p.Position == Position.Defence || p.Position == Position.GoalKeeper)) { total += Convert.ToInt32(Math.Floor(p.GoalsConceeded * -0.5)); } if (p.GoalsConceeded > 2 && p.Position == Position.Midfield) { if (p.GoalsConceeded > 6) { total -= 3; } else if (p.GoalsConceeded > 4) { total -= 2; } else if (p.GoalsConceeded > 2) { total -= 1; } } total += p.MOTM ? scoring.MOTM : 0; total += p.PenaltiesMissed * scoring.PenMiss; total += p.PenaltiesSaved * scoring.PenSave; total += p.RedCard ? scoring.RedCard : 0; total += p.YellowCard ? scoring.YellowCard : 0; p.TotalPoints = total; }
public void UpdateShadowMap(ShadowMapRenderDelegate renderScene) { //shadowMapProjection = Matrix.PerspectiveFovLH(MathHelper.PiOver2, 1, 1f, LightRadius + 1); shadowMapProjection = CreateShadowMapProjection(LightRadius); for (int i = 0; i < 6; i++) { Performance.BeginEvent(new Color4(1, 1, 0), "ShadowCubeFace" + i.ToString()); var view = CreateShadowMapView(LightPosition, i); // TODO: store this value instead of rebuilding every time context.ClearDepthStencilView(depthStencilViewFaces[i], DepthStencilClearFlags.Depth, 1, 0); //if (i != 0) continue; //context.ClearDepthStencilView(depthStencilViewFaces[i], DepthStencilClearFlags.Depth, 0, 0); LightCameras[i].SetViewProjectionMatrix(view, shadowMapProjection); context.ClearState(); context.Rasterizer.SetViewports(new Viewport(0, 0, shadowMapSize, shadowMapSize)); context.OutputMerger.SetTargets(depthStencilViewFaces[i]); renderScene(LightCameras[i]); Performance.EndEvent(); } }
public int InsertToSPerformance(Performance performance) { bool exito = false; if (DBConnection.dbconn != null) { NpgsqlCommand dbcmd = DBConnection.dbconn.CreateCommand(); try { string save_sql = "INSERT INTO start_performance VALUES (NEXTVAL ('start_performance_id_seq'), " + performance.Angle + "," + this.GetLastGameSessionId() + "," + performance.Movement_id + ");"; dbcmd.CommandText = save_sql; dbcmd.ExecuteNonQuery(); exito = true; } catch (NpgsqlException ex) { Debug.Log(ex.Message); } // clean up dbcmd.Dispose(); dbcmd = null; } else { Debug.Log("Database connection not established"); } return(-1); }
public void AddPerformance( string theatre, string performance, DateTime performanceStartDateAndTime, TimeSpan duration, decimal price) { if (!this.sortedDictionaryStringSortedSetPerformance.ContainsKey(theatre)) { throw new ArgumentException("Theatre does not exist"); } var performances = this.sortedDictionaryStringSortedSetPerformance[theatre]; var performanceEndDateAndTime = performanceStartDateAndTime + duration; if (CheckValidPerformanceDateAndTime(performances, performanceStartDateAndTime, performanceEndDateAndTime)) { throw new InvalidOperationException("Time/duration overlap"); } var currentPerformance = new Performance(theatre, performance, performanceStartDateAndTime, duration, price); performances.Add(currentPerformance); //sortedSetPerformances.Add(currentPerformance); }
void UpdateNativeView(object sender, EventArgs e) { Performance.Start(); VisualElement view = _renderer.Element; AView aview = _renderer.ViewGroup; if (aview is FormsViewGroup) { var formsViewGroup = (FormsViewGroup)aview; formsViewGroup.SendBatchUpdate((float)(view.AnchorX * _context.ToPixels(view.Width)), (float)(view.AnchorY * _context.ToPixels(view.Height)), (int)(view.IsVisible ? ViewStates.Visible : ViewStates.Invisible), view.IsEnabled, (float)view.Opacity, (float)view.Rotation, (float)view.RotationX, (float)view.RotationY, (float)view.Scale, _context.ToPixels(view.TranslationX), _context.ToPixels(view.TranslationY)); } else { UpdateAnchorX(); UpdateAnchorY(); UpdateIsVisible(); if (view.IsEnabled != aview.Enabled) { aview.Enabled = view.IsEnabled; } UpdateOpacity(); UpdateRotation(); UpdateRotationX(); UpdateRotationY(); UpdateScale(); UpdateTranslationX(); UpdateTranslationY(); } Performance.Stop(); }
public void UpdatePerformance() { Performance pr = new Performance() { ZeroTo100 = 2.9, HorsePower = 610, MaxSpeed = 315.2, }; using (var context = new RentMyCarContext(options)) { var service = new CarRepository(context); service.SetPerformance(this._user.UserName, 2, pr); } using (var context = new RentMyCarContext(options)) { Assert.AreEqual(2.9, context.Cars.Include(c => c.Performance) .Single().Performance.ZeroTo100); Assert.AreEqual(610, context.Cars.Include(c => c.Performance) .Single().Performance.HorsePower); Assert.AreEqual(315.2, context.Cars.Include(c => c.Performance) .Single().Performance.MaxSpeed); } }
public async Task <IActionResult> Create([Bind("Name,Date,Comments,VenueID")] Performance performance) { try { if (ModelState.IsValid) { _context.Add(performance); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { id = performance.ID })); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. Make sure your Performance Name is " + "not a double entry on the same date." + "Try again, and if the problem persists " + "see your system administrator."); } ViewData["VenueID"] = new SelectList(_context.Venues, "ID", "VenueName", performance.VenueID); return(View(performance)); }
public void AddPerformance( string theaterName, string performanceTitle, DateTime startDateTime, TimeSpan duration, decimal price) { if (!this.performances.ContainsKey(theaterName)) { throw new TheaterNotFoundException("Theatre does not exist"); } var performance = this.performances[theaterName]; var endDateTime = startDateTime + duration; if (CheckOverlappingPerformances(performance, startDateTime, endDateTime)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var newPerformance = new Performance(theaterName, performanceTitle, startDateTime, duration, price); performance.Add(newPerformance); }
internal MapPath CalcPath(int startX, int startY, int endX, int endY) { Performance.Push("Calculate path from " + startX + "," + startY + " to " + endX + "," + endY); try { Log.Status("Map: Calculating path from " + startX + "," + startY + " to " + endX + "," + endY + "..."); MapPath path = Pathfinder.FindPath(startX, startY, endX, endY); if (path != null) { Log.Status("... success (" + path.Count + " Nodes)!"); return(path); } Log.Status("... failed!"); return(null); } finally { Performance.Pop(); } }
public virtual void AddPerformance( string theatreName, string performanceTitle, DateTime dateTime, TimeSpan duration, decimal price) { if (!this.theatresDatabase.ContainsKey(theatreName)) { throw new TheatreNotFoundException("Theatre does not exist"); } var theatreData = this.theatresDatabase[theatreName]; var dateTimeAndDuration = dateTime + duration; if (CheckOverlappingPerformance(theatreData, dateTime, dateTimeAndDuration)) { throw new TimeDurationOverlapException("Time/duration overlap"); } var performanceData = new Performance(theatreName, performanceTitle, dateTime, duration, price); theatreData.Add(performanceData); }
private void onSettings(bool open, Toggl.TogglSettingsView settings) { if (this.TryBeginInvoke(this.onSettings, open, settings)) { return; } if (this.isSaving) { return; } using (Performance.Measure("filling settings from OnSettings")) { this.updateUI(settings); this.selectDefaultProjectFromSettings(); } if (open) { this.Show(); this.Activate(); } }
static void Main(string[] args) { float area = 0; Performance.Benchmark("Read and calculate", () => { var corners = new List <Point>(); var pos = new Point(0, 0); corners.Add(pos); var route = File.ReadAllText("rute.txt"); int prev = route[0]; foreach (var c in route) { if (c != prev) { corners.Add(pos); prev = c; } pos += GetDirection(c); } area = GetArea(corners); }); Console.WriteLine($"Arealet er {area}"); }
public void WaterYear1931() { Performance p = new Performance(); string path = Globals.TestDataPath; //controlfile tempPath yyyy-mm-dd hh:mm yyyy-mm-dd hh:mm 1DAY -UxlsFileName=file.xls [-STrace=n]"); //-UxlsFileName=V:\PN6200\Models\BoiseRiverWare\BoiseModelData.xls -UDebugLevel=1 -UWaterYear=1943 -UFirstWaterYear=1919 List <string> args = new List <string>(); args.Add(path + "\\RiverWare\\snakeControl.txt"); args.Add("c:\\temp"); args.Add("1927-10-04"); // start date for RiverWare args.Add("12:00"); args.Add("1928-07-01"); // end date for riverware args.Add("12:00"); args.Add("1DAY"); args.Add("-UXlsFileName=" + path + "\\Riverware\\SnakeTestData.xls"); args.Add("-UWaterYear=1931"); // actual xls data begins 10/4/1930 (water year 1931) args.Add("-UFirstWaterYear=1928"); Reclamation.RiverwareDmi.Program.Main(args.ToArray()); string fn = @"c:\temp\Inflow.Jackson.txt"; TextFile tf = new TextFile(fn); File.Delete(fn); Assert.AreEqual("# import began on line index: 1113", tf[tf.IndexOf("# import")]); Assert.AreEqual("start_date: 1927-10-04 24:00", tf[tf.IndexOf("start_date")]); int idx = tf.IndexOf("start_date"); Assert.AreEqual(691.4, Convert.ToDouble(tf[idx + 1]), .1); Assert.AreEqual(689.4, Convert.ToDouble(tf[idx + 2]), .1); Assert.AreEqual(689.4, Convert.ToDouble(tf[idx + 3]), .1); Assert.AreEqual(4211.4, Convert.ToDouble(tf[idx + 4]), .1); p.Report("completed FullDataDump()"); }
public static void Import(string serverIP, string database, string password, string networkListName, string[] siteList, string mrdbPath) { string fn = @"C:\temp\mcf.xml"; Performance perf = new Performance(); var pnMcf = new McfDataSet(); if (File.Exists(fn) && File.GetLastWriteTime(fn).Date == DateTime.Now.Date) { // read existing file. Logger.WriteLine("Reading existing XML"); pnMcf.ReadXml(fn); } else { Logger.WriteLine("Reading csv files from MCF"); pnMcf = McfUtility.GetDataSetFromCsvFiles(mrdbPath); pnMcf.WriteXml(fn); } DumpInfo(pnMcf); Application.DoEvents(); Logger.WriteLine(serverIP); var svr = PostgreSQL.GetPostgresServer(database, serverIP, "decodes", password) as PostgreSQL; DecodesUtility.UpdateSequences(svr); DecodesUtility.GenerateDataSet(@"c:\temp\decodes.xsd", svr); var decodes = DecodesUtility.GetDataSet(svr); McfDecodesConverter c = new McfDecodesConverter(svr, pnMcf, decodes, siteList); c.importMcf(networkListName); }
public ActionResult Edit([Bind(Include = "ID,StudentID,CategoryID,CategoryInfo,PublicationStatsID,AbstractStatsID,ProposalStatsID,TeachingStatsID")] Performance performance) { try { if (ModelState.IsValid) { db.Entry(performance).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { id = performance.StudentID })); } } catch (DataException /*dex*/) { //Log the error (uncomment dex cariable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, please see your system administrator."); } ViewBag.Student = performance.Student; ViewBag.CategoryID = new SelectList(db.CommonFields.Where(o => o.Category == "PerformanceCategory"), "Id", "Name", performance.CategoryID); ViewBag.PublicationStatsID = new SelectList(db.CommonFields.Where(o => o.Category == "Publication"), "Id", "Name", performance.PublicationStatsID); ViewBag.AbstractsStatID = new SelectList(db.CommonFields.Where(o => o.Category == "Publication"), "Id", "Name", performance.AbstractStatsID); ViewBag.ProposalStatsID = new SelectList(db.CommonFields.Where(o => o.Category == "Proposal"), "Id", "Name", performance.ProposalStatsID); ViewBag.TeachingStatsID = new SelectList(db.CommonFields.Where(o => o.Category == "Teaching"), "Id", "Name", performance.TeachingStatsID); return(View(performance)); }
void Awake() { var list=new List<Cell>(); // foreach(Transform e in tableCells.parentCells){ foreach(Transform e in parentCells){ list.Add(e.GetComponent<Cell>()); } cells=list.ToArray(); control=GetComponent<TRNTH.Control>(); performance=GetComponent<Performance>(); }
static Data() { // Conferences Nwc = new Conference("Northwest Conference", "NWC"); Sciac = new Conference("Southern California Intercollegiate Athletic Conference", "SCIAC"); Scac = new Conference("Southern Collegiate Athletic Conference", "SCAC"); Pac12 = new Conference("Pacific 12", "PAC-12"); Conferences = new List<Conference> { Nwc, Sciac, Scac, Pac12 }; // Teams LewisAndClark = new Team("Lewis & Clark") { Conference = Nwc }; Willamette = new Team("Willamette") { Conference = Nwc }; PugetSound = new Team("Puget Sound") { Conference = Nwc }; ClaremontMuddScripps = new Team("Claremont-Mudd-Scripps") { Conference = Sciac }; Pomona = new Team("Pomona-Pitzer") { Conference = Sciac }; ColoradoCollege = new Team("Colorado") { Conference = Scac }; Chapman = new Team("Chapman"); Whitman = new Team("Whitman") { Conference = Nwc }; UniversityOfWashington = new Team("Washington") { Conference = Pac12 }; PacificLutheran = new Team("Pacific Lutheran") { Conference = Nwc }; Teams = new List<Team> { LewisAndClark, Willamette, PugetSound, ClaremontMuddScripps, Pomona, ColoradoCollege, Chapman, Whitman, UniversityOfWashington, PacificLutheran, }; // States California = new State("CA", "California"); Colorado = new State("CO", "Colorado"); Oregon = new State("OR", "Oregon"); Washington = new State("WA", "Washington"); States = new List<State> { California, Colorado, Oregon, Washington }; // Cities Estacada = new City("Estacada", Oregon); Seattle = new City("Seattle", Washington); Claremont = new City("Claremont", California); WallaWalla = new City("Walla Walla", Washington); Chino = new City("Chino", California); Salem = new City("Salem", Oregon); Tacoma = new City("Tacoma", Washington); Portland = new City("Portland", Oregon); Cities = new List<City> { Estacada, Seattle, Claremont, WallaWalla, Chino, Salem, Tacoma, Portland }; // Venues McIver = new Venue("Milo McIver State Park", Estacada); BushPark = new Venue("Bush Pasture Park", Salem); VeteransGolfCourse = new Venue("Veteran's Memorial Golf Course", WallaWalla); PomonaCampus = new Venue("Pomona College Campus", Claremont); LincolnPark = new Venue("Lincoln Park", Seattle); PradoPark = new Venue("Prado Park", Chino); PluGolfCourse = new Venue("PLU Golf Course", Tacoma); FortSteilacoom = new Venue("Fort Steilacoom Park", Tacoma); Venues = new List<Venue> { McIver, BushPark, VeteransGolfCourse, PomonaCampus, LincolnPark, PradoPark, PluGolfCourse, FortSteilacoom }; // Runners Karl = new Runner("Dickman", "Karl", Gender.Male) { EnrollmentYear = 2006 }; Hannah = new Runner("Palmer", "Hannah", Gender.Female) { EnrollmentYear = 2006 }; Richie = new Runner("LeDonne", "Richie", Gender.Male) { EnrollmentYear = 2007 }; Keith = new Runner("Woodard", "Keith", Gender.Male) { EnrollmentYear = 1969 }; Leo = new Runner("Castillo", "Leo", Gender.Male) { EnrollmentYear = 2012 }; Francis = new Runner("Reynolds", "Francis", Gender.Male) { EnrollmentYear = 2010 }; Florian = new Runner("Scheulen", "Florian", Gender.Male) { EnrollmentYear = 2010 }; Jackson = new Runner("Brainerd", "Jackson", Gender.Male) { EnrollmentYear = 2012 }; Runners = new List<Runner> { Karl, Hannah, Richie, Keith, Leo, Francis, Florian, Jackson }; // Affiliations IEnumerable<Runner> runners = new List<Runner> { Florian, Karl, Francis, Richie, Leo, Jackson }; IEnumerable<Team> teams = new List<Team> { ClaremontMuddScripps, LewisAndClark, PugetSound, LewisAndClark, Willamette, ColoradoCollege }; IEnumerable<int> years = new List<int> { 2005, 2006, 2006, 2007, 2008, 2008 }; IEnumerableExtensions.ForEachEqual(runners, teams, years, (runner, team, year) => { for(int i = 0; i < 4; i++) { runner.Affiliations[year + i] = team; } }); foreach(int year in new List<int> { 2006, 2008, 2009, 2010 }) { Hannah.Affiliations[year] = LewisAndClark; } // Meets LCInvite = new Meet("Lewis & Clark Invitational"); CharlesBowles = new Meet("Charles Bowles Invitational"); NwcChampionships = new Meet("Northwest Conference Championship"); SciacMultiDuals = new Meet("SCIAC Multi-Duals"); Sundodger = new Meet("Sundodger Invitational"); Regionals = new Meet("NCAA West Region Championship"); PluInvite = new Meet("Pacific Lutheran Invitational"); Meets = new List<Meet> { LCInvite, CharlesBowles, NwcChampionships, SciacMultiDuals, Sundodger, Regionals, PluInvite }; // Meet instances LCInvite09 = new MeetInstance(LCInvite, new DateTime(2009, 9, 12), McIver) { Host = LewisAndClark }; LCInvite10 = new MeetInstance(LCInvite, new DateTime(2010, 9, 27), McIver) { Host = LewisAndClark }; CharlesBowles09 = new MeetInstance(CharlesBowles, new DateTime(2009, 10, 3), BushPark) { Host = Willamette }; NwcChampionships10 = new MeetInstance(NwcChampionships, new DateTime(2010, 10, 30), FortSteilacoom) { Host = PugetSound }; NwcChampionships09 = new MeetInstance(NwcChampionships, new DateTime(2009, 10, 31), McIver) { Host = LewisAndClark }; NwcChampionships08 = new MeetInstance(NwcChampionships, new DateTime(2008, 11, 1), VeteransGolfCourse) { Host = Whitman }; PluInvite10 = new MeetInstance(PluInvite, new DateTime(2010, 10, 16), PluGolfCourse) { Host = PacificLutheran }; SciacMultiDuals09 = new MeetInstance(SciacMultiDuals, new DateTime(2009, 10, 17), PradoPark) { Host = ClaremontMuddScripps }; Sundodger09 = new MeetInstance(Sundodger, new DateTime(2009, 9, 19), LincolnPark) { Host = UniversityOfWashington }; Regionals08 = new MeetInstance(Regionals, new DateTime(2009, 11, 15), BushPark) { Host = Willamette }; Regionals09 = new MeetInstance(Regionals, new DateTime(2009, 11, 14), PomonaCampus) { Host = Pomona }; MeetInstances = new List<MeetInstance> { LCInvite09, LCInvite10, CharlesBowles09, NwcChampionships10, NwcChampionships09, NwcChampionships08, PluInvite10, SciacMultiDuals09, Sundodger09, Regionals08, Regionals09 }; // Races Races = new Dictionary<MeetInstance, Gender, Race>(); foreach(MeetInstance meetInstance in MeetInstances) { int womensDistance = meetInstance.Meet == CharlesBowles ? 5000 : 6000; Races[meetInstance, Gender.Male] = new Race(meetInstance, Gender.Male, 8000); Races[meetInstance, Gender.Female] = new Race(meetInstance, Gender.Female, womensDistance); } // Performances KarlAtSundodger = new Performance(Karl, Races[Sundodger09, Gender.Male], 24 * 60 + 55); KarlAtWillamette = new Performance(Karl, Races[CharlesBowles09, Gender.Male], 24 * 60 + 44); HannahsPerformance = new Performance(Hannah, Races[Regionals08, Gender.Female], 22 * 60 + 3); FrancisPerformance = new Performance(Francis, Races[NwcChampionships08, Gender.Male], 24 * 60 + 30); Performances = new List<Performance> { KarlAtSundodger, KarlAtWillamette, HannahsPerformance, FrancisPerformance }; }
static void SyncMain(string[] argList) { Arguments args = new Arguments(argList); var p = new OptionSet(); if (argList.Length == 0) { ShowHelp(p); return; } if (args.Contains("debug")) { Logger.EnableLogger(); Reclamation.TimeSeries.Parser.SeriesExpressionParser.Debug = true; } if (args.Contains("test-web")) { var data = Reclamation.Core.Web.GetPage("https://www.usbr.gov"); foreach (var item in data) { Console.WriteLine(item); } return; } if (args.Contains("initialize")) { Rwis.Initialize.Program.initializeMain(argList); return; } Performance perf = new Performance(); var db = TimeSeriesDatabase.InitDatabase(args); if (args.Contains("update-sitecatalog")) { var csvFileName = args["update-sitecatalog"]; if( !File.Exists(csvFileName)) { Console.WriteLine("Cannot open file "+csvFileName); return; } UpdateSiteCatalog(db, csvFileName); return; } DateTime t1, t2; SetupDates(args, out t1, out t2); if (args.Contains("dbinventory")) { db.Inventory(); } if (args.Contains("siteinventory")) { SiteInventory(args, db); } if (args.Contains("update")) { var updateType = args["update"].ToString(); string sql = ""; if (updateType.ToLower() == "all") { sql = "provider IN ('HydrometDailySeries','HDBSeries','ShefSeries')"; } else if (updateType.Length == 2) { sql = "SUBSTRING(tablename,1,2) = '" + db.Server.SafeSqlLiteral(args["update"]).ToLower() + "'"; } else { sql = "provider = '" + db.Server.SafeSqlLiteral(args["update"]) + "'"; } var updateList = db.GetSeriesCatalog(sql); Console.WriteLine("Updating " + updateList.Count + " Series "); foreach (var item in updateList) { try { Console.Write(item.Name.Substring(0, System.Math.Min(30, item.Name.Length)) + "... "); var s = db.GetSeries(item.id); s.Update(t1, t2); s.Read(t1, t2); Console.WriteLine("Updated " + s.Count + " values"); SaveProperties(s); } catch (Exception e) { Console.WriteLine(e.Message); } } } db.Server.Cleanup(); Console.WriteLine("RWIS Sync.exe: Completed " + DateTime.Now.ToString() + "\n"); var mem = GC.GetTotalMemory(true); double mb = mem / 1024.0 / 1024.0; Console.WriteLine("Mem Usage: " + mb.ToString("F3") + " Mb"); perf.Report("RWIS Sync: finished "); }
internal Train () { this.Acceleration = new Acceleration(); this.Performance = new Performance(); this.Delay = new Delay(); this.Move = new Move(); this.Brake = new Brake(); this.Pressure = new Pressure(); this.Handle = new Handle(); this.Cab = new Cab(); this.Car = new Car(); this.Device = new Device(); this.MotorP1 = new Motor(); this.MotorP2 = new Motor(); this.MotorB1 = new Motor(); this.MotorB2 = new Motor(); }
public Performance Save(Performance performance, int hourOffset = 0) { if (performance == null) { throw new ArgumentException("Cannot save null perforamnce"); } try { StartTx(); Performance performanceDB = null; Artist artist = artistDao.ById(performance.ArtistId); venueDao.EntityExists(performance.VenueId); // Validate start end dates if (performance.StartDate.Value.Date != performance.EndDate.Value.Date) { throw new ServiceException((int)PerformanceErrorCode.PERFORMANCE_DATE_INVALID); } if ((performance.StartDate.Value.Hour + 1) != (performance.EndDate.Value.Hour)) { throw new ServiceException((int)PerformanceErrorCode.PERFORMANCE_DATE_INVALID); } //Validate if in past if ((performance.StartDate.Value.CompareTo(DateTime.Now) <= 0)) { throw new ServiceException((int)PerformanceErrorCode.PERFORMANCE_IN_PAST); } // Clear eventually added millis and seconds performance.StartDate = new DateTime( performance.StartDate.Value.Year, performance.StartDate.Value.Month, performance.StartDate.Value.Day, performance.StartDate.Value.Hour, 0, 0); performance.EndDate = new DateTime( performance.EndDate.Value.Year, performance.EndDate.Value.Month, performance.EndDate.Value.Day, performance.EndDate.Value.Hour, 0, 0); // Validate if artist has already a performance with the defined date + offset DateTime startDateWithOffset = performance.StartDate.Value; DateTime endDateWithOffset = performance.EndDate.Value; startDateWithOffset = startDateWithOffset.AddHours(-hourOffset); endDateWithOffset = endDateWithOffset.AddHours(hourOffset); if (performanceDao.ArtistHasPerformanceOnDate(performance.ArtistId, startDateWithOffset, endDateWithOffset, performance.Id ?? -1)) { throw new ServiceException((int)PerformanceErrorCode.ARTIST_OVERBOOKED); } // Validate if other artist has performance on venue if (performanceDao.VenueHasPerformanceOnDate(performance.VenueId.Value, performance.StartDate.Value, performance.EndDate.Value, performance.Id ?? -1)) { throw new ServiceException((int)PerformanceErrorCode.VENUE_OVERBOOKED); } // New performance if (performance.Id == null) { performanceDB = performanceDao.Persist(performance); } // Update existing one else { // Check if performance is moved and save former dateTime values if it is so performanceDB = performanceDao.ById(performance.Id); if (performanceDB.StartDate.Value.CompareTo(performance.StartDate.Value) != 0) { performance.FormerStartDate = performanceDB.StartDate; performance.FormerEndDate = performanceDB.EndDate; } // Check if venue has changed if (performanceDB.VenueId != performance.VenueId) { // Also if just venue has changed, the dates needs to be set performance.FormerStartDate = performanceDB.StartDate; performance.FormerEndDate = performanceDB.EndDate; performance.FormerVenueId = performanceDB.VenueId; } performanceDB = performanceDao.Update(performance); } CommitTx(); return performanceDB; } catch (Exception) { RollbackTx(); throw; } }
static MouseInputHook() { hookProc = new WinAPI.WindowHook.HookProc(MouseHook); hookProcPtr = Marshal.GetFunctionPointerForDelegate(hookProc); MouseInputPerformance = Performance.CreatePerformance("_MouseInput"); }