コード例 #1
0
ファイル: baseClass.cs プロジェクト: saraddargon/MTECH
        public static List <WorkLoad> getWorkLoad(DateTime beginDate, DateTime?dTo, int idWorkcenter = 0)
        {
            var workLoads = new List <WorkLoad>();

            using (var db = new DataClasses1DataContext())
            {
                if (idWorkcenter > 0)
                {
                    var bDate = beginDate.Date;
                    var tDate = (dTo != null) ? dTo.Value.Date : beginDate.Date.AddDays(7);
                    while (bDate <= tDate)
                    {
                        CalCapacity_WorkCenter(idWorkcenter, bDate);
                        bDate = bDate.AddDays(1);
                    }
                }
                //
                var d = db.mh_CapacityAvailables.Where(x => x.Date >= beginDate &&
                                                       (dTo == null || x.Date <= dTo)).ToList();
                foreach (var dd in d)
                {
                    var m = db.mh_CapacityLoads.Where(x => x.Date == dd.Date &&
                                                      x.WorkCenterID == dd.WorkCenterID && x.Active).ToList();
                    decimal loadCapa  = 0.00m;
                    decimal loadCapaX = 0.00m;
                    //if (m.Count > 0)
                    loadCapa  = m.Sum(x => x.Capacity);
                    loadCapaX = m.Sum(x => x.CapacityX);
                    var wl = workLoads.Where(x => x.Date == dd.Date &&
                                             x.idWorkCenter == dd.WorkCenterID).FirstOrDefault();
                    if (wl == null)
                    {
                        wl = new WorkLoad();
                        workLoads.Add(wl);
                    }
                    wl.idWorkCenter       = dd.WorkCenterID;
                    wl.Date               = dd.Date.Date;
                    wl.CapacityAvailable  = dd.Capacity.ToDecimal();
                    wl.CapacityAvailableX = dd.CapacityX.ToDecimal();
                    wl.CapacityAlocate   += loadCapa;  //Capa ในวัน
                    wl.CapacityAlocateX  += loadCapaX; //เวลาในวัน
                }
                return(workLoads);
            }
        }
コード例 #2
0
ファイル: baseClass.cs プロジェクト: saraddargon/MTECH
        public static WorkLoad getWorkLoad_From(DateTime beginDate, int idWorkcenter)
        {
            var wl = new WorkLoad();

            using (var db = new DataClasses1DataContext())
            {
                if (idWorkcenter > 0)
                {
                    var  bDate = beginDate.Date;
                    bool findE = true;
                    while (findE)
                    {
                        var av = CalCapacity_WorkCenter(idWorkcenter, bDate);
                        var m  = db.mh_CapacityLoads.Where(x => x.Date == av.Date &&
                                                           x.WorkCenterID == av.WorkCenterID && x.Active).ToList();

                        decimal loadCapa  = 0.00m;
                        decimal loadCapaX = 0.00m;
                        loadCapa  = m.Sum(x => x.Capacity);
                        loadCapaX = m.Sum(x => x.CapacityX);

                        if (av.CapacityX - loadCapaX > 0)
                        {
                            wl.idWorkCenter       = av.WorkCenterID;
                            wl.Date               = av.Date.Date;
                            wl.CapacityAvailable  = av.Capacity.ToDecimal();
                            wl.CapacityAvailableX = av.CapacityX.ToDecimal();
                            wl.CapacityAlocate   += loadCapa;  //Capa ในวัน
                            wl.CapacityAlocateX  += loadCapaX; //เวลาในวัน
                            findE = false;
                        }
                        //
                        bDate = bDate.AddDays(1);
                    }
                }
                //
                return(wl);
            }
        }