public List <BudModifyTaskRes> GetInTaskRes(string taskId) { List <BudModifyTaskRes> listModifyTaskRes = new List <BudModifyTaskRes>(); BudModifyTaskService service = new BudModifyTaskService(); listModifyTaskRes = (from mts in this join mt in service on mts.ModifyTaskId equals mt.ModifyTaskId where mt.TaskId == taskId select mts).ToList <BudModifyTaskRes>(); List <string> modifyTasResIds = this.GetModifyTasResIds(listModifyTaskRes); List <BudModifyTaskRes> list3 = new List <BudModifyTaskRes>(); using (List <string> .Enumerator enumerator = modifyTasResIds.GetEnumerator()) { Func <BudModifyTaskRes, bool> predicate = null; string id; while (enumerator.MoveNext()) { id = enumerator.Current; BudModifyTaskRes item = new BudModifyTaskRes { ModifyTaskResId = Guid.NewGuid().ToString(), ModifyTaskId = taskId, ModifyId = null, ResourceId = id }; decimal num = 0M; decimal num2 = 0M; decimal num3 = 0M; if (predicate == null) { predicate = mtr => mtr.ResourceId == id; } foreach (BudModifyTaskRes res2 in listModifyTaskRes.Where <BudModifyTaskRes>(predicate).ToList <BudModifyTaskRes>()) { num += res2.ResourceQuantity; num2 += res2.ResourceQuantity * res2.ResourcePrice; } if (num != 0M) { num3 = num2 / num; } item.ResourcePrice = num3; item.ResourceQuantity = num; list3.Add(item); } } return(list3); }
private List <BudTaskResource> GetAllRes(string prjId, int version) { List <BudTaskResource> list = (from taskRes in this join task in this.tSer on taskRes.TaskId equals task.TaskId where (task.PrjId == prjId) && (task.TaskType == "") select taskRes).ToList <BudTaskResource>(); BudModifyTaskResService service = new BudModifyTaskResService(); BudModifyTaskService service2 = new BudModifyTaskService(); BudModifyService service3 = new BudModifyService(); using (List <BudModifyTaskRes> .Enumerator enumerator = (from mtr in service join mt in service2 on mtr.ModifyTaskId equals mt.ModifyTaskId join m in service3 on mt.ModifyId equals m.ModifyId where (m.PrjId == prjId) && (m.Flowstate == 1) select mtr).ToList <BudModifyTaskRes>().GetEnumerator()) { BudModifyTaskRes modifyTaskRes; while (enumerator.MoveNext()) { modifyTaskRes = enumerator.Current; BudModify byId = service3.GetById(modifyTaskRes.ModifyId); BudModifyTask task = (from mts in service2 where mts.ModifyTaskId == modifyTaskRes.ModifyTaskId select mts).FirstOrDefault <BudModifyTask>(); BudTaskResource item = new BudTaskResource { TaskResourceId = modifyTaskRes.ModifyTaskResId }; if (task.ModifyType == 0) { item.TaskId = modifyTaskRes.ModifyTaskId; } else { item.TaskId = task.TaskId; } item.ResourceId = modifyTaskRes.ResourceId; item.ResourceQuantity = new decimal?(modifyTaskRes.ResourceQuantity); item.ResourcePrice = new decimal?(modifyTaskRes.ResourcePrice); item.InputDate = DateTime.Now; item.InputUser = byId.InputUser; item.PrjGuid = prjId; item.Versions = new int?(version); list.Add(item); } } return(list); }
public string GetNextChildOrderNumber(string taskId) { string str = "001"; BudModifyTaskService service = new BudModifyTaskService(); BudTask byId = this.GetById(taskId); string str2 = (from t in this where t.ParentId == taskId orderby t.OrderNumber descending select t.OrderNumber).FirstOrDefault <string>(); if (!string.IsNullOrEmpty(str2)) { int num = Convert.ToInt32(str2.Substring(str2.Length - 3)) + 1; str = num.ToString().PadLeft(3, '0'); } while (service.IsOrderNumberExists(byId.PrjId, byId.OrderNumber + str)) { int num2 = Convert.ToInt32(str) + 1; str = num2.ToString().PadLeft(3, '0'); } return(byId.OrderNumber + str); }
public BudTask GetTaskById(string taskId) { BudTask task = (from t in this where t.TaskId == taskId select t).FirstOrDefault <BudTask>(); if (task == null) { BudModifyTask byTaskId = new BudModifyTaskService().GetByTaskId(taskId); if (byTaskId != null) { BudModify byId = new BudModifyService().GetById(byTaskId.ModifyId); task = new BudTask { TaskId = byTaskId.ModifyTaskId, ParentId = byTaskId.TaskId, OrderNumber = byTaskId.OrderNumber, Version = 1, PrjId = byId.PrjId, TaskCode = byTaskId.ModifyTaskCode, TaskName = byTaskId.ModifyTaskContent, Unit = byTaskId.Unit, Quantity = new decimal?(byTaskId.Quantity), UnitPrice = new decimal?(byTaskId.UnitPrice), Total = new decimal?(byTaskId.Total), StartDate = byTaskId.StartDate, EndDate = byTaskId.EndDate, ConstructionPeriod = byTaskId.ConstructionPeriod, Note = byTaskId.Note, InputDate = DateTime.Now, InputUser = byId.InputUser, TaskType = string.Empty, IsValid = true, Total2 = byTaskId.Total2 }; } } return(task); }
public IList <BudTask> GetByProject(string prjId, int level = 0x3e7) { int orderNumberLen = level * 3; List <BudTask> source = (from t in this where ((t.PrjId == prjId) && (t.TaskType == string.Empty)) && (t.OrderNumber.Length <= orderNumberLen) orderby t.OrderNumber select t).ToList <BudTask>(); BudModifyTaskService service = new BudModifyTaskService(); BudModifyService service2 = new BudModifyService(); foreach (BudModifyTask task in (from mt in service join m in service2 on mt.ModifyId equals m.ModifyId where ((m.PrjId == prjId) && (m.Flowstate == 1)) && (mt.ModifyType == 0) select mt).ToList <BudModifyTask>()) { BudModify byId = service2.GetById(task.ModifyId); BudTask item = new BudTask { TaskId = task.ModifyTaskId, ParentId = task.TaskId, OrderNumber = task.OrderNumber, Version = 1, PrjId = prjId, TaskCode = task.ModifyTaskCode, TaskName = task.ModifyTaskContent, Unit = task.Unit, Quantity = new decimal?(task.Quantity), UnitPrice = new decimal?(task.UnitPrice), Total = new decimal?(task.Total), StartDate = task.StartDate, EndDate = task.EndDate, ConstructionPeriod = task.ConstructionPeriod, Note = task.Note, InputDate = DateTime.Now, InputUser = byId.InputUser, TaskType = string.Empty, IsValid = true }; source.Add(item); } using (List <BudModifyTask> .Enumerator enumerator2 = (from mt in service join m in service2 on mt.ModifyId equals m.ModifyId where ((m.PrjId == prjId) && (m.Flowstate == 1)) && (mt.ModifyType == 1) select mt).ToList <BudModifyTask>().GetEnumerator()) { Func <BudTask, bool> predicate = null; BudModifyTask modifyTask; while (enumerator2.MoveNext()) { modifyTask = enumerator2.Current; if (predicate == null) { predicate = t => t.TaskId == modifyTask.TaskId; } BudTask task3 = source.Where <BudTask>(predicate).FirstOrDefault <BudTask>(); if (task3 != null) { decimal?quantity = task3.Quantity; decimal num = modifyTask.Quantity; task3.Quantity = quantity.HasValue ? new decimal?(quantity.GetValueOrDefault() + num) : null; decimal?total = task3.Total; decimal num2 = modifyTask.Total; task3.Total = total.HasValue ? new decimal?(total.GetValueOrDefault() + num2) : null; } } } return(source); }