Esempio n. 1
0
        public void Test()
        {
            var repo = DataAccessor.CreateInstance <TestDataAccessor>();

            XmlDocument[] teTypeXml;
            repo.procTestXMLInternal(out teTypeXml);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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]);
            }
        }
Esempio n. 6
0
        public void Test()
        {
            TestAccessor ta = DataAccessor.CreateInstance <TestAccessor>();
            Person       p  = ta.SelectByName("Tester", "Testerson");

            Assert.AreEqual(2, p.ID);
        }
Esempio n. 7
0
        public static cmRevision GetRevisionByID(int revisionID)
        {
            RevisionAccessor ra       = DataAccessor.CreateInstance <RevisionAccessor>();
            cmRevision       revision = ra.GetByID(revisionID);

            return(revision);
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
        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);
                }
            }
        }
Esempio n. 10
0
        public void Test2()
        {
            PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>();

            List <Person> list = da.SelectBy("FirstName", "John");

            Assert.AreNotEqual(0, list.Count);
        }
Esempio n. 11
0
        public void XmlRootTest()
        {
            var repo = DataAccessor.CreateInstance <TestDataAccessor>();
            var now  = DateTime.Now;
            var res  = repo.GetSysObjectXml();

            Console.Write(_lastQueryExecutionTime);
        }
Esempio n. 12
0
        public void Test()
        {
            TestAccessor ta = DataAccessor.CreateInstance <TestAccessor>();

            List <Person> list = ta.GetPersonList();

            Assert.AreNotEqual(0, list.Count);
        }
Esempio n. 13
0
        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));
        }
Esempio n. 14
0
        public void TestXml()
        {
            var da      = DataAccessor.CreateInstance <BLOBRepository>();
            var testObj = da.GetXMLDocTestObject();
            var textXML = FromHexString(testObj.FBlob, Encoding.UTF8);

            textXML.Should().NotBeNull();
        }
Esempio n. 15
0
        public void Test1()
        {
            TestAccessor ta = DataAccessor.CreateInstance <TestAccessor> /*[a]*/ () /*[/a]*/;

            Person person = ta.SelectByKey(1);

            Assert.IsNotNull(person);
        }
Esempio n. 16
0
        public void Test3()
        {
            PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>();

            List <Person> list = da.SelectByLastName("Testerson", 1);

            Assert.AreNotEqual(0, list.Count);
        }
Esempio n. 17
0
        public void Test4()
        {
            PersonAccessor da = DataAccessor.CreateInstance <PersonAccessor>();

            List <Person> list = da.SelectID(42);

            Assert.AreEqual(42, list[0].ID);
        }
Esempio n. 18
0
        public void Test()
        {
            TestAccessor pa = DataAccessor.CreateInstance <TestAccessor>();

            IDictionary <int, string> dic = pa.GetPersonNameDictionary();

            Assert.AreEqual("John", dic[1]);
        }
Esempio n. 19
0
 public static void ResetSecondFactorAuth(long userID)
 {
     using (DbManager dbManager = new DbManager())
     {
         UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager);
         ua.ResetSecondFactorAuth(userID);
     }
 }
Esempio n. 20
0
 public static void SetSecondFactorType(long userID, int secondFactorType)
 {
     using (DbManager dbManager = new DbManager())
     {
         UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager);
         ua.SetSecondFactorType(userID, secondFactorType);
     }
 }
Esempio n. 21
0
 public static void SetSecondFactorVerified(long userID, bool verified)
 {
     using (DbManager dbManager = new DbManager())
     {
         UserAccessor ua = DataAccessor.CreateInstance <UserAccessor>(dbManager);
         ua.SetSecondFactorVerified(userID, verified);
     }
 }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        public IEnumerable <Operation> GetTaken()
        {
            using (var session = sessionFactory.OpenSession())
            {
                var accessor = DataAccessor.CreateInstance <OperationAccessor>(session);

                return(accessor.GetListOfTaken());
            }
        }
Esempio n. 24
0
        public void Test()
        {
            PersonAccessor pa = DataAccessor.CreateInstance <PersonAccessor>();

            List <Person> list = new List <Person>();

            pa.SelectAll(list);

            Assert.AreNotEqual(0, list.Count);
        }
Esempio n. 25
0
        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);
                }
            }
        }
Esempio n. 26
0
    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"));
    }
Esempio n. 27
0
        private User GetUser(string login)
        {
            using (var session = sessionFactory.OpenSession())
            {
                var userAccessor = DataAccessor.CreateInstance <UserAccessor>(session);

                var result = userAccessor.GetByLogin(login);

                return(result);
            }
        }
Esempio n. 28
0
        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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        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);
            }
        }