コード例 #1
0
        private async Task CreativeModelSaveAsync(CreativeModel model, Creative creative)
        {
            creative.CreativeTitle                    = model.CreativeTitle;
            creative.ModelType                        = model.ModelType;
            creative.TemplateEngineType               = model.TemplateEngineType == TemplateEngineTypes.Undefined ? TemplateEngineTypes.DollarString : model.TemplateEngineType;
            creative.CreativeSettings.EmailSubject    = model.CreativeSettings.EmailSubject;
            creative.CreativeSettings.EmailHtmlBody   = model.CreativeSettings.EmailHtmlBody;
            creative.CreativeSettings.EmailTextBody   = model.CreativeSettings.EmailTextBody;
            creative.CreativeSettings.TextMessageBody = model.CreativeSettings.TextMessageBody;
            bool dirty = true;

            if (creative.CreativeId < 1)
            {
                await Rdb.SaveChangesAsync();

                dirty = false;
            }
            if (model.NewAttachments != null)
            {
                foreach (var newAttachment in model.NewAttachments)
                {
                    var pointer = await Blobs.StoreFileAsync(false, BlobStorageServices.Roots.Portal, newAttachment, creative.AttachmentPrefix + Path.GetFileName(newAttachment.FileName), false);

                    creative.CreativeSettings.Attachments.Add(pointer);
                    dirty = true;
                }
            }
            if (dirty)
            {
                await Rdb.SaveChangesAsync();
            }
        }
コード例 #2
0
        async void ITenantJobs.DownloadTableauPdfContinuationJobAsync()
        {
            string resultData      = this.GetParentJobResultData();
            var    downloadOptions = JsonConvert.DeserializeObject <DownloadPdfOptions>(resultData);
            var    pdfBytes        = await TableauVisualService.DownloadPdfAsync(downloadOptions);

            var dateTime = DateTime.UtcNow;
            var blob     = await BlobStorageService.StoreFileAsync(
                true,
                BlobStorageServices.Roots.User,
                new BasicFormFile(pdfBytes)
            {
                ContentDisposition = ContentDisposition.Attachment,
                ContentType        = MimeType.Application.Pdf,
                FileName           = $"{downloadOptions.WorkbookName}{MimeType.Application.Pdf.PrimaryFileExtension}",
                Name = $"{downloadOptions.WorkbookName}{MimeType.Application.Pdf.PrimaryFileExtension}",
            },
                $"{downloadOptions.WorkbookName.RemoveSpecialCharacters()}-{dateTime.ToString().RemoveSpecialCharacters()}{MimeType.Application.Pdf.PrimaryFileExtension}");

            PostResult(blob);
        }
コード例 #3
0
        public async Task <IActionResult> PortalSettings(
            int id,
            //            [Bind("logoFile")]
            //           IFormFile logoFile,
            [Bind(
                 nameof(PortalOptionsModel.RegisterMessage),
                 nameof(PortalOptionsModel.LoginMessage),
                 nameof(PortalOptionsModel.HomeMessage),
                 nameof(PortalOptionsModel.CopyrightMessage),
                 nameof(PortalOptionsModel.AboutMessage),
                 nameof(PortalOptionsModel.CssFile),
                 nameof(PortalOptionsModel.LogoFile),
                 nameof(PortalOptionsModel.FaviconFile),
                 nameof(PortalOptionsModel.JavascriptFile),
                 nameof(PortalOptionsModel.PrimaryColor),
                 nameof(PortalOptionsModel.SecondaryColor)
                 )]
            PortalOptionsModel model)
        {
            var app = await GetApplicationAsync(id);

            if (app == null)
            {
                return(NotFound());
            }
            SetHeroLayoutViewData(app, PageKeys.PortalSettings);

            if (ModelState.IsValid)
            {
                var po = app.AppSettings.PortalOptions ?? new PortalConfig();
                app.AppSettings.PortalOptions = po;
                po.RegisterMessage            = model.RegisterMessage;
                po.LoginMessage     = model.LoginMessage;
                po.HomeMessage      = model.HomeMessage;
                po.CopyrightMessage = model.CopyrightMessage;
                po.AboutMessage     = model.AboutMessage;
                po.PrimaryColor     = model.PrimaryColor;
                po.SecondaryColor   = model.SecondaryColor;
                if (model.LogoFile != null)
                {
                    po.LogoLink = (await Blobs.StoreFileAsync(false, BlobStorageServices.Roots.Portal, model.LogoFile, "customlogo" + Path.GetExtension(model.LogoFile.FileName), true)).Uri;
                }
                if (model.FaviconFile != null)
                {
                    po.FaviconLink = (await Blobs.StoreFileAsync(false, BlobStorageServices.Roots.Portal, model.FaviconFile, "customfavicon" + Path.GetExtension(model.FaviconFile.FileName), true)).Uri;
                }
                if (model.CssFile != null)
                {
                    po.CssLink = (await Blobs.StoreFileAsync(false, BlobStorageServices.Roots.Portal, model.CssFile, "customcss" + Path.GetExtension(model.CssFile.FileName), true)).Uri;
                }
                if (model.JavascriptFile != null)
                {
                    po.JavascriptLink = (await Blobs.StoreFileAsync(false, BlobStorageServices.Roots.Portal, model.JavascriptFile, "customjs" + Path.GetExtension(model.JavascriptFile.FileName), true)).Uri;
                }
                Rdb.Update(app);
                await Rdb.SaveChangesAsync();

                SetToast(AspHelpers.ToastMessages.Saved);
                return(RedirectToAction(ActionNames.ApplicationBasics));
            }
            return(View(model));
        }