Beispiel #1
0
        private void ExecuteFindItemsCommand(object param)
        {
            OrderItemType   searchType  = ((_dockingManager.ActiveContent as OrderItemList).DataContext as OrderItemDataProvider).ItemType;
            SearchParameter searchParam = new SearchParameter(searchType, param.ToString());
            Action          postAction  = null;

            if (searchParam.ItemType == OrderItemType.Unresolved)
            {
                postAction = () => ResolvedListDataProvider.NotifyPropertyChanged("Data");
            }
            ResultWindow resultWindow = new ResultWindow();

            resultWindow.Title = string.Format("Výsledek hledání: {0}", param.ToString());
            resultWindow.resultList.DataContext = new OrderItemDataProvider(OrderItemType.Results, searchParam, postAction);
            resultWindow.Width = _mainWindow.Width;
            resultWindow.ShowDialog();
        }
        public async Task GivenUpdatedResources_WhenBulkUpdatingSearchParameterIndicesAsync_ThenResourceMetadataIsUnchanged()
        {
            ResourceElement patientResource1 = CreatePatientResourceElement("Patient1", Guid.NewGuid().ToString());
            SaveOutcome     upsertResult1    = await Mediator.UpsertResourceAsync(patientResource1);

            ResourceElement patientResource2 = CreatePatientResourceElement("Patient2", Guid.NewGuid().ToString());
            SaveOutcome     upsertResult2    = await Mediator.UpsertResourceAsync(patientResource2);

            SearchParameter searchParam     = null;
            const string    searchParamName = "newSearchParam";

            try
            {
                searchParam = await CreatePatientSearchParam(searchParamName, SearchParamType.String, "Patient.name");

                ISearchValue searchValue = new StringSearchValue(searchParamName);

                (ResourceWrapper original1, ResourceWrapper updated1) = await CreateUpdatedWrapperFromExistingPatient(upsertResult1, searchParam, searchValue);

                (ResourceWrapper original2, ResourceWrapper updated2) = await CreateUpdatedWrapperFromExistingPatient(upsertResult2, searchParam, searchValue);

                var resources = new List <ResourceWrapper> {
                    updated1, updated2
                };

                await _dataStore.BulkUpdateSearchParameterIndicesAsync(resources, CancellationToken.None);

                // Get the reindexed resources from the database
                var             resourceKey1 = new ResourceKey(upsertResult1.RawResourceElement.InstanceType, upsertResult1.RawResourceElement.Id, upsertResult1.RawResourceElement.VersionId);
                ResourceWrapper reindexed1   = await _dataStore.GetAsync(resourceKey1, CancellationToken.None);

                var             resourceKey2 = new ResourceKey(upsertResult2.RawResourceElement.InstanceType, upsertResult2.RawResourceElement.Id, upsertResult2.RawResourceElement.VersionId);
                ResourceWrapper reindexed2   = await _dataStore.GetAsync(resourceKey2, CancellationToken.None);

                VerifyReindexedResource(original1, reindexed1);
                VerifyReindexedResource(original2, reindexed2);
            }
            finally
            {
                if (searchParam != null)
                {
                    _searchParameterDefinitionManager.DeleteSearchParameter(searchParam.ToTypedElement());
                    await _fixture.TestHelper.DeleteSearchParameterStatusAsync(searchParam.Url, CancellationToken.None);
                }
            }
        }
        public void Verify_SetNavigationSearchText()
        {
            //Arrange
            var searchText     = "Jirabox";
            var searchCriteria = new SearchParameter {
                SearchText = searchText
            };

            navigationServiceMock.SetupProperty(x => x.NavigationParameter).SetReturnsDefault(searchCriteria);

            //Act
            searchResultViewModel.SetNavigationSearchText(searchText);

            //Assert
            Assert.IsNotNull(navigationServiceMock.Object.NavigationParameter);
            Assert.IsTrue(((SearchParameter)navigationServiceMock.Object.NavigationParameter).SearchText.Equals(searchText));
        }
        private IEnumerable <SearchIndexEntry> ProcessNonCompositeSearchParameter(SearchParameter searchParameter, Base resource, FhirEvaluationContext context)
        {
            Debug.Assert(searchParameter?.Type != SearchParamType.Composite, "The search parameter must be non-composite.");

            SearchParameterInfo searchParameterInfo = searchParameter.ToInfo();

            foreach (ISearchValue searchValue in ExtractSearchValues(
                         searchParameter.Url,
                         searchParameter.Type.Value,
                         searchParameter.Target,
                         resource,
                         searchParameter.Expression,
                         context))
            {
                yield return(new SearchIndexEntry(searchParameterInfo, searchValue));
            }
        }
Beispiel #5
0
        public void Search_SearchParams_ReturnsWallpaperInfos()
        {
            var webClientMock    = CreateWebClientMock(includeDetailPageData: true);
            var webClientFactory = CreateWebClientFactory(webClientMock.Object);
            var wallhavenClient  = new WallhavenClient(webClientFactory);
            var searchParam      = new SearchParameter
            {
                Sorting    = Sorting.Views,
                Order      = Order.Descending,
                Categories = new Category(CategoryValue.General)
            };

            List <WallpaperInfo> wallpaperInfos = wallhavenClient.Search(searchParam);

            Assert.That(wallpaperInfos, Is.Not.Empty);
            Assert.That(wallpaperInfos.All(IsValidWallpaperInfo), Is.True);
        }
Beispiel #6
0
 public static void SetPropertyPath(this SearchParameter searchParameter, string[] paths)
 {
     string[] workingPaths;
     if (paths != null)
     {
         //A searchparameter always has a Resource as focus, so we don't need the name of the resource to be at the start of the Path.
         //See also: https://github.com/ewoutkramer/fhirpath/blob/master/fhirpath.md
         workingPaths = paths.Select <string, string>(pp => StripResourceNameFromStart(pp, searchParameter.Base.GetLiteral())).ToArray();
         var xpaths = workingPaths.Select(pp => "//" + pp.Replace('.', '/'));
         searchParameter.Xpath = String.Join(" | ", xpaths);
     }
     else
     {
         searchParameter.Xpath = String.Empty;
         //Null is not an error, for example Composite parameters don't have a path.
     }
 }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:吴小科      2010/07/13 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgvCounter()
        {
            try
            {
                //打开数据库
                dataAccess = new DataAccess();
                dataAccess.Open();
                //获取操作类
                GetData getData = new GetData(dataAccess.Connection);
                //设置加载条件
                SearchParameter sp = new SearchParameter();
                sp.SetValue(":input_type", '0');
                //获取绑定数据表
                DataTable dtInput_storage = getData.GetTableBySqlStr(Constants.SqlStr.TC_INPUT_INIT_STORAGE_LEFTJOIN_GOODS, sp);
                //添加序列号
                int countNumber = 0;
                dtInput_storage.Columns.Add("num", typeof(int));
                for (int i = 0; i < dtInput_storage.Rows.Count; i++)
                {
                    dtInput_storage.Rows[i]["num"] = ++countNumber;
                }
                //绑定数据
                dataGridView_input_storage.DataSource = dtInput_storage;

                if (dataGridView_input_storage != null && dataGridView_input_storage.Rows.Count > 0 && countNum != 0)
                {
                    dataGridView_input_storage.Rows[0].Selected                = false;
                    dataGridView_input_storage.Rows[countNum].Selected         = true;
                    dataGridView_input_storage.FirstDisplayedScrollingRowIndex = countNum;
                }
                if (dataGridView_input_storage.Rows.Count == 0)
                {
                    dataGridClear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
        public List <Model.Payment> GetPayments(SearchParameter searchParam)
        {
            List <Model.Payment> result = null;

            _context.Configuration.ProxyCreationEnabled = false;
            _context.Configuration.LazyLoadingEnabled   = false;
            if (searchParam != null)
            {
                Model.Payment payment = GetPaymentObject(searchParam);

                Decimal Amount = Convert.ToDecimal(payment.Amount);
                Int32   day    = Convert.ToDateTime(payment.CreationDate).Date.Day;
                Int32   month  = Convert.ToDateTime(payment.CreationDate).Date.Month;
                Int32   year   = Convert.ToDateTime(payment.CreationDate).Date.Year;

                if (!searchParam.IsFilterValue)
                {
                    searchParam.TotalRecordCount = _context.Payments.Where(c => c.IsActive == true).Count();

                    result = _context.Payments.Where(c => c.IsActive == true
                                                     ).OrderByDescending(x => x.Id)
                             .Skip(searchParam.StartIndex).Take((searchParam.PageSize > 0 ?
                                                                 searchParam.PageSize : searchParam.TotalRecordCount)).
                             ToList();
                }
                else
                {
                    result = _context.Payments.Where(c => c.IsActive == true &&
                                                     (payment.Id == 0 ? 1 == 1 : c.Id == payment.Id) &&
                                                     (string.IsNullOrEmpty(payment.TransactionId) ? 1 == 1 : c.TransactionId.ToUpper().StartsWith(payment.TransactionId.ToUpper())) &&
                                                     (string.IsNullOrEmpty(payment.ResponseCode) ? 1 == 1 : c.ResponseCode.ToUpper().StartsWith(payment.ResponseCode.ToUpper())) &&
                                                     (string.IsNullOrEmpty(payment.ApprovalCode) ? 1 == 1 : c.ApprovalCode.ToUpper().StartsWith(payment.ApprovalCode.ToUpper())) &&
                                                     (Amount == 0 ? 1 == 1 : SqlFunctions.StringConvert((double)c.Amount).ToUpper().StartsWith(SqlFunctions.StringConvert((double)Amount).ToUpper())) &&
                                                     ((day == 1 && month == 1 && year == 1 ? 1 == 1 :
                                                       SqlFunctions.DatePart("dd", c.CreationDate) == day &&
                                                       SqlFunctions.DatePart("mm", c.CreationDate) == month &&
                                                       SqlFunctions.DatePart("yyyy", c.CreationDate) == year))
                                                     ).OrderByDescending(x => x.Id).ToList();

                    searchParam.TotalRecordCount = result.Count();
                }
            }
            searchParam.SearchedCount = (!searchParam.IsFilterValue ? searchParam.TotalRecordCount : result.Count);
            return(result);
        }
Beispiel #9
0
        public void Parameter_Tmotlin_Read_Succeeds()
        {
            Mock<ICode> code = new Mock<ICode>();
            byte[] codeBytes = new byte[] { 0x01, 0x02, 0x03, 0x04 };
            code.SetupGet(x => x.CodeBytes).Returns(codeBytes);
            Mock<ISearchParameterLocator> searchParameterLocator = new Mock<ISearchParameterLocator>();
            searchParameterLocator.Setup(x => x.Locate<Address>(ParameterType.TmotlinCoolantTemperatureAddress)).Returns(new Address { value = 0xd3b6a });


            SearchParameter<Address, Address> tmotlin = new SearchParameter<Address, Address>(ParameterType.TmotlinCoolantTemperatureAddress, code.Object, 0, searchParameterLocator.Object, new AddressValueConverter());
            Address result = tmotlin.Value;
            Assert.AreEqual(0xd3b5au, result.value);

            Assert.AreEqual(0x01, codeBytes[0]);
            Assert.AreEqual(0x0d, codeBytes[1]);
            Assert.AreEqual(0x3b, codeBytes[2]);
            Assert.AreEqual(0x6a, codeBytes[3]);
        }
Beispiel #10
0
        public bool AssetFilterCheck(object asset)
        {
            if (String.IsNullOrWhiteSpace(SearchParameter))
            {
                return(true);
            }
            var _asset = asset as Asset;

            if (_asset != null)
            {
                if (_asset.FileNamesPreviewWithExtension.ToLower().Contains(SearchParameter.ToLower()))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #11
0
        public ActionResult <string> GetBingRank(SearchParameter searchParameter)
        {
            try
            {
                _logger.LogInformation("Entered the get RankController GetBingRank function");

                var searchResults = _searchService.GetBingResult(searchParameter.UrlToSearch, searchParameter.KeyWords, searchParameter.NoOfResults);
                var rankings      = _parser.GetBingPageRank(searchResults, searchParameter.UrlToSearch);

                _logger.LogInformation("Executed the get RankController GetBingRank function successfully");
                return(Ok(rankings));
            }
            catch (Exception ex)
            {
                _logger.LogError("Error in  RankController GetBingRank function ");
                throw;
            }
        }
Beispiel #12
0
        public static int SearchTextW(IntPtr listWin,
                                      [MarshalAs(UnmanagedType.LPWStr)] string searchString, int searchParameter)
        {
            ListerResult    result = ListerResult.Error;
            SearchParameter sp     = (SearchParameter)searchParameter;

            callSignature = String.Format("SearchText ({0}, {1}, {2})",
                                          listWin.ToString(), searchString, sp.ToString());
            try {
                object listerControl = TcHandles.GetObject(listWin);
                result = Plugin.SearchText(listerControl, searchString, sp);
                TcHandles.UpdateHandle(listWin, listerControl);
                TraceCall(TraceLevel.Warning, result.ToString());
            } catch (Exception ex) {
                ProcessException(ex);
            }
            return((int)result);
        }
Beispiel #13
0
        public async Task GivenACreateResourceRequest_WhenCreatingASearchParameterResource_ThenAddNewSearchParameterShouldBeCalled()
        {
            var searchParameter = new SearchParameter()
            {
                Id = "Id"
            };
            var resource = searchParameter.ToTypedElement().ToResourceElement();

            var request = new CreateResourceRequest(resource);
            var wrapper = CreateResourceWrapper(resource, false);

            var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created));

            var behavior = new CreateOrUpdateSearchParameterBehavior <CreateResourceRequest, UpsertResourceResponse>(_searchParameterOperations, _fhirDataStore);
            await behavior.Handle(request, CancellationToken.None, async() => await Task.Run(() => response));

            await _searchParameterOperations.Received().AddSearchParameterAsync(Arg.Any <ITypedElement>());
        }
Beispiel #14
0
        private SearchParameterInfo CreateSearchParameterInfo(SearchParameter searchParameter)
        {
            // Return SearchParameterInfo that has already been created for this Uri
            if (_uriDictionary.TryGetValue(new Uri(searchParameter.Url), out var spi))
            {
                return(spi);
            }

            // Return SearchParameterInfo that has already been created for this Resource
            if (_resourceTypeDictionary.TryGetValue(searchParameter.ResourceType.ToString(), out var spDictionary) &&
                spDictionary.TryGetValue(searchParameter.Name, out var resourceSpi) &&
                resourceSpi.Url == new Uri(searchParameter.Url))
            {
                return(resourceSpi);
            }

            return(searchParameter.ToInfo());
        }
        public void FillSearchParameterWithDevices(List <SearchParameter> sp)
        {
            SearchParameter p;

            // Add controllers.
            for (int i = 0; i < 4; i++)
            {
                var device = _devices[i];
                if (device == null)
                {
                    continue;
                }
                p              = new SearchParameter();
                p.ProductGuid  = device.ProductGuid;
                p.InstanceGuid = device.InstanceGuid;
                sp.Add(p);
            }
        }
        public IActionResult Put(int id, SearchParameter searchParameter)
        {
            var currentUserProfileId   = GetCurrentUserProfile().Id;
            var searchParameterDBState = _searchParameterRepository.GetTracklessSearchParameterById(id);

            if ((currentUserProfileId != searchParameter.UserProfileId) || (searchParameterDBState.UserProfileId != searchParameter.UserProfileId))
            {
                return(Unauthorized());
            }

            if (id != searchParameter.Id)
            {
                return(BadRequest());
            }

            _searchParameterRepository.Update(searchParameter);
            return(NoContent());
        }
Beispiel #17
0
        public SearchParameter ParseQuery(IQueryCollection query)
        {
            var result = new SearchParameter();

            if (query == null)
            {
                return(result);
            }

            foreach (var key in query.Keys)
            {
                TrySetStr((r) => result.Filter     = r, key, Constants.SearchParameterNames.Filter, query);
                TrySetInt((r) => result.StartIndex = r <= 0 ? result.StartIndex : r, key, Constants.SearchParameterNames.StartIndex, query);
                TrySetInt((r) => result.Count      = r <= 0 ? result.Count : r, key, Constants.SearchParameterNames.Count, query);
            }

            return(result);
        }
Beispiel #18
0
        public IList <OrderWithItemsViewModel> GetOrdersAndItemsByUser(Guid userId, SearchParameter parameter)
        {
            _unitOfWork.BeginTransaction();

            var user = _userRepository.GetById(userId);

            if (user == null)
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.UserException.NOT_FOUND);
            }

            var orders          = _orderRepository.GetOrdersAndItemsByUser(user, parameter);
            var ordersViewModel = orders.Select(x => x.MapToOrderItemsViewModel()).ToList();

            _unitOfWork.Commit();
            return(ordersViewModel);
        }
Beispiel #19
0
        //***********************************************************************
        /// <summary>
        /// 添加后库存数目剪掉添加数目数据信息
        /// </summary>
        /// <history>
        ///    完成信息:代国明      2010/07/22 完成
        ///    更新信息:
        /// </history>
        //***********************************************************************
        void UpdateStorageDetailsByAdd()
        {
            try
            {
                result = -1;

                //打开数据库连接
                dataAccess = new DataAccess();
                dataAccess.Open();

                //打开事务
                dataAccess.BeginTransaction();

                SearchParameter sp = new SearchParameter();

                sp.SetValue(":GOODS_CODE", tempStorageEntity.Goods_code);
                sp.SetValue(":COUNT", tempStorageEntity.Count);

                //取得操作类
                GetData getData = new GetData(dataAccess.Connection, dataAccess.Transaction);

                //取得结果符
                result = getData.UpdateTemp_storage(tempStorageEntity, sp);

                //提交事务
                dataAccess.Commit();
            }
            catch (Exception ex)
            {
                if (dataAccess.Transaction != null)
                {
                    //回滚
                    dataAccess.Rollback();
                }

                //提示错误
                MessageBox.Show("数据添加时发生错误,请检查数据库!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                //关闭数据库连接
                dataAccess.Close();
            }
        }
Beispiel #20
0
        public void ExplicitConstruction_CombinesSqlStatementsAndCoordinatesReader()
        {
            // Arrange
            var searchTerm       = "foobar";
            var searchStrategies = new List <ISqlQueryStrategy>
            {
                new SqlQueryStrategy(
                    "SELECT CustomerId AS Id, 50 AS Weight FROM dbo.Customer WHERE CustomerName LIKE @searchTerm"),
                new SqlQueryStrategy(
                    "SELECT CustomerId AS Id, 1 AS Weight FROM dbo.Customer WHERE Address1 LIKE @searchTerm"),
                new SqlQueryStrategy("SELECT CustomerId AS Id, .01 AS Weight FROM dbo.Customer WHERE City LIKE @searchTerm")
            }.ToArray();

            var readerFactory     = A.Fake <ISqlDataReaderFactory>();
            var reader            = A.Fake <ISqlItemResultDataReader>();
            var statementProvider = A.Fake <IConsolidatedSqlStatementProvider>();
            var sqlStatement      = "SELECT * FROM BUZZ";

            var searchParameter = new SearchParameter(searchTerm);

            A.CallTo(() => readerFactory.Create(sqlStatement, searchParameter)).Returns(reader);
            A.CallTo(() => statementProvider.CreateSqlSearchStatement(searchStrategies)).Returns(sqlStatement);
            A.CallTo(() => reader.Read()).Returns(true).NumberOfTimes(2);
            A.CallTo(() => reader.Current).ReturnsNextFromSequence(new WeightedItemResult {
                Id = 1, Weight = 10
            }, new WeightedItemResult {
                Id = 2, Weight = 20
            });

            // Act
            var sut = new SqlServerResultCollector(readerFactory, statementProvider, searchStrategies);

            var results = sut.GetWeightedItemsMatching(searchTerm).ToList();

            // Assert
            A.CallTo(() => statementProvider.CreateSqlSearchStatement(searchStrategies)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => readerFactory.Create(sqlStatement, searchParameter)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => reader.Current).MustHaveHappened(Repeated.Exactly.Times(2));
            A.CallTo(() => reader.Dispose()).MustHaveHappened(Repeated.Exactly.Once);

            results.Count.ShouldBe(2);
            results[0].Id.ShouldBe(1);
            results[1].Id.ShouldBe(2);
        }
        public JsonResult LoadPark(JQueryDataTablesModel jQueryDataTablesModel)
        {
            SearchParameter param = new SearchParameter();

            param.SearchColumn = new List <string> {
                "Id", "ParkName",                                     //"OfficePhone",
                "SpacesToRent",
                "SpacesToOwn",
                "PhysicalAddress",
                "State",
                "PhysicalZip",
                "IsOn"
            };
            param.SearchColumnValue = jQueryDataTablesModel.sSearch_;
            param.StartIndex        = jQueryDataTablesModel.iDisplayStart;
            param.PageSize          = jQueryDataTablesModel.iDisplayLength;

            List <ParkDto> result = _masterServiceFacade.GetListPark(param);

            var parks = GenericFilterHelper <ParkDto> .GetFilteredRecords(
                sourceData : result, //Updating bcos, on/off feature has to implement
                startIndex : jQueryDataTablesModel.iDisplayStart,
                pageSize : jQueryDataTablesModel.iDisplayLength,
                sortedColumns : jQueryDataTablesModel.GetSortedColumns(string.Empty),
                totalRecordCount : param.TotalRecordCount,
                searchString : jQueryDataTablesModel.sSearch,
                isSearch : param.IsFilterValue,
                searchColumnValues : jQueryDataTablesModel.sSearch_,
                properties : new List <string> {
                "Id", "ParkName",                                //"OfficePhone",
                "SpacesToRent",
                "SpacesToOwn",
                "PhysicalAddress",
                "State",
                "PhysicalZip",
                "IsOn"
            });

            return(Json(new JQueryDataTablesResponse <ParkDto>(
                            items: parks,
                            totalRecords: param.TotalRecordCount,
                            totalDisplayRecords: param.SearchedCount,
                            sEcho: jQueryDataTablesModel.sEcho)));
        }
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/7/15 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                sp.SetValue(":authority_level", "2");
                DataTable dtCounter = getData.GetTableBySqlStr(Constants.SqlStr.tc_AUTHORITY_LEFTJOIN_STAFF, sp);;

                dgv.AutoGenerateColumns = false;
                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dtCounter;

                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
                if (LoginUser.UserAuthority == "0")
                {
                    btnRepassword.Text = "初始化管理员密码";
                    btnUpdate.Text     = "修改药监局密码";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据查询时发生错误,请检查数据库!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }
Beispiel #23
0
        //*******************************************************************
        /// <summary>
        /// 绑定画面
        /// </summary>
        /// <history>
        ///     完成信息:李梓楠      2010/11/14 完成
        ///     更新信息:
        /// </history>
        //*******************************************************************
        private void BandingDgv()
        {
            try
            {
                dataAccess = new DataAccess();
                dataAccess.Open();

                GetData getData = new GetData(dataAccess.Connection);

                SearchParameter sp = new SearchParameter();
                if (checkDate.Checked == true)
                {
                    sp.SetValue(":VISIT_DATE_FROM", dateVisitFrom.Value.Date);
                    sp.SetValue(":VISIT_DATE_TO", dateVisitTo.Value.Date);
                }
                DataTable dtCounter = getData.GetTableBySqlStr(Constants.SqlStr.TC_VISIT_JOIN_IN_OUT_CUSTOMER_GOODS, sp);

                dtCounter.Columns.Add("index", typeof(int));
                for (int i = 0; i < dtCounter.Rows.Count; i++)
                {
                    dtCounter.Rows[i]["index"] = i + 1;
                }
                dgv.DataSource = dtCounter;

                dtPrint = dtCounter;
                //使被修改对线变为选中行
                if (dgv != null && dgv.Rows.Count > 0 && countNum != 0)
                {
                    dgv.Rows[0].Selected                = false;
                    dgv.Rows[countNum].Selected         = true;
                    dgv.FirstDisplayedScrollingRowIndex = countNum;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("请查看数据库是否正常!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                throw ex;
            }
            finally
            {
                dataAccess.Close();
            }
        }
        /// <summary>
        /// Returns the Business Object with a code equal to the specified as a parameter
        /// </summary>
        /// <param name="code">Code of the Business Object.</param>
        /// <returns>Business Object with the specified code.</returns>
        public virtual async Task <T> GetByCode(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(default(T));
            }

            var searchParameter = new SearchParameter
            {
                SearchText = code,
                ExcludeObjectsWithNameInOtherLanguage = false
            };

            var businessObjects = await BaseManager.Search(searchParameter);

            T businessObject = await GetByCode(code, businessObjects);

            return(businessObject);
        }
        internal static string SearchParameterToString(this SearchParameter parameter)
        {
            switch (parameter)
            {
            case SearchParameter.NameOrExtension:
                return("Name Or Extension");

            case SearchParameter.Name:
                return("File Name");

            case SearchParameter.Extension:
                return("Extension");

            case SearchParameter.WholePath:
                return("Whole FullName");
            }

            return("Unknown");
        }
Beispiel #26
0
        public void GivenAChainedParameterPointingToMultipleResourceTypes_WhenParsed_ThenCorrectExpressionShouldBeCreated()
        {
            ResourceType sourceResourceType = ResourceType.Patient;

            ResourceType[] targetResourceTypes = new[] { ResourceType.Organization, ResourceType.Practitioner };

            string param1 = "ref";
            string param2 = "param";

            string key   = $"{param1}.{param2}";
            string value = "Seattle";

            // Setup the search parameters.
            SetupReferenceSearchParameter(sourceResourceType, param1, targetResourceTypes);

            var expectedTargets = targetResourceTypes.Select(targetResourceType =>
            {
                SearchParameter searchParameter = SetupSearchParameter(targetResourceType, param2);

                Expression expectedExpression = SetupExpression(searchParameter, value);

                return(new { TargetResourceType = targetResourceType, Expression = expectedExpression });
            })
                                  .ToArray();

            // Parse the expression.
            Expression expression = _expressionParser.Parse(sourceResourceType.ToString(), key, value);

            ValidateMultiaryExpression(
                expression,
                MultiaryOperator.Or,
                expectedTargets.Select(expected =>
            {
                return((Action <Expression>)(chainedExpression =>
                                             ValidateChainedExpression(
                                                 chainedExpression,
                                                 sourceResourceType,
                                                 param1,
                                                 expected.TargetResourceType.ToString(),
                                                 actualSearchExpression => Assert.Equal(expected.Expression, actualSearchExpression))));
            })
                .ToArray());
        }
        public static IEnumerable <object[]> ValidSearchParamData()
        {
            var duplicateUrl = new SearchParameter()
            {
                Url = "http://duplicate"
            };
            var uniqueUrl = new SearchParameter()
            {
                Url = "http://unique"
            };

            var data = new List <object[]>();

            data.Add(new object[] { uniqueUrl, "POST" });
            data.Add(new object[] { duplicateUrl, "PUT" });
            data.Add(new object[] { duplicateUrl, "DELETE" });

            return(data);
        }
Beispiel #28
0
        private SearchParameterInfo CreateSearchParameterInfo(SearchParameter searchParameter)
        {
            SearchParameterInfo info = searchParameter.ToInfo();

            var uri = new Uri(searchParameter.Url);

            if (_unsupportedParams.Unsupported.Contains(uri))
            {
                info.IsSupported  = false;
                info.IsSearchable = false;
            }

            if (_unsupportedParams.PartialSupport.Contains(uri))
            {
                info.IsPartiallySupported = true;
            }

            return(info);
        }
Beispiel #29
0
        public async Task GivenDeletedResource_WhenBulkUpdatingSearchParameterIndicesAsync_ThenExceptionIsThrown()
        {
            ResourceElement patientResource1 = CreatePatientResourceElement("Patient1", Guid.NewGuid().ToString());
            SaveOutcome     upsertResult1    = await Mediator.UpsertResourceAsync(patientResource1);

            ResourceElement patientResource2 = CreatePatientResourceElement("Patient2", Guid.NewGuid().ToString());
            SaveOutcome     upsertResult2    = await Mediator.UpsertResourceAsync(patientResource2);

            SearchParameter searchParam     = null;
            const string    searchParamName = "newSearchParam";

            try
            {
                searchParam = await CreatePatientSearchParam(searchParamName, SearchParamType.String, "Patient.name");

                ISearchValue searchValue = new StringSearchValue(searchParamName);

                // Update the resource wrappers, adding the new search parameter
                (ResourceWrapper original1, ResourceWrapper updated1) = await CreateUpdatedWrapperFromExistingPatient(upsertResult1, searchParam, searchValue);

                (_, ResourceWrapper updated2) = await CreateUpdatedWrapperFromExistingPatient(upsertResult2, searchParam, searchValue);

                // Delete one of the two resources
                ResourceWrapper deletedWrapper = CreateDeletedWrapper(original1);
                await _dataStore.UpsertAsync(deletedWrapper, WeakETag.FromVersionId(deletedWrapper.Version), allowCreate : true, keepHistory : false, CancellationToken.None);

                var resources = new List <ResourceWrapper> {
                    updated1, updated2
                };

                // Attempt to reindex both resources, one of which has since been deleted and has a version that is out of date.
                await Assert.ThrowsAsync <PreconditionFailedException>(() => _dataStore.BulkUpdateSearchParameterIndicesAsync(resources, CancellationToken.None));
            }
            finally
            {
                if (searchParam != null)
                {
                    _searchParameterDefinitionManager.DeleteSearchParameter(searchParam.ToTypedElement());
                    await _fixture.TestHelper.DeleteSearchParameterStatusAsync(searchParam.Url, CancellationToken.None);
                }
            }
        }
Beispiel #30
0
        public void GivenANestedChainedParameter_WhenParsed_ThenCorrectExpressionShouldBeCreated()
        {
            ResourceType sourceResourceType       = ResourceType.Patient;
            ResourceType firstTargetResourceType  = ResourceType.Organization;
            ResourceType secondTargetResourceType = ResourceType.Practitioner;

            string param1 = "ref1";
            string param2 = "ref2";
            string param3 = "param";

            string key   = $"{param1}.{param2}.{param3}";
            string value = "Microsoft";

            // Setup the search parameters.
            SetupReferenceSearchParameter(sourceResourceType, param1, firstTargetResourceType);
            SetupReferenceSearchParameter(firstTargetResourceType, param2, secondTargetResourceType);

            SearchParameter searchParameter = SetupSearchParameter(secondTargetResourceType, param3);

            Expression expectedExpression = SetupExpression(searchParameter, value);

            // Parse the expression.
            Expression expression = _expressionParser.Parse(sourceResourceType.ToString(), key, value);

            ValidateMultiaryExpression(
                expression,
                MultiaryOperator.Or,
                chainedExpression => ValidateChainedExpression(
                    chainedExpression,
                    sourceResourceType,
                    param1,
                    firstTargetResourceType.ToString(),
                    nestedExpression => ValidateMultiaryExpression(
                        nestedExpression,
                        MultiaryOperator.Or,
                        nestedChainedExpression => ValidateChainedExpression(
                            nestedChainedExpression,
                            firstTargetResourceType,
                            param2,
                            secondTargetResourceType.ToString(),
                            actualSearchExpression => Assert.Equal(expectedExpression, actualSearchExpression)))));
        }
 public User this[string value, SearchParameter param = SearchParameter.Id]
 {
     get
     {
         switch (param)
         {
             case SearchParameter.Id:
                 return Users[value];
             case SearchParameter.Name:
                 return Users.Values.First(u => String.Equals(u.Name, value, StringComparison.CurrentCultureIgnoreCase));
             case SearchParameter.Username:
                 return Users.Values.First(u => String.Equals(u.Name, value, StringComparison.CurrentCultureIgnoreCase));
         }
         if (param == SearchParameter.Id)
         {
             GetUser(value);
         }
         return null;
     }
 }
 /// <summary>
 /// Gets the expression.
 /// </summary>
 /// <param name="ef">The ef.</param>
 /// <param name="expression">The expression.</param>
 /// <param name="propName">Name of the prop.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public static IExpression GetExpression(IExpressionFactory ef, SearchParameter expression, string propName, string value)
 {
     switch (expression) {
         case SearchParameter.StartingWith:
             return ef.InsensitiveLike(propName, value, LikeMatchMode.BeginsWith);
         case SearchParameter.Contains:
             return ef.InsensitiveLike(propName, value, LikeMatchMode.Contains);
         case SearchParameter.EqualOrGreaterThan:
             return ef.Ge(propName, value);
         case SearchParameter.EqualOrLessThan:
             return ef.Le(propName, value);
         case SearchParameter.EqualTo:
             return ef.Eq(propName, value);
         case SearchParameter.GreaterThan:
             return ef.Gt(propName, value);
         case SearchParameter.LessThan:
             return ef.Lt(propName, value);
         case SearchParameter.NotEqualTo:
             return ef.InsensitiveNe(propName, value);
     }
     return null;
 }
 /// <summary>
 /// Adds the comma delimited strings to the expression factory.
 /// </summary>
 /// <param name="criteria">The criteria.</param>
 /// <param name="expressions">The expressions.</param>
 /// <param name="text">The text.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="clause">The clause.</param>
 private static void AddCommaDelimitedStringsToExpression(ICriteria criteria, IExpressionFactory expressions, String text,
     String propertyName, SearchParameter clause)
 {
     if (!string.IsNullOrEmpty(text))
     {
         string[] values = text.Split(',');
         IList<IExpression> expression = values.Select(value => GetExpression(expressions, clause, propertyName, value)).ToList();
         IJunction junction = expressions.Disjunction();
         foreach (IExpression e in expression)
         {
             junction.Add(e);
         }
         criteria.Add(junction);
     }
 }
Beispiel #34
0
 /// <summary>
 /// Adds the comma delimited strings to the expression factory.
 /// </summary>
 /// <param name="criteria">The criteria.</param>
 /// <param name="expressions">The expressions.</param>
 /// <param name="text">The text.</param>
 /// <param name="propertyName">Name of the property.</param>
 /// <param name="clause">The clause.</param>
 private static void AddCommaDelimitedStringsToExpression(ICriteria criteria, IExpressionFactory expressions, String text,
     String propertyName, SearchParameter clause)
 {
     if (!string.IsNullOrEmpty(text))
     {
         IList<IExpression> expression = new List<IExpression>();
         IJunction junction;
         string[] values = text.Split(',');
         foreach (String value in values)
         {
             expression.Add(GetExpression(expressions, clause, propertyName, value));
         }
         junction = expressions.Disjunction();
         foreach (IExpression e in expression)
         {
             junction.Add(e);
         }
         criteria.Add(junction);
     }
     return;
 }