コード例 #1
0
ファイル: TicketManage.aspx.cs プロジェクト: evelh/Done
        /// <summary>
        ///  获取页面参数
        /// </summary>
        protected TicketManageDto GetParam()
        {
            // 为方便页面处理 owner_resource_id 存储的是 sys_resource_department 的id ,存储时需要转换
            long?owner_resource_id = null;
            long?role_id           = null;
            var  priResString      = Request.Form["owner_resource_id"];

            if (!string.IsNullOrEmpty(priResString))
            {
                var resDep = new sys_resource_department_dal().FindById(long.Parse(priResString));
                if (resDep != null)
                {
                    owner_resource_id = resDep.resource_id;
                    role_id           = resDep.role_id;
                }
            }
            TicketManageDto param      = new TicketManageDto();
            var             pageTicket = AssembleModel <sdk_task>();

            pageTicket.owner_resource_id = owner_resource_id;
            pageTicket.role_id           = role_id;
            var dueDate = Request.Form["DueDate"];
            var dueTime = Request.Form["DueTime"];

            if (!string.IsNullOrEmpty(dueTime) && !string.IsNullOrEmpty(dueDate))
            {
                var dueDateTime = dueDate + " " + dueTime; // 获取到截止时间
                var dueD        = DateTime.Parse(dueDateTime);
                pageTicket.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(dueD);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('未获取到相关截止时间,请重新填写!');</script>");
                return(null);
            }
            #region 如果sla设置自动计算截止时间 ,保存时计算出工单的结束时间
            if (pageTicket.sla_id != null)
            {
                var thisSla = new d_sla_dal().FindNoDeleteById((long)pageTicket.sla_id);
                if (thisSla != null && thisSla.set_ticket_due_date == 1)
                {
                    if (pageTicket.sla_start_time == null)
                    {
                        pageTicket.sla_start_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
                    }
                    var    slaValue     = new sdk_task_dal().GetSlaTime(pageTicket);
                    string slaTimeValue = "";
                    if (slaValue != null)
                    {
                        slaTimeValue = slaValue.ToString();
                    }
                    if (!string.IsNullOrEmpty(slaTimeValue) && slaTimeValue.Substring(0, 1) == "{")
                    {
                        var slaDic = new EMT.Tools.Serialize().JsonToDictionary(slaTimeValue);
                        if (slaDic != null && slaDic.Count > 0)
                        {
                            var duteDateDic = slaDic.FirstOrDefault(_ => _.Key == "截止时间");
                            if (!default(KeyValuePair <string, object>).Equals(duteDateDic))
                            {
                                var duteDate = DateTime.Parse(duteDateDic.Value.ToString());
                                pageTicket.estimated_end_time = Tools.Date.DateHelper.ToUniversalTimeStamp(duteDate);
                            }
                            var firstResponseDateDic = slaDic.FirstOrDefault(_ => _.Key == "响应时间");
                            if (!default(KeyValuePair <string, object>).Equals(firstResponseDateDic))
                            {
                                pageTicket.first_response_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(firstResponseDateDic.Value.ToString()));
                            }
                            var resoluTatgetDic = slaDic.FirstOrDefault(_ => _.Key == "解决时间");
                            if (!default(KeyValuePair <string, object>).Equals(resoluTatgetDic))
                            {
                                pageTicket.resolution_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(resoluTatgetDic.Value.ToString()));
                            }
                            var resoluPlanTatgetDic = slaDic.FirstOrDefault(_ => _.Key == "解决方案提供时间");
                            if (!default(KeyValuePair <string, object>).Equals(firstResponseDateDic))
                            {
                                pageTicket.resolution_plan_target_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(resoluPlanTatgetDic.Value.ToString()));
                            }
                        }
                    }
                }
            }
            #endregion

            if (isAdd)
            {
                pageTicket.type_id = (int)DTO.DicEnum.TASK_TYPE.SERVICE_DESK_TICKET;
                param.ticket       = pageTicket;
            }
            else
            {
                #region 获取页面相关值
                thisTicket.account_id           = pageTicket.account_id;
                thisTicket.contract_id          = pageTicket.contract_id;
                thisTicket.contact_id           = pageTicket.contact_id;
                thisTicket.status_id            = pageTicket.status_id;
                thisTicket.priority             = pageTicket.priority;
                thisTicket.issue_type_id        = pageTicket.issue_type_id;
                thisTicket.sub_issue_type_id    = pageTicket.sub_issue_type_id;
                thisTicket.source_type_id       = pageTicket.source_type_id;
                thisTicket.estimated_end_time   = pageTicket.estimated_end_time;
                thisTicket.estimated_hours      = pageTicket.estimated_hours;
                thisTicket.sla_id               = pageTicket.sla_id;
                thisTicket.department_id        = pageTicket.department_id;
                thisTicket.owner_resource_id    = pageTicket.owner_resource_id;
                thisTicket.role_id              = pageTicket.role_id;
                thisTicket.installed_product_id = pageTicket.installed_product_id;
                thisTicket.service_id           = pageTicket.service_id;
                thisTicket.cost_code_id         = pageTicket.cost_code_id;
                thisTicket.purchase_order_no    = pageTicket.purchase_order_no;
                thisTicket.cate_id              = pageTicket.cate_id;
                thisTicket.ticket_type_id       = pageTicket.ticket_type_id;
                thisTicket.title       = pageTicket.title;
                thisTicket.description = pageTicket.description;
                thisTicket.resolution  = pageTicket.resolution;

                thisTicket.sla_start_time              = pageTicket.sla_start_time;
                thisTicket.estimated_end_time          = pageTicket.estimated_end_time;
                thisTicket.first_response_target_time  = pageTicket.first_response_target_time;
                thisTicket.resolution_target_time      = pageTicket.resolution_target_time;
                thisTicket.resolution_plan_target_time = pageTicket.resolution_plan_target_time;
                #endregion
                param.ticket = thisTicket;
            }
            param.resDepIds = Request.Form["OtherResId"];
            var AddSoule = Request.Form["AddSoule"];
            if (AddSoule == "on")
            {
                param.isAppSlo = true;
            }
            param.completeReason = Request.Form["reason"];
            param.repeatReason   = Request.Form["RepeatReason"];
            #region 检查单相关
            var CheckListIds = Request.Form["CheckListIds"];  // 检查单Id
            if (!string.IsNullOrEmpty(CheckListIds))
            {
                List <CheckListDto> ckList = new List <CheckListDto>();
                var checkIdArr             = CheckListIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var checkId in checkIdArr)
                {
                    if (string.IsNullOrEmpty(Request.Form[checkId + "_item_name"]))  // 条目名称为空 不添加
                    {
                        continue;
                    }
                    var     is_complete = Request.Form[checkId + "_is_complete"];
                    var     is_import   = Request.Form[checkId + "_is_import"];
                    var     sortOrder   = Request.Form[checkId + "_sort_order"];
                    decimal?sort        = null;
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort = decimal.Parse(sortOrder);
                    }
                    var thisCheck = new CheckListDto()
                    {
                        ckId       = long.Parse(checkId),
                        isComplete = is_complete == "on",
                        itemName   = Request.Form[checkId + "_item_name"],
                        isImport   = is_import == "on",
                        sortOrder  = sort,
                    };
                    ckList.Add(thisCheck);
                }
                param.ckList = ckList;
            }
            #endregion
            #region 工单自定义字段,页面暂无自定义
            if (tickUdfList != null && tickUdfList.Count > 0)
            {
                var list = new List <UserDefinedFieldValue>();
                foreach (var udf in tickUdfList)                            // 循环添加
                {
                    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);
                }
                if (isAdd)
                {
                    param.udfList = list;
                }
                else
                {
                    param.udfList = ticketUdfValueList;
                }
            }
            #endregion
            return(param);
        }
コード例 #2
0
ファイル: TicketManage.aspx.cs プロジェクト: evelh/Done
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    Bind();  // 绑定页面下拉数据
                }
                CallBack = Request.QueryString["CallBack"];

                var accountId = Request.QueryString["account_id"];
                if (!string.IsNullOrEmpty(accountId))
                {
                    thisAccount = new CompanyBLL().GetCompany(long.Parse(accountId));
                }
                var contractId = Request.QueryString["contract_id"];
                if (!string.IsNullOrEmpty(contractId))
                {
                    thisContract = new ctt_contract_dal().FindNoDeleteById(long.Parse(contractId));
                }
                var insProId = Request.QueryString["insProId"];
                if (!string.IsNullOrEmpty(insProId))
                {
                    insPro = new crm_installed_product_dal().FindNoDeleteById(long.Parse(insProId));
                    if (insPro != null && insPro.account_id != null)
                    {
                        thisAccount = new CompanyBLL().GetCompany((long)insPro.account_id);
                    }
                }

                var taskId = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(taskId));
                    if (thisTicket != null)
                    {
                        thisBookMark = new IndexBLL().GetSingBook(Request.RawUrl, LoginUserId);
                        var isCopyString = Request.QueryString["isCopy"];
                        if (string.IsNullOrEmpty(isCopyString))
                        {
                            isAdd = false;
                        }
                        else
                        {
                            isCopy = true;
                        }
                        if (!IsPostBack)
                        {
                            cate_id.ClearSelection();
                            cate_id.SelectedValue             = thisTicket.cate_id.ToString();
                            this.ticket_type_id.SelectedValue = thisTicket.ticket_type_id.ToString();
                            this.status_id.SelectedValue      = thisTicket.status_id.ToString();
                            if (isCopy)
                            {
                                this.status_id.ClearSelection(); this.status_id.SelectedValue = ((int)DicEnum.TICKET_STATUS.NEW).ToString();
                            }
                            if (thisTicket.priority_type_id != null)
                            {
                                priority_type_id.SelectedValue = thisTicket.priority_type_id.ToString();
                            }
                            if (thisTicket.issue_type_id != null)
                            {
                                issue_type_id.SelectedValue = thisTicket.issue_type_id.ToString();
                            }
                            if (thisTicket.source_type_id != null)
                            {
                                source_type_id.SelectedValue = thisTicket.source_type_id.ToString();
                            }
                            if (thisTicket.issue_type_id != null)
                            {
                                issue_type_id.SelectedValue = thisTicket.issue_type_id.ToString();
                            }
                            if (thisTicket.sla_id != null)
                            {
                                sla_id.SelectedValue = thisTicket.sla_id.ToString();
                            }
                            if (thisTicket.department_id != null)
                            {
                                department_id.SelectedValue = thisTicket.department_id.ToString();
                            }
                        }
                        ticketUdfValueList = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.TASK, thisTicket.id, tickUdfList);

                        thisAccount = new CompanyBLL().GetCompany(thisTicket.account_id);
                        if (thisTicket.contact_id != null)
                        {
                            thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                        }

                        if (thisTicket.owner_resource_id != null && thisTicket.role_id != null)
                        {
                            var resDepList = new sys_resource_department_dal().GetResDepByResAndRole((long)thisTicket.owner_resource_id, (long)thisTicket.role_id);
                            if (resDepList != null && resDepList.Count > 0)
                            {
                                proResDep = resDepList[0];
                                priRes    = new sys_resource_dal().FindNoDeleteById((long)thisTicket.owner_resource_id);
                            }
                        }

                        if (thisTicket.installed_product_id != null)
                        {
                            insPro = new crm_installed_product_dal().FindNoDeleteById((long)thisTicket.installed_product_id);
                        }

                        if (thisTicket.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisTicket.contract_id);
                        }

                        if (thisTicket.cost_code_id != null)
                        {
                            thisCostCode = new d_cost_code_dal().FindNoDeleteById((long)thisTicket.cost_code_id);
                        }
                        var otherResList = new sdk_task_resource_dal().GetTaskResByTaskId(thisTicket.id);
                        if (otherResList != null && otherResList.Count > 0)
                        {
                            foreach (var item in otherResList)
                            {
                                if (item.resource_id != null && item.role_id != null)
                                {
                                    var resDepList = new sys_resource_department_dal().GetResDepByResAndRole((long)item.resource_id, (long)item.role_id);
                                    if (resDepList != null && resDepList.Count > 0)
                                    {
                                        ticketResIds += resDepList[0].id + ",";
                                    }
                                }
                            }

                            if (ticketResIds != "")
                            {
                                ticketResIds = ticketResIds.Substring(0, ticketResIds.Length - 1);
                            }
                        }

                        ticketCheckList = new sdk_task_checklist_dal().GetCheckByTask(thisTicket.id);
                        if (ticketCheckList != null && ticketCheckList.Count > 0)
                        {
                            ticketCheckList = ticketCheckList.OrderBy(_ => _.sort_order).ToList();
                        }
                        #region 时间轴显示相关 工单备注类型获取
                        var    slaValue     = new sdk_task_dal().GetSlaTime(thisTicket);
                        string slaTimeValue = "";
                        if (slaValue != null)
                        {
                            slaTimeValue = slaValue.ToString();
                        }
                        if (!string.IsNullOrEmpty(slaTimeValue))
                        {
                            if (slaTimeValue.Substring(0, 1) == "{")
                            {
                                slaDic = new EMT.Tools.Serialize().JsonToDictionary(slaTimeValue);
                            }
                        }
                        var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                        if (actList != null && actList.Count > 0)
                        {
                            ticketNoteTypeList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        #endregion
                        entryList = new sdk_work_entry_dal().GetList(thisTicket.id);
                    }
                }


                var ticket_type_id = Request.QueryString["ticket_type_id"];
                if (!string.IsNullOrEmpty(ticket_type_id))
                {
                    this.ticket_type_id.ClearSelection();
                    this.ticket_type_id.SelectedValue = ticket_type_id;
                }
            }
            catch (Exception msg)
            {
                Response.Write("<script>alert('" + msg.Message + "');window.close();</script>");
            }
        }
コード例 #3
0
ファイル: TicketView.aspx.cs プロジェクト: evelh/Done
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var taskId = Request.QueryString["id"];
                if (!string.IsNullOrEmpty(taskId))
                {
                    thisTicket = new sdk_task_dal().FindNoDeleteById(long.Parse(taskId));
                    if (thisTicket != null)
                    {
                        isAdd              = false;
                        thisBookMark       = new IndexBLL().GetSingBook(Request.Url.LocalPath + "?id=" + taskId, LoginUserId);
                        ticketUdfValueList = new UserDefinedFieldsBLL().GetUdfValue(DicEnum.UDF_CATE.TASK, thisTicket.id, tickUdfList);
                        thisAccount        = new CompanyBLL().GetCompany(thisTicket.account_id);
                        if (thisTicket.contact_id != null)
                        {
                            thisContact = new crm_contact_dal().FindNoDeleteById((long)thisTicket.contact_id);
                        }
                        if (thisTicket.owner_resource_id != null && thisTicket.role_id != null)
                        {
                            var resDepList = new sys_resource_department_dal().GetResDepByResAndRole((long)thisTicket.owner_resource_id, (long)thisTicket.role_id);
                            if (resDepList != null && resDepList.Count > 0)
                            {
                                proResDep = resDepList[0];
                                priRes    = new sys_resource_dal().FindNoDeleteById((long)thisTicket.owner_resource_id);
                            }
                        }

                        if (thisTicket.installed_product_id != null)
                        {
                            insPro = new crm_installed_product_dal().FindNoDeleteById((long)thisTicket.installed_product_id);
                        }
                        if (thisTicket.contract_id != null)
                        {
                            thisContract = new ctt_contract_dal().FindNoDeleteById((long)thisTicket.contract_id);
                        }
                        if (thisTicket.cost_code_id != null)
                        {
                            thisCostCode = new d_cost_code_dal().FindNoDeleteById((long)thisTicket.cost_code_id);
                        }
                        ticketCheckList = new sdk_task_checklist_dal().GetCheckByTask(thisTicket.id);
                        if (ticketCheckList != null && ticketCheckList.Count > 0)
                        {
                            ticketCheckList = ticketCheckList.OrderBy(_ => _.sort_order).ToList();
                        }
                        entryList = new sdk_work_entry_dal().GetList(thisTicket.id);

                        var otherResList = new sdk_task_resource_dal().GetTaskResByTaskId(thisTicket.id);
                        if (otherResList != null && otherResList.Count > 0)
                        {
                            ticketResList = new List <sys_resource_department>();
                            var srdDal = new sys_resource_department_dal();
                            foreach (var resRole in otherResList)
                            {
                                if (resRole.resource_id == null || resRole.role_id == null)
                                {
                                    continue;
                                }
                                var thisResDep = srdDal.GetResDepByResAndRole((long)resRole.resource_id, (long)resRole.role_id);
                                if (thisResDep != null && thisResDep.Count > 0)
                                {
                                    ticketResList.Add(thisResDep[0]);
                                }
                            }
                        }

                        if (thisTicket.service_id != null)
                        {
                            thisService = new ivt_service_dal().FindNoDeleteById((long)thisTicket.service_id);
                            if (thisService == null)
                            {
                                thisServiceBun = new ivt_service_bundle_dal().FindNoDeleteById((long)thisTicket.service_id);
                            }
                        }
                        createRes = new sys_resource_dal().FindNoDeleteById(thisTicket.create_user_id);

                        var    slaValue     = new sdk_task_dal().GetSlaTime(thisTicket);
                        string slaTimeValue = "";
                        if (slaValue != null)
                        {
                            slaTimeValue = slaValue.ToString();
                        }
                        if (!string.IsNullOrEmpty(slaTimeValue))
                        {
                            if (slaTimeValue.Substring(0, 1) == "{")
                            {
                                slaDic = new EMT.Tools.Serialize().JsonToDictionary(slaTimeValue);
                            }
                        }
                        var actList = new d_general_dal().GetGeneralByTableId((int)GeneralTableEnum.ACTION_TYPE);
                        if (actList != null && actList.Count > 0)
                        {
                            ticketNoteTypeList = actList.Where(_ => _.ext2 == ((int)DicEnum.ACTIVITY_CATE.TASK_NOTE).ToString()).ToList();
                        }
                        ticketOther     = new sdk_task_other_dal().GetTicketOther(thisTicket.id);
                        ticketOtherList = new sdk_task_other_person_dal().GetTicketOther(thisTicket.id);
                    }
                }
                var ticketIds = Request.QueryString["ids"];
                if (!string.IsNullOrEmpty(ticketIds))
                {
                    pageTicketList = new sdk_task_dal().GetTicketByIds(ticketIds);
                }


                if (thisTicket == null)
                {
                    Response.Write("<script>alert('未查询到该工单信息!');window.close();</script>");
                    return;
                }
                var history = new sys_windows_history()
                {
                    title = "工单:" + thisTicket.no + ":" + thisTicket.title,
                    url   = Request.RawUrl,
                };
                new IndexBLL().BrowseHistory(history, LoginUserId);
            }
            catch (Exception msg)
            {
                Response.Write("<script>alert('" + msg.Message + "');window.close();</script>");
            }
        }