コード例 #1
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static FavouriteFolder GetFolderfromDatabaseByFoldername(ConnParams conn, string folderName)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            lstFav = lstFav.FindFolderWithClassesByFolderName(folderName);
            return(lstFav.lstFavFolder[0]);
        }
コード例 #2
0
 public static bool Remove(string strName)
 {
     if (!FavouriteList.Contains(strName))
     {
         return(false);
     }
     return(FavouriteList.faveList.Remove(strName));
 }
コード例 #3
0
        private List <FavouriteProduct> FindFavouriteListProducts(FavouriteList favouriteList)
        {
            var favouriteProducts = this.dbContext.FavouriteProducts
                                    .Include(x => x.Product)
                                    .Include(x => x.FavouriteList)
                                    .Where(x => x.FavouriteList.Id == favouriteList.Id)
                                    .ToList();

            return(favouriteProducts);
        }
コード例 #4
0
        private FavouriteProduct CreateFavouriteProduct(Product product, FavouriteList favouriteList)
        {
            var favouriteProduct = new FavouriteProduct
            {
                Product         = product,
                ProductId       = product.Id,
                FavouriteList   = favouriteList,
                FavouriteListId = favouriteList.Id,
            };

            return(favouriteProduct);
        }
コード例 #5
0
 public static void Add(string strName)
 {
     if (FavouriteList.Contains(strName))
     {
         return;
     }
     if (strName.Length < 8)
     {
         return;
     }
     FavouriteList.faveList.Add(strName);
 }
コード例 #6
0
ファイル: CreateList.cs プロジェクト: Bronwin87/OB
        public async Task Do(Request request)
        {
            var list = new FavouriteList
            {
                Name   = request.Name,
                UserId = request.UserId
            };

            _ctx.Add(list);

            await _ctx.SaveChangesAsync();
        }
コード例 #7
0
    public static void Load()
    {
        FavouriteList.Clear();
        if (!File.Exists("cfg/favourites.cfg"))
        {
            return;
        }
        string str = File.ReadAllText("cfg/favourites.cfg");

        if (string.IsNullOrEmpty(str))
        {
            return;
        }
        Debug.Log("Running cfg/favourites.cfg");
        ConsoleSystem.RunFile(str);
    }
コード例 #8
0
        private static async Task SeedAdminAsync(ApplicationDbContext dbContext, UserManager <ApplicationUser> userManager)
        {
            var admin = await userManager.FindByNameAsync(GlobalConstants.AdminUsername);

            if (admin == null)
            {
                string id           = Guid.NewGuid().ToString();
                var    shoppingCart = new ShoppingCart()
                {
                    Id = id
                };
                var favouriteList = new FavouriteList()
                {
                    Id = id
                };
                var user = new ApplicationUser
                {
                    Id                 = id,
                    UserName           = GlobalConstants.AdminUsername,
                    NormalizedUserName = "******",
                    Email              = "*****@*****.**",
                    NormalizedEmail    = "*****@*****.**",
                    ShoppingCart       = shoppingCart,
                    ShoppingCartId     = id,
                    FavouriteList      = favouriteList,
                    FavouriteListId    = favouriteList.Id,
                };

                favouriteList.User   = user;
                favouriteList.UserId = user.Id;

                var password = "******";
                await dbContext.ShoppingCarts.AddAsync(shoppingCart);

                await dbContext.FavouriteLists.AddAsync(favouriteList);

                var result = await userManager.CreateAsync(user, password);

                await userManager.AddToRoleAsync(user, GlobalConstants.AdministratorRoleName);

                if (!result.Succeeded)
                {
                    throw new Exception(string.Join(Environment.NewLine, result.Errors.Select(e => e.Description)));
                }
            }
        }
コード例 #9
0
        private void RefreshConnectionData(string filepath)
        {
            ConnParams    conParams  = new ConnParams(filepath, false);
            RecentQueries recQueries = new RecentQueries(conParams);

            recQueries = recQueries.ChkIfRecentConnIsInDb();

            if (recQueries != null)
            {
                FavouriteList favList = new FavouriteList(conParams);
                favList.RemoveFavouritFolderForAConnection();

                GroupofSearchStrings grpSearchString = new GroupofSearchStrings(conParams);
                grpSearchString.RemovesSearchStringsForAConnection();

                recQueries.deleteRecentQueriesForAConnection();
            }
        }
コード例 #10
0
 public static void load(ref ConsoleSystem.Arg arg)
 {
     FavouriteList.Load();
 }
コード例 #11
0
ファイル: serverfavourite.cs プロジェクト: sknchan/LegacyRust
    public static void @remove(ref ConsoleSystem.Arg arg)
    {
        string str = arg.GetString(0, string.Empty);

        FavouriteList.Remove(str);
    }
コード例 #12
0
 private static void InitCache()
 {
     FavouriteList        = GetFavourites();
     FavouriteList_Active = FavouriteList.FindAll(delegate(MyFavourite f) { return(f.ISACTIVE.Equals(1)); });
 }
コード例 #13
0
ファイル: ServerBrowser.cs プロジェクト: Virobeast2/RCLIENT
    private void Add_Server(int iMaxPlayers, int iCurrentPlayers, int iPing, uint iLastPlayed, [In, MarshalAs(UnmanagedType.LPStr)] string strHostname, [In, MarshalAs(UnmanagedType.LPStr)] string strAddress, int iPort, int iQueryPort, [In, MarshalAs(UnmanagedType.LPStr)] string tags, bool bPassworded, int iType)
    {
        string strName = strAddress + ":" + iPort.ToString();
        Server item    = new Server {
            name           = strHostname,
            address        = strAddress,
            maxplayers     = iMaxPlayers,
            currentplayers = iCurrentPlayers,
            ping           = iPing,
            lastplayed     = iLastPlayed,
            port           = iPort,
            queryport      = iQueryPort,
            fave           = FavouriteList.Contains(strName)
        };

        if (item.name.Length > 0x40)
        {
            item.name = item.name.Substring(0, 0x40);
        }
        if (!this.ShouldIgnoreServer(item))
        {
            this.playerCount += iCurrentPlayers;
            this.serverCount++;
            this.slotCount            += iMaxPlayers;
            this.needsServerListUpdate = true;
            int      num        = (int)((((float)this.playerCount) / ((float)this.slotCount)) * 100f);
            string[] textArray1 = new string[] { "Found ", this.playerCount.ToString(), " players on ", this.serverCount.ToString(), " servers. We are at ", num.ToString(), "% capacity." };
            this.detailsLabel.Text = string.Concat(textArray1);
            if (iType == 3)
            {
                this.servers[5].Add(item);
                this.categoryButtons[5].UpdateServerCount(this.servers[5].Count);
            }
            else if (iType == 4)
            {
                int    num2 = (int)POSIX.Time.ElapsedSecondsSince((int)item.lastplayed);
                string str2 = string.Empty;
                if (num2 < 60)
                {
                    str2 = num2.ToString() + " seconds ago";
                }
                else if (num2 < 0xe10)
                {
                    str2 = ((num2 / 60)).ToString() + " minutes ago";
                }
                else if (num2 < 0x2a300)
                {
                    str2 = (((num2 / 60) / 60)).ToString() + " hours ago";
                }
                else
                {
                    str2 = ((((num2 / 60) / 60) / 0x18)).ToString() + " days ago";
                }
                item.name = item.name + " (" + str2 + ")";
                this.servers[4].Add(item);
                this.categoryButtons[4].UpdateServerCount(this.servers[4].Count);
            }
            else if (tags.Contains("official"))
            {
                this.servers[0].Add(item);
                this.categoryButtons[0].UpdateServerCount(this.servers[0].Count);
            }
            else
            {
                char[] separator = new char[] { ',' };
                foreach (string str3 in tags.Split(separator))
                {
                    ulong num4;
                    if ((!str3.StartsWith("mp") && !str3.StartsWith("cp")) && (str3.StartsWith("sg:") && ulong.TryParse(str3.Substring(3), NumberStyles.HexNumber, null, out num4)))
                    {
                        if (SteamGroups.MemberOf(num4))
                        {
                            this.servers[3].Add(item);
                            this.categoryButtons[3].UpdateServerCount(this.servers[3].Count);
                        }
                        return;
                    }
                }
                if (tags.Contains("modded"))
                {
                    this.servers[2].Add(item);
                    this.categoryButtons[2].UpdateServerCount(this.servers[2].Count);
                }
                else if (!strHostname.Contains("oxide", true) && !strHostname.Contains("rust++", true))
                {
                    this.servers[1].Add(item);
                    this.categoryButtons[1].UpdateServerCount(this.servers[1].Count);
                }
            }
        }
    }
コード例 #14
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static List <FavouriteFolder> GetFavourites(ConnParams conn)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            return(lstFav.ReturnFavouritFolderList());
        }
コード例 #15
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static void SaveFavourite(ConnParams conn, FavouriteFolder FavFolder)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            lstFav.AddFolderToDatabase(FavFolder);
        }
コード例 #16
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static long GetTimeforFavCreation(ConnParams conn)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            return(lstFav.ReturnTimeWhenFavouriteListCreated());
        }
コード例 #17
0
    private void Add_Server(int iMaxPlayers, int iCurrentPlayers, int iPing, uint iLastPlayed, [In] string strHostname, [In] string strAddress, int iPort, int iQueryPort, [In] string tags, bool bPassworded, int iType)
    {
        ulong  num;
        string str = string.Concat(strAddress, ":", iPort.ToString());

        ServerBrowser.Server server = new ServerBrowser.Server()
        {
            name           = strHostname,
            address        = strAddress,
            maxplayers     = iMaxPlayers,
            currentplayers = iCurrentPlayers,
            ping           = iPing,
            lastplayed     = iLastPlayed,
            port           = iPort,
            queryport      = iQueryPort,
            fave           = FavouriteList.Contains(str)
        };
        if (server.name.Length > 64)
        {
            server.name = server.name.Substring(0, 64);
        }
        if (this.ShouldIgnoreServer(server))
        {
            return;
        }
        ServerBrowser serverBrowser = this;

        serverBrowser.playerCount = serverBrowser.playerCount + iCurrentPlayers;
        ServerBrowser serverBrowser1 = this;

        serverBrowser1.serverCount = serverBrowser1.serverCount + 1;
        ServerBrowser serverBrowser2 = this;

        serverBrowser2.slotCount   = serverBrowser2.slotCount + iMaxPlayers;
        this.needsServerListUpdate = true;
        int num1 = (int)((float)this.playerCount / (float)this.slotCount * 100f);

        this.detailsLabel.Text = string.Concat(new string[] { "Found ", this.playerCount.ToString(), " players on ", this.serverCount.ToString(), " servers. We are at ", num1.ToString(), "% capacity." });
        if (iType == 3)
        {
            this.servers[5].Add(server);
            this.categoryButtons[5].UpdateServerCount(this.servers[5].Count);
            return;
        }
        if (iType == 4)
        {
            int    num2  = (int)POSIX.Time.ElapsedSecondsSince((int)server.lastplayed);
            string empty = string.Empty;
            if (num2 < 60)
            {
                empty = string.Concat(num2.ToString(), " seconds ago");
            }
            else if (num2 < 3600)
            {
                int num3 = num2 / 60;
                empty = string.Concat(num3.ToString(), " minutes ago");
            }
            else if (num2 >= 172800)
            {
                int num4 = num2 / 60 / 60 / 24;
                empty = string.Concat(num4.ToString(), " days ago");
            }
            else
            {
                int num5 = num2 / 60 / 60;
                empty = string.Concat(num5.ToString(), " hours ago");
            }
            ServerBrowser.Server server1 = server;
            server1.name = string.Concat(server1.name, " (", empty, ")");
            this.servers[4].Add(server);
            this.categoryButtons[4].UpdateServerCount(this.servers[4].Count);
            return;
        }
        if (tags.Contains("official"))
        {
            this.servers[0].Add(server);
            this.categoryButtons[0].UpdateServerCount(this.servers[0].Count);
            return;
        }
        string[] strArrays = tags.Split(new char[] { ',' });
        for (int i = 0; i < (int)strArrays.Length; i++)
        {
            string str1 = strArrays[i];
            if (!str1.StartsWith("mp"))
            {
                if (!str1.StartsWith("cp"))
                {
                    if (str1.StartsWith("sg:") && ulong.TryParse(str1.Substring(3), NumberStyles.HexNumber, null, out num))
                    {
                        if (!SteamGroups.MemberOf(num))
                        {
                            return;
                        }
                        this.servers[3].Add(server);
                        this.categoryButtons[3].UpdateServerCount(this.servers[3].Count);
                        return;
                    }
                }
            }
        }
        if (tags.Contains("modded"))
        {
            this.servers[2].Add(server);
            this.categoryButtons[2].UpdateServerCount(this.servers[2].Count);
            return;
        }
        if (strHostname.Contains("oxide", true))
        {
            return;
        }
        if (strHostname.Contains("rust++", true))
        {
            return;
        }
        this.servers[1].Add(server);
        this.categoryButtons[1].UpdateServerCount(this.servers[1].Count);
    }
コード例 #18
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static void UpdateFavourite(ConnParams conn, FavouriteFolder FavFolder)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            lstFav.RemoveFolderfromDatabase(FavFolder);
        }
コード例 #19
0
 public static void add(ref ConsoleSystem.Arg arg)
 {
     FavouriteList.Add(arg.GetString(0, string.Empty));
 }
コード例 #20
0
 public static void remove(ref ConsoleSystem.Arg arg)
 {
     FavouriteList.Remove(arg.GetString(0, string.Empty));
 }
コード例 #21
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static void RenameFolderInDatabase(ConnParams conn, FavouriteFolder oldFav, FavouriteFolder newFav)
        {
            FavouriteList lstFav = new FavouriteList(conn);

            lstFav.RenameFolderInDatabase(oldFav, newFav);
        }
コード例 #22
0
 public static void save(ref ConsoleSystem.Arg arg)
 {
     FavouriteList.Save();
 }
コード例 #23
0
ファイル: dbInteraction.cs プロジェクト: pondyond/db4o
        public static void RemoveFavFolder(ConnParams conn)
        {
            FavouriteList favouriteList = new FavouriteList(conn);

            favouriteList.RemoveFavouritFolderForAConnection();
        }
コード例 #24
0
        public async Task <IActionResult> OnPostConfirmationAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? this.Url.Content("~/");

            // Get the information about the user from the external login provider
            var info = await this.signInManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                this.ErrorMessage = "Error loading external login information during confirmation.";
                return(this.RedirectToPage("./Login", new { ReturnUrl = returnUrl }));
            }

            if (this.ModelState.IsValid)
            {
                string id           = Guid.NewGuid().ToString();
                var    shoppingCart = new ShoppingCart()
                {
                    Id = id
                };
                var favouriteList = new FavouriteList()
                {
                    Id = id
                };

                favouriteList.UserId = id;
                await this.dbContext.FavouriteLists.AddAsync(favouriteList);

                var user = new ApplicationUser {
                    Id = id, UserName = this.Input.Email, Email = this.Input.Email, ShoppingCart = shoppingCart, ShoppingCartId = shoppingCart.Id, FavouriteList = favouriteList, FavouriteListId = favouriteList.Id
                };
                var result = await this.userManager.CreateAsync(user);

                if (result.Succeeded)
                {
                    result = await this.userManager.AddLoginAsync(user, info);

                    if (result.Succeeded)
                    {
                        await this.userManager.AddToRoleAsync(user, GlobalConstants.UserRoleName);

                        await this.signInManager.SignInAsync(user, isPersistent : false);

                        this.logger.LogInformation(
                            "User created an account using {Name} provider.",
                            info.LoginProvider);

                        var cart = SessionHelper.GetObjectFromJson <List <ShoppingCartProductsViewModel> >(this.HttpContext.Session, GlobalConstants.SessionShoppingCartKey);
                        if (cart != null)
                        {
                            foreach (var product in cart)
                            {
                                this.shoppingCartsService.AddProductInShoppingCart(product.Id, this.Input.Email, product.Quantity);
                            }

                            HttpContext.Session.Remove(GlobalConstants.SessionShoppingCartKey);
                        }

                        return(this.LocalRedirect(returnUrl));
                    }
                }

                foreach (var error in result.Errors)
                {
                    this.ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            this.LoginProvider = info.LoginProvider;
            this.ReturnUrl     = returnUrl;
            return(this.Page());
        }
コード例 #25
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? this.Url.Content("~/");
            if (this.ModelState.IsValid)
            {
                string id           = Guid.NewGuid().ToString();
                var    shoppingCart = new ShoppingCart()
                {
                    Id = id
                };
                var favouriteList = new FavouriteList()
                {
                    Id = id
                };

                favouriteList.UserId = id;
                await this.dbContext.FavouriteLists.AddAsync(favouriteList);

                var user = new ApplicationUser {
                    Id = id, UserName = this.Input.Username, Email = this.Input.Email, ShoppingCart = shoppingCart, ShoppingCartId = shoppingCart.Id, FavouriteList = favouriteList, FavouriteListId = favouriteList.Id
                };
                var result = await this.userManager.CreateAsync(user, this.Input.Password);

                if (result.Succeeded)
                {
                    this.logger.LogInformation("User created a new account with password.");

                    await this.userManager.AddToRoleAsync(user, GlobalConstants.UserRoleName);

                    var code = await this.userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = this.Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: this.Request.Scheme);

                    await this.emailSender.SendEmailAsync(
                        this.Input.Email,
                        "Confirm your email",
                        $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await signInManager.SignInAsync(user, isPersistent : false);

                    var cart = SessionHelper.GetObjectFromJson <List <ShoppingCartProductsViewModel> >(HttpContext.Session, GlobalConstants.SessionShoppingCartKey);
                    if (cart != null)
                    {
                        foreach (var product in cart)
                        {
                            shoppingCartService.AddProductInShoppingCart(product.Id, Input.Username, product.Quantity);
                        }

                        HttpContext.Session.Remove(GlobalConstants.SessionShoppingCartKey);
                    }

                    return(this.LocalRedirect(returnUrl));
                }

                foreach (var error in result.Errors)
                {
                    this.ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(this.Page());
        }