public async Task <IActionResult> InitAppAuditAsync(Int32 appId) { AppDto app = null; var user = await GetUserContextAsync(); var response = new ResponseModel <dynamic>(); if (appId != 0)// 如果appId为0则是新创建app { app = await _appServices.GetAppAsync(appId, user.Id); if (app == null) { response.IsSuccess = false; response.Message = "没有获取到指定的应用"; return(Json(response)); } } var uniqueToken = CreateUniqueTokenAsync(user.Id); var appTypes = await _appServices.GetAppTypesAsync(); response.Model = new { app, uniqueToken, appTypes }; response.IsSuccess = true; response.Message = "应用审核初始化成功"; return(Json(response)); }
private AppDto GetApp(Ctx flags) { if (App == null) { return(null); } var result = new AppDto { Id = App.AppId, Url = (App as Apps.IApp)?.Path, Name = App.Name, Folder = App.Folder, }; if (!flags.HasFlag(Ctx.AppAdvanced)) { return(result); } result.GettingStartedUrl = GetGettingStartedUrl(); result.Identifier = _appToLaterInitialize.AppGuid; result.Permissions = new HasPermissionsDto { Count = App.Metadata.Permissions.Count() }; return(result); }
/// <summary> /// Executes the specified context. /// </summary> /// <param name="context">The context.</param> public void Execute(JobExecutionContext context) { string applicationName = context.JobDetail.Group; if (String.IsNullOrEmpty(applicationName) || applicationName == "all") // index all applications { AppDto dto = AppContext.Current.GetApplicationDto(); if (dto.Application.Count > 0) { foreach (AppDto.ApplicationRow row in dto.Application) { RemoveExpired(row.ApplicationId); } } } else { AppDto dto = AppContext.Current.GetApplicationDto(applicationName); if (dto.Application.Count > 0) { RemoveExpired(dto.Application[0].ApplicationId); } } }
private async Task ExpenseDetail(AppDto appInfo, ExpenseDetailEntity entity) { await UnitOfWorkService.Execute(async() => { var id = await _expenseDetailRepository.InsertAndGetIdAsync(entity); var orgId = _staffRepository.GetOrgId(appInfo.SalesMan).OrgId; var dataInOrg = new DataInOrgEntity { DataId = id.ToString(), DataType = (int)DataType.ExpenseDetail, OrgId = orgId, RoleId = ((int)UserType.Admin).ToString() }; var dataRlt = _dataInOrgRepository.Inserts(dataInOrg); if (id <= 0 && !dataRlt) { return(new Result { Status = false, Message = "数据库操作失败" }); } return(new Result { Status = true }); }); }
public void SaveApp_sends_app_to_repository() { var viewModel = new AppViewModel { Id = Guid.NewGuid(), Name = "Name", Description = "Description", Url = "http://www.test.com" }; var dto = new AppDto { Id = viewModel.Id, Name = viewModel.Name, Description = viewModel.Description, BaseUrl = viewModel.Url }; App app = null; var repository = Substitute.For <IAppRepository> (); repository.Store(Arg.Do <App> (a => app = a)); repository.GetByIdentifier(Arg.Any <AppIdentifier>()).Returns(new App(dto)); var appService = new AppService(repository); appService.SaveApp(viewModel); app.ShouldNotBeNull(); app.Identifier.Id.ShouldBe(viewModel.Id); app.Metadata.Name.ShouldBe(viewModel.Name); app.Metadata.Description.ShouldBe(viewModel.Description); app.Url.BaseUrl.ShouldBe(viewModel.Url); }
/// <summary> /// Gets the application dto. /// </summary> /// <param name="appId">The app id.</param> /// <returns></returns> public static AppDto GetApplicationDto(Guid appId) { // Assign new cache key, specific for site guid and response groups requested //string cacheKey = CoreCache.CreateCacheKey("Expression", ExpressionId.ToString()); AppDto dto = null; // check cache first //object cachedObject = MarketingCache.Get(cacheKey); //if (cachedObject != null) // dto = (ExpressionDto)cachedObject; // Load the object if (dto == null) { AppAdmin admin = new AppAdmin(); admin.LoadByApplication(appId); dto = admin.CurrentDto; // Insert to the cache collection //MarketingCache.Insert(cacheKey, dto, MarketingConfiguration.CacheConfig.ExpressionCollectionTimeout); } dto.AcceptChanges(); return(dto); }
public Result Update(AppDto dto) { try { var entity = dto.MapTo <AppEntity>(); var rlt = UnitOfWorkService.Execute(() => _repo.Update(entity)); if (!rlt) { return new Result { Status = false, Message = "数据库操作失败" } } ; var json = Serializer.Serialize(dto); var url = _configuration.GetValue("WebApi:url", "http://localhost:15002/sync"); var http = _hxHttpClientFactory.CreateHttpClient(); http.SendAsync(url, Serializer.Serialize(new CusNotification { Method = 12, Body = json })); Logger.Info($"app同步结果update:{json}"); return(new Result { Status = true }); } catch (Exception ex) { Logger.Error("update app error", ex); return(new Result { Status = false, Message = "内部服务器错误" }); } }
public async Task <IActionResult> InitUserAppManageInfoAsync(Int32 appId) { AppDto appDto = null; var response = new ResponseModel <dynamic>(); var userContext = await GetUserContextAsync(); if (appId != 0)// 如果appId为0则是新创建app { appDto = await _appServices.GetAppAsync(appId, userContext.Id); if (appDto == null) { response.IsSuccess = false; response.Message = "未获取到我的应用"; return(Json(response)); } } var appTypes = await _appServices.GetAppTypesAsync(); if (!userContext.IsAdmin) { appTypes = appTypes.Where(w => !w.IsSystem).ToList(); } var uniqueToken = CreateUniqueTokenAsync(userContext.Id); response.Model = new { appTypes, UserId = userContext.Id, appDto }; response.IsSuccess = true; response.Message = "我的应用初始化成功"; return(Json(response)); }
/// <summary> /// 封装从页面传入的forms表单到AppDto类型 /// </summary> /// <param name="forms"></param> /// <returns></returns> private static AppDto WrapperAppDto(IFormCollection forms) { var appDto = new AppDto { IconUrl = forms["val_icon"], Name = forms["val_name"], AppTypeId = Int32.Parse(forms["val_app_category_id"]), AppUrl = forms["val_url"], Width = Int32.Parse(forms["val_width"]), Height = Int32.Parse(forms["val_height"]), AppStyle = EnumExtensions.ToEnum <AppStyle>(forms["val_type"]), Remark = forms["val_remark"], AppAuditState = EnumExtensions.ToEnum <AppAuditState>(Int32.Parse(forms["val_verifytype"])), AppReleaseState = AppReleaseState.UnRelease, //未发布 IsIconByUpload = Int32.Parse(forms["isIconByUpload"]) == 1 }; if (appDto.AppStyle == AppStyle.App) { appDto.IsResize = Int32.Parse(forms["val_isresize"]) == 1; appDto.IsOpenMax = Int32.Parse(forms["val_isopenmax"]) == 1; appDto.IsFlash = Int32.Parse(forms["val_isflash"]) == 1; appDto.IsSetbar = Int32.Parse(forms["val_issetbar"]) == 1; } if ((forms["val_Id"] + "").Length > 0) { appDto.Id = Int32.Parse(forms["val_Id"]); } return(appDto); }
public async Task <ActionResult> UpdateApp([FromBody] AppDto appDto) { try { await CheckPermission(Permissions.SuperUser); await appsBusiness.UpdateApp(appDto); return(Ok()); } catch (KeyNotFoundException ex) { logger.LogWarning(ex, ex.Message); return(NotFound()); } catch (AccessViolationException ex) { logger.LogError(ex, ex.Message); return(StatusCode(403, ex.Message)); } catch (Exception ex) { logger.LogError(ex, ex.Message); return(StatusCode(500)); } }
/// <summary> /// Handles the Authenticate event of the LoginCtrl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.AuthenticateEventArgs"/> instance containing the event data.</param> void LoginCtrl_Authenticate(object sender, AuthenticateEventArgs e) { string appName = ((TextBox)LoginCtrl.FindControl("Application")).Text; AppDto dto = AppContext.Current.GetApplicationDto(appName); // If application does not exists or is not activa, prevent login if (dto == null || dto.Application.Count == 0 || !dto.Application[0].IsActive) { LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Application name is incorrect.", false); LoginCtrl.FailureText = "Login failed. Please try again."; return; } Membership.Provider.ApplicationName = appName; if (Membership.ValidateUser(LoginCtrl.UserName, LoginCtrl.Password)) { CHelper.CreateAuthenticationCookie(LoginCtrl.UserName, appName, LoginCtrl.RememberMeSet); string url = FormsAuthentication.GetRedirectUrl(LoginCtrl.UserName, LoginCtrl.RememberMeSet); LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", String.Empty, true); if (url.Contains(".axd") || url.Contains("/Apps/Core/Controls/Uploader/")) // prevent redirecting to report files { Response.Redirect("~/default.aspx"); } else { Response.Redirect(url); } } else { LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Login or password are incorrect.", false); LoginCtrl.FailureText = "Login failed. Please try again."; } }
public async Task AddApp(AppDto appDto) { var app = AppDtoToApp(appDto); app.Id = 0; app.IsMain = false; await appsRepository.AddApp(app); }
public async Task CreateNewAppAsync(AppDto appDto) { Check.IfNullOrZero(appDto); var app = appDto.ConvertToModel <AppDto, App>(); var internalApp = new App(app.Name, app.IconUrl, app.AppUrl, app.Width, app.Height, app.AppTypeId, app.AppAuditState, AppReleaseState.UnRelease, app.AppStyle, app.UserId, app.Remark, appDto.IsIconByUpload); await _appContext.CreateNewAppAsync(internalApp); }
public void Register(AppDto appDto) { var app = new App(appDto.Name, new ClientCredentials(appDto.AppId, appDto.AppSecret), new SignEndpoint(appDto.Signin, appDto.Signout)); this._documentStore.Save(app); }
public async Task <IActionResult> GetApps() { var subject = HttpContext.User.OpenIdSubject(); var entities = await appProvider.GetUserApps(subject); var response = entities.Select(a => AppDto.FromApp(a, subject, appPlansProvider)).ToList(); return(Ok(response)); }
private App AppDtoToApp(AppDto app) { return(new App() { Id = app.Id, Key = app.Key, Secret = app.Secret, Description = app.Description }); }
public IActionResult Modify(string id) { var dto = new AppDto(); if (id.IsNotNullOrEmpty()) { dto = Get(id); dto.AppTypeDesc = dto.AppType.GetDescription(); } return(View(dto)); }
private async Task <AppDto> InvokeCommandAsync(ICommand command) { var context = await CommandBus.PublishAsync(command); var userOrClientId = HttpContext.User.UserOrClientId() !; var result = context.Result <IAppEntity>(); var response = AppDto.FromApp(result, userOrClientId, appPlansProvider, Resources); return(response); }
private Task <AppDto> InvokeCommandAsync(ICommand command) { return(InvokeCommandAsync(command, x => { var userOrClientId = HttpContext.User.UserOrClientId() !; var isFrontend = HttpContext.User.IsInClient(DefaultClients.Frontend); return AppDto.FromApp(x, userOrClientId, isFrontend, appPlansProvider, Resources); })); }
public async Task <IActionResult> PostApp([FromBody] CreateAppDto request) { var context = await CommandBus.PublishAsync(request.ToCommand()); var userOrClientId = HttpContext.User.UserOrClientId(); var userPermissions = HttpContext.Permissions(); var result = context.Result <IAppEntity>(); var response = AppDto.FromApp(result, userOrClientId, userPermissions, appPlansProvider, this); return(CreatedAtAction(nameof(GetApps), response)); }
public static Task SaveAppAsync(AppDto appDto) { return(Task.Run(() => { using (var db = new ConfigCenterConnection()) { var app = Mapper.Map <AppDto, App>(appDto); db.App.Add(app); db.SaveChanges(); } })); }
private void Valid(AppDto dto) { var app = this._appService.GetById(dto.AppId); Assert.NotNull(app); this.Show(app); Assert.Equal(dto.AppId, app.AppId); Assert.Equal(dto.AppSecret, app.AppSecret); Assert.NotEqual(dto.CreateTime, app.CreateTime); Assert.Equal(dto.Name, app.Name); Assert.Equal(dto.Signin, app.Signin); Assert.Equal(dto.Signout, app.Signout); }
public async Task <IActionResult> GetApps() { var userOrClientId = HttpContext.User.UserOrClientId(); var userPermissions = HttpContext.Permissions(); var apps = await appProvider.GetUserApps(userOrClientId, userPermissions); var response = apps.ToArray(a => AppDto.FromApp(a, userOrClientId, userPermissions, appPlansProvider, this)); Response.Headers[HeaderNames.ETag] = response.ToManyEtag(); return(Ok(response)); }
public IActionResult GetApp(string app) { var response = Deferred.Response(() => { var userOrClientId = HttpContext.User.UserOrClientId() !; return(AppDto.FromApp(App, userOrClientId, appPlansProvider, Resources)); }); Response.Headers[HeaderNames.ETag] = App.ToEtag(); return(Ok(response)); }
public async Task <IActionResult> GetApps() { var userId = HttpContext.User.OpenIdSubject(); var userPermissions = HttpContext.User.Permissions(); var entities = await appProvider.GetUserApps(userId, userPermissions); var response = entities.ToArray(a => AppDto.FromApp(a, userId, userPermissions, appPlansProvider)); Response.Headers["ETag"] = response.ToManyEtag(); return(Ok(response)); }
public Result Add(AppDto dto, UserType roleId)//TODO:缓存同步 { try { var id = ""; var entity = dto.MapTo <AppEntity>(); var rlt = UnitOfWorkService.Execute(() => { id = _repo.InsertAndGetId(entity); var orgId = _staffRepository.GetOrgId(dto.SalesMan).OrgId; var dataInOrg = new DataInOrgEntity { DataId = id, DataType = (int)DataType.App, OrgId = orgId, RoleId = ((int)roleId).ToString() }; var dataRlt = _dataInOrgRepository.Inserts(dataInOrg); return(id.IsNotNullOrEmpty() && dataRlt); }); if (!rlt) { return new Result { Status = false, Message = "数据库操作失败" } } ; dto.Id = id; var json = Serializer.Serialize(dto); var url = _configuration.GetValue("WebApi:url", "http://localhost:15002/sync"); var http = _hxHttpClientFactory.CreateHttpClient(); http.SendAsync(url, Serializer.Serialize(new CusNotification { Method = 11, Body = json })); Logger.Info($"app同步结果add:{json}"); //_mediator.Publish(syncModel); return(new Result { Status = true }); } catch (Exception ex) { Logger.Error("add app error", ex); return(new Result { Status = false, Message = "内部服务器错误" }); } }
public async Task <IActionResult> Edit(AppDto dto) { JsonModel jm = new JsonModel(); dto.UpdateTime = DateTime.Now; Usy_App app = AutoMapper.Mapper.Map <Usy_App>(dto); app = await _appRepository.UpdateAsync(app); jm.Statu = "y"; jm.Msg = "修改成功!"; return(Json(jm)); }
public JsonResult SaveApp(AppDto appDto) { ResponseResult responseResult; try { AppBusiness.SaveApp(appDto); responseResult = new ResponseResult(true, ""); } catch (Exception) { responseResult = new ResponseResult(false, ""); } return(Json(responseResult, JsonRequestBehavior.AllowGet)); }
public async Task <IActionResult> GetApps() { var subject = User.OpenIdSubject(); if (string.IsNullOrWhiteSpace(subject)) { return(Ok(new List <AppDto>())); } var apps = await appStore.QueryAsync(subject, HttpContext.RequestAborted); var response = apps.Select(x => AppDto.FromDomainObject(x, subject)).ToArray(); return(Ok(response)); }
public IActionResult GetApp(string app) { var response = Deferred.Response(() => { var userOrClientId = HttpContext.User.UserOrClientId() !; var isFrontend = HttpContext.User.IsInClient(DefaultClients.Frontend); return(AppDto.FromDomain(App, userOrClientId, isFrontend, Resources)); }); Response.Headers[HeaderNames.ETag] = App.ToEtag(); return(Ok(response)); }