Beispiel #1
0
        // najde dnešní verze po startu aplikace nebo odkazem v Layotu dle TRUNC(VER_DATETIME) <= TRUNC(SYSDATE)
        public void GetTodayVersions()
        {
            if (SelectionMaskOutputEntity == null)
            {
                SelectionMaskOutputEntity = new SelectionMaskOutputEntity();
            }

            List <V_VERSION_LIST2> versionsFromDB = dbRepository.GetAllRecordsFromV_VERSION_LIST2();

            SelectionResult = new List <SelectionMaskOutputEntity>();

            SelectionResult = versionsFromDB.Select(x => new SelectionMaskOutputEntity(x.VER_ID,
                                                                                       x.VER_COMPANY,
                                                                                       x.VER_GROUP,
                                                                                       x.VER_DATETIME,
                                                                                       x.VER_CREATED_DATE,
                                                                                       x.VER_CREATED_USER,
                                                                                       x.STATUS,
                                                                                       x.VER_COMPANY_TYPE
                                                                                       )
                                                    ).OrderByDescending(x => x.Id)
                              .ToList();
        }
Beispiel #2
0
        // Vrátí odpovídající záznamy dle vyhledávací masky vybrané z DB View V_VERSION_LIST1
        public void GetSelectedRecords(SelectionMaskEntity selectionsparameters)
        {
            SelectionMaskOutputEntity = new SelectionMaskOutputEntity();

            if (SelectionResult == null)
            {
                SelectionResult = new List <SelectionMaskOutputEntity>();
            }

            SelectionResult.Clear();

            List <V_VERSION_LIST1> recordsFromDB = dbRepository.GetAllRecordsFromV_VERSION_LIST1();

            recordsFromDB.OrderByDescending(x => x.VER_ID);
            IEnumerable <V_VERSION_LIST1> temporaryRecords = recordsFromDB.OrderByDescending(x => x.VER_ID);

            // CompanyWithGroup

            if (selectionsparameters.CompanyWithGroup != null)
            {
                string[] pole = selectionsparameters.CompanyWithGroup.Split(',');
                string   companyWithGroupCompany = pole[0];
                string   companyWithGroupGroup   = pole[1];

                temporaryRecords = recordsFromDB.Where(company => company.VER_COMPANY == companyWithGroupCompany)
                                   .Where(group => group.VER_GROUP == companyWithGroupGroup);
            }

            // Company a Group
            if ((selectionsparameters.Company != null) && (selectionsparameters.Group != null))
            {
                temporaryRecords = recordsFromDB.Where(company => company.VER_COMPANY == selectionsparameters.Company)
                                   .Where(group => group.VER_GROUP == selectionsparameters.Group);
            }
            if ((selectionsparameters.Company != null) && (selectionsparameters.Group == null))
            {
                temporaryRecords = recordsFromDB.Where(company => company.VER_COMPANY == selectionsparameters.Company);
            }
            if ((selectionsparameters.Company == null) && (selectionsparameters.Group != null))
            {
                temporaryRecords = recordsFromDB.Where(group => group.VER_GROUP == selectionsparameters.Group);
            }

            // Company type a Company
            if ((selectionsparameters.CompanyTyp != null) && (selectionsparameters.Company != null))
            {
                temporaryRecords = recordsFromDB.Where(companyTyp => companyTyp.VER_COMPANY_TYPE == selectionsparameters.CompanyTyp)
                                   .Where(company => company.VER_COMPANY == selectionsparameters.Company);
            }
            if ((selectionsparameters.CompanyTyp != null) && (selectionsparameters.Company == null))
            {
                temporaryRecords = recordsFromDB.Where(companyTyp => companyTyp.VER_COMPANY_TYPE == selectionsparameters.CompanyTyp);
            }
            if ((selectionsparameters.CompanyTyp == null) && (selectionsparameters.Company != null))
            {
                temporaryRecords = temporaryRecords.Where(company => company.VER_COMPANY == selectionsparameters.Company);
            }

            // VersionDateFrom a VersionDateTo
            if ((selectionsparameters.VersionDateFrom != DateTime.MinValue) && (selectionsparameters.VersionDateTo != DateTime.MinValue))  // otestováno
            {
                temporaryRecords = recordsFromDB.Where(versionDateFrom => versionDateFrom.VER_DATETIME >= selectionsparameters.VersionDateFrom)
                                   .Where(versionDateTo => versionDateTo.VER_DATETIME <= selectionsparameters.VersionDateTo);
            }
            if ((selectionsparameters.VersionDateFrom != DateTime.MinValue) && (selectionsparameters.VersionDateTo == DateTime.MinValue))  // otestováno
            {
                temporaryRecords = recordsFromDB.Where(versiondateFrom => versiondateFrom.VER_DATETIME >= selectionsparameters.VersionDateFrom);
            }
            if ((selectionsparameters.VersionDateTo != DateTime.MinValue) && (selectionsparameters.VersionDateFrom == DateTime.MinValue)) // otestováno
            {
                temporaryRecords = recordsFromDB.Where(versiondateTo => versiondateTo.VER_DATETIME <= selectionsparameters.VersionDateTo);
            }

            // CreationDateFrom a CreationDateTo
            if ((selectionsparameters.CreationDateFrom != DateTime.MinValue) && (selectionsparameters.CreationDateTo != DateTime.MinValue)) // otestováno
            {
                temporaryRecords = recordsFromDB.Where(creationDateFrom => creationDateFrom.VER_CREATED_DATE >= selectionsparameters.CreationDateFrom)
                                   .Where(creationDateTo => creationDateTo.VER_CREATED_DATE <= selectionsparameters.CreationDateTo);
            }
            if ((selectionsparameters.CreationDateFrom != DateTime.MinValue) && (selectionsparameters.CreationDateTo == DateTime.MinValue))  // otestováno
            {
                temporaryRecords = recordsFromDB.Where(creationDateFrom => creationDateFrom.VER_CREATED_DATE >= selectionsparameters.CreationDateFrom);
            }
            if ((selectionsparameters.CreationDateTo != DateTime.MinValue) && (selectionsparameters.CreationDateFrom == null))  // otestováno
            {
                temporaryRecords = recordsFromDB.Where(creationDateTo => creationDateTo.VER_CREATED_DATE <= selectionsparameters.CreationDateTo);
            }

            // Id version
            if (selectionsparameters.Id != null)
            {
                temporaryRecords = recordsFromDB.Where(versionId => versionId.VER_ID == selectionsparameters.Id).ToList();
            }

            // vrátit výsledky bez smazaných verzí else včetně smazaných verzí
            if (!selectionsparameters.SearchInDeleted)
            {
                SelectionResult = temporaryRecords.Where(x => x.STATUS != "ZRUŠENO")
                                  .Select(x => new SelectionMaskOutputEntity(x.VER_ID,
                                                                             x.VER_COMPANY,
                                                                             x.VER_GROUP,
                                                                             x.VER_DATETIME,
                                                                             x.VER_CREATED_DATE,
                                                                             x.VER_CREATED_USER,
                                                                             x.STATUS,
                                                                             x.VER_COMPANY_TYPE
                                                                             )
                                          ).OrderByDescending(x => x.Id)
                                  .ToList();
            }
            else
            {
                SelectionResult = temporaryRecords.Select(x => new SelectionMaskOutputEntity(x.VER_ID,
                                                                                             x.VER_COMPANY,
                                                                                             x.VER_GROUP,
                                                                                             x.VER_DATETIME,
                                                                                             x.VER_CREATED_DATE,
                                                                                             x.VER_CREATED_USER,
                                                                                             x.STATUS,
                                                                                             x.VER_COMPANY_TYPE
                                                                                             )
                                                          ).OrderByDescending(x => x.Id)
                                  .ToList();
            }
        }