public bool ValidateLicense() { FileCryptography.DoDecrypt(filename, null); string decryptedData = FileCryptography.decryptedData; if (!string.IsNullOrEmpty(decryptedData)) { string[] prodCatalog = decryptedData.Split('%'); string[] strLic = prodCatalog[0].ToString().Split('|');; // decryptedData.Split('|'); // if ((name == strLic[0]) && (email == strLic[1]) && (licensekey == strLic[2]) && (EntropyGenerator.GetSystemInfo("") == strLic[3])) if ((name == strLic[0]) && (email == strLic[1]) && (licensekey == strLic[2])) { KnowledgeMatrix.Properties.Settings.Default.IP = EntropyGenerator.GetIPForMachine(); KnowledgeMatrix.Properties.Settings.Default.Authenicated = "true"; KnowledgeMatrix.Properties.Settings.Default.Setting = EntropyGenerator.GetSystemInfo(""); KnowledgeMatrix.Properties.Settings.Default.ProductKey = strLic[4]; KnowledgeMatrix.Properties.Settings.Default.DateOfActivation = DateTime.Now; KnowledgeMatrix.Properties.Settings.Default.Save(); FileCryptography.encryptedData = prodCatalog[1]; FileCryptography.entropy = EntropyGenerator.GetKeyBytesForMachine(); FileCryptography.FileName = KnowledgeMatrix.Framework.Utility.XML_QUESTION_NAME; FileCryptography.DoEncrypt(); // FileCryptography.DoEncrypt(prodCatalog[1], KnowledgeMatrix.Framework.Utility.XML_QUESTION_NAME, null); return(true); } else { KnowledgeMatrix.Properties.Settings.Default.IP = "0.0.0.0"; KnowledgeMatrix.Properties.Settings.Default.Authenicated = "false"; KnowledgeMatrix.Properties.Settings.Default.Setting = ""; KnowledgeMatrix.Properties.Settings.Default.ProductKey = ""; KnowledgeMatrix.Properties.Settings.Default.DateOfActivation = DateTime.MaxValue; KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate = DateTime.MaxValue; KnowledgeMatrix.Properties.Settings.Default.Save(); return(false); } } else { KnowledgeMatrix.Properties.Settings.Default.IP = "0.0.0.0"; KnowledgeMatrix.Properties.Settings.Default.Authenicated = "false"; KnowledgeMatrix.Properties.Settings.Default.Setting = ""; KnowledgeMatrix.Properties.Settings.Default.ProductKey = ""; KnowledgeMatrix.Properties.Settings.Default.DateOfActivation = DateTime.MaxValue; KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate = DateTime.MaxValue; KnowledgeMatrix.Properties.Settings.Default.Save(); return(false); } }
public void GenerateLicense() { StringBuilder strLic = new StringBuilder(); strLic.Append(name); strLic.Append("|"); strLic.Append(email); strLic.Append("|"); strLic.Append(LicenseKey); strLic.Append("|"); systeminfo = EntropyGenerator.GetSystemInfo(""); strLic.Append(systeminfo); strLic.Append("|"); productId = Guid.NewGuid().ToString().Replace("-", "").Remove(25); strLic.Append(productId); if (string.IsNullOrWhiteSpace(IP)) { IP = EntropyGenerator.GetIPForMachine(); } //Include the Product Catalog along with the //License info string prodCatalog = System.IO.File.ReadAllText(Application.StartupPath + Utility.FolderType() + @"ProductsManagement\QuestionMaster.txt"); strLic.Append("%"); strLic.Append(prodCatalog); filename = FileCryptography.DoEncrypt(strLic.ToString(), filename, IP); //For Admin Generate Database AdminDatabaseMgmt obj = new AdminDatabaseMgmt(); obj.name = name; obj.email = email; obj.Licensekey = LicenseKey; obj.SystemInfo = systeminfo; obj.ProductId = productId; obj.IP = IP; obj.phoneNumber = phoneNumber; obj.Add(); }
public void RegisterUser() { StringBuilder strLic = new StringBuilder(); strLic.Append(name); strLic.Append("|"); strLic.Append(email); strLic.Append("|"); strLic.Append(organisationName); strLic.Append("|"); strLic.Append(phoneNumber); strLic.Append("|"); systeminfo = EntropyGenerator.GetSystemInfo(""); strLic.Append(systeminfo); strLic.Append("|"); strLic.Append(EntropyGenerator.GetIPForMachine()); filename = FileCryptography.DoEncrypt(strLic.ToString(), filename, KnowledgeMatrix.Properties.Settings.Default.RegistrationKey); //FileCryptography.DoDecrypt(filename, Properties.Settings.Default.RegistrationKey); }
static void Main() { // string [] ab=Environment.GetCommandLineArgs(); //MessageBox.Show(ab[0]); // AuthorizationOperations obj = new AuthorizationOperations(); // obj.isUserAccessible(OperationNames.TypeOfOperations.eTutor_Manage); // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionHandler); // Set the unhandled exception mode to force all Windows Forms errors // to go through our handler. Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Utility.compress(@"Second Standard Science - NSO.txt"); // Add the event handler for handling non-UI thread exceptions to the event. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionHandler); SplashScreen.SplashScreen.ShowSplashScreen(); Application.DoEvents(); SplashScreen.SplashScreen.SetStatus("Validating App Installation..."); //Thread ms_oThread = null; //ms_oThread = new Thread(new ThreadStart(ShowForm)); //ms_oThread.IsBackground = true; //ms_oThread.SetApartmentState(ApartmentState.MTA); //ms_oThread.Start(); //Console.WriteLine("Before sleep"); System.Threading.Thread.Sleep(2500); //Console.WriteLine("After sleep"); validateAndCreateDirectory(@"QuestionPaper"); validateAndCreateDirectory(@"QuestionBank"); validateAndCreateDirectory(@"MockTest"); validateAndCreateDirectory(@"eTutor"); validateAndCreateDirectory(@"ProductsManagement"); //if (!Directory.Exists(Application.StartupPath + @"\QuestionPaper\")) // Directory.CreateDirectory(Application.StartupPath + @"\QuestionPaper\"); //if (!Directory.Exists(Application.StartupPath + @"\QuestionBank\")) // Directory.CreateDirectory(Application.StartupPath + @"\QuestionBank\"); //if (!Directory.Exists(Application.StartupPath + @"\MockTest\")) // Directory.CreateDirectory(Application.StartupPath + @"\MockTest\"); //if (!Directory.Exists(Application.StartupPath + @"\eTutor\")) // Directory.CreateDirectory(Application.StartupPath + @"\eTutor\"); //if (!Directory.Exists(Application.StartupPath + @"\ProductsManagement\")) // Directory.CreateDirectory(Application.StartupPath + @"\ProductsManagement\"); // MessageBox.Show(EntropyGenerator.GetIPForMachine()); // MessageBox.Show(Properties.Settings.Default.IP); // Properties.Settings.Default.Authenicated = "false"; // Properties.Settings.Default.Save(); // MessageBox.Show(Utility.isAppValidated().ToString()); //MessageBox.Show(Application.StartupPath); //EncDec.Encrypt(@"C:\Users\224702\Desktop\Sample.txt", @"C:\Users\224702\Desktop\Sample1.txt", @"127.0.0.1"); //EncDec.Decrypt(@"C:\Users\224702\Desktop\Sample1.txt", @"C:\Users\224702\Desktop\Sample2.txt", @"127.0.0.1"); // Utility.ResetActivation(); if (Utility.isAppValidated()) { //check if the ip is same as in settings SplashScreen.SplashScreen.SetStatus("Validating User Info... "); if (KnowledgeMatrix.Properties.Settings.Default.IP != EntropyGenerator.GetIPForMachine()) { if (KnowledgeMatrix.Properties.Settings.Default.Setting == EntropyGenerator.GetSystemInfo("")) { if (KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate != null && KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate >= DateTime.Now)//Check the datetime { SplashScreen.SplashScreen.CloseForm(); MessageBox.Show("The system is tampered. Contact Administrator."); } else { SplashScreen.SplashScreen.CloseForm(); KnowledgeMatrix.Properties.Settings.Default.IP = EntropyGenerator.GetIPForMachine(); KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate = DateTime.Now; KnowledgeMatrix.Properties.Settings.Default.Save(); MessageBox.Show("The app is used under different IP but in same machine."); Application.EnableVisualStyles(); // Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new frmMasterDetailGrid()); Application.Run(new Form1()); } } else { MessageBox.Show("The app is tampered. Contact Administrator."); } } else { if (KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate != null && KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate >= DateTime.Now)//Check the datetime { MessageBox.Show("The system is tampered. Contact Administrator."); } else { SplashScreen.SplashScreen.CloseForm(); KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate = DateTime.Now; KnowledgeMatrix.Properties.Settings.Default.Save(); Application.EnableVisualStyles(); // Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); //Application.Run(new frmMasterDetailGrid()); } } } else { SplashScreen.SplashScreen.CloseForm(); //FileCryptography.DoEncryptDecrypt(); KnowledgeMatrix.Properties.Settings.Default.LastAccessedDate = DateTime.Now; KnowledgeMatrix.Properties.Settings.Default.Save(); Application.EnableVisualStyles(); // Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); // Application.Run(new frmMasterDetailGrid()); if (System.Environment.UserInteractive) { //string parameter = string.Concat(args); //switch (parameter) //{ //case "--install": //DemoWinAppInstaller obj=new DemoWinAppInstaller(); //obj = null;//.Install();//(new string[] { Assembly.GetExecutingAssembly().Location }); // break; //case "--uninstall": // ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location }); // break; //} } else { } } }