Exemple #1
0
        public async virtual Task<JsonResult> ChangeProfilePicture()
        {
            try
            {
                //Check input
                if (Request.Files.Count <= 0 || Request.Files[0] == null)
                {
                    throw new UserFriendlyException(L("ProfilePicture_Change_Error"));
                }

                var file = Request.Files[0];

                if (file.ContentLength > 30720) //30KB.
                {
                    throw new UserFriendlyException(L("ProfilePicture_Warn_SizeLimit"));
                }

                //Get user
                var user = await _userManager.GetUserByIdAsync(AbpSession.GetUserId());

                //Delete old picture
                if (user.ProfilePictureId.HasValue)
                {
                    await _binaryObjectManager.DeleteAsync(user.ProfilePictureId.Value);
                }

                //Save new picture
                var storedFile = new BinaryObject(file.InputStream.GetAllBytes());
                await _binaryObjectManager.SaveAsync(storedFile);

                //Update new picture on the user
                user.ProfilePictureId = storedFile.Id;

                //Return success
                return Json(new MvcAjaxResponse());
            }
            catch (UserFriendlyException ex)
            {
                //Return error message
                return Json(new MvcAjaxResponse(new ErrorInfo(ex.Message)));
            }
        }
Exemple #2
0
        public async Task <JsonResult> UploadCustomCss()
        {
            try
            {
                var cssFile = Request.Form.Files.First();

                //Check input
                if (cssFile == null)
                {
                    throw new UserFriendlyException(L("File_Empty_Error"));
                }

                if (cssFile.Length > 1048576) //1MB
                {
                    throw new UserFriendlyException(L("File_SizeLimit_Error"));
                }

                byte[] fileBytes;
                using (var stream = cssFile.OpenReadStream())
                {
                    fileBytes = stream.GetAllBytes();
                }

                var cssFileObject = new BinaryObject(AbpSession.GetTenantId(), fileBytes);
                await _binaryObjectManager.SaveAsync(cssFileObject);

                var tenant = await _tenantManager.GetByIdAsync(AbpSession.GetTenantId());

                tenant.CustomCssId = cssFileObject.Id;

                return(Json(new AjaxResponse(new { id = cssFileObject.Id })));
            }
            catch (UserFriendlyException ex)
            {
                return(Json(new AjaxResponse(new ErrorInfo(ex.Message))));
            }
        }
 public Task SaveAsync(BinaryObject file)
 {
     return _binaryObjectRepository.InsertAsync(file);
 }
        private async Task SetRandomProfilePictureAsync(User user)
        {
            try
            {
                //Save a random profile picture
                var storedFile = new BinaryObject(user.TenantId, GetRandomProfilePictureBytes());
                await _binaryObjectManager.SaveAsync(storedFile);

                //Update new picture on the user
                user.ProfilePictureId = storedFile.Id;
                await CurrentUnitOfWork.SaveChangesAsync();
            }
            catch
            {
                //we can ignore this exception                
            }
        }
        public async Task UpdateProfilePicture(UpdateProfilePictureInput input)
        {
            var tempProfilePicturePath = Path.Combine(_appFolders.TempFileDownloadFolder, input.FileName);

            byte[] byteArray;

            using (var fsTempProfilePicture = new FileStream(tempProfilePicturePath, FileMode.Open))
            {
                using (var bmpImage = new Bitmap(fsTempProfilePicture))
                {
                    var width = input.Width == 0 ? bmpImage.Width : input.Width;
                    var height = input.Height == 0 ? bmpImage.Height : input.Height;
                    var bmCrop = bmpImage.Clone(new Rectangle(input.X, input.Y, width, height), bmpImage.PixelFormat);

                    using (var stream = new MemoryStream())
                    {
                        bmCrop.Save(stream, bmpImage.RawFormat);
                        stream.Close();
                        byteArray = stream.ToArray();
                    }
                }
            }

            if (byteArray.LongLength > 102400) //100 KB
            {
                throw new UserFriendlyException(L("ResizedProfilePicture_Warn_SizeLimit"));
            }

            var user = await UserManager.GetUserByIdAsync(AbpSession.GetUserId());

            if (user.ProfilePictureId.HasValue)
            {
                await _binaryObjectManager.DeleteAsync(user.ProfilePictureId.Value);
            }

            var storedFile = new BinaryObject(AbpSession.TenantId, byteArray);
            await _binaryObjectManager.SaveAsync(storedFile);

            user.ProfilePictureId = storedFile.Id;

            FileHelper.DeleteIfExists(tempProfilePicturePath);
        }
 public ComponentInfo GetComponentInfo(string subscriberID, string packageID, string templateName, bool includeDialogs, string billingRef, System.DateTime timestamp, BinaryObject templatePackage, string hmac)
 {
     return(base.Channel.GetComponentInfo(subscriberID, packageID, templateName, includeDialogs, billingRef, timestamp, templatePackage, hmac));
 }
 public BinaryObject[] GetInterview(string subscriberID, string packageID, string templateName, BinaryObject[] answers, InterviewFormat format, string[] markedVariables, string tempImageUrl, System.Collections.Generic.Dictionary <string, string> settings, string billingRef, System.DateTime timestamp, BinaryObject templatePackage, string hmac)
 {
     return(base.Channel.GetInterview(subscriberID, packageID, templateName, answers, format, markedVariables, tempImageUrl, settings, billingRef, timestamp, templatePackage, hmac));
 }
 public AssemblyResult AssembleDocument(string subscriberID, string packageID, string templateName, BinaryObject[] answers, OutputFormat format, OutputOptions outputOptions, System.Collections.Generic.Dictionary <string, string> settings, string billingRef, System.DateTime timestamp, BinaryObject templatePackage, string hmac)
 {
     return(base.Channel.AssembleDocument(subscriberID, packageID, templateName, answers, format, outputOptions, settings, billingRef, timestamp, templatePackage, hmac));
 }
Exemple #9
0
    public static void Load()
    {
        path         = FileTools.CombinePath(TABLE_PATH, "actionaudioinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        ActionAudioInfo_ARRAY ActionAudioInfo_items = Serializer.Deserialize <ActionAudioInfo_ARRAY>(stream);

        for (int i = 0; i < ActionAudioInfo_items.items.Count; i++)
        {
            ActionAudioInfoDict.Add(ActionAudioInfo_items.items [i].id, ActionAudioInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "actorinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        ActorInfo_ARRAY ActorInfo_items = Serializer.Deserialize <ActorInfo_ARRAY>(stream);

        for (int i = 0; i < ActorInfo_items.items.Count; i++)
        {
            ActorInfoDict.Add(ActorInfo_items.items [i].id, ActorInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "audioenglishinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        AudioEnglishInfo_ARRAY AudioEnglishInfo_items = Serializer.Deserialize <AudioEnglishInfo_ARRAY>(stream);

        for (int i = 0; i < AudioEnglishInfo_items.items.Count; i++)
        {
            AudioEnglishInfoDict.Add(AudioEnglishInfo_items.items [i].id, AudioEnglishInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "audioinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        AudioInfo_ARRAY AudioInfo_items = Serializer.Deserialize <AudioInfo_ARRAY>(stream);

        for (int i = 0; i < AudioInfo_items.items.Count; i++)
        {
            AudioInfoDict.Add(AudioInfo_items.items [i].id, AudioInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "englishcoloursinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        EnglishColoursInfo_ARRAY EnglishColoursInfo_items = Serializer.Deserialize <EnglishColoursInfo_ARRAY>(stream);

        for (int i = 0; i < EnglishColoursInfo_items.items.Count; i++)
        {
            EnglishColoursInfoDict.Add(EnglishColoursInfo_items.items [i].id, EnglishColoursInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "englishletterinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        EnglishLetterInfo_ARRAY EnglishLetterInfo_items = Serializer.Deserialize <EnglishLetterInfo_ARRAY>(stream);

        for (int i = 0; i < EnglishLetterInfo_items.items.Count; i++)
        {
            EnglishLetterInfoDict.Add(EnglishLetterInfo_items.items [i].id, EnglishLetterInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "englishlevelinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        EnglishLevelInfo_ARRAY EnglishLevelInfo_items = Serializer.Deserialize <EnglishLevelInfo_ARRAY>(stream);

        for (int i = 0; i < EnglishLevelInfo_items.items.Count; i++)
        {
            EnglishLevelInfoDict.Add(EnglishLevelInfo_items.items [i].id, EnglishLevelInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "englishmainiteminfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        EnglishMainItemInfo_ARRAY EnglishMainItemInfo_items = Serializer.Deserialize <EnglishMainItemInfo_ARRAY>(stream);

        for (int i = 0; i < EnglishMainItemInfo_items.items.Count; i++)
        {
            EnglishMainItemInfoDict.Add(EnglishMainItemInfo_items.items [i].id, EnglishMainItemInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "expressphotosinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        ExpressPhotosInfo_ARRAY ExpressPhotosInfo_items = Serializer.Deserialize <ExpressPhotosInfo_ARRAY>(stream);

        for (int i = 0; i < ExpressPhotosInfo_items.items.Count; i++)
        {
            ExpressPhotosInfoDict.Add(ExpressPhotosInfo_items.items [i].id, ExpressPhotosInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "mainanimation");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        MainAnimation_ARRAY MainAnimation_items = Serializer.Deserialize <MainAnimation_ARRAY>(stream);

        for (int i = 0; i < MainAnimation_items.items.Count; i++)
        {
            MainAnimationDict.Add(MainAnimation_items.items [i].id, MainAnimation_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "mainiteminfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        MainItemInfo_ARRAY MainItemInfo_items = Serializer.Deserialize <MainItemInfo_ARRAY>(stream);

        for (int i = 0; i < MainItemInfo_items.items.Count; i++)
        {
            MainItemInfoDict.Add(MainItemInfo_items.items [i].id, MainItemInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "matrixlevel");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        MatrixLevel_ARRAY MatrixLevel_items = Serializer.Deserialize <MatrixLevel_ARRAY>(stream);

        for (int i = 0; i < MatrixLevel_items.items.Count; i++)
        {
            MatrixLevelDict.Add(MatrixLevel_items.items [i].id, MatrixLevel_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "matrixlevelinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        MatrixLevelInfo_ARRAY MatrixLevelInfo_items = Serializer.Deserialize <MatrixLevelInfo_ARRAY>(stream);

        for (int i = 0; i < MatrixLevelInfo_items.items.Count; i++)
        {
            MatrixLevelInfoDict.Add(MatrixLevelInfo_items.items [i].id, MatrixLevelInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "newbieinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        NewBieInfo_ARRAY NewBieInfo_items = Serializer.Deserialize <NewBieInfo_ARRAY>(stream);

        for (int i = 0; i < NewBieInfo_items.items.Count; i++)
        {
            NewBieInfoDict.Add(NewBieInfo_items.items [i].id, NewBieInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "newbiescript");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        NewBieScript_ARRAY NewBieScript_items = Serializer.Deserialize <NewBieScript_ARRAY>(stream);

        for (int i = 0; i < NewBieScript_items.items.Count; i++)
        {
            NewBieScriptDict.Add(NewBieScript_items.items [i].id, NewBieScript_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "sensitiveword");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        SensitiveWord_ARRAY SensitiveWord_items = Serializer.Deserialize <SensitiveWord_ARRAY>(stream);

        for (int i = 0; i < SensitiveWord_items.items.Count; i++)
        {
            SensitiveWordDict.Add(SensitiveWord_items.items [i].id, SensitiveWord_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "supermarketgoodsinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        SuperMarketGoodsInfo_ARRAY SuperMarketGoodsInfo_items = Serializer.Deserialize <SuperMarketGoodsInfo_ARRAY>(stream);

        for (int i = 0; i < SuperMarketGoodsInfo_items.items.Count; i++)
        {
            SuperMarketGoodsInfoDict.Add(SuperMarketGoodsInfo_items.items [i].id, SuperMarketGoodsInfo_items.items [i]);
        }
        path         = FileTools.CombinePath(TABLE_PATH, "timelineinfo");
        resource     = ResourceManager.Instance.GetResource(path, typeof(TextAsset), enResourceType.TableProto);
        binaryObject = resource.m_content as BinaryObject;
        stream       = new MemoryStream(binaryObject.m_data);
        TimelineInfo_ARRAY TimelineInfo_items = Serializer.Deserialize <TimelineInfo_ARRAY>(stream);

        for (int i = 0; i < TimelineInfo_items.items.Count; i++)
        {
            TimelineInfoDict.Add(TimelineInfo_items.items [i].id, TimelineInfo_items.items [i]);
        }
    }
Exemple #10
0
        public async Task <IActionResult> Attach(string emailId, [FromForm] IFormFile[] files)
        {
            try
            {
                if (files.Length == 0 || files == null)
                {
                    ModelState.AddModelError("Attach", "No files uploaded to attach");
                    return(BadRequest(ModelState));
                }

                var emailAttachments = new List <EmailAttachment>();

                foreach (var file in files)
                {
                    if (file == null)
                    {
                        ModelState.AddModelError("Save", "No file attached");
                        return(BadRequest(ModelState));
                    }

                    long size = file.Length;
                    if (size <= 0)
                    {
                        ModelState.AddModelError("File attachment", $"File size of file {file.FileName} cannot be 0");
                        return(BadRequest(ModelState));
                    }

                    string organizationId = binaryObjectManager.GetOrganizationId();
                    string apiComponent   = "EmailAPI";

                    //add file to binary objects (create entity and put file in EmailAPI folder in Server)
                    BinaryObject binaryObject = new BinaryObject()
                    {
                        Name                = file.FileName,
                        Folder              = apiComponent,
                        CreatedBy           = applicationUser?.UserName,
                        CreatedOn           = DateTime.UtcNow,
                        CorrelationEntityId = Guid.Parse(emailId)
                    };

                    string filePath = Path.Combine("BinaryObjects", organizationId, apiComponent, binaryObject.Id.ToString());
                    //upload file to Server
                    binaryObjectManager.Upload(file, organizationId, apiComponent, binaryObject.Id.ToString());
                    binaryObjectManager.SaveEntity(file, filePath, binaryObject, apiComponent, organizationId);
                    binaryObjectRepository.Add(binaryObject);

                    //create email attachment
                    EmailAttachment emailAttachment = new EmailAttachment()
                    {
                        Name                  = binaryObject.Name,
                        BinaryObjectId        = binaryObject.Id,
                        ContentType           = binaryObject.ContentType,
                        ContentStorageAddress = binaryObject.StoragePath,
                        SizeInBytes           = binaryObject.SizeInBytes,
                        EmailId               = Guid.Parse(emailId),
                        CreatedOn             = DateTime.UtcNow,
                        CreatedBy             = applicationUser?.UserName
                    };
                    repository.Add(emailAttachment);
                    emailAttachments.Add(emailAttachment);
                }
                return(Ok(emailAttachments));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Attach", ex.Message);
                return(BadRequest(ModelState));
            }
        }
        public async Task <IActionResult> Post(string id, [FromForm] IFormFile file)
        {
            try
            {
                if (file == null)
                {
                    ModelState.AddModelError("Save", "No asset uploaded");
                    return(BadRequest(ModelState));
                }

                long size = file.Length;
                if (size <= 0)
                {
                    ModelState.AddModelError("Asset Upload", $"File size of file {file.FileName} cannot be 0");
                    return(BadRequest(ModelState));
                }

                var existingAsset = repository.GetOne(Guid.Parse(id));
                if (existingAsset == null)
                {
                    ModelState.AddModelError("Asset", "Asset cannot be found or does not exist.");
                    return(NotFound(ModelState));
                }
                string organizationId = binaryObjectManager.GetOrganizationId();
                string apiComponent   = "AssetAPI";

                BinaryObject binaryObject = new BinaryObject();
                binaryObject.Name                = file.FileName;
                binaryObject.Folder              = apiComponent;
                binaryObject.CreatedOn           = DateTime.UtcNow;
                binaryObject.CreatedBy           = applicationUser?.UserName;
                binaryObject.CorrelationEntityId = existingAsset.Id;

                string filePath = Path.Combine("BinaryObjects", organizationId, apiComponent, binaryObject.Id.ToString());

                var existingbinary = binaryObjectRepo.Find(null, x => x.Folder?.ToLower(null) == binaryObject.Folder.ToLower(null) && x.Name.ToLower(null) == file?.FileName?.ToLower(null) && x.Id != binaryObject.Id)?.Items?.FirstOrDefault();
                if (existingbinary != null)
                {
                    ModelState.AddModelError("BinaryObject", "Same file name already exists in the given folder");
                    return(BadRequest(ModelState));
                }
                binaryObjectManager.Upload(file, organizationId, apiComponent, binaryObject.Id.ToString());
                binaryObjectManager.SaveEntity(file, filePath, binaryObject, apiComponent, organizationId);
                binaryObjectRepo.Add(binaryObject);

                existingAsset.BinaryObjectID = binaryObject.Id;
                existingAsset.SizeInBytes    = file.Length;
                repository.Update(existingAsset);

                await webhookPublisher.PublishAsync("Files.NewFileCreated", binaryObject.Id.ToString(), binaryObject.Name).ConfigureAwait(false);

                await webhookPublisher.PublishAsync("Assets.AssetUpdated", existingAsset.Id.ToString(), existingAsset.Name).ConfigureAwait(false);

                return(Ok(existingAsset));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Asset", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Exemple #12
0
 public bool SetBinary(int index, BinaryObject bin)
 {
     var r = MarshalFromNative<CefListValue>();
     var function = (CefValuesCapiDelegates.SetBinaryCallback2)
                    Marshal.GetDelegateForFunctionPointer(r.SetBinary,
                                                          typeof (CefValuesCapiDelegates.SetBinaryCallback2));
     var value = function(Handle, index, bin.Handle);
     return Convert.ToBoolean(value);
 }
Exemple #13
0
        public virtual async Task <JsonResult> UpdateTenantLogos(TenantLogosUploadModel model)
        {
            JsonResult   jsonResult;
            Guid?        headerImageId;
            BinaryObject binaryObject;
            BinaryObject binaryObject1;
            BinaryObject binaryObject2;
            BinaryObject binaryObject3;

            try
            {
                bool flag = false;
                ITenantSettingsAppService tenantSettingsAppService = this._tenantSettingsAppService;
                int?tenantId = this.AbpSession.TenantId;
                TenantLogosEditDto tenantLogos = await tenantSettingsAppService.GetTenantLogos(tenantId.Value);

                if (this.Request.Files.Count > 0)
                {
                    foreach (object key in this.Request.Files.Keys)
                    {
                        HttpPostedFileBase item = this.Request.Files[key.ToString()];
                        if (item.ContentLength > 512000)
                        {
                            throw new UserFriendlyException(this.L("TenantCompanyLogo_Warn_SizeLimit"));
                        }
                        string str = key.ToString();
                        if (str == "HeaderImage")
                        {
                            headerImageId = tenantLogos.HeaderImageId;
                            if (headerImageId.HasValue)
                            {
                                headerImageId = tenantLogos.HeaderImageId;
                                if (headerImageId.Value != Guid.Empty)
                                {
                                    IBinaryObjectManager binaryObjectManager = this._binaryObjectManager;
                                    headerImageId = tenantLogos.HeaderImageId;
                                    await binaryObjectManager.DeleteAsync(headerImageId.Value);
                                }
                            }
                            binaryObject = new BinaryObject(item.InputStream.GetAllBytes());
                            await this._binaryObjectManager.SaveAsync(binaryObject);

                            tenantLogos.HeaderImageId = new Guid?(binaryObject.Id);
                            flag = true;
                        }
                        else if (str == "HeaderMobileImage")
                        {
                            headerImageId = tenantLogos.HeaderMobileImageId;
                            if (headerImageId.HasValue)
                            {
                                headerImageId = tenantLogos.HeaderMobileImageId;
                                if (headerImageId.Value != Guid.Empty)
                                {
                                    IBinaryObjectManager binaryObjectManager1 = this._binaryObjectManager;
                                    headerImageId = tenantLogos.HeaderMobileImageId;
                                    await binaryObjectManager1.DeleteAsync(headerImageId.Value);
                                }
                            }
                            binaryObject1 = new BinaryObject(item.InputStream.GetAllBytes());
                            await this._binaryObjectManager.SaveAsync(binaryObject1);

                            tenantLogos.HeaderMobileImageId = new Guid?(binaryObject1.Id);
                            flag = true;
                        }
                        else if (str == "MailImage")
                        {
                            headerImageId = tenantLogos.MailImageId;
                            if (headerImageId.HasValue)
                            {
                                headerImageId = tenantLogos.MailImageId;
                                if (headerImageId.Value != Guid.Empty)
                                {
                                    IBinaryObjectManager binaryObjectManager2 = this._binaryObjectManager;
                                    headerImageId = tenantLogos.MailImageId;
                                    await binaryObjectManager2.DeleteAsync(headerImageId.Value);
                                }
                            }
                            binaryObject2 = new BinaryObject(item.InputStream.GetAllBytes());
                            await this._binaryObjectManager.SaveAsync(binaryObject2);

                            tenantLogos.MailImageId = new Guid?(binaryObject2.Id);
                            flag = true;
                        }
                        else if (str == "InvoiceImage")
                        {
                            headerImageId = tenantLogos.InvoiceImageId;
                            if (headerImageId.HasValue)
                            {
                                headerImageId = tenantLogos.InvoiceImageId;
                                if (headerImageId.Value != Guid.Empty)
                                {
                                    IBinaryObjectManager binaryObjectManager3 = this._binaryObjectManager;
                                    headerImageId = tenantLogos.InvoiceImageId;
                                    await binaryObjectManager3.DeleteAsync(headerImageId.Value);
                                }
                            }
                            binaryObject3 = new BinaryObject(item.InputStream.GetAllBytes());
                            await this._binaryObjectManager.SaveAsync(binaryObject3);

                            tenantLogos.InvoiceImageId = new Guid?(binaryObject3.Id);
                            flag = true;
                        }
                        binaryObject  = null;
                        binaryObject1 = null;
                        binaryObject2 = null;
                        binaryObject3 = null;
                        item          = null;
                    }
                }
                if (model.ClearHeaderImageId.HasValue && model.ClearHeaderImageId.Value)
                {
                    headerImageId = model.HeaderImageId;
                    if (headerImageId.HasValue)
                    {
                        IBinaryObjectManager binaryObjectManager4 = this._binaryObjectManager;
                        headerImageId = tenantLogos.HeaderImageId;
                        await binaryObjectManager4.DeleteAsync(headerImageId.Value);

                        headerImageId             = null;
                        tenantLogos.HeaderImageId = headerImageId;
                        flag = true;
                    }
                }
                if (model.ClearHeaderMobileImageId.HasValue && model.ClearHeaderMobileImageId.Value)
                {
                    headerImageId = model.HeaderMobileImageId;
                    if (headerImageId.HasValue)
                    {
                        IBinaryObjectManager binaryObjectManager5 = this._binaryObjectManager;
                        headerImageId = tenantLogos.HeaderMobileImageId;
                        await binaryObjectManager5.DeleteAsync(headerImageId.Value);

                        headerImageId = null;
                        tenantLogos.HeaderMobileImageId = headerImageId;
                        flag = true;
                    }
                }
                if (model.ClearMailImageId.HasValue && model.ClearMailImageId.Value)
                {
                    headerImageId = model.MailImageId;
                    if (headerImageId.HasValue)
                    {
                        IBinaryObjectManager binaryObjectManager6 = this._binaryObjectManager;
                        headerImageId = tenantLogos.MailImageId;
                        await binaryObjectManager6.DeleteAsync(headerImageId.Value);

                        headerImageId           = null;
                        tenantLogos.MailImageId = headerImageId;
                        flag = true;
                    }
                }
                if (model.ClearInvoiceImageId.HasValue && model.ClearInvoiceImageId.Value)
                {
                    headerImageId = model.InvoiceImageId;
                    if (headerImageId.HasValue)
                    {
                        IBinaryObjectManager binaryObjectManager7 = this._binaryObjectManager;
                        headerImageId = tenantLogos.InvoiceImageId;
                        await binaryObjectManager7.DeleteAsync(headerImageId.Value);

                        headerImageId = null;
                        tenantLogos.InvoiceImageId = headerImageId;
                        flag = true;
                    }
                }
                if (flag)
                {
                    await this._tenantSettingsAppService.UpdateTenantLogos(tenantLogos);
                }
                jsonResult = this.Json(new MvcAjaxResponse());
            }
            catch (UserFriendlyException userFriendlyException1)
            {
                UserFriendlyException userFriendlyException = userFriendlyException1;
                jsonResult = this.Json(new MvcAjaxResponse(new ErrorInfo(userFriendlyException.Message), false));
            }
            return(jsonResult);
        }