Exemplo n.º 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);
     }
 }
Exemplo n.º 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.");
            }
        }
Exemplo n.º 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.");
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 6
0
 public override void PushUpChildren(ICoatingScheduleLogic upChild)
 {
     if (ChildrenLogic.Count > 0 && !ParentLogic.ChildIsTop(this))
     {
         ChildrenLogic.First().SwapUp();
     }
 }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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.");
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
 public override void PushDownChildren(ICoatingScheduleLogic upChild)
 {
     if (ChildrenLogic.Count > 0)
     {
         ChildrenLogic.Last().SwapDown();
     }
 }
Exemplo n.º 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();
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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();
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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();
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }