예제 #1
0
        public static List <DirectMessageModel> Search(IServerAuthentication restClientAuthenticator, int page = 1, int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <DirectMessageModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #2
0
        public static ListModel <PatientCommunicationModel> Search(
            IServerAuthentication restClientAuthenticator,
            bool?alreadySent             = null,
            string creationDateOperator  = "",
            DateTime?utcCreationDate1    = null,
            DateTime?utcCreationDate2    = null,
            string patientExternalId     = "",
            string appointmentExternalId = "",
            bool?outgoing    = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("creationDateOperator", creationDateOperator);
            criteria.Add("utcCreationDate1", utcCreationDate1.ToString());
            criteria.Add("utcCreationDate2", utcCreationDate2.ToString());
            criteria.Add("alreadySent", alreadySent.ToString());
            criteria.Add("patientExternalId", patientExternalId);
            criteria.Add("appointmentExternalId", appointmentExternalId);
            criteria.Add("outgoing", outgoing.ToString());
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <PatientCommunicationModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
        public static ListModel <AppointmentCancelRequestModel> Search(
            IServerAuthentication restClientAuthenticator,
            bool?alreadySent = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("alreadySent", alreadySent.ToString());
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <AppointmentCancelRequestModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #4
0
        public static ListModel <PortalPatientModel> Search(
            IServerAuthentication restClientAuthenticator,
            string firstName = "",
            string lastName  = "",
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("firstName", firstName);
            criteria.Add("lastName", lastName);
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <PortalPatientModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
        public void PersonManager_Search_ShouldCall_RepositorySearch(PersonSearchCriteria personSearchCriteria)
        {
            //Arrange
            Mock <IPersonRepository> personRepository = new Mock <IPersonRepository>();


            SetupUserIdentity();
            SetupPersonRepository(personRepository);

            var criteria = new SearchCriteria();

            criteria.Add(new FilterParameter("PersonId", 123));

            PersonsManager personsManager = new PersonsManager(userManager.Object, cacheStoreManager, mockLogManager.Object, personRepository.Object, transformationManager);

            //Act
            IPaginatedList <BLL_Person> actual = personsManager.Search(criteria);

            int expectedTotalRecordCount = 1;

            //Assert
            personRepository.Verify(p => p.Search(It.IsAny <SearchCriteria>()));

            Assert.AreEqual(expectedTotalRecordCount, actual.TotalRecordCount);
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the AdvancedSearchViewModel class
        /// </summary>
        public AdvancedSearchViewModel()
        {
            scope = Data.GraphManager.Instance.DefaultGraphComponentsInstance.Scope;

            // Setup a listener for the AttributeListUpdated event
            Data.Attributes.GlobalAttributeCollection.GetInstance(this.scope).AttributeListUpdated += new EventHandler <Data.Attributes.AttributeEventArgs>(GlobalAttributeCollection_AttributeListUpdated);

            // Get a list of all the attributes
            Attributes = new ObservableCollection <string>(Data.Attributes.GlobalAttributeCollection.GetInstance(scope).GetAttributes().Where(attribute => attribute.Visible).Select(attribute => attribute.Name));

            // Get a list of all valid operators
            Operators = new ObservableCollection <string>(ExtensionMethods.GetNames(typeof(SearchOperator)));

            // Make sure that we have one criterion and that it is disabled
            // and inactive.
            SearchCriterionViewModel newSearchCriterion = new SearchCriterionViewModel(this)
            {
                IsEnabled = true, IsActive = false
            };

            SearchCriteria.Add(newSearchCriterion);

            // Wire up event handlers for the Activated and Deactivated events of
            // the newly created SearchCriterion control
            newSearchCriterion.Activated   += new EventHandler <EventArgs>(SearchCriterion_Activated);
            newSearchCriterion.Deactivated += new EventHandler <EventArgs>(SearchCriterion_Deactivated);
        }
예제 #7
0
        public static ListModel <AppointmentRequestReasonModel> Search(
            IServerAuthentication restClientAuthenticator,
            bool?changed     = null,
            bool?isDeleted   = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("changed", changed.ToString());
            criteria.Add("isDeleted", isDeleted.ToString());

            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <AppointmentRequestReasonModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
        public static ListModel <OrderStatusModel> Search(
            IServerAuthentication restClientAuthenticator,
            string ID        = "",
            string name      = "",
            int page         = 1,
            int itemsPerPage = 10
            )
        {
            var criteria = new SearchCriteria();

            criteria.Add("name", name);
            criteria.Add("externalId", ID);
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <OrderStatusModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
 public void ShouldAllowAddingOfCriteria()
 {
     var criteria = new SearchCriteria<TestEntity>();
     criteria.Add(entity => entity.Id.HasValue);
     var list = new List<Expression<Func<TestEntity, bool>>>(criteria.All);
     Assert.IsTrue(list.Count == 1);
     Assert.AreEqual("entity.Id.HasValue", list[0].Body.ToString());
 }
        public static ListModel <PatientUpdateModel> Search(
            IServerAuthentication restClientAuthenticator,
            string patientExternalID = "",
            string method            = "",
            bool?alreadySent         = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());
            criteria.Add("patientExternalID", patientExternalID);
            criteria.Add("method", method);
            criteria.Add("AlreadySent", alreadySent.ToString());

            return(ApiClientGenericObject <PatientUpdateModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #11
0
        public T Get <TEntity>(object id) where TEntity : T
        {
            var criteria   = new SearchCriteria <TEntity>();
            var expression = GetIdEqualityPredicate <TEntity>(id);

            criteria.Add(expression);

            return(CreateQuery(criteria).FirstOrDefault());
        }
예제 #12
0
        public static ListModel <PatientModel> Search(
            IServerAuthentication restClientAuthenticator,

            string fullName   = "",
            DateTime?birthday = null,

            bool?active      = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("FullName", fullName);
            criteria.Add("Birthday", birthday.ToString());
            criteria.Add("Active", active.ToString());
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <PatientModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #13
0
        private Task OnAddSearchCriteria()
        {
            var sc = new SearchCriteriaViewModel();

            SearchCriteria.Add(sc);
            if (SearchCriteria.Count == 1)
            {
                Search.RaiseCanExecuteChanged();
            }

            return(OnEditSearchCriteria(sc));
        }
        protected override void LoadSearchCriteria()
        {
            var searchCriteria = new SearchCriteria(SearchCriteriaType.Command);

            var queryParams = EntitySource.Root.Descendants("query-param", XmlNamespace);

            foreach (var queryParam in queryParams)
            {
                var property = new NHibernateCommandProperty(queryParam, this);
                searchCriteria.Properties.Add(property);
            }

            SearchCriteria.Add(searchCriteria);
        }
예제 #15
0
 private void ExecuteComboBoxCommand()
 {
     if (IsCheckedXMLFile)
     {
         if (!SearchCriteria.Contains("Content"))
         {
             SearchCriteria.Add("Content");
             SearchCriteria.Add("Text");
             SearchCriteria.Add("Name");
         }
     }
     else
     {
     }
 }
        protected void GetIndexSearchCriteria(Dictionary <string, SearchCriteria> map)
        {
            foreach (IndexSchema indexSchema in table.Indexes)
            {
                SearchCriteria searchCriteria = new SearchCriteria(ExtendedProperty);
                foreach (MemberColumnSchema mcs in indexSchema.MemberColumns)
                {
                    if (mcs.Table.Equals(table))
                    {
                        searchCriteria.Add(mcs);
                    }
                }

                if (!String.IsNullOrEmpty(ExtendedProperty) && indexSchema.ExtendedProperties.Contains(ExtendedProperty) && indexSchema.ExtendedProperties[ExtendedProperty].Value != null)
                {
                    searchCriteria.SetMethodNameGeneration(indexSchema.ExtendedProperties[ExtendedProperty].Value.ToString());
                }

                AddToMap(map, searchCriteria);
            }
        }
예제 #17
0
                protected void GetForeignKeySearchCriteria(Dictionary <string, SearchCriteria> map)
                {
                    foreach (TableKeySchema tks in table.ForeignKeys)
                    {
                        SearchCriteria searchCriteria = new SearchCriteria();
                        foreach (MemberColumnSchema mcs in tks.ForeignKeyMemberColumns)
                        {
                            if (mcs.Table.Equals(table))
                            {
                                searchCriteria.Add(mcs);
                            }
                        }

                        if (!String.IsNullOrEmpty(extendedProperty) && tks.ExtendedProperties.Contains(extendedProperty) && tks.ExtendedProperties[extendedProperty].Value != null)
                        {
                            searchCriteria.SetMethodNameGeneration(tks.ExtendedProperties[extendedProperty].Value.ToString());
                        }

                        AddToMap(map, searchCriteria);
                    }
                }
예제 #18
0
        public static ListModel <OrderModel> Search(
            IServerAuthentication restClientAuthenticator,
            string patientID         = null,
            string locationID        = null,
            string ID                = "",
            DateTime?utcCreationDate = null,
            DateTime?utcPickupDate   = null,
            decimal?patientBalance   = null,
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("patientExternalId", patientID);
            criteria.Add("locationExternalId", locationID);
            criteria.Add("externalId", ID);
            criteria.Add("creationDate", utcCreationDate.ToString());
            criteria.Add("pickupDate", utcPickupDate.ToString());
            criteria.Add("patientBalance", patientBalance.ToString());
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <OrderModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #19
0
        public static ListModel <LocationModel> Search(
            IServerAuthentication restClientAuthenticator,
            string name      = "",
            string ID        = "",
            bool?active      = null,
            string city      = "",
            string state     = "",
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("name", name);
            criteria.Add("externalId", ID);
            criteria.Add("active", active.ToString());
            criteria.Add("city", city);
            criteria.Add("state", state);
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <LocationModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #20
0
        public static ListModel <UserModel> Search(
            IServerAuthentication restClientAuthenticator,
            string username  = "",
            bool?active      = null,
            string firstName = "",
            string lastName  = "",
            int page         = 1,
            int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("username", username);
            criteria.Add("active", active.ToString());
            criteria.Add("firstName", firstName);
            criteria.Add("lastname", lastName);
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <UserModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #21
0
		public override void OnResponse( GameClient sender, RelayInfo info )
		{
			if ( info.ButtonID != 0 )
			{
				// Always update name
				m_Criteria.Name = info.GetTextEntry( 1 ).Text;
			}

			switch ( info.ButtonID )
			{
				case 0: // Cancel
					{
						break;
					}
				case 1: // Search
					{
						if ( m_Criteria.Count == 0 )
						{
							Resend( 1154586 ); // Please select some criteria to search for.
							break;
						}

						StartSearch( m_Mobile, m_Criteria, 0 );

						break;
					}
				case 2: // Clear search criteria
					{
						m_Criteria.Clear();
						Resend();

						break;
					}
				case 3: // Submit price criteria
					{
						m_Criteria.MinPrice = Utility.ToInt32( info.GetTextEntry( 2 ).Text );
						m_Criteria.MaxPrice = Utility.ToInt32( info.GetTextEntry( 3 ).Text );
						Resend();

						break;
					}
				case 4: // Reset Item Name
					{
						m_Criteria.Name = "";
						Resend();

						break;
					}
				case 5: // Reset Item Price
					{
						m_Criteria.MinPrice = SearchCriteria.DefaultMinPrice;
						m_Criteria.MaxPrice = SearchCriteria.DefaultMaxPrice;
						Resend();

						break;
					}
				default:
					{
						if ( info.ButtonID < 100 )
						{
							int criterionIdx = ( info.ButtonID - 50 );

							if ( criterionIdx >= 0 && criterionIdx < m_SelectedCriteria.Length )
							{
								SearchCriterion criterion = m_SelectedCriteria[criterionIdx];
								m_Criteria.Remove( criterion );
							}
						}
						else
						{
							if ( m_Criteria.Count >= SearchCriteria.MaxCount )
							{
								Resend( 1154681 ); // You may not add any more search criteria items.
								break;
							}

							int categoryIdx = ( info.ButtonID / 100 ) - 1;
							int criterionIdx = ( info.ButtonID % 100 );

							var categories = SearchCriteriaCategory.AllCategories;

							if ( categoryIdx >= 0 && categoryIdx < categories.Length )
							{
								SearchCriteriaCategory category = categories[categoryIdx];

								if ( criterionIdx >= 0 && criterionIdx < category.Criteria.Length )
								{
									SearchCriterionEntry entry = category.Criteria[criterionIdx];

									SearchCriterion sc = entry.Criterion.Clone();

									if ( sc is ValuedSearchCriterion )
										( (ValuedSearchCriterion) sc ).Value = Utility.ToInt32( info.GetTextEntry( info.ButtonID ).Text );

									m_Criteria.Add( sc );
								}
							}
						}

						Resend();

						break;
					}
			}
		}
예제 #22
0
        /// <summary>
        /// Handles the Activated event for any SearchCriterion control.  This event
        /// is fired when a SearchCriterion is made active, which mean that the input
        /// controls should be activated and a new (inactive) control should be created.
        /// However, if a control is not valid, a new control can't be added.
        /// </summary>
        /// <param name="sender">The specific SearchCriterion instance that fired the event</param>
        /// <param name="e">Event arguments for the event</param>
        private void SearchCriterion_Activated(object sender, EventArgs e)
        {
            bool addNew = true;
            SearchCriterionViewModel sourceCriterion = sender as SearchCriterionViewModel;

            // Check how many SearchCriterion controls we currently have
            if (SearchCriteria.Count > 1)
            {
                // Loop through all SearchCriterion view models in our list
                foreach (SearchCriterionViewModel criterion in SearchCriteria)
                {
                    // If this criterion control is the one that fired the Activate
                    // event, just skip it
                    if (criterion == sourceCriterion)
                    {
                        continue;
                    }

                    // Check if the SearchCriterion is currently active
                    if (criterion.IsActive)
                    {
                        // Validate the Search Criterion
                        criterion.Validate();

                        if (!criterion.IsValid)
                        {
                            // Set a flag that we don't actually want to create
                            // a new Criterion because this one was invalid.
                            addNew            = false;
                            SelectedCriterion = criterion;
                        }
                    }
                }
            }

            // Check if we are actually adding a new SearchCritrion control
            if (addNew)
            {
                // Set the IsActive property to true which will trigger the
                // underlying StoryBoard to enable the input controls.
                sourceCriterion.IsActive = true;

                // Make sure that we have one criterion and that it is disabled
                // and inactive.
                SearchCriterionViewModel newSearchCriterion = new SearchCriterionViewModel(this)
                {
                    IsEnabled = true, IsActive = false
                };
                SearchCriteria.Add(newSearchCriterion);
                SelectedCriterion = sourceCriterion;

                // Wire up event handlers for the Activated and Deactivated events of
                // the newly created SearchCriterion control
                newSearchCriterion.Activated   += new EventHandler <EventArgs>(SearchCriterion_Activated);
                newSearchCriterion.Deactivated += new EventHandler <EventArgs>(SearchCriterion_Deactivated);
            }
            else
            {
                sourceCriterion.IsActive = false;
            }
        }
 public void AddSearchCriteria(string propertyName, object value, ScanOperator criteriaOperator = ScanOperator.Equal)
 {
     SearchCriteria.Add(new DynamoScanSearchCriteriaEntity {
         PropertyName = propertyName, Value = value, ScanOperator = criteriaOperator
     });
 }
예제 #24
0
        private void PopulateExposuretypesforAdvancedFilter(SearchCriteria criteria)
        {
            //populated list
            var PopPL2List     = new List <int>();
            var PopExpGrpList  = new List <int>();
            var PopExpTypeList = new List <int>();
            //param list
            var SubDivList  = new List <int>();
            var PL2List     = new List <int>();
            var ExpGrpList  = new List <int>();
            var ExpTypeList = new List <int>();

            string subdivisionParam    = criteria.Parameters.FirstOrDefaultValue <string>(FilterParameters.SubDivisions);
            string productLineParam    = criteria.Parameters.FirstOrDefaultValue <string>(FilterParameters.ProductLines);
            string exposuresgroupParam = criteria.Parameters.FirstOrDefaultValue <string>(FilterParameters.ExposureGroups);
            string exposuresParam      = criteria.Parameters.FirstOrDefaultValue <string>(FilterParameters.Exposuretypes);

            if (!string.IsNullOrEmpty(subdivisionParam))
            {
                SubDivList = subdivisionParam.Split(COMMA_SEPARATOR).Select(a => Convert.ToInt32(a)).ToList();
            }

            if (!string.IsNullOrEmpty(productLineParam))
            {
                PL2List = productLineParam.Split(COMMA_SEPARATOR).Select(a => Convert.ToInt32(a)).ToList();
            }

            if (!string.IsNullOrEmpty(exposuresgroupParam))
            {
                ExpGrpList = exposuresgroupParam.Split(COMMA_SEPARATOR).Select(a => Convert.ToInt32(a)).ToList();
            }

            if (!string.IsNullOrEmpty(exposuresParam))
            {
                ExpTypeList = exposuresParam.Split(COMMA_SEPARATOR).Select(a => Convert.ToInt32(a)).ToList();
            }


            var ExpGlobalReTree = GetGlobalReExposureTree();

            if (SubDivList.Count > 0)
            {
                SubDivList.ForEach((division) =>
                {
                    var prdl = ExpGlobalReTree.Where(t => ((t.SubdivisionCode ?? -1) == division))
                               .GroupBy(g => g.ProductLineCode)
                               .Select(e => e.First().ProductLineCode ?? -1).ToList();

                    bool isselected = false;
                    prdl.ForEach((product) =>
                    {
                        if (PL2List.Contains(product))
                        {
                            isselected = true;
                            PopPL2List.Add(product);
                        }
                    });
                    if (!isselected)
                    {
                        PopPL2List.AddRange(prdl);
                    }
                    PopPL2List = PopPL2List.Distinct().ToList();

                    //populate exp grp
                    PopPL2List.ForEach((product) =>
                    {
                        var grplist = ExpGlobalReTree.Where(t => ((t.SubdivisionCode ?? -1) == division))
                                      .Where(t => (t.ProductLineCode == product))
                                      .GroupBy(g => g.ExposureGroupCode)
                                      .Select(e => e.First().ExposureGroupCode ?? -1).ToList();

                        isselected = false;
                        grplist.ForEach((group) =>
                        {
                            if (ExpGrpList.Contains(group))
                            {
                                isselected = true;
                                PopExpGrpList.Add(group);
                            }
                        });
                        if (!isselected)
                        {
                            PopExpGrpList.AddRange(grplist);
                        }
                        PopExpGrpList = PopExpGrpList.Distinct().ToList();

                        //populate exp type
                        PopExpGrpList.ForEach((group) =>
                        {
                            var explist = ExpGlobalReTree.Where(t => ((t.SubdivisionCode ?? -1) == division))
                                          .Where(t => (t.ProductLineCode == product))
                                          .Where(t => (t.ExposureGroupCode == group))
                                          .GroupBy(g => g.ExposureTypeCode)
                                          .Select(e => e.First().ExposureTypeCode).ToList();
                            isselected = false;
                            explist.ForEach((exposure) =>
                            {
                                if (ExpTypeList.Contains(exposure))
                                {
                                    isselected = true;
                                    PopExpTypeList.Add(exposure);
                                }
                            });
                            if (!isselected)
                            {
                                PopExpTypeList.AddRange(explist);
                            }
                            PopExpTypeList = PopExpTypeList.Distinct().ToList();
                        });
                    });

                    PopPL2List.Clear();
                    PopExpGrpList.Clear();
                });
            }

            criteria.Add(new FilterParameter("PopulatedExposuretypes", string.Join(",", PopExpTypeList.Select(x => x.ToString()).ToArray())));
            //throw new IllegalArgumentAPIException("count ={0} list is "+string.Join(",", PopExpTypeList.Select(x => x.ToString()).ToArray()), PopExpTypeList.Count());
        }
예제 #25
0
                protected void GetIndexSearchCriteria(Dictionary<string, SearchCriteria> map)
                {
                    foreach (IndexSchema indexSchema in table.Indexes)
                    {
                        SearchCriteria searchCriteria = new SearchCriteria();
                        foreach (MemberColumnSchema mcs in indexSchema.MemberColumns)
                            if (mcs.Table.Equals(table))
                                searchCriteria.Add(mcs);

                        if (!String.IsNullOrEmpty(extendedProperty) && indexSchema.ExtendedProperties.Contains(extendedProperty) && indexSchema.ExtendedProperties[extendedProperty].Value != null)
                            searchCriteria.SetMethodNameGeneration(indexSchema.ExtendedProperties[extendedProperty].Value.ToString());

                        AddToMap(map, searchCriteria);
                    }
                }
예제 #26
0
        public static ListModel <AppointmentModel> Search(IServerAuthentication restClientAuthenticator, string appointmentExternalId = "",
                                                          DateTime?patientBirthday = null, string status                = "", string startDateOperator = "", DateTime?start1 = null,
                                                          DateTime?start2          = null, string portalCreatedOperator = "", DateTime?portalCreated1  = null, DateTime?portalCreated2 = null,
                                                          int page = 1, int itemsPerPage = 10)
        {
            var criteria = new SearchCriteria();

            criteria.Add("appointmentExternalId", appointmentExternalId);
            criteria.Add("patientBirthday", patientBirthday.ToString());
            criteria.Add("status", status);
            criteria.Add("startDateOperator", startDateOperator);
            criteria.Add("start1", start1.ToString());
            criteria.Add("start2", start2.ToString());
            criteria.Add("portalCreatedOperator", portalCreatedOperator);
            criteria.Add("portalCreated1", portalCreated1.ToString());
            criteria.Add("portalCreated2", portalCreated2.ToString());

            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());

            return(ApiClientGenericObject <AppointmentModel> .Search(restClientAuthenticator, ControllerName, criteria));
        }
예제 #27
0
        public static ListModel <FormModel> Search(
            IServerAuthentication restClientAuthenticator,
            string formStatus            = "",
            string creationDateOperator  = "",
            DateTime?utcCreationDate1    = null,
            DateTime?utcCreationDate2    = null,
            string completedDateOperator = "",
            DateTime?utcCompletedDate1   = null,
            DateTime?utcCompletedDate2   = null,
            string closedDateOperator    = "",
            DateTime?utcClosedDate1      = null,
            DateTime?utcClosedDate2      = null,
            string patientFirstName      = "",
            string patientLastName       = "",
            bool?FormLayoutActive        = null,
            string patientExternalId     = "",
            int page              = 1,
            int itemsPerPage      = 10,
            bool onlyProfileForms = false)
        {
            var criteria = new SearchCriteria();

            criteria.Add("formStatus", formStatus);
            criteria.Add("creationDateOperator", creationDateOperator);
            criteria.Add("utcCreationDate1", utcCreationDate1.ToString());
            criteria.Add("utcCreationDate2", utcCreationDate2.ToString());
            criteria.Add("completedDateOperator", completedDateOperator);
            criteria.Add("utcCompletedDate1", utcCompletedDate1.ToString());
            criteria.Add("utcCompletedDate2", utcCompletedDate2.ToString());
            criteria.Add("dateClosedOperator", closedDateOperator);
            criteria.Add("utcClosedDate1", utcClosedDate1.ToString());
            criteria.Add("utcClosedDate2", utcClosedDate2.ToString());
            criteria.Add("patientFirstName", patientFirstName);
            criteria.Add("patientLastName", patientLastName);
            criteria.Add("FormLayoutActive", FormLayoutActive.ToString());
            criteria.Add("page", page.ToString());
            criteria.Add("itemsPerPage", itemsPerPage.ToString());
            criteria.Add("patientExternalId", patientExternalId);
            criteria.Add("onlyProfileForms", onlyProfileForms.ToString());

            var baseAddress        = restClientAuthenticator.GetBaseAddress();
            var authorizationToken = restClientAuthenticator.GetToken();

            var tries      = 0;
            var keepTrying = true;

            using (var restClient = new HttpClient())
            {
                restClient.BaseAddress = new Uri(baseAddress);
                restClient.DefaultRequestHeaders.Accept.Clear();
                restClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                while (keepTrying)
                {
                    restClient.DefaultRequestHeaders.Add("Authorization", authorizationToken);
                    HttpResponseMessage response = restClient.GetAsync(string.Format(ApiClientGenericObjectResources.SearchRequestUri, controllerName, "/search?", criteria.GetAsUrlParameters())).Result;

                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        authorizationToken = restClientAuthenticator.GetToken(true);

                        tries++;
                        keepTrying = tries < 4;
                    }
                    else
                    {
                        keepTrying = false;

                        if (response.IsSuccessStatusCode)
                        {
                            ListModel <FormModel> formModelList = response.Content.ReadAsAsync <ListModel <FormModel> >().Result;

                            return(formModelList);
                        }
                        else
                        {
                            throw new HttpRequestException(string.Format(ApiClientGenericObjectResources.UnsuccessfulResponseMessage, response.StatusCode.ToString()));
                        }
                    }
                }
                throw new HttpRequestException(string.Format(ApiClientGenericObjectResources.UnsuccessfulResponseMessage, HttpStatusCode.Unauthorized.ToString()));
            }
        }