Exemple #1
0
 public override void AddLogic(ICoatingScheduleLogic newController = null) //update with a picker window. include a default.
 {
     try
     {
         if (newController != null)
         {
             newController.CoatingLine = CoatingLine;
         }
         else
         {
             newController = new CoatingScheduleProduct(0, "", "", "", "")
             {
                 CoatingLine = CoatingLine
             };
         }
         ChildrenLogic.Add(newController);
         newController.Connect(this);
         if (Control != null)
         {
             Control.AddControlToBottom(newController);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.Message);
     }
 }
Exemple #2
0
        public override void SwapChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent)
        {
            if (lastParent.GetType() == typeof(CoatingScheduleLine))
            {
                Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleLine)lastParent);

                if (indexOfParent > 0) // if not at the top
                {
                    lastParent.RemoveLogic(upChild);
                    ChildrenLogic[indexOfParent - 1].AddControlToBottom(upChild);
                }
                else if (indexOfParent == 0)
                {
                    ParentLogic.SwapChildUp(upChild, this);
                }
                else
                {
                    throw new Exception("Invoking object not a member of current object");
                }
            }
            else
            {
                throw new Exception("Call received by a non-child control.");
            }
        }
Exemple #3
0
 public override void AddControlToTop(ICoatingScheduleLogic newLogic)
 {
     ChildrenLogic.Insert(0, newLogic);
     newLogic.Connect(this);
     Control.AddControlToTop(newLogic);
     SpreadUnits();
 }
        public override void SwapChildDown(ICoatingScheduleLogic downChild, ICoatingScheduleLogic lastParent)
        {
            if (lastParent.GetType() == typeof(CoatingScheduleDay))
            {
                Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent);

                if (indexOfParent < ChildrenLogic.Count - 1) // if not at the bottom
                {
                    lastParent.RemoveLogic(downChild);
                    ChildrenLogic[indexOfParent + 1].AddControlToTop(downChild);
                }
                else if (indexOfParent == ChildrenLogic.Count - 1)
                {
                    //must add back the child
                    var day   = ChildrenLogic.Last();
                    var line  = day.ChildrenLogic.Last();
                    var shift = line.ChildrenLogic.First(x => x.CoatingLine == downChild.CoatingLine);
                    shift.AddControlToBottom(downChild);
                }
                else
                {
                    throw new Exception("Invoking object not a member of current object");
                }
            }
            else
            {
                throw new Exception("Call received by a non-child control.");
            }
        }
Exemple #5
0
        public override void AddControlToTop(ICoatingScheduleLogic newLogic)
        {
            if (newLogic.GetType() == typeof(CoatingScheduleShift))
            {
                CoatingScheduleShift newController = (CoatingScheduleShift)newLogic;

                bool foundLineMatch = false;
                for (Int32 index = 0; !foundLineMatch && index < ChildrenLogic.Count; index++)
                {
                    var shift = ChildrenLogic[index];
                    if (newController.CoatingLine == shift.CoatingLine)
                    {
                        foundLineMatch = true;
                        shift.AddControlToTop(newController);
                    }
                }
            }
            else if (ChildrenLogic.Count > 0)
            {
                var foundShift =
                    ChildrenLogic.FirstOrDefault(
                        shift => shift.CoatingLine == newLogic.CoatingLine);
                if (foundShift != null)
                {
                    foundShift.AddControlToTop(newLogic);
                }
            }
        }
Exemple #6
0
 public override void PushUpChildren(ICoatingScheduleLogic upChild)
 {
     if (ChildrenLogic.Count > 0 && !ParentLogic.ChildIsTop(this))
     {
         ChildrenLogic.First().SwapUp();
     }
 }
Exemple #7
0
 public override void AddLogic(ICoatingScheduleLogic newController = null)
 {
     if (newController == null)
     {
         foreach (string coatingLine in StaticFactoryValuesManager.CoatingLines)
         {
             CoatingScheduleShift newLogic = new CoatingScheduleShift();
             newLogic.CoatingLine = coatingLine;
             ChildrenLogic.Add(newLogic);
             newLogic.Connect(this);
             if (Control != null)
             {
                 Control.AddControlToBottom(newLogic);
             }
         }
     }
     else
     {
         ChildrenLogic.Add(newController);
         newController.Connect(this);
         if (Control != null)
         {
             Control.AddControlToBottom(newController);
         }
     }
 }
Exemple #8
0
        public override void AddControlToBottom(ICoatingScheduleLogic upChild)
        {
            if (upChild.GetType() == typeof(CoatingScheduleShift))
            {
                CoatingScheduleShift newController = (CoatingScheduleShift)upChild;

                bool foundLineMatch = false;
                for (Int32 index = 0; !foundLineMatch && index < ChildrenLogic.Count; index++)
                {
                    var shift = ChildrenLogic[index];
                    if (newController.CoatingLine == shift.CoatingLine)
                    {
                        foundLineMatch = true;
                        shift.AddControlToBottom(newController);
                    }
                }
            }
            else if (ChildrenLogic.Count > 0)
            {
                var foundShift =
                    ChildrenLogic.Last(
                        shift => shift.CoatingLine == upChild.CoatingLine);
                if (foundShift != null)
                {
                    foundShift.AddControlToBottom(upChild);
                }
            }
        }
        public override void SwapChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent)
        {
            if (lastParent.GetType() == typeof(CoatingScheduleDay))
            {
                Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent);

                if (indexOfParent > 0) // if not at the top
                {
                    lastParent.RemoveLogic(upChild);
                    ChildrenLogic[indexOfParent - 1].AddControlToBottom(upChild);
                }
                else if (indexOfParent == 0)
                {
                    //must add back the child
                    ICoatingScheduleLogic child  = ChildrenLogic[0];
                    ICoatingScheduleLogic child2 = child.ChildrenLogic[0];
                    ICoatingScheduleLogic child3 = child2.ChildrenLogic.First(x => x.CoatingLine == upChild.CoatingLine);
                    child3.AddLogic(upChild);
                }
                else
                {
                    throw new Exception("Invoking object not a member of current object");
                }
            }
            else
            {
                throw new Exception("Call received by a non-child control.");
            }
        }
Exemple #10
0
        public override void AddLogic(ICoatingScheduleLogic newController = null)
        {
            CoatingScheduleLine newLogic;

            if (newController != null)
            {
                newLogic = (CoatingScheduleLine)newController;
                newLogic.Connect(this);
                if (Control != null)
                {
                    Control.AddControlToBottom(newLogic);
                }
            }
            else
            {
                newLogic       = new CoatingScheduleLine();
                newLogic.Shift = GetNextShift();
                newLogic.Connect(this);
                if (Control != null)
                {
                    Control.AddControlToBottom(newLogic);
                }
                newLogic.AddLogic();
            }
            ChildrenLogic.Add(newLogic);
        }
Exemple #11
0
 public override void PushDownChildren(ICoatingScheduleLogic upChild)
 {
     if (ChildrenLogic.Count > 0)
     {
         ChildrenLogic.Last().SwapDown();
     }
 }
Exemple #12
0
        public override bool IsFull()
        {
            if (ChildrenLogic.Count < ShiftHandler.CoatingInstance.Shifts.Count)
            {
                return(false);
            }

            return(ChildrenLogic.All(logic => logic.IsFull()));
        }
 public override void DestroySelf()
 {
     for (Int32 index = 0; index < ChildrenLogic.Count; index++)
     {
         ChildrenLogic[index].Disconnect();
     }
     ChildrenLogic.Clear();
     Disconnect();
 }
Exemple #14
0
        public List <string> OpenLines()
        {
            List <string> lines = new List <string>();

            foreach (var source in ChildrenLogic.Where(l => !l.IsFull()))
            {
                lines.Add(source.CoatingLine);
            }
            return(lines);
        }
Exemple #15
0
 public override void PushUpChildren(ICoatingScheduleLogic upChild)
 {
     if (upChild.GetType() == typeof(CoatingScheduleProduct))
     {
         var shifts = ChildrenLogic.Where(x => x.CoatingLine == ((CoatingScheduleProduct)upChild).CoatingLine);
         foreach (var shift in shifts)
         {
             shift.PushUpChildren(upChild);
         }
     }
 }
        public DateTime GetNextDay()
        {
            if (ChildrenLogic.Count == 0) // if nothing to base off of, just start today
            {
                return(DateTime.Today);
            }

            DateTime nextDay = ChildrenLogic.Max(day => ((CoatingScheduleDay)day).Date);

            return(ShiftHandler.CoatingInstance.GetNextWorkingDay(nextDay));
        }
Exemple #17
0
 public override void DestroySelf()
 {
     for (Int32 index = 0; index < ChildrenLogic.Count; index++)
     {
         var product = ChildrenLogic[index];
         product.Disconnect();
     }
     ParentLogic.RemoveLogic(this);
     ChildrenLogic.Clear();
     Disconnect();
 }
Exemple #18
0
 public CoatingScheduleLine(List <CoatingScheduleShift> shifts)
 {
     foreach (CoatingScheduleShift shift in shifts)
     {
         ChildrenLogic.Add(shift);
         shift.Connect(this);
         if (Control != null)
         {
             Control.AddControlToBottom(shift);
         }
     }
 }
        public override void PushChildUp(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent)
        {
            if (lastParent.GetType() == typeof(CoatingScheduleDay))
            {
                Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent);

                for (Int32 i = indexOfParent; i >= 0; --i)
                {
                    ChildrenLogic[i].PushUpChildren(upChild);
                }
            }
        }
        public override void PushChildDown(ICoatingScheduleLogic upChild, ICoatingScheduleLogic lastParent)
        {
            if (lastParent.GetType() == typeof(CoatingScheduleDay))
            {
                Int32 indexOfParent = ChildrenLogic.IndexOf((CoatingScheduleDay)lastParent);
                Int32 dayCount      = ChildrenLogic.Count;

                for (Int32 i = dayCount - 1; i >= indexOfParent; --i)
                {
                    ChildrenLogic[i].PushDownChildren(upChild);
                }
            }
        }
        public override bool ChildIsTop(ICoatingScheduleLogic child)
        {
            bool isTop = false;

            if (child.GetType() == typeof(CoatingScheduleDay) && ChildrenLogic.Count > 0)
            {
                isTop = ChildrenLogic.First() == (CoatingScheduleDay)child;
            }
            else
            {
                throw new Exception("Child not contained within class.");
            }
            return(isTop);
        }
Exemple #22
0
        public double UnitsConsumed(ProductMasterItem item)
        {
            double consumed = 0;

            foreach (var coatingScheduleLogic in ChildrenLogic.Where(l => l is CoatingScheduleProduct))
            {
                var product = ((CoatingScheduleProduct)coatingScheduleLogic);
                var config  = product.Config;

                consumed += config.GetUnitsConsumed(item, product.Units, product.MasterID);
            }

            return(consumed);
        }
Exemple #23
0
        public override bool ChildIsTop(ICoatingScheduleLogic child)
        {
            bool isTop = false;

            if (ChildrenLogic.Count > 0)
            {
                isTop = ChildrenLogic.First() == child;
                if (isTop)
                {
                    isTop = ParentLogic.ChildIsTop(this);
                }
            }
            return(isTop);
        }
Exemple #24
0
 public override void RemoveLogic(ICoatingScheduleLogic child)
 {
     if (child.GetType() == typeof(CoatingScheduleLine))
     {
         ChildrenLogic.Remove((CoatingScheduleLine)child);
         Control.RemoveControl(child.Control);
     }
     else
     {
         foreach (var logic in ChildrenLogic)
         {
             logic.RemoveLogic(child);
         }
     }
 }
Exemple #25
0
 public override void AddControlToBottom(ICoatingScheduleLogic upChild)
 {
     if (upChild.GetType() == typeof(CoatingScheduleLine)) // if child type, add to list
     {
         AddLogic(upChild);
     }
     else if (ChildrenLogic.Count > 0) // if not child type, but this logic has children, try to have them add
     {
         ChildrenLogic.Last().AddControlToBottom(upChild);
     }
     else // if no children, create one and add new control to bottom
     {
         AddLogic();
         ChildrenLogic[0].AddControlToBottom(upChild);
     }
 }
Exemple #26
0
        public bool HasChild(ICoatingScheduleLogic child)
        {
            if (ChildrenLogic.Contains(child))
            {
                return(true);
            }

            bool childFound = false;

            for (Int32 index = 0; !childFound && index < ChildrenLogic.Count; index++)
            {
                var childLogic = ChildrenLogic[index];
                childFound = childLogic.HasChild(child);
            }
            return(childFound);
        }
Exemple #27
0
        public override void AddControlToTop(ICoatingScheduleLogic newController)
        {
            CoatingScheduleLine newLogic;

            if (newController != null)
            {
                if (newController.GetType() == typeof(CoatingScheduleLine))
                {
                    newLogic = (CoatingScheduleLine)newController;

                    newLogic.Shift = GetNextShift();
                    ChildrenLogic.Add(newLogic);
                    newLogic.Connect(this);
                    Control.AddControlToTop(newLogic);
                    newLogic.AddLogic();
                }
                else if (ChildrenLogic.Count > 0)
                {
                    ChildrenLogic[0].AddControlToTop(newController);
                }
                else
                {
                    newLogic = new CoatingScheduleLine();

                    newLogic.Date  = Date;
                    newLogic.Shift = GetNextShift();
                    ChildrenLogic.Add(newLogic);
                    newLogic.Connect(this);
                    Control.AddControlToTop(newLogic);
                    newLogic.AddLogic();

                    newLogic.AddControlToTop(newController);
                }
            }
            else
            {
                newLogic = new CoatingScheduleLine();

                newLogic.Date  = Date;
                newLogic.Shift = GetNextShift();
                ChildrenLogic.Add(newLogic);
                newLogic.Connect(this);
                Control.AddControlToTop(newLogic);
                newLogic.AddLogic();
            }
        }
 public override void AddControlToTop(ICoatingScheduleLogic newLogic)
 {
     if (newLogic.GetType() == typeof(CoatingScheduleDay))  // if child type, add to list
     {
         AddControlToTop(newLogic);
     }
     else if (ChildrenLogic.Count > 0) // if not child type, but this logic has children, try to have them add
     {
         ChildrenLogic.Last().AddControlToTop(newLogic);
     }
     else // if no children, create one and add new control to bottom
     {
         AddLogic();
         ChildrenLogic[0].AddControlToTop(newLogic);
     }
     UpdateDateText();
 }
Exemple #29
0
        public override bool ChildIsTop(ICoatingScheduleLogic child)
        {
            bool isTop = false;

            if (child.GetType() == typeof(CoatingScheduleLine) && ChildrenLogic.Count > 0)
            {
                isTop = ChildrenLogic.First() == (CoatingScheduleLine)child;
                if (isTop)
                {
                    isTop = ParentLogic.ChildIsTop(this);
                }
            }
            else
            {
                throw new Exception("Child is not contained in this class.");
            }
            return(isTop);
        }
Exemple #30
0
        public double UnitsProduced(ProductMasterItem item)
        {
            double produced = 0;

            foreach (var coatingScheduleLogic in ChildrenLogic.Where(l => l is CoatingScheduleProduct))
            {
                var product = ((CoatingScheduleProduct)coatingScheduleLogic);

                if (product.MasterID == item.MasterID)
                {
                    double temp = 0;
                    Double.TryParse(product.Units, out temp);
                    produced += temp;
                }
            }

            return(produced);
        }