/Source/AIGA/src/eduGRID_Framework/eduGRID_Client/eduGRID_Client/ConfXP.Base/MSR.LST.ArchiveService/archiver/Constants.cs

https://github.com/abhishek-kumar/AIGA · C# · 71 lines · 49 code · 12 blank · 10 comment · 5 complexity · 1ce993d6db37cd630e99edd58155f16c MD5 · raw file

  1. using System;
  2. using System.Reflection;
  3. namespace MSR.LST.ConferenceXP.ArchiveService
  4. {
  5. /// <summary>
  6. /// Constants class..Static to hold all the constants for the application
  7. /// </summary>
  8. public abstract class Constants
  9. {
  10. public static string PersistenceCName = "ArchiveService@microsoft.com"; // name of us as a participant
  11. public static string PersistenceName = "Archive Service";
  12. public static int MaxDBStringSize = 255; // no. of chars allowed in varchar datatypes
  13. public static string SQLConnectionString =
  14. "Initial Catalog='ArchiveService';Data Source=.;Integrated Security=true;Connect Timeout=120";
  15. public const int TicksPerMs = 10000; // handy constant
  16. public static int CommandTimeout = 60; // command timeout used on commands in DBHelper
  17. // Recording constants
  18. public static int InitialStreams = 4; // number of streams we expect
  19. public static int BufferSize = 405 * 8080 / 4; // 1/4 of the data than an intermediate page in a SQL BLOB can hold
  20. public static int BufferTimeout = -1; // timeout before buffer writes to disk; turned off
  21. public static int IndexCapacity = BufferSize / 1024; // allow for 1024 byte frames
  22. public static int InitialBuffers = 2; // basic # of buffers necessary under small load
  23. public static int MaxBuffers = 8; // under horrendous load, we can peak to this
  24. public static int StopAfterVenueEmptySec = 60; // <x> sec after a venue is empty, we stop recording
  25. // Playback constants
  26. public static int BuffersPerStream = 2; // One to buffer, one to send. 30 sec buffering / sender.
  27. public static long LongestSleepTime = 1000 * TicksPerMs; // The longest time the sending thread should nap.
  28. public static int PlaybackBufferInterval = 10 * 1000 * TicksPerMs; // temporal length of buffer, in ms
  29. // intentionally equivelant to the time a recording buffer of medium-qual video
  30. public static int TicksSpent = 16 * TicksPerMs; // a debugging constant for displaying too much time spent
  31. public static int SenderCreationLeadTime = 500 * TicksPerMs; // time before a sender is needed that is created
  32. // remoting stuff
  33. public static int TCPListeningPort = 8082; // port that our remoting object listens on
  34. #region App.Config Overrides
  35. private const string baseName = "MSR.LST.ConferenceXP.ArchiveService.";
  36. /// <summary>
  37. /// This static constructor reads for every non-constant static field in the class and checks for an app.config override.
  38. /// </summary>
  39. static Constants()
  40. {
  41. Type myType = typeof(Constants);
  42. FieldInfo[] fields = myType.GetFields(BindingFlags.Public | BindingFlags.Static);
  43. foreach (FieldInfo field in fields)
  44. {
  45. if (field.IsLiteral) // Is Constant?
  46. continue; // We can't set it
  47. string fullName = baseName + field.Name;
  48. string configOverride = System.Configuration.ConfigurationManager.AppSettings[fullName];
  49. if (configOverride != null && configOverride != String.Empty)
  50. {
  51. Type newType = field.FieldType;
  52. object newValue = Convert.ChangeType(configOverride, newType);
  53. field.SetValue(null, newValue);
  54. }
  55. }
  56. }
  57. #endregion
  58. }
  59. }