private void Form1_Load(object sender, EventArgs e) { //Intrensic.Administration.frmUsers frmUsers = new Administration.frmUsers(); //frmUsers.Show(); //using (CodeITDbContext ctx = new CodeITDbContext(1)) //{ //} //CodeITDL.IntrensicEntities ie = new IntrensicEntities(); //CodeITDL.CodeITDbContext ctx = new CodeITDbContext(1); //ctx.AuditLogs. TestDB(); //frmProgressStatus progressStatus = new frmProgressStatus(new List<string>() { "" }); //progressStatus.Show(); //axWindowsMediaPlayer1.uiMode = "none"; axWindowsMediaPlayer1.enableContextMenu = false; //axWindowsMediaPlayer1.fullScreen = false; //axWindowsMediaPlayer1.Ctlenabled = false; axWindowsMediaPlayer1.windowlessVideo = true; //axWindowsMediaPlayer1.EditMode = false; axWindowsMediaPlayer1.DoubleClickEvent += axWindowsMediaPlayer1_DoubleClickEvent; //driveDetector = new DriveDetector(); //driveDetector.DeviceArrived += new DriveDetectorEventHandler( // OnDriveArrived); //driveDetector.DeviceRemoved += new DriveDetectorEventHandler( // OnDriveRemoved); //driveDetector.QueryRemove += new DriveDetectorEventHandler( // OnQueryRemove); deleteFiles(); frmUserMainScreen usrMainScreen = new frmUserMainScreen(); usrMainScreen.Show(); //CodeITBL.CopyFileAndComputeMD5Async copyMD5 = new CodeITBL.CopyFileAndComputeMD5Async(); //copyMD5.AsyncCheckProgress += copyMD5_AsyncCheckProgress; //copyMD5.AsyncCopy(filename, filename_destination_custom); return; //CodeITBL.AsyncCheckEventArgs eventArgs = new CodeITBL.AsyncCheckEventArgs(CodeITBL.AsyncCheckState.Checking, ""); //CodeITBL.AsyncMD5 asyncMD5 = new CodeITBL.AsyncMD5(); //asyncMD5.AsyncCheckProgress += asyncMD5_AsyncCheckProgress; //asyncMD5.AsyncCheck(filename); //System.Threading.Thread.Sleep(10000); //SDCardMonitor.addInsetSDCard(); //SDCardMonitor.AddremovalSD(); //ON APP START SCAN ALL DRIVES FOR GOPRO FOLDER STRUCTURE SINCE THEY MIGHT INSERTED THE SD CARD BEFORE //STARTING THE APPLICATION //INCREMENTAL CHECKSUM C# //CodeITBL.CRC32 crc32 = new CodeITBL.CRC32(); //private uint crc = 0xFFFFFFFF; CopyAndCalculateCRC(); System.Threading.Thread.Sleep(4000); CopyAndCalculateCRCAsync(); CopyAndCalculateCRC_noasync(); //CopyAndCalculateCRCAsync(); //helper = new CodeITBL.CRCHelper(); //helper.CalculaterAdler32Incremental(fileContent); //MessageBox.Show(helper.GetAdler32IncrementalValue().ToString()); ////lblInfo.Text = result.ToString(); //MessageBox.Show((DateTime.Now - start).TotalSeconds.ToString()); //axVLCPlugin21.playlist.add(@"H:\DCIM\100GOPRO\GOPR0006.MP4"); //axVLCPlugin21.playlist.play(); //wmPlayer.st //WMPLib.WindowsMediaPlayerClass player = new WMPLib.WindowsMediaPlayerClass(); //CodeITBL.VideoPlayback game = new CodeITBL.VideoPlayback(); //game.Run(); //using (CodeITBL.VideoPlayback game = new CodeITBL.VideoPlayback()) //{ // game.Run(); //} //Microsoft.Xna.Framework.Media.VideoPlayer vplayer = new Microsoft.Xna.Framework.Media.VideoPlayer(); //Microsoft.Xna.Framework.Media.Video video = new Microsoft.Xna.Framework.Media.Video(); //Microsoft.Xna.Framework.Graphics.GraphicsDevice device = new Microsoft.Xna.Framework.Graphics.GraphicsDevice(); //Microsoft.Xna.Framework.Media.Video v = new Microsoft.Xna.Framework.Media.Video(); //v. //vplayer.pl //Microsoft.Xna.Framework.Media.MediaPlayer player; //VideoPlayer play = new VideoPlayer() //*/ }
private void PerformLogin() { DateTime started = DateTime.Now; btnLogin.Enabled = false; System.Windows.Forms.Application.DoEvents(); var loadingCancalationTokenSource = new CancellationTokenSource(); var loadingCancalationToken = loadingCancalationTokenSource.Token; var loadingTask = new Task(() => { var loadingForm = new frmLoading(); loadingForm.TopMost = true; loadingForm.Show(); while (!loadingCancalationToken.IsCancellationRequested) { Thread.Sleep(50); System.Windows.Forms.Application.DoEvents(); } loadingForm.Close(); }, loadingCancalationTokenSource.Token); loadingTask.Start(); string userName = txtUserName.Text.Trim(); string password = txtPassword.Text; bool hasUsers = false; CodeITDL.CodeITDbContext ctx = null; try { ctx = new CodeITDL.CodeITDbContext(0); if (ctx != null) { CodeITDL.License lic = null; string clientLicense = string.Empty; try { User user = ctx.Users.Where(d => d.UserName == userName && d.Password == password).FirstOrDefault(); lic = ctx.Licenses.Where(s => s.Id == (ctx.UserLicenses.Where(c => c.UserId == (user.Id)).FirstOrDefault()).LicenseId).FirstOrDefault(); } catch(Exception) { } if (lic != null) clientLicense = Encoding.UTF8.GetString(lic.LicenseBytes); if (!CodeITLicence.Licence.ValidateLicenceFromDB(clientLicense)) { System.Windows.Forms.MessageBox.Show("You don't have license. Please contact administrator.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { hasUsers = ctx.Users.Where(x => x.RoleId == (int)Role.Administrator && x.CustomerId == Context.CustomerId).Count() > 0; if (!hasUsers && userName.ToLower().Equals("administrator") && password.Equals("intrensic")) { loadingCancalationTokenSource.Cancel(true); System.Windows.MessageBox.Show("You are logged in as administrator, please add user with administrator role first", "Info", MessageBoxButton.OK, MessageBoxImage.Information); Administration.frmUsers frmUsers = new Administration.frmUsers(); frmUsers.ControlBox = true; frmUsers.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; frmUsers.Icon = Intrensic.Properties.Resources.Intrensic; frmUsers.Name = "Initial User Creation Screen"; frmUsers.isInitailUserFromLogin = true; frmUsers.ShowDialog(); } else if (!hasUsers) { loadingCancalationTokenSource.Cancel(true); System.Windows.MessageBox.Show("There are no defined users and initial login information is not correct, please try again", "Info", MessageBoxButton.OK, MessageBoxImage.Information); txtUserName.Clear(); txtPassword.Clear(); txtUserName.Focus(); LoginAudit.WriteLoginAudit(CodeITConstants.LOGIN_INCORECT_CREDENTIALS_NO_USERS); } else if (hasUsers) { User usr = new User(); usr = ctx.Users.FirstOrDefault(x => x.UserName.ToLower().Equals(userName.ToLower()) && x.Password.ToLower().Equals(password.ToLower()) && x.CustomerId == Context.CustomerId); if (usr == null) usr = new User(); if (usr.Id <= 0) { loadingCancalationTokenSource.Cancel(true); LoginAudit.WriteLoginAudit(CodeITConstants.LOGIN_INCORECT_CREDENTIALS_HAS_USERS); System.Windows.MessageBox.Show("Username and/or password are not correct. Please try again", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } else { foreach (Form frm in System.Windows.Forms.Application.OpenForms) { if (frm.Name == "frmProgressStatus") { //check if user trying to login is user with current upload progress if (!((frmProgressStatus)frm).getOwnerOfUploadProcess.UserName.ToLower().Equals(userName.ToLower())) { loadingCancalationTokenSource.Cancel(true); LoginAudit.WriteLoginAudit(CodeITConstants.LOGIN_WHILE_UPLOAD_IN_PROGRESS_BY_DIFFERENT_USER, usr.Id); System.Windows.MessageBox.Show("There is an active upload process initiated by user: "******"Please wait for the upload process to complete before you are able to login", "Info", MessageBoxButton.OK, MessageBoxImage.Information); return; } else { ((frmProgressStatus)frm).DisableCancelButtonsOnLogout(false); } } } Context.UserId = usr.Id; } if (Context.UserId > 0) { Context.UserId = usr.Id; LoginAudit.WriteLoginAudit(CodeITConstants.LOGIN_SUCCESSFULL); ContextMenuItems(true); txtUserName.Clear(); txtPassword.Clear(); frmUserMainScreen frmMain = new frmUserMainScreen(); frmMain.InitialGoToUpload = loginStartedFromGoProDevice; frmMain.InitialUploadPath = uploadPath; frmMain.Show(); Context.mainForm = frmMain; this.uploadPath = string.Empty; this.loginStartedFromGoProDevice = false; this.Hide(); //Thread.Sleep(5000); loadingCancalationTokenSource.Cancel(true); Context.CheckForGoProDevice(); } } } } } catch (Exception ex) { // } finally { if (ctx != null) { ctx.Dispose(); } loadingCancalationTokenSource.Cancel(true); btnLogin.Enabled = true; } }