/// <summary>
        /// get  part storage
        /// </summary>
        /// <param name="warehouseNR"></param>
        /// <param name="positionNR"></param>
        /// <param name="partNR"></param>
        /// <returns></returns>
        public PartStorage GetPartStorage(string warehouseNR, DateTime date, string positionNR, string partNR)
        {
            PartStorage partStorage = context.Position
                                      .Single(p => p.WarehouseNR.Equals(warehouseNR) && p.PositionNR.Equals(positionNR))
                                      .PartStorage.Where(ps => ps.PartNR.Equals(partNR) && ps.FIFO.Equals(date)).Take(1).Single();

            //List<PartStorage> partStorage = context.Position.Single(p => p.WarehouseNR.Equals(warehouseNR) && p.PositionNR.Equals(positionNR)).PartStorage.ToList();

            return(partStorage);
        }
Пример #2
0
        /// <summary>
        /// Processes a section part for all given start times.
        /// </summary>
        /// <param name="sectionPart">The Part storage to process</param>
        /// <param name="startTimes">The start times to process against. The result is again all start times passed</param>
        /// <returns>The list of DateTime entries calculated. This list is at least as big as the number of start times provided</returns>
        private List <DateTime> ProcessSectionPart(PartStorage sectionPart, IEnumerable <DateTime> startTimes)
        {
            List <DateTime> result = new List <DateTime>();
            bool            add    = !sectionPart.Value.StartsWith("-");

            string[] parts;
            if (sectionPart.Value.Contains("*"))
            {
                parts = sectionPart.Value.Split(new char[] { '*' });
            }
            else
            {
                parts = new string[] { sectionPart.Value };
            }

            int repeatCount = parts.Length == 2 ? int.Parse(parts[1]) : 1;

            foreach (DateTime start in startTimes)
            {
                for (int i = 0; i < repeatCount; i++)
                {
                    string valueString = parts[0].StartsWith("-") || parts[0].StartsWith("+") ? parts[0].Substring(1, parts[0].Length - 2) : parts[0].Substring(0, parts[0].Length - 2);
                    int    value       = add ? int.Parse(valueString) : 0 - int.Parse(valueString);
                    value = value * (i + 1);
                    switch (sectionPart.Type)
                    {
                    case PartType.Year:
                        result.Add(start.AddYears(value));
                        break;

                    case PartType.Month:
                        result.Add(start.AddMonths(value));
                        break;

                    case PartType.Week:
                        result.Add(start.AddDays(value * 7));
                        break;

                    case PartType.Day:
                        result.Add(start.AddDays(value));
                        break;
                    }
                }
            }

            return(result);
        }
Пример #3
0
        /*
         * {
         +1m +2d +2m +2d
         +2w +3d
         +3m +1m
         +3m*2
         * }";
         */

        /// <summary>
        /// Calculates the Date for the given PartStorage
        /// If it is a full date that is being parsed and returned
        /// If it is an Injection, it is found in the list of injections
        /// </summary>
        /// <param name="sectionPart">The PartStorage to process</param>
        /// <returns>A datetime if found, null otherwise</returns>
        private IEnumerable <DateTime> ProcessSectionPart(PartStorage sectionPart)
        {
            switch (sectionPart.Type)
            {
            case PartType.FullDate:
                return(new DateTime[] { DateTime.Parse(sectionPart.Value) });

            case PartType.Injection:
                if (this.Injections.ContainsKey(sectionPart.Injection))
                {
                    if (sectionPart.Indexes.Count > 0)
                    {
                        DateTime[]      data   = this.Injections[sectionPart.Injection].ToArray();
                        List <DateTime> result = new List <DateTime>();
                        foreach (int index in sectionPart.Indexes)
                        {
                            if (index < data.Length)
                            {
                                result.Add(data[index]);
                            }
                        }

                        return(result);
                    }
                    else
                    {
                        return(this.Injections[sectionPart.Injection]);
                    }
                }

                return(null);

            default:
                return(null);
            }
        }
 /// <summary>
 /// delete part storage
 /// </summary>
 /// <param name="partStorage"></param>
 public void Delete(PartStorage partStorage)
 {
     context.PartStorage.DeleteOnSubmit(partStorage);
 }
 /// <summary>
 /// add one uniqStorage
 /// </summary>
 /// <param name="uniqStorage">the instance of uniqStorage</param>
 public void Add(PartStorage uniqStorage)
 {
     context.PartStorage.InsertOnSubmit(uniqStorage);
 }
Пример #6
0
        /// <summary>
        /// Processes the current line with the start date being the given date
        /// </summary>
        /// <param name="line">The line being processed</param>
        /// <param name="start">The start date to use for calculations</param>
        /// <returns>An array with all DateTime entries calculated</returns>
        private DateTime[] ProcessLine(string line, DateTime start)
        {
            // Find order to devide in sections
            string[]             parts    = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            List <PartStorage[]> sections = new List <PartStorage[]>();

            // Order of importants:
            // Not used anymore

            /*
             * Y = 4
             * M = 3
             * W = 2
             * D = 1
             */

            // First generate sections for the current line
            // List<PartStorage> CurrentSection = new List<PartStorage>();
            foreach (string p in parts)
            {
                PartStorage ps = this.DeterminePart(p);
                sections.Add(new PartStorage[] { ps });

                /*if (CurrentSection.Count > 0 && CurrentSection[CurrentSection.Count - 1].Type <= ps.Type)
                 * {
                 *  sections.Add(CurrentSection.ToArray());
                 *  CurrentSection.Clear();
                 * }
                 *
                 * CurrentSection.Add(ps);
                 */
            }

            // if (CurrentSection.Count > 0) sections.Add(CurrentSection.ToArray());
            // CurrentSection.Clear();

            // Process each section to see if we can find a date
            List <DateTime>        results    = new List <DateTime>();
            IEnumerable <DateTime> startDates = new DateTime[] { start };

            foreach (PartStorage[] section in sections)
            {
                List <DateTime> internalResult = new List <DateTime>();
                foreach (PartStorage part in section)
                {
                    if (part.Type == PartType.Injection)
                    {
                        var d = this.ProcessSectionPart(part);
                        if (d == null || d.Count() == 0)
                        {
                            return(null);
                        }
                        if (sections.Count == 1)
                        {
                            results.AddRange(d);
                        }
                        else
                        {
                            startDates = d;
                        }
                    }
                    else if (part.Type == PartType.FullDate)
                    {
                        var d = this.ProcessSectionPart(part);
                        if (sections.Count > 1 && d.Count() > 0)
                        {
                            startDates = d;
                        }
                        else
                        {
                            results.AddRange(d);
                        }
                    }
                    else
                    {
                        if (internalResult.Count == 0)
                        {
                            internalResult = this.ProcessSectionPart(part, startDates);
                        }
                        else
                        {
                            internalResult = this.ProcessSectionPart(part, internalResult);
                        }
                    }
                }

                results.AddRange(internalResult);
            }

            results.Sort();

            return(results.ToArray());
        }
 /// <summary>
 /// delete part storage
 /// </summary>
 /// <param name="partStorage"></param>
 public void Delete(PartStorage partStorage)
 {
     context.PartStorage.DeleteOnSubmit(partStorage);
 }
 /// <summary>
 /// add one uniqStorage
 /// </summary>
 /// <param name="uniqStorage">the instance of uniqStorage</param>
 public void Add(PartStorage uniqStorage)
 {
     context.PartStorage.InsertOnSubmit(uniqStorage);
 }