Exemplo n.º 1
0
        public IActionResult PutUsergroups(Usergroups usergroups)
        {
            Usergroups group = _context.Usergroups.Find(usergroups.GroupId, usergroups.ProjectId);

            group.Name         = usergroups.Name;
            group.Introduction = usergroups.Introduction;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsergroupsExists(usergroups.GroupId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     Api                   = new Api(this);
     Apps                  = new Apps(this);
     Auth                  = new Auth(this);
     Bots                  = new Bots(this);
     Channels              = new Channels(this);
     Chat                  = new Chat(this);
     Conversations         = new Conversations(this);
     Dialog                = new Dialog(this);
     Dnd                   = new Dnd(this);
     Emoji                 = new Emoji(this);
     Files                 = new Files(this);
     Groups                = new Groups(this);
     Im                    = new Im(this);
     Migration             = new Migration(this);
     Mpim                  = new Mpim(this);
     Oauth                 = new Oauth(this);
     Pins                  = new Pins(this);
     Reactions             = new Reactions(this);
     Reminders             = new Reminders(this);
     Rtm                   = new Rtm(this);
     Search                = new Search(this);
     Stars                 = new Stars(this);
     Team                  = new Team(this);
     Usergroups            = new Usergroups(this);
     Users                 = new Users(this);
     BaseUri               = new System.Uri("https://slack.com/api");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new  List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
        private void InitializeComponent()
        {
            this.BatchSendEmail.Click += new EventHandler(this.BatchSendEmail_Click);
            DataTable dt = UserGroups.GetUserGroupWithOutGuestTitle();

            foreach (DataRow dr in dt.Rows)
            {
                dr["grouptitle"] = "<img src=../images/usergroup.GIF border=0  style=\"position:relative;top:2 ;height:18 ;\">" + dr["grouptitle"];
            }
            Usergroups.AddTableData(dt);
        }
        private void BatchSendEmail_Click(object sender, EventArgs e)
        {
            #region 批量发送邮件

            if (this.CheckCookie())
            {
                groupidlist = Usergroups.GetSelectString(",");

                if (groupidlist == "" && usernamelist.Text.Trim() == "")
                {
                    base.RegisterStartupScript("", "<script>alert('您需要输入接收邮件用户名称或选取相关的用户组,因此邮件无法发送');</script>");
                    return;
                }

                int percount = 5; //每多少记录为一次等待

                //发送用户列表邮件
                if (usernamelist.Text.Trim() != "")
                {
                    DataTable dt = Users.GetEmailListByUserNameList(usernamelist.Text);
                    if (dt.Rows.Count <= 0)
                    {
                        base.RegisterStartupScript("", "<script>alert('您输入的接收邮件用户名未能查找到相关用户,因此邮件无法发送');</script>");
                        return;
                    }
                    Thread[] lThreads = new Thread[dt.Rows.Count];
                    int      count    = 0;

                    foreach (DataRow dr in dt.Rows)
                    {
                        EmailMultiThread emt = new EmailMultiThread(dr["UserName"].ToString(), dr["Email"].ToString(), subject.Text, body.Text);
                        lThreads[count] = new Thread(new ThreadStart(emt.Send));
                        lThreads[count].Start();

                        if (count >= percount)
                        {
                            Thread.Sleep(5000);
                            count = 0;
                        }
                        count++;
                    }
                }

                if (groupidlist == "")
                {
                    base.LoadRegisterStartupScript("PAGE", "window.location.href='global_usergroupsendemail.aspx';");
                    return;
                }
                ClientScript.RegisterStartupScript(this.GetType(), "Page", "<script>submit_Click();</script>");
            }

            #endregion
        }
Exemplo n.º 5
0
        public ActionResult <Post> PostPost(GroupPost groupPost)
        {
            Usergroups usergroups = new Usergroups
                                        (groupPost.projectId, groupPost.leaderAccount, groupPost.name, groupPost.content);

            _context.Usergroups.Add(usergroups);
            _context.SaveChanges();

            Post post = new Post
                            (groupPost.projectId, usergroups.GroupId, groupPost.postTime, groupPost.content, groupPost.maxMenberNum);

            _context.Post.Add(post);
            _context.SaveChanges();

            return(CreatedAtAction("GetPost", new { id = post.PostId }, post));
        }
        private void ExportUserEmails()
        {
            string groupidlist = "";

            if (this.CheckCookie())
            {
                groupidlist = Usergroups.GetSelectString(",");
            }


            if (groupidlist == "")
            {
                return;
            }

            DataTable dt = Users.GetEmailListByGroupidList(groupidlist);

            string words = "";

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    words += dt.Rows[i][1].ToString().Trim() + "; ";
                }
            }

            string filename = "Useremail.txt";

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer          = false;
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(filename));
            HttpContext.Current.Response.ContentType = "text/plain";
            this.EnableViewState = false;
            HttpContext.Current.Response.Write(words);
            HttpContext.Current.Response.End();
        }
        private void BatchSendSM_Click(object sender, EventArgs e)
        {
            #region 批量短消息发送

            if (this.CheckCookie())
            {
                groupidlist = Usergroups.GetSelectString(",");

                if (groupidlist == "")
                {
                    base.RegisterStartupScript("", "<script>alert('请您先选取相关的用户组,再点击提交按钮');</script>");
                    return;
                }

#if EntLib
                if (RabbitMQConfigs.GetConfig() != null && RabbitMQConfigs.GetConfig().SendShortMsg.Enable)//当开启errlog错误日志记录功能时
                {
                    PrivateMessageInfo pm = new PrivateMessageInfo()
                    {
                        Msgfrom      = username.Replace("'", "''"),
                        Msgfromid    = userid,
                        Folder       = int.Parse(folder.SelectedValue),
                        Subject      = subject.Text,
                        Postdatetime = Discuz.Common.Utils.GetDateTime(), //获取发送消息的系统时间
                        Message      = message.Text,
                        New          = 1                                  //标记为未读
                    };
                    Discuz.EntLib.ServiceBus.SendShortMsgClientHelper.GetSendShortMsgClient().AsyncSendShortMsgByUserGroup(groupidlist, pm);
                    return;
                }
#endif
                ClientScript.RegisterStartupScript(this.GetType(), "Page", "<script>submit_Click();</script>");
            }

            #endregion
        }
Exemplo n.º 8
0
 /// <summary>
 /// Checks if a user got a specific Usergroup
 /// </summary>
 /// <param name="usergroup"></param>
 /// <returns></returns>
 public bool HasRank(Usergroup usergroup)
 {
     return(Usergroups.Any(userRank => userRank == usergroup));
 }
Exemplo n.º 9
0
        private void BatchSendSM_Click(object sender, EventArgs e)
        {
            #region 批量短消息发送

            if (this.CheckCookie())
            {
                string groupidlist = Usergroups.GetSelectString(",");

                if (groupidlist == "")
                {
                    base.RegisterStartupScript("", "<script>alert('请您先选取相关的用户组,再点击提交按钮');</script>");
                    return;
                }

#if EntLib
                if (RabbitMQConfigs.GetConfig() != null && RabbitMQConfigs.GetConfig().SendShortMsg.Enable)//当开启errlog错误日志记录功能时
                {
                    PrivateMessageInfo pm = new PrivateMessageInfo()
                    {
                        Msgfrom      = username.Replace("'", "''"),
                        Msgfromid    = userid,
                        Folder       = int.Parse(folder.SelectedValue),
                        Subject      = subject.Text,
                        Postdatetime = Discuz.Common.Utils.GetDateTime(), //获取发送消息的系统时间
                        Message      = message.Text,
                        New          = 1                                  //标记为未读
                    };
                    Discuz.EntLib.ServiceBus.SendShortMsgClientHelper.GetSendShortMsgClient().AsyncSendShortMsgByUserGroup(groupidlist, pm);
                }
#else
                int percount = Discuz.Common.Utils.StrToInt(postcountpercircle.Text, 100); //每多少记录为一次等待
                int count    = 0;                                                          //当前记录数

                //foreach (DataRow dr in DbHelper.ExecuteDataset("SELECT [uid] ,[username]  From [" + BaseConfigs.GetTablePrefix + "users] WHERE [groupid] IN(" + groupidlist + ")").Tables[0].Rows)
                foreach (DataRow dr in Users.GetUserListByGroupidList(groupidlist).Rows)
                {
                    //DbHelper.ExecuteNonQuery("INSERT INTO [" + BaseConfigs.GetTablePrefix + "pms] (msgfrom,msgfromid,msgto,msgtoid,folder,new,subject,postdatetime,message) VALUES ('" + this.username.Replace("'", "''") + "','" + this.userid.ToString() + "','" + dr["username"].ToString().Replace("'", "''") + "','" + dr["uid"].ToString() + "','" + folder.SelectedValue + "','1','" + subject.Text + "','" + postdatetime.Text + "','" + message.Text + "')");
                    //DbHelper.ExecuteNonQuery("UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [newpmcount]=[newpmcount]+1  WHERE [uid] =" + dr["uid"].ToString());
                    //Discuz.Data.DatabaseProvider.GetInstance().SendPMToUser(username.Replace("'", "''"), userid, dr["username"].ToString().Replace("'", "''"), Convert.ToInt32(dr["uid"].ToString()), int.Parse(folder.SelectedValue), subject.Text, Convert.ToDateTime(postdatetime.Text), message.Text);
                    PrivateMessageInfo pm = new PrivateMessageInfo();
                    pm.Msgfrom      = username.Replace("'", "''");
                    pm.Msgfromid    = userid;
                    pm.Msgto        = dr["username"].ToString().Replace("'", "''");
                    pm.Msgtoid      = Convert.ToInt32(dr["uid"].ToString());
                    pm.Folder       = int.Parse(folder.SelectedValue);
                    pm.Subject      = subject.Text;
                    pm.Postdatetime = postdatetime.Text;
                    pm.Message      = message.Text;
                    pm.New          = 1;//标记为未读
                    PrivateMessages.CreatePrivateMessage(pm, 0);
                    if (count >= percount)
                    {
                        Thread.Sleep(500);
                        count = 0;
                    }
                    count++;
                }
#endif
                base.RegisterStartupScript("PAGE", "window.location.href='global_sendSMtogroup.aspx';");
            }

            #endregion
        }
Exemplo n.º 10
0
        private void BatchSendEmail_Click(object sender, EventArgs e)
        {
            #region 批量发送邮件

            if (this.CheckCookie())
            {
                string groupidlist = Usergroups.GetSelectString(",");

                if ((groupidlist == "") && (usernamelist.Text.Trim() == ""))
                {
                    base.RegisterStartupScript("", "<script>alert('您需要输入接收邮件用户名称或选取相关的用户组,因此邮件无法发送');</script>");
                    return;
                }

                int percount = 5; //每多少记录为一次等待

                //发送用户列表邮件
                if (usernamelist.Text.Trim() != "")
                {
                    //string strwhere = " WHERE [Email] Is Not null AND (";
                    //foreach (string username in usernamelist.Text.Split(','))
                    //{
                    //    if (username.Trim() != "")
                    //        strwhere += " [username] like '%" + username.Trim() + "%' OR ";
                    //}
                    //strwhere = strwhere.Substring(0, strwhere.Length - 3) + ")";

                    //DataTable dt = DbHelper.ExecuteDataset("SELECT [username],[Email]  From [" + BaseConfigs.GetTablePrefix + "users] " + strwhere).Tables[0];
                    DataTable dt = Users.GetEmailListByUserNameList(usernamelist.Text);
                    if (dt.Rows.Count <= 0)
                    {
                        base.RegisterStartupScript("", "<script>alert('您输入的接收邮件用户名未能查找到相关用户,因此邮件无法发送');</script>");
                        return;
                    }
                    base.LoadRegisterStartupScript("PAGE", "window.location.href='global_usergroupsendemail.aspx';");

                    Thread[] lThreads = new Thread[dt.Rows.Count];
                    int      count    = 0;

                    foreach (DataRow dr in dt.Rows)
                    {
                        EmailMultiThread emt = new EmailMultiThread(dr["UserName"].ToString(), dr["Email"].ToString(), subject.Text, body.Text);
                        lThreads[count] = new Thread(new ThreadStart(emt.Send));
                        lThreads[count].Start();

                        if (count >= percount)
                        {
                            Thread.Sleep(5000);
                            count = 0;
                        }
                        count++;

                        //ThreadPool.QueueUserWorkItem(new WaitCallback(SendMail),string.Format("http://bbs.ent.tom.com/forum/view_thread.php?forumid=1&threadid={0}&backurl=http%3A%2F%2Fbbs.ent.tom.com%2Fforum%2Flist_thread.php%3Fforumid%3D1%26page%3D1%26sort%3D0",PageNumber.ToString()));
                    }
                }

                //发送用户组邮件
                if (groupidlist != "")
                {
                    //DataTable dt = DbHelper.ExecuteDataset("SELECT [username],[Email]  From [" + BaseConfigs.GetTablePrefix + "users] WHERE [Email] Is Not null AND [Email]<>'' AND [groupid] IN(" + groupidlist + ")").Tables[0];
                    DataTable dt       = Users.GetEmailListByGroupidList(groupidlist);
                    Thread[]  lThreads = new Thread[dt.Rows.Count];
                    int       count    = 0;

                    foreach (DataRow dr in dt.Rows)
                    {
                        EmailMultiThread emt = new EmailMultiThread(dr["UserName"].ToString(), dr["Email"].ToString(), subject.Text, body.Text);
                        lThreads[count] = new Thread(new ThreadStart(emt.Send));
                        lThreads[count].Start();

                        if (count >= percount)
                        {
                            Thread.Sleep(5000);
                            count = 0;
                        }
                        count++;

                        //ThreadPool.QueueUserWorkItem(new WaitCallback(SendMail),string.Format("http://bbs.ent.tom.com/forum/view_thread.php?forumid=1&threadid={0}&backurl=http%3A%2F%2Fbbs.ent.tom.com%2Fforum%2Flist_thread.php%3Fforumid%3D1%26page%3D1%26sort%3D0",PageNumber.ToString()));
                    }
                }
                base.RegisterStartupScript("PAGE", "window.location.href='global_usergroupsendemail.aspx';");
            }

            #endregion
        }