private void WriteLog(string message) { HarperACL.AppEventLog log = new HarperACL.AppEventLog(); log.aelAppName = "ForgotPassword"; log.aelDateCreated = DateTime.Now; log.aelMessage1 = string.Empty; log.aelMessage2 = string.Empty; log.aelSeverity = "INFO"; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(db_connection)) { context.AppEventLogs.InsertOnSubmit(log); context.SubmitChanges(); } }
public void TestTemp() { using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { //var lastcustomer = (from a in context.Customers // select new { cusnum = long.Parse(a.cusCustNum) }) // .OrderByDescending(x => x.cusnum) // .ToList(); for (int i = 0; i < 20; i++) { DateTime end1 = new DateTime(); DateTime end2 = new DateTime(); DateTime start1 = new DateTime(); DateTime start2 = new DateTime(); start1 = DateTime.Now; var lastcustomer1 = (from a in context.Customers select new { cusnum = Convert.ToInt64(a.cusCustNum) }) .OrderByDescending(x => x.cusnum) .Take(1).Single(); long newcustnum = lastcustomer1.cusnum + 1; end1 = DateTime.Now; start2 = DateTime.Now; newcustnum = 0; List <string> lastcustomer = (from a in context.Customers select a.cusCustNum).ToList(); List <long> cusnumbs = new List <long>(); foreach (string cus in lastcustomer) { cusnumbs.Add(long.Parse(cus)); } cusnumbs.Sort(); cusnumbs.Reverse(); newcustnum = cusnumbs[0]; newcustnum++; end2 = DateTime.Now; TimeSpan method1 = end1 - start1; TimeSpan method2 = end2 - start2; System.Diagnostics.Debug.WriteLine(string.Format("Old {0}: vs New: {1}", new object[] { method2.TotalMilliseconds, method1.TotalMilliseconds })); } } }
public void TestTemp() { using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { //var lastcustomer = (from a in context.Customers // select new { cusnum = long.Parse(a.cusCustNum) }) // .OrderByDescending(x => x.cusnum) // .ToList(); for (int i = 0; i < 20; i++) { DateTime end1 = new DateTime(); DateTime end2 = new DateTime(); DateTime start1 = new DateTime(); DateTime start2 = new DateTime(); start1 = DateTime.Now; var lastcustomer1 = (from a in context.Customers select new { cusnum = Convert.ToInt64(a.cusCustNum) }) .OrderByDescending(x => x.cusnum) .Take(1).Single(); long newcustnum = lastcustomer1.cusnum + 1; end1 = DateTime.Now; start2 = DateTime.Now; newcustnum = 0; List<string> lastcustomer = (from a in context.Customers select a.cusCustNum).ToList(); List<long> cusnumbs = new List<long>(); foreach (string cus in lastcustomer) { cusnumbs.Add(long.Parse(cus)); } cusnumbs.Sort(); cusnumbs.Reverse(); newcustnum = cusnumbs[0]; newcustnum++; end2 = DateTime.Now; TimeSpan method1 = end1 - start1; TimeSpan method2 = end2 - start2; System.Diagnostics.Debug.WriteLine(string.Format("Old {0}: vs New: {1}", new object[] { method2.TotalMilliseconds, method1.TotalMilliseconds })); } } }
public void TestAllLogins() { int good = 0; int bad = 0; GateKeeperProvider currentProvider = (GateKeeperProvider)Membership.Provider; string u; string p; HarperACL.Authenticator auth; SupportClasses.BaseResponse baseResponse; List <HarperACL.Customer> customers; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.Customers join b in context.NetMemberships on a.cusID equals b.cusID where a.cusUserName != null && b.nmbDateEnd >= DateTime.Now && a.cusFirstName == "" && a.cusLastName == "" select a).ToList(); } foreach (HarperACL.Customer customer in customers) { u = customer.cusUserName; p = currentProvider.GetPassword(u, ""); p = HarperCRYPTO.Cryptography.EncryptData(p); auth = new HarperACL.Authenticator(u, p, false, false, false); baseResponse = auth.Login(); if (baseResponse.TypedResponse != null && baseResponse.TypedResponse.Success && (baseResponse.TypedResponse as SupportClasses.LoginResponse).Authenticated) { good++; } else { bad++; } System.Threading.Thread.Sleep(10); } Assert.AreEqual(true, true); }
public void BulkEncrypt() { GateKeeperProvider currentProvider = (GateKeeperProvider)Membership.Provider; string u; string p; List <HarperACL.Customer> customers; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.Customers join b in context.NetMemberships on a.cusID equals b.cusID where (a.cusEncryptedPassword == null || a.cusEncryptedPassword == "") && b.nmbDateEnd >= DateTime.Now && a.cusDateUpdated < DateTime.Now.AddDays(-2) select a).ToList(); foreach (HarperACL.Customer customer in customers) { if (!string.IsNullOrEmpty(customer.cusUserName)) { string z = currentProvider.GetPassword(customer.cusUserName, ""); if (!string.IsNullOrEmpty(z)) { string enc = HarperCRYPTO.Cryptography.EncryptData(z); if (!string.IsNullOrEmpty(enc)) { customer.cusEncryptedPassword = enc; customer.cusDateUpdated = DateTime.Now; } } } } context.SubmitChanges(); } Assert.AreEqual(true, true); }
private void WriteLog(Exception e) { HarperACL.AppEventLog log = new HarperACL.AppEventLog(); log.aelAppName = "ForgotPassword"; log.aelDateCreated = DateTime.Now; log.aelMessage1 = string.Empty; log.aelMessage2 = string.Empty; log.aelMessage3 = e.Message; log.aelSeverity = "EXCEPTION"; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(db_connection)) { context.AppEventLogs.InsertOnSubmit(log); context.SubmitChanges(); } }
public void BulkEncrypt() { GateKeeperProvider currentProvider = (GateKeeperProvider)Membership.Provider; string u; string p; List<HarperACL.Customer> customers; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.Customers join b in context.NetMemberships on a.cusID equals b.cusID where (a.cusEncryptedPassword == null || a.cusEncryptedPassword == "") && b.nmbDateEnd >= DateTime.Now && a.cusDateUpdated < DateTime.Now.AddDays(-2) select a).ToList(); foreach (HarperACL.Customer customer in customers) { if (!string.IsNullOrEmpty(customer.cusUserName)) { string z = currentProvider.GetPassword(customer.cusUserName, ""); if (!string.IsNullOrEmpty(z)) { string enc = HarperCRYPTO.Cryptography.EncryptData(z); if (!string.IsNullOrEmpty(enc)) { customer.cusEncryptedPassword = enc; customer.cusDateUpdated = DateTime.Now; } } } } context.SubmitChanges(); } Assert.AreEqual(true, true); }
public void TestAllLogins() { int good = 0; int bad = 0; GateKeeperProvider currentProvider = (GateKeeperProvider)Membership.Provider; string u; string p; HarperACL.Authenticator auth; SupportClasses.BaseResponse baseResponse; List<HarperACL.Customer> customers; using (HarperACL.ACLDataDataContext context = new HarperACL.ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { customers = (from a in context.Customers join b in context.NetMemberships on a.cusID equals b.cusID where a.cusUserName != null && b.nmbDateEnd >= DateTime.Now && a.cusFirstName == "" && a.cusLastName == "" select a).ToList(); } foreach (HarperACL.Customer customer in customers) { u = customer.cusUserName; p = currentProvider.GetPassword(u, ""); p = HarperCRYPTO.Cryptography.EncryptData(p); auth = new HarperACL.Authenticator(u, p, false, false, false); baseResponse = auth.Login(); if (baseResponse.TypedResponse != null && baseResponse.TypedResponse.Success && (baseResponse.TypedResponse as SupportClasses.LoginResponse).Authenticated) { good++; } else { bad++; } System.Threading.Thread.Sleep(10); } Assert.AreEqual(true, true); }