public static bool MergeDictionaries(object dataObjectType, ParameterCollection reference, IDictionary source,
                                       IDictionary destination, IDictionary destinationCopy, IDictionary<string, Exception> validationErrors) {            
     if (source != null) {
         foreach (DictionaryEntry de in source) {
             object value = de.Value;
             // search for a parameter that corresponds to this dictionary entry.
             Parameter referenceParameter = null;
             string parameterName = (string)de.Key;
             foreach (Parameter p in reference) {
                 if (String.Equals(p.Name, parameterName, StringComparison.OrdinalIgnoreCase)) {
                     referenceParameter = p;
                     break;
                 }
             }
             // use the parameter for type conversion, default value and/or converting empty string to null.
             if (referenceParameter != null) {
                 try {
                     value = referenceParameter.GetValue(value, true);
                 }
                 catch (Exception e) {
                     // catch conversion exceptions so they can be handled. Note that conversion throws various
                     // types of exceptions like InvalidCastException, FormatException, OverflowException, etc.
                     validationErrors[referenceParameter.Name] = e;
                 }
             }
             // save the value to the merged dictionaries.
             destination[parameterName] = value;
             if (destinationCopy != null) {
                 destinationCopy[parameterName] = value;
             }
         }
     }
     return validationErrors.Count == 0;
 }
 public SqlDataSourceRefreshSchemaForm(IServiceProvider serviceProvider, SqlDataSourceDesigner sqlDataSourceDesigner, ParameterCollection parameters) : base(serviceProvider)
 {
     this._sqlDataSourceDesigner = sqlDataSourceDesigner;
     this._sqlDataSource = (SqlDataSource) this._sqlDataSourceDesigner.Component;
     this._connectionString = this._sqlDataSourceDesigner.ConnectionString;
     this._providerName = this._sqlDataSourceDesigner.ProviderName;
     this._selectCommand = this._sqlDataSourceDesigner.SelectCommand;
     this._selectCommandType = this._sqlDataSource.SelectCommandType;
     this.InitializeComponent();
     this.InitializeUI();
     Array values = Enum.GetValues(typeof(TypeCode));
     Array.Sort(values, new TypeCodeComparer());
     foreach (TypeCode code in values)
     {
         ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[1]).Items.Add(code);
     }
     Array array = Enum.GetValues(typeof(DbType));
     Array.Sort(array, new DbTypeComparer());
     foreach (DbType type in array)
     {
         ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[2]).Items.Add(type);
     }
     ArrayList list = new ArrayList(parameters.Count);
     foreach (Parameter parameter in parameters)
     {
         list.Add(new ParameterItem(parameter));
     }
     this._parametersDataGridView.DataSource = list;
     this._commandTextBox.Text = this._selectCommand;
     this._commandTextBox.Select(0, 0);
 }
Ejemplo n.º 3
0
		public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
		{
			if (String.Compare (tableName, "BazValidationAttributesTable", StringComparison.OrdinalIgnoreCase) == 0)
				return BazValidationAttributes;

			return null;
		}
Ejemplo n.º 4
0
		internal void SetCachedObject (string methodName, ParameterCollection parameters, object o)
		{
			if (o == null)
				return;

			string key = GetKeyFromParameters (methodName, parameters);

			if (DataCache [key] != null)
				DataCache.Remove (key);

			DateTime absoluteExpiration = Cache.NoAbsoluteExpiration;
			TimeSpan slidindExpiraion = Cache.NoSlidingExpiration;

			if (cacheDuration > 0) {
				if (cacheExpirationPolicy == DataSourceCacheExpiry.Absolute)
					absoluteExpiration = DateTime.Now.AddSeconds (cacheDuration);
				else
					slidindExpiraion = new TimeSpan (0, 0, cacheDuration);
			}

			string [] dependencies;
			if (cacheKeyDependency.Length > 0)
				dependencies = new string [] { cacheKeyDependency };
			else
				dependencies = new string [] { };

			DataCache.Add (key, o, new CacheDependency (new string [] { }, dependencies),
				       absoluteExpiration, slidindExpiraion, CacheItemPriority.Default, null);
		}
Ejemplo n.º 5
0
        /// <summary>
        /// This function takes in the query that needs to be executed and returns a data reader as output
        /// </summary>
        /// <param name="Conn">The SQL Connection to be used</param>
        /// <param name="CommType">The Command type whether it is stored procedure or a simple query</param>
        /// <param name="CommString">If Stored procedure, then the name of the stored procedure, if simple query, then the query in
        /// string format</param>
        /// <param name="Parameters">List of parameters, if any required for Stored procedure</param>
        /// <returns>SQL Data reader that is the output of the select query executed</returns>
        public static SqlDataReader ExecuteDataReader(SqlConnection Conn, CommandType CommType, string CommString, ParameterCollection Parameters)
        {
            SqlDataReader return_sdr = null;
            try
            {
                SqlCommand comm = new SqlCommand(CommString, Conn);
                comm.CommandType = CommType;
                if (Parameters != null && Parameters.Count > 0)
                {
                    foreach (Parameter param in Parameters)
                    {
                        if (param.DefaultValue == "")
                            comm.Parameters.AddWithValue(param.Name, DBNull.Value);
                        else
                            comm.Parameters.AddWithValue(param.Name, param.DefaultValue);
                    }
                }
                if (Conn.State != ConnectionState.Open)
                {
                    Conn.Open();
                }
                return_sdr = comm.ExecuteReader();

            }
            catch (SqlException sqx)
            {
                throw new Exception("SQLException : " + sqx.ErrorCode + Environment.NewLine + "Line Number : " + sqx.LineNumber + " Message : " + sqx.Message + Environment.NewLine + "Stack Trace :" + Environment.NewLine + sqx.StackTrace);
            }
            catch (Exception exp)
            {
                throw new Exception("Exception : " + exp.InnerException + Environment.NewLine + " Message : " + exp.Message + Environment.NewLine + "Stack Trace :" + Environment.NewLine + exp.StackTrace);
            }
            return return_sdr;
        }
 internal WebControlParameterProxy(Parameter parameter, ParameterCollection parameterCollection, EntityDataSource entityDataSource)
 {
     Debug.Assert(null != entityDataSource);
     _parameter = parameter;
     _collection = parameterCollection;
     _entityDataSource = entityDataSource;
     VerifyUniqueType(_parameter);
 }
Ejemplo n.º 7
0
        public static DataSet getfieldAreaTopValue(int id)
        {
            string sql = "GetFieldAreaTopValue";
            ParameterCollection par = new ParameterCollection();
            par.Add("@Id", id.ToString());

            return SQLDatabaseManager.ExecuteDataSet1(sql, par);

        }
        Parameter _parameter; // Can be null, that's why this class doesn't subclass Parameter

        internal WebControlParameterProxy(string propertyName, ParameterCollection parameterCollection, EntityDataSource entityDataSource)
        {
            Debug.Assert(null != entityDataSource);
            Debug.Assert(!String.IsNullOrEmpty(propertyName));

            _parameter = EntityDataSourceUtil.GetParameter(propertyName, parameterCollection);
            _collection = parameterCollection;
            _entityDataSource = entityDataSource;
            VerifyUniqueType(_parameter);
        }
Ejemplo n.º 9
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;
		}
Ejemplo n.º 10
0
 private void BuildCommand(IConfigurationElement parametersSection, ParameterCollection parameters)
 {
     parameters.Clear();
     foreach (IConfigurationElement parameterElement in parametersSection.Elements.Values)
     {
         Parameter commandParameter = new Parameter();
         foreach (IConfigurationElement propertyElement in parameterElement.Elements.Values)
         {
             ReflectionServices.SetValue(commandParameter, propertyElement.GetAttributeReference("name").Value.ToString(), propertyElement.GetAttributeReference("value").Value);
         }
         parameters.Add(commandParameter);
     }
 }
Ejemplo n.º 11
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;
		}
 public SqlDataSourceParameterValueEditorForm(IServiceProvider serviceProvider, ParameterCollection parameters) : base(serviceProvider)
 {
     this._parameterItems = new ArrayList();
     foreach (Parameter parameter in parameters)
     {
         this._parameterItems.Add(new ParameterItem(parameter));
     }
     this.InitializeComponent();
     this.InitializeUI();
     string[] names = Enum.GetNames(typeof(TypeCode));
     Array.Sort<string>(names);
     ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[1]).Items.AddRange(names);
     string[] array = Enum.GetNames(typeof(DbType));
     Array.Sort<string>(array);
     ((DataGridViewComboBoxColumn) this._parametersDataGridView.Columns[2]).Items.AddRange(array);
     this._parametersDataGridView.DataSource = this._parameterItems;
 }
        public EntityDataSourceStatementEditorForm(System.Web.UI.Control entityDataSource, IServiceProvider serviceProvider,
            bool hasAutoGen, bool isAutoGen, string propertyName, string statementLabelText, string statementAccessibleName,
            string helpTopic, string statement, ParameterCollection parameters)
            : base(serviceProvider)
        {

            _entityDataSource = entityDataSource;
            InitializeComponent();
            InitializeUI(propertyName, statementLabelText, statementAccessibleName);
            InitializeTabIndexes();
            InitializeAnchors();

            _helpTopic = helpTopic;

            if (!hasAutoGen)
            {
                HideCheckBox();
            }

            _parameters = parameters;

            _autoGenerateCheckBox.Checked = isAutoGen;
            _statementPanel.Enabled = !isAutoGen;

            _statementTextBox.Text = statement;
            _statementTextBox.Select(0, 0);

            List<Parameter> paramList = new List<Parameter>();
            foreach (Parameter p in parameters)
            {
                paramList.Add(p);
            }
            _parameterEditorUserControl.AddParameters(paramList.ToArray());

            _cachedStatementText = null;
        }
Ejemplo n.º 14
0
		public IList GetTableData (string tableName, DataSourceSelectArguments args, string where, ParameterCollection whereParams)
		{
			return null;
		}
        // Updates the parameters collection associated with the specified property name
        private static void SetParameters(string propertyName, EntityDataSourceDesigner designer, ParameterCollection parameters)
        {
            switch (propertyName)
            {
                case "CommandText":
                    designer.SetCommandParameterContents(parameters);
                    break;
                case "OrderBy":
                    designer.SetOrderByParameterContents(parameters);
                    break;
                case "Select":
                    designer.SetSelectParameterContents(parameters);
                    break;
                case "Where":
                    designer.SetWhereParameterContents(parameters);
                    break;
                default:
                    Debug.Fail("Unknown property name in EntityDataSourceStatementEditor: " + propertyName);
                    break;

            }
        }
Ejemplo n.º 16
0
		internal void SetOwnerCollection (ParameterCollection own)
		{
			_owner = own;
		}
Ejemplo n.º 17
0
 private void @__BuildControl__control2(System.Web.UI.WebControls.ParameterCollection @__ctrl)
 {
     global::System.Web.UI.WebControls.ControlParameter @__ctrl1;
     @__ctrl1 = this.@__BuildControl__control3();
     @__ctrl.Add(@__ctrl1);
 }
Ejemplo n.º 18
0
        public void RaiseAjaxPostBackEvent(string eventArgument, ParameterCollection extraParams)
        {
            bool success = true;
            string message = null;
            object value = null;

            try
            {
                if (eventArgument.IsEmpty())
                {
                    throw new ArgumentNullException("eventArgument");
                }

                string data = null;

                if (this.DirectConfig != null)
                {
                    JToken serviceToken = this.DirectConfig.SelectToken("config.serviceParams");

                    if (serviceToken != null)
                    {
                        data = JSON.ToString(serviceToken);
                    }
                }

                switch (eventArgument)
                {
                    case "remotevalidation":
                        RemoteValidationEventArgs e = new RemoteValidationEventArgs(data, extraParams);
                        this.RemoteValidation.OnValidation(e);                        
                        success = e.Success;
                        message = e.ErrorMessage;
                        if (e.ValueIsChanged)
                        {
                            value = e.Value;
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                success = false;
                message = this.IsDebugging ? ex.ToString() : ex.Message;

                if (this.ResourceManager.RethrowAjaxExceptions)
                {
                    throw;
                }
            }

            ResourceManager.ServiceResponse = new { valid=success, message, value };
        }
Ejemplo n.º 19
0
        /// <summary>
        /// myself:不用异常处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchButton1_Click(object sender, EventArgs e)
        {
            //try
            //{
            if (SearchByXH.Text != "")
            {
                querry += "and [XH]= @XH";
            }
            if (SearchByNickName.Text != "")
            {
                querry += "and [User_NickName]=@UNN";
            }
            if (SearchByName.Text != "")
            {
                querry += "and [XM]=@XM";
            }
            if (SearchByQQ.Text != "")
            {
                querry += "and [User_QQ]=@UQ";
            }
            if (DropXY.SelectedValue != null)
            {
                querry += "and [YXSMC]=@XY";
            }
            if (DropZY.SelectedValue != null)
            {
                querry += "and [ZYMC]=@ZY";
            }
            //}
            //catch
            //{
            //    Context.Response.Write("<script>alert('出错了!')</script>");
            //}
            ParameterCollection co = new ParameterCollection();
            co.Add("@XH", SearchByXH.Text);
            co.Add("@UNN", SearchByNickName.Text);
            co.Add("@XM", SearchByName.Text);
            co.Add("@UQ", SearchByQQ.Text);
            co.Add("@XY", DropXY.SelectedValue);
            co.Add("@ZY", DropZY.SelectedValue);

            Source1.SelectCommand = querry;
            Repeater1.DataSource = Source1;
            Repeater1.DataBind();
        }
 internal void SetOwner(ParameterCollection owner)
 {
     this._owner = owner;
 }
		void InitializeParameters (DbCommand command, ParameterCollection parameters, IDictionary values, IDictionary oldValues, bool parametersMayMatchOldValues)
		{
			IOrderedDictionary parameterValues = parameters.GetValues (context, owner);

			foreach (string parameterName in parameterValues.Keys) {
				Parameter p = parameters [parameterName];
				object value = FindValueByName (parameterName, values, false);
				string valueName = parameterName;
				if (value == null)
					value = FindValueByName (parameterName, oldValues, true);

				if (value == null && parametersMayMatchOldValues) {
					value = FindValueByName (parameterName, oldValues, false);
					valueName = FormatOldParameter (parameterName);
				}

				if (value != null) {
					object dbValue = p.ConvertValue (value);
					DbParameter newParameter = CreateDbParameter (valueName, dbValue, p.Direction, p.Size);
					if (!command.Parameters.Contains (newParameter.ParameterName)) {
						command.Parameters.Add (newParameter);
					}
				}
				else {
					command.Parameters.Add (CreateDbParameter (p.Name, parameterValues [parameterName], p.Direction, p.Size));
				}
			}

			if (values != null) {
				foreach (DictionaryEntry de in values)
					if (!command.Parameters.Contains (ParameterPrefix + (string) de.Key))
						command.Parameters.Add (CreateDbParameter ((string) de.Key, de.Value));
			}

			if (oldValues != null) {
				foreach (DictionaryEntry de in oldValues)
					if (!command.Parameters.Contains (ParameterPrefix + FormatOldParameter ((string) de.Key)))
						command.Parameters.Add (CreateDbParameter (FormatOldParameter ((string) de.Key), de.Value));
			}
		}
        /// <devdoc>
        /// Adds parameters to an DbCommand from an IOrderedDictionary.
        /// The exclusion list contains parameter names that should not be added
        /// to the command's parameter collection.
        /// </devdoc>
        private void AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, string oldValuesParameterFormatString) {
            Debug.Assert(command != null);

            IDictionary caseInsensitiveExclusionList = null;
            if (exclusionList != null) {
                caseInsensitiveExclusionList = new ListDictionary(StringComparer.OrdinalIgnoreCase);
                foreach (DictionaryEntry de in exclusionList) {
                    caseInsensitiveExclusionList.Add(de.Key, de.Value);
                }
            }

            if (parameters != null) {
                string parameterPrefix = ParameterPrefix;
                foreach (DictionaryEntry de in parameters) {
                    string rawParamName = (string)de.Key;

                    if ((caseInsensitiveExclusionList != null) && (caseInsensitiveExclusionList.Contains(rawParamName))) {
                        // If we have an exclusion list and it contains this parameter, skip it
                        continue;
                    }

                    string formattedParamName;
                    if (oldValuesParameterFormatString == null) {
                        formattedParamName = rawParamName;
                    }
                    else {
                        formattedParamName = String.Format(CultureInfo.InvariantCulture, oldValuesParameterFormatString, rawParamName);
                    }
                    object value = de.Value;

                    // If the reference collection contains this parameter, we will use
                    // the Parameter's settings to format the value
                    Parameter parameter = reference[formattedParamName];
                    if (parameter != null) {
                        value = parameter.GetValue(de.Value, false);
                    }

                    formattedParamName = parameterPrefix + formattedParamName;

                    if (command.Parameters.Contains(formattedParamName)) {
                        // We never overwrite an existing value with a null value
                        if (value != null) {
                            command.Parameters[formattedParamName].Value = value;
                        }
                    }
                    else {
                        // Parameter does not exist, add a new one
                        DbParameter dbParameter = _owner.CreateParameter(formattedParamName, value);
                        command.Parameters.Add(dbParameter);
                    }
                }
            }
        }
        /// <devdoc>
        /// Initializes a DbCommand with parameters from a ParameterCollection.
        /// The exclusion list contains parameter names that should not be added
        /// to the command's parameter collection.
        /// </devdoc>
        private void InitializeParameters(DbCommand command, ParameterCollection parameters, IDictionary exclusionList) {
            Debug.Assert(command != null);
            Debug.Assert(parameters != null);

            string parameterPrefix = ParameterPrefix;

            IDictionary caseInsensitiveExclusionList = null;
            if (exclusionList != null) {
                caseInsensitiveExclusionList = new ListDictionary(StringComparer.OrdinalIgnoreCase);
                foreach (DictionaryEntry de in exclusionList) {
                    caseInsensitiveExclusionList.Add(de.Key, de.Value);
                }
            }

            IOrderedDictionary values = parameters.GetValues(_context, _owner);
            for (int i = 0; i < parameters.Count; i++) {
                Parameter parameter = parameters[i];
                if ((caseInsensitiveExclusionList == null) || (!caseInsensitiveExclusionList.Contains(parameter.Name))) {
                    DbParameter dbParameter = _owner.CreateParameter(parameterPrefix + parameter.Name, values[i]);
                    dbParameter.Direction = parameter.Direction;
                    dbParameter.Size = parameter.Size;
                    if (parameter.DbType != DbType.Object || (parameter.Type != TypeCode.Empty && parameter.Type != TypeCode.DBNull)) {
                        SqlParameter sqlParameter = dbParameter as SqlParameter;
                        if (sqlParameter == null) {
                            dbParameter.DbType = parameter.GetDatabaseType();
                        }
                        else {
                            // In Whidbey, the DbType Date and Time members mapped to SqlDbType.DateTime since there
                            // were no SqlDbType equivalents. SqlDbType has since been modified to include the new
                            // Katmai types, including Date and Time. For backwards compatability SqlParameter's DbType
                            // setter doesn't support Date and Time, so the SqlDbType property should be used instead.
                            // Other new SqlServer 2008 types (DateTime2, DateTimeOffset) can be set using DbType.
                            DbType dbType = parameter.GetDatabaseType();
                            switch (dbType) {
                                case DbType.Time:
                                    sqlParameter.SqlDbType = SqlDbType.Time;
                                    break;
                                case DbType.Date:
                                    sqlParameter.SqlDbType = SqlDbType.Date;
                                    break;
                                default:
                                    dbParameter.DbType = parameter.GetDatabaseType();
                                    break;
                            }
                        }
                    }
                    command.Parameters.Add(dbParameter);
                }
            }
        }
Ejemplo n.º 24
0
 private static void ApplyParameterCollection(Row row, ParameterCollection parameters)
 {
     ApplyParameterCollection(row, parameters, null);
 }
Ejemplo n.º 25
0
        private static void ApplyParameterCollection(Row row, ParameterCollection parameters, string prefix)
        {
            if (string.IsNullOrEmpty(prefix))
                prefix = "{0}";
            foreach (RowCell cell in row.Cells)
            {
                string value = null;
                if (cell.Value != null)
                    value = cell.Value.ToString();

                if (parameters[cell.CellId] == null)
                    parameters.Add(cell.CellId, row.Columns[cell.CellId].DataType, value);
                else
                    parameters[cell.CellId].DefaultValue = value;

                if (parameters[String.Format("@" + prefix, cell.CellId)] == null)
                    parameters.Add(String.Format("@" + prefix, cell.CellId), row.Columns[cell.CellId].DataType, value);
                else
                    parameters[String.Format("@" + prefix, cell.CellId)].DefaultValue = value;
            }
        }
Ejemplo n.º 26
0
        void IAjaxPostBackEventHandler.RaiseAjaxPostBackEvent(string eventArgument, ParameterCollection extraParams)
        {
            string action = eventArgument;

            foreach (Task task in this.Tasks)
            {
                if (!task.DirectEvents.Update.IsDefault && task.DirectEvents.Update.HandlerName == action)
                {
                    task.DirectEvents.Update.OnEvent(new DirectEventArgs(extraParams));
                }
            }
        }
Ejemplo n.º 27
0
		ParameterCollection GetParameterCollection (ref ParameterCollection output, bool propagateTrackViewState, bool subscribeChanged)
		{
			if (output != null)
				return output;
			
			output = new ParameterCollection ();
			if (subscribeChanged)
				output.ParametersChanged += new EventHandler (ParametersChanged);
			
			if (IsTrackingViewState && propagateTrackViewState)
				((IStateManager) output).TrackViewState ();
			
			return output;
		}
 private void OnOkButtonClick(object sender, EventArgs e)
 {
     ICollection dataSource = (ICollection) this._parametersDataGridView.DataSource;
     ParameterCollection parameters = new ParameterCollection();
     foreach (ParameterItem item in dataSource)
     {
         if (item.DbType == DbType.Object)
         {
             parameters.Add(new Parameter(item.Name, item.Type, item.DefaultValue));
         }
         else
         {
             parameters.Add(new Parameter(item.Name, item.DbType, item.DefaultValue));
         }
     }
     if (this._sqlDataSourceDesigner.RefreshSchema(new DesignerDataConnection(string.Empty, this._providerName, this._connectionString), this._selectCommand, this._selectCommandType, parameters, false))
     {
         base.DialogResult = DialogResult.OK;
         base.Close();
     }
 }
Ejemplo n.º 29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="eventArgument"></param>
        /// <param name="extraParams"></param>
        public void RaiseAjaxPostBackEvent(string eventArgument, ParameterCollection extraParams)
        {
            bool success = true;
            string msg = null;

            StoreResponseData response = new StoreResponseData(true);

            try
            {
                if (eventArgument.IsEmpty())
                {
                    throw new ArgumentNullException("eventArgument");
                }

                //string data = null;
                //JToken parametersToken = null;

                //if (this.DirectConfig != null)
                //{
                //    JToken serviceToken = this.DirectConfig.SelectToken("config.serviceParams", false);

                //    if (serviceToken != null)
                //    {
                //        data = JSON.ToString(serviceToken);
                //    }
                //}

                switch (eventArgument)
                {
                    case "read":
                        if (this.IsBoundUsingDataSourceID)
                        {
                            Node bindNode = new Node();
                            this.DataBindNode(bindNode, extraParams["dataPath"]);
                            response.Data = bindNode.Children.ToJson();
                        }
                        else
                        {
                            NodeLoadEventArgs e = new NodeLoadEventArgs(extraParams);
                            this.OnReadData(e);
                            NodeCollection nodes = e.Nodes;
                            success = e.Success;
                            msg = e.ErrorMessage;
                            response.Data = nodes != null ? nodes.ToJson() : null;
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                success = false;
                msg = this.IsDebugging ? ex.ToString() : ex.Message;

                if (this.ResourceManager.RethrowAjaxExceptions)
                {
                    throw;
                }
            }

            

            //if (success)
            //{
            //    switch (eventArgument)
            //    {
            //        case "read":

            //            if (this.RequiresDataBinding)
            //            {
            //                this.DataBind();
            //            }

            //            response.Data = this.GetAjaxDataJson();
            //            PageProxy dsp = this.Proxy.Primary as PageProxy;
            //            response.Total = dsp != null ? dsp.Total : -1;
            //            break;
            //    }
            //}
            
            ResourceManager.ServiceResponse = new Response { Data = response.ToString(), Success = success, Message = msg };
        }
 public void InitializeParameters(ParameterCollection selectParameters)
 {
     Parameter[] parameterArray = new Parameter[selectParameters.Count];
     selectParameters.CopyTo(parameterArray, 0);
     this._parameterEditorUserControl.AddParameters(parameterArray);
 }
Ejemplo n.º 31
0
 internal void SetOwnerCollection(ParameterCollection own)
 {
     _owner = own;
 }
		/// <summary>
		/// Merge the current data item fields with view parameter default values
		/// </summary>
		/// <param name="viewParams">default parameters</param>
		/// <param name="values">new parameters for update and insert</param>
		/// <param name="oldValues">old parameters for update and delete</param>
		/// <param name="allwaysAddNewValues">true for insert, as current item is
		/// irrelevant for insert</param>
		/// <returns>merged values</returns>
		IOrderedDictionary MergeParameterValues (ParameterCollection viewParams, IDictionary values, IDictionary oldValues)
		{
			IOrderedDictionary parametersValues = viewParams.GetValues (context, owner);
			OrderedDictionary mergedValues = new OrderedDictionary (StringComparer.InvariantCultureIgnoreCase);
			foreach (string parameterName in parametersValues.Keys) {
				mergedValues [parameterName] = parametersValues [parameterName];
				if (oldValues != null) {
					object value = FindValueByName (parameterName, oldValues, true);
					if (value != null) {
						object dataValue = viewParams [parameterName].ConvertValue (value);
						mergedValues [parameterName] = dataValue;
					}
				}

				if (values != null) {
					object value = FindValueByName (parameterName, values, false);
					if (value != null) {
						object dataValue = viewParams [parameterName].ConvertValue (value);
						mergedValues [parameterName] = dataValue;
					}
				}
			}

			if (values != null) {
				foreach (DictionaryEntry de in values)
					if (FindValueByName ((string) de.Key, mergedValues, false) == null)
						mergedValues [de.Key] = de.Value;
			}

			if (oldValues != null) {
				foreach (DictionaryEntry de in oldValues) {
					string oldValueKey = FormatOldParameter ((string) de.Key);
					if (FindValueByName (oldValueKey, mergedValues, false) == null)
						mergedValues [oldValueKey] = de.Value;
				}
			}

			return mergedValues;
		}