diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..adc7784e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,12 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text eol=lf + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +*.bmp binary +*.png binary \ No newline at end of file diff --git a/.gitignore b/.gitignore index 130a5e8a..0bec0747 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ -/packages/ +**/packages/ **/bin/ -*/obj/ -*/*/obj/ -.vs -*/*/FakesAssemblies/ -**/*.vspscc +**/obj/ +**/.vs/ +*.coverage +*.xml +*.cache + +#Ignore thumbnails created by Windows +Thumbs.db + +#Ignore files built by Visual Studio +*.user \ No newline at end of file diff --git a/NewPlatform.Flexberry.ORM.ODataService.nuspec b/NewPlatform.Flexberry.ORM.ODataService.nuspec index 29e2cac2..f8568fff 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.nuspec +++ b/NewPlatform.Flexberry.ORM.ODataService.nuspec @@ -2,7 +2,7 @@ NewPlatform.Flexberry.ORM.ODataService - 5.1.0-beta01 + 5.1.0-beta02 Flexberry ORM ODataService New Platform Ltd. New Platform Ltd. @@ -22,6 +22,7 @@ 2. [BREAKINGCHANGE] Method MapODataServiceDataObjectRoute now requires HttpServer as parameter. 3. At creation of dynamic views of the master in them are added with primary keys. 4. Use common DataObjectCache for all sql queries per http request. + 5. [BREAKINGCHANGE] DataObjectController events have new argument - `DataObjectController controller`. Fixed 1. Fix error with POST request and header "Prefer". diff --git a/NewPlatform.Flexberry.ORM.ODataService.sln b/NewPlatform.Flexberry.ORM.ODataService.sln index 1df8afca..601cd9f1 100644 --- a/NewPlatform.Flexberry.ORM.ODataService.sln +++ b/NewPlatform.Flexberry.ORM.ODataService.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2036 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewPlatform.Flexberry.ORM.ODataService", "NewPlatform.Flexberry.ORM.ODataService\NewPlatform.Flexberry.ORM.ODataService.csproj", "{01BBE45A-3A3F-4EA5-9457-8C62167B5E99}" EndProject @@ -20,6 +20,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewPlatform.Flexberry.ORM.O EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Open Source", "Open Source", "{DB00E5CF-65B6-4A94-8C83-A80DB75E9B02}" ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes .gitignore = .gitignore .travis.yml = .travis.yml CHANGELOG.md = CHANGELOG.md @@ -61,6 +62,5 @@ Global EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {611B715C-AD46-45B1-BA4E-36C8F1A1896E} - EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.2\lib\NET35;packages\Unity.Interception.2.1.505.0\lib\NET35;packages\EnterpriseLibrary.Common.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Data.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Logging.5.0.505.0\lib\NET35;packages\EnterpriseLibrary.Logging.Database.5.0.505.0\lib\NET35 EndGlobalSection EndGlobal diff --git a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Actions.cs b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Actions.cs index 63e2fa4d..0f798c16 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Actions.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Actions.cs @@ -2,26 +2,18 @@ { using System; using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Http; using System.Reflection; using System.Web.Http; using System.Web.OData; using System.Web.OData.Extensions; - using System.Web.OData.Query; using System.Web.OData.Routing; - using Expressions; + using ICSSoft.STORMNET; - using Microsoft.OData.Core; - using Microsoft.OData.Edm.Library; - using Microsoft.OData.Edm.Values; - using NewPlatform.Flexberry.ORM.ODataService.Formatter; + using NewPlatform.Flexberry.ORM.ODataService.Functions; using NewPlatform.Flexberry.ORM.ODataService.Handlers; - using NewPlatform.Flexberry.ORM.ODataService.Model; using NewPlatform.Flexberry.ORM.ODataService.Routing; + using Action = NewPlatform.Flexberry.ORM.ODataService.Functions.Action; /// @@ -107,7 +99,7 @@ private IHttpActionResult ExecuteAction(ODataActionParameters parameters) if (result is DataObject) { - var entityType = _model.GetEdmEntityType(result.GetType()); + var entityType = Model.GetEdmEntityType(result.GetType()); return SetResult(GetEdmObject(entityType, result, 1, null)); } diff --git a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Events.cs b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Events.cs index 73f19801..50497b6d 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Events.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.Events.cs @@ -1,11 +1,12 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Controllers { + using System; + using System.Net; + using ICSSoft.STORMNET; using ICSSoft.STORMNET.Business; using NewPlatform.Flexberry.ORM.ODataService.Events; - using System; - using System.Net; /// /// OData controller class. @@ -25,7 +26,7 @@ public partial class DataObjectController /// internal bool ExecuteCallbackBeforeGet(ref LoadingCustomizationStruct lcs) { - return _events.CallbackBeforeGet == null || _events.CallbackBeforeGet(ref lcs); + return _events.CallbackBeforeGet == null || _events.CallbackBeforeGet(this, ref lcs); } /// @@ -35,7 +36,7 @@ internal bool ExecuteCallbackBeforeGet(ref LoadingCustomizationStruct lcs) /// internal bool ExecuteCallbackBeforeCreate(DataObject obj) { - return _events.CallbackBeforeCreate == null || _events.CallbackBeforeCreate(obj); + return _events.CallbackBeforeCreate == null || _events.CallbackBeforeCreate(this, obj); } /// @@ -45,7 +46,7 @@ internal bool ExecuteCallbackBeforeCreate(DataObject obj) /// internal bool ExecuteCallbackBeforeUpdate(DataObject obj) { - return _events.CallbackBeforeUpdate == null || _events.CallbackBeforeUpdate(obj); + return _events.CallbackBeforeUpdate == null || _events.CallbackBeforeUpdate(this, obj); } /// @@ -55,7 +56,7 @@ internal bool ExecuteCallbackBeforeUpdate(DataObject obj) /// internal bool ExecuteCallbackBeforeDelete(DataObject obj) { - return _events.CallbackBeforeDelete == null || _events.CallbackBeforeDelete(obj); + return _events.CallbackBeforeDelete == null || _events.CallbackBeforeDelete(this, obj); } /// @@ -64,7 +65,7 @@ internal bool ExecuteCallbackBeforeDelete(DataObject obj) /// Объект после создания. internal void ExecuteCallbackAfterGet(ref DataObject[] objs) { - _events.CallbackAfterGet?.Invoke(ref objs); + _events.CallbackAfterGet?.Invoke(this, ref objs); } /// @@ -73,7 +74,7 @@ internal void ExecuteCallbackAfterGet(ref DataObject[] objs) /// Объект после создания. internal void ExecuteCallbackAfterCreate(DataObject obj) { - _events.CallbackAfterCreate?.Invoke(obj); + _events.CallbackAfterCreate?.Invoke(this, obj); } /// @@ -82,7 +83,7 @@ internal void ExecuteCallbackAfterCreate(DataObject obj) /// Объект после обновления. internal void ExecuteCallbackAfterUpdate(DataObject obj) { - _events.CallbackAfterUpdate?.Invoke(obj); + _events.CallbackAfterUpdate?.Invoke(this, obj); } /// @@ -91,7 +92,7 @@ internal void ExecuteCallbackAfterUpdate(DataObject obj) /// Объект перед удалением. internal void ExecuteCallbackAfterDelete(DataObject obj) { - _events.CallbackAfterDelete?.Invoke(obj); + _events.CallbackAfterDelete?.Invoke(this, obj); } /// @@ -107,7 +108,7 @@ internal Exception ExecuteCallbackAfterInternalServerError(Exception ex, ref Htt return ex; } - return _events.CallbackAfterInternalServerError(ex, ref code); + return _events.CallbackAfterInternalServerError(this, ex, ref code); } } } \ No newline at end of file diff --git a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.ModifyData.cs b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.ModifyData.cs index bd734ad3..5e9d5c18 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.ModifyData.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.ModifyData.cs @@ -64,7 +64,7 @@ public HttpResponseMessage Post([FromBody] EdmEntityObject edmEntity) DataObject obj = UpdateObject(edmEntity, null); ExecuteCallbackAfterCreate(obj); - edmEntity = GetEdmObject(_model.GetEdmEntityType(type), obj, 1, null, null); + edmEntity = GetEdmObject(Model.GetEdmEntityType(Type), obj, 1, null, null); var responseForPreferMinimal = TestPreferMinimal(); if (responseForPreferMinimal != null) { @@ -146,7 +146,7 @@ public HttpResponseMessage Patch([FromODataUri] Guid key, [FromBody] EdmEntityOb return Request.CreateResponse(System.Net.HttpStatusCode.NoContent); } - edmEntity = GetEdmObject(_model.GetEdmEntityType(type), obj, 1, null, null); + edmEntity = GetEdmObject(Model.GetEdmEntityType(Type), obj, 1, null, null); var result = Request.CreateResponse(System.Net.HttpStatusCode.OK, edmEntity); result.Headers.Add("Preference-Applied", "return=representation"); return result; @@ -194,7 +194,7 @@ private HttpResponseMessage DeleteEntity(object key) Init(); - var obj = _dataObjectCache.CreateDataObject(type, key); + var obj = DataObjectCache.CreateDataObject(Type, key); // Раз объект данных удаляется, то и все ассоциированные с ним файлы должны быть удалены. // Запоминаем метаданные всех ассоциированных файлов, кроме файлов соответствующих файловым свойствам типа File @@ -221,7 +221,7 @@ private HttpResponseMessage DeleteEntity(object key) } else { - _dataService.UpdateObject(obj); + DataService.UpdateObject(obj); } } @@ -465,7 +465,7 @@ private DataObject UpdateObject(EdmEntityObject edmEntity, object key) } else { - _dataService.UpdateObjects(ref objsArrSmall); + DataService.UpdateObjects(ref objsArrSmall); } // При успешном обновлении вычищаем из файловой системы, файлы подлежащие удалению. @@ -494,8 +494,8 @@ private DataObject ReturnDataObject(Type objType, object keyValue) if (keyValue != null) { - DataObject dataObjectFromCache = _dataObjectCache.GetLivingDataObject(objType, keyValue); - var view = _model.GetDataObjectDefaultView(objType); + DataObject dataObjectFromCache = DataObjectCache.GetLivingDataObject(objType, keyValue); + var view = Model.GetDataObjectDefaultView(objType); if (dataObjectFromCache != null) { @@ -509,7 +509,7 @@ private DataObject ReturnDataObject(Type objType, object keyValue) && dataObjectFromCache.GetLoadedProperties().Length == 1 && dataObjectFromCache.CheckLoadedProperty(x => x.__PrimaryKey)) { - _dataService.LoadObject(view, dataObjectFromCache); + DataService.LoadObject(view, dataObjectFromCache); } return dataObjectFromCache; @@ -518,7 +518,7 @@ private DataObject ReturnDataObject(Type objType, object keyValue) // Проверим существование объекта в базе. LoadingCustomizationStruct lcs = LoadingCustomizationStruct.GetSimpleStruct(objType, view); lcs.LimitFunction = FunctionBuilder.BuildEquals(keyValue); - DataObject[] dobjs = _dataService.LoadObjects(lcs, _dataObjectCache); + DataObject[] dobjs = DataService.LoadObjects(lcs, DataObjectCache); if (dobjs.Length == 1) { DataObject dataObject = dobjs[0]; @@ -532,12 +532,12 @@ private DataObject ReturnDataObject(Type objType, object keyValue) if (keyValue != null) { - obj = _dataObjectCache.CreateDataObject(objType, keyValue); + obj = DataObjectCache.CreateDataObject(objType, keyValue); } else { obj = (DataObject)Activator.CreateInstance(objType); - _dataObjectCache.AddDataObject(obj); + DataObjectCache.AddDataObject(obj); } _newDataObjects.Add(obj, true); @@ -560,13 +560,13 @@ private DataObject GetDataObjectByEdmEntity(EdmEntityObject edmEntity, object ke } IEdmEntityType entityType = (IEdmEntityType)edmEntity.ActualEdmType; - Type objType = _model.GetDataObjectType(_model.GetEdmEntitySet(entityType).Name); + Type objType = Model.GetDataObjectType(Model.GetEdmEntitySet(entityType).Name); // Значение свойства. object value; // Получим значение ключа. - var keyProperty = entityType.Properties().FirstOrDefault(prop => prop.Name == _model.KeyPropertyName); + var keyProperty = entityType.Properties().FirstOrDefault(prop => prop.Name == Model.KeyPropertyName); if (key != null) { value = key; @@ -599,7 +599,7 @@ private DataObject GetDataObjectByEdmEntity(EdmEntityObject edmEntity, object ke // Все свойства объекта данных означим из пришедшей сущности, если они были там установлены(изменены). foreach (var prop in entityType.Properties()) { - string dataObjectPropName = _model.GetDataObjectProperty(entityType.FullTypeName(), prop.Name).Name; + string dataObjectPropName = Model.GetDataObjectProperty(entityType.FullTypeName(), prop.Name).Name; if (edmEntity.GetChangedPropertyNames().Contains(prop.Name)) { // Обработка мастеров и детейлов. diff --git a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.UserFunctions.cs b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.UserFunctions.cs index d1db8b10..2aa6a571 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.UserFunctions.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.UserFunctions.cs @@ -131,7 +131,7 @@ internal IHttpActionResult ExecuteUserFunction(QueryParameters queryParameters) Request.ODataProperties().SelectExpandClause = QueryOptions.SelectExpand.SelectExpandClause; } - this.type = type; + this.Type = type; CreateDynamicView(); IncludeCount = false; if (queryOpt.Count != null && queryOpt.Count.Value) @@ -149,7 +149,7 @@ internal IHttpActionResult ExecuteUserFunction(QueryParameters queryParameters) NameValueCollection queryParams = Request.RequestUri.ParseQueryString(); - if ((_model.ExportService != null || _model.ODataExportService != null) && (Request.Properties.ContainsKey(PostPatchHandler.AcceptApplicationMsExcel) || Convert.ToBoolean(queryParams.Get("exportExcel")))) + if ((Model.ExportService != null || Model.ODataExportService != null) && (Request.Properties.ContainsKey(PostPatchHandler.AcceptApplicationMsExcel) || Convert.ToBoolean(queryParams.Get("exportExcel")))) { _objs = (result as IEnumerable).Cast().ToArray(); return ResponseMessage(CreateExcel(queryParams)); @@ -170,9 +170,9 @@ internal IHttpActionResult ExecuteUserFunction(QueryParameters queryParameters) Request.ODataProperties().SelectExpandClause = QueryOptions.SelectExpand.SelectExpandClause; } - this.type = result.GetType(); + this.Type = result.GetType(); CreateDynamicView(); - var entityType = _model.GetEdmEntityType(this.type); + var entityType = Model.GetEdmEntityType(this.Type); return SetResult(GetEdmObject(entityType, result, 1, null, _dynamicView)); } diff --git a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.cs b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.cs index 2a4af6eb..74cded16 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Controllers/DataObjectController.cs @@ -48,20 +48,62 @@ public partial class DataObjectController : BaseODataController private DataObject[] _objs; private LoadingCustomizationStruct _lcs; + private static readonly IAssembliesResolver _defaultAssembliesResolver = new DefaultAssembliesResolver(); + private List _lcsLoadingTypes = new List(); + private DynamicView _dynamicView; + private Dictionary _parentExpandedNavigationSelectItem = new Dictionary(); + private Dictionary _properties = new Dictionary(); + + internal BaseOfflineManager OfflineManager { get; set; } + + /// + /// Конструктор по-умолчанию. + /// + /// Data service for all manipulations with data. + /// DataObject cache. + /// EDM model. + /// The container with registered events. + /// The container with OData Service functions. + public DataObjectController( + IDataService dataService, + DataObjectCache dataObjectCache, + DataObjectEdmModel model, + IEventHandlerContainer events, + IFunctionContainer functions) + { + DataService = dataService ?? throw new ArgumentNullException(nameof(dataService), "Contract assertion not met: dataService != null"); + + if (dataObjectCache != null) + { + DataObjectCache = dataObjectCache; + } + else + { + DataObjectCache = new DataObjectCache(); + DataObjectCache.StartCaching(false); + } + + Model = model; + _events = events; + _functions = functions; + + OfflineManager = new DummyOfflineManager(); + } + /// /// Data service for all manipulations with data. /// - private readonly IDataService _dataService; - + public IDataService DataService { get; } + /// /// Data object cache for sync loading. /// - private readonly DataObjectCache _dataObjectCache; + public DataObjectCache DataObjectCache { get; } /// /// The current EDM model. /// - private readonly DataObjectEdmModel _model; + public DataObjectEdmModel Model { get; } /// /// Используемые в запросе параметры. Заполняется в методе Init(). @@ -71,7 +113,7 @@ public partial class DataObjectController : BaseODataController /// /// Тип DataObject, который соответствует сущности в наборе из запроса. Заполняется в методе Init(). /// - public Type type { get; set; } + public Type Type { get; set; } /// /// Включать или нет в метаданные количество сущностей. @@ -83,48 +125,6 @@ public partial class DataObjectController : BaseODataController /// public int Count { get; set; } - private static readonly IAssembliesResolver _defaultAssembliesResolver = new DefaultAssembliesResolver(); - private List _lcsLoadingTypes = new List(); - private DynamicView _dynamicView; - private Dictionary _parentExpandedNavigationSelectItem = new Dictionary(); - private Dictionary _properties = new Dictionary(); - - internal BaseOfflineManager OfflineManager { get; set; } - - /// - /// Конструктор по-умолчанию. - /// - /// Data service for all manipulations with data. - /// DataObject cache. - /// EDM model. - /// The container with registered events. - /// The container with OData Service functions. - public DataObjectController( - IDataService dataService, - DataObjectCache dataObjectCache, - DataObjectEdmModel model, - IEventHandlerContainer events, - IFunctionContainer functions) - { - _dataService = dataService ?? throw new ArgumentNullException(nameof(dataService), "Contract assertion not met: dataService != null"); - - if (dataObjectCache != null) - { - _dataObjectCache = dataObjectCache; - } - else - { - _dataObjectCache = new DataObjectCache(); - _dataObjectCache.StartCaching(false); - } - - _model = model; - _events = events; - _functions = functions; - - OfflineManager = new DummyOfflineManager(); - } - /// /// Обрабатывает все несопоставленные запросы OData /// @@ -181,10 +181,10 @@ public HttpResponseMessage GetString() ODataPath odataPath = Request.ODataProperties().Path; string key = odataPath.Segments[1].ToString().Trim().Replace("'", string.Empty); Init(); - var obj = LoadObject(type, key); + var obj = LoadObject(Type, key); var result = Request.CreateResponse( System.Net.HttpStatusCode.OK, - GetEdmObject(_model.GetEdmEntityType(type), obj, 1, null, _dynamicView)); + GetEdmObject(Model.GetEdmEntityType(Type), obj, 1, null, _dynamicView)); return result; } @@ -208,10 +208,10 @@ public HttpResponseMessage GetGuid() Guid key = new Guid(odataPath.Segments[1].ToString()); Init(); - var obj = LoadObject(type, key); + var obj = LoadObject(Type, key); var result = Request.CreateResponse( System.Net.HttpStatusCode.OK, - GetEdmObject(_model.GetEdmEntityType(type), obj, 1, null, _dynamicView)); + GetEdmObject(Model.GetEdmEntityType(Type), obj, 1, null, _dynamicView)); return result; } @@ -261,13 +261,13 @@ private bool HasOdataError(Exception exception) public int GetObjectsCount(Type type, ODataQueryOptions queryOptions) { var expr = GetExpressionFilterOnly(type, queryOptions); - View view = _model.GetDataObjectDefaultView(type); + View view = Model.GetDataObjectDefaultView(type); var lcs = LinqToLcs.GetLcs(expr, view); lcs.View = view; lcs.LoadingTypes = new[] { type }; lcs.ReturnType = LcsReturnType.Objects; - return _dataService.GetObjectsCount(lcs); + return DataService.GetObjectsCount(lcs); } internal HttpResponseMessage CreateExcel(NameValueCollection queryParams) @@ -325,17 +325,17 @@ internal HttpResponseMessage CreateExcel(NameValueCollection queryParams) par.DetailsInSeparateColumns = Convert.ToBoolean(queryParams.Get("detSeparateCols")); par.DetailsInSeparateRows = Convert.ToBoolean(queryParams.Get("detSeparateRows")); MemoryStream result; - if (_model.ODataExportService != null) + if (Model.ODataExportService != null) { - result = _model.ODataExportService.CreateExportStream(_dataService, par, _objs, queryParams); + result = Model.ODataExportService.CreateExportStream(DataService, par, _objs, queryParams); } else { - result = _model.ExportService.CreateExportStream(_dataService, par, _objs); + result = Model.ExportService.CreateExportStream(DataService, par, _objs); } HttpResponseMessage msg = Request.CreateResponse(HttpStatusCode.OK); - RawOutputFormatter.PrepareHttpResponseMessage(ref msg, "application/ms-excel", _model, result.ToArray()); + RawOutputFormatter.PrepareHttpResponseMessage(ref msg, "application/ms-excel", Model, result.ToArray()); msg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); msg.Content.Headers.ContentDisposition.FileName = "list.xlsx"; return msg; @@ -354,12 +354,12 @@ internal EdmEntityObjectCollection GetEdmCollection(IEnumerable objs, Type type, { if (level == 0) return null; - var entityType = _model.GetEdmEntityType(type); + var entityType = Model.GetEdmEntityType(type); List edmObjList = new List(); foreach (var obj in objs) { - var realType = _model.GetEdmEntityType(obj.GetType()); + var realType = Model.GetEdmEntityType(obj.GetType()); var edmObj = GetEdmObject(realType, obj, level, expandedNavigationSelectItem, dynamicView); if (edmObj != null) edmObjList.Add(edmObj); @@ -442,7 +442,7 @@ internal EdmEntityObject GetEdmObject(IEdmEntityType entityType, object obj, int foreach (var prop in entityType.Properties()) { - string dataObjectPropName = _model.GetDataObjectProperty(entityType.FullTypeName(), prop.Name).Name; + string dataObjectPropName = Model.GetDataObjectProperty(entityType.FullTypeName(), prop.Name).Name; if (prop is EdmNavigationProperty) { if (expandedProperties.ContainsKey(prop.Name)) @@ -459,18 +459,18 @@ internal EdmEntityObject GetEdmObject(IEdmEntityType entityType, object obj, int View view; if (master == null) { - view = _model.GetDataObjectDefaultView(obj.GetType()); + view = Model.GetDataObjectDefaultView(obj.GetType()); obj = LoadObject(view, (DataObject)obj); } master = obj.GetType().GetProperty(dataObjectPropName).GetValue(obj, null); if (master != null) { - view = _model.GetDataObjectDefaultView(master.GetType()); + view = Model.GetDataObjectDefaultView(master.GetType()); if (view != null) { master = LoadObject(view, (DataObject)master); - edmObj = GetEdmObject(_model.GetEdmEntityType(master.GetType()), master, level, expandedItem); + edmObj = GetEdmObject(Model.GetEdmEntityType(master.GetType()), master, level, expandedItem); } } } @@ -480,10 +480,10 @@ internal EdmEntityObject GetEdmObject(IEdmEntityType entityType, object obj, int { if (!DynamicView.ContainsPoperty(dynamicView.View, propPath)) { - _dataService.LoadObject(dynamicView.View, (DataObject)master, false, true, _dataObjectCache); + DataService.LoadObject(dynamicView.View, (DataObject)master, false, true, DataObjectCache); } - edmObj = GetEdmObject(_model.GetEdmEntityType(master.GetType()), master, level, expandedItem, dynamicView); + edmObj = GetEdmObject(Model.GetEdmEntityType(master.GetType()), master, level, expandedItem, dynamicView); } } @@ -493,7 +493,7 @@ internal EdmEntityObject GetEdmObject(IEdmEntityType entityType, object obj, int if (navProp.TargetMultiplicity() == EdmMultiplicity.Many) { DetailArray detail = null; - View view = _model.GetDataObjectDefaultView(obj.GetType()); + View view = Model.GetDataObjectDefaultView(obj.GetType()); if (dynamicView == null || !DynamicView.ContainsPoperty(dynamicView.View, propPath)) { obj = LoadObject(view, (DataObject)obj); @@ -515,7 +515,7 @@ internal EdmEntityObject GetEdmObject(IEdmEntityType entityType, object obj, int } else { - if (prop.Name == _model.KeyPropertyName) + if (prop.Name == Model.KeyPropertyName) { object key = obj.GetType().GetProperty(dataObjectPropName).GetValue(obj, null); if (key is KeyGuid) @@ -620,7 +620,7 @@ public Expression ToExpression(ODataQueryOptions queryOpt) if (queryOpt.OrderBy != null) { // queryable = queryOpt.OrderBy.ApplyTo(queryable, new ODataQuerySettings()); - queryable = new OrderByQueryOption(queryOpt.OrderBy, type).ApplyTo(queryable, new ODataQuerySettings()); + queryable = new OrderByQueryOption(queryOpt.OrderBy, Type).ApplyTo(queryable, new ODataQuerySettings()); } if (queryOpt.Skip != null) @@ -739,7 +739,7 @@ private IQueryable FilterApplyTo(FilterQueryOption filter, IQueryable query) throw Error.ArgumentNull("assembliesResolver"); } - if (type == null) + if (Type == null) { throw Error.NotSupported(SRResources.ApplyToOnUntypedQueryOption, "ApplyTo"); } @@ -758,18 +758,18 @@ private IQueryable FilterApplyTo(FilterQueryOption filter, IQueryable query) updatedSettings.HandleNullPropagation = HandleNullPropagationOptionHelper.GetDefaultHandleNullPropagationOption(query); } - FilterBinder binder = FilterBinder.Transform(filterClause, type, filter.Context.Model, assembliesResolver, updatedSettings); + FilterBinder binder = FilterBinder.Transform(filterClause, Type, filter.Context.Model, assembliesResolver, updatedSettings); _filterDetailProperties = binder.FilterDetailProperties; if (binder.IsOfTypesList.Count > 0) { - _lcsLoadingTypes = _model.GetTypes(binder.IsOfTypesList); + _lcsLoadingTypes = Model.GetTypes(binder.IsOfTypesList); } else { _lcsLoadingTypes.Clear(); } - query = ExpressionHelpers.Where(query, binder.LinqExpression, type); + query = ExpressionHelpers.Where(query, binder.LinqExpression, Type); return query; } @@ -780,8 +780,8 @@ private IQueryable FilterApplyTo(FilterQueryOption filter, IQueryable query) /// Контекст запроса OData. private ODataQueryContext CreateODataQueryContext(Type type) { - ODataPath path = new ODataPath(new EntitySetPathSegment(_model.GetEdmEntitySet(_model.GetEdmEntityType(type)))); - return new ODataQueryContext(_model, type, path); + ODataPath path = new ODataPath(new EntitySetPathSegment(Model.GetEdmEntitySet(Model.GetEdmEntityType(type)))); + return new ODataQueryContext(Model, type, path); } /// @@ -790,12 +790,12 @@ private ODataQueryContext CreateODataQueryContext(Type type) /// Сущность или коллекция сущностей. private IEdmObject EvaluateOdataPath() { - type = _model.GetDataObjectType(Request.ODataProperties().Path.Segments.OfType().First().ToString()); + Type = Model.GetDataObjectType(Request.ODataProperties().Path.Segments.OfType().First().ToString()); DetailArray detail = null; ODataPath odataPath = Request.ODataProperties().Path; Guid key = new Guid(odataPath.Segments[1].ToString()); IEdmEntityType entityType = null; - var obj = LoadObject(type, key); + var obj = LoadObject(Type, key); if (obj == null) { throw new InvalidOperationException("Not Found OData Path Segment " + 1); @@ -804,8 +804,8 @@ private IEdmObject EvaluateOdataPath() bool returnCollection = false; for (int i = 2; i < odataPath.Segments.Count; i++) { - type = obj.GetType(); - entityType = _model.GetEdmEntityType(type); + Type = obj.GetType(); + entityType = Model.GetEdmEntityType(Type); string propName = odataPath.Segments[i].ToString(); EdmNavigationProperty navProp = (EdmNavigationProperty)entityType.FindProperty(propName); @@ -814,7 +814,7 @@ private IEdmObject EvaluateOdataPath() DataObject master = (DataObject)obj.GetType().GetProperty(propName).GetValue(obj, null); if (master == null) { - View view = _model.GetDataObjectDefaultView(obj.GetType()); + View view = Model.GetDataObjectDefaultView(obj.GetType()); obj = LoadObject(view, obj); } @@ -823,9 +823,9 @@ private IEdmObject EvaluateOdataPath() throw new InvalidOperationException("Not Found OData Path Segment " + i); } - if (master != null && _model.GetDataObjectDefaultView(master.GetType()) != null) + if (master != null && Model.GetDataObjectDefaultView(master.GetType()) != null) { - master = LoadObject(_model.GetDataObjectDefaultView(master.GetType()), master); + master = LoadObject(Model.GetDataObjectDefaultView(master.GetType()), master); } obj = master; @@ -833,7 +833,7 @@ private IEdmObject EvaluateOdataPath() if (navProp.TargetMultiplicity() == EdmMultiplicity.Many) { - View view = _model.GetDataObjectDefaultView(obj.GetType()); + View view = Model.GetDataObjectDefaultView(obj.GetType()); obj = LoadObject(view, obj); detail = (DetailArray)obj.GetType().GetProperty(propName).GetValue(obj, null); i++; @@ -852,17 +852,17 @@ private IEdmObject EvaluateOdataPath() } } - entityType = _model.GetEdmEntityType(obj.GetType()); + entityType = Model.GetEdmEntityType(obj.GetType()); if (returnCollection) { - type = detail.ItemType; + Type = detail.ItemType; } else { - type = obj.GetType(); + Type = obj.GetType(); } - QueryOptions = new ODataQueryOptions(new ODataQueryContext(_model, type, Request.ODataProperties().Path), Request); + QueryOptions = new ODataQueryOptions(new ODataQueryContext(Model, Type, Request.ODataProperties().Path), Request); if (QueryOptions.SelectExpand != null && QueryOptions.SelectExpand.SelectExpandClause != null) { Request.ODataProperties().SelectExpandClause = QueryOptions.SelectExpand.SelectExpandClause; @@ -870,8 +870,8 @@ private IEdmObject EvaluateOdataPath() if (returnCollection) { - IQueryable queryable = ApplyExpression(type, QueryOptions, detail.GetAllObjects()); - return GetEdmCollection(queryable, type, 1, null); + IQueryable queryable = ApplyExpression(Type, QueryOptions, detail.GetAllObjects()); + return GetEdmCollection(queryable, Type, 1, null); } return GetEdmObject(entityType, obj, 1, null); @@ -945,34 +945,34 @@ private HttpResponseMessage ExecuteExpression() NameValueCollection queryParams = Request.RequestUri.ParseQueryString(); - if ((_model.ExportService != null || _model.ODataExportService != null) && (Request.Properties.ContainsKey(PostPatchHandler.AcceptApplicationMsExcel) || Convert.ToBoolean(queryParams.Get("exportExcel")))) + if ((Model.ExportService != null || Model.ODataExportService != null) && (Request.Properties.ContainsKey(PostPatchHandler.AcceptApplicationMsExcel) || Convert.ToBoolean(queryParams.Get("exportExcel")))) { return CreateExcel(queryParams); } HttpResponseMessage msg = null; EdmEntityObjectCollection edmCol = null; - edmCol = GetEdmCollection(_objs, type, 1, null, _dynamicView); + edmCol = GetEdmCollection(_objs, Type, 1, null, _dynamicView); msg = Request.CreateResponse(HttpStatusCode.OK, edmCol); return msg; } public LoadingCustomizationStruct CreateLcs() { - Expression expr = GetExpression(type, QueryOptions); + Expression expr = GetExpression(Type, QueryOptions); if (_filterDetailProperties != null && _filterDetailProperties.Count > 0) { CreateDynamicView(); _filterDetailProperties = null; } - View view = _model.GetDataObjectDefaultView(type); + View view = Model.GetDataObjectDefaultView(Type); if (_dynamicView != null) view = _dynamicView.View; IEnumerable resolvingViews; - view = DynamicView.GetViewWithPropertiesUsedInExpression(expr, type, view, _dataService, out resolvingViews); + view = DynamicView.GetViewWithPropertiesUsedInExpression(expr, Type, view, DataService, out resolvingViews); if (_lcsLoadingTypes.Count == 0) - _lcsLoadingTypes = _model.GetDerivedTypes(type).ToList(); + _lcsLoadingTypes = Model.GetDerivedTypes(Type).ToList(); for (int i = 0; i < _lcsLoadingTypes.Count; i++) { @@ -1005,8 +1005,8 @@ public LoadingCustomizationStruct CreateLcs() /// private void Init() { - type = _model.GetDataObjectType(Request.ODataProperties().Path.Segments.OfType().First().ToString()); - QueryOptions = new ODataQueryOptions(new ODataQueryContext(_model, type, Request.ODataProperties().Path), Request); + Type = Model.GetDataObjectType(Request.ODataProperties().Path.Segments.OfType().First().ToString()); + QueryOptions = new ODataQueryOptions(new ODataQueryContext(Model, Type, Request.ODataProperties().Path), Request); if (QueryOptions.SelectExpand != null && QueryOptions.SelectExpand.SelectExpandClause != null) { Request.ODataProperties().SelectExpandClause = QueryOptions.SelectExpand.SelectExpandClause; @@ -1023,7 +1023,7 @@ private void Init() /// Объект DataObject для данного ключа. private DataObject LoadObject(Type type, string key) { - View view = _model.GetDataObjectDefaultView(type); + View view = Model.GetDataObjectDefaultView(type); return LoadObject(type, view, key); } @@ -1035,7 +1035,7 @@ private DataObject LoadObject(Type type, string key) /// Объект DataObject для данного ключа. private DataObject LoadObject(Type type, Guid key) { - View view = _model.GetDataObjectDefaultView(type); + View view = Model.GetDataObjectDefaultView(type); return LoadObject(type, view, key); } @@ -1074,9 +1074,9 @@ private DataObject[] LoadObjects(LoadingCustomizationStruct lcs, out int count, { foreach (var propType in Information.GetAllTypesFromView(lcs.View)) { - if (!_dataService.SecurityManager.AccessObjectCheck(propType, tTypeAccess.Full, false)) + if (!DataService.SecurityManager.AccessObjectCheck(propType, tTypeAccess.Full, false)) { - _dataService.SecurityManager.AccessObjectCheck(propType, tTypeAccess.Read, true); + DataService.SecurityManager.AccessObjectCheck(propType, tTypeAccess.Read, true); } } @@ -1089,11 +1089,11 @@ private DataObject[] LoadObjects(LoadingCustomizationStruct lcs, out int count, { if (!callGetObjectsCount) { - dobjs = _dataService.LoadObjects(lcs, _dataObjectCache); + dobjs = DataService.LoadObjects(lcs, DataObjectCache); } else { - count = _dataService.GetObjectsCount(lcs); + count = DataService.GetObjectsCount(lcs); } } @@ -1120,20 +1120,20 @@ private void CreateDynamicView() { if (QueryOptions.SelectExpand == null || QueryOptions.SelectExpand.SelectExpandClause == null) { - var properties = DynamicView.GetProperties(type); + var properties = DynamicView.GetProperties(Type); if (_filterDetailProperties != null && _filterDetailProperties.Count > 0) { properties.AddRange(_filterDetailProperties); } - _dynamicView = DynamicView.Create(type, properties /*, _model.DynamicViewCache */); // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + _dynamicView = DynamicView.Create(Type, properties /*, _model.DynamicViewCache */); // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! return; } List props = new List(); if (QueryOptions.SelectExpand.SelectExpandClause.AllSelected) { - var props2 = DynamicView.GetProperties(type); + var props2 = DynamicView.GetProperties(Type); props.AddRange(props2); } @@ -1155,7 +1155,7 @@ private void CreateDynamicView() typeName = (edmType as EdmEntityType).FullName(); } - var types = _model.GetTypes(new List() { typeName }); + var types = Model.GetTypes(new List() { typeName }); var props2 = DynamicView.GetProperties(types[0]); for (int i = 0; i < props2.Count; i++) { @@ -1175,7 +1175,7 @@ private void CreateDynamicView() props.AddRange(_filterDetailProperties); } - _dynamicView = DynamicView.Create(type, props /*, _model.DynamicViewCache */); // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + _dynamicView = DynamicView.Create(Type, props /*, _model.DynamicViewCache */); // TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } private void GetPropertiesForDynamicView(ExpandedNavigationSelectItem parent, IEnumerable selectedItems) @@ -1231,13 +1231,13 @@ private string GetPropertyName(SelectItem item) } } - string itemName = _model.GetDataObjectProperty(itemProperty.DeclaringType.FullTypeName(), itemProperty.Name).Name; + string itemName = Model.GetDataObjectProperty(itemProperty.DeclaringType.FullTypeName(), itemProperty.Name).Name; string parentName = null; var parentExpandedItem = _parentExpandedNavigationSelectItem[item]; while (parentExpandedItem != null) { IEdmProperty property = (parentExpandedItem.PathToNavigationProperty.FirstSegment as NavigationPropertySegment).NavigationProperty; - string name = _model.GetDataObjectProperty(property.DeclaringType.FullTypeName(), property.Name).Name; + string name = Model.GetDataObjectProperty(property.DeclaringType.FullTypeName(), property.Name).Name; if (parentName == null) { parentName = name; diff --git a/NewPlatform.Flexberry.ORM.ODataService/Events/Delegates.cs b/NewPlatform.Flexberry.ORM.ODataService/Events/Delegates.cs index 8cbc7935..fe86627f 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Events/Delegates.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Events/Delegates.cs @@ -1,68 +1,79 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Events { - using ICSSoft.STORMNET; - using ICSSoft.STORMNET.Business; using System; using System.Net; + using ICSSoft.STORMNET; + using ICSSoft.STORMNET.Business; + + using NewPlatform.Flexberry.ORM.ODataService.Controllers; + /// /// Тип делегата, вызываемого перед выполнением запроса. /// - /// . - /// - public delegate bool DelegateBeforeGet(ref LoadingCustomizationStruct lcs); + /// Контроллер OData. + /// Структура загрузки. + /// для продолжения операции. + public delegate bool DelegateBeforeGet(DataObjectController controller, ref LoadingCustomizationStruct lcs); /// /// Тип делегата, вызываемого перед созданием объекта. /// + /// Контроллер OData. /// Объект. - /// - public delegate bool DelegateBeforeCreate(DataObject obj); + /// для продолжения операции. + public delegate bool DelegateBeforeCreate(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого перед изменением объекта. /// + /// Контроллер OData. /// Объект. - /// - public delegate bool DelegateBeforeUpdate(DataObject obj); + /// для продолжения операции. + public delegate bool DelegateBeforeUpdate(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого перед удалением объекта. /// + /// Контроллер OData. /// Объект. - /// - public delegate bool DelegateBeforeDelete(DataObject obj); + /// для продолжения операции. + public delegate bool DelegateBeforeDelete(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого после вычитывания объектов. /// + /// Контроллер OData. /// Вычитанные объекты. - public delegate void DelegateAfterGet(ref DataObject[] objs); + public delegate void DelegateAfterGet(DataObjectController controller, ref DataObject[] objs); /// /// Тип делегата, вызываемого после создания объекта. /// + /// Контроллер OData. /// Объект после создания. - public delegate void DelegateAfterCreate(DataObject obj); + public delegate void DelegateAfterCreate(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого после обновления объекта. /// + /// Контроллер OData. /// Объект после обновления. - public delegate void DelegateAfterUpdate(DataObject obj); + public delegate void DelegateAfterUpdate(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого после удаления объекта. /// + /// Контроллер OData. /// Объект перед удалением. - public delegate void DelegateAfterDelete(DataObject obj); + public delegate void DelegateAfterDelete(DataObjectController controller, DataObject obj); /// /// Тип делегата, вызываемого после возникновения исключения. /// + /// Контроллер OData. /// Исключение, которое возникло внутри ODataService. /// Возвращаемый код HTTP. По-умолчанияю 500. /// Исключение, которое будет отправлено клиенту. - public delegate Exception DelegateAfterInternalServerError(Exception ex, ref HttpStatusCode code); - + public delegate Exception DelegateAfterInternalServerError(DataObjectController controller, Exception ex, ref HttpStatusCode code); } diff --git a/NewPlatform.Flexberry.ORM.ODataService/Functions/QueryParameters.cs b/NewPlatform.Flexberry.ORM.ODataService/Functions/QueryParameters.cs index 7804c010..dc8c45af 100644 --- a/NewPlatform.Flexberry.ORM.ODataService/Functions/QueryParameters.cs +++ b/NewPlatform.Flexberry.ORM.ODataService/Functions/QueryParameters.cs @@ -1,11 +1,12 @@ namespace NewPlatform.Flexberry.ORM.ODataService.Functions { - using Controllers; - using ICSSoft.STORMNET.Business; - using Model; using System; using System.Net.Http; - using System.Web.OData.Query; + + using ICSSoft.STORMNET.Business; + + using NewPlatform.Flexberry.ORM.ODataService.Controllers; + using NewPlatform.Flexberry.ORM.ODataService.Model; /// /// Класс для хранения параметров запроса OData. @@ -64,7 +65,7 @@ public LoadingCustomizationStruct CreateLcs(Type type, string odataQuery = null) } _controller.QueryOptions = _controller.CreateODataQueryOptions(type, request); - _controller.type = type; + _controller.Type = type; return _controller.CreateLcs(); } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs index 6d301a47..7b08843d 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterGetTest.cs @@ -5,6 +5,8 @@ using ICSSoft.STORMNET; + using NewPlatform.Flexberry.ORM.ODataService.Controllers; + using Xunit; /// @@ -22,7 +24,7 @@ public class AfterGetTest : BaseODataServiceIntegratedTest /// Метод вызываемый после вычитывания объектов. /// /// Считанные объекты. - public void AfterGet(ref DataObject[] objs) + public void AfterGet(DataObjectController controller, ref DataObject[] objs) { Objs = objs; } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs index b74dfa1b..2b340337 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterInternalServerErrorTest.cs @@ -8,6 +8,8 @@ using Xunit; using System; + using NewPlatform.Flexberry.ORM.ODataService.Controllers; + /// /// Класс тестов для тестирования логики после возникновения исключения. /// @@ -21,7 +23,7 @@ public class AfterInternalServerErrorTest : BaseODataServiceIntegratedTest /// Исключение, которое возникло внутри ODataService. /// Возвращаемый код HTTP. По-умолчанияю 500. /// Исключение, которое будет отправлено клиенту. - public Exception AfterInternalServerError(Exception e, ref HttpStatusCode code) + public Exception AfterInternalServerError(DataObjectController controller, Exception e, ref HttpStatusCode code) { Ex = e; code = HttpStatusCode.InternalServerError; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs index 1e77a3b3..3bd0f5a7 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/AfterSaveTest.cs @@ -31,7 +31,7 @@ public class AfterSaveTest : BaseODataServiceIntegratedTest /// Метод вызываемый после создания объекта. /// /// Объект после создания. - public void AfterCreate(DataObject obj) + public void AfterCreate(DataObjectController controller, DataObject obj) { ParamObj = obj; } @@ -40,7 +40,7 @@ public void AfterCreate(DataObject obj) /// Метод вызываемый после обновления объекта. /// /// Объект после обновления. - public void AfterUpdate(DataObject obj) + public void AfterUpdate(DataObjectController controller, DataObject obj) { ParamObj = obj; } @@ -49,7 +49,7 @@ public void AfterUpdate(DataObject obj) /// Метод вызываемый после удаления объекта. /// /// Объект перед удалением. - public void AfterDelete(DataObject obj) + public void AfterDelete(DataObjectController controller, DataObject obj) { ParamObj = obj; } diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs index 8462c7a5..97622f22 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeGetTest.cs @@ -7,6 +7,8 @@ using ICSSoft.STORMNET; using ICSSoft.STORMNET.Business; + using NewPlatform.Flexberry.ORM.ODataService.Controllers; + using Xunit; /// @@ -21,7 +23,7 @@ public class BeforeGetTest : BaseODataServiceIntegratedTest /// /// /// - public bool BeforeGet(ref LoadingCustomizationStruct lcs) + public bool BeforeGet(DataObjectController controller, ref LoadingCustomizationStruct lcs) { this.lcs = lcs; return true; diff --git a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs index 6b6338dc..928fede0 100644 --- a/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs +++ b/Tests/NewPlatform.Flexberry.ORM.ODataService.Tests/Events/BeforeSaveTest.cs @@ -9,6 +9,7 @@ using ICSSoft.STORMNET.Business; using ICSSoft.STORMNET.Exceptions; + using NewPlatform.Flexberry.ORM.ODataService.Controllers; using NewPlatform.Flexberry.ORM.ODataService.Tests.Extensions; using Newtonsoft.Json; @@ -29,7 +30,7 @@ public class BeforeSaveTest : BaseODataServiceIntegratedTest /// Метод вызываемый перед созданием объекта. /// /// Объект перед созданием. - public bool BeforeCreate(DataObject obj) + public bool BeforeCreate(DataObjectController controller, DataObject obj) { ParamObj = obj; return true; @@ -39,7 +40,7 @@ public bool BeforeCreate(DataObject obj) /// Метод вызываемый перед обновлением объекта. /// /// Объект перед обновлением. - public bool BeforeUpdate(DataObject obj) + public bool BeforeUpdate(DataObjectController controller, DataObject obj) { ParamObj = obj; return true; @@ -49,7 +50,7 @@ public bool BeforeUpdate(DataObject obj) /// Метод вызываемый перед удалением объекта. /// /// Объект перед удалением. - public bool BeforeDelete(DataObject obj) + public bool BeforeDelete(DataObjectController controller, DataObject obj) { ParamObj = obj; return true;