protected override int InsertObject(object newEntity)
        {
            LinqDataSourceInsertEventArgs insertEventArgs = new LinqDataSourceInsertEventArgs(newEntity);

            OnInserting(insertEventArgs);
            if (insertEventArgs.Cancel)
            {
                return(-1);
            }

            LinqDataSourceStatusEventArgs insertedEventArgs = null;

            try {
                InsertDataObject(Context, EntitySet, insertEventArgs.NewObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                insertedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnInserted(insertedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Insert));
                if (insertedEventArgs.ExceptionHandled)
                {
                    return(-1);
                }
                throw;
            }
            insertedEventArgs = new LinqDataSourceStatusEventArgs(insertEventArgs.NewObject);
            OnInserted(insertedEventArgs);

            return(1);
        }
Esempio n. 2
0
 protected void sourceHistoricData_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     if (e.Exception != null) {
         showException(e.Exception, labelException, "adding assets class prices");
         e.ExceptionHandled = true;
     }
 }
 protected virtual void OnInserted(LinqDataSourceStatusEventArgs e)
 {
     if (Inserted != null)
     {
         Inserted(this, e);
     }
 }
 protected virtual void OnContextCreated(LinqDataSourceStatusEventArgs e)
 {
     if (ContextCreated != null)
     {
         ContextCreated(this, e);
     }
 }
 protected virtual void OnUpdated(LinqDataSourceStatusEventArgs e)
 {
     if (Updated != null)
     {
         Updated(this, e);
     }
 }
 protected virtual void OnSelected(LinqDataSourceStatusEventArgs e)
 {
     if (Selected != null)
     {
         Selected(this, e);
     }
 }
        protected override int UpdateObject(object oldEntity, object newEntity)
        {
            LinqDataSourceUpdateEventArgs updateEventArgs = new LinqDataSourceUpdateEventArgs(oldEntity, newEntity);

            OnUpdating(updateEventArgs);
            if (updateEventArgs.Cancel)
            {
                return(-1);
            }

            LinqDataSourceStatusEventArgs updatedEventArgs = null;

            try {
                UpdateDataObject(Context, EntitySet, updateEventArgs.OriginalObject, updateEventArgs.NewObject);
            }
            catch (Exception e) {
                ResetDataObject(EntitySet, updateEventArgs.OriginalObject);
                // allow user to handle dlinq exceptions including OnValidate validation.
                updatedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnUpdated(updatedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Update));
                if (updatedEventArgs.ExceptionHandled)
                {
                    return(-1);
                }
                throw;
            }
            updatedEventArgs = new LinqDataSourceStatusEventArgs(updateEventArgs.NewObject);
            OnUpdated(updatedEventArgs);

            return(1);
        }
        protected override int DeleteObject(object oldEntity)
        {
            LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(oldEntity);

            OnDeleting(deleteEventArgs);
            if (deleteEventArgs.Cancel)
            {
                return(-1);
            }

            LinqDataSourceStatusEventArgs deletedEventArgs = null;

            try {
                DeleteDataObject(Context, EntitySet, deleteEventArgs.OriginalObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                deletedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnDeleted(deletedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Delete));
                if (deletedEventArgs.ExceptionHandled)
                {
                    return(-1);
                }
                throw;
            }
            deletedEventArgs = new LinqDataSourceStatusEventArgs(deleteEventArgs.OriginalObject);
            OnDeleted(deletedEventArgs);

            return(1);
        }
        protected void lds2_Updated(object sender, LinqDataSourceStatusEventArgs e)
        {
            this.gv.SelectedIndex = -1;
            this.gv.EditIndex = -1;

            this.gv.DataBind();
        }
 protected void LinqDataSource1_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     List<Donation> l = (List<Donation>)e.Result;
     if (l != null && l.Count != 0)
         LabelTotal.Text = "Tổng cộng: " + l.Count.ToString();
     else
         LabelTotal.Text = "";
 }
        protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            ClearOriginalValues();

            QueryContext queryContext = CreateQueryContext(arguments);
            object       table        = GetSource(queryContext);
            IList        result       = null;

            if (_selectResult != null)
            {
                try {
                    IQueryable query = QueryableDataSourceHelper.AsQueryable(_selectResult);
                    query = ExecuteQuery(query, queryContext);

                    Type dataObjectType = GetDataObjectType(query.GetType());
                    result = query.ToList(dataObjectType);

                    if (_storeOriginalValues)
                    {
                        ITable dlinqTable = table as ITable;
                        // We can store original values if the type is exact or derived
                        if ((dlinqTable != null) && dataObjectType.IsAssignableFrom(EntityType))
                        {
                            StoreOriginalValues(result);
                        }
                    }
                }
                catch (Exception e) {
                    result = null;
                    LinqDataSourceStatusEventArgs selectedEventArgs = new LinqDataSourceStatusEventArgs(e);
                    OnSelected(selectedEventArgs);
                    OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Select));
                    if (!selectedEventArgs.ExceptionHandled)
                    {
                        throw;
                    }
                }
                finally {
                    if (result != null)
                    {
                        int totalRowCount = -1; // paging performed, but row count not available.
                        if (arguments.RetrieveTotalRowCount)
                        {
                            totalRowCount = arguments.TotalRowCount;
                        }
                        else if (!AutoPage)
                        {
                            totalRowCount = result.Count;
                        }
                        LinqDataSourceStatusEventArgs selectedEventArgs = new LinqDataSourceStatusEventArgs(result, totalRowCount);
                        OnSelected(selectedEventArgs);
                    }
                }
                // Null out the select context
                Context = null;
            }
            return(result);
        }
        protected virtual void OnContextCreated(LinqDataSourceStatusEventArgs e)
        {
            EventHandler <LinqDataSourceStatusEventArgs> handler = (EventHandler <LinqDataSourceStatusEventArgs>)Events[EventContextCreated];

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 13
0
 void linqds_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     if (e.Exception != null) return;
     SetDataSource(e.Result as IEnumerable);
     RecordCount = e.TotalRowCount;
 }
        private void OnSelected(object sender, LinqDataSourceStatusEventArgs e)
        {
            if (!EnableCache)
                return;

            if (e.Exception != null || e.Result == null)
                return;

            string key = GetKey();
            object source = CacheManager.Get<object>(key);
            if (source != null)
                return;
            else
                source = e.Result;

            Debug.WriteLine("Cache Insert: " + key);
            if (!String.IsNullOrEmpty(CacheProfile))
                CacheManager.Set(key, source, CacheManager.GetProfile(CacheProfile));
            else if (Duration > 0)
                CacheManager.Set(key, source, CacheSettings.FromDuration(Duration));
            else
                CacheManager.Set(key, source);
        }
Esempio n. 15
0
        protected void Settings_Updated(object sender, LinqDataSourceStatusEventArgs e)
        {
            TransmitSettings.Instance.Reload();

            (this.Master as SiteMasterPage).Flash("Settings saved");
        }
Esempio n. 16
0
 protected void LinqDataSourceTerritories_Updated(object sender, LinqDataSourceStatusEventArgs e)
 {
 }
 protected void LinqDataSourceAssignments_Updated(object sender, LinqDataSourceStatusEventArgs e)
 {
     TerritorySite.BL.Linq.Territory.UpdateOnlineOnly(CurrentTerritory.TerritoryId);
 }
Esempio n. 18
0
		protected virtual void OnInserted (LinqDataSourceStatusEventArgs e)
		{
			if (Inserted != null)
				Inserted (this, e);
		}
Esempio n. 19
0
		protected virtual void OnUpdated (LinqDataSourceStatusEventArgs e)
		{
			if (Updated != null)
				Updated (this, e);
		}
 protected virtual void OnUpdated(LinqDataSourceStatusEventArgs e) {
     EventHandler<LinqDataSourceStatusEventArgs> handler =
         (EventHandler<LinqDataSourceStatusEventArgs>)Events[EventUpdated];
     if (handler != null) {
         handler(this, e);
     }
 }
 protected void LinqDataSource_Rooms_Updated(object sender, LinqDataSourceStatusEventArgs e)
 {
     if (e.Exception != null)
     {
         Label_StatusMsg.Text = "Could not edit room: ";
         e.ExceptionHandled = true;
     }
 }
        protected override int UpdateObject(object oldEntity, object newEntity) {
            LinqDataSourceUpdateEventArgs updateEventArgs = new LinqDataSourceUpdateEventArgs(oldEntity, newEntity);
            OnUpdating(updateEventArgs);
            if (updateEventArgs.Cancel) {
                return -1;
            }

            LinqDataSourceStatusEventArgs updatedEventArgs = null;
            try {
                UpdateDataObject(Context, EntitySet, updateEventArgs.OriginalObject, updateEventArgs.NewObject);
            }
            catch (Exception e) {
                ResetDataObject(EntitySet, updateEventArgs.OriginalObject);
                // allow user to handle dlinq exceptions including OnValidate validation.
                updatedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnUpdated(updatedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Update));
                if (updatedEventArgs.ExceptionHandled) {
                    return -1;
                }
                throw;
            }
            updatedEventArgs = new LinqDataSourceStatusEventArgs(updateEventArgs.NewObject);
            OnUpdated(updatedEventArgs);

            return 1;
        }
Esempio n. 23
0
 protected void LinqDataSource1_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     //LabelTotal.Text = "TC: " + (e.Result as List<Pack>).Count.ToString();
 }
		protected void UsersUpdated(object sender, LinqDataSourceStatusEventArgs e)
		{
			new SvnConfigMaker().Generate();
		}
 protected void LinqDataSourceAddress_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     TerritorySite.BL.Linq.Address insertedAddress = (TerritorySite.BL.Linq.Address)e.Result;
     insertedAddress.Geocode();
 }
 protected void LinqDataSource1_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     OverviewActivities.DataBind();
 }
Esempio n. 27
0
 protected void LinqDataSource1_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     //if (e.Result != null && e.Result is List<Donation>)
     //    LableCount.Text = "" + ((List<Donation>)e.Result).Count.ToString();
 }
Esempio n. 28
0
 protected void sourceModel_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
     if (e.Exception != null) {
         showException(e.Exception, labelException, "adding the model entry");
         labelException.Text += e.Exception.Message;
         e.ExceptionHandled = true;
     }
 }
Esempio n. 29
0
		protected virtual void OnContextCreated (LinqDataSourceStatusEventArgs e)
		{
			if (ContextCreated != null)
				ContextCreated (this, e);
		}
        protected override int InsertObject(object newEntity) {
            LinqDataSourceInsertEventArgs insertEventArgs = new LinqDataSourceInsertEventArgs(newEntity);
            OnInserting(insertEventArgs);
            if (insertEventArgs.Cancel) {
                return -1;
            }

            LinqDataSourceStatusEventArgs insertedEventArgs = null;
            try {
                InsertDataObject(Context, EntitySet, insertEventArgs.NewObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                insertedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnInserted(insertedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Insert));
                if (insertedEventArgs.ExceptionHandled) {
                    return -1;
                }
                throw;
            }
            insertedEventArgs = new LinqDataSourceStatusEventArgs(insertEventArgs.NewObject);
            OnInserted(insertedEventArgs);

            return 1;
        }
Esempio n. 31
0
		protected virtual void OnSelected (LinqDataSourceStatusEventArgs e)
		{
			if (Selected != null)
				Selected (this, e);
		}
        protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) {
            ClearOriginalValues();

            QueryContext queryContext = CreateQueryContext(arguments);
            object table = GetSource(queryContext);
            IList result = null;

            if (_selectResult != null) {
                try {
                    IQueryable query = QueryableDataSourceHelper.AsQueryable(_selectResult);
                    query = ExecuteQuery(query, queryContext);

                    Type dataObjectType = GetDataObjectType(query.GetType());
                    result = query.ToList(dataObjectType);

                    if (_storeOriginalValues) {
                        ITable dlinqTable = table as ITable;
                        // We can store original values if the type is exact or derived
                        if ((dlinqTable != null) && dataObjectType.IsAssignableFrom(EntityType)) {
                            StoreOriginalValues(result);
                        }
                    }
                }
                catch (Exception e) {
                    result = null;
                    LinqDataSourceStatusEventArgs selectedEventArgs = new LinqDataSourceStatusEventArgs(e);
                    OnSelected(selectedEventArgs);
                    OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Select));
                    if (!selectedEventArgs.ExceptionHandled) {
                        throw;
                    }
                }
                finally {
                    if (result != null) {
                        int totalRowCount = -1; // paging performed, but row count not available.
                        if (arguments.RetrieveTotalRowCount) {
                            totalRowCount = arguments.TotalRowCount;
                        }
                        else if (!AutoPage) {
                            totalRowCount = result.Count;
                        }
                        LinqDataSourceStatusEventArgs selectedEventArgs = new LinqDataSourceStatusEventArgs(result, totalRowCount);
                        OnSelected(selectedEventArgs);
                    }
                }
                // Null out the select context
                Context = null;
            }
            return result;
        }        
 protected void DS_AllProducts_Deleted(object sender, LinqDataSourceStatusEventArgs e)
 {
     GV.DataBind();
 }
        protected override int DeleteObject(object oldEntity) {
            LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(oldEntity);
            OnDeleting(deleteEventArgs);
            if (deleteEventArgs.Cancel) {
                return -1;
            }

            LinqDataSourceStatusEventArgs deletedEventArgs = null;
            try {
                DeleteDataObject(Context, EntitySet, deleteEventArgs.OriginalObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                deletedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnDeleted(deletedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Delete));
                if (deletedEventArgs.ExceptionHandled) {
                    return -1;
                }
                throw;
            }
            deletedEventArgs = new LinqDataSourceStatusEventArgs(deleteEventArgs.OriginalObject);
            OnDeleted(deletedEventArgs);

            return 1;
        }
        private ContextDataSourceContextData CreateContextAndTable(DataSourceOperation operation)
        {
            ContextDataSourceContextData contextData = null;
            bool eventFired = false;

            try {
                LinqDataSourceContextEventArgs contextEventArgs = new LinqDataSourceContextEventArgs(operation);
                OnContextCreating(contextEventArgs);

                contextData = new ContextDataSourceContextData(contextEventArgs.ObjectInstance);
                Type       contextType     = null;
                MemberInfo tableMemberInfo = null;
                if (contextData.Context == null)
                {
                    // construct the context unless accessing a static table for Select.
                    contextType     = ContextType;
                    tableMemberInfo = GetTableMemberInfo(contextType);
                    if (tableMemberInfo != null)
                    {
                        if (MemberIsStatic(tableMemberInfo))
                        {
                            if (operation != DataSourceOperation.Select)
                            {
                                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
                                                                                  AtlasWeb.LinqDataSourceView_TableCannotBeStatic, TableName, contextType.Name, _owner.ID));
                            }
                        }
                        else
                        {
                            contextData.Context = CreateContext(contextType);
                            _isNewContext       = true;
                        }
                    }
                }
                else
                {
                    // use the manually constructed context.
                    tableMemberInfo = GetTableMemberInfo(contextData.Context.GetType());
                }

                // fetch the table from the context.
                if (tableMemberInfo != null)
                {
                    FieldInfo field = tableMemberInfo as FieldInfo;
                    if (field != null)
                    {
                        contextData.EntitySet = field.GetValue(contextData.Context);
                    }
                    PropertyInfo property = tableMemberInfo as PropertyInfo;
                    if (property != null)
                    {
                        contextData.EntitySet = property.GetValue(contextData.Context, null);
                    }
                }
                if (contextData.EntitySet == null)
                {
                    throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
                                                                      AtlasWeb.LinqDataSourceView_TableNameNotFound, TableName, contextType.Name, _owner.ID));
                }
            }
            catch (Exception e) {
                eventFired = true;
                LinqDataSourceStatusEventArgs createdEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnContextCreated(createdEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.ContextCreate));
                // CreateContextAndTable will return null if this exception is handled.
                if (!createdEventArgs.ExceptionHandled)
                {
                    throw;
                }
            }
            finally {
                if (!eventFired)
                {
                    // contextData can be null if exception thrown from ContextCreating handler.
                    object context = (contextData == null) ? null : contextData.Context;
                    LinqDataSourceStatusEventArgs createdEventArgs = new LinqDataSourceStatusEventArgs(context);
                    OnContextCreated(createdEventArgs);
                }
            }
            return(contextData);
        }
        private ContextDataSourceContextData CreateContextAndTable(DataSourceOperation operation) {
            ContextDataSourceContextData contextData = null;            
            bool eventFired = false;
            try {
                LinqDataSourceContextEventArgs contextEventArgs = new LinqDataSourceContextEventArgs(operation);
                OnContextCreating(contextEventArgs);

                contextData = new ContextDataSourceContextData(contextEventArgs.ObjectInstance);
                Type contextType = null;
                MemberInfo tableMemberInfo = null;
                if (contextData.Context == null) {
                    // construct the context unless accessing a static table for Select.
                    contextType = ContextType;
                    tableMemberInfo = GetTableMemberInfo(contextType);
                    if (tableMemberInfo != null) {
                        if (MemberIsStatic(tableMemberInfo)) {
                            if (operation != DataSourceOperation.Select) {
                                throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
                                    AtlasWeb.LinqDataSourceView_TableCannotBeStatic, TableName, contextType.Name, _owner.ID));
                            }
                        }
                        else {
                            contextData.Context = CreateContext(contextType);
                            _isNewContext = true;                            
                        }
                    }
                }
                else {
                    // use the manually constructed context.
                    tableMemberInfo = GetTableMemberInfo(contextData.Context.GetType());
                }

                // fetch the table from the context.
                if (tableMemberInfo != null) {
                    FieldInfo field = tableMemberInfo as FieldInfo;
                    if (field != null) {
                        contextData.EntitySet = field.GetValue(contextData.Context);
                    }
                    PropertyInfo property = tableMemberInfo as PropertyInfo;
                    if (property != null) {
                        contextData.EntitySet = property.GetValue(contextData.Context, null);
                    }
                }
                if (contextData.EntitySet == null) {
                    throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture,
                        AtlasWeb.LinqDataSourceView_TableNameNotFound, TableName, contextType.Name, _owner.ID));
                }
            }
            catch (Exception e) {
                eventFired = true;
                LinqDataSourceStatusEventArgs createdEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnContextCreated(createdEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.ContextCreate));
                // CreateContextAndTable will return null if this exception is handled.
                if (!createdEventArgs.ExceptionHandled) {
                    throw;
                }
            }
            finally {
                if (!eventFired) {
                    // contextData can be null if exception thrown from ContextCreating handler.
                    object context = (contextData == null) ? null : contextData.Context;
                    LinqDataSourceStatusEventArgs createdEventArgs = new LinqDataSourceStatusEventArgs(context);
                    OnContextCreated(createdEventArgs);
                }
            }
            return contextData;
        }
Esempio n. 37
0
 protected void LinqDataSource1_Inserted(object sender, LinqDataSourceStatusEventArgs e)
 {
 }
Esempio n. 38
0
 protected void linqVendor_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     GetSummary();
 }
        protected override void OnContextCreated(LinqDataSourceStatusEventArgs e)
        {
            base.OnContextCreated(e);

            _dataServiceContext = (DataServiceContext)e.Result;
        }
Esempio n. 40
0
 protected void businessPartnerDocumentsDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e)
 {
     string test = " tes";
 }