Ejemplo n.º 1
0
        public virtual int Create(DealMilestone item)
        {
            if (String.IsNullOrEmpty(item.Title) || String.IsNullOrEmpty(item.Color))
            {
                throw new ArgumentException();
            }

            int id;

            using (var db = GetDb())
                using (var tx = db.BeginTransaction())
                {
                    if (item.SortOrder == 0)
                    {
                        item.SortOrder = db.ExecuteScalar <int>(Query("crm_deal_milestone")
                                                                .SelectMax("sort_order")) + 1;
                    }

                    id = db.ExecuteScalar <int>(
                        Insert("crm_deal_milestone")
                        .InColumnValue("id", 0)
                        .InColumnValue("title", item.Title)
                        .InColumnValue("description", item.Description)
                        .InColumnValue("color", item.Color)
                        .InColumnValue("probability", item.Probability)
                        .InColumnValue("status", (int)item.Status)
                        .InColumnValue("sort_order", item.SortOrder)
                        .Identity(1, 0, true));
                    tx.Commit();
                }

            AdminLog.PostAction("CRM: saved opportunity stage {0}", item);

            return(id);
        }
Ejemplo n.º 2
0
        public IActionResult GetAdminCPLogList(string keyword, int page = 1, int limit = 20)
        {
            int numPerPage, currentPage, startRowIndex;

            numPerPage    = limit;
            currentPage   = page;
            startRowIndex = (currentPage - 1) * numPerPage;
            Expression ex = AdminLog._.Id > 0;

            if (!string.IsNullOrWhiteSpace(keyword))
            {
                if (Utils.IsInt(keyword))
                {
                    ex &= (AdminLog._.Id == int.Parse(keyword) | AdminLog._.UserName.Contains(keyword));
                }
                else
                {
                    ex &= AdminLog._.UserName.Contains(keyword);
                }
            }
            string kid = Request.Query["kid"];
            //if (Utils.IsInt(kid) && int.Parse(kid) > 0)
            //{
            //    ex &= AdminLog._.KId == int.Parse(kid);
            //}
            IList <AdminLog> list       = AdminLog.FindAll(ex, AdminLog._.Id.Desc(), null, startRowIndex, numPerPage);
            long             totalCount = AdminLog.FindCount(ex, AdminLog._.Id.Desc(), null, startRowIndex, numPerPage);

            Core.Admin.WriteLogActions("后台管理日志留言列表(page:" + page + ");");
            return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain"));
        }
Ejemplo n.º 3
0
        public async Task KillProgram(string confirmation = null)
        {
            if (confirmation.ToUpperInvariant() != "CONFIRM")
            {
                await ReplyAsync("**Please confirm by entering the TwoAuth code as follows:** " +
                                 Guild.Load(Context.Guild.Id).Prefix + "die confirm\n" +
                                 "Issuing this command will log the Bot out and terminate the process.");

                return;
            }

            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

            EmbedBuilder eb = new EmbedBuilder
            {
                Title = "",
                Color = new Color(User.Load(Context.User.Id).AboutR, User.Load(Context.User.Id).AboutG,
                                  User.Load(Context.User.Id).AboutB),
                Description = ""
            }.AddField("", "");

            await ReplyAsync("", false, eb.Build());

            await DiscordBot.Bot.LogoutAsync();

            Environment.Exit(0);
        }
Ejemplo n.º 4
0
        public ActionResult ProduziUslugu(int id)
        {
            mssql  s = new mssql();
            Ugovor u = s.Ugovor.SingleOrDefault(x => x.Id == id);

            u.produzenje = false;
            u.boja       = "aqua";
            if (u.VpsPaketiId != null || u.DedicatedPaketiId != null)
            {
                u.DatumVazenja = DateTime.Now.AddMonths(1);
            }
            else
            {
                u.DatumVazenja = DateTime.Now.AddYears(1);
            }
            s.SaveChanges();

            Produzenja p = s.Produzenja.Where(x => x.UgovorId == id).OrderByDescending(x => x.Id).First();

            p.DatumRealizacije = DateTime.Now;
            s.SaveChanges();

            var      user = Session["admin"] as Admin;
            AdminLog l    = new AdminLog();

            l.Datum   = DateTime.Now;
            l.Hidden  = false;
            l.IP      = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
            l.AdminId = user.Id;
            l.Poruka  = "Ugovor id: " + u.Id + ", Produzenje";
            s.AdminLog.Add(l);
            s.SaveChanges();

            return(RedirectToAction("Index", "Admin"));
        }
Ejemplo n.º 5
0
 public static void CreateLog(AdminLog model)
 {
     using (var dbcon = CreateCmslogConnection())
     {
         dbcon.ExecuteAsync("insert into adminlog(OperateUsers_Id,LoginIP,Operation,Remark) values(@OperateUsers_Id,@LoginIP,@Operation,@Remark)", new { OperateUsers_Id = model.OperateUsers_Id, LoginIP = model.LoginIP, Operation = model.Operation, Remark = model.Remark });
     }
 }
Ejemplo n.º 6
0
        public async Task ShowGuildConfig()
        {
            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

            try
            {
                EmbedBuilder eb = new EmbedBuilder()
                                  .WithTitle("Guild Configuration")
                                  .WithFooter("Guild Configuration can be edited by Guild Owner/Administrator");

                eb.WithDescription("```INI\n" +
                                   "[ 1] Prefix [ " + (Guild.Load(Context.Guild.Id).Prefix ?? "UNDEFINED") + " ]\n" +
                                   "[ 2] Welcome Channel [ #" + (Guild.Load(Context.Guild.Id).WelcomeChannelID.GetTextChannel().Name ?? "UNDEFINED") + " ]\n" +
                                   "[ 3] Welcome Channel ID [ " + (Guild.Load(Context.Guild.Id).WelcomeChannelID) + " ]\n" +
                                   "[ 4] Log Channel [ #" + (Guild.Load(Context.Guild.Id).LogChannelID.GetTextChannel().Name ?? "UNDEFINED") + " ]\n" +
                                   "[ 5] Log Channel ID [ " + (Guild.Load(Context.Guild.Id).LogChannelID) + " ]\n" +
                                   "[ 6] Bot Channel [ #" + (Guild.Load(Context.Guild.Id).BotChannelID.GetTextChannel().Name ?? "UNDEFINED") + " ]\n" +
                                   "[ 7] Bot Channel ID [ " + (Guild.Load(Context.Guild.Id).BotChannelID) + " ]\n" +
                                   "[ 8] Senpai Enabled [ " + Guild.Load(Context.Guild.Id).SenpaiEnabled.ToYesNo() + " ]\n" +
                                   "[ 9] Quotes Enabled [ " + Guild.Load(Context.Guild.Id).QuotesEnabled.ToYesNo() + " ]\n" +
                                   "[10] NSFW Commands Enabled [ " + Guild.Load(Context.Guild.Id).NSFWCommandsEnabled.ToYesNo() + " ]\n" +
                                   "[11] Rule34 Channel [ #" + (Guild.Load(Context.Guild.Id).RuleGambleChannelID.GetTextChannel().Name ?? "UNDEFINED") + " ]\n" +
                                   "[12] Rule34 Channel ID [ " + (Guild.Load(Context.Guild.Id).RuleGambleChannelID) + " ]\n" +
                                   "```");

                await ReplyAsync("", false, eb.Build());
            }
            catch (Exception e)
            {
                await ReplyAsync(
                    "It appears that your Guild Configuration has not been set-up completely. Please complete all the steps before using this command.");

                await new LogMessage(LogSeverity.Warning, "ShowConfigModule", e.Message).PrintToConsole();
            }
        }
Ejemplo n.º 7
0
        public ActionResult Aktiviraj(int id)
        {
            mssql  s = new mssql();
            Ugovor u = s.Ugovor.SingleOrDefault(x => x.Id == id);

            u.DatumOdobrenja = DateTime.Now;
            if (u.VpsPaketiId != null || u.DedicatedPaketiId != null)
            {
                u.DatumVazenja = DateTime.Now.AddMonths(1);
            }
            else
            {
                u.DatumVazenja = DateTime.Now.AddYears(1);
            }
            u.StatusId = 3;
            u.boja     = "aqua";
            s.SaveChanges();


            var      user = Session["admin"] as Admin;
            AdminLog l    = new AdminLog();

            l.Datum   = DateTime.Now;
            l.Hidden  = false;
            l.IP      = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
            l.AdminId = user.Id;
            l.Poruka  = "Ugovor id: " + u.Id + ", Aktiviran ";
            s.AdminLog.Add(l);
            s.SaveChanges();

            return(RedirectToAction("Index", "ugovor"));
        }
Ejemplo n.º 8
0
            public async Task ToggleShowingAllAwards()
            {
                Configuration.UpdateConfiguration(showAllAwards: !Configuration.Load().ShowAllAwards);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("Showing All Awards has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().ShowAllAwards.ToYesNo() + ")");
            }
Ejemplo n.º 9
0
            public async Task SetDatabaseName([Remainder] string value)
            {
                Configuration.UpdateConfiguration(databaseName: value);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("Database Name has been changed by " + Context.User.Mention + " to " + value);
            }
Ejemplo n.º 10
0
            public async Task ToggleEXPAwardingReactionsPoster()
            {
                Configuration.UpdateConfiguration(awardingEXPReactPostEnabled: !Configuration.Load().AwardingEXPReactPostEnabled);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("EXP awarding has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().AwardingEXPReactPostEnabled.ToYesNo() + ")");
            }
Ejemplo n.º 11
0
            public async Task ToggleAwardingEXPMention()
            {
                Configuration.UpdateConfiguration(awardingEXPMentionUser: !Configuration.Load().AwardingEXPMentionUser);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("AwardingEXPMentionUser has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().AwardingEXPMentionUser.ToYesNo() + ")");
            }
Ejemplo n.º 12
0
            public async Task SetGlobalLogChannel(SocketTextChannel channel)
            {
                Configuration.UpdateConfiguration(logChannelId: channel.Id);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync(Context.User.Mention + " has updated \"LogChannelID\" to: " + channel.Mention);
            }
Ejemplo n.º 13
0
            public async Task SendSyntax()
            {
                await ReplyAsync("**Syntax:** " +
                                 Guild.Load(Context.Guild.Id).Prefix + "editconfig [command] [command syntax]\n```INI\n" +
                                 "Available Commands\n" +
                                 "-----------------------------\n" +
                                 "[ 1] clearactivity\n" +
                                 "[ 2] setgame [type] [message]\n" +
                                 "[a.] [type] -> [none] [playing] [listening] [watching]\n" +
                                 "[ 3] setstreaming [stream url] [message]\n" +
                                 "[ 4] status [status]\n" +
                                 "[a.] [status] -> [online] [donotdisturb] [idle] [invisible]\n" +
                                 "[ 5] toggleunknowncommand\n" +
                                 "[ 6] leaderboardamount [number of users to display]\n" +
                                 "[ 7] quotelevel [level]\n" +
                                 "[ 8] prefixlevel [level]\n" +
                                 "[ 9] rgblevel [level]\n" +
                                 "[10] senpaichance [number 1-100]\n" +
                                 "[11] globallogchannel [channel mention / channel id]\n" +
                                 "[12] rule34 [max number for random to use]\n" +
                                 "[13] minlengthforexp [string length for exp gain]\n" +
                                 "[14] leaderboardtrophyurl [link]\n" +
                                 "[15] leaderboardembedcolor [uint id]\n" +
                                 "[16] toggleexpawarding\n" +
                                 "[17] toggleshowallawards\n" +
                                 "[18] awardsiconurl [link]\n" +
                                 "[19] toggleawardingexpmention\n" +
                                 "[20] toggleexpreactawarding\n" +
                                 "[21] toggleexpreactpostawarding\n" +
                                 "```");

                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);
            }
Ejemplo n.º 14
0
            public async Task ToggleUc()
            {
                Configuration.UpdateConfiguration(unknownCommandEnabled: !Configuration.Load().UnknownCommandEnabled);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("UnknownCommand has been toggled by " + Context.User.Mention + " (enabled: " + Configuration.Load().UnknownCommandEnabled.ToYesNo() + ")");
            }
Ejemplo n.º 15
0
        public object AddAdmin(Guid id)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var user = CoreContext.UserManager.GetUsers(id);

            if (user.IsVisitor())
            {
                throw new System.Security.SecurityException("Collaborator can not be an administrator");
            }

            WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true);

            var result = new
            {
                id           = user.ID,
                smallFotoUrl = user.GetSmallPhotoURL(),
                displayName  = user.DisplayUserName(),
                title        = user.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(user.ID),
                accessList   = GetAccessList(user.ID)
            };

            AdminLog.PostAction("Settings: added portal administrator ID=\"{0}\"", id);

            return(result);
        }
Ejemplo n.º 16
0
            public async Task SetDefaultWebsiteName([Remainder] string name = null)
            {
                StringConfiguration.UpdateConfiguration(websiteName: name);
                AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("DefaultWebsiteName has been changed by " + Context.User.Mention + " to " + name);
            }
Ejemplo n.º 17
0
        public async Task ShowBotConfig()
        {
            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

            EmbedBuilder eb = new EmbedBuilder()
                              .WithTitle("Bot Configuration")
                              .WithFooter("Bot Owner permissions required to change these variables!");

            eb.WithDescription("```INI\n" +
                               "[ 1] Developer [ " + (Configuration.Load().Developer.GetUser().Username ?? "Melissa") + " ]\n" +
                               "[ 2] Developer ID [ " + Configuration.Load().Developer + " ]\n" +
                               "[ 3] Activity Name [ " + (Configuration.Load().ActivityName ?? "") + " ]\n" +
                               "[ 4] Activity Type [ " + (((ActivityType)Configuration.Load().ActivityType).ToString() ?? "") + " ]\n" +
                               "[ 5] Activity Stream [ " + Configuration.Load().ActivityStream + " ]\n" +
                               "[ 6] Status [ " + Configuration.Load().Status + " ]\n" +
                               "[ 7] Unknown Command Enabled [ " + Configuration.Load().UnknownCommandEnabled.ToYesNo() + " ]\n" +
                               "[ 8] Awarding EXP Enabled [ " + Configuration.Load().AwardingEXPEnabled.ToYesNo() + " ]\n" +
                               "[ 9] Leaderboard Amount [ " + Configuration.Load().LeaderboardAmount + " ]\n" +
                               "[10] Quote Level Requirement [ " + Configuration.Load().QuoteLevelRequirement + " ]\n" +
                               "[11] Prefix Level Requirement [ " + Configuration.Load().PrefixLevelRequirement + " ]\n" +
                               "[12] RGB Level Requirement [ " + Configuration.Load().RGBLevelRequirement + " ]\n" +
                               "[13] Senpai Chance Rate [ " + Configuration.Load().SenpaiChanceRate + "/100 ]\n" +
                               "[14] Global Log Channel [ #" + (Configuration.Load().LogChannelId.GetTextChannel().Name ?? "UNDEFINED") + " ]\n" +
                               "[15] Global Log Channel ID [ " + Configuration.Load().LogChannelId + " ]\n" +
                               "[16] Respects [ " + Configuration.Load().Respects + " ]\n" +
                               "[17] Min Length For EXP [ " + Configuration.Load().MinLengthForEXP + " ]\n" +
                               "[18] Max Rule34 Gamble ID [ " + Configuration.Load().MaxRuleXGamble + " ]\n" +
                               "[19] Showing All Awards [ " + Configuration.Load().ShowAllAwards.ToYesNo() + "]\n" +
                               "```");

            await ReplyAsync("", false, eb.Build());
        }
Ejemplo n.º 18
0
        public object RestoreGreetingSettings()
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                _tenantInfoSettings = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(TenantProvider.CurrentTenantID);
                _tenantInfoSettings.RestoreDefault();
                SettingsManager.Instance.SaveSettings <TenantInfoSettings>(_tenantInfoSettings, TenantProvider.CurrentTenantID);

                AdminLog.PostAction("Settings: restored previous greeting settings");

                return(new
                {
                    Status = 1,
                    Message = Resources.Resource.SuccessfullySaveGreetingSettingsMessage,
                    LogoPath = _tenantInfoSettings.GetAbsoluteCompanyLogoPath(),
                    CompanyName = CoreContext.TenantManager.GetCurrentTenant().Name,
                });
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Ejemplo n.º 19
0
        public ActionResult AdminLogin(string UserName, string Password)
        {
            var user = us.Login(UserName, Password);

            if (user != null)
            {
                var admin = us.IfAdmin(user);
                if (admin != null)
                {
                    Session.Add("AdminId", admin.AdminId);
                    Session.Add("AdminName", admin.Users.UserName);
                    AdminLog adminLog = new AdminLog()
                    {
                        AdminId         = admin.AdminId,
                        OperationRecord = "登录",
                        OperatorTime    = DateTime.Now,
                        IP = us.GetAddressIP(),
                    };
                    us.AddAdminLog(adminLog);
                    return(Redirect("/Admin/Index"));
                }
                else
                {
                    TempData["DataError"] = "账号或密码错误!";
                    return(Redirect("/Admin/AdminLog"));
                }
            }
            else
            {
                TempData["DataError"] = "账号或密码错误或用户不存在!";
                return(Redirect("/Admin/AdminLogin"));
            }
        }
Ejemplo n.º 20
0
        public ActionResult Provjera(string username, string password)
        {
            mssql s = new mssql();
            Admin a = s.Admin.SingleOrDefault(x => x.Email == username && x.Password == password && x.Izbrisan == false);

            if (a == null)
            {
                AdminLog l = new AdminLog();
                l.Datum  = DateTime.Now;
                l.Hidden = false;
                l.IP     = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
                l.Poruka = "Logiranje ne postoji korisnik username: "******", password: "******"Login"));
            }
            else
            {
                AdminLog l = new AdminLog();
                l.Datum   = DateTime.Now;
                l.Hidden  = false;
                l.IP      = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
                l.AdminId = a.Id;
                l.Poruka  = "Logiranje.";
                s.AdminLog.Add(l);
                s.SaveChanges();

                Session["admin"] = new Admin()
                {
                    Ime = a.Ime, Prezime = a.Prezime, Id = a.Id, AdminHead = a.AdminHead
                };
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 21
0
        public ActionResult produzi(int id)
        {
            mssql  s = new mssql();
            Ugovor u = s.Ugovor.SingleOrDefault(x => x.Id == id);

            u.produzenje = true;
            u.boja       = "crimson";
            s.SaveChanges();

            Produzenja p = new Produzenja();

            p.UgovorId      = id;
            p.DatumZahtjeva = p.DatumRealizacije = DateTime.Now;
            s.Produzenja.Add(p);
            s.SaveChanges();

            var      user = Session["admin"] as Admin;
            AdminLog l    = new AdminLog();

            l.Datum   = DateTime.Now;
            l.Hidden  = false;
            l.IP      = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
            l.AdminId = user.Id;
            l.Poruka  = "Ugovor id: " + u.Id + ", Produzen";
            s.AdminLog.Add(l);
            s.SaveChanges();

            return(RedirectToAction("KlijentPanel", "Klijent"));
        }
Ejemplo n.º 22
0
        public string SendNotificationToChange(string userId)
        {
            var user = CoreContext.UserManager.GetUsers(
                string.IsNullOrEmpty(userId)
                    ? SecurityContext.CurrentAccount.ID
                    : new Guid(userId));

            var canChange =
                user.IsMe() ||
                SecurityContext.CheckPermissions(new UserSecurityProvider(user.ID), ASC.Core.Users.Constants.Action_EditUser);

            if (!canChange)
            {
                throw new SecurityAccessDeniedException(Resource.ErrorAccessDenied);
            }

            user.MobilePhoneActivationStatus = MobilePhoneActivationStatus.NotActivated;
            CoreContext.UserManager.SaveUserInfo(user);

            if (user.IsMe())
            {
                return(StudioNotifyService.GenerateConfirmUrl(user.Email, ConfirmType.PhoneActivation));
            }

            AdminLog.PostAction("UserProfile: erase phone number for user with id {0}", user.ID);
            StudioNotifyService.Instance.SendMsgMobilePhoneChange(user);
            return(string.Empty);
        }
Ejemplo n.º 23
0
        public ActionResult Promjeni(int uid, int status)
        {
            mssql  s = new mssql();
            Ugovor u = s.Ugovor.SingleOrDefault(x => x.Id == uid);

            u.StatusId = status;
            if (status == 2)
            {
                u.boja = "coral";
            }
            if (status == 4)
            {
                u.boja = "indianred";
            }
            s.SaveChanges();

            var      user = Session["admin"] as Admin;
            AdminLog l    = new AdminLog();

            l.Datum   = DateTime.Now;
            l.Hidden  = false;
            l.IP      = Request.UserHostAddress + " " + Request.UserHostName + " " + Request.Browser.Browser;
            l.AdminId = user.Id;
            l.Poruka  = "Ugovor id: " + u.Id + ", status " + u.Status.Naziv;
            s.AdminLog.Add(l);
            s.SaveChanges();


            return(RedirectToAction("Index", "ugovor"));
        }
Ejemplo n.º 24
0
        public async Task SendMessageToAllGuilds([Remainder] string message = null)
        {
            if (message == null)
            {
                await ReplyAsync("**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "globalmessage [message]\n" +
                                 "This will post an embed message to all guilds. It's main purpose is to inform guild owners of updates and changes.");

                return;
            }

            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

            EmbedBuilder eb = new EmbedBuilder()
            {
                Title       = "Announcement from " + Context.User.Username,
                Color       = new Color(User.Load(Context.User.Id).AboutR, User.Load(Context.User.Id).AboutG, User.Load(Context.User.Id).AboutB),
                Description = message
            }.WithCurrentTimestamp();

            foreach (SocketGuild g in DiscordBot.Bot.Guilds)
            {
                await Guild.Load(g.Id).LogChannelID.GetTextChannel().SendMessageAsync("", false, eb.Build());
            }

            await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("", false, eb.WithFooter("Message sent to all guilds").Build());
        }
Ejemplo n.º 25
0
        public object SaveSettings(string defaultProductID)
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                var defaultPageSettingsObj = new StudioDefaultPageSettings
                {
                    DefaultProductID = new Guid(defaultProductID)
                };
                var resultStatus = SettingsManager.Instance.SaveSettings(defaultPageSettingsObj, TenantProvider.CurrentTenantID);

                AdminLog.PostAction("Settings: default product ID \"{0}\"", defaultProductID);

                return(new
                {
                    Status = 1,
                    Message = Resources.Resource.SuccessfullySaveSettingsMessage
                });
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Ejemplo n.º 26
0
        public object SaveSettings(bool smsEnable)
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                if (smsEnable && StudioSmsNotificationSettings.SentSms >= StudioSmsNotificationSettings.PaidSms)
                {
                    throw new Exception(Resource.SmsNotPaidError);
                }

                StudioSmsNotificationSettings.Enable = smsEnable;

                AdminLog.PostAction("Settings: saved sms validation settings to {0}", smsEnable);

                return(new
                {
                    Status = 1,
                    Message = Resource.SuccessfullySaveSettingsMessage
                });
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Ejemplo n.º 27
0
        public object SaveSettings(bool turnOn)
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                var passwordSettingsObj = new StudioAdminMessageSettings {
                    Enable = turnOn
                };
                SettingsManager.Instance.SaveSettings(passwordSettingsObj, TenantProvider.CurrentTenantID);

                AdminLog.PostAction("Settings: saved admin message settings to \"{0}\"", turnOn);
                MessageService.Send(HttpContext.Current.Request, MessageAction.AdministratorMessageSettingsUpdated);

                return(new
                {
                    Status = 1,
                    Message = Resources.Resource.SuccessfullySaveSettingsMessage
                });
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Ejemplo n.º 28
0
        public object ChangeOwner(Guid ownerId)
        {
            try
            {
                SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

                var curTenant = CoreContext.TenantManager.GetCurrentTenant();
                var owner     = CoreContext.UserManager.GetUsers(curTenant.OwnerId);

                if (owner.IsVisitor())
                {
                    throw new System.Security.SecurityException("Collaborator can not be an owner");
                }

                if (curTenant.OwnerId.Equals(SecurityContext.CurrentAccount.ID) && !Guid.Empty.Equals(ownerId))
                {
                    StudioNotifyService.Instance.SendMsgConfirmChangeOwner(curTenant,
                                                                           CoreContext.UserManager.GetUsers(ownerId).DisplayUserName(),
                                                                           GetConfirmLink(ownerId, owner.Email));

                    var emailLink = string.Format("<a href=\"mailto:{0}\">{0}</a>", owner.Email);
                    return(new { Status = 1, Message = Resource.ChangePortalOwnerMsg.Replace(":email", emailLink) });
                }

                AdminLog.PostAction("Settings: changed portal owner to ID=\"{0}\"", ownerId);

                return(new { Status = 0, Message = Resource.ErrorAccessDenied });
            }
            catch (Exception e)
            {
                return(new { Status = 0, Message = e.Message.HtmlEncode() });
            }
        }
Ejemplo n.º 29
0
        public async Task EditFooter(IUser user, [Remainder] string footer)
        {
            if (user == null || footer == null)
            {
                await ReplyAsync("**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "editfooter [@User] [Footer]");

                return;
            }

            List <(string, string)> queryParams = new List <(string, string)>()
            {
                ("@footerText", footer)
            };

            DatabaseActivity.ExecuteNonQueryCommand(
                "UPDATE users SET footerText=@footerText WHERE id='" + user.Id + "';", queryParams);
            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id, user.Id);

            var eb = new EmbedBuilder()
                     .WithDescription(Context.User.Username + " updated " + user.Mention + "'s footer successfully.")
                     .WithColor(Color.DarkGreen);
            var message = await ReplyAsync("", false, eb.Build());

            Context.Message.DeleteAfter(10);
            message.DeleteAfter(10);
        }
Ejemplo n.º 30
0
        public async Task AddQuote([Remainder] string quote = null)
        {
            EmbedBuilder eb;

            if (quote == null)
            {
                eb = new EmbedBuilder
                {
                    Title       = "Invalid Syntax",
                    Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "addquote [quote] (@creator)",
                    Color       = new Color(210, 47, 33)
                };

                await ReplyAsync("", false, eb.Build());

                return;
            }

            Quote.AddQuote(quote, Context.User.Id, Context.Guild.Id);
            AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id);

            eb = new EmbedBuilder()
                 .WithDescription(Context.User.Mention + " Quote Added")
                 .WithColor(33, 210, 47);

            await ReplyAsync("", false, eb.Build());
        }