Calendar.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. namespace Comal.Classes
  2. {
  3. }
  4. //public class CalendarBooking : BaseObject, IPackable
  5. // {
  6. // public Guid Packet { get; set; }
  7. // public Guid Station { get; set; }
  8. // public DateTime Start { get; set; }
  9. // public DateTime End { get; set; }
  10. // public Boolean IsShared { get; set; }
  11. // public void Pack(FastBinaryWriter writer)
  12. // {
  13. // writer.Write(Packet.ToByteArray());
  14. // writer.Write(Station.ToByteArray());
  15. // writer.Write(Start.ToBinary());
  16. // writer.Write(End.ToBinary());
  17. // writer.Write(IsShared);
  18. // }
  19. // public void Unpack(FastBinaryReader reader)
  20. // {
  21. // Packet = new Guid(reader.ReadBytes(16));
  22. // Station = new Guid(reader.ReadBytes(16));
  23. // Start = DateTime.FromBinary(reader.ReadInt64());
  24. // End = DateTime.FromBinary(reader.ReadInt64());
  25. // IsShared = reader.ReadBoolean();
  26. // }
  27. // }
  28. // [UserTracking(false)]
  29. //public class Calendar : Entity, IPersistent, IRemotable, ILicense<ManufacturingLicense>
  30. //{
  31. // public String Summary { get; set; }
  32. // public PackableList<CalendarBooking> Bookings { get; set; }
  33. // public bool IsActive { get; set; }
  34. // protected override void Init()
  35. // {
  36. // Summary = "";
  37. // Bookings = new PackableList<CalendarBooking>();
  38. // IsActive = true;
  39. // }
  40. // public void Build(ManufacturingPacket[] packets)
  41. // {
  42. // this.Bookings.Clear();
  43. // //Progress.Show("Recalculating Manufacturing Calendar");
  44. // var config = new GlobalConfiguration<FactorySetup>();
  45. // FactorySetup settings = config.Load();
  46. // if (settings.Sections.Count == 0)
  47. // return;
  48. // CalendarFactory factory = new CalendarFactory();
  49. // foreach (FactorySection section in settings.Sections)
  50. // factory.Sections.Add(new Section(section.Name, section.ID, section.Stations));
  51. // //Progress.SetMessage("Loading Manufacturing Packets");
  52. // //var packets = new Client<ManufacturingPacket>().Load(new Filter<ManufacturingPacket>(x => x.Issued).IsNotEqualTo(DateTime.MinValue).And(x => x.IsComplete).IsEqualTo(false), new SortOrder<ManufacturingPacket>(x => x.DueDate));
  53. // //Progress.SetMessage("Calculating");
  54. // foreach (ManufacturingPacket packet in packets)
  55. // {
  56. // List<Step> steps = new List<Step>();
  57. // //foreach (SetoutStage stage in packet.Stages)
  58. // //{
  59. // // if (stage.Completed.IsEmpty())
  60. // // steps.Add(new Step(stage.SectionID, stage.Minutes * packet.Quantity, stage.Sequence));
  61. // //}
  62. // if (steps.Count > 0)
  63. // {
  64. // factory.Widgets.Add(
  65. // new Widget(packet.ID, packet.SetoutLink.Description, packet.SetoutLink.JobLink.Name, packet.Serial, packet.DueDate, steps.ToArray())
  66. // );
  67. // }
  68. // }
  69. // StringBuilder summary = new StringBuilder();
  70. // factory.ProcessWidgets(DateTime.Today.AddHours(7), summary);
  71. // this.Summary = summary.ToString();
  72. // //Comal.Classes.Calendar calendar = new Comal.Classes.Calendar()
  73. // //{
  74. // // IsActive = true,
  75. // // Summary = summary.ToString()
  76. // //};
  77. // Dictionary<Guid, DateTime> dates = new Dictionary<Guid, DateTime>();
  78. // foreach (Section section in factory.Sections)
  79. // {
  80. // foreach (Station station in section.Stations)
  81. // {
  82. // List<Booking> bookings = station.Bookings.OrderBy(x => x.Start).ToList();
  83. // foreach (Booking booking in bookings)
  84. // {
  85. // if (!dates.ContainsKey(booking.Widget.PacketID))
  86. // dates[booking.Widget.PacketID] = DateTime.MinValue;
  87. // if (dates[booking.Widget.PacketID].CompareTo(booking.End) < 0)
  88. // dates[booking.Widget.PacketID] = booking.End;
  89. // CalendarBooking calendarbooking = new CalendarBooking()
  90. // {
  91. // Start = booking.Start,
  92. // End = booking.End,
  93. // Packet = booking.Widget.PacketID,
  94. // Station = station.ID,
  95. // IsShared = booking.Shared
  96. // };
  97. // this.Bookings.Add(calendarbooking);
  98. // }
  99. // }
  100. // }
  101. // // Need to move this into CalendarStore.. ManufacturingPacketForecast is not remotable..
  102. // //var fstore = new Client<ManufacturingPacketForecast>();
  103. // //foreach (Guid setoutid in dates.Keys)
  104. // //{
  105. // // ManufacturingPacket packet = packets.Where(x => x.ID.Equals(setoutid)).FirstOrDefault();
  106. // // if (packet != null)
  107. // // {
  108. // // ManufacturingPacketForecast forecast = packet.Forecast;
  109. // // if (forecast != null)
  110. // // {
  111. // // if (forecast.ManufacturingDate.CompareTo(dates[setoutid]) != 0)
  112. // // {
  113. // // forecast.ManufacturingDate = dates[setoutid];
  114. // // fstore.Save(ref forecast, "Updated because of change to Manufacturing Packet");
  115. // // }
  116. // // }
  117. // // }
  118. // //}
  119. // //Progress.SetMessage("Saving Updated Calendar");
  120. // //new Client<Comal.Classes.Calendar>().Save(ref calendar, "Updated because of changed Manufacturing Packet");
  121. // //Progress.Close();
  122. // }
  123. // }