Ejemplo n.º 1
0
        public ActionResult AddContact(Tnsmtp_ContactMap model)
        {
            if (model.Gid == 0)
            {
                return(FailResult("请先添加小组!"));
            }

            DataAccess.Tnsmtp_Contact tnsmtp = new DataAccess.Tnsmtp_Contact();
            if (tnsmtp.SelectIsExtByEmail(SysUser.UserId, model.Email, model.Gid.Value))
            {
                return(FailResult("该联系人已存在!"));
            }

            DataAccess.Tnsmtp_ContactCollection tnsmtp_ContactCollection = new DataAccess.Tnsmtp_ContactCollection();
            tnsmtp_ContactCollection.ListCount(SysUser.UserId, model.Gid.Value);
            if (tnsmtp_ContactCollection.DataTable.Rows.Count > 2000)
            {
                return(FailResult("该小组已超过2000条邮箱!"));
            }


            DataAccess.Tnsmtp_Contact tnsmtp_Contact = new DataAccess.Tnsmtp_Contact();
            tnsmtp_Contact.ContactName = model.ContactName;
            tnsmtp_Contact.Email       = model.Email;
            tnsmtp_Contact.Gid         = model.Gid;
            tnsmtp_Contact.Status      = 0;
            tnsmtp_Contact.UserId      = SysUser.UserId;

            if (!tnsmtp_Contact.Insert())
            {
                return(FailResult("添加失败!"));
            }
            return(SuccessResult("添加成功!"));
        }
Ejemplo n.º 2
0
        public bool Enter(List <int> spids, int gid, int userid)
        {
            Tnsmtp_SpidermailCollection collection = new Tnsmtp_SpidermailCollection();

            if (!collection.ListBySpids(spids))
            {
                Alert("查询失败!");
                return(false);
            }
            DataAccess.Tnsmtp_ContactCollection tnsmtp_ContactCollection = new DataAccess.Tnsmtp_ContactCollection();
            tnsmtp_ContactCollection.ListCount(userid, gid);
            if (tnsmtp_ContactCollection.DataTable.Rows.Count > 2000)
            {
                Alert("该小组已超过2000条邮箱!");
                return(false);
            }



            BeginTransaction();

            for (int i = 0; i < collection.DataTable.Rows.Count; i++)
            {
                string email = collection.DataTable.Rows[i][Tnsmtp_Spidermail._EMAIL].ToString();

                Tnsmtp_Contact tnsmtp = new DataAccess.Tnsmtp_Contact();
                if (tnsmtp.SelectIsExtByEmail(userid, email, gid))
                {
                    continue;
                }

                DataAccess.Tnsmtp_Contact tnsmtp_Contact = new DataAccess.Tnsmtp_Contact();
                tnsmtp_Contact.ReferenceTransactionFrom(this.Transaction);


                tnsmtp_Contact.ContactName = collection.DataTable.Rows[i][Tnsmtp_Spidermail._FIRSTNAME].ToString();
                tnsmtp_Contact.Email       = email;
                tnsmtp_Contact.Gid         = gid;
                tnsmtp_Contact.Status      = 0;
                tnsmtp_Contact.UserId      = userid;

                if (!tnsmtp_Contact.Insert())
                {
                    Rollback();
                    Alert("添加失败!");
                    return(false);
                }
            }
            Commit();
            return(true);
        }