Esempio n. 1
0
        public async Task <ActionResult> Edit(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM vm)
        {
            try
            {
                //log.Info(string.Format("{0}: Edit", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
                var entity = new Elmah.DataSourceEntities.ELMAH_Error();
                entity.CopyFrom <Elmah.EntityContracts.IELMAH_Error>(vm.Item);

                using (var scope = _serviceProvider.CreateScope())
                {
                    var serviceInstance = (Elmah.WcfContracts.IELMAH_ErrorService)scope.ServiceProvider.GetRequiredService(typeof(Elmah.WcfContracts.IELMAH_ErrorService));

                    var request1 = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageUserDefinedOfIdentifier();
                    request1.Criteria = new Elmah.CommonBLLEntities.ELMAH_ErrorChainedQueryCriteriaIdentifier();
                    request1.Criteria.Identifier.ErrorId.NullableValueToCompare = vm.Item.ErrorId;

                    var originalItem = await serviceInstance.GetCollectionOfEntityByIdentifier(request1);

                    entity.CopyFrom <Elmah.DataSourceEntities.ELMAH_Error>(originalItem.Message[0]);
                    // TODO: Some of the FKs not in view/.cshtml, must assigned here,
                    //entity.ParentBusinessEntityID = originalItem.Message[0].ParentBusinessEntityID;

                    var request = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageBuiltIn();

                    request.Criteria.Add(entity);
                    var _Response = await serviceInstance.UpsertEntity(request);

                    if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
                    {
                        //log.Info(string.Format("{0}: Edit", Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));
                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                    else
                    {
                        vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                        //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
                        //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                        vm.StatusOfResult        = _Response.BusinessLogicLayerResponseStatus;
                        vm.StatusMessageOfResult = _Response.ServerErrorMessage;
                        //log.Error(string.Format("{0}: Edit: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), _Response.ServerErrorMessage));
                        return(View(vm));
                    }
                }
            }
            catch (Exception ex)
            {
                Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Update;
                vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
                //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ELMAH_Error);
                vm.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                vm.StatusMessageOfResult = ex.Message;
                vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                //log.Error(string.Format("{0}: {1}, {2}, {3}", uiAction, Framework.Models.LoggingOptions.UI_Process_Failed.ToString(), vm.StatusOfResult, vm.StatusMessageOfResult));

                return(View(vm));
            }
        }
Esempio n. 2
0
 public async Task LoadExtraData(Framework.ViewModels.UIAction uiAction)
 {
     if (uiAction != Framework.ViewModels.UIAction.ViewDetails)
     {
         using (var scope = this.ServiceProvider.CreateScope())
         {
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// GET method of Adds the new <see cref="ElmahModel.ElmahHost"/>.
        /// GET: /ElmahHost/AddNew
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> AddNew()
        {
            var entity = CreateEmptyEntityOrGetFromTempData(TempDataKey_ElmahHostController_Copy);

            Framework.ViewModels.UIAction uiAction           = Framework.ViewModels.UIAction.Create;
            Elmah.AspNetMvcCoreViewModel.ElmahHost.ItemVM vm = await Elmah.AspNetMvcCoreViewModel.ElmahHost.ItemVM.CreateNewViewModel(this._serviceProvider, entity);

            await vm.LoadExtraData(uiAction);

            return(View(vm));
        }
Esempio n. 4
0
        /// <summary>
        /// GET method of details page, based on identifier or unique constraint, this entity only, no related entities.
        /// GET: /ElmahHost/Details/5
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> Details(string host = default(string))
        {
            Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.ViewDetails;
            var vm = new Elmah.AspNetMvcCoreViewModel.ElmahHost.ItemVM();

            vm.SetServiceProvider(this._serviceProvider);
            await vm.Load(!string.IsNullOrEmpty(host), host, uiAction);

            vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Details, Elmah.Resx.UIStringResourcePerApp.ElmahHost);
            //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
            //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.Details, Elmah.Resx.UIStringResourcePerApp.ElmahHost);

            return(View(vm));
        }
        /// <summary>
        /// GET method of delete page of <see cref="ElmahModel.ElmahStatusCode"/>
        /// GET: /ElmahStatusCode/Delete/5
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> Delete(int?statusCode = default(int?))
        {
            Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Delete;
            using (var scope = _serviceProvider.CreateScope())
            {
                var vm = (Elmah.AspNetMvcCoreViewModel.ElmahStatusCode.ItemVM)scope.ServiceProvider.GetRequiredService(typeof(Elmah.AspNetMvcCoreViewModel.ElmahStatusCode.ItemVM));
                vm.SetServiceProvider(this._serviceProvider);
                await vm.Load(statusCode.HasValue, statusCode, uiAction);

                vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahStatusCode);
                //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
                //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.Delete, Elmah.Resx.UIStringResourcePerApp.ElmahStatusCode);
                return(View(vm));
            }
        }
Esempio n. 6
0
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> AddNew(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM vm)
        {
            try
            {
                //log.Info(string.Format("{0}: AddNew", Framework.Models.LoggingOptions.UI_Process_Started.ToString()));
                var entity = new Elmah.DataSourceEntities.ELMAH_Error();
                entity.CopyFrom <Elmah.EntityContracts.IELMAH_Error>(vm.Item);

                using (var scope = _serviceProvider.CreateScope())
                {
                    var serviceInstance = (Elmah.WcfContracts.IELMAH_ErrorService)scope.ServiceProvider.GetRequiredService(typeof(Elmah.WcfContracts.IELMAH_ErrorService));
                    var request         = new Elmah.CommonBLLEntities.ELMAH_ErrorRequestMessageBuiltIn();

                    request.Criteria.Add(entity);
                    var _Response = await serviceInstance.UpsertEntity(request);

                    if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK)
                    {
                        TempData[TempDataKey_ELMAH_ErrorController_Copy] = null;
                        TempData.Remove(TempDataKey_ELMAH_ErrorController_Copy);
                        //log.Info(string.Format("{0}: Insert", Framework.Models.LoggingOptions.UI_Process_Ended.ToString()));

                        return(Redirect(Request.Headers["Referer"].ToString()));
                    }
                    else
                    {
                        vm = await Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM.CreateNewViewModel(this._serviceProvider, vm.Item);

                        vm.StatusOfResult        = _Response.BusinessLogicLayerResponseStatus;
                        vm.StatusMessageOfResult = _Response.ServerErrorMessage;
                        //log.Error(string.Format("{0}: AddNew: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), _Response.ServerErrorMessage));
                        return(View(vm));
                    }
                }
            }
            catch (Exception ex)
            {
                Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Create;
                var entity = CreateEmptyEntityOrGetFromTempData(TempDataKey_ELMAH_ErrorController_Copy);
                vm = await Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM.CreateNewViewModel(this._serviceProvider, entity);

                vm.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                vm.StatusMessageOfResult = ex.Message;
                vm.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(Elmah.AspNetMvcCoreViewModel.ELMAH_Error.ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                //log.Error(string.Format("{0}: AddNew: {1}", Framework.Models.LoggingOptions.Business_Logic_Layer_Process_Failed.ToString(), ex.Message));
                return(View(vm));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// GET method of editing page of <see cref="ElmahModel.ElmahHost"/>.
        /// GET: /ElmahHost/Edit/5
        /// </summary>
        /// <returns></returns>
        //[Authorize(Roles = Elmah.MvcCore.Security.RolesCombination.AllRoles)]
        public async Task <ActionResult> Edit(string host = default(string))
        {
            Framework.ViewModels.UIAction uiAction = Framework.ViewModels.UIAction.Update;
            using (var scope = _serviceProvider.CreateScope())
            {
                var vm = (Elmah.AspNetMvcCoreViewModel.ElmahHost.ItemVM)scope.ServiceProvider.GetRequiredService(typeof(Elmah.AspNetMvcCoreViewModel.ElmahHost.ItemVM));

                vm.SetServiceProvider(this._serviceProvider);
                await vm.Load(!string.IsNullOrEmpty(host), host, uiAction);

                vm.ContentData.Title = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ElmahHost);
                //TODO: create a new new entry in xxx.UIStringResourceExt.resx file if you need, and uncomment next line, reference resource key here, then add in .cshtml file.
                //vm.ContentData.Summary = string.Format("{0} {1}", Framework.Resx.UIStringResource.Edit, Elmah.Resx.UIStringResourcePerApp.ElmahHost);

                return(View(vm));
            }
        }
Esempio n. 8
0
        public virtual async Task Load(bool isToCompareStatusCode, int?statusCode
                                       , Framework.ViewModels.UIAction uiAction)
        {
            using (var scope = this.ServiceProvider.CreateScope())
            {
                try
                {
                    //log.Info(string.Format("{0}: Details", Framework.LoggingOptions.UI_Process_Started.ToString()));

                    var thisService = scope.ServiceProvider.GetRequiredService <Elmah.WcfContracts.IElmahStatusCodeService>();
                    var _Response   = await thisService.GetMessageOfEntityByIdentifier(isToCompareStatusCode, statusCode, -1, -1, null);

                    if (_Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK || _Response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.UIProcessReady)
                    {
                        this.Item = _Response.Message[0];
                        this.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Launch);
                        //log.Info(string.Format("{0}: {1}", uiAction, Framework.Models.LoggingOptions.UI_Process_Succeeded.ToString()));
                        await this.LoadExtraData(uiAction);
                    }
                    else
                    {
                        this.StatusOfResult        = _Response.BusinessLogicLayerResponseStatus;
                        this.StatusMessageOfResult = _Response.ServerErrorMessage;
                        this.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                        //log.Error(string.Format("{0}: {1}, {2}, {3}", uiAction, Framework.Models.LoggingOptions.UI_Process_Failed.ToString(), this.StatusOfResult, this.StatusMessageOfResult));
                    }
                }
                catch (Exception ex)
                {
                    this.StatusOfResult        = Framework.Services.BusinessLogicLayerResponseStatus.MessageErrorDetected;
                    this.StatusMessageOfResult = ex.Message;
                    this.UIActionStatusMessage = new Framework.ViewModels.UIActionStatusMessage(typeof(ItemVM).FullName, uiAction.ToString(), uiAction, Framework.ViewModels.UIActionStatus.Failed);
                    //log.Error(string.Format("{0}: {1}, {2}, {3}", uiAction, Framework.Models.LoggingOptions.UI_Process_Failed.ToString(), this.StatusOfResult, this.StatusMessageOfResult));
                }
            }
        }