Exemplo n.º 1
0
      public async void WriteUser(string command, Moderator user)
      {
         var client = new SlackAPI.SlackTaskClient(Config.SlackToken);
         if (!client.ConnectAsync().Result.ok)
         {
            return;
         }

         string userId = "";

         foreach (var x in client.UserLookup)
         {
            if (String.Equals(x.Value.name, user.Name, StringComparison.InvariantCultureIgnoreCase))
            {
               userId = x.Value.id;
               break;
            }
         }

         var channel = await client.JoinDirectMessageChannelAsync(userId);

         var result = await client.PostMessageAsync(channel.channel.id, command, "Consensusbot");
         if (result.ok)
         {
            return;
         }
         else
         {
            Console.Write("something went wrong");
         }
      }
Exemplo n.º 2
0
        /// <summary>
        /// 插入版主信息
        /// </summary>
        /// <param name="moderator">Moderator实体类</param>
        /// <returns></returns>
        public int Insert(Moderator moderator)
        {
            string sql = "insert into Moderator values(@moderator_id,@division_id,@member_id)";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@moderator_id", moderator.ModeratorId),
                new SqlParameter("@division_id", moderator.DivisionId),
                new SqlParameter("@member_id", moderator.MemberId)
            };
            return(SqlHelper.ExecuteNonQuery(sql, parameters));
        }
Exemplo n.º 3
0
        public ActionResult AddMod(Moderator moderator)
        {
            if (db.ModeratorList.Contains(moderator))
            {
                return(BadRequest());
            }
            db.ModeratorList.Add(moderator);
            db.SaveChanges();

            return(RedirectToAction("Moderators"));
        }
Exemplo n.º 4
0
        public Forum(Tenant tenantId, ForumId forumId, Creator creator, Moderator moderator, string subject, string description, string exclusiveOwner)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "The tenant must be provided.");
            AssertionConcern.AssertArgumentNotNull(forumId, "The forum id must be provided.");
            AssertionConcern.AssertArgumentNotNull(creator, "The creator must be provided.");
            AssertionConcern.AssertArgumentNotNull(moderator, "The moderator must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(subject, "The subject must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(description, "The description must be provided.");

            Apply(new ForumStarted(tenantId, forumId, creator, moderator, subject, description, exclusiveOwner));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Get()
        {
            var creator = new Moderator("un", "pw", "dd", "::1");
            await _context.Users.AddAsync(creator);

            await _context.SaveChangesAsync();

            var users = await _context.Users.ToListAsync();

            return(Ok(users));
        }
Exemplo n.º 6
0
        public static Moderator ModeratorWithoutPassword(this Moderator moderator)
        {
            if (moderator == null)
            {
                return(null);
            }

            moderator.Password = null;
            moderator.Role     = null;
            return(moderator);
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "Username")] Moderator moderator)
        {
            if (ModelState.IsValid)
            {
                db.Moderators.Add(moderator);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(moderator));
        }
 public bool changeModLevel(int forumId, int subForumId, string moderatorName, Moderator.modLevel newLevel)
 {
     try
     {
         return httpProxy.changeModLevel(forumId, subForumId, moderatorName, newLevel);
     }
     catch (FaultException fe)
     {
         throw new Exception(fe.Message);
     }
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Poster    bob       = new Poster("BobBobski");
            Moderator jill      = new Moderator("JillJill");
            Guest     someGuest = new Guest();

            bob.PostComment("comment 1");
            bob.PostComment("comment 2");
            bob.CheckStats();
            jill.BanUser(bob, "bad bob");
            someGuest.ReadComment("comment some comment");
        }
Exemplo n.º 10
0
        public ActionResult updatesalmod(Moderator moderator)
        {
            moderatorRepository.Update(moderator);
            Notice notice = new Notice();

            notice.Massage  = "Your Salary Has been Changed by Admin/Moderator Panel";
            notice.Send_For = moderator.ModeratorId;
            notice.Send_by  = Session["UserId"].ToString();
            notice.Status   = "Unread";
            noticeRepository.Insert(notice);
            return(RedirectToAction("ModeratorList", "Admin"));
        }
Exemplo n.º 11
0
        protected List <Moderator> GetModerators()
        {
            var moderators = this.Get <DataBroker>().GetAllModerators();

            var modsSorted = new List <Moderator>();

            foreach (var mod in moderators)
            {
                if (mod.IsGroup)
                {
                    continue;
                }

                var sortedMod = new Moderator
                {
                    Name        = mod.Name,
                    ModeratorID = mod.ModeratorID,
                    Email       = mod.Email,
                    Block       = new UserBlockFlags(mod.BlockFlags),
                    Avatar      = mod.Avatar,
                    AvatarImage = mod.AvatarImage,
                    DisplayName = mod.DisplayName,
                    Style       = mod.Style
                };

                // Check if Mod is already in modsSorted
                if (modsSorted.Find(s => s.Name.Equals(sortedMod.Name) && s.ModeratorID.Equals(sortedMod.ModeratorID))
                    != null)
                {
                    continue;
                }

                // Get All Items from that MOD
                var modList     = moderators.Where(m => m.Name.Equals(sortedMod.Name)).ToList();
                var forumsCount = modList.Count;

                sortedMod.ForumIDs = new ModeratorsForums[forumsCount];

                for (var i = 0; i < forumsCount; i++)
                {
                    var forumsId = new ModeratorsForums
                    {
                        ForumID = modList[i].ForumID, ForumName = modList[i].ForumName
                    };

                    sortedMod.ForumIDs[i] = forumsId;
                }

                modsSorted.Add(sortedMod);
            }

            return(modsSorted);
        }
Exemplo n.º 12
0
                public async Task Type([Remainder] SocketGuildUser user)
                {
                    Moderator mod = user.ToModerator();

                    if (mod == null)
                    {
                        await ReplyAsync($":x: User {user.Mention} is not a moderator.");

                        return;
                    }
                    await ReplyAsync($":white_check_mark: User {user.Mention} is a type {mod.modType.GetHashCode()} moderator.");
                }
Exemplo n.º 13
0
        public static async Task InitializeAsync(UserManager <User> userManager, RoleManager <IdentityRole> roleManager,
                                                 IOptions <PhotoConfig> photoOptions, IOptions <UsersConfig> usersOptions)
        {
            await AddRoleAsync(roleManager, "administrator");
            await AddRoleAsync(roleManager, "moderator");
            await AddRoleAsync(roleManager, "employer");
            await AddRoleAsync(roleManager, "freelancer");

            foreach (var moderatorData in usersOptions.Value.Moderators)
            {
                var moderator = new Moderator
                {
                    Name             = moderatorData.Name,
                    Surname          = moderatorData.Surname,
                    Email            = moderatorData.Email,
                    UserName         = moderatorData.UserName,
                    SignUpDate       = DateTime.Now,
                    Balance          = new Balance(),
                    ProfilePhotoName = photoOptions.Value.DefaultPhoto
                };

                await AddUserAsync(moderator, moderatorData.Password, moderator.Role);
            }

            foreach (var administratorData in usersOptions.Value.Administrators)
            {
                var administrator = new Administrator
                {
                    Name             = administratorData.Name,
                    Surname          = administratorData.Surname,
                    Email            = administratorData.Email,
                    UserName         = administratorData.UserName,
                    SignUpDate       = DateTime.Now,
                    Balance          = new Balance(),
                    ProfilePhotoName = photoOptions.Value.DefaultPhoto
                };

                await AddUserAsync(administrator, administratorData.Password, administrator.Role);
            }

            async Task AddUserAsync(User user, string password, string role)
            {
                if (await userManager.FindByNameAsync(user.UserName) is null)
                {
                    var result = await userManager.CreateAsync(user, password);

                    if (result.Succeeded)
                    {
                        await userManager.AddToRoleAsync(user, role);
                    }
                }
            }
        }
Exemplo n.º 14
0
        public bool izmeniModeratora(ModeratorLOC moderatorLoc)
        {
            bool      rezultat_upisa = true;
            Moderator moderator_     = SkolaEntities.Moderators.FirstOrDefault(p => p.sifra_moderatora == moderatorLoc.sifra_moderatora);

            if (moderator_.korisnicko_ime != moderatorLoc.korisnicko_ime)
            {
                bool moderator_postoji = traziModeratora(moderatorLoc.korisnicko_ime);

                if (moderator_postoji == false)
                {
                    Moderator moderator = SkolaEntities.Moderators.FirstOrDefault(m => m.sifra_moderatora == moderatorLoc.sifra_moderatora);
                    moderator.ime            = moderatorLoc.ime;
                    moderator.prezime        = moderatorLoc.prezime;
                    moderator.korisnicko_ime = moderatorLoc.korisnicko_ime;
                    moderator.datum_rodjenja = moderatorLoc.datum_rodjenja;

                    try
                    {
                        SkolaEntities.SubmitChanges();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Greska pri upisu moderatora u bazu " + e);
                        rezultat_upisa = false;
                    }
                }
                else
                {
                    rezultat_upisa = false;
                }
            }
            else
            {
                Moderator moderator = SkolaEntities.Moderators.FirstOrDefault(m => m.sifra_moderatora == moderatorLoc.sifra_moderatora);
                moderator.ime            = moderatorLoc.ime;
                moderator.prezime        = moderatorLoc.prezime;
                moderator.datum_rodjenja = moderatorLoc.datum_rodjenja;

                try
                {
                    SkolaEntities.SubmitChanges();
                }
                catch (Exception e)
                {
                    Console.WriteLine("Greska pri upisu moderatora u bazu " + e);
                    rezultat_upisa = false;
                }
            }


            return(rezultat_upisa);
        }
Exemplo n.º 15
0
        public async Task <IActionResult> RemoveModerator(string userId)
        {
            Moderator mod = _db.Moderators
                            .Include(m => m.User)
                            .FirstOrDefault(m => m.UserId == userId);
            await _userManager.RemoveClaimAsync(mod.User, new Claim("ModerateShop", mod.ShopId.ToString()));

            _db.Moderators.Remove(mod);
            _db.SaveChanges();

            return(RedirectToAction("Moderators"));
        }
Exemplo n.º 16
0
 public bool EditModerator(int id, Moderator moderator)
 {
     try
     {
         using (SqlConnection connection = new SqlConnection(path))
         {
             var command = connection.CreateCommand();
             command.CommandType = CommandType.StoredProcedure;
             command.CommandText = "dbo.EditModerator";
             var loginParametr = new SqlParameter()
             {
                 DbType        = DbType.String,
                 ParameterName = "@login",
                 Value         = moderator.Login,
                 Direction     = ParameterDirection.Input
             };
             var passParametr = new SqlParameter()
             {
                 DbType        = DbType.String,
                 ParameterName = "@password",
                 Value         = moderator.Password,
                 Direction     = ParameterDirection.Input
             };
             var roleParametr = new SqlParameter()
             {
                 DbType        = DbType.String,
                 ParameterName = "@role",
                 Value         = moderator.ModeratorRole,
                 Direction     = ParameterDirection.Input
             };
             var idParametr = new SqlParameter()
             {
                 DbType        = DbType.Int32,
                 ParameterName = "@id",
                 Value         = id,
                 Direction     = ParameterDirection.Input
             };
             command.Parameters.Add(idParametr);
             command.Parameters.Add(loginParametr);
             command.Parameters.Add(passParametr);
             command.Parameters.Add(roleParametr);
             connection.Open();
             command.ExecuteNonQuery();
         }
         return(true);
     }
     catch (SqlException e)
     {
         _logger.Error(e.Message);
         return(false);
     }
 }
        //For Authenticate,
        public async Task <Moderator> CheckModeratorExist(string login)
        {
            Moderator foundedModerator = await context.Moderators.FirstOrDefaultAsync(moderator => moderator.Login == login);

            if (foundedModerator == null)
            {
                return(null);
            }
            else
            {
                return(foundedModerator);
            }
        }
        public async Task <Moderator> CheckModeratorExist(Guid id)
        {
            Moderator foundedModerator = await context.Moderators.FirstOrDefaultAsync(moderator => moderator.Id == id);

            if (foundedModerator == null)
            {
                return(null);
            }
            else
            {
                return(foundedModerator);
            }
        }
Exemplo n.º 19
0
        private async Task <SaveResult> EditEntityAsync(CalendarViewModel model, Moderator record)
        {
            var saveResult    = new SaveResult();
            var editModerator = await _context.Moderator.FindAsync(record.Id);

            editModerator.ToEntity(record.MemberId, model.Id, model.SessionUserId);

            _context.Update(editModerator);
            await _context.SaveChangesAsync();

            saveResult.IsSuccess = true;
            return(saveResult);
        }
Exemplo n.º 20
0
        public ActionResult Delete(int id)
        {
            Moderator mod = db.ModeratorList.Find(id);

            if (mod == null)
            {
                return(NotFound());
            }
            db.ModeratorList.Remove(mod);
            db.SaveChanges();

            return(RedirectToAction("Moderators"));
        }
Exemplo n.º 21
0
        public void GetEducationMaterial_EducationMaterialFromDAL_CorrectMappingToEducationMaterialDTO()
        {
            User user = new Moderator(1, "test name", "test surname", 1);

            SecurityContext.SetUser(user);
            var educationManterialService = GetEducationMaterialService();

            var actualEducationMaterialDTO = educationManterialService.GetEducationMaterial(0).GetEnumerator().Current;

            Assert.True(actualEducationMaterialDTO.EducationMaterialId == 1 &&
                        actualEducationMaterialDTO.Name == "testName" &&
                        actualEducationMaterialDTO.Content == "testContent");
        }
Exemplo n.º 22
0
        public void GetRoutesList_RoutesListFromDAL_CorrectMappingToRoutesListDTO()
        {
            User user = new Moderator(1, "test name", "test surname", 1);

            SecurityContext.SetUser(user);
            var routtesListService = GetRoutesListService();

            var actualRoutesListDTO = routtesListService.GetRoutesList(0).GetEnumerator().Current;

            Assert.True(actualRoutesListDTO.RouteId == 1 &&
                        actualRoutesListDTO.Name == "testName" &&
                        actualRoutesListDTO.Content == "testContent");
        }
Exemplo n.º 23
0
        public ActionResult AddModerator(Moderator moderator)
        {
            Forum forum = forumDAO.GetForumByName(moderator.ForumName);

            if (!moderatorDAO.IsModerator(moderator.UserId, forum.ID))
            {
                moderatorDAO.AddModerator(moderator.UserId, moderator.Username, moderator.ForumName);
                return(Ok(moderator));
            }
            else
            {
                return(StatusCode(409));
            }
        }
Exemplo n.º 24
0
 public void Add(Moderator moderator)
 {
     try {
         int    lastID        = this.Add((AbstractUser)moderator);
         String QueryTemplate = "INSERT INTO Users_Moderators (Id, Administrator) VALUES ({0}, {1})";
         String Query         = String.Format(QueryTemplate, lastID, Session.user.Id);
         this.ExecInsert(Query);
         EmailSender.UserAdd((AbstractUser)moderator, "Moderador");
     } catch (Exception ex) {
         throw ex;
     } finally {
         this.SqlConnection.Close();
     }
 }
Exemplo n.º 25
0
        public IActionResult Ekle(Moderator moderator, string img)
        {
            var id       = HttpContext.Session.GetInt32("id");
            var filepath = @"wwwroot/profile_images";

            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }
            string path = "/images/man-200x200.png";

            if (!string.IsNullOrEmpty(img))
            {
                var    t          = img.Replace("data:image/jpeg;base64,", "");
                byte[] imagebytes = Convert.FromBase64String(t);
                string filename   = "IMG_" + id + "_" + DateTime.UtcNow.ToString("yyyyMMdd_hhmmss") + new Random().Next(0, 99);
                var    ext        = ".png";
                filename += ext;
                string fullpath = Path.Combine(filepath, filename);


                using (var stream = new FileStream(fullpath, FileMode.Create, FileAccess.ReadWrite))
                {
                    try
                    {
                        using (BinaryWriter bw = new BinaryWriter(stream))
                        {
                            bw.Write(imagebytes);
                        }
                        path = fullpath.Replace("wwwroot", "");
                    }
                    catch (Exception ex)
                    {
                        return(Content("Fotoğraf yüklenirken bir sorun oluştu. : " + ex.Message));
                    }
                }
            }

            SHA1 sha = new SHA1CryptoServiceProvider();

            string sifrelenmisveri = Convert.ToBase64String(sha.ComputeHash(Encoding.UTF8.GetBytes(moderator.Profil.Sifre)));

            moderator.Profil.Sifre    = sifrelenmisveri;
            moderator.Profil.Rol      = 2;
            moderator.Profil.Fotograf = path;
            db.Hesaplar.Add(moderator.Profil);
            db.Moderatorler.Add(moderator);
            db.SaveChanges();
            return(Redirect("~/Moderator/Listele"));
        }
Exemplo n.º 26
0
        public async Task <IActionResult> CreateModerator(Moderator moderator)
        {
            if (!AdminAuthorization())
            {
                return(Unauthorized());
            }
            database.Moderator.Add(moderator);
            await database.SaveChangesAsync();

            await LogAction("created an admin", moderator.Id, moderator.Login);


            return(Ok());
        }
Exemplo n.º 27
0
        public IActionResult EditModerator(string userId)
        {
            Moderator mod = _db.Moderators.FirstOrDefault(m => m.UserId == userId);

            if (mod == null)
            {
                mod = new Moderator()
                {
                    UserId = userId
                };
            }
            ViewBag.Shops = _db.Shops;
            return(View(mod));
        }
 public ActionResult Create(Moderator moderator)
 {
     try
     {
         moderator.ApplicationId = User.Identity.GetUserId();
         context.Moderators.Add(moderator);
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        private static void ModeratorRequestCallBack()
        {
            Moderator mod = new Moderator();

            if (mod.getanswer())
            {
                network.sendRequestAnswer(true);
                togglerole();
            }
            else
            {
                network.sendRequestAnswer(false);
            }
        }
Exemplo n.º 30
0
        // GET: Rooms
        public ActionResult Index()
        {
            string user = AppHelper.GetVmtUser();

            ViewBag.Mod = user.ToLower();
            Moderator mod = db.Moderators.Find(user);

            if (mod != null)
            {
                return(View(mod.RoomsAllowed));
            }
            //return empty room list
            return(View(new List <Room>()));
        }
Exemplo n.º 31
0
        public static bool Update(Moderator todo)
        {
            bool state = false;

            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(UPDATE, connection);

                command.Parameters.AddWithValue("@idUser", todo.idUser);
                state = command.ExecuteNonQuery() != 0;
            }
            return(state);
        }
Exemplo n.º 32
0
        //ADD Moderator
        public static Moderator Insert(Moderator todo)
        {
            using (SqlConnection connection = DataBase.GetConnection())
            {
                connection.Open();
                SqlCommand command = new SqlCommand(INSERT, connection);

                command.Parameters.AddWithValue("@idUser", todo.idUser);

                int id = Int32.Parse(command.ExecuteScalar().ToString());
                todo.idModerator = id;
            }
            return(todo);
        }
Exemplo n.º 33
0
        private void CommandShow(ChatCommand cmd, Moderator mod, bool broadcast = true)
        {
            var usage = "usage: $vote show [ {motion id} | ]";
             var opts = cmd.Args.Split(' ');

             // args empty
             if (opts.GetUpperBound(0) == 0)
             {
            WriteUser(usage, mod);
            return;
             }

             try
             {
            var motion = Motion.GetMotion(Int32.Parse(opts[0]));
            var message = new StringBuilder();
            message.AppendFormat("Motion [{0}]", motion.Id.ToString());
            message.AppendFormat("{{0}/{1}/{2}}", motion.Votes.Yes, motion.Votes.No, motion.Votes.Abstain);
            message.AppendFormat(": {0}  #  {1}", motion.Text, motion.PostUrl);

            if (broadcast)
            {
               WriteChannel(message.ToString(),ChatProviderType.All);
            }
            else
            {
               WriteUser(message.ToString(),mod,cmd.Source);
            }

             }
             catch
             {
            WriteUser(usage, mod,cmd.Source);
             }
        }
Exemplo n.º 34
0
        protected List<Moderator> GetModerators()
        {
            var moderators = this.Get<YafDbBroker>().GetAllModerators();

            var modsSorted = new List<Moderator>();

            foreach (SimpleModerator mod in moderators)
            {
                if (mod.IsGroup)
                {
                    continue;
                }

                var sortedMod = new Moderator
                    {
                        Name = mod.Name,
                        ModeratorID = mod.ModeratorID,
                        Email = mod.Email,
                        Avatar = mod.Avatar,
                        AvatarImage = mod.AvatarImage,
                        DisplayName = mod.DisplayName,
                        Style = mod.Style
                    };

                // Check if Mod is already in modsSorted
                if (modsSorted.Find(s => s.Name.Equals(sortedMod.Name) && s.ModeratorID.Equals(sortedMod.ModeratorID))
                    != null)
                {
                    continue;
                }

                // Get All Items from that MOD
                var modList = moderators.Where(m => m.Name.Equals(sortedMod.Name)).ToList();
                var forumsCount = modList.Count();

                sortedMod.ForumIDs = new ModeratorsForums[forumsCount];

                for (int i = 0; i < forumsCount; i++)
                {
                    var forumsId = new ModeratorsForums
                        { ForumID = modList[i].ForumID, ForumName = modList[i].ForumName };

                    sortedMod.ForumIDs[i] = forumsId;
                }

                modsSorted.Add(sortedMod);
            }

            return modsSorted;
        }
Exemplo n.º 35
0
        private void AddModerators()
        {

            ModeratorCollection moderators = new ModeratorCollection();

            //------------------ old ------------------------
            
            string[] strForumUser=_Request.Get("forum-user",Method.Post,string.Empty).Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries );

            foreach (string str in strForumUser)
            {
                Moderator m = new Moderator();
                m.SortOrder = _Request.Get<int>("sortorder." + str, Method.Post, 0);
                m.UserID = int.Parse(str.Split('.')[1]);
                m.ForumID = int.Parse(str.Split('.')[0]);
                m.BeginDate = DateTimeUtil.ParseBeginDateTime(_Request.Get("begindate." + str, Method.Post));
                m.EndDate = DateTimeUtil.ParseEndDateTime(_Request.Get("enddate." + str, Method.Post));
                m.IsNew = _Request.Get<bool>("isnew." + str, Method.Post, false);
                m.ModeratorType = _Request.Get<ModeratorType>("ModeratorType." + str, Method.Post, ModeratorType.Moderators);
                if (Forum.ParentID != 0 && m.ModeratorType == ModeratorType.CategoryModerators)
                {
                    ShowError("非顶级分类不可以添加 分类版主!");
                }
                else if(Forum.ParentID==0)
                {
                    m.ModeratorType = ModeratorType.CategoryModerators;
                }
                moderators.Add(m);
            }


            //-----------------  new  ----------------------
            if (!string.IsNullOrEmpty(_Request.Get("newmoderatorsid",Method.Post))
                && _Request.Get("newmoderatorsid", Method.Post).Contains("{0}"))//No javascript
            {
                Moderator m=GetNewModerators("{0}");
                if (m != null)
                    moderators.Add(m);
            }
            else
            {
                int[] newModeratorIds = _Request.GetList<int>("newmoderatorsid", Method.Post, new int[0]);
                foreach (int i in newModeratorIds)
                {
                    Moderator m = GetNewModerators(i.ToString());
                    if (m != null)
                        moderators.Add(m);
                }
            }


            MessageDisplay msgDisplay = CreateMessageDisplay();


            if (moderators.Count == 0)
                Return(true);

            try
            {
               ForumBO.Instance.AddModerators(My, moderators);
            }
            catch( Exception ex )
            {
                msgDisplay.AddError(ex.Message);
            }

            if (HasUnCatchedError)
            {
                CatchError<ErrorInfo>(delegate(ErrorInfo error)
                {
                    msgDisplay.AddError(error);
                });
            }
            else
            {

            }

            if (!msgDisplay.HasAnyError())
                Return(true);
        }
Exemplo n.º 36
0
        private Moderator GetNewModerators(string key)
        {
            User user;
            Moderator m = new Moderator();
            m.ForumID = ForumID;

            user = UserBO.Instance.GetUser(_Request.Get("username.new." + key, Method.Post, string.Empty, false).Trim());

            //用户名不存在
            if (user == null || user.UserID <= 0)
                return null;

            m.UserID = user.UserID;
            m.EndDate = DateTimeUtil.ParseEndDateTime(_Request.Get("enddate.new." + key, Method.Post));
            m.BeginDate = DateTimeUtil.ParseBeginDateTime(_Request.Get("begindate.new." + key, Method.Post));
            m.SortOrder = _Request.Get<int>("SortOrder.new." + key, Method.Post, 0);
            m.ModeratorType = _Request.Get<ModeratorType>("ModeratorType.new." + key, Method.Post, ModeratorType.Moderators);
            m.IsNew = true;
            return m;
        }
Exemplo n.º 37
0
        private void CommandCast(ChatCommand cmd, Moderator mod)
        {
            var usage = "usage: $vote cast [choice]{ yes | no | abstain } [motion id] ";

             if (cmd.Args.Length == 0)
             {
            WriteUser(usage, mod,cmd.Source);
            return;
             }

             var stuff = cmd.Args.Split(' ');

             if (stuff.GetUpperBound(0) < 1)
             {
            WriteUser(usage, mod,cmd.Source);
            return;
             }

             var id = -1;
             try
             {
            id = Int32.Parse(stuff[1]);
             }
             catch
             {
            WriteUser(usage, mod,cmd.Source);
            return;
             }

             Choice c = Choice.Abstain;
             bool error = false;
             switch (stuff[0].ToLower())
             {
            case "yes":
            case "y":
            case "+1":
            case "yay":
            case "yae":
            case "yea":
            case "oui":
            case "si":
            case "ja":
            case "da":
               c = Choice.Yes;
               break;
            case "no":
            case "n":
            case "-1":
            case "nae":
            case "nay":
            case "non":
            case "nein":
            case "neit":
               c = Choice.No;
               break;
            case "abstain":
            case "abs":
            case "0":
               c = Choice.Abstain;
               break;
            default:
               error = true;
               break;
             }

             if (error)
             {
            WriteUser(usage, mod);
            return;
             }

             WriteUser("Submitting ballot.  Please wait.",mod,cmd.Source);

             var motion = Motion.GetMotion(id);
             var b = new Ballot();
             b.Choice = c;
             b.Moderator = mod;
             b.Motion = motion;
             b.Insert();

             WriteUser("Your ballot has been recorded", mod,cmd.Source);
        }
Exemplo n.º 38
0
 public ModeratorWrapped Wrap(Moderator moderator, User currentUser = null)
 {
     return Wrap(new List<Moderator> {moderator}, currentUser)[0];
 }
Exemplo n.º 39
0
        /// <summary>
        /// Write a message to a user (PM)
        /// </summary>
        /// <param name="command">message</param>
        /// <param name="user">user nick</param>
        public void WriteUser(string command, Moderator user)
        {
            command.Replace(Environment.NewLine, "||");

             client.SendMessage(command, new string[] { user.IrcId });
        }
Exemplo n.º 40
0
        private void CommandMotion(ChatCommand cmd,Moderator mod)
        {
            var usage = "usage: $vote motion [text of the motion]";

             if (cmd.Args.Length == 0)
             {
            WriteUser(usage, mod,cmd.Source);
            return;
             }

             WriteUser("Submitting your motion...this make take a second.", mod,cmd.Source);
             var motion = Motion.Create(mod, cmd.Args);

             var result = "Motion entered [" + motion.Id.ToString() + "]: " + motion.PostUrl;

             WriteChannel(result,ChatProviderType.All);
        }
Exemplo n.º 41
0
        private void CommandHelp(Moderator mod, ChatCommand cmd = null)
        {
            string context = "";
             if (cmd != null && cmd.Args != null && cmd.Args.Trim().Contains(" "))
             {
            context = cmd.Args.Split(' ')[0];
             }

             switch (context.ToLowerInvariant())
             {
            case "help":
               WriteUser("usage: $vote [ new { text } | cast { id } { yes/no/abstain } | help ]",mod,cmd.Source);
               break;
            case "new":
               WriteUser("usage: $vote new I'd like to do this.  all in favor?",mod,cmd.Source);
               break;
            case "cast":
               WriteUser("usage: $vote cast [ yes / yea / +1 | no / nae / -1 | abstain / abs / 0 ]", mod,cmd.Source);
               break;
            default:
               WriteUser("usage: $vote [ new { text } | cast { id } { yes/no/abstain } | help ]", mod,cmd.Source);
               break;
             }
        }
Exemplo n.º 42
0
 public ModeratorWrapped(Moderator moderator)
 {
     Moderator = moderator;
 }
Exemplo n.º 43
0
        private void WriteUser(string message, Moderator user, ChatProviderType provider = ChatProviderType.All)
        {
            List<IChatProvider> providers = new List<IChatProvider>();
             if (provider == ChatProviderType.All)
             {
            foreach (var item in this.ChatProviders)
            {
               providers.Add(item);
            }
             }
             else
             {
            providers = this.ChatProviders.Where(p => p.Type == provider).ToList();
             }

             foreach (IChatProvider p in providers)
             {
            p.WriteUser(message, user);
             }
        }