예제 #1
0
 public bool DeleteFile(string fullPath)
 {
     if (File.Exists(fullPath))
     {
         MixCommonHelper.RemoveFile(fullPath);
     }
     return(true);
 }
예제 #2
0
        public bool DeleteWebFile(string name, string extension, string FileFolder)
        {
            string fullPath = string.Format(@"{0}/{1}/{2}{3}", "wwwroot", FileFolder, name, extension);

            if (File.Exists(fullPath))
            {
                MixCommonHelper.RemoveFile(fullPath);
            }
            return(true);
        }
예제 #3
0
        public bool DeleteTemplate(string name, string templateFolder)
        {
            string fullPath = $"{templateFolder}/{name + MixFileExtensions.CsHtml}";

            if (File.Exists(fullPath))
            {
                MixCommonHelper.RemoveFile(fullPath);
            }

            return(true);
        }
예제 #4
0
        public bool DeleteFile(string name, string extension, string FileFolder)
        {
            string folder   = MixCommonHelper.GetFullPath(new string[] { FileFolder });
            string fullPath = string.Format(@"{0}/{1}{2}", folder, name, extension);

            if (File.Exists(fullPath))
            {
                MixCommonHelper.RemoveFile(fullPath);
            }
            return(true);
        }
예제 #5
0
        public bool DeleteWebFile(string filePath)
        {
            string fullPath = MixCommonHelper.GetFullPath(new string[]
            {
                "wwwroot",
                filePath
            });

            if (File.Exists(fullPath))
            {
                MixCommonHelper.RemoveFile(fullPath);
            }
            return(true);
        }
예제 #6
0
        public override MixPost ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            if (Id == 0)
            {
                Id = Repository.Max(c => c.Id, _context, _transaction).Data + 1;
                CreatedDateTime = DateTime.UtcNow;
            }
            LastModified      = DateTime.UtcNow;
            PublishedDateTime = PublishedDateTime?.ToUniversalTime();

            //  Parsing Extra Fields to json string
            var arrField = Columns != null?JArray.Parse(
                Newtonsoft.Json.JsonConvert.SerializeObject(Columns.OrderBy(c => c.Priority).Where(
                                                                c => !string.IsNullOrEmpty(c.Name)))) : new JArray();

            ExtraFields = arrField.ToString(Newtonsoft.Json.Formatting.None);

            // Parsing Extra Properties value
            if (Properties != null && Properties.Count > 0)
            {
                JArray arrProperties = new JArray();
                foreach (var p in Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(p.Name)))
                {
                    arrProperties.Add(JObject.FromObject(p));
                }
                ExtraProperties = arrProperties.ToString(Formatting.None)?.Trim();
            }

            Template = View != null?string.Format(@"{0}/{1}{2}", View.FolderType, View.FileName, View.Extension) : Template;

            if (ThumbnailFileStream != null)
            {
                string folder        = MixCmsHelper.GetUploadFolder(Specificulture);
                string filename      = MixCommonHelper.GetRandomName(ThumbnailFileStream.Name);
                bool   saveThumbnail = MixCommonHelper.SaveFileBase64(folder, filename, ThumbnailFileStream.Base64);
                if (saveThumbnail)
                {
                    MixCommonHelper.RemoveFile(Thumbnail);
                    Thumbnail = $"{folder}/{filename}";
                }
            }
            if (ImageFileStream != null)
            {
                string folder    = MixCmsHelper.GetUploadFolder(Specificulture);
                string filename  = MixCommonHelper.GetRandomName(ImageFileStream.Name);
                bool   saveImage = MixCommonHelper.SaveFileBase64(folder, filename, ImageFileStream.Base64);
                if (saveImage)
                {
                    MixCommonHelper.RemoveFile(Image);
                    Image = $"{folder}/{filename}";
                }
            }

            if (!string.IsNullOrEmpty(Image) && Image[0] == '/')
            {
                Image = Image.Substring(1);
            }
            if (!string.IsNullOrEmpty(Thumbnail) && Thumbnail[0] == '/')
            {
                Thumbnail = Thumbnail.Substring(1);
            }
            Tags = ListTag.ToString(Newtonsoft.Json.Formatting.None);
            GenerateSEO();

            return(base.ParseModel(_context, _transaction));
        }