コード例 #1
0
 public static void LinkCategory()
 {
     using (var DWdb = new DWModel())
     {
         using (var db = new SSRS())
         {
             foreach (var timeoption in DWdb.Timing_Option.ToList())
             {
                 var prodTD = db.ProdTBs.Where(r => r.Code == timeoption.Fixture.Code &&
                                               r.WorkCenter == timeoption.Timing_WorkStations.Name).FirstOrDefault();
                 foreach (var item in prodTD.OptionTBs)
                 {
                     foreach (var param in item.ParametersTBs)
                     {
                         var cat = DWdb.Categories.Where(r => r.Name == param.ParamName).FirstOrDefault();
                         if (cat != null)
                         {
                             Console.WriteLine(cat.Name);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        public static void addSizeTimeOption(string fixtureCode)
        {
            List <string> SizeParams = new List <string>()
            {
                "11", "12", "14", "22", "24", "26", "315", "33", "35", "44"
            };

            using (var db = new DWModel())
            {
                var fixture  = db.Fixtures.Where(r => r.Code == fixtureCode).FirstOrDefault();
                var category = db.Categories.Where(r => r.id == SizeID).FirstOrDefault();
                //category.Footnote = " ";

                foreach (var wks in db.Timing_WorkStations.ToList())
                {
                    var paramList = (from fx in db.Fixtures
                                     join fica in db.CategoryAtFixtures on fx.id equals fica.FixtureId
                                     join cat in db.Categories on fica.CategoryId equals cat.id
                                     join paca in db.ParameterAtCategoryAtFixtures on fica.id equals paca.CategoryAtFixtureId
                                     join param in db.Parameters on paca.ParameterId equals param.id
                                     where fx.Code == fixtureCode && cat.id == SizeID && SizeParams.Contains(param.Code)
                                     select param).ToList();
                    foreach (var param in paramList)
                    {
                        var newoption = addTimeOptionCustom(fixture, category, param, wks, "Standard", 1);
                        OptionList.Add(newoption);
                        db.Timing_Option.Add(newoption);
                        db.SaveChanges();
                    }
                }
            }
        }
コード例 #3
0
        public static void LinkParams()
        {
            using (var DWdb = new DWModel())
            {
                using (var db = new SSRS())
                {
                    foreach (var timeoption in DWdb.Timing_Option.ToList())
                    {
                        var prodTD = db.ProdTBs.Where(r => r.Code == timeoption.Fixture.Code &&
                                                      r.WorkCenter == timeoption.Timing_WorkStations.Name).FirstOrDefault();
                        foreach (var item in prodTD.OptionTBs)
                        {
                            foreach (var param in item.ParametersTBs)
                            {
                                var fixture  = timeoption.Fixture;
                                var category = fixture.CategoryAtFixtures.Where(r => r.Category.Name == param.ParamName).FirstOrDefault();
                                if (category != null)
                                {
                                    var parameter = category.ParameterAtCategoryAtFixtures.Where(r => r.Parameter.Code == param.ParamValue).FirstOrDefault();

                                    if (parameter != null)
                                    {
                                        //Console.WriteLine("OK");
                                        timeoption.Parameters.Add(parameter.Parameter);
                                        //DWdb.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public static void addWorkstations()
        {
            using (var db = new SSRS())
            {
                //var wks = db.ProdTBs.ToList();
                var wks = db.ProdTBs.Select(x => new { x.WorkCenter, x.OpCode }).Distinct().ToList();


                foreach (var item in wks)
                {
                    if (item.OpCode != null)
                    {
                        var wk = new Timing_WorkStations()
                        {
                            Name = item.WorkCenter,

                            OpCode = item.OpCode
                        };

                        using (var DWdb = new DWModel())
                        {
                            DWdb.Timing_WorkStations.Add(wk);
                            DWdb.SaveChanges();
                        }
                    }
                }
            }
        }
コード例 #5
0
        public static void addLengthTimeOption(string fixtureCode)
        {
            using (var db = new DWModel())
            {
                var           fixture      = db.Fixtures.Where(r => r.Code == fixtureCode).FirstOrDefault();
                var           category     = db.Categories.Where(r => r.id == LengthID).FirstOrDefault();
                List <string> LengthParams = new List <string>()
                {
                    "4", "8", "12"
                };

                foreach (var wks in db.Timing_WorkStations.ToList())
                {
                    var paramlist = (from fx in db.Fixtures
                                     join fica in db.CategoryAtFixtures on fx.id equals fica.FixtureId
                                     join cat in db.Categories on fica.CategoryId equals cat.id
                                     join paca in db.ParameterAtCategoryAtFixtures on fica.id equals paca.CategoryAtFixtureId
                                     join param in db.Parameters on paca.ParameterId equals param.id
                                     where fx.Code == fixtureCode && cat.id == LengthID && LengthParams.Contains(param.Code)
                                     select param).ToList();
                    foreach (var param in paramlist)
                    {
                        var newoption = addTimeOptionCustom(fixture, category, param, wks, "Standard", 1);
                        OptionList.Add(newoption);

                        db.Timing_Option.Add(newoption);
                        db.SaveChanges();
                    }
                }
            }
        }
コード例 #6
0
 public static List <Timing_Option> GetTiming_Options()
 {
     using (var db = new DWModel())
     {
         return(db.Timing_Option.ToList());
     }
 }
コード例 #7
0
        public static void UploadStandardTime()
        {
            List <string> listA = new List <string>();

            using (var reader = new StreamReader(@"C:\Users\dangl\source\repos\MigrateToDW\TimeCalculator\ProductEpicor.csv"))
            {
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(';');
                    listA.Add(values[0]);
                }
            }


            OptionList = new List <Timing_Option>();
            using (var db = new DWModel())
            {
                foreach (var fixture in db.Fixtures.ToList())
                {
                    if (listA.Contains(fixture.Code))
                    {
                        Console.WriteLine(fixture.Code);
                        if (Utilities.getLengthParams(fixture.Code).Count > 0)
                        {
                            Utilities.addLengthTimeOption(fixture.Code);
                        }
                        else if (Utilities.getSizeParams(fixture.Code).Count > 0)
                        {
                            Utilities.addSizeTimeOption(fixture.Code);
                        }
                        else
                        {
                            Console.WriteLine("{0} does not have size or legnth param", fixture.Code);
                        }
                    }
                }
            }

            //before your loop
            var csv = new StringBuilder();

            csv.AppendLine("FamilyName,Fixture, WorkStation, Length, Time");
            foreach (var item in OptionList)
            {
                if (listA.Contains(item.Fixture.Code))
                {
                    var newLine = string.Format("{0},{1},{2},{3}", item.Fixture.FamilyName, item.Fixture.Code,
                                                item.Timing_WorkStations.Name, item.Parameters.FirstOrDefault().Description);
                    csv.AppendLine(newLine);
                }
            }
            string filepath = @"C:\Users\dangl\source\repos\MigrateToDW\TimeCalculator\Input.csv";

            File.WriteAllText(filepath, csv.ToString());
        }
コード例 #8
0
        public static void updateTime()
        {
            using (var db = new DWModel())
            {
                var inputfile = new List <string>()
                {
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\Copy of Final Packaging.csv",
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\SawExt.csv",
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\Time _welding.csv",
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\TimeLenses.csv",
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\DANG Time _ wire cutV2.csv",
                    @"C:\Users\dangl\source\repos\MigrateToDW\MigrateToDW1\Claudine's Time\DANG Time _ punch.csv"
                };

                foreach (var item in inputfile)
                {
                    using (var reader = new StreamReader(item))
                    {
                        while (!reader.EndOfStream)
                        {
                            decimal num      = 0;
                            bool    isDouble = false;
                            var     line     = reader.ReadLine();
                            var     values   = line.Split(',');
                            try
                            {
                                isDouble = decimal.TryParse(values[4], out num);
                                var productID   = values[1];
                                var lengthDesc  = values[3];
                                var workstation = values[2];
                                if (isDouble)
                                {
                                    var option = db.Timing_Option.Where(r => r.Fixture.Code == productID &&
                                                                        r.Name == "Standard" &&
                                                                        r.Parameters.Any(t => t.Description == lengthDesc) &&
                                                                        r.Timing_WorkStations.Name == workstation).FirstOrDefault();

                                    option.Time = num;
                                    var cat = option.Parameters.FirstOrDefault().ParameterAtCategoryAtFixtures.FirstOrDefault().CategoryAtFixture.Category;
                                    option.Categories.Clear();
                                    option.Categories.Add(cat);
                                    db.SaveChanges();
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                                continue;
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
 private void getSectionTime(string size)
 {
     using (var db = new DWModel(true))
     {
         var SectionTime = db.Fixtures.Where(r => r.id == productID &&
                                             r.Timing_Option.Any(q => q.Name == "Standard")
                                             ).Select(r => r.Timing_Option.Where(z => z.Parameters.Any(k => k.Description == size))
                                                      .ToList()).FirstOrDefault()
                           .ToDictionary(o => o.Timing_WorkStations.OpCode, o => o.Time);
         ProductionTimeERP = ProductionTimeERP == null ? SectionTime : ProductionTimeERP.Concat(SectionTime).GroupBy(x => x.Key).ToDictionary(x => x.Key, x => x.Sum(y => y.Value));
         SectionResults.Add(new section()
         {
             size = size, result = ProductionTimeERP
         });
     }
 }
コード例 #10
0
        void getStandardTime(List <string> Parameters)
        {
            Dictionary <string, decimal> SectionTime = new Dictionary <string, decimal>();

            using (var db = new DWModel())
            {
                var optionList = (db.Fixtures.Where(r => r.id == productID).Select(r => r.Timing_Option).ToList()).FirstOrDefault();
                foreach (var item in optionList.AsEnumerable())
                {
                    var paramValue = item.Parameters.Select(r => r.Description).ToList();
                    if (Parameters.All(paramValue.Contains))
                    {
                        SectionTime.Add(item.Timing_WorkStations.OpCode, item.Time);
                    }
                }
            }
            updateTime(SectionTime);
            ProductionTimeERP = ProductionTimeERP == null ? SectionTime : ProductionTimeERP.Concat(SectionTime).GroupBy(x => x.Key).ToDictionary(x => x.Key, x => x.Sum(y => y.Value));
        }
コード例 #11
0
        public static void addTimeOption()
        {
            HashSet <Timing_Option> globalopts = new HashSet <Timing_Option>();

            List <Fixture> fixtures = new List <Fixture>();

            using (var DWdb = new DWModel())
            {
                using (var db = new SSRS())
                {
                    var prod = db.ProdTBs.ToList();
                    foreach (var item in prod)
                    {
                        foreach (var opt in item.OptionTBs)
                        {
                            var fixture     = DWdb.Fixtures.Where(r => r.Code == item.Code).FirstOrDefault();
                            var workstation = DWdb.Timing_WorkStations.Where(r => r.Name == item.WorkCenter).FirstOrDefault();
                            if (fixture != null && workstation != null)
                            {
                                var optnew = new Timing_Option()
                                {
                                    Name    = opt.OptionName,
                                    Time    = (decimal)opt.ProdTime,
                                    Fixture = fixture,

                                    Timing_WorkStations = workstation
                                };
                                //DWdb.Timing_Option.Add(optnew);
                                //DWdb.SaveChanges();
                                globalopts.Add(optnew);
                            }
                        }
                    }
                }

                foreach (var item in globalopts)
                {
                    DWdb.Timing_Option.Add(item);
                    DWdb.SaveChanges();
                }
            }
        }
コード例 #12
0
        public static List <Parameter> getSizeParams(string fixtureCode)
        {
            List <Parameter> list       = new List <Parameter>();
            List <string>    SizeParams = new List <string>()
            {
                "11", "12", "14", "22", "24", "26", "315", "33", "35", "44"
            };

            using (var db = new DWModel())
            {
                list = (from fx in db.Fixtures
                        join fica in db.CategoryAtFixtures on fx.id equals fica.FixtureId
                        join cat in db.Categories on fica.CategoryId equals cat.id
                        join paca in db.ParameterAtCategoryAtFixtures on fica.id equals paca.CategoryAtFixtureId
                        join param in db.Parameters on paca.ParameterId equals param.id
                        where fx.Code == fixtureCode && cat.id == SizeID && SizeParams.Contains(param.Code)
                        select param).ToList();
            }
            return(list);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            //Utilities.updateTime();

            //Utilities.UploadStandardTime();

            string lineDesc = "BBRLED-1000-80-35-RG-35'-W-UNV-DP-1-DF";

            lineDesc = "SKPLED-22-4000-80-35-0.5-W-UNV-DP-1-TB9";
            string DWConnectiontring = "metadata = res://*/DBConnection.csdl|res://*/DBConnection.ssdl|res://*/DBConnection.msl;provider=System.Data.SqlClient;provider connection string='Data Source=VAULT\\DRIVEWORKS;Initial Catalog=\"AXIS Automation\";Integrated Security=True;MultipleActiveResultSets=True'";

            using (AXISAutomation.Tools.DBConnection.AXIS_AutomationEntities _AutomationEntities = new AXISAutomation.Tools.DBConnection.AXIS_AutomationEntities(DWConnectiontring))
            {
                _Fixture fixture = new AXISAutomation.FixtureConfiguration._Fixture(lineDesc, _AutomationEntities);

                fixture.SPM.ConfigureAll();
                var Time = new TimeCalculator(fixture, 4);
            }

            using (var db = new DWModel())
            {
                //string codeid = "BBRLED";
                //string optionName = "Standard";
                //string workStation = "Cutting Extrusion";
                //string CategoryName = "Length";
                //string parameter = "8";

                //var time = db.Timing_Option.First(r => r.Fixture.Code == codeid
                //&& r.Name == optionName && r.Timing_WorkStations.Name == workStation
                //&& r.Categories.Any( t => t.Name == CategoryName)
                //&& r.Parameters.Any(e => e.Code == parameter));

                //int optionID = 72636;
                //var time2 = db.Timing_Option.Where(r => r.OptionID == optionID).FirstOrDefault();
                //time2.Time = (decimal)1.40;
                //db.SaveChanges();
            }
        }