internal UnitXml ValidateAndInsertUnitMas(string EnvironmentName, string UnitCd, int CKy, int UsrKy) { string actionUri = "ValidateAndInsertUnitMas"; Dictionary <string, object> paramDictionary = new Dictionary <string, object>(); paramDictionary.Add("CKy", CKy); paramDictionary.Add("UsrKy", UsrKy); paramDictionary.Add("UnitCd", UnitCd); UnitXml list = new UnitXml(); list = RunApiOperation( validateAndInsertBaseUri, actionUri, EnvironmentName, paramDictionary, list.GetType()) as UnitXml; return(list); }
internal List <SelectProjectScheduleDetails> SetMSExcelImportJsonData(string EnvironmentName, int PrjKy, int PrcsSchKy, string MSImportStringData, int CKy, int UsrKy) { // -- Define New List List <UnitXml> newUnitXml = new List <UnitXml>(); List <ItemTypeXml> newItemTypeXml = new List <ItemTypeXml>(); List <ItmMasXml> newResourceXml = new List <ItmMasXml>(); List <ItmMasXml> newTaskXml = new List <ItmMasXml>(); List <PrcsDetXml> newPMTaskXml = new List <PrcsDetXml>(); List <PrcsSchDetCmpnXml> newPMResourceXml = new List <PrcsSchDetCmpnXml>(); // -- Define New List List <SelectProjectScheduleDetails> list = new List <SelectProjectScheduleDetails>(); List <PMExcel_ImportModel> listNew = new List <PMExcel_ImportModel>(); if (MSImportStringData != "[]" || MSImportStringData != "[null]" || MSImportStringData != "") { try { PMExcel_ImportModel task = new JavaScriptSerializer().Deserialize <PMExcel_ImportModel>(MSImportStringData); if (task.UnitXml != null) { foreach (UnitXml unitXml in task.UnitXml) { try { if (unitXml != null) { UnitXml unt = ValidateAndInsertUnitMas(EnvironmentName, unitXml.Unit, CKy, UsrKy); newUnitXml.Add(unt); } } catch (Exception ex) { } } } if (task.ItemTypeXml != null) { foreach (ItemTypeXml itemTypeXml in task.ItemTypeXml) { try { if (itemTypeXml != null) { CdMasXml it = ValidateAndInsertCdMas(EnvironmentName, itemTypeXml.ItemTypeCd, itemTypeXml.ItemTypeNm, "ItmTyp", CKy, UsrKy, 0, itemTypeXml.ItemTypeCd); ItemTypeXml itmTyp = new ItemTypeXml(); itmTyp.ItemTypeKy = it.CdKy; itmTyp.ItemTypeCd = it.Code; itmTyp.ItemTypeNm = it.CdNm; newItemTypeXml.Add(itmTyp); } } catch (Exception ex) { } } } if (task.ResourceXml != null) { foreach (ResourceXml resourceXml in task.ResourceXml) { try { if (resourceXml != null) { ItmMasXml itm = ValidateAndInsertItmMas(EnvironmentName, resourceXml.ResourceID, resourceXml.ItemTypeCd, resourceXml.ResourceName, CKy, UsrKy); newResourceXml.Add(itm); } } catch (Exception ex) { } } } if (task.TaskXml != null) { foreach (TaskXml taskXml in task.TaskXml) { try { if (taskXml != null) { ItmMasXml itm = ValidateAndInsertItmMas(EnvironmentName, taskXml.TaskCd, "Task", taskXml.TaskName, CKy, UsrKy); newTaskXml.Add(itm); } } catch (Exception ex) { } } } int LiNo = 0; if (task.PMTaskXml != null) { foreach (PMTaskXml pmTaskXml in task.PMTaskXml) { try { if (pmTaskXml != null) { LiNo++; int untKy = pmTaskXml.Unit == null ? 1 : newUnitXml.Where(o => o.Unit.ToUpper() == pmTaskXml.Unit.ToUpper()).FirstOrDefault().UnitKy; double qty = 0, rate = 0; int intLvl = 0; double.TryParse(pmTaskXml.Quantity, out qty); double.TryParse(pmTaskXml.Rate, out rate); int.TryParse(pmTaskXml.IndentLevel, out intLvl); PrcsDetXml rtn = ValidateAndInsertPMTask( EnvironmentName, PrjKy, PrcsSchKy, pmTaskXml.TaskID, pmTaskXml.TaskName, LiNo.ToString(), pmTaskXml.StartTime, pmTaskXml.EndTime, intLvl, qty, rate, untKy, CKy, UsrKy); newPMTaskXml.Add(rtn); } } catch (Exception ex) { } } } LiNo = 0; if (task.PMResourceXml != null) { int tempPrcsDetKy = 1; //task.PMResourceXml = task.PMResourceXml.OrderBy(o => o.TaskID).ToArray(); foreach (PMResourceXml pmResourceXml in task.PMResourceXml) { try { if (pmResourceXml != null) { int untKy = pmResourceXml.Unit == null ? 1 : newUnitXml.Where(o => o.Unit.ToUpper() == pmResourceXml.Unit.ToUpper()).FirstOrDefault().UnitKy; int prcsDetKy = pmResourceXml.TaskID == null ? 1 : newPMTaskXml.Where(o => o.TaskID.ToUpper() == pmResourceXml.TaskID.ToUpper()).FirstOrDefault().PrcsDetKy; int prcsSchDetKy = pmResourceXml.TaskID == null ? 1 : newPMTaskXml.Where(o => o.TaskID.ToUpper() == pmResourceXml.TaskID.ToUpper()).FirstOrDefault().PrcsSchDetKy; int resKy = 1; if (tempPrcsDetKy != prcsDetKy) { LiNo = 0; } tempPrcsDetKy = prcsDetKy; LiNo++; if (pmResourceXml.ResourceID.Length > 15) { resKy = pmResourceXml.ResourceID == null ? 1 : newResourceXml.Where(o => o.ItmCd.ToUpper() == pmResourceXml.ResourceID.ToUpper().Substring(0, 15)).FirstOrDefault().ItmKy; } else { resKy = pmResourceXml.ResourceID == null ? 1 : newResourceXml.Where(o => o.ItmCd.ToUpper() == pmResourceXml.ResourceID.ToUpper()).FirstOrDefault().ItmKy; } double qty = 0; double.TryParse(pmResourceXml.Quantity, out qty); PrcsSchDetCmpnXml rtn = ValidateAndInsertPMResource( EnvironmentName, prcsSchDetKy, prcsDetKy, 1, resKy, 1, LiNo.ToString(), qty, qty, 0, 0, untKy, CKy, UsrKy); newPMResourceXml.Add(rtn); } } catch (Exception ex) { } } } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } else { list = new System.Collections.Generic.List <SelectProjectScheduleDetails>(); } return(list); }