示例#1
0
 public static void InstallSwitch(string AppToInstall)
 {
     try
     {
         if (Properties.Settings.Default.Drive == String.Empty)
         {
             Core.ILogging.Output(true, false, false, false, "The Drive settings field has been left empty. Please configure this and try again.", true);
             MessageBox.Show("The Drive settings field has been left empty. Please configure this and try again.", "Error: No Drive set", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             Form Fs = new FmSelectSystem();
             Fs.Show();
             FmSelectSystem.SettingsActive = true;
             return;
         }
         Downloading             = true;
         PackageDownloadComplete = false;
         PackageProgress         = 0;
         Path = cd + "\\Data\\Cache\\Switch\\" + AppToInstall + ".zip";
         Uri URL = new Uri("https://www.switchbru.com/appstore/zips/" + AppToInstall + ".zip");
         CacheCheck.PerformCheck();
         URLStr = URL.ToString();
         GetPackage.DownloadProgressChanged += new DownloadProgressChangedEventHandler(PackageDownloadProgress);
         GetPackage.DownloadFileCompleted   += new AsyncCompletedEventHandler(PackageDownloadedAsync);
         GetPackage.DownloadFileAsync(URL, Path);
         return;
     }
     catch (Exception ex)
     {
         Core.ILogging.Output(true, false, false, false, ex.Message, true);
         MessageBox.Show(ex.Message + Environment.NewLine + "URL: " + URLStr, "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Installing  = false;
         Downloading = false;
         return;
     }
 }
示例#2
0
 private void FmSelectSystem_Load(object sender, EventArgs e)
 {
     LblVersion.Text = "Version: " + Application.ProductVersion;
     CacheCheck.PerformCheck();
     this.Refresh();
     return;
 }
示例#3
0
        public int ConfirmUsername(int confirmKey)
        {
            var userId = Context.User.GetUserId();

            if (userId == null)
            {
                return(0);
            }

            //Check cache and throw error if user is trying too much
            var key   = "confirmusername-" + userId;
            var cache = HttpRuntime.Cache[key];

            if (cache != null)
            {
                var cacheCheck = (CacheCheck)cache;

                if (DateTime.Now > cacheCheck.Last.AddMinutes(5))
                {
                    cacheCheck = new CacheCheck();
                }

                if (cacheCheck.Count > 2)
                {
                    return(2);
                }

                cacheCheck.Count++;
                cacheCheck.Last = DateTime.Now;
            }
            else
            {
                HttpRuntime.Cache.Add(key,
                                      new CacheCheck(),
                                      null,
                                      Cache.NoAbsoluteExpiration,
                                      TimeSpan.FromMinutes(5),
                                      CacheItemPriority.Low,
                                      null);
            }

            var dbUser = _db.MtgoLink.FirstOrDefault(l => l.UserId == userId);

            if (dbUser == null)
            {
                return(0);
            }

            if (dbUser.Confirmed)
            {
                return(2);
            }

            if (_db.MtgoLink.Any(u => u.MtgoUsername == dbUser.MtgoUsername && u.Confirmed))
            {
                return(3);
            }

            if (dbUser.ConfirmKey != confirmKey.ToString(CultureInfo.InvariantCulture))
            {
                return(1);
            }

            dbUser.Confirmed        = true;
            dbUser.ConfirmKey       = null;
            _db.Entry(dbUser).State = EntityState.Modified;
            _db.SaveChanges();

            return(4);
        }