public BlockDTO GetBlockByNum(int num) { BlockDTO response = null; try { var entity = _hiveContext.Blocks.Where(x => x.num == num).FirstOrDefault(); response = AutoMapper.Mapper.Map <BlockDTO>(entity); } catch (Exception ex) { throw; } return(response); }
public BlockDTO GetMostRecentBlock() { BlockDTO block = new BlockDTO(); var entity = _hiveContext.Blocks.OrderByDescending(x => x.num).Take(1).FirstOrDefault(); if (entity != null) { block = _mapper.Map <BlockDTO>(entity); } //using(var db = new HiveContext()) //{ //} return(block); }
/// <summary> /// 입력한 블록 정보를 정제하는 함수 /// </summary> /// <param name="_inputStringList">csv 파일로부터 읽어온 블록 정보 raw 데이터</param> /// <param name="_workshopList">작업장 정보</param> /// <returns>정제된 블록 정보</returns> /// <remarks> /// 최초 작성 : 정용국, 2016년 01월 20일 /// 수정 작성 : 유상현, 2020년 05월 13일 /// </remarks> List <BlockDTO> IDataManagement.RefineInputBlockData(List <string[]> _inputStringList, List <WorkshopDTO> _workshopList, double _UnitGridLength) { List <BlockDTO> returnList = new List <BlockDTO>(); //작업영역 고려 여부 변수 추가 //bool IsWorkAreaInfoConsidered = false; for (int i = 1; i < _inputStringList.Count; i++) { double tempUpperCount; double tempBotCount; double tempLeftCount; double tempRightCount; double tempLeadTime; double tempLength; double tempBreadth; DateTime tempImportDate; DateTime tempExportDate; List <int> tempPreferWorkShop = new List <int>(); List <int> tempPreferAddress = new List <int>(); bool PreferWorkShop = true; bool PreferAddress = true; bool IsRoadSide = false; int tempSearchDirection; int tempArrangementDirection; BlockDTO tempBlockDTO; //블록 크기 입력 //if (Convert.ToDouble(_inputStringList[i][3]) >= Convert.ToDouble(_inputStringList[i][4])) tempLength = Convert.ToDouble(_inputStringList[i][4]); tempLength = Convert.ToDouble(_inputStringList[i][3]); //if (Convert.ToDouble(_inputStringList[i][4]) < Convert.ToDouble(_inputStringList[i][3])) tempBreadth = Convert.ToDouble(_inputStringList[i][3]); tempBreadth = Convert.ToDouble(_inputStringList[i][4]); tempLength /= _UnitGridLength; tempBreadth /= _UnitGridLength; //상하좌우 작업공간 입력 if (_inputStringList[i][11] == "") { tempUpperCount = 0.0; } else { tempUpperCount = Convert.ToDouble(_inputStringList[i][11]); } if (_inputStringList[i][12] == "") { tempBotCount = 0.0; } else { tempBotCount = Convert.ToDouble(_inputStringList[i][12]); } if (_inputStringList[i][13] == "") { tempLeftCount = 0.0; } else { tempLeftCount = Convert.ToDouble(_inputStringList[i][13]); } if (_inputStringList[i][14] == "") { tempRightCount = 0.0; } else { tempRightCount = Convert.ToDouble(_inputStringList[i][14]); } //tempLeadTime = 0.0; //if (_inputStringList[i][9] == "") tempLeadTime = 0.0; //else tempLeadTime = Convert.ToDouble(_inputStringList[i][9]); //입출고일 입력 if (_inputStringList[i][6] == "") { tempImportDate = DateTime.Parse("0001-01-01"); } else { tempImportDate = DateTime.Parse(_inputStringList[i][6]); } if (_inputStringList[i][7] == "") { tempExportDate = DateTime.Parse("0001-01-01"); } else { tempExportDate = DateTime.Parse(_inputStringList[i][7]); } //리드타임 계산 TimeSpan ts = tempExportDate - tempImportDate; tempLeadTime = ts.Days; //입고일과 출고일이 같은 데이터가 입력된 경우에는 출고일 +1 //TimeSpan ts = tempExportDate - tempImportDate; //int tempTS = ts.Days; //if (tempTS == 0) tempExportDate = tempExportDate.AddDays(1); //선호작업장, 도로인접 배치 여부 입력 if (_inputStringList[i][8] == "") { PreferWorkShop = false; PreferAddress = false; } else if (_inputStringList[i][8] == "-1") { PreferWorkShop = false; IsRoadSide = true; } if (PreferWorkShop == false) //선호작업장 값이 없는 경우 { //모든 작업장을 선호작업장으로 가짐 int totalWorkShop = _workshopList.Count; for (int j = 0; j < totalWorkShop; j++) { tempPreferWorkShop.Add(j); } } else//선호작업장 값이 있는 경우 { string[] temp = _inputStringList[i][8].Split('-'); for (int j = 0; j < temp.Length; j++) { tempPreferWorkShop.Add(Convert.ToInt32(temp[j])); } int totalWorkShop = _workshopList.Count; for (int j = 0; j < totalWorkShop; j++) { if (!tempPreferWorkShop.Contains(j)) { tempPreferWorkShop.Add(j); } } } // 선호지번 잠시 안씀 //if (_inputStringList[i][9] == "") PreferAddress = false; //if (PreferAddress == false) //선호지번 값이 없는 경우 //{ // //선호지번은 빈 리스트 //} //else//선호지번 값이 있는 경우 //{ // string[] temp = _inputStringList[i][9].Split('-'); // for (int j = 0; j < temp.Length; j++) tempPreferAddress.Add(Convert.ToInt32(temp[j])); //} //탐색방향 입력 if (_inputStringList[i][9] == "") { tempSearchDirection = 1; } else { tempSearchDirection = Convert.ToInt32(_inputStringList[i][9]); } //배치방향 입력 if (_inputStringList[i][10] == "") { tempArrangementDirection = 0; } else { tempArrangementDirection = Convert.ToInt32(_inputStringList[i][10]); } tempBlockDTO = new BlockDTO( Convert.ToInt16(_inputStringList[i][0]), _inputStringList[i][1], _inputStringList[i][2], tempBreadth, tempLength, tempUpperCount, tempBotCount, tempLeftCount, tempRightCount, tempPreferWorkShop, tempPreferAddress, tempLeadTime, tempImportDate, tempExportDate, DateTime.MinValue, DateTime.MinValue, IsRoadSide, PreferWorkShop, tempSearchDirection, tempArrangementDirection); returnList.Add(tempBlockDTO); } return(returnList); }
/// <summary> /// 블록 그리드 정보가 갱신되면 이를 불러와 블록 정보에 저장하는 함수 /// </summary> /// <param name="_datagrid">블록 정보가 변경된 그리드</param> /// <param name="_workshopList">갱신할 블록 정보</param> /// <remarks> /// 최초 작성 : 이동건, 2016년 02월 25일 /// </remarks> void IDataManagement.UpdateBlockDataOfGrid(DataGridView _datagrid, List <BlockDTO> _blockList) { BlockDTO tempBlockDTO; _blockList.Clear(); foreach (DataGridViewRow row in _datagrid.Rows) { //for (int i = 0; i < row.Cells.Count; i++) //{ // if (row.IsNewRow || row.Cells[i].Value == null) // continue; //} if (row.Cells[0].Value != null) { string value1 = row.Cells[0].Value.ToString(); string value2 = row.Cells[1].Value.ToString(); string value3 = row.Cells[2].Value.ToString(); string value4 = row.Cells[3].Value.ToString(); string value5 = row.Cells[4].Value.ToString(); string value6 = row.Cells[5].Value.ToString(); string value7 = row.Cells[6].Value.ToString(); string value8 = row.Cells[7].Value.ToString(); string value9 = row.Cells[8].Value.ToString(); string value10 = row.Cells[9].Value.ToString(); string value11 = row.Cells[10].Value.ToString(); string value12 = row.Cells[11].Value.ToString(); string value13 = row.Cells[12].Value.ToString(); string value14 = row.Cells[13].Value.ToString(); List <int> tempPreferWorkShop = new List <int>(); List <int> tempPreferAddress = new List <int>(); string[] PreferWorkshoptemp = value13.Split(','); for (int j = 0; j < PreferWorkshoptemp.Length; j++) { tempPreferWorkShop.Add(Convert.ToInt32(PreferWorkshoptemp[j])); } if (value14 != "") { string[] PreferAddresstemp = value14.Split(','); for (int j = 0; j < PreferAddresstemp.Length; j++) { tempPreferAddress.Add(Convert.ToInt32(PreferAddresstemp[j])); } } tempBlockDTO = new BlockDTO(Convert.ToInt16(value1), value2, value3, Convert.ToDouble(value4), Convert.ToDouble(value5), Convert.ToDouble(value6), Convert.ToDouble(value7), Convert.ToDouble(value8), Convert.ToDouble(value9), tempPreferWorkShop, tempPreferAddress, Convert.ToDouble(value10), DateTime.Parse(value11), DateTime.Parse(value12), DateTime.MinValue, DateTime.MinValue); _blockList.Add(tempBlockDTO); } } }