Exemple #1
0
        protected override void OnInit(EventArgs e)
        {
            Control control;

            if (_grid == null)
            {
                control = FindNestedControl(_gridId);

                if (control != null && control is GridView)
                {
                    _grid = control as GridView;
                }
                else
                {
                    throw new Exception(string.Format("GridView '{0}' not found", _gridId));
                }
            }

            if (_grid is VoteHolderGridView)
            {
                GridBindingStart += ((VoteHolderGridView)_grid).OnGridBindingStart;
            }

            _businessQuery = BusinessQuery.CreateInstance(_queryType);

            if (!ReferenceEquals(QueryCreated, null))
            {
                QueryCreated();
            }

            if (_pager == null && _pagerId != null)
            {
                control = FindControl(_pagerId);
                if (control != null && control is Pager)
                {
                    _pager         = control as Pager;
                    _pager.StateID = GetStateID();
                    _childControls.Add(_pager);
                }
                else
                {
                    throw new Exception(string.Format("Pager '{0}' not found", _pagerId));
                }
            }

            InitializeGridSettings();
            InitializeQuerySettings();

            if (IsPagingEnabled && Page.IsPostBack)
            {
                _pager.PageSize = _businessQuery.Query.PageSettings.PageSize;
            }

            InitializePagerSettings();

            if (!Page.IsPostBack)
            {
                IsRequiredToBindGrid = true;
            }
        }
Exemple #2
0
        public GridController(GridView grid, Pager pager,
                              BusinessQuery businessQuery, Type entityBaseType)
        {
            IsRequiredToBindGrid = false;
            if (grid == null)
            {
                throw new ArgumentNullException("grid");
            }

            if (businessQuery == null)
            {
                throw new ArgumentNullException("businessQuery");
            }

            _businessQuery      = businessQuery;
            this.entityBaseType = entityBaseType;

            _grid = grid;
            _childControls.Add(grid);

            if (pager != null)
            {
                _pager = pager;
                //if (pager is Control)
                _childControls.Add(pager);
            }

            InitializeGridSettings();
            InitializeQuerySettings();
            InitializePagerSettings();
        }
            public override Response <IBusiness> FindBusinesses(BusinessQuery query)
            {
                if (this.ForceErrorResult)
                {
                    throw new FindException("Stubbed client always errors!");
                }

                var results = new List <IBusiness>();

                if (!this.ForceEmptyResult)
                {
                    results.Add(_business);
                }
                return(new Response <IBusiness>(this, results, GetDictionary(this), _emptyMessages));
            }
Exemple #4
0
        public void ItShouldPrintAHumanReadableBusinessQuery()
        {
            var q = new BusinessQuery("Whitepages")
            {
                City = "Seattle", StateCode = "WA"
            };

            var s = q.ToString();

            Console.Out.WriteLine(s);

            Assert.IsTrue(s.StartsWith("BusinessQuery"));
            Assert.IsTrue(s.Contains("Whitepages"));
            Assert.IsTrue(s.Contains("Seattle"));
            Assert.IsTrue(s.Contains("WA"));
        }
        static void Main(string[] args)
        {
            var apiKey = ExampleUtils.GetApiKey(args);
            var client = new Client(apiKey);
            var query  = new BusinessQuery
            {
                Name       = Name,
                City       = City,
                StateCode  = StateCode,
                PostalCode = PostalCode,
            };

            Response <IBusiness> response = null;

            try
            {
                response = client.FindBusinesses(query);
            }
            catch (FindException)
            {
                Console.Out.WriteLine("FindBusiness lookup for {0}; {1}; {2}; {3} failed!", Name, City, StateCode, PostalCode);
            }

            if ((response != null) && (response.IsSuccess))
            {
                var results = response.Results;
                Console.Out.WriteLine(
                    "FindBusiness lookup for {0}; {1}; {2}; {3} was successful, returning {4} root business objects{5}{5}",
                    Name, City, StateCode, PostalCode, results.Count, System.Environment.NewLine);

                foreach (var business in results)
                {
                    ExampleUtils.DumpBusiness(business, 2);
                    Console.Out.WriteLine();
                }
            }

#if DEBUG
            System.Console.Out.WriteLine("Press the ENTER key to quit...");
            System.Console.In.ReadLine();
#endif
        }
Exemple #6
0
 public GridController(GridView grid, Pager pager, BusinessQuery businessQuery)
     : this(grid, pager, businessQuery, null)
 {
 }
 /// <summary>
 /// Executes the given query and returns the response.
 /// </summary>
 /// <param name="query">The query to perform</param>
 /// <returns>The response object</returns>
 public virtual Response <IBusiness> FindBusinesses(BusinessQuery query)
 {
     return(_businessResultFinder.Find(query, this));
 }
Exemple #8
0
 public static BusinessQuery <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> Secure <TCollection, TReadOnlyCollection, TObject, TEntry, TKey>(this BusinessQuery <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> businessQuery)
     where TCollection : BusinessCollection <TObject, TEntry, TKey>
     where TReadOnlyCollection : BusinessReadOnlyCollection <TObject, TEntry, TKey>
     where TObject : BusinessObject <TEntry, TKey>
     where TEntry : class
 {
     return(businessQuery.ExecCustomFunction(MyAppBusinessContext.READ_SECURITY_KEY));
 }