protected List <ctt_contract_cost> noCicostList = null; // 没有配置项的项目产品 protected void Page_Load(object sender, EventArgs e) { try { var id = Request.QueryString["id"]; thisProject = new pro_project_dal().FindNoDeleteById(long.Parse(id)); if (thisProject != null) { var taskList = new sdk_task_dal().GetProTask(thisProject.id); if (taskList != null && taskList.Count > 0) { actTaskList = taskList.Where(_ => _.status_id != (int)DTO.DicEnum.TICKET_STATUS.DONE).ToList(); } var costList = new ctt_contract_cost_dal().GetCostByProId(thisProject.id); if (costList != null && costList.Count > 0) { noCicostList = costList.Where(_ => _.product_id == null).ToList(); } if (!IsPostBack) { // noTempId noTempId.DataTextField = "name"; noTempId.DataValueField = "id"; noTempId.DataSource = new sys_notify_tmpl_dal().GetTempByEvent(DicEnum.NOTIFY_EVENT.PROJECT_COMPLETED); noTempId.DataBind(); } } } catch (Exception msg) { Response.End(); } }
/// <summary> /// 检查员工的可用性 /// </summary> private void CheckResAvailability(HttpContext context) { // 在同一项目下校验 try { var project_id = context.Request.QueryString["project_id"]; var resId = context.Request.QueryString["res_id"]; var startTime = context.Request.QueryString["startTime"]; // 开始时间 var endTime = context.Request.QueryString["endTime"]; var days = context.Request.QueryString["days"]; // 持续时间 var thisTaskRpeHour = context.Request.QueryString["thisTaskRpeHour"]; // 这个员工在这个任务中的日工作时间 if (!string.IsNullOrEmpty(project_id) && !string.IsNullOrEmpty(resId) && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime) && !string.IsNullOrEmpty(thisTaskRpeHour)) { var project = new pro_project_dal().FindNoDeleteById(long.Parse(project_id)); var taskList = new sdk_task_dal().GetListByProAndRes(long.Parse(project_id), long.Parse(resId)); int readDays = 0; var startDate = DateTime.Parse(startTime); var endDate = DateTime.Parse(endTime); if (!string.IsNullOrEmpty(days)) { readDays = int.Parse(days); endDate = new BLL.TaskBLL().RetrunMaxTime(project.id, startDate, readDays); } else { readDays = new BLL.TaskBLL().GetDayByTime(Tools.Date.DateHelper.ToUniversalTimeStamp(startDate), Tools.Date.DateHelper.ToUniversalTimeStamp(endDate), long.Parse(project_id)); } if (readDays != 0) { // 员工在这个项目中应该工作的时长 var totalHours = readDays * (decimal)project.resource_daily_hours; if (taskList != null && taskList.Count > 0) { var startDateLong = Tools.Date.DateHelper.ToUniversalTimeStamp(startDate); var thisList = taskList.Where(_ => (_.type_id == (int)DTO.DicEnum.TASK_TYPE.PROJECT_ISSUE || _.type_id == (int)DTO.DicEnum.TASK_TYPE.PROJECT_TASK) && (_.estimated_begin_time <Tools.Date.DateHelper.ToUniversalTimeStamp(endDate) && _.estimated_end_time> startDateLong)).ToList(); if (thisList != null && thisList.Count > 0) { // 员工在这些天中已经分配的时长 var taskTotalHours = thisList.Sum(_ => { var thisDays = (decimal)_.hours_per_resource * GetDiffDays(startDate, endDate, Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_begin_time), Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_end_time), project.id); if (thisDays == 0 || _.hours_per_resource == null) { return(0); } else { // 计算员工平均工作时长 TimeSpan ts1 = new TimeSpan(Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_begin_time).Ticks); TimeSpan ts2 = new TimeSpan(Tools.Date.DateHelper.ConvertStringToDateTime((long)_.estimated_end_time).Ticks); var allDays = ts1.Subtract(ts2).Duration().Days; return(((decimal)_.hours_per_resource / allDays) * thisDays); } }); // 员工的剩余时长 var shengyuHours = totalHours - taskTotalHours; var preHours = decimal.Parse(thisTaskRpeHour); var result = shengyuHours > preHours; context.Response.Write(new { result = result, reason = shengyuHours.ToString("#0.00") }); } } } //pageTask.estimated_duration = ts.Days + 1; } } catch (Exception) { } }