コード例 #1
0
        public override MixArticle ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            if (Id == 0)
            {
                Id = Repository.Max(c => c.Id, _context, _transaction).Data + 1;
                CreatedDateTime = DateTime.UtcNow;
            }
            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)).OrderBy(p => p.Priority))
                {
                    arrProperties.Add(JObject.FromObject(p));
                }
                ExtraProperties = arrProperties.ToString(Formatting.None);
            }

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

            if (ThumbnailFileStream != null)
            {
                string folder = CommonHelper.GetFullPath(new string[]
                {
                    MixConstants.Folder.UploadFolder, "Articles", DateTime.UtcNow.ToString("dd-MM-yyyy")
                });
                string filename      = CommonHelper.GetRandomName(ThumbnailFileStream.Name);
                bool   saveThumbnail = CommonHelper.SaveFileBase64(folder, filename, ThumbnailFileStream.Base64);
                if (saveThumbnail)
                {
                    CommonHelper.RemoveFile(Thumbnail);
                    Thumbnail = CommonHelper.GetFullPath(new string[] { folder, filename });
                }
            }
            if (ImageFileStream != null)
            {
                string folder = CommonHelper.GetFullPath(new string[]
                {
                    MixConstants.Folder.UploadFolder, "Articles", DateTime.UtcNow.ToString("dd-MM-yyyy")
                });
                string filename  = CommonHelper.GetRandomName(ImageFileStream.Name);
                bool   saveImage = CommonHelper.SaveFileBase64(folder, filename, ImageFileStream.Base64);
                if (saveImage)
                {
                    CommonHelper.RemoveFile(Image);
                    Image = CommonHelper.GetFullPath(new string[] { 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));
        }
コード例 #2
0
        public override SiocProduct ParseModel(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            if (string.IsNullOrEmpty(Id))
            {
                Id = Guid.NewGuid().ToString();
                CreatedDateTime = DateTime.UtcNow;
            }
            if (Properties.Count > 0)
            {
                JArray arrProperties = new JArray();
                foreach (var p in Properties.Where(p => !string.IsNullOrEmpty(p.Value) && !string.IsNullOrEmpty(p.Name)).OrderBy(p => p.Priority))
                {
                    arrProperties.Add(JObject.FromObject(p));
                }
                ExtraProperties = arrProperties.ToString(Formatting.None);
            }

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

            if (ThumbnailFileStream != null)
            {
                string folder = SwCmsHelper.GetFullPath(new string[]
                {
                    SWCmsConstants.Parameters.UploadFolder, "Products", DateTime.UtcNow.ToString("dd-MM-yyyy")
                });
                string filename      = SwCmsHelper.GetRandomName(ThumbnailFileStream.Name);
                bool   saveThumbnail = SwCmsHelper.SaveFileBase64(folder, filename, ThumbnailFileStream.Base64);
                if (saveThumbnail)
                {
                    SwCmsHelper.RemoveFile(Thumbnail);
                    Thumbnail = SwCmsHelper.GetFullPath(new string[] { folder, filename });
                }
            }
            if (ImageFileStream != null)
            {
                string folder = SwCmsHelper.GetFullPath(new string[]
                {
                    SWCmsConstants.Parameters.UploadFolder, "Products", DateTime.UtcNow.ToString("dd-MM-yyyy")
                });
                string filename  = SwCmsHelper.GetRandomName(ImageFileStream.Name);
                bool   saveImage = SwCmsHelper.SaveFileBase64(folder, filename, ImageFileStream.Base64);
                if (saveImage)
                {
                    SwCmsHelper.RemoveFile(Image);
                    Image = SwCmsHelper.GetFullPath(new string[] { folder, filename });
                }
            }

            Tags        = ListTag.ToString(Newtonsoft.Json.Formatting.None);
            NormalPrice = SwCmsHelper.ReversePrice(StrNormalPrice);
            DealPrice   = SwCmsHelper.ReversePrice(StrDealPrice);
            ImportPrice = SwCmsHelper.ReversePrice(StrImportPrice);

            GenerateSEO();

            return(base.ParseModel(_context, _transaction));
        }
コード例 #3
0
        public override string ToString()
        {
            ListTag list = new ListTag();

            list.ListEntries.Add(new IntegerTag(Internal.Recipe.Index));
            foreach (ItemStack item in Internal.UsedInput)
            {
                list.ListEntries.Add(new ItemTag(item));
            }
            return(list.ToString());
        }
コード例 #4
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));
        }
コード例 #5
0
 /// <summary>Constructs the argument with input text.</summary>
 /// <param name="_text">The input text.</param>
 /// <param name="wasquoted">Whether the argument was quoted at input time.</param>
 /// <param name="perfect">Whether the argument must parse back "perfectly" (meaning, it will ToString to the exact original input).</param>
 /// <param name="_engine">The backing script engine.</param>
 public TextArgumentBit(string _text, bool wasquoted, bool perfect, ScriptEngine _engine)
 {
     Engine = _engine;
     if (wasquoted)
     {
         InputValue = new TextTag(_text);
         ResType    = TextTag.TYPE;
         return;
     }
     else if (_text == "true")
     {
         InputValue = BooleanTag.TRUE;
         ResType    = BooleanTag.TYPE;
         return;
     }
     else if (_text == "false")
     {
         InputValue = BooleanTag.FALSE;
         ResType    = BooleanTag.TYPE;
         return;
     }
     else if (_text == "&{NULL}")
     {
         InputValue = NullTag.NULL_VALUE;
         ResType    = NullTag.TYPE;
         return;
     }
     else if (long.TryParse(_text, out long ti) && ti.ToString() == _text)
     {
         InputValue = new IntegerTag(ti);
         ResType    = IntegerTag.TYPE;
         return;
     }
     else if (double.TryParse(_text, out double tn) && (!perfect || tn.ToString() == _text))
     {
         InputValue = new NumberTag(tn);
         ResType    = NumberTag.TYPE;
         return;
     }
     else if (_text.Contains('|'))
     {
         if (_text.Contains(':'))
         {
             MapTag map = MapTag.For(_text);
             if (map.ToString() == _text)
             {
                 InputValue = map;
                 ResType    = MapTag.TYPE;
                 return;
             }
         }
         ListTag list = ListTag.For(_text);
         if (list.ToString() == _text)
         {
             InputValue = list;
             ResType    = ListTag.TYPE;
             return;
         }
     }
     InputValue = new TextTag(_text);
     ResType    = TextTag.TYPE;
 }
コード例 #6
0
ファイル: RecipeResultTag.cs プロジェクト: Morphan1/Voxalia
 public override string ToString()
 {
     ListTag list = new ListTag();
     list.ListEntries.Add(new IntegerTag(Internal.Recipe.Index));
     foreach (ItemStack item in Internal.UsedInput)
     {
         list.ListEntries.Add(new ItemTag(item));
     }
     return list.ToString();
 }