Ejemplo n.º 1
0
        /// <summary>
        /// 执行联系人活动信息
        /// </summary>
        public bool ExectueContactAction(ExexuteContactDto param, long userId)
        {
            if (string.IsNullOrEmpty(param.ids))
            {
                return(false);
            }
            if (!param.isHasNote && !param.isHasTodo)
            {
                return(false);
            }
            var conList = GetListByIds(param.ids);

            if (conList == null || conList.Count == 0)
            {
                return(false);
            }
            var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now);
            var caDal   = new com_activity_dal();
            var accBll  = new CompanyBLL();

            foreach (var contact in conList)
            {
                if (param.isHasNote)
                {
                    var thisNote = new com_activity()
                    {
                        id             = caDal.GetNextIdCom(),
                        cate_id        = (int)DicEnum.ACTIVITY_CATE.NOTE,
                        account_id     = contact.account_id,
                        action_type_id = param.note_action_type,
                        contact_id     = contact.id,
                        object_id      = contact.id,
                        object_type_id = (int)DicEnum.OBJECT_TYPE.CONTACT,
                        description    = param.note_content,
                        create_time    = timeNow,
                        update_time    = timeNow,
                        create_user_id = userId,
                        resource_id    = userId,
                        update_user_id = userId,
                    };
                    caDal.Insert(thisNote);
                    OperLogBLL.OperLogAdd <com_activity>(thisNote, thisNote.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ACTIVITY, "新增备注");
                }
                if (param.isHasTodo)
                {
                    long?resId = param.assignRes;
                    if (resId == -1)
                    {
                        var thisAcc = accBll.GetCompany(contact.account_id);
                        if (thisAcc != null)
                        {
                            resId = thisAcc.resource_id;
                        }
                    }
                    var thisTodo = new com_activity()
                    {
                        id             = caDal.GetNextIdCom(),
                        cate_id        = (int)DicEnum.ACTIVITY_CATE.TODO,
                        account_id     = contact.account_id,
                        action_type_id = param.todo_action_type,
                        contact_id     = contact.id,
                        object_id      = contact.id,
                        resource_id    = resId,
                        object_type_id = (int)DicEnum.OBJECT_TYPE.CONTACT,
                        description    = param.todo_content,
                        create_time    = timeNow,
                        update_time    = timeNow,
                        create_user_id = userId,
                        update_user_id = userId,
                        start_date     = param.startDate,
                        end_date       = param.endDate,
                    };
                    caDal.Insert(thisTodo);
                    OperLogBLL.OperLogAdd <com_activity>(thisTodo, thisTodo.id, userId, DicEnum.OPER_LOG_OBJ_CATE.ACTIVITY, "新增备注");
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        protected bool isTemp = false;  // 是否是查看联系人活动模板
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var groupId = Request.QueryString["groupId"];
                if (!string.IsNullOrEmpty(groupId))
                {
                    pageGroup = conBll.GetGroupById(long.Parse(groupId));
                }
                if (pageGroup != null && Request.QueryString["isGroup"] == "1")
                {
                    var contactList = conBll.GetGroupContactByGroup(pageGroup.id);
                    if (contactList != null && contactList.Count > 0)
                    {
                        var accoubtId = Request.QueryString["accountId"];
                        contactList.ForEach(_ => {
                            var thisContact = conBll.GetContact(_.contact_id);
                            if (thisContact != null)
                            {
                                if (!string.IsNullOrEmpty(accoubtId))
                                {
                                    if (thisContact.account_id.ToString() == Request.QueryString["accountId"])
                                    {
                                        conIds += _.contact_id.ToString() + ",";
                                    }
                                }
                                else
                                {
                                    conIds += _.contact_id.ToString() + ",";
                                }
                            }
                        });
                        if (!string.IsNullOrEmpty(conIds))
                        {
                            conIds = conIds.Substring(0, conIds.Length - 1);
                        }
                    }
                }
                if (string.IsNullOrEmpty(conIds))
                {
                    conIds = Request.QueryString["ids"];
                }
                if (!string.IsNullOrEmpty(conIds))
                {
                    conIdArr = conIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                }
                chooseType = Request.QueryString["chooseType"];
                if (noteTypeList != null && noteTypeList.Count > 0)
                {
                    noteTypeList = noteTypeList.Where(_ => _.parent_id == (int)DTO.DicEnum.CALENDAR_DISPLAY.LIST).ToList();
                }
                if (!string.IsNullOrEmpty(Request.QueryString["tempId"]))
                {
                    actionTemp = conBll.GetTempById(long.Parse(Request.QueryString["tempId"]));
                }
                if (actionTemp != null && Request.QueryString["isTemp"] == "1")
                {
                    isTemp = true;
                }
                if (string.IsNullOrEmpty(conIds) && (!isTemp))
                {
                    Response.Write($"<script>alert('请选择相关联系人!');window.close();</script>");
                    return;
                }

                if (IsPostBack)
                {
                    ExexuteContactDto param = new ExexuteContactDto();
                    param.ids = conIds;
                    if (!string.IsNullOrEmpty(Request.Form["ckNote"]) && Request.Form["ckNote"].Equals("on"))
                    {
                        param.isHasNote = true;
                    }
                    if (param.isHasNote)
                    {
                        param.note_action_type = int.Parse(Request.Form["note_action_type"]);
                        param.note_content     = Request.Form["note_content"];
                    }
                    if (!string.IsNullOrEmpty(Request.Form["ckTodo"]) && Request.Form["ckTodo"].Equals("on"))
                    {
                        param.isHasTodo = true;
                    }
                    if (param.isHasTodo)
                    {
                        param.todo_action_type = int.Parse(Request.Form["todo_action_type"]);
                        param.todo_content     = Request.Form["todo_content"];
                        param.assignRes        = long.Parse(Request.Form["todo_resource_id"]);
                        param.startDate        = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["startDate"]));
                        param.endDate          = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Parse(Request.Form["endDate"]));
                    }
                    var result = false;
                    if (param.isHasTodo || param.isHasNote)
                    {
                        result = conBll.ExectueContactAction(param, LoginUserId);
                    }

                    ClientScript.RegisterStartupScript(this.GetType(), "提示信息", $"<script>alert('执行{(result?"成功":"失败")}');window.close();</script>");
                }
            }
            catch (Exception msg)
            {
                Response.Write($"<script>alert('{msg.Message}');window.close();</script>");
            }
        }