Ejemplo n.º 1
0
        public static void Login()
        {
            var manager    = new EidssSecurityManager();
            int resultCode = manager.LogIn(BaseSettings.DefaultOrganization, BaseSettings.DefaultUser,
                                           BaseSettings.DefaultPassword);

            if (resultCode != 0)
            {
                string err = string.Format("Could not login under user {0} from organization {1}.",
                                           BaseSettings.DefaultUser, BaseSettings.DefaultOrganization);
                throw new ApplicationException(err);
            }
            m_Trace.Trace(TraceTitle, "EIDSS login successfully.");
        }
Ejemplo n.º 2
0
        public static void Authorize(Login login)
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[bv.common.Core.Localizer.lngEn]);
            Thread.CurrentThread.CurrentCulture   = Thread.CurrentThread.CurrentUICulture;

            if (string.IsNullOrEmpty(login.language) || !Localizer.SupportedLanguages.ContainsKey(login.language))
            {
                throw new AuthLanguageException();
            }

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[login.language]);
            Thread.CurrentThread.CurrentCulture   = Thread.CurrentThread.CurrentUICulture;

            if (!string.IsNullOrEmpty(login.externalSystem) && !SupportedExternalSystem.ContainsKey(login.externalSystem))
            {
                throw new AuthExternalException();
            }

            var security = new EidssSecurityManager();
            var result   = security.LogIn(login.organization, login.user, login.password);

            switch (result)
            {
            case 0:
                break;

            case 1:
                throw new AuthEmptyException();

            case 2:
                throw new AuthNotFoundException();

            case 3:
            case 4:
            case 5:
                throw new AuthVersionException();

            case 6:
                throw new AuthLockedException(security.GetAccountLockTimeout(login.organization, login.user));

            case 9:
                throw new AuthExpiredException();

            default:
                throw new AuthFailedException();
            }

            EidssUserContext.CurrentLanguage = login.language;
        }
Ejemplo n.º 3
0
        public void TestInitialize()
        {
            DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString"));
            ConnectionManager.DefaultInstance.SetCredentials(Config.GetSetting("EidssConnectionString"));
            EidssUserContext.Init();
            context    = ModelUserContext.Instance as EidssUserContext;
            m_Security = new EidssSecurityManager();
            int result = m_Security.LogIn(Organizaton, Admin, AdminPassword);

            Assert.AreEqual(0, result);
            EIDSS_LookupCacheHelper.Init();
            //while(!LookupCache.Filled)
            //    Thread.Sleep(500);
            ModelUserContext.CurrentLanguage = "en";
        }
Ejemplo n.º 4
0
        public void LogInByTicketDeadlockTest()
        {
            EidssSecurityManager target = new EidssSecurityManager();

            if (target.AccessGranted)
            {
                target.LogOut();
            }
            int res = target.LogIn(Organizaton, Admin, AdminPassword);

            Assert.AreEqual(0, res);
            m_Users[0] = (long)EidssUserContext.User.ID;
            //if (target.AccessGranted)
            //    target.LogOut();
            //res = target.LogIn(Organizaton, User, UserPassword);
            //Assert.AreEqual(0, res);
            //m_Users[1] = (long)EidssUserContext.User.ID;
            if (target.AccessGranted)
            {
                target.LogOut();
            }
            var threads     = new List <Thread>();
            int threadCount = 100;

            for (int i = 0; i < threadCount; i++)
            {
                var thread = new Thread(LoginByTicket);
                threads.Add(thread);
                thread.Start();
                Debug.WriteLine("login thread <{0}> is started", i);
            }
            while (true)
            {
                Thread.Sleep(100);
                for (int i = 0; i < threadCount; i++)
                {
                    if (threads[i].IsAlive)
                    {
                        break;
                    }
                    if (i == threadCount - 1)
                    {
                        return;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void FarmPanelCollection()
        {
            EidssUserContext.Init();
            DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString"));
            using (var context = ModelUserContext.Instance as EidssUserContext)
            {
                var target = new EidssSecurityManager();

                int result = target.LogIn(Organizaton, Admin, AdminPassword);
                Assert.AreEqual(0, result);

                using (var manager = DbManagerFactory.Factory.Create(context))
                {
                    var acc     = VetCase.Accessor.Instance(null);
                    var vetcase = (VetCase)acc.CreateNew(manager, null, (int)HACode.Livestock);

                    var panel = vetcase.Farm;

                    var         herdaccessor = VetFarmTree.Accessor.Instance(null);
                    VetFarmTree farm         = panel.FarmTree[0];
                    VetFarmTree herd         = herdaccessor.CreateHerd(manager, panel, farm);
                    VetFarmTree spec         = herdaccessor.CreateSpecies(manager, panel, herd);
                    spec.SpeciesType = spec.SpeciesTypeLookup.FirstOrDefault(c => c.idfsBaseReference == 837790000000);
                    //spec.idfsSpeciesTypeReference = 837790000000;
                    panel.FarmTree.Add(herd);
                    panel.FarmTree.Add(spec);

                    panel.Address.Region     = panel.Address.RegionLookup.FirstOrDefault();
                    panel.Address.Rayon      = panel.Address.RayonLookup.FirstOrDefault();
                    panel.Address.Settlement = panel.Address.SettlementLookup.FirstOrDefault();

                    var animal = (AnimalListItem)AnimalListItem.Accessor.Instance(null).CreateNew(manager, vetcase, (int)HACode.Livestock);
                    animal.idfSpecies = spec.idfParty;
                    animal.idfHerd    = herd.idfParty;
                    animal.idfCase    = vetcase.idfCase;

                    vetcase.AnimalList.Add(animal);
                    //vetcase.Validation += new ValidationEvent(panel_Validation);


                    //acc.Post(manager, vetcase);
                    //vetcase.Validation -= panel_Validation;
                }
            }
        }
Ejemplo n.º 6
0
        public void MyTestInitialize()
        {
            //DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString", ""));
            //ClassLoader.Init("eidss*.dll", Environment.MachineName.Equals("LEONOV") ? @"c:\Projects\EIDSS4\eidss.main\bin\Debug\" : null);
            ClassLoader.Init("eidss*.dll", null);
            DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString", ""));
            EidssUserContext.Init();
            var target = new EidssSecurityManager();

            const string organizaton = "NCDC&PH";
            const string admin       = "test_admin";
            //const string User = "******";
            const string adminPassword = "******";
            //const string UserPassword = "******";

            int result = target.LogIn(organizaton, admin, adminPassword);

            Assert.AreEqual(0, result);
        }
Ejemplo n.º 7
0
        public bool Authorize()
        {
            var security = new EidssSecurityManager();
            var result   = security.LogIn(Organization, UserName, Password);

            if (result == 0) //authorized
            {
                //set current language
                EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(LanguagePreference);
                System.Web.Security.FormsAuthentication.SetAuthCookie(this.UserName, false);
                HttpContext.Current.Session["UserName"] = UserName;
                return(true);
            }
            else
            {
                ErrorMessage = SecurityMessages.GetLoginErrorMessage(result);
                return(false);
            }
        }
Ejemplo n.º 8
0
        public void Login(string Organization, string User, string Password, string Language)
        {
            if (!Localizer.SupportedLanguages.ContainsKey(Language))
            {
                throw new SoapException("Language is not supported", SoapException.ClientFaultCode);
            }
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(Localizer.SupportedLanguages[Language]);

            var security = new EidssSecurityManager();
            var result   = security.LogIn(Organization, User, Password);

            if (result == 0) //authorized
            {
                //set current language
                EidssUserContext.CurrentLanguage = Language;
            }
            else
            {
                throw new SoapException(SecurityMessages.GetLoginErrorMessage(result), SoapException.ClientFaultCode);
            }
        }
Ejemplo n.º 9
0
        public void AccessGrantedTest()
        {
            EidssSecurityManager target = new EidssSecurityManager();

            if (target.AccessGranted)
            {
                target.LogOut();
            }
            bool actual;

            actual = target.AccessGranted;
            Assert.IsFalse(actual);
            int res = target.LogIn(Organizaton, Admin, AdminPassword);

            Assert.AreEqual(0, res);
            actual = target.AccessGranted;
            Assert.IsTrue(actual);
            target.LogOut();
            actual = target.AccessGranted;
            Assert.IsFalse(actual);
        }
Ejemplo n.º 10
0
        public void LogOutTest()
        {
            EidssSecurityManager target = new EidssSecurityManager(); // TODO: Initialize to an appropriate value
            int actual;

            actual = target.LogIn(Organizaton, Admin, AdminPassword);
            Assert.AreEqual(0, actual);
            target.LogOut();
            Assert.AreEqual(false, target.AccessGranted);
            using (DbManager manager = DbManagerFactory.Factory.Create())
            {
                DataTable dt = manager.SetCommand("select * from tstLocalConnectionContext where strConnectionContext=@clientID",
                                                  manager.Parameter("@clientID", EidssUserContext.ClientID)).ExecuteDataTable();
                Assert.AreEqual(1, dt.Rows.Count);
                DataRow row = dt.Rows[0];
                Assert.AreEqual(DBNull.Value, row["idfUserID"]);
                Assert.AreEqual(DBNull.Value, row["binChallenge"]);
                Assert.AreEqual(DBNull.Value, row["idfDataAuditEvent"]);
                Assert.AreEqual(DBNull.Value, row["idfEventID"]);
            }
        }
Ejemplo n.º 11
0
        public ActionResult Layout(string queryId, string layoutId, string ticket, string lang)
        {
            if (!string.IsNullOrEmpty(ticket))
            {
                EidssSecurityManager target = new EidssSecurityManager();
                int res = target.LogIn(ticket);

                if (res == 0)
                {
                    System.Web.Security.FormsAuthentication.SetAuthCookie(EidssUserContext.User.LoginName, false);
                    if (!string.IsNullOrEmpty(lang))
                    {
                        EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(lang);
                    }
                    return(Redirect(String.Format("/{0}{1}?queryId={2}&layoutId={3}", lang, "/Layout/Layout", queryId, layoutId)));
                }
            }

            SetSelectedLanguage();
            return(View("LoginLang", new eidss.avr.mweb.Models.Login()));
        }
Ejemplo n.º 12
0
        public ActionResult LoginLang(string ticket = null, string lang = null)
        {
            //LoginHelper.Logout(this);
            if (!string.IsNullOrEmpty(ticket))
            {
                EidssSecurityManager target = new EidssSecurityManager();
                int res = target.LogIn(ticket);

                if (res == 0)
                {
                    System.Web.Security.FormsAuthentication.SetAuthCookie(EidssUserContext.User.LoginName, false);
                    if (!string.IsNullOrEmpty(lang))
                    {
                        EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(lang);
                    }
                    return(Redirect(String.Format("/{0}{1}", lang, "/QueryLayoutTree/QueryLayoutTree")));
                }
            }

            SetSelectedLanguage();
            return(View(new eidss.avr.mweb.Models.Login()));
        }
Ejemplo n.º 13
0
        public bool LoadReferences(string Organization, string User, string Password,
                                   long[] types, string[] langs,
                                   out BaseReferenceRaw[] refs, out BaseReferenceTranslationRaw[] refs_trans,
                                   out GisBaseReferenceRaw[] gis_refs, out GisBaseReferenceTranslationRaw[] gis_refs_trans)
        {
            refs           = null;
            refs_trans     = null;
            gis_refs       = null;
            gis_refs_trans = null;
            var security = new EidssSecurityManager();
            var result   = security.LogIn(Organization, User, Password);

            if (result == 0) //authorized
            {
                refs           = BaseReferenceRaw.GetList(types);
                refs_trans     = BaseReferenceTranslationRaw.GetList(types, langs);
                gis_refs       = GisBaseReferenceRaw.GetAll();
                gis_refs_trans = GisBaseReferenceTranslationRaw.GetAll(langs);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 14
0
        /*public bool ValidateOnChange()
         * {
         *  if (NewPassword != ConfirmPassword)
         *  {
         *      ErrorMessage = Translator.GetMessageString("msgConfirmPasswordError");
         *      return false;
         *  }
         *  var security = new EidssSecurityManager();
         *  var result = security.LogIn(Organization, UserName, OldPassword);
         *  if (result == 0) //authorized
         *  {
         *      return true;
         *  }
         *  else
         *  {
         *      ErrorMessage = SecurityMessages.GetLoginErrorMessage(result);
         *      return false;
         *  }
         * }*/

        public bool Authorize()
        {
            var security = new EidssSecurityManager();
            var result   = security.LogIn(Organization, UserName, Password);

            switch (result)
            {
            case 0:
                EidssUserContext.CurrentLanguage = Cultures.GetLanguageAbbreviation(LanguagePreference);
                System.Web.Security.FormsAuthentication.SetAuthCookie(this.UserName, false);
                return(true);

            case 6:
                int    lockInMinutes = security.GetAccountLockTimeout(this.Organization, this.UserName);
                string err           = BvMessages.Get("ErrLoginIsLocked", "You have exceeded the number of incorrect login attempts. Please try again in {0} minutes.");
                ErrorMessage = string.Format(err, lockInMinutes);
                return(false);

            default:
                ErrorMessage = SecurityMessages.GetLoginErrorMessage(result);
                return(false);
            }
        }
Ejemplo n.º 15
0
        public HumanCaseInfo[] SaveHumanCases2(string Organization, string User, string Password, string Language, HumanCaseInfo[] hc_in)
        {
            //HttpContext.Current.Request.SaveAs(@"C:\Work\temporary\test.txt", true);
            var security = new EidssSecurityManager();
            var result   = security.LogIn(Organization, User, Password);

            if (result == 0) //authorized
            {
                EidssUserContext.CurrentLanguage      = Language;
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(Language);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(Language);
                Check(PermissionHelper.InsertPermission(EIDSSPermissionObject.HumanCase));
                Check(PermissionHelper.UpdatePermission(EIDSSPermissionObject.HumanCase));
                var list = new List <HumanCaseInfo>();
                hc_in.ToList().ForEach(c =>
                {
                    if (c.Id == 0)
                    {
                        c.NotificationDate              = DateTime.Today;
                        c.NotificationSentBy.Id         = EidssSiteContext.Instance.OrganizationID;
                        c.NotificationSentBy.Name       = EidssSiteContext.Instance.OrganizationName;
                        c.NotificationSentByPerson.Id   = (long)EidssUserContext.User.ID;
                        c.NotificationSentByPerson.Name = EidssUserContext.User.FullName;
                    }
                    try
                    {
                        c.Save(c.Id == 0);
                    }
                    catch (SoapException)
                    {
                    }
                    list.Add(c);
                });
                return(list.ToArray());
            }
            return(null);
        }
Ejemplo n.º 16
0
        //[Ignore]
        public void VsSessionFullTest()
        {
            var acc = VsSession.Accessor.Instance(null);

            manager.BeginTransaction();

            #region создание сессии

            var session = acc.CreateNewT(manager, null);
            Assert.IsNotNull(session);
            var idSession = session.idfVectorSurveillanceSession;

            session.strSessionID      = NeedNewValue;
            session.strFieldSessionID = "testFieldSessionID";
            Assert.IsTrue(session.VsStatusLookup.Count > 0);
            session.VsStatus =
                session.VsStatusLookup.SingleOrDefault(l => l.idfsBaseReference == (long)VsStatusEnum.InProgress);
            Assert.AreEqual(10310001, session.idfsVectorSurveillanceStatus);

            session.datStartDate = DateTime.Now;

            session.strDescription = "created from unit test";
            //Assert.IsTrue(session.PensideTestTypeLookup.Count > 0);

            session.Location.Country = session.Location.CountryLookup.SingleOrDefault(c => c.strCountryName == "Georgia");
            session.Location.Region  = session.Location.RegionLookup.SingleOrDefault(c => c.strRegionName == "Abkhazia");
            session.Location.Rayon   = session.Location.RayonLookup.SingleOrDefault(c => c.strRayonName == "Gagra");

            Assert.IsNotNull(session.Location.Country);
            Assert.IsNotNull(session.Location.Region);
            Assert.IsNotNull(session.Location.Rayon);

            #endregion

            #region создаём векторы

            var accVector = Vector.Accessor.Instance(null);

            //
            var vector1 = AddVector(accVector, manager, session);

            //
            var vector2   = AddVector(accVector, manager, session);
            var idVector1 = vector1.idfVector;

            //проверка hostvector
            Assert.IsNull(vector2.idfHostVector);
            vector2.HostVector = vector1;
            Assert.IsNotNull(vector2.idfHostVector);

            var idVector2 = vector2.idfVector;
            //
            var vector3   = AddVector(accVector, manager, session);
            var idVector3 = vector3.idfVector;

            #endregion

            #region в вектор создаём sample

            var accSample = VectorSample.Accessor.Instance(null);

            //подвешиваем семплы к 1 и 3 векторам
            AddSample(accSample, manager, vector1);
            AddSample(accSample, manager, vector3);

            Assert.IsTrue(session.Samples.Count == 2);
            Assert.IsTrue(vector1.Samples.Count == 1);
            Assert.IsTrue(vector2.Samples.Count == 0);
            Assert.IsTrue(vector3.Samples.Count == 1);

            #endregion

            #region проверяем клонирование, замену в контейнере и установку флагов изменения

            Assert.IsTrue(session.Vectors[0].HasChanges);
            Assert.IsTrue(session.Vectors[0].Location.HasChanges);
            var clonedVector = session.Vectors[0].CloneWithSetup(manager) as Vector;
            Assert.IsNotNull(clonedVector);
            Assert.IsFalse(clonedVector.HasChanges);
            Assert.IsFalse(clonedVector.Location.HasChanges);
            session.Vectors.ReplaceAndSetChange(session.Vectors[0], clonedVector);
            Assert.IsTrue(clonedVector.HasChanges);
            Assert.IsTrue(clonedVector.Location.HasChanges);

            #endregion

            //проверим связность списков
            Assert.IsTrue(session.Vectors.Count > 0);
            Assert.IsTrue(vector1.Vectors.Count == session.Vectors.Count);
            Assert.IsTrue(session.Samples.Count > 0);
            Assert.IsTrue(vector1.Samples.Count + vector3.Samples.Count == session.Samples.Count);

            var target = new EidssSecurityManager();
            int result = target.LogIn(Organizaton, Admin, AdminPassword);
            Assert.AreEqual(0, result);

            #region работа с полевыми тестами Field Tests

            //sample1.isJustCreated = !sample1.isJustCreated; //??? TODO не всегда срабатывает

            foreach (var fieldTest in session.FieldTests)
            {
                Assert.IsNotNull(fieldTest.idfPensideTest);
                Assert.AreEqual(EidssUserContext.User.EmployeeID, fieldTest.idfTestedByPerson);
                Assert.AreEqual(EidssUserContext.User.OrganizationID, fieldTest.idfTestedByOffice);
            }

            //в первом тесте меняем что-либо, чтобы строка реально сохранилась в БД
            // commented variable because of warning
            //int fieldTestsChangedRowsCount = 0;
            if (session.FieldTests.Count > 0)
            {
                var fieldTest = session.FieldTests[0];
                //определим результат, который подходит для данного типа теста

                /*
                 * var results = fieldTest.TypeFieldTestToResultMatrixLookup.Where(c => c.idfsPensideTestName == fieldTest.idfsPensideTestName);
                 * if (fieldTest.PensideTestResultLookup.Count > 0)
                 * {
                 *  if (results.Count() > 0)
                 *  {
                 *      fieldTest.PensideTestResult =
                 *          fieldTest.PensideTestResultLookup.Where(
                 *              c => c.idfsBaseReference == results.ToList()[0].idfsPensideTestResult).ToList()[0];
                 *  }
                 *  else
                 *  {
                 *      fieldTest.PensideTestResult = fieldTest.PensideTestResultLookup[0];
                 *  }
                 * }
                 * fieldTestsChangedRowsCount++;
                 */
            }


            //TODO вставить проверки саммари

            #endregion

            //сохранение сессии со всеми дочерними объектами
            session.Validation += OnSessionValidation;

            foreach (var vector in session.Vectors)
            {
                vector.Validation += OnSessionValidation;
            }

            foreach (var sample in session.Samples)
            {
                sample.Validation += OnSessionValidation;
            }

            /*
             * Assert.IsTrue(acc.Post(manager, session));
             *
             * foreach (var vector in session.PoolsVectors)
             * {
             *  vector.Validation -= OnSessionValidation;
             * }
             *
             * foreach (var sample in session.Samples)
             * {
             *  sample.Validation -= OnSessionValidation;
             * }
             * session.Validation -= OnSessionValidation;
             *
             * //загружаем сохранённую сессию из БД
             * session = acc.SelectByKey(manager, idSession);
             *
             #region Проверки для сессии
             *
             * Assert.IsNotNull(session);
             * Assert.AreEqual(idSession, session.idfVectorSurveillanceSession);
             * Assert.AreNotEqual(NeedNewValue, session.strSessionID);
             * Assert.AreEqual(10310001, session.idfsVectorSurveillanceStatus);
             * Assert.IsTrue(session.strFieldSessionID.Length > 0);
             * Assert.IsTrue(session.strDescription.Length > 0);
             * Assert.IsNotNull(session.datStartDate);
             *
             * //TODO проверить диагнозы
             * //TODO проверить summary
             *
             #endregion
             *
             #region Проверки для векторов
             *
             * vector1 = session.PoolsVectors.Where(c => c.idfVector == idVector1).SingleOrDefault();
             * vector2 = session.PoolsVectors.Where(c => c.idfVector == idVector2).SingleOrDefault();
             * vector3 = session.PoolsVectors.Where(c => c.idfVector == idVector3).SingleOrDefault();
             *
             * Assert.IsNotNull(vector1, "vector1 is null");
             * Assert.IsNotNull(vector2, "vector2 is null");
             * Assert.IsNotNull(vector3, "vector3 is null");
             *
             * Assert.IsTrue(session.PoolsVectors.Count > 0);
             * Assert.IsNotNull(vector1.Vectors);
             * Assert.IsNotNull(vector1.Samples);
             * Assert.IsTrue(vector1.Vectors.Count == session.PoolsVectors.Count);
             * Assert.IsTrue(vector2.Vectors.Count == session.PoolsVectors.Count);
             * Assert.IsTrue(vector3.Vectors.Count == session.PoolsVectors.Count);
             *
             * Assert.IsTrue(session.Samples.Count > 0);
             * Assert.IsTrue(vector1.Samples.Count == session.Samples.Count);
             * Assert.IsTrue(vector2.Samples.Count == session.Samples.Count);
             * Assert.IsTrue(vector3.Samples.Count == session.Samples.Count);
             *
             * //проверить наличие семплов на В1 и В3, отсутствие на В2. Общее кол-во семплов совпадает с сессионными.
             * Assert.IsTrue(vector1.SamplesForThisVector.Count == 1);
             * Assert.IsTrue(vector2.SamplesForThisVector.Count == 0);
             * Assert.IsTrue(vector3.SamplesForThisVector.Count == 1);
             *
             * Assert.IsTrue(vector1.SamplesForThisVector[0].idfVector == vector1.idfVector);
             *
             * //проверить Host у В2
             * Assert.IsNotNull(vector2.idfHostVector);
             *
             * //проверим на одном векторе
             * Assert.AreEqual(idVector1, vector1.idfVector);
             * Assert.AreNotEqual(NeedNewValue, vector1.strVectorID);
             * Assert.IsNotNull(vector1.VsVectorType);
             * Assert.IsNotNull(vector1.VsVectorSubType);
             * Assert.IsNotNull(vector1.datCollectionDateTime);
             * Assert.IsTrue(vector1.strSessionID.Length > 0);
             * Assert.IsNotNull(vector1.CollectedByOffice);
             * Assert.IsTrue(vector1.intQuantity > 0);
             * Assert.IsTrue(vector1.strFieldVectorID.Length > 0);
             * Assert.IsTrue(vector1.intElevation > 0);
             * Assert.IsNotNull(vector1.VsSurrounding);
             * Assert.IsTrue(vector1.strGEOReferenceSources.Length > 0);
             * //Assert.IsNotNull(vector1.Collector);
             * Assert.IsTrue(vector1.intCollectionEffort > 0);
             * Assert.IsNotNull(vector1.CollectionMethod);
             * Assert.IsNotNull(vector1.BasisOfRecord);
             * Assert.IsNotNull(vector1.AnimalGender);
             * Assert.IsNotNull(vector1.Identifier);
             * Assert.IsNotNull(vector1.datIdentifiedDateTime);
             * Assert.IsNotNull(vector1.IdentificationMethod);
             * Assert.IsNotNull(vector1.DayPeriod);
             *
             #endregion
             *
             #region Проверки для семплов (samples)
             *
             * //проверим на одном семпле
             * var sample1 = vector3.SamplesForThisVector[0];
             *
             * Assert.IsTrue(sample1.idfMaterial == sample3.idfMaterial);
             * Assert.IsNotNull(sample1.idfVectorSurveillanceSession);
             * Assert.IsNotNull(sample1.idfVector);
             * Assert.IsNotNull(sample1.idfParty);
             * Assert.IsNotNull(sample1.idfsVectorType);
             * Assert.IsNotNull(sample1.idfsVectorSubType);
             * //Assert.IsNotNull(sample1.SampleType);
             * Assert.IsTrue(sample1.strFieldBarcode.Length > 0);
             * Assert.IsNotNull(sample1.datCollectionDateTime);
             * Assert.IsNotNull(sample1.idfFieldCollectedByOffice);
             * //TODO это поле должно приходить не нулевым, когда доделают AccessionIn
             * //Assert.IsNotNull(sample1.idfsAccessionCondition);
             * Assert.IsTrue(sample1.strNote.Length > 0);
             *
             #endregion
             *
             #region Проверки для полевых тестов Field Tests
             *
             * Assert.IsTrue(session.FieldTests.Count > 0);
             *
             * if (fieldTestsChangedRowsCount > 0)
             * {
             *  //столько тестов должно быть с не пустым результатом
             *  //Assert.AreEqual(session.FieldTests.Where(c => c.PensideTestResult != null).Count(),
             *  //                fieldTestsChangedRowsCount);
             * }
             *
             #endregion
             */
        }
Ejemplo n.º 17
0
        public void UpdateLayoutDetailSettingsTest()
        {
            lock (m_LayoutDB.Connection)
            {
                OpenConnection();
                // create layout under admin
                var securityManager = new EidssSecurityManager();
                int result          = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.Admin, BaseReportTests.AdminPassword);
                Assert.AreEqual(0, result);

                long layoutId = CreateLayout();

                var layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                var row          = (LayoutDetailDataSet.LayoutRow)layoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, row.idfPerson);

                row.strDefaultLayoutName = "English name";
                row.strLayoutName        = "russian";

                UpdateLayout(layoutDetail);

                var newLayoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                var newRow          = (LayoutDetailDataSet.LayoutRow)newLayoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);

                securityManager.LogOut();
                CloseConnection();

                // check that layout under user has the same chart options
                OpenConnection();
                result = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.User, BaseReportTests.UserPassword);
                Assert.AreEqual(0, result);

                layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);

                Assert.AreNotEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);

                UpdateLayout(layoutDetail);

                newLayoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                newRow          = (LayoutDetailDataSet.LayoutRow)newLayoutDetail.Layout.Rows[0];

                Assert.AreEqual(EidssUserContext.User.EmployeeID, newRow.idfPerson);
                securityManager.LogOut();
                CloseConnection();

                // check that layout under admin has original options
                OpenConnection();

                result = securityManager.LogIn(BaseReportTests.Organizaton, BaseReportTests.Admin, BaseReportTests.AdminPassword);
                Assert.AreEqual(0, result);

                layoutDetail = (LayoutDetailDataSet)m_LayoutDB.GetDetail(layoutId);
                Assert.AreEqual(1, layoutDetail.Layout.Rows.Count);
                //row = (LayoutDetailDataSet.LayoutRow) layoutDetail.Layout.Rows[0];

                DeleteLayout(layoutId);
                securityManager.LogOut();
                CloseConnection();
            }
        }