private void InitScript() { var script = new StringBuilder(); FolderType folderType; if (Enum.TryParse(Request[RootParam], true, out folderType)) { object rootId = null; switch (folderType) { case FolderType.COMMON: rootId = Classes.Global.FolderCommon; break; case FolderType.USER: rootId = Classes.Global.FolderMy; break; case FolderType.Projects: rootId = Classes.Global.FolderProjects; break; } if (rootId != null) { script.AppendFormat("jq(\"#fileSelectorTree > ul > li.tree-node:not([data-id=\\\"{0}\\\"])\").remove();", rootId); } } if (!string.IsNullOrEmpty(RequestExt)) { script.AppendFormat(";ASC.Files.FileSelector.filesFilter = ASC.Files.Constants.FilterType.ByExtension;" + "ASC.Files.FileSelector.filesFilterText = \"{0}\";", RequestExt.Replace("\"", "\\\"")); } if (RequestType != FilterType.None) { script.AppendFormat("ASC.Files.FileSelector.filesFilter = ASC.Files.Constants.FilterType[\"{0}\"] || ASC.Files.Constants.FilterType.None;", RequestType); } var originForPost = "*"; if (FromEditor && !FilesLinkUtility.DocServiceApiUrl.StartsWith("/")) { var origin = new Uri(FilesLinkUtility.DocServiceApiUrl ?? ""); originForPost = origin.Scheme + "://" + origin.Host + ":" + origin.Port; } script.AppendFormat("ASC.Files.FileChoice.init(\"{0}\", ({1} == true), \"{2}\", ({3} == true), \"{4}\", ({5} == true));", (Request[FilesLinkUtility.FolderId] ?? "").Replace("\"", "\\\""), OnlyFolder.ToString().ToLower(), (Request[ThirdPartyParam] ?? "").ToLower().Replace("\"", "\\\""), FromEditor.ToString().ToLower(), originForPost, DisplayPrivacy.ToString().ToLower()); Page.RegisterInlineScript(script.ToString()); }
protected override Task WriteBody (TestContext ctx, CancellationToken cancellationToken) { switch (TestRunner.EffectiveType) { case HttpRequestTestType.PutChunked: case HttpRequestTestType.PutChunkDontCloseRequest: return PutChunked (); case HttpRequestTestType.EntityTooBig: return EntityTooBig (); case HttpRequestTestType.PostContentLength: return PostContentLength (); case HttpRequestTestType.ClientAbortsPost: return ClientAbortsPost (); default: return base.WriteBody (ctx, cancellationToken); } async Task EntityTooBig () { var stream = await RequestExt.GetRequestStreamAsync ().ConfigureAwait (false); await Content.WriteToAsync (ctx, stream, cancellationToken).ConfigureAwait (false); // This throws on .NET try { stream.Dispose (); } catch { } } async Task PostContentLength () { using (var stream = await RequestExt.GetRequestStreamAsync ().ConfigureAwait (false)) { await AbstractConnection.WaitWithTimeout (ctx, 1500, Handler.WaitUntilReady ()); await Content.WriteToAsync (ctx, stream, cancellationToken); stream.Flush (); } } async Task PutChunked () { var stream = await RequestExt.GetRequestStreamAsync ().ConfigureAwait (false); try { await Content.WriteToAsync (ctx, stream, cancellationToken).ConfigureAwait (false); await stream.FlushAsync (); } finally { if (TestRunner.EffectiveType == HttpRequestTestType.PutChunked) stream.Dispose (); } } async Task ClientAbortsPost () { var stream = await RequestExt.GetRequestStreamAsync ().ConfigureAwait (false); try { stream.Dispose (); } catch (Exception ex) { ctx.LogDebug (4, $"{ME} GOT EX: {ex.Message}"); } } }
private void InitScript() { Page.RegisterBodyScripts(PathProvider.GetFileStaticRelativePath("filechoice.js")); var script = new StringBuilder(); FolderType folderType; if (Enum.TryParse(Request[RootParam], true, out folderType)) { object rootId = null; switch (folderType) { case FolderType.COMMON: rootId = Classes.Global.FolderCommon; break; case FolderType.USER: rootId = Classes.Global.FolderMy; break; } if (rootId != null) { script.AppendFormat("jq(\"#fileSelectorTree > ul > li.tree-node:not([data-id=\\\"{0}\\\"])\").remove();", rootId); } } if (!string.IsNullOrEmpty(RequestExt)) { script.AppendFormat(";ASC.Files.FileSelector.filesFilter = ASC.Files.Constants.FilterType.ByExtension;" + "ASC.Files.FileSelector.filesFilterText = \"{0}\";", RequestExt.Replace("\"", "\\\"")); } FilterType filter; if (Enum.TryParse(Request[DocumentTypeParam], out filter)) { script.AppendFormat("ASC.Files.FileSelector.filesFilter = ASC.Files.Constants.FilterType[\"{0}\"] || ASC.Files.Constants.FilterType.None;", filter); } script.AppendFormat("ASC.Files.FileChoice.init(\"{0}\", ({1} == true), ({2} == true), ({3} == true));", Request[FilesLinkUtility.FolderId], OnlyFolder.ToString().ToLower(), (!string.IsNullOrEmpty(Request[ThirdPartyParam])).ToString().ToLower(), (!string.IsNullOrEmpty(Request[MailMergeParam])).ToString().ToLower()); Page.RegisterInlineScript(script.ToString()); }
public override async Task<Response> SendAsync (TestContext ctx, CancellationToken cancellationToken) { var portable = DependencyInjector.Get<IPortableSupport> (); if (TestRunner.EffectiveType == HttpRequestTestType.CloseRequestStream) { Request.Method = "POST"; RequestExt.SetContentLength (16384); var stream = await RequestExt.GetRequestStreamAsync ().ConfigureAwait (false); try { portable.Close (stream); throw ctx.AssertFail ("Expected exception."); } catch (Exception ex) { return new SimpleResponse (this, HttpStatusCode.InternalServerError, null, ex); } } return await base.SendAsync (ctx, cancellationToken).ConfigureAwait (false); }
public async Task OnPost() { var callback = await RequestExt.GetObject <PaymentViewModel>(Request.Body); if (!(callback is null)) { var added = await _dataRepository.CreateOrderHistoryAsync( new Order { OrderMnemonic = callback.Data.Id, Status = callback.Data.Status, Email = callback.Data.BuyerFields.BuyerEmail, BtcPrice = callback.Data.BtcPaid, Rate = callback.Data.Rate.ToString() }); if (added == 1) { var msg = $"Order {callback.Data.Id} ({callback.Data.Status}) added for {callback.Data.BuyerFields.BuyerEmail}"; _logger.LogInformation(msg); _pushoverNotification.Send("GDI Order (new)", $"{msg}"); if (callback.Data.Status == "paid") { var user = await _dataRepository.GetUserAsync(callback.Data.BuyerFields.BuyerEmail); if (!(user is null)) { var addUserToCourse = await _dataRepository.AddUserToCourseAsync( new UserCourse { UserId = user.UserId, CourseId = 1 // GDI only now }); _pushoverNotification.Send("GDI Order (paid)", $"{msg}"); if (addUserToCourse == 1) { var link = $"https://app.cryptodev.tv/student/{user.Guid}"; var email = await _emailNotification.SendAsync( "GitHub dla Inwestorów już dostępny dla Ciebie", $"Dziękuje za zakup. Kurs dostępny tutaj: {link}", $"Dziękuje za zakup. Kurs dostępny <a href='{link}'>tutaj</a>", new string[] { user.Email }); if (email.IsSuccess) { _pushoverNotification.Send("GDI Order (sent)", $"{msg}"); } else { _logger.LogWarning($"{email.Message}"); _pushoverNotification.Send("GDI Error (mail)", $"{email.Message}"); } } } else { var err1 = $"User {callback.Data.BuyerFields.BuyerEmail} not assigned for course"; _logger.LogWarning($"{err1}"); _pushoverNotification.Send("GDI Error (assigned)", $"{err1}"); } } }