コード例 #1
0
        public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            Cultures = LoadCultures(Specificulture, _context, _transaction);
            Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            Columns = new List <ModuleFieldViewModel>();
            JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray();

            foreach (var field in arrField)
            {
                ModuleFieldViewModel thisField = new ModuleFieldViewModel()
                {
                    Name       = CommonHelper.ParseJsonPropertyName(field["name"].ToString()),
                    Title      = field["title"]?.ToString(),
                    Options    = field["options"] != null ? field["options"].Value <JArray>() : new JArray(),
                    Priority   = field["priority"] != null ? field["priority"].Value <int>() : 0,
                    DataType   = (MixDataType)(int)field["dataType"],
                    Width      = field["width"] != null ? field["width"].Value <int>() : 3,
                    IsUnique   = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true,
                    IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true,
                    IsDisplay  = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true,
                    IsSelect   = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false,
                    IsGroupBy  = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false,
                };
                Columns.Add(thisField);
            }
            this.Templates = this.Templates ?? MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Name == ActivedTheme && t.FolderType == this.TemplateFolderType).Data;
            this.View     = MixTemplates.UpdateViewModel.GetTemplateByPath(Template, Specificulture, MixEnums.EnumTemplateFolder.Modules, _context, _transaction);
            this.Template = CommonHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });
        }
コード例 #2
0
        public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            Cultures = MixModules.Helper.LoadCultures(Id, Specificulture, _context, _transaction);
            Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            Columns = new List <ModuleFieldViewModel>();
            JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray();

            foreach (var field in arrField)
            {
                ModuleFieldViewModel thisField = new ModuleFieldViewModel()
                {
                    Name       = CommonHelper.ParseJsonPropertyName(field["name"].ToString()),
                    Title      = field["title"]?.ToString(),
                    Options    = field["options"] != null ? field["options"].Value <JArray>() : new JArray(),
                    Priority   = field["priority"] != null ? field["priority"].Value <int>() : 0,
                    DataType   = (MixDataType)(int)field["dataType"],
                    Width      = field["width"] != null ? field["width"].Value <int>() : 3,
                    IsUnique   = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true,
                    IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true,
                    IsDisplay  = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true,
                    IsSelect   = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false,
                    IsGroupBy  = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false,
                };
                Columns.Add(thisField);
            }
            // Load Attributes
            LoadAttributes(_context, _transaction);

            this.Templates = MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Id == ActivedTheme && t.FolderType == this.TemplateFolderType, _context, _transaction).Data;
            var templateName = Template?.Substring(Template.LastIndexOf('/') + 1) ?? MixConstants.DefaultTemplate.Module;

            this.View = Templates.FirstOrDefault(t => !string.IsNullOrEmpty(templateName) && templateName.Equals($"{t.FileName}{t.Extension}"));
            if (this.View == null)
            {
                this.View = Templates.FirstOrDefault(t => MixConstants.DefaultTemplate.Module.Equals($"{t.FileName}{t.Extension}"));
            }
            this.Template = $"{View?.FileFolder}/{View?.FileName}{View.Extension}";

            this.Forms = MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Id == ActivedTheme && t.FolderType == this.FormFolderType).Data;
            this.FormView     = MixTemplates.UpdateViewModel.GetTemplateByPath(FormTemplate, Specificulture, MixEnums.EnumTemplateFolder.Forms, _context, _transaction);
            this.FormTemplate = $"{FormView?.FileFolder}/{FormView?.FileName}{View.Extension}";

            this.Edms = MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Id == ActivedTheme && t.FolderType == this.EdmFolderType).Data;
            this.EdmView     = MixTemplates.UpdateViewModel.GetTemplateByPath(EdmTemplate, Specificulture, MixEnums.EnumTemplateFolder.Edms, _context, _transaction);
            this.EdmTemplate = $"{EdmView?.FileFolder}/{EdmView?.FileName}{View.Extension}";

            // TODO: Verified why use below code
            //if (SetAttributeId.HasValue)
            //{
            //    AttributeSet = MixAttributeSets.UpdateViewModel.Repository.GetSingleModel(s => s.Id == SetAttributeId.Value).Data;
            //}
            //else
            //{
            //    AttributeSet = new MixAttributeSets.UpdateViewModel();
            //}
        }
コード例 #3
0
ファイル: UpdateViewModel.cs プロジェクト: sicollins/mix.core
 public override MixUrlAlias ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     if (Id == 0)
     {
         Id = UpdateViewModel.Repository.Max(c => c.Id).Data + 1;
         CreatedDateTime = DateTime.UtcNow;
         Cultures        = Cultures ?? LoadCultures(Specificulture, _context, _transaction);
         Cultures.ForEach(c => c.IsSupported = true);
     }
     return(base.ParseModel(_context, _transaction));
 }
コード例 #4
0
ファイル: Eu4Culture.cs プロジェクト: Dinglydell/Eu4Helper
        public PdxSublist GetGroupData()
        {
            var data = new PdxSublist(null, Name);

            data.AddValue("graphical_culture", GraphicalCulture);
            Cultures.ForEach((culture) =>
            {
                data.AddSublist(culture.Name, culture.GetCultureData());
            });
            return(data);
        }
コード例 #5
0
        public override SiocMedia ParseModel(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            if (Id == 0)
            {
                Id = BEMediaViewModel.Repository.Max(c => c.Id).Data + 1;
                CreatedDateTime = DateTime.UtcNow;
                IsClone         = true;
                Cultures        = Cultures ?? CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
                Cultures.ForEach(c => c.IsSupported = true);
            }

            return(base.ParseModel(_context, _transaction));
        }
コード例 #6
0
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            var getAlias = ApiUrlAliasViewModel.Repository.GetSingleModel(
                u => u.Specificulture == Specificulture && u.SourceId == Id.ToString() && u.Type == (int)SWCmsConstants.UrlAliasType.Page);

            UrlAlias = getAlias.Data;
            if (UrlAlias == null)
            {
                UrlAlias = new ApiUrlAliasViewModel()
                {
                    Type           = SWCmsConstants.UrlAliasType.Page,
                    Specificulture = Specificulture,
                    Alias          = SeoName
                };
            }
            Cultures = Cultures ?? CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
            Cultures.ForEach(c => c.IsSupported = _context.SiocCategory.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            if (!string.IsNullOrEmpty(this.Tags))
            {
                ListTag = JArray.Parse(this.Tags);
            }

            int themeId = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0);

            View = ApiTemplateViewModel.GetTemplateByPath(themeId, Template, SWCmsConstants.TemplateFolder.Pages, _context, _transaction);

            if (this.View == null)
            {
                this.View = new ApiTemplateViewModel(new SiocTemplate()
                {
                    Extension    = SWCmsConstants.Parameters.TemplateExtension,
                    TemplateId   = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0),
                    TemplateName = ActivedTemplate,
                    FolderType   = TemplateFolderType,
                    FileFolder   = this.TemplateFolder,
                    FileName     = SWCmsConstants.Default.DefaultTemplate,
                    ModifiedBy   = ModifiedBy,
                    Content      = "<div></div>"
                });
            }
            this.Template = SwCmsHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });

            this.ModuleNavs   = GetModuleNavs(_context, _transaction);
            this.ParentNavs   = GetParentNavs(_context, _transaction);
            this.ChildNavs    = GetChildNavs(_context, _transaction);
            this.PositionNavs = GetPositionNavs(_context, _transaction);
        }
コード例 #7
0
        public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            Cultures = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
            Cultures.ForEach(c => c.IsSupported = _context.SiocModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            Columns = new List <ModuleFieldViewModel>();
            JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray();

            foreach (var field in arrField)
            {
                ModuleFieldViewModel thisField = new ModuleFieldViewModel()
                {
                    Name       = CommonHelper.ParseJsonPropertyName(field["name"].ToString()),
                    Title      = field["title"]?.ToString(),
                    Options    = field["options"] != null ? field["options"].Value <JArray>() : new JArray(),
                    Priority   = field["priority"] != null ? field["priority"].Value <int>() : 0,
                    DataType   = (SWCmsConstants.DataType)(int) field["dataType"],
                    Width      = field["width"] != null ? field["width"].Value <int>() : 3,
                    IsUnique   = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true,
                    IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true,
                    IsDisplay  = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true,
                    IsSelect   = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false,
                    IsGroupBy  = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false,
                };
                Columns.Add(thisField);
            }
            int themeId = GlobalConfigurationService.Instance.GetLocalInt(SWCmsConstants.ConfigurationKeyword.ThemeId, Specificulture, 0);

            View = ApiTemplateViewModel.Repository.GetSingleModel(t =>
                                                                  t.TemplateId == themeId &&
                                                                  !string.IsNullOrEmpty(this.Template) && this.Template.Contains($"{t.FileName}{t.Extension}")).Data;
            if (this.View == null)
            {
                this.View = new ApiTemplateViewModel(new SiocTemplate()
                {
                    Extension    = SWCmsConstants.Parameters.TemplateExtension,
                    TemplateId   = themeId,
                    TemplateName = ActivedTemplate,
                    FolderType   = TemplateFolderType,
                    FileFolder   = this.TemplateFolder,
                    FileName     = SWCmsConstants.Default.DefaultTemplate,
                    ModifiedBy   = ModifiedBy,
                    Content      = "<div></div>"
                });
            }
            this.Template = SwCmsHelper.GetFullPath(new string[]
            {
                this.View?.FileFolder
                , this.View?.FileName
            });
        }
コード例 #8
0
 public override MixMedia ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     if (Id == 0)
     {
         Id = UpdateViewModel.Repository.Max(c => c.Id).Data + 1;
         CreatedDateTime = DateTime.UtcNow;
         IsClone         = true;
         Cultures        = Cultures ?? LoadCultures(Specificulture, _context, _transaction);
         Cultures.ForEach(c => c.IsSupported = true);
     }
     if (FileFolder[0] == '/')
     {
         FileFolder = FileFolder.Substring(1);
     }
     return(base.ParseModel(_context, _transaction));
 }
コード例 #9
0
ファイル: UpdateViewModel.cs プロジェクト: sicollins/mix.core
 public override MixMedia ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     if (CreatedDateTime == default)
     {
         Id = Id > 0 ? Id : UpdateViewModel.Repository.Max(c => c.Id).Data + 1;
         CreatedDateTime = DateTime.UtcNow;
         Cultures        = Cultures ?? LoadCultures(Specificulture, _context, _transaction);
         Cultures.ForEach(c => c.IsSupported = true);
     }
     if (string.IsNullOrEmpty(TargetUrl))
     {
         if (FileFolder[0] == '/')
         {
             FileFolder = FileFolder.Substring(1);
         }
     }
     return(base.ParseModel(_context, _transaction));
 }
コード例 #10
0
        public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            EditorValue ??= Description;
            EditorType ??= MixEditorType.Html;
            Cultures = MixModules.Helper.LoadCultures(Id, Specificulture, _context, _transaction);
            Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
            Columns = new List <ModuleFieldViewModel>();
            JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray();

            foreach (var field in arrField)
            {
                var col = field.ToObject <ModuleFieldViewModel>();
                Columns.Add(col);
            }

            this.Templates = MixTemplates.UpdateViewModel.Repository.GetModelListBy(
                t => t.Theme.Id == ActivedTheme && t.FolderType == this.TemplateFolderType, _context, _transaction).Data;
            var templateName = Template?.Substring(Template.LastIndexOf('/') + 1) ?? MixConstants.DefaultTemplate.Module;

            this.View = Templates.FirstOrDefault(t => !string.IsNullOrEmpty(templateName) && templateName.Equals($"{t.FileName}{t.Extension}"));
            this.View ??= Templates.FirstOrDefault();
            this.Template = $"{View?.FileFolder}/{View?.FileName}{View?.Extension}";
        }
コード例 #11
0
 public override void ExpandView(SiocCmsContext _context = null, IDbContextTransaction _transaction = null)
 {
     IsClone  = true;
     Cultures = CommonRepository.Instance.LoadCultures(Specificulture, _context, _transaction);
     Cultures.ForEach(c => c.IsSupported = _context.SiocUrlAlias.Any(m => m.Id == Id && m.Specificulture == c.Specificulture));
 }