public void Test() { var repo = DataAccessor.CreateInstance <TestDataAccessor>(); XmlDocument[] teTypeXml; repo.procTestXMLInternal(out teTypeXml); }
public R Create(DbManagerProxy manager, IObject Parent, int?HACode, params object[] pars) { T acc = DataAccessor.CreateInstance <T>(); IObjectCreator creator = acc as IObjectCreator; return(creator.CreateNew(manager, Parent, HACode) as R); }
public static List <DDOSRedirectorSetting> GetAll() { SiteAccessor ua = DataAccessor.CreateInstance <SiteAccessor>(); List <DDOSRedirectorSetting> lstDomain = new List <DDOSRedirectorSetting>(); Dictionary <int, string> dicDomain = ua.GetActiveDomains(); List <int> lstSelectedDomain = HttpRuntime.Cache[_CacheKey] as List <int>; if (lstSelectedDomain == null) { lstSelectedDomain = PopulateData(); } foreach (int k in dicDomain.Keys) { if (string.Compare("System", dicDomain[k], true) == 0) { continue; } bool flag = false; if (lstSelectedDomain != null && lstSelectedDomain.Contains <int>(k)) { flag = true; } lstDomain.Add(new DDOSRedirectorSetting() { DomainName = dicDomain[k], DomainID = k, Flag = flag }); } return(lstDomain.OrderBy(d => d.DomainName).ToList()); }
public static bool VerifyBackupCode(cmUser user, string code, out List <string> newCodes) { newCodes = null; bool existed = false; using (DbManager dbManager = new DbManager()) { SecondFactorBackupCodeAccessor accessor = DataAccessor.CreateInstance <SecondFactorBackupCodeAccessor>(dbManager); existed = accessor.IsCodeExist(user.ID, code); if (existed) { int count = accessor.RemoveCode(user.ID, code); if (count == 0) { newCodes = GenerateBackupCodes(user.ID, dbManager); } } } if (existed && !user.IsSecondFactorVerified) { SetSecondFactorVerified(user.ID, true); } return(existed); }
public void Test() { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); // ExecuteDictionary. // Dictionary <int, Person> dic; dic = pa.GetPersonDictionary1(); dic = pa.GetPersonDictionary2(); dic = pa.GetPersonDictionary3(); foreach (int id in dic.Keys) { Console.WriteLine("{0}: {1} {2}", id, dic[id].FirstName, dic[id].LastName); } // ExecuteScalarDictionary. // Dictionary <int, string> sdic = pa.GetPersonNameDictionary(); foreach (int id in dic.Keys) { Console.WriteLine("{0}: {1}", id, sdic[id]); } }
public void Test() { TestAccessor ta = DataAccessor.CreateInstance <TestAccessor>(); Person p = ta.SelectByName("Tester", "Testerson"); Assert.AreEqual(2, p.ID); }
public static cmRevision GetRevisionByID(int revisionID) { RevisionAccessor ra = DataAccessor.CreateInstance <RevisionAccessor>(); cmRevision revision = ra.GetByID(revisionID); return(revision); }
public void Test() { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); // ExecuteList. // IList list; list = pa.GetPersonList1(); list = pa.GetPersonList2(); foreach (Person p in list) { Console.WriteLine("{0}: {1} {2}", p.ID, p.FirstName, p.LastName); } // ExecuteScalarList. // List <int> slist = pa.GetPersonIDList(); foreach (int id in slist) { Console.WriteLine("{0}", id); } }
public static void BackupIfNotExists(cmSite site, string path, string relativePath, string name, bool nameAsComments = false) { if (File.Exists(path)) { // if last revision not exist, backup first RevisionAccessor ra = DataAccessor.CreateInstance <RevisionAccessor>(); cmRevision revision = ra.GetLastRevision(site.ID, relativePath); if (revision == null || !File.Exists(Revisions.GetLocalPath(revision.FilePath))) { SqlQuery <cmRevision> query = new SqlQuery <cmRevision>(); string localFile, filePath; localFile = Revisions.GetNewFilePath(out filePath); File.Copy(path, localFile); revision = new cmRevision(); if (nameAsComments) { revision.Comments = name; } else { revision.Comments = string.Format("No revision found for [{0}], make a backup.", name); } revision.SiteID = site.ID; revision.FilePath = filePath; revision.Ins = DateTime.Now; revision.RelativePath = relativePath; revision.UserID = CustomProfile.Current.UserID; query.Insert(revision); } } }
public void Test2() { PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>(); List <Person> list = da.SelectBy("FirstName", "John"); Assert.AreNotEqual(0, list.Count); }
public void XmlRootTest() { var repo = DataAccessor.CreateInstance <TestDataAccessor>(); var now = DateTime.Now; var res = repo.GetSysObjectXml(); Console.Write(_lastQueryExecutionTime); }
public void Test() { TestAccessor ta = DataAccessor.CreateInstance <TestAccessor>(); List <Person> list = ta.GetPersonList(); Assert.AreNotEqual(0, list.Count); }
public void Test() { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); List <Person> list = pa.GetPersonList(2); Assert.That(list, Is.Not.Null); Assert.That(list.Count, Is.LessThanOrEqualTo(2)); }
public void TestXml() { var da = DataAccessor.CreateInstance <BLOBRepository>(); var testObj = da.GetXMLDocTestObject(); var textXML = FromHexString(testObj.FBlob, Encoding.UTF8); textXML.Should().NotBeNull(); }
public void Test1() { TestAccessor ta = DataAccessor.CreateInstance <TestAccessor> /*[a]*/ () /*[/a]*/; Person person = ta.SelectByKey(1); Assert.IsNotNull(person); }
public void Test3() { PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>(); List <Person> list = da.SelectByLastName("Testerson", 1); Assert.AreNotEqual(0, list.Count); }
public void Test4() { PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>(); List <Person> list = da.SelectID(42); Assert.AreEqual(42, list[0].ID); }
public void Test() { TestAccessor pa = DataAccessor.CreateInstance <TestAccessor>(); IDictionary <int, string> dic = pa.GetPersonNameDictionary(); Assert.AreEqual("John", dic[1]); }
public static void ResetSecondFactorAuth(long userID) { using (DbManager dbManager = new DbManager()) { UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager); ua.ResetSecondFactorAuth(userID); } }
public static void SetSecondFactorType(long userID, int secondFactorType) { using (DbManager dbManager = new DbManager()) { UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager); ua.SetSecondFactorType(userID, secondFactorType); } }
public static void SetSecondFactorVerified(long userID, bool verified) { using (DbManager dbManager = new DbManager()) { UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager); ua.SetSecondFactorVerified(userID, verified); } }
public void TestImage() { var da = DataAccessor.CreateInstance <BLOBRepository>(); var testObj = da.GetImageTestObject(); var bytes = HexString2Bytes(testObj.FBlob); bytes.Should().NotBeNull(); //File.WriteAllBytes(@"F:\okos\Temp\file.png", bytes); }
public IEnumerable <Operation> GetTaken() { using (var session = sessionFactory.OpenSession()) { var accessor = DataAccessor.CreateInstance <OperationAccessor>(session); return(accessor.GetListOfTaken()); } }
public void Test() { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); List <Person> list = new List <Person>(); pa.SelectAll(list); Assert.AreNotEqual(0, list.Count); }
public void TransactionTest() { using (DbManager db = new DbManager()) { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); db.BeginTransaction(); // Insert and get id. // Person person = Person.CreateInstance(); person.FirstName = "Crazy"; person.LastName = "Frog"; person.Gender = Gender.Unknown; int id = pa.Insert(db, person); person = pa.SelectByID(db, id); TypeAccessor.WriteConsole(person); Assert.IsNotNull(person); // Update. // person.Gender = Gender.Other; pa.Query.Update(db, person); person = pa.SelectByID(db, person.ID); TypeAccessor.WriteConsole(person); Assert.AreEqual(Gender.Other, person.Gender); // Delete. // pa.Query.Delete(db, person); person = pa.SelectByID(db, person.ID); Assert.IsNull(person); db.CommitTransaction(); // Get All. // List <Person> list = pa.Query.SelectAll(db); foreach (Person p in list) { TypeAccessor.WriteConsole(p); } } }
public void Test() { PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>(); // ExecuteObject. // Assert.IsNotNull(pa.GetByID(1)); Assert.IsNotNull(pa.GetPersonByID(2)); Assert.IsNotNull(pa.GetPersonByName("Tester", "Testerson")); Assert.IsNotNull(pa.SelectByName("Tester", "Testerson")); }
private User GetUser(string login) { using (var session = sessionFactory.OpenSession()) { var userAccessor = DataAccessor.CreateInstance <UserAccessor>(session); var result = userAccessor.GetByLogin(login); return(result); } }
public void Test() { TestAccessor ta = DataAccessor.CreateInstance <TestAccessor>(); Assert.IsTrue(ta.GetName1() is Name1); Assert.IsTrue(ta.GetName2() is Name2); Assert.IsTrue(ta.GetName1List()[0] is Name1); Assert.IsTrue(ta.GetName2List()[0] is Name2); Assert.IsTrue(ta.GetName1Dictionary()[1] is Name1); Assert.IsTrue(ta.GetName2Dictionary()[1] is Name2); }
private static string GenerateSecretKey(long userID) { string secretKey = Guid.NewGuid().ToString().Replace("-", string.Empty); using (DbManager dbManager = new DbManager()) { UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager); ua.SetSecondFactorSecretKey(userID, secretKey, (int)SecondFactorAuthType.GoogleAuthenticator); } return(secretKey); }
public void Test3() { using (DbManager db = new DbManager()) { TestAccessor ta = DataAccessor.CreateInstance <TestAccessor> /*[a]*/ () /*[/a]*/; Person person = ta.SelectByKey(/*[a]*/ db /*[/a]*/, 1); Assert.IsNotNull(person); } }