Пример #1
0
        /// <summary>
        /// 群组验证
        /// </summary>
        /// <param name="entity">群组对象</param>
        public static string ValidateCGroupInputDto(CGroupInputDto entity)
        {
            //基础验证
            StringBuilder sb = BasicValidate <CGroupInputDto>(entity);

            if (entity.G_NAME == null)
            {
                sb.Append("群组名称不能为空.");
            }

            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        /// 添加群组
        /// </summary>
        /// <param name="cGroupInputDto">群组对象</param>
        public ReturnInfo AddGroup(CGroupInputDto cGroupInputDto)
        {
            ReturnInfo    RInfo        = new ReturnInfo();
            StringBuilder sb           = new StringBuilder();
            string        ValidateInfo = Helper.ValidateCGroupInputDto(cGroupInputDto);

            sb.Append(ValidateInfo);
            if (string.IsNullOrEmpty(ValidateInfo))
            {
                try
                {
                    CGroup entity = Mapper.Map <CGroupInputDto, CGroup>(cGroupInputDto);
                    entity.G_CreateDate = DateTime.Now;
                    entity.G_UpdateDate = DateTime.Now;

                    string MaxID2 = _cGroupRepository.GetMaxID();
                    string NowID2 = Helper.GenerateID2("G", MaxID2);
                    entity.G_ID = NowID2;
                    _unitOfWork.RegisterNew(entity);
                    bool result = _unitOfWork.Commit();
                    RInfo.IsSuccess = result;
                    RInfo.ErrorInfo = sb.ToString();
                    RInfo.ErrorInfo = NowID2;
                    return(RInfo);
                }
                catch (Exception ex)
                {
                    _unitOfWork.Rollback();
                    sb.Append(ex.Message);
                    RInfo.IsSuccess = false;
                    RInfo.ErrorInfo = sb.ToString();
                    return(RInfo);
                }
            }
            else
            {
                RInfo.IsSuccess = false;
                RInfo.ErrorInfo = sb.ToString();
                return(RInfo);
            }
        }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                switch (ctype)
                {
                case ConcentState.Concent:
                    //ContactInputDto cInputDto = new ContactInputDto();

                    //ReturnInfo r = AutofacConfig.contactService.AddContact(cInputDto);

                    //if (r.IsSuccess == true)
                    //{

                    //    this.ShowResult = ShowResult.Yes;
                    //    this.Close();
                    //    Toast("消费记录提交成功!", ToastLength.SHORT);
                    //}
                    //else
                    //{
                    //    throw new Exception(r.ErrorInfo);
                    //}


                    break;

                case ConcentState.Group:
                    if (txtName.Text.Trim().Length <= 0)
                    {
                        throw new Exception("请输入群组名称!");
                    }

                    CGroupInputDto cgroupInputDto = new CGroupInputDto();
                    cgroupInputDto.G_NAME = txtName.Text.Trim();
                    string guser = "";
                    foreach (ListViewRow rows in listView1.Rows)
                    {
                        if (Convert.ToBoolean(((Layout.frmAddUserLayout)(rows.Control)).Check.BindDisplayValue) == true)
                        {
                            if (guser.Length <= 0)
                            {
                                guser = ((Layout.frmAddUserLayout)(rows.Control)).lblUser.BindDataValue.ToString();
                            }
                            else
                            {
                                guser = guser + "," + ((Layout.frmAddUserLayout)(rows.Control)).lblUser.BindDataValue.ToString();
                            }
                        }
                    }
                    if (guser.Length <= 0)
                    {
                        throw new Exception("请选择群组成员!");
                    }
                    guser = guser + "," + Client.Session["U_ID"].ToString();
                    cgroupInputDto.G_USER       = guser;
                    cgroupInputDto.G_CreateUser = Client.Session["U_ID"].ToString();
                    cgroupInputDto.G_UpdateUser = Client.Session["U_ID"].ToString();
                    ReturnInfo r = AutofacConfig.cGroupService.AddGroup(cgroupInputDto);

                    if (r.IsSuccess == true)
                    {
                        string[] guser1  = guser.Split(',');
                        string   groupid = r.ErrorInfo;  //当返回true时,返回群组编号
                        //创建群组
                        im1.CreateGroup(guser1, groupid, cgroupInputDto.G_NAME);

                        this.ShowResult = ShowResult.Yes;
                        this.Close();
                        Toast("群组创建成功!", ToastLength.SHORT);
                    }
                    else
                    {
                        throw new Exception(r.ErrorInfo);
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                Toast(ex.Message, ToastLength.SHORT);
            }
        }