public void TestParseInputMultiplesFiltros()
        {
            Database database = SingleInstance <DatabaseMap> .GetInstance.GetDatabaseInstance(1);

            IInterpreter interpreter = new SimpleInterpreter();

            // se la crea para setearla en la database debido a que eso solo se realiza de forma
            // automática en el programa al recibir mensajes
            ConsoleChannel console = new ConsoleChannel();

            database.SetAdapter(console);

            TransactionTypeFilter transactionTypeFilter = new TransactionTypeFilter("compra");
            DepartmentFilter      departmentFilter      = new DepartmentFilter("canelones");
            PropertyTypeFilter    propertyTypeFilter    = new PropertyTypeFilter("casa");

            List <IFilter> filters = new List <IFilter>();

            filters.Add(transactionTypeFilter);
            filters.Add(departmentFilter);
            filters.Add(propertyTypeFilter);

            database.SetState(Status.WaitingTransactionType);
            interpreter.ParseInput(1, "2");
            interpreter.ParseInput(1, "canelones");
            interpreter.ParseInput(1, "1");

            Assert.IsTrue(database.GetFilters().SequenceEqual(filters));
        }
Exemple #2
0
        public void TestAskAndParseAPI()
        {
            Database database = new Database(1);

            Database database2 = new Database(5);

            APIInfoCasas apiCore = new APIInfoCasas();

            ICApi api = new ICApi();

            api.SetDepartment("montevideo");
            api.SetPropertyTypes(new PropertyType[] { PropertyType.Apartamento });
            api.SetTransactionType(TransactionType.Alquiler);
            api.SetCitiesAndNeighbourhoods(new string[] { "buceo" });

            List <IFilter> filters = new List <IFilter>();

            DepartmentFilter      department            = new DepartmentFilter("montevideo");
            PropertyTypeFilter    propertyTypeFilter    = new PropertyTypeFilter("apartamento");
            TransactionTypeFilter transactionTypeFilter = new TransactionTypeFilter("alquiler");
            NeighbourhoodFilter   neighbourhoodFilter   = new NeighbourhoodFilter("buceo");

            filters.Add(department);
            filters.Add(propertyTypeFilter);
            filters.Add(transactionTypeFilter);
            filters.Add(neighbourhoodFilter);

            apiCore.AskAPI(filters, 1);

            List <ICApiSearchResult> apiResult = api.Search();

            apiCore.Parse(apiResult, 5, "buceo");

            Assert.IsTrue(database.GetPropertyList().SequenceEqual(database2.GetPropertyList()));
        }
        public void TestEqualsTrue()
        {
            IFilter filter1 = new DepartmentFilter("montevideo");
            IFilter filter2 = new DepartmentFilter("montevideo");

            Assert.IsTrue(filter1.Equals(filter2));
        }
        public void TestEqualsFalse()
        {
            IFilter filter1 = new DepartmentFilter("montevideo");
            IFilter filter2 = new DepartmentFilter("canelones");

            Assert.IsFalse(filter1.Equals(filter2));
        }
        public void Initialize(Guid? organisationId, Guid? id, Guid? parentDepartmentId)
        {
            if (id.HasValue)
            {
                var departmentDetailsResult = DepartmentHelper.GetDetails(id.Value);
                Department = departmentDetailsResult;
            }
            else
            {
                Department = new Department
                {
                    Name = "Новое подразделение",
                    ParentDepartmentUID = parentDepartmentId ?? Guid.Empty,
                    OrganisationUID = organisationId.Value
                };
            }

            var filter = new DepartmentFilter();
            filter.UIDs.Add(Department.ParentDepartmentUID);
            var departmentListResult = DepartmentHelper.Get(filter);
            SelectedDepartment = departmentListResult.FirstOrDefault();

            var employeeFilter = new EmployeeFilter { LogicalDeletationType = LogicalDeletationType.All, UIDs = new List<Guid> { Department.ChiefUID }, IsAllPersonTypes = true };
            var chiefResult = EmployeeHelper.Get(employeeFilter);
            SelectedChief = chiefResult.Select(e => ShortEmployeeModel.CreateFromModel(e)).FirstOrDefault();

            if (Department.Photo != null && Department.Photo.Data != null)
            {
                photoData = string.Format("data:image/gif;base64,{0}", Convert.ToBase64String(Department.Photo.Data));
                Department.Photo.Data = null;
            }
        }
Exemple #6
0
		public static ShortDepartment GetSingleShort(Guid uid)
		{
			var filter = new DepartmentFilter();
			filter.UIDs.Add(uid);
			var operationResult = ClientManager.RubezhService.GetDepartmentList(filter);
			return Common.ThrowErrorIfExists(operationResult).FirstOrDefault();
		}
 public List <DepartmentModel> GetDepList(DepartmentFilter filter, out int total)
 {
     using (DataProvider dp = new DataProvider())
     {
         var list = data.GetDepList(dp, filter, out total);
         return(Mapper.Map <List <DepartmentModel> >(list));
     }
 }
 public PagedActionResult <Department> QueryCodeData([FromUri] DepartmentFilter filter)
 {
     return(SafeGetPagedData <Department>((result) =>
     {
         var pagedData = this.DepartmentService.QueryCodeData(filter);
         result.Data = pagedData.Items;
         result.TotalCount = pagedData.TotalCount;
     }));
 }
Exemple #9
0
		public HRFilter()
		{
			EmployeeFilter = new EmployeeFilter();
			DepartmentFilter = new DepartmentFilter();
			PositionFilter = new PositionFilter();
			AdditionalColumnTypeFilter = new AdditionalColumnTypeFilter();
			AccessTemplateFilter = new AccessTemplateFilter();
			PassCardTemplateFilter = new PassCardTemplateFilter();
			CardFilter = new CardFilter();
		}
 public PagedActionResult <Department> Search([FromUri] DepartmentFilter filter)
 {
     return(SafeGetPagedData <Department>((result) =>
     {
         if (!ModelState.IsValid)//表示没有过滤参数成功匹配,判定为错误请求。
         {
             throw new DomainException("查询参数错误。");
         }
         var pagedData = this.DepartmentService.QueryData(filter);
         result.Data = pagedData.Items;
         result.TotalCount = pagedData.TotalCount;
     }));
 }
Exemple #11
0
        public FileResult Export(DepartmentFilter filter)
        {
            var response = _departmentService.Filter(filter);

            var csv = new CsvExport();

            csv.ConcatRow(0, "DEPARTAMENTO,ESTADO");
            csv.ConcatRows(0, "Name,Status", response.Departments);

            var stream = csv.RetrieveFile();

            return(new StreamFactory().Csv(stream, "Departamentos"));
        }
Exemple #12
0
        public PagedResultDto <Department> QueryCodeData(DepartmentFilter filter)
        {
            var result    = new PagedResultDto <Department>();
            var queryable = this.Repository.GetQueryable(false);

            if (filter != null)
            {
                if (!string.IsNullOrEmpty(filter.Keyword))
                {
                    queryable = queryable.Where(t => t.Code.Contains(filter.Keyword) || t.Name.Contains(filter.Keyword));
                }
                else
                {
                    if (!string.IsNullOrEmpty(filter.Code))
                    {
                        queryable = queryable.Where(t => t.Code.Contains(filter.Code));
                    }
                    if (!string.IsNullOrEmpty(filter.Name))
                    {
                        queryable = queryable.Where(t => t.Name.Contains(filter.Name));
                    }
                }
                if (!string.IsNullOrEmpty(filter.DistrictRegion))
                {
                    queryable = queryable.Where(t => t.DistrictRegion == filter.DistrictRegion);
                }
                if (!string.IsNullOrEmpty(filter.AdministrationRegion))
                {
                    queryable = queryable.Where(t => t.AdministrationRegion == filter.AdministrationRegion);
                }
                if (filter.Start.HasValue && filter.Limit.HasValue)
                {
                    result.TotalCount = queryable.Count();
                    result.Items      = queryable.OrderBy(t => t.ID).Skip(filter.Start.Value).Take(filter.Limit.Value);
                }
                else
                {
                    result.Items      = queryable.ToArray();
                    result.TotalCount = result.Items.Count();
                }
            }
            else
            {
                result.Items      = queryable.ToArray();
                result.TotalCount = result.Items.Count();
            }
            return(result);
        }
        public void TestEqualsNullException()
        {
            IFilter filter1 = new DepartmentFilter("artigas");
            IFilter filter2 = null;

            // el test pasa dado que nunca se llega al Assert.Fail (el equals lanza excepción)
            // y se hace el catch del tipo correcto (NullReferenceException)
            try
            {
                filter1.Equals(filter2);
                Assert.Fail();
            }
            catch (NullReferenceException)
            {
            }
        }
        public JsonResult GetOrganisations(DepartmentFilter departmentFilter)
        {
            var departmentViewModel = new DepartmentsViewModel();
            departmentViewModel.Initialize(new DepartmentFilter
            {
                OrganisationUIDs = departmentFilter.OrganisationUIDs,
                LogicalDeletationType = departmentFilter.LogicalDeletationType
            });
            dynamic result = new
            {
                page = 1,
                total = 100,
                records = 100,
                rows = departmentViewModel.Organisations,
            };

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemple #15
0
        public List <PM_Department> GetDepList(DataProvider dp, DepartmentFilter filter, out int total, bool IsPage = true)
        {
            var list = dp.PM_Department.Where(m => !m.IsDel);

            if (!string.IsNullOrWhiteSpace(filter.DepName))
            {
                list = list.Where(m => m.DepName.Contains(filter.DepName));
            }
            list  = list.OrderByDescending(m => m.CreateTime);
            total = list.Count();
            if (IsPage)
            {
                return(list.Skip(filter.Skip).Take(filter.PageSize).ToList());
            }
            else
            {
                return(list.ToList());
            }
        }
Exemple #16
0
		public HRViewModel(SKDTabItems skdTabItems)
		{
			SKDTabItems = skdTabItems;
			EditFilterCommand = new RelayCommand(OnEditFilter, CanEditFilter);
			ChangeIsDeletedCommand = new RelayCommand(OnChangeIsDeleted, CanChangeIsDeleted);
			EmployeesViewModel = new EmployeesViewModel();
			DepartmentsViewModel = new DepartmentsViewModel();
			PositionsViewModel = new PositionsViewModel();
			AdditionalColumnTypesViewModel = new AdditionalColumnTypesViewModel();
			CardsViewModel = new CardsViewModel();
			AccessTemplatesViewModel = new AccessTemplatesViewModel();
			PassCardTemplatesViewModel = new PassCardTemplatesViewModel();
			OrganisationsViewModel = new OrganisationsViewModel();
			DepartmentFilter = new DepartmentFilter();
			PositionFilter = new PositionFilter();
			CardFilter = new CardFilter();
			if (CanSelectEmployees) 
				IsEmployeesSelected = true;
			else if (CanSelectDepartments) 
				IsDepartmentsSelected = true;
			else if (CanSelectPositions) 
				IsPositionsSelected = true;
			else if (CanSelectAdditionalColumns) 
				IsAdditionalColumnTypesSelected = true;
			else if (CanSelectCards) 
				IsCardsSelected = true;
			else if (CanSelectAccessTemplates) 
				IsAccessTemplatesSelected = true;
			else if (CanSelectPassCardTemplates) 
				IsPassCardTemplatesSelected = true;
			else if (CanSelectOrganisations) 
				IsOrganisationsSelected = true;
			PersonTypes = new ObservableCollection<PersonType>();
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Employees_View))
				PersonTypes.Add(PersonType.Employee);
			if (ClientManager.CurrentUser.HasPermission(PermissionType.Oper_SKD_Guests_View))
				PersonTypes.Add(PersonType.Guest);
			_selectedPersonType = PersonTypes.FirstOrDefault();
			var user = ClientManager.CurrentUser;
			Filter = new HRFilter() { User = user };
			Filter.EmployeeFilter.User = user;
		}
Exemple #17
0
        public void TestGetFilters()
        {
            Database database = new Database(1);

            List <IFilter> filters = new List <IFilter>();

            database.AddFilter(new PropertyTypeFilter("casa"));
            database.AddFilter(new NeighbourhoodFilter("axh"));
            database.AddFilter(new DepartmentFilter("fsgf"));

            IFilter filter1 = new PropertyTypeFilter("casa");
            IFilter filter2 = new NeighbourhoodFilter("axh");
            IFilter filter3 = new DepartmentFilter("fsgf");

            filters.Add(filter1);
            filters.Add(filter2);
            filters.Add(filter3);

            Assert.IsTrue(database.GetFilters().SequenceEqual(filters));
        }
        public async Task <IHttpActionResult> GetAllMatches([FromUri] DepartmentQueriesBindingModel queries)
        {
            var filter = new DepartmentFilter();

            if (queries != null && queries.FieldsQueries != null && queries.FieldsQueries.Any())
            {
                filter = queries.FieldsQueries.Aggregate(filter,
                                                         (current, query) => DepartmentFilter.CreateFromDepartmentQuery(query, current));
            }
            else
            {
                return(Ok(ResponseDto <DepartmentMatchDto> .NotFound()));
            }

            var departments = await DepartmentsService.Instance.Query().FilterQuery(filter).ToListAsync();

            var result = CollectionResponseDto <DepartmentMatchDto, DepartmentExtended> .Create(departments.SelectExtended(),
                                                                                                user => DepartmentMatchDto.CreateFromModel(user, queries.FieldsQueries), departments.Count);

            return(Ok(result));
        }
Exemple #19
0
        public ActionResult GetDepList(DepartmentFilter filter)
        {
            var data = business.GetDepList(filter, out int total);

            return(Json(new TableDataModel(total, data)));
        }
Exemple #20
0
        public List <Department> GetDepartment(DepartmentFilter filter)
        {
            string sql = "select d.Id,d.Name,d.IsEnabled ,d.`Desc`,d.CreateTime,u.userName as CreaterName from t_department d JOIN t_user u ON d.CreaterId = u.Id";

            return(GetData <Department, DepartmentFilter>(sql, filter));
        }
 async public Task <IEnumerable <VDepartment> > GetDepartmentList(DepartmentFilter filter) =>
 await Db.GetListSpAsync <VDepartment, DepartmentFilter>(filter);
Exemple #22
0
        /// <summary>
        /// 查询列表&分页
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public AjaxResult GetList(DepartmentFilter filter)
        {
            var list = _departmentService.GetList();

            return(AjaxResult.Success(list));
        }
Exemple #23
0
		public void Initialize()
		{
			DepartmentFilter = new DepartmentFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				LogicalDeletationType = Filter.LogicalDeletationType 
			};
			PositionFilter = new PositionFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				LogicalDeletationType = Filter.LogicalDeletationType 
			};
			AdditionalColumnTypeFilter = new AdditionalColumnTypeFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				LogicalDeletationType = Filter.LogicalDeletationType 
			};
			CardFilter = new CardFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				EmployeeFilter = Filter.EmployeeFilter, 
			};
			AccessTemplateFilter = new AccessTemplateFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				LogicalDeletationType = Filter.LogicalDeletationType 
			};
			PassCardTemplateFilter = new PassCardTemplateFilter() 
			{ 
				OrganisationUIDs = Filter.OrganisationUIDs, 
				LogicalDeletationType = Filter.LogicalDeletationType 
			};
			InitializeEmployeeFilter();
			DepartmentsViewModel.Initialize(DepartmentFilter);
			PositionsViewModel.Initialize(PositionFilter);
			AdditionalColumnTypesViewModel.Initialize(AdditionalColumnTypeFilter);
			CardsViewModel.Initialize(CardFilter);
			AccessTemplatesViewModel.Initialize(AccessTemplateFilter);
			PassCardTemplatesViewModel.Initialize(PassCardTemplateFilter);
			OrganisationsViewModel.Initialize(Filter.LogicalDeletationType);
			EmployeesViewModel.Initialize(EmployeeFilter);
        }
		protected override IEnumerable<ShortDepartment> GetDepartments()
		{
			var filter = new DepartmentFilter { OrganisationUIDs = new List<Guid> { _organisationUID }, ExceptUIDs = new List<Guid> { _departmentUID } };
			return DepartmentHelper.Get(filter);
		}
Exemple #25
0
		public static IEnumerable<ShortDepartment> Get(DepartmentFilter filter)
		{
			var result = ClientManager.RubezhService.GetDepartmentList(filter);
			return Common.ThrowErrorIfExists(result);
		}
		public OperationResult<List<ShortDepartment>> GetDepartmentList(Guid clientUID, DepartmentFilter filter)
		{
			return SafeOperationCall(clientUID, () => RubezhService.GetDepartmentList(clientUID, filter), "GetDepartmentList");
		}
Exemple #27
0
        public JsonResult GetDepartmentsFilter(bool isWithDeleted)
        {
            var filter = new DepartmentFilter { User = ClientManager.CurrentUser };
            if (isWithDeleted)
            {
                filter.LogicalDeletationType = LogicalDeletationType.All;
            }

            var departmentViewModel = new DepartmentsViewModel();
            departmentViewModel.Initialize(filter);

            dynamic result = new
            {
                page = 1,
                total = 100,
                records = 100,
                rows = departmentViewModel.Organisations,
            };

            return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemple #28
0
		public OperationResult<List<ShortDepartment>> GetDepartmentList(Guid clientUID, DepartmentFilter filter)
		{
			OperationResult<List<ShortDepartment>> result;
			using (var databaseService = new RubezhDAL.DataClasses.DbService())
			{
				result = databaseService.DepartmentTranslator.ShortTranslator.Get(filter);
			}
			return result;
		}
Exemple #29
0
        public JsonResult Filter(DepartmentFilter filter)
        {
            var response = _departmentService.Filter(filter);

            return(new JsonFactory().Success(response.Departments, response.TotalRecords));
        }
		public OperationResult<List<ShortDepartment>> GetDepartmentList(DepartmentFilter filter)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.GetDepartmentList(RubezhServiceFactory.UID, filter);
			}, "GetDepartmentList");
		}
        public JsonNetResult Restore(Guid uid)
        {
            var filter = new DepartmentFilter
            {
                UIDs = new List<Guid> { uid },
                LogicalDeletationType = LogicalDeletationType.All
            };
            var getDepartmentsResult = DepartmentHelper.Get(filter);
            var department = getDepartmentsResult.FirstOrDefault();

            var operationResult = DepartmentHelper.Restore(department);
            return new JsonNetResult { Data = operationResult };
        }