namespace Comal.Classes { } //public class CalendarBooking : BaseObject, IPackable // { // public Guid Packet { get; set; } // public Guid Station { get; set; } // public DateTime Start { get; set; } // public DateTime End { get; set; } // public Boolean IsShared { get; set; } // public void Pack(FastBinaryWriter writer) // { // writer.Write(Packet.ToByteArray()); // writer.Write(Station.ToByteArray()); // writer.Write(Start.ToBinary()); // writer.Write(End.ToBinary()); // writer.Write(IsShared); // } // public void Unpack(FastBinaryReader reader) // { // Packet = new Guid(reader.ReadBytes(16)); // Station = new Guid(reader.ReadBytes(16)); // Start = DateTime.FromBinary(reader.ReadInt64()); // End = DateTime.FromBinary(reader.ReadInt64()); // IsShared = reader.ReadBoolean(); // } // } // [UserTracking(false)] //public class Calendar : Entity, IPersistent, IRemotable, ILicense //{ // public String Summary { get; set; } // public PackableList Bookings { get; set; } // public bool IsActive { get; set; } // protected override void Init() // { // Summary = ""; // Bookings = new PackableList(); // IsActive = true; // } // public void Build(ManufacturingPacket[] packets) // { // this.Bookings.Clear(); // //Progress.Show("Recalculating Manufacturing Calendar"); // var config = new GlobalConfiguration(); // FactorySetup settings = config.Load(); // if (settings.Sections.Count == 0) // return; // CalendarFactory factory = new CalendarFactory(); // foreach (FactorySection section in settings.Sections) // factory.Sections.Add(new Section(section.Name, section.ID, section.Stations)); // //Progress.SetMessage("Loading Manufacturing Packets"); // //var packets = new Client().Load(new Filter(x => x.Issued).IsNotEqualTo(DateTime.MinValue).And(x => x.IsComplete).IsEqualTo(false), new SortOrder(x => x.DueDate)); // //Progress.SetMessage("Calculating"); // foreach (ManufacturingPacket packet in packets) // { // List steps = new List(); // //foreach (SetoutStage stage in packet.Stages) // //{ // // if (stage.Completed.IsEmpty()) // // steps.Add(new Step(stage.SectionID, stage.Minutes * packet.Quantity, stage.Sequence)); // //} // if (steps.Count > 0) // { // factory.Widgets.Add( // new Widget(packet.ID, packet.SetoutLink.Description, packet.SetoutLink.JobLink.Name, packet.Serial, packet.DueDate, steps.ToArray()) // ); // } // } // StringBuilder summary = new StringBuilder(); // factory.ProcessWidgets(DateTime.Today.AddHours(7), summary); // this.Summary = summary.ToString(); // //Comal.Classes.Calendar calendar = new Comal.Classes.Calendar() // //{ // // IsActive = true, // // Summary = summary.ToString() // //}; // Dictionary dates = new Dictionary(); // foreach (Section section in factory.Sections) // { // foreach (Station station in section.Stations) // { // List bookings = station.Bookings.OrderBy(x => x.Start).ToList(); // foreach (Booking booking in bookings) // { // if (!dates.ContainsKey(booking.Widget.PacketID)) // dates[booking.Widget.PacketID] = DateTime.MinValue; // if (dates[booking.Widget.PacketID].CompareTo(booking.End) < 0) // dates[booking.Widget.PacketID] = booking.End; // CalendarBooking calendarbooking = new CalendarBooking() // { // Start = booking.Start, // End = booking.End, // Packet = booking.Widget.PacketID, // Station = station.ID, // IsShared = booking.Shared // }; // this.Bookings.Add(calendarbooking); // } // } // } // // Need to move this into CalendarStore.. ManufacturingPacketForecast is not remotable.. // //var fstore = new Client(); // //foreach (Guid setoutid in dates.Keys) // //{ // // ManufacturingPacket packet = packets.Where(x => x.ID.Equals(setoutid)).FirstOrDefault(); // // if (packet != null) // // { // // ManufacturingPacketForecast forecast = packet.Forecast; // // if (forecast != null) // // { // // if (forecast.ManufacturingDate.CompareTo(dates[setoutid]) != 0) // // { // // forecast.ManufacturingDate = dates[setoutid]; // // fstore.Save(ref forecast, "Updated because of change to Manufacturing Packet"); // // } // // } // // } // //} // //Progress.SetMessage("Saving Updated Calendar"); // //new Client().Save(ref calendar, "Updated because of changed Manufacturing Packet"); // //Progress.Close(); // } // }