コード例 #1
0
        public List <FlowChartDetailAndMgData> QueryFLDetailList(int id, string week)
        {
            Week getWeek = new Model.ViewModels.Week();
            List <FlowChartMgDataDTO> mgDataList = new List <FlowChartMgDataDTO>();
            List <int> flDetailUIDList           = new List <int>();

            switch (week)
            {
            case "next":
                getWeek = GetCurrentWeek(DateTime.Now.Date);
                break;

            case "current":
                getWeek = GetLastWeek(DateTime.Now.Date);
                break;
            }
            var maxVersion = flowChartDetailRepository.GetMany(m => m.FlowChart_Master_UID == id).Max(m => m.FlowChart_Version);
            var list       = flowChartDetailRepository.GetMany(m => m.FlowChart_Master_UID == id && m.FlowChart_Version == maxVersion).OrderBy(m => m.Process_Seq).ToList();
            var dto        = AutoMapper.Mapper.Map <List <FlowChartDetailAndMgData> >(list);

            if (list.Count() > 0)
            {
                flDetailUIDList = list.Select(m => m.FlowChart_Detail_UID).ToList();
                var mgList = flowChartMgDataRepository.GetMany(m => flDetailUIDList.Contains(m.FlowChart_Detail_UID) && m.Product_Date >= getWeek.Monday && m.Product_Date <= getWeek.Sunday).ToList();
                mgDataList = AutoMapper.Mapper.Map <List <FlowChartMgDataDTO> >(mgList);

                foreach (var flDetailMgDataItem in dto)
                {
                    var currentMgList = mgDataList.Where(m => m.FlowChart_Detail_UID == flDetailMgDataItem.FlowChart_Detail_UID).ToList();
                    flDetailMgDataItem.MgDataList = currentMgList;
                }
            }
            return(dto);
        }
コード例 #2
0
        public void SaveAllDetailInfo(List <FlowChartDetailAndMGDataInputDTO> list, int AccountID)
        {
            var idList     = list.Select(m => m.FlowChart_Detail_UID).ToList();
            var mgDataList = flowChartMgDataRepository.GetMany(m => idList.Contains(m.FlowChart_Detail_UID)).ToList();

            foreach (var item in list)
            {
                var mgDataItem = mgDataList.Where(m => m.FlowChart_Detail_UID == item.FlowChart_Detail_UID).FirstOrDefault();
                if (mgDataItem != null)
                {
                    mgDataItem.Product_Plan  = item.Product_Plan;
                    mgDataItem.Target_Yield  = double.Parse(item.Target_Yield.Substring(0, item.Target_Yield.Length - 1)) / 100;
                    mgDataItem.Modified_Date = DateTime.Now;
                    mgDataItem.Modified_UID  = AccountID;
                    flowChartMgDataRepository.Update(mgDataItem);
                }
            }
            unitOfWork.Commit();
        }