/// <summary>
		/// Iterates through the <see cref="Navigation.Crumb"/> contents of <see cref="Navigation.StateController.Crumbs"/>
		/// </summary>
		/// <param name="arguments">This parameter is ignored</param>
		/// <returns>An <see cref="System.Collections.IEnumerable"/> list of <see cref="Navigation.Crumb"/> items</returns>
		protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
		{
			foreach (Crumb crumb in StateController.Crumbs)
			{
				yield return crumb;
			}
		}
Exemplo n.º 2
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments selectArgs)
        {
            // only continue if a membership provider has been configured
            if (!Utils.IsProviderConfigured())
                return null;

            // get roles and build data table
            DataTable dataTable = new DataTable();
            String[] roles = Utils.BaseRoleProvider().GetAllRoles();
            dataTable.Columns.Add("Role");
            dataTable.Columns.Add("UsersInRole");

            // add users in role counts
            for (int i = 0; i < roles.Length; i++)
            {
                DataRow row = dataTable.NewRow();
                row["Role"] = roles[i];
                row["UsersInRole"] = Utils.BaseRoleProvider().GetUsersInRole(roles[i].ToString()).Length;
                dataTable.Rows.Add(row);
            }
            dataTable.AcceptChanges();
            DataView dataView = new DataView(dataTable);

            // sort if a sort expression available
            if (selectArgs.SortExpression != String.Empty)
            {
                dataView.Sort = selectArgs.SortExpression;
            }

            // return as a DataList
            return (IEnumerable) dataView;
        }
		public void Equals ()
		{
			DataSourceSelectArguments arg1 = new DataSourceSelectArguments ();
			DataSourceSelectArguments arg2 = DataSourceSelectArguments.Empty;

			Assert.IsTrue (arg1.Equals (arg2), "Equals#1");
			Assert.IsTrue (arg1.GetHashCode () == arg2.GetHashCode (), "GetHashCode#1");

			arg1.SortExpression = "sort";
			arg1.MaximumRows = 10;
			arg1.StartRowIndex = 5;
			arg1.RetrieveTotalRowCount = true;
			arg1.TotalRowCount = 30;

			Assert.IsFalse (arg1.Equals (arg2), "Equals#2");
			Assert.IsFalse (arg1.GetHashCode () == arg2.GetHashCode (), "GetHashCode#2");

			arg2.SortExpression = "sort";
			arg2.MaximumRows = 10;
			arg2.StartRowIndex = 5;

			Assert.IsFalse (arg1.Equals (arg2), "Equals#3");
			Assert.IsFalse (arg1.GetHashCode () == arg2.GetHashCode (), "GetHashCode#3");

			arg2.RetrieveTotalRowCount = true;
			arg2.TotalRowCount = 30;

			Assert.IsTrue (arg1.Equals (arg2), "Equals#4");
			Assert.IsTrue (arg1.GetHashCode () == arg2.GetHashCode (), "GetHashCode#4");
		}
Exemplo n.º 4
0
		public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
		{
			if (String.Compare (tableName, "BazValidationAttributesTable", StringComparison.OrdinalIgnoreCase) == 0)
				return BazValidationAttributes;

			return null;
		}
		protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
		{
			if (this.dataSourceControl.Enabled == true)
			{
				IOrderedDictionary parameters = this.dataSourceControl.DataParameters.GetValues(HttpContext.Current, this.dataSourceControl);
				DataEventArgs args = new DataEventArgs(this.dataSourceControl.PageSize, arguments.StartRowIndex, arguments.SortExpression, parameters);

				this.dataSourceControl.GetData(args);

				arguments.TotalRowCount = args.TotalRowCount;
				arguments.MaximumRows = this.dataSourceControl.PageSize;
				arguments.AddSupportedCapabilities(DataSourceCapabilities.Page | DataSourceCapabilities.Sort | DataSourceCapabilities.RetrieveTotalRowCount);
				arguments.RetrieveTotalRowCount = true;

				if (!(args.Data is ICollection))
				{
					return (args.Data.OfType<Object>().ToList());
				}
				else
				{
					return (args.Data);
				}
			}
			else
			{
				arguments.TotalRowCount = 0;
				return (new ArrayList());
			}
		}
Exemplo n.º 6
0
        private void BindData()
        {
            SqlDataSource1.DataBind();
            //string sqlquery = "SELECT * FROM [ISBEPI_DEV].[dbo].[HomeVisitorSiteVisitSurvey] WHERE Schd_ID = 16";
            DataTable dt = new DataTable();
            DataSourceSelectArguments args = new DataSourceSelectArguments();
            DataView view = (DataView)SqlDataSource1.Select(args);
            dt = view.ToTable();
            DataSet ds = new DataSet();
            ds.Tables.Add(dt);
            DataSet new_ds = FlipDataSet(ds); // Flip the DataSet
            DataView my_DataView = new_ds.Tables[0].DefaultView;
            this.DataGrid1.DataSource = my_DataView;
            this.DataGrid1.DataBind();

            DataTable dt2 = new DataTable();
            DataSourceSelectArguments args2 = new DataSourceSelectArguments();
            DataView view2 = (DataView)SqlDataSource2.Select(args2);
            dt2 = view2.ToTable();
            DataSet ds2 = new DataSet();
            ds2.Tables.Add(dt2);
            DataSet new_ds2 = FlipDataSet(ds2); // Flip the DataSet
            DataView my_DataView2 = new_ds2.Tables[0].DefaultView;
            this.DataGrid2.DataSource = my_DataView2;
            this.DataGrid2.DataBind();
        }
Exemplo n.º 7
0
 public virtual void Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
 {
     if (callback == null)
     {
         throw new ArgumentNullException("callback");
     }
     callback(this.ExecuteSelect(arguments));
 }
 protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
 {
     if (string.IsNullOrEmpty(this._owner.DataFile))
     {
         throw new InvalidOperationException(System.Web.SR.GetString("AccessDataSourceView_SelectRequiresDataFile", new object[] { this._owner.ID }));
     }
     return base.ExecuteSelect(arguments);
 }
Exemplo n.º 9
0
        /// <summary>
        /// Gets a list of data asynchronously from the underlying data storage.
        /// </summary>
        /// <param name="arguments">A <see cref="T:System.Web.UI.DataSourceSelectArguments"></see> that is used to request operations on the data beyond basic data retrieval.</param>
        /// <param name="callback">A <see cref="T:System.Web.UI.DataSourceViewSelectCallback"></see> delegate that is used to notify a data-bound control when the asynchronous operation is complete.</param>
        /// <exception cref="T:System.ArgumentNullException">The <see cref="T:System.Web.UI.DataSourceViewSelectCallback"></see> supplied is null.</exception>
        public override void Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            callback(ExecuteSelect(arguments));
        }
Exemplo n.º 10
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            GenericSelectArgs args = new GenericSelectArgs(arguments)
            {
            };

            var theResult = this.Owner.Select(args);

            return theResult;
        }
Exemplo n.º 11
0
        public override bool Equals(object obj)
        {
            DataSourceSelectArguments arguments = obj as DataSourceSelectArguments;

            if (arguments == null)
            {
                return(false);
            }
            return((((arguments.MaximumRows == this._maximumRows) && (arguments.RetrieveTotalRowCount == this._retrieveTotalRowCount)) && ((arguments.SortExpression == this._sortExpression) && (arguments.StartRowIndex == this._startRowIndex))) && (arguments.TotalRowCount == this._totalRowCount));
        }
Exemplo n.º 12
0
		public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
		{
			if (String.Compare (tableName, "AssociatedFooTable", StringComparison.OrdinalIgnoreCase) == 0)
				return AssociatedFoo;

			if (String.Compare (tableName, "AssociatedBarTable", StringComparison.OrdinalIgnoreCase) == 0)
				return AssociatedBar;

			if (String.Compare (tableName, "BazWithDataTypeAttributeTable", StringComparison.OrdinalIgnoreCase) == 0)
				return BazWithDataTypeAttribute;

			return null;
		}
Exemplo n.º 13
0
		public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
		{
			if (String.Compare (tableName, "EmployeeTable", StringComparison.OrdinalIgnoreCase) == 0)
				return Employees;

			if (String.Compare (tableName, "SeasonalEmployeeTable", StringComparison.OrdinalIgnoreCase) == 0)
				return SeasonalEmployees;

			if (String.Compare (tableName, "BazDataTypeDefaultTypesTable", StringComparison.OrdinalIgnoreCase) == 0)
				return DefaultDataTypes;

			return null;
		}
Exemplo n.º 14
0
 public QueryContext(IDictionary<string, object> whereParameters,
     IDictionary<string, object> orderGroupsByParameters,
     IOrderedDictionary orderByParameters,
     IDictionary<string, object> groupByParameters,
     IDictionary<string, object> selectParameters, 
     DataSourceSelectArguments arguments) {
     WhereParameters = whereParameters;
     OrderByParameters = orderByParameters;
     OrderGroupsByParameters = orderGroupsByParameters;
     SelectParameters = selectParameters;
     GroupByParameters = groupByParameters;
     Arguments = arguments;
 }
Exemplo n.º 15
0
        public virtual void Select(DataSourceSelectArguments selectArgs,
                                   DataSourceViewSelectCallback callBack)
        {
            if (callBack == null)
            {
                throw new ArgumentNullException("callBack");
            }

            selectArgs.RaiseUnsupportedCapabilitiesError(this);

            IEnumerable selectList = ExecuteSelect(selectArgs);

            callBack(selectList);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="arguments"></param>
        /// <param name="parameters"></param>
        /// <param name="sourceType"></param>
        public SelectingEventArgs(DataSourceSelectArguments arguments, IDictionary parameters, Type sourceType)
            : base(sourceType)
        {
            if (arguments == null)
                throw new ControlParameterException("The arguments for the SelectingEventArgs instance cannot be null.", "arguments");

            this.startRowIndex = arguments.StartRowIndex;
            this.maximumRows = arguments.MaximumRows;

            if (parameters != null && parameters.Count > 0)
            {
                this.parameters.AddRange(parameters.Keys.Cast<string>().Select<string, ISourceParameter>(n => new SourceParameter(n, parameters[n])));
            }
        }
 private void BindData()
 {
     SqlDataSource1.DataBind();          
     DataTable dt = new DataTable();
     DataSourceSelectArguments args = new DataSourceSelectArguments();
     DataView view = (DataView)SqlDataSource2.Select(args);
     dt = view.ToTable();
     DataSet ds = new DataSet();
     ds.Tables.Add(dt);
     DataSet new_ds = FlipDataSet(ds); // Flip the DataSet
     DataView my_DataView = new_ds.Tables[0].DefaultView;
     this.DataGrid1.DataSource = my_DataView;
     this.DataGrid1.DataBind();
 }
Exemplo n.º 18
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            arguments.RaiseUnsupportedCapabilitiesError(this);

            DataTable dt = _owner.GetDataTable();
            if(dt == null) return new DataTable().DefaultView;

            _dataView = new DataView(dt);

            PerformFiltering();

            PerformSorting(arguments.SortExpression);

            return _dataView;
        }
Exemplo n.º 19
0
        // MSDN: The DataSourceSelectArguments class overrides the Object.Equals method to test
        // equality using the various properties of the objects. If the MaximumRows,
        // RetrieveTotalRowCount, SortExpression, StartRowIndex, and TotalRowCount properties
        // are all equal in value, the Equals(Object) method returns true.
        public override bool Equals(object obj)
        {
            DataSourceSelectArguments args = obj as DataSourceSelectArguments;

            if (args == null)
            {
                return(false);
            }

            return(this.SortExpression == args.SortExpression &&
                   this.StartRowIndex == args.StartRowIndex &&
                   this.MaximumRows == args.MaximumRows &&
                   this.RetrieveTotalRowCount == args.RetrieveTotalRowCount &&
                   this.TotalRowCount == args.TotalRowCount);
        }
 protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
 {
     arguments.RaiseUnsupportedCapabilitiesError(this);
     XmlNode xmlDocument = this._owner.GetXmlDocument();
     XmlNodeList nodes = null;
     if (this._owner.XPath.Length != 0)
     {
         nodes = xmlDocument.SelectNodes(this._owner.XPath);
     }
     else
     {
         nodes = xmlDocument.SelectNodes("/node()/node()");
     }
     return new XmlDataSourceNodeDescriptorEnumeration(nodes);
 }
Exemplo n.º 21
0
		public LinqDataSourceSelectEventArgs (
			DataSourceSelectArguments arguments,
			IDictionary<string, object> whereParameters,
			IOrderedDictionary orderByParameters,
			IDictionary<string, object> groupByParameters,
			IDictionary<string, object> orderGroupsByParameters,
			IDictionary<string, object> selectParameters)
		{
			// all nullable.
			Arguments = arguments;
			WhereParameters = whereParameters;
			OrderByParameters = orderByParameters;
			GroupByParameters = groupByParameters;
			OrderGroupsByParameters = orderGroupsByParameters;
			SelectParameters = selectParameters;
		}
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            var loadedEntities =  base.ExecuteSelect(arguments);

            if (!this._dataSource.GenerateEmptyRowOnTop)
            {
                return loadedEntities;
            }

            if (arguments.MaximumRows > 0)
            {
                throw new InvalidOperationException("GenerateEmptyRowOnTop is not supported together with paging!");
            }

            return Yield(Activator.CreateInstance(this.EntityType), loadedEntities);
        }
		private object[] GetParametersForSelect(DataSourceSelectArguments arguments)
		{
			var parameters = new List<object>();
			foreach (DictionaryEntry entry in SelectParameters.GetValues(HttpContext.Current, owner))
			{
				parameters.Add(entry.Value);
			}
			if (CanPage)
			{
				parameters.Add(arguments.MaximumRows);
				parameters.Add(arguments.StartRowIndex);
			}
			if ((!string.IsNullOrEmpty(arguments.SortExpression)) && (!InternalSort))
			{
				parameters.Add(arguments.SortExpression);
			}
			return parameters.ToArray();
		}
        /// <devdoc>
        /// Returns all the rows of the datasource.
        /// </devdoc>
        protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) {
            arguments.RaiseUnsupportedCapabilitiesError(this);


            XmlNode root = _owner.GetXmlDocument();

            XmlNodeList nodes = null;
            if (_owner.XPath.Length != 0) {
                // If an XPath is specified on the control, use it
                nodes = root.SelectNodes(_owner.XPath);
            }
            else {
                // Otherwise, get all the children of the root
                nodes = root.SelectNodes("/node()/node()");
            }

            return new XmlDataSourceNodeDescriptorEnumeration(nodes);
        }
Exemplo n.º 25
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            arguments.RaiseUnsupportedCapabilitiesError(this);

            SearchRequestData requestData = _owner.GetSearchRequestData();
            if (requestData == null || (((requestData.SearchText == null) || (requestData.SearchText == "")) && (requestData.MetaDataNameList == null || requestData.MetaDataNameList.Length == 0)))
            {
                return null;
            }

            requestData.EnablePaging = false;
            requestData.ProviderName = Ektron.Cms.WebSearch.Utils.SQLIndexProvider;
            SearchQuery searchQ = new SearchQuery(requestData);
            searchQ.Columns = " ContentID64,ContentLanguage,FolderID64,ContentType,DocTitle,QuickLink ";
            DataTable suggestedResultTable = new DataTable();
            DataTable table = Manager.Providers[requestData.ProviderName].Search(requestData, searchQ.Query, HttpContext.Current, ref resultCount, ref suggestedResultTable);

            return (IEnumerable)MakeSearchResponseData(table,requestData.SearchText  );
        }
Exemplo n.º 26
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            arguments.RaiseUnsupportedCapabilitiesError(this);

            SearchRequestData requestData = _owner.GetSearchRequestData();
            if (requestData == null || (((requestData.SearchText == null) || (requestData.SearchText == "")) && (requestData.MetaDataNameList == null || requestData.MetaDataNameList.Length == 0)))
            {
                return null;
            }
            requestData.ProviderName = Ektron.Cms.WebSearch.Utils.SQLIndexProvider;
            SearchQuery searchQ = new SearchQuery(requestData);
            searchQ.Columns = " Characterization,DocLastAuthor,EDescription,DocTitle,FileName,CMSSize,DateCreated,DateModified,ContentID64,ContentLanguage,FolderID64,QuickLink,ContentType,TaxCategory	 ";

            DataTable suggestedResultTable = new DataTable();
            DataTable table = Manager.Providers[requestData.ProviderName].Search(requestData, searchQ.Query , HttpContext.Current, ref resultCount,ref suggestedResultTable );

            return (IEnumerable)table;
            //Make search results according to request
        }
Exemplo n.º 27
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            DataSetArea areaDataSet = new DataSetArea();
            //read from DB
            DataSourceSelectArguments selectSt = new DataSourceSelectArguments();
            SqlDataSource1.ConnectionString = common.getConnectionString();
            DataView allDataDataView = (DataView)SqlDataSource1.Select(selectSt);
            foreach (DataRowView d in allDataDataView)
            {
              int number2 = areaDataSet.AreaTable.Rows.Count;
              areaDataSet.AreaTable.Rows.Add(new object[] { number2+1, d["Name"].ToString()});
            }

            //read data from form
            string text = TextBoxAreaName.Text;

            //add data to dataset
            int number = areaDataSet.AreaTable.Rows.Count;
            areaDataSet.AreaTable.Rows.Add(new object[] { number+1, text });

            //TODO: Add to BD
            int t = 8;
            string sConnectionString = common.getConnectionString();
            SqlConnection objConn
                = new SqlConnection(sConnectionString);
            objConn.Open();
            string SQLquery = "Select ID, Name From AreaTable";
            SqlDataAdapter da
                = new SqlDataAdapter(SQLquery, objConn);
            //da.FillSchema(areaDataSet, SchemaType.Source, "AreaTable");
        //    da.FillSchema(areaDataSet.AreaTable, SchemaType.Source);
            //da.Fill(areaDataSet, "AreaTable");
        //    da.Fill(areaDataSet.AreaTable);
            SqlCommand insertRow = new SqlCommand();
            insertRow.CommandText = "INSERT INTO AreaTable(ID, Name)   VALUES(@param1,@param2)";
            insertRow.Parameters.AddWithValue("@param1", number + 1);
            insertRow.Parameters.AddWithValue("@param2", text);
            insertRow.Connection = objConn;
            insertRow.ExecuteNonQuery();
            //da.InsertCommand = insertRow;
            //da.Update(areaDataSet.AreaTable);
            objConn.Close();
        }
Exemplo n.º 28
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            arguments.RaiseUnsupportedCapabilitiesError(this);

            SearchRequestData requestData = _owner.GetSearchRequestData();
            if (requestData == null || (((requestData.SearchText == null) || (requestData.SearchText == "")) && (requestData.MetaDataNameList == null || requestData.MetaDataNameList.Length == 0)))
            {
                return null;
            }
            requestData.ProviderName = Ektron.Cms.WebSearch.Utils.SQLIndexProvider;
            SearchQuery searchQ = new SearchQuery(requestData);
            searchQ.Columns = " ContentID64,ContentLanguage,FolderID64,ContentType ";
            DataTable suggestedResultTable = new DataTable();
            DataTable table = Manager.Providers[requestData.ProviderName].Search(requestData, searchQ.Query , HttpContext.Current, ref resultCount,ref suggestedResultTable );

            //Implement this at a later point
            //Make search results according to request
            return (IEnumerable)table;
        }
Exemplo n.º 29
0
		protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
		{
			if (this.Query != null)
			{
			    ItemDataSourceSelectingEventArgs selectingArgs = new ItemDataSourceSelectingEventArgs(arguments);
			    OnSelecting(selectingArgs);

				IList<ContentItem> items = Query
					.FirstResult(selectingArgs.Arguments.StartRowIndex)
					.MaxResults(selectingArgs.Arguments.MaximumRows)
					.Select();

			    Collections.ItemListEventArgs args = new N2.Collections.ItemListEventArgs(new Collections.ItemList(items));
			    OnSelected(args);
			    return args.Items;
			}
			else
			    return null;
		}
		protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
		{
			var args = new TpObjectDataSourceEventArgs();
			owner.OnSelecting(args);
			if (args.Cancel)
			{
				return null;
			}

			object obj = args.BusinessObject ?? Source.GetDataFromSource(GetParametersForSelect(arguments));

			if (arguments.RetrieveTotalRowCount && CanRetrieveTotalRowCount)
			{
				arguments.TotalRowCount = GetRowCount(obj);
			}

			args.SelectParams = SelectParameters.GetValues(HttpContext.Current, owner);

			if (obj == null)
			{
				return null;
			}

			if (!(obj is IEnumerable))
			{
				obj = new[] {obj};
			}
			if (InternalSort && (!string.IsNullOrEmpty(arguments.SortExpression)))
			{
				obj = Sort((IEnumerable) obj, arguments.SortExpression);
			}

			args.BusinessObject = obj;
			owner.OnSelected(args);

			return (IEnumerable) obj;
		}
Exemplo n.º 31
0
 protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
 {
     IEnumerable result;
     if (null == this.source)
     {
         result = null;
     }
     else
     {
         DataTable table = new DataTable();
         table.Columns.Add("Key");
         table.Columns.Add("Name");
         foreach (string role in this.source.ListRoles())
         {
             table.Rows.Add(new object[]
             {
                 role,
                 role
             });
         }
         result = table.Rows;
     }
     return result;
 }
Exemplo n.º 32
0
 protected internal abstract IEnumerable ExecuteSelect(DataSourceSelectArguments arguments);
		public void FormView_CreateDataSourceSelectArguments2 () {
			DataSourceView view;
			Page p = new Page ();

			Poker dv = new Poker ();
			p.Controls.Add (dv);

			ObjectDataSource data = new ObjectDataSource ();
			data.TypeName = typeof (DataSourceObject).AssemblyQualifiedName;
			data.SelectMethod = "GetList";
			data.SortParameterName = "sortExpression";
			DataSourceSelectArguments arg;
			p.Controls.Add (data);

			dv.DataSource = data;
			dv.DataBind ();

			arg = dv.DoCreateDataSourceSelectArguments ();
			Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "Default");

			dv.AllowPaging = true;
			dv.PageIndex = 2;
			arg = dv.DoCreateDataSourceSelectArguments ();
			view = dv.DoGetData ();
			Assert.IsFalse (view.CanPage);
			Assert.IsTrue (view.CanRetrieveTotalRowCount);
			Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = true, CanPage = false, CanRetrieveTotalRowCount = true");

			// make DataSourceView.CanPage = true
			data.EnablePaging = true;

			arg = dv.DoCreateDataSourceSelectArguments ();
			view = dv.DoGetData ();
			Assert.IsTrue (view.CanPage);
			Assert.IsFalse (view.CanRetrieveTotalRowCount);
			Assert.IsTrue (arg.Equals (new DataSourceSelectArguments (2, -1)), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = false");

			dv.AllowPaging = false;
			arg = dv.DoCreateDataSourceSelectArguments ();
			Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = false");

			// make DataSourceView.CanRetrieveTotalRowCount = true
			data.SelectCountMethod = "GetCount";

			arg = dv.DoCreateDataSourceSelectArguments ();
			Assert.IsTrue (arg.Equals (DataSourceSelectArguments.Empty), "AllowPaging = false, CanPage = true, CanRetrieveTotalRowCount = true");

			dv.AllowPaging = true;
			arg = dv.DoCreateDataSourceSelectArguments ();
			DataSourceSelectArguments arg1 = new DataSourceSelectArguments (2, 1);
			arg1.RetrieveTotalRowCount = true;
			view = dv.DoGetData ();
			Assert.IsTrue (view.CanPage);
			Assert.IsTrue (view.CanRetrieveTotalRowCount);
			Assert.IsTrue (arg.Equals (arg1), "AllowPaging = true, CanPage = true, CanRetrieveTotalRowCount = true");
		}
        protected Array ExecuteCustomSelect(DataSourceSelectArguments arguments)
        {
            if (CanPage)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Page);

            if (CanSort)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort);

            if (CanRetrieveTotalRowCount)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount);
            
            ActiveRecordDataSourceFindEventArgs args = new ActiveRecordDataSourceFindEventArgs();
            CreateOrderFromFindParameters(args, arguments.SortExpression);

            if (args.Order.Count <= 0)
                CreateOrderFromFindParameters(args, Source.DefaultSort);

            args.ModelType = BuildManager.GetType(Source.TypeName, false, true);

            Source.OnBeforeFind(args);

            if (args.Cancel)
                return null;

            bool useSlicedFind = false;
            int firstResult = 0;
            int maxResults = 0;

            if (CanPage)
            {
                useSlicedFind = true;
                firstResult = arguments.StartRowIndex;
                maxResults = arguments.MaximumRows;
            }
            else if (Source.DefaultMaximumRows > 0)
            {
                useSlicedFind = true;
                firstResult = 0;
                maxResults = Source.DefaultMaximumRows;
            }

            Dictionary<string, object> methodParameters = CreateMethodParametersFromFindParameters();

            if (!String.IsNullOrEmpty(Source.FindMethodFirstResultParam) && useSlicedFind)
                methodParameters[Source.FindMethodFirstResultParam] = firstResult;

            if (!String.IsNullOrEmpty(Source.FindMethodMaxResultsParam) && useSlicedFind)
                methodParameters[Source.FindMethodMaxResultsParam] = maxResults;

            if (!String.IsNullOrEmpty(Source.FindMethodOrderParam) && CanSort)
                methodParameters[Source.FindMethodOrderParam] = args.Order.ToArray();

            Array result = null;

            try
            {
                if (arguments.RetrieveTotalRowCount)
                    arguments.TotalRowCount = ExecuteCount(args);

                MethodInfo findMethod;
                Dictionary<string, int> methodParameterNameToIndex;

                ResolveCustomFindMethod(args.ModelType, methodParameters, out findMethod, out methodParameterNameToIndex);

                if (findMethod == null)
                    throw new ApplicationException(String.Format("Invalid custom find method '{0}'.", Source.FindMethod));

                object[] findMethodArgs = new object[methodParameters.Keys.Count];

                foreach (string key in methodParameters.Keys)
                    findMethodArgs[methodParameterNameToIndex[key]] = methodParameters[key];

                result = findMethod.Invoke(null, findMethodArgs) as Array;
            }
            catch (Exception e)
            {
                args.Exception = e;
                args.WasError = true;

                Source.OnFindError(args);

                if (Source.ThrowOnError && !args.DoNotThrow)
                    throw;

                return null;
            }

            args.Result = result;

            Source.OnFind(args);

            return result;
        }                 
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            if (!String.IsNullOrEmpty(Source.FindMethod))
                return ExecuteCustomSelect(arguments);

            if (CanPage)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Page);

            if (CanSort)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort);

            if (CanRetrieveTotalRowCount)
                arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount);

            ActiveRecordDataSourceFindEventArgs args = new ActiveRecordDataSourceFindEventArgs();
            CreateCriteriaFromFindParameters(args);
            CreateOrderFromFindParameters(args, arguments.SortExpression);

            //set default sort
            if (args.Order.Count <= 0)
                CreateOrderFromFindParameters(args, Source.DefaultSort);

            args.ModelType = BuildManager.GetType(Source.TypeName, false, true);

            Source.OnBeforeFind(args);

            if (args.Cancel)
                return null;

            Array result = null;

            try
            {
                if (arguments.RetrieveTotalRowCount)
                    arguments.TotalRowCount = ExecuteCount(args);

                bool useSlicedFind = false;
                int firstResult = 0;
                int maxResults = 0;

                if (CanPage)
                {
                    useSlicedFind = true;
                    firstResult = arguments.StartRowIndex;
                    maxResults = arguments.MaximumRows;
                }
                else if (Source.DefaultMaximumRows > 0)
                {
                    useSlicedFind = true;
                    firstResult = 0;
                    maxResults = Source.DefaultMaximumRows;
                }

                if (useSlicedFind)
                    result = ActiveRecordMediator.SlicedFindAll(args.ModelType, firstResult, maxResults, args.Order.ToArray(), args.Criteria.ToArray());
                else
                    result = ActiveRecordMediator.FindAll(args.ModelType, args.Order.ToArray(), args.Criteria.ToArray());
                
            }
            catch (Exception e)
            {
                args.Exception = e;
                args.WasError = true;

                Source.OnFindError(args);

                if (Source.ThrowOnError && !args.DoNotThrow)
                    throw;

                return null;
            }

            args.Result = result;

            Source.OnFind(args);

            return result;
        }
Exemplo n.º 36
0
        public List <RekvirentData> GetListsOld()
        {
            SPDataSource ds = new SPDataSource();

            ds.DataSourceMode  = SPDataSourceMode.List;
            ds.UseInternalName = true;
            ds.Scope           = SPViewScope.Recursive;
            ds.IncludeHidden   = true;

            string queryString;

            //queryString = "<View><ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/><FieldRef Name='PermMask'/></ViewFields><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>5</Value></Eq></Where></Query></View>";
            //queryString = "<View><ViewFields><FieldRef Name='ID'/><FieldRef Name='Title'/><FieldRef Name='PermMask'/></View>";
            queryString = "<View></View>";

            ds.SelectCommand = queryString;

            Parameter dbParam_ListId = new Parameter("ListID");

            dbParam_ListId.DefaultValue = "DF806E7E-0073-4202-99E3-C4A269E2FA5D";
            ds.SelectParameters.Add(dbParam_ListId);


            SPDataSourceView     dsw;
            List <RekvirentData> dt = new List <RekvirentData>();

            dsw = ds.GetView();

            SPList xlist = dsw.List;

            SPViewCollection colViews = xlist.Views;

            foreach (SPView vView in colViews)
            {
            }

            /*
             * SPListItem newFolder = xlist.Items.Add(xlist.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, null);
             * if (newFolder != null)
             * {
             *  newFolder["Title"] = "Min Nye Folder";
             *  newFolder.Update();
             * }
             */
            System.Web.UI.DataSourceSelectArguments args = new System.Web.UI.DataSourceSelectArguments();

            SPDataSourceViewResultItem[] arrResult = (SPDataSourceViewResultItem[])dsw.Select(args);
            foreach (SPDataSourceViewResultItem Result in arrResult)
            {
                SPListItem oListItem = (SPListItem)Result.ResultItem;
                //SPField myField = xitem.Fields[new Guid("{FE7E79DD-DD68-438e-A960-E3686025D44B}")];

                RekvirentData r = new RekvirentData();
                foreach (SPField ofield in oListItem.Fields)
                {
                    string tekst;
                    try
                    {
                        tekst = ">" + ofield.Title + "< >" + ofield.InternalName + "<>" + oListItem[ofield.Id] + "<";
                    }
                    catch
                    {
                        //OK
                    }

                    switch (ofield.InternalName)
                    {
                    case "ID":
                        r.ID = (int)oListItem[ofield.Id];
                        break;

                    case "Title":
                        r.Title = (string)oListItem[ofield.Id];
                        break;
                    }
                }
                dt.Add(r);
            }

            return(dt);
        }
Exemplo n.º 37
0
 public System.Data.DataView Insert(System.Web.UI.DataSourceSelectArguments dataSourceSelectArguments)
 {
     throw new NotImplementedException();
 }
 protected internal abstract System.Collections.IEnumerable ExecuteSelect(DataSourceSelectArguments arguments);
 public virtual new void Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
 {
 }