コード例 #1
0
        /// <summary>
        /// 获取代理设置列表
        /// </summary>
        /// <param name="para"></param>
        /// <param name="searchValue"></param>
        /// <returns></returns>
        public JsonResult GetAgentSetList(DataTableParameter para, string searchValue)
        {
            int total    = 0;
            var dataList = GetAgentSetList(Userinfo, out total, para, searchValue);

            if (dataList != null)
            {
                foreach (var item in dataList)
                {
                    string strHtml   = "<div class='row'><div class='col-md-8'>{0}</div><div class='col-md-4' style='text-align:right'>{1}</div></div>";
                    string linkAList = "<a class='glyphicon glyphicon-pencil edit' title='修改' Id='" + item.id + "'></a>";
                    linkAList          += "&nbsp;&nbsp;&nbsp;" + "<a class='glyphicon glyphicon-eye-open detail' title='详情' id='" + item.id + "' ></a>";
                    strHtml             = string.Format(strHtml, item.b_DelegateName, linkAList);
                    item.b_DelegateName = strHtml;
                    if (!string.IsNullOrEmpty(item.b_StartDateMinute))
                    {
                        item.b_StartDate = item.b_StartDate + " " + item.b_StartDateMinute;
                    }

                    if (!string.IsNullOrEmpty(item.b_EndDateMinute))
                    {
                        item.b_EndDate = item.b_EndDate + " " + item.b_EndDateMinute;
                    }
                    item.AgentModuleList = new List <string>(item.b_AgentContent.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries));
                    if (item.AgentModuleList.Count > 0)
                    {
                        string agentContext = "";
                        foreach (var agentModule in item.AgentModuleList)
                        {
                            string value = EnumDescription.GetFieldText(EnumDescription.GetEnumByTextUseDefault <AgentModule>(agentModule));
                            agentContext = agentContext + value + ";";
                        }
                        item.b_AgentContent = agentContext;
                    }
                }
            }
            return(Json(new
            {
                sEcho = para.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = total,
                aaData = dataList
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <returns></returns>
        public JsonResult SaveAgentSet(AgentSetModel model)
        {
            var retModel = new JsonReturnModel();

            try
            {
                //限制输入的代理人不能为自己
                if (model.b_AgentName == Userinfo.UserName)
                {
                    retModel.AddError("errorMessage", "代理人选择不能为自己!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                var b_AgentName = IdentityDA.GetIdentityByKeyedName(inn, model.b_AgentName);
                if (b_AgentName.isError())
                {
                    retModel.AddError("errorMessage", "找不到对应的代理人!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                if (model.AgentModuleList == null || model.AgentModuleList.Count == 0)
                {
                    retModel.AddError("errorMessage", "请您选择授权模块!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                string value = string.Join(";", model.AgentModuleList.ToArray()) + ";";
                model.b_AgentContent = value;

                //验证输入的时间是否正确
                string b_StartDate = !string.IsNullOrEmpty(model.b_StartDateMinute) ? model.b_StartDate + " " + model.b_StartDateMinute : model.b_StartDate;
                string b_EndDate   = !string.IsNullOrEmpty(model.b_EndDateMinute) ? model.b_EndDate + " " + model.b_EndDateMinute : model.b_EndDate;

                DateTime StartDate;
                if (!DateTime.TryParse(b_StartDate, out StartDate))
                {
                    retModel.AddError("errorMessage", "输入的生效时间错误!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                DateTime EndDate;
                if (!DateTime.TryParse(b_EndDate, out EndDate))
                {
                    retModel.AddError("errorMessage", "输入的终止时间错误!");
                    return(Json(retModel, JsonRequestBehavior.AllowGet));
                }

                Item item = null;
                if (string.IsNullOrEmpty(model.id))
                {
                    item = inn.newItem("b_AgentSet", "add");
                }
                else
                {
                    item = inn.newItem("b_AgentSet", "edit");
                    item.setAttribute("id", model.id);
                }
                item.setProperty("b_delegatename", model.b_DelegateName);
                item.setProperty("b_agentname", model.b_AgentName);
                item.setProperty("b_startdate", model.b_StartDate);
                item.setProperty("b_startdateminute", model.b_StartDateMinute);
                item.setProperty("b_enddate", model.b_EndDate);
                item.setProperty("b_enddateminute", model.b_EndDateMinute);
                item.setProperty("b_agentcontent", model.b_AgentContent);
                item.setProperty("b_isvalid", model.b_IsValid);
                item.setProperty("b_agentreason", model.b_AgentReason);
                var result = item.apply();
                if (result.isError())
                {
                    retModel.AddError("errorMessage", result.getErrorString());
                }
                else
                {
                    if (model.b_IsValid == "1")
                    {
                        string agentContext = "";
                        if (model.AgentModuleList.Count > 0)
                        {
                            foreach (var agentModule in model.AgentModuleList)
                            {
                                string moduleStr = EnumDescription.GetFieldText(EnumDescription.GetEnumByTextUseDefault <AgentModule>(agentModule));
                                agentContext = agentContext + moduleStr + ";";
                            }
                        }
                        WorkFlowBll.SendAgentEmail(inn, model.b_DelegateName, model.b_AgentName, StartDate, EndDate, agentContext);
                    }
                }
            }
            catch (Exception ex)
            {
                retModel.AddError("errorMessage", ex.Message);
            }
            return(Json(retModel, JsonRequestBehavior.AllowGet));
        }