コード例 #1
0
        /// <summary>
        /// 校验工单负责人的时间 是否已经使用
        /// </summary>
        private void CheckTicketResTime(HttpContext context)
        {
            var ticketIds = context.Request.QueryString["ids"];

            if (!string.IsNullOrEmpty(ticketIds))
            {
                var tickList = new sdk_task_dal().GetTaskByIds(ticketIds);
                if (tickList != null && tickList.Count > 0)
                {
                    var start = DateTime.Parse(context.Request.QueryString["start"]);
                    var end   = DateTime.Parse(context.Request.QueryString["end"]);
                    var tbll  = new TicketBLL();
                    List <sys_resource> repearResList = new List <sys_resource>();
                    bool isHasRes = true;
                    if (!tickList.Any(_ => tbll.IsHasRes(_.id)))
                    {
                        // 代表选择工单无负责人
                        isHasRes = false;
                    }
                    else
                    {
                        var startLong = Tools.Date.DateHelper.ToUniversalTimeStamp(start);
                        var endLong   = Tools.Date.DateHelper.ToUniversalTimeStamp(end);
                        foreach (var ticket in tickList)
                        {
                            var resList = tbll.GetResNameByTime(ticket.id, startLong, endLong);
                            if (resList != null && resList.Count > 0)
                            {
                                repearResList.AddRange(resList);
                            }
                        }
                        if (repearResList != null && repearResList.Count > 0)
                        {
                            repearResList = repearResList.Distinct().ToList();
                        }
                    }
                    context.Response.Write(new EMT.Tools.Serialize().SerializeJson(new { hasRes = isHasRes, resList = repearResList }));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 获取相应参数
        /// </summary>
        private TaskSaveDto GetParam()
        {
            TaskSaveDto param = AssembleModel <TaskSaveDto>();

            param.resDepIds  = Request.Form["resDepList"]; // 员工角色 Id
            param.contactIds = Request.Form["conIds"];     // 联系人 ID
            var preTaskIds = Request.Form["preIds"];       // 前驱任务IDs

            if (!string.IsNullOrEmpty(preTaskIds))
            {
                var preTasArr = preTaskIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                Dictionary <long, int> predic = new Dictionary <long, int>();
                foreach (var preTasId in preTasArr)
                {
                    var layDays = Request.Form[preTasId + "_lagDays"];
                    if ((!string.IsNullOrEmpty(layDays)) && (!string.IsNullOrWhiteSpace(layDays)))
                    {
                        predic.Add(long.Parse(preTasId), int.Parse(layDays));
                    }
                }
                param.predic = predic;
            }
            var pageTask = AssembleModel <sdk_task>();

            pageTask.cost_code_id = pageTask.cost_code_id == 0 ? null : pageTask.cost_code_id;
            if (pageTask.parent_id == null)
            {
                var subList = new sdk_task_dal().GetAllProTask(thisProject.id);
                if (subList != null && subList.Count >= 99)
                {
                    if (isAdd)
                    {
                        Response.Write("<script>alert('项目下任务过多,不能添加!');window.close();</script>");
                        return(null);
                    }
                    else
                    {
                        if (!subList.Any(_ => _.id == thisTask.id))
                        {
                            Response.Write("<script>alert('项目下任务过多,不能保存!');window.close();</script>");
                            return(null);
                        }
                    }
                }
            }
            //if (parTask != null)
            //{
            //    pageTask.parent_id = parTask.id;
            //}
            if (type_id != (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
            {
                pageTask.is_visible_in_client_portal          = (sbyte)(DisplayInCapNone.Checked ? 1 : 0);
                pageTask.can_client_portal_user_complete_task = (sbyte)(DisplayInCapYes.Checked ? 1 : 0);
                if (TaskTypeFixedWork.Checked)
                {
                    pageTask.estimated_type_id = (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXWORK;
                }
                else if (TaskTypeFixedDuration.Checked)
                {
                    pageTask.estimated_type_id = (int)DicEnum.TIME_ENTRY_METHOD_TYPE.FIXDURATION;
                }
            }
            else
            {
                if (rateList != null && rateList.Count > 0)
                {
                    Dictionary <long, decimal> rateDic = new Dictionary <long, decimal>();
                    foreach (var rate in rateList)
                    {
                        var hours = Request.Form[rate.id + "_esHours"];
                        if (!string.IsNullOrEmpty(hours) && !string.IsNullOrWhiteSpace(hours))
                        {
                            rateDic.Add(rate.id, decimal.Parse(hours));
                        }
                    }
                    param.rateDic = rateDic;
                }
                pageTask.status_id = (int)DicEnum.TICKET_STATUS.NEW;
            }

            var startString        = Request.Form["estimated_beginTime"];
            var estimated_start    = Request.Form["estimated_start"];
            var estimated_end_time = Request.Form["estimated_end_time_"];

            if (!string.IsNullOrEmpty(startString) && !string.IsNullOrEmpty(estimated_end_time) && !string.IsNullOrEmpty(estimated_start))
            {
                pageTask.estimated_end_time   = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(estimated_end_time));
                pageTask.estimated_begin_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(startString + " " + estimated_start));
                // if (type_id == (int)DicEnum.TASK_TYPE.PROJECT_PHASE) // d
                //{
                TimeSpan ts1 = new TimeSpan((DateTime.Parse(startString)).Ticks);
                TimeSpan ts2 = new TimeSpan(Tools.Date.DateHelper.ConvertStringToDateTime((long)pageTask.estimated_end_time).Ticks);
                TimeSpan ts  = ts1.Subtract(ts2).Duration();

                //pageTask.estimated_duration = ts.Days + 1;
                // }
                // RetrunMaxTime 计算结束时间
                if (type_id != (int)DicEnum.TASK_TYPE.PROJECT_PHASE)
                {
                    if (thisProject.use_resource_daily_hours == 1)  // 用工作量为固定工作任务计算时间
                    {
                        decimal teaNum       = 0;
                        var     dayWorkHours = (decimal)thisProject.resource_daily_hours;
                        if (!string.IsNullOrEmpty(param.resDepIds))
                        {
                            teaNum += param.resDepIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count();
                        }
                        if (pageTask.owner_resource_id != null)
                        {
                            teaNum += 1;
                        }
                        teaNum = teaNum == 0 ? 1 : teaNum;
                        var workHours = pageTask.estimated_hours;
                        pageTask.estimated_duration = (int)Math.Ceiling(((workHours / teaNum) / dayWorkHours));
                        pageTask.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(new TaskBLL().RetrunMaxTime(thisProject.id, DateTime.Parse(startString), (int)pageTask.estimated_duration));
                    }
                    else
                    {
                    }
                }
                else
                {
                    pageTask.estimated_duration = new TaskBLL().GetDayByTime((long)pageTask.estimated_begin_time, (long)pageTask.estimated_end_time, (long)thisProject.id);
                }
            }
            if (isAdd)
            {
                param.task            = pageTask;
                param.task.type_id    = type_id;
                param.task.project_id = thisProject.id;
                param.task.account_id = thisProject.account_id;
            }
            else
            {
                // thisTask
                thisTask.title       = pageTask.title;
                thisTask.parent_id   = pageTask.parent_id;
                thisTask.description = pageTask.description;
                if (thisTask.estimated_begin_time != pageTask.estimated_begin_time)
                {
                    thisTask.estimated_begin_time       = pageTask.estimated_begin_time;
                    thisTask.start_no_earlier_than_date = Tools.Date.DateHelper.ConvertStringToDateTime((long)thisTask.estimated_begin_time);
                }
                if (thisTask.estimated_end_time != pageTask.estimated_end_time)
                {
                    thisTask.estimated_end_time = pageTask.estimated_end_time;
                    thisTask.estimated_duration = new TaskBLL().GetDayByTime((long)thisTask.estimated_begin_time, (long)pageTask.estimated_end_time, (long)thisTask.project_id);
                }
                else
                {
                    if (thisTask.estimated_duration != pageTask.estimated_duration)
                    {
                        thisTask.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(new TaskBLL().RetrunMaxTime(thisProject.id, DateTime.Parse(startString), (int)pageTask.estimated_duration));
                        thisTask.estimated_duration = pageTask.estimated_duration;
                    }
                    else
                    {
                        thisTask.estimated_end_time = pageTask.estimated_end_time;
                        thisTask.estimated_duration = pageTask.estimated_duration;
                    }
                }



                if (!isPhase)
                {
                    thisTask.status_id         = pageTask.status_id;
                    thisTask.priority          = pageTask.priority;
                    thisTask.purchase_order_no = pageTask.purchase_order_no;
                    thisTask.can_client_portal_user_complete_task = pageTask.can_client_portal_user_complete_task;
                    thisTask.is_visible_in_client_portal          = pageTask.is_visible_in_client_portal;
                    thisTask.is_project_issue        = pageTask.is_project_issue;
                    thisTask.issue_report_contact_id = pageTask.issue_report_contact_id;
                    thisTask.estimated_type_id       = pageTask.estimated_type_id;
                    thisTask.estimated_hours         = pageTask.estimated_hours;
                    //      thisTask.estimated_duration = pageTask.estimated_duration;
                    thisTask.hours_per_resource = pageTask.hours_per_resource;
                    if (thisTask.start_no_earlier_than_date == null)
                    {
                        thisTask.start_no_earlier_than_date = pageTask.start_no_earlier_than_date;
                    }

                    thisTask.department_id     = pageTask.department_id;
                    thisTask.cost_code_id      = pageTask.cost_code_id;
                    thisTask.owner_resource_id = pageTask.owner_resource_id;
                    thisTask.template_id       = pageTask.template_id;
                    var IsEditEsTime = this.IsEditEsTime.Value; //Request.Form["IsEditEsTime"];
                    var thisVt       = new v_task_all_dal().FindById(thisTask.id);
                    if (!string.IsNullOrEmpty(IsEditEsTime))
                    {
                        if (IsEditEsTime == "1")
                        {
                            thisTask.projected_variance = (thisVt.worked_hours == null ? 0 : (decimal)thisVt.worked_hours) - (thisTask.estimated_hours + (thisVt.change_Order_Hours == null ? 0 : (decimal)thisVt.change_Order_Hours)) + (thisVt.remain_hours == null ? 0 : (decimal)thisVt.remain_hours);
                        }
                        else if (IsEditEsTime == "0")
                        {
                            thisTask.projected_variance = (thisVt.worked_hours == null ? 0 : (decimal)thisVt.worked_hours) - (thisTask.estimated_hours + (thisVt.change_Order_Hours == null ? 0 : (decimal)thisVt.change_Order_Hours));
                        }
                    }
                    else
                    {
                    }
                }
                param.task = thisTask;
            }

            if (task_udfList != null && task_udfList.Count > 0)
            {
                var list = new List <UserDefinedFieldValue>();
                foreach (var udf in task_udfList)                            // 循环添加
                {
                    var new_udf = new UserDefinedFieldValue()
                    {
                        id    = udf.id,
                        value = string.IsNullOrEmpty(Request.Form[udf.id.ToString()]) ? null : Request.Form[udf.id.ToString()],
                    };
                    list.Add(new_udf);
                }
                param.udf = list;
            }



            return(param);
        }