Exemplo n.º 1
0
        public IMenuAction RegisterAllAvrReports()
        {
            AvrReportsCategory.SmallIconIndex = (int)MenuIconsSmall.LaunchAVR;

            string avrPermissions = PermissionHelper.SelectPermission(EIDSSPermissionObject.AVRReport);

            if (EidssUserContext.User.HasPermission(avrPermissions))
            {
                int order = 0;
                foreach (KeyValuePair <long, string> pair in GetAvrQueries())
                {
                    order += 100;
                    long   queryId   = pair.Key;
                    string queryName = pair.Value;

                    EidssUserContext.CheckUserLoggedIn();
                    List <AvrTreeElement> layouts         = AvrQueryLayoutTreeDbHelper.ReLoadLayouts(true, queryId);
                    List <AvrTreeElement> readOnlyLayouts = layouts.Where(l => l.ReadOnly).ToList();
                    if (readOnlyLayouts.Count == 0)
                    {
                        continue;
                    }
                    List <AvrTreeElement> folders = AvrQueryLayoutTreeDbHelper.ReLoadFolders(true, queryId);

                    DeleteAvrEmptyFolders(readOnlyLayouts, folders);

                    IMenuAction queryMenuAction = AddEmptyAvrMenuAction(AvrReportsCategory, queryName, order);

                    CreateAvrFoldersLayoutsMenu(queryMenuAction, readOnlyLayouts, folders);
                }
            }

            return(AvrReportsCategory);
        }
Exemplo n.º 2
0
        public void GetQueriesInfoTest()
        {
            const string queryCountSQL = @"select count (*) from tasQuery where blnSubQuery = 0";

            lock (m_LayoutDB.Connection)
            {
                EidssUserContext.CheckUserLoggedIn();

                LookupManager.ClearByTable("Query");
                LookupManager.ClearAndReloadOnIdle();
                int queryCount       = GetCount(queryCountSQL);
                int actualQueryCount = AvrQueryLayoutTreeDbHelper.ReLoadQueries().Count;
                Assert.AreEqual(queryCount, actualQueryCount);
            }
        }
Exemplo n.º 3
0
        public void GetLayoutInfoTest()
        {
            string layoutCountSQL =
                string.Format(@"select count (*) from tasLayout where idflQuery = {0}  and (idfPerson = {1}  or blnShareLayout=1)",
                              BaseReportTests.QueryId, (long)EidssUserContext.User.EmployeeID);
            string folderCountSQL = @"select count (*) from tasLayoutFolder where idflQuery = " + BaseReportTests.QueryId;

            lock (m_LayoutDB.Connection)
            {
                EidssUserContext.CheckUserLoggedIn();

                PresenterFactory.SharedPresenter.SharedModel.SelectedQueryId = BaseReportTests.QueryId;

                int layoutCount = GetCount(layoutCountSQL);
                int folderCount = GetCount(folderCountSQL);

                LookupManager.ClearAndReloadOnIdle();
                int actualLayoutCount = AvrQueryLayoutTreeDbHelper.LoadLayouts(false, BaseReportTests.QueryId).Count;
                Assert.AreEqual(layoutCount, actualLayoutCount);

                int actualFolderCount = AvrQueryLayoutTreeDbHelper.LoadFolders(false, BaseReportTests.QueryId).Count;
                Assert.AreEqual(folderCount, actualFolderCount);
            }
        }
Exemplo n.º 4
0
        public void CreateModifyDeleteFoldersTest()
        {
            lock (m_SyncLock)
            {
                EidssUserContext.CheckUserLoggedIn();

                PresenterFactory.SharedPresenter.SharedModel.SelectedQueryId = m_TestQueryId;

                List <AvrTreeElement> original = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId);

                AvrTreeElement folder1 = CreateFolderItem(null, "Folder1", "Nat f1");
                AvrQueryLayoutTreeDbHelper.SaveFolder(folder1.ID, folder1.ParentID, m_TestQueryId, folder1.DefaultName, folder1.NationalName);
                AvrTreeElement folder2 = CreateFolderItem(null, "Folder2", "Nat f2");
                AvrQueryLayoutTreeDbHelper.SaveFolder(folder2.ID, folder2.ParentID, m_TestQueryId, folder2.DefaultName, folder2.NationalName);
                AvrTreeElement folder3 = CreateFolderItem(null, "Folder3", "Nat f3");
                AvrQueryLayoutTreeDbHelper.SaveFolder(folder3.ID, folder3.ParentID, m_TestQueryId, folder3.DefaultName, folder3.NationalName);

                LookupManager.ClearAndReloadOnIdle();

                List <AvrTreeElement> saved1 = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId);
                Assert.AreEqual(original.Count + 3, saved1.Count, "some folders not saved");

                AvrTreeElement savedFolder1 = saved1.Find(ById(folder1.ID));
                Assert.IsNotNull(savedFolder1);
                AvrTreeElement savedFolder2 = saved1.Find(ById(folder2.ID));
                Assert.IsNotNull(savedFolder2);
                AvrTreeElement savedFolder3 = saved1.Find(ById(folder3.ID));
                Assert.IsNotNull(savedFolder3);

                Assert.AreEqual(m_TestQueryId, savedFolder1.ParentID);
                Assert.AreEqual(m_TestQueryId, savedFolder2.ParentID);
                Assert.AreEqual(m_TestQueryId, savedFolder3.ParentID);

                AvrQueryLayoutTreeDbHelper.SaveFolder(savedFolder2.ID, savedFolder1.ID,
                                                      m_TestQueryId, savedFolder2.DefaultName, savedFolder2.NationalName);
                AvrQueryLayoutTreeDbHelper.SaveFolder(savedFolder3.ID, savedFolder2.ID,
                                                      m_TestQueryId, savedFolder3.DefaultName, savedFolder3.NationalName);

                LookupManager.ClearAndReloadOnIdle();

                List <AvrTreeElement> saved2 = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId);

                AvrTreeElement updatedFolder2 = saved2.Find(ById(folder2.ID));
                Assert.IsNotNull(updatedFolder2);
                AvrTreeElement updatedFolder3 = saved2.Find(ById(folder3.ID));
                Assert.IsNotNull(updatedFolder3);
                Assert.AreEqual(folder1.ID, updatedFolder2.ParentID);
                Assert.AreEqual(folder2.ID, updatedFolder3.ParentID);

                int oldFoldersCount = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId).Count;

                // delete saved folders

                using (var avrDbService = new Folder_DB())
                {
                    Assert.IsTrue(avrDbService.Delete(folder3.ID),
                                  string.Format("could not delete folder '{0}' because of '{1}'", folder3.ID, avrDbService.LastError));
                    Assert.IsTrue(avrDbService.Delete(folder2.ID),
                                  string.Format("could not delete folder '{0}' because of '{1}'", folder2.ID, avrDbService.LastError));
                    Assert.IsTrue(avrDbService.Delete(folder1.ID),
                                  string.Format("could not delete folder '{0}' because of '{1}'", folder1.ID, avrDbService.LastError));
                }

                LookupManager.ClearAndReloadOnIdle();

                Assert.AreEqual(oldFoldersCount - 3, AvrQueryLayoutTreeDbHelper.ReLoadFolders(false, m_TestQueryId).Count);
            }
        }
Exemplo n.º 5
0
        public void UpdateFoldersTest()
        {
            lock (m_SyncLock)
            {
                PresenterFactory.SharedPresenter.SharedModel.SelectedQueryId = m_TestQueryId;
                long layoutId = CreateLayout();
                try
                {
                    List <AvrTreeElement> original = AvrQueryLayoutTreeDbHelper.LoadQueries();
                    original.AddRange(AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId));
                    EidssUserContext.CheckUserLoggedIn();
                    original.AddRange(AvrQueryLayoutTreeDbHelper.LoadLayouts(false, m_TestQueryId));
                    var final = new List <AvrTreeElement>(original);

                    AvrTreeElement layout = original.Find(ById(layoutId));
                    Assert.IsNotNull(layout);

                    AvrTreeElement folder1 = CreateFolderItem(null, "Folder1", "Nat f1");
                    AvrQueryLayoutTreeDbHelper.SaveFolder(folder1.ID, folder1.ParentID, m_TestQueryId, folder1.DefaultName,
                                                          folder1.NationalName);

                    AvrTreeElement folder2 = CreateFolderItem(folder1.ID, "Folder2", "Nat f2");
                    AvrQueryLayoutTreeDbHelper.SaveFolder(folder2.ID, folder2.ParentID, m_TestQueryId, folder2.DefaultName,
                                                          folder2.NationalName);

                    AvrTreeElement folder3 = CreateFolderItem(folder2.ID, "Folder3", "Nat f3");
                    AvrQueryLayoutTreeDbHelper.SaveFolder(folder3.ID, folder3.ParentID, m_TestQueryId, folder3.DefaultName,
                                                          folder3.NationalName);

                    final.AddRange(new[] { folder1, folder2, folder3 });
                    layout.ParentID = folder1.ID;

                    LookupManager.ClearAndReloadOnIdle();
                    List <AvrTreeElement> saved = AvrQueryLayoutTreeDbHelper.LoadQueries();
                    saved.AddRange(AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId));
                    EidssUserContext.CheckUserLoggedIn();
                    saved.AddRange(AvrQueryLayoutTreeDbHelper.LoadLayouts(false, m_TestQueryId));

                    AvrTreeElement newFolder1 = saved.Find(ById(folder1.ID));
                    Assert.IsNotNull(newFolder1);
                    AvrTreeElement newFolder2 = saved.Find(ById(folder2.ID));
                    Assert.IsNotNull(newFolder2);
                    AvrTreeElement newFolder3 = saved.Find(ById(folder3.ID));
                    Assert.IsNotNull(newFolder3);
                    AvrTreeElement newLayout = saved.Find(ById(layoutId));
                    Assert.IsNotNull(newLayout);
                    Assert.AreEqual(m_TestQueryId, newFolder1.ParentID);
                    Assert.AreEqual(newFolder1.ID, newFolder2.ParentID);
                    Assert.AreEqual(newFolder2.ID, newFolder3.ParentID);
                    Assert.AreEqual(m_TestQueryId, newLayout.ParentID);
                    newLayout.ParentID = m_TestQueryId;
                    layout.ParentID    = m_TestQueryId;

                    LookupManager.ClearAndReloadOnIdle();
                    int oldFoldersCount = AvrQueryLayoutTreeDbHelper.LoadFolders(false, m_TestQueryId).Count;

                    // delete saved folders

                    using (var avrDbService = new Folder_DB())
                    {
                        Assert.IsTrue(avrDbService.Delete(folder3.ID),
                                      string.Format("could not delete folder '{0}' because of '{1}'", folder3.ID, avrDbService.LastError));
                        Assert.IsTrue(avrDbService.Delete(folder2.ID),
                                      string.Format("could not delete folder '{0}' because of '{1}'", folder2.ID, avrDbService.LastError));
                        Assert.IsTrue(avrDbService.Delete(folder1.ID),
                                      string.Format("could not delete folder '{0}' because of '{1}'", folder1.ID, avrDbService.LastError));
                    }
                    LookupManager.ClearAndReloadOnIdle();
                    Assert.AreEqual(oldFoldersCount - 3, AvrQueryLayoutTreeDbHelper.ReLoadFolders(false, m_TestQueryId).Count);
                }
                finally
                {
                    DeleteLayout(layoutId);
                }
            }
        }