コード例 #1
0
ファイル: StringMapCreater.cs プロジェクト: zzdxpq007/xms
        public bool CreateMany(IEnumerable <Domain.StringMap> entities)
        {
            var result = true;

            using (UnitOfWork.Build(_stringMapRepository.DbContext))
            {
                result = _stringMapRepository.CreateMany(entities);
                //本地化标签
                foreach (var entity in entities)
                {
                    _localizedLabelService.Append(SolutionDefaults.DefaultSolutionId, entity.Name.IfEmpty(""), StringMapDefaults.ModuleName, "LocalizedName", entity.StringMapId);
                }
                _localizedLabelService.Save();
            }
            return(result);
        }
コード例 #2
0
        private bool CreateCore(params Domain.OptionSetDetail[] entities)
        {
            Guard.NotEmpty(entities, nameof(entities));
            bool result = false;

            using (UnitOfWork.Build(_optionSetDetailRepository.DbContext))
            {
                result = _optionSetDetailRepository.CreateMany(entities);
                //本地化标签
                foreach (var entity in entities)
                {
                    _localizedLabelService.Append(SolutionDefaults.DefaultSolutionId, entity.Name.IfEmpty(""), OptionSetDefaults.ModuleName, "LocalizedName", entity.OptionSetDetailId);
                }
                _localizedLabelService.Save();
            }
            return(result);
        }
コード例 #3
0
ファイル: RibbonButtonCreater.cs プロジェクト: zzdxpq007/xms
        private bool CreateCore(params Domain.RibbonButton[] entities)
        {
            Guard.NotEmpty(entities, nameof(entities));
            foreach (var entity in entities)
            {
                entity.SolutionId = SolutionDefaults.DefaultSolutionId;//组件属于默认解决方案
            }
            var result = true;

            using (UnitOfWork.Build(_ribbonButtonRepository.DbContext))
            {
                result = _ribbonButtonRepository.CreateMany(entities);
                _dependencyService.Create(entities);
                //本地化标签
                foreach (var entity in entities)
                {
                    _localizedLabelService.Append(entity.SolutionId, entity.Label.IfEmpty(""), RibbonButtonDefaults.ModuleName, "LocalizedName", entity.RibbonButtonId)
                    .Append(entity.SolutionId, entity.Description.IfEmpty(""), RibbonButtonDefaults.ModuleName, "Description", entity.RibbonButtonId);
                }
                _localizedLabelService.Save();
            }
            return(result);
        }
コード例 #4
0
ファイル: AttributeCreater.cs プロジェクト: xixiky/xms
        public bool CreateDefaultAttributes(Domain.Entity entity, params string[] defaultAttributeNames)
        {
            var result     = true;
            var attributes = _defaultAttributeProvider.GetSysAttributes(entity).Where(x => defaultAttributeNames.Contains(x.Name, StringComparer.InvariantCultureIgnoreCase)).ToList();

            using (UnitOfWork.Build(_attributeRepository.DbContext))
            {
                result = _attributeRepository.CreateMany(attributes);
                //新建字段选项
                var stateCodeAttr = attributes.Find(n => n.Name.IsCaseInsensitiveEqual("statecode"));
                if (stateCodeAttr != null)
                {
                    result = _stringMapCreater.CreateMany(stateCodeAttr.PickLists);
                }
                var statusCodeAttr = attributes.Find(n => n.Name.IsCaseInsensitiveEqual("statuscode"));
                if (statusCodeAttr != null)
                {
                    _optionSetCreater.Create(statusCodeAttr.OptionSet);
                }
                //创建关系
                result = _relationShipCreater.CreateMany(_defaultAttributeProvider.GetSysAttributeRelationShips(entity, attributes));
                //attribute localization
                foreach (var attr in attributes)
                {
                    var label = attr.TypeIsPrimaryKey() ? entity.LocalizedName : _loc["entity_sys_" + attr.Name];
                    _localizedLabelService.Append(entity.SolutionId, label, AttributeDefaults.ModuleName, "LocalizedName", attr.AttributeId)
                    .Append(entity.SolutionId, label, AttributeDefaults.ModuleName, "Description", attr.AttributeId);
                }
                _localizedLabelService.Save();
                //add to cache
                foreach (var attr in attributes)
                {
                    _cacheService.SetEntity(attr);
                }
            }
            return(result);
        }
コード例 #5
0
ファイル: FormService.cs プロジェクト: zzdxpq007/xms
        public void UpdateLocalizedLabel(Domain.SystemForm original)
        {
            //删除原有的
            if (original != null)
            {
                DeleteOriginalLabels(original);
            }
            var attributeMetadatas = _attributeFinder.FindByEntityId(_entityid);
            var solutionId         = SolutionDefaults.DefaultSolutionId;//组件属于默认解决方案

            if (Form.Header != null && Form.Header.Rows.NotEmpty())
            {
                //header
                foreach (var row in Form.Header.Rows)
                {
                    foreach (var cell in row.Cells)
                    {
                        if (!cell.Id.Equals(Guid.Empty) && cell.Label.IsNotEmpty())
                        {
                            if (cell.Control.ControlType == FormControlType.Standard ||
                                cell.Control.ControlType == FormControlType.Hidden ||
                                cell.Control.ControlType == FormControlType.Lookup ||
                                cell.Control.ControlType == FormControlType.OptionSet)
                            {
                                var attr = attributeMetadatas.Find(n => n.Name.IsCaseInsensitiveEqual(cell.Control.Name));
                                if (attr != null && !cell.Label.IsCaseInsensitiveEqual(attr.LocalizedName))//与字段显示名称不一致时
                                {
                                    _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                                }
                            }
                            else
                            {
                                _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                            }
                        }
                    }
                }
            }
            if (Form.NavGroups.NotEmpty())
            {
                //navs
                foreach (var navg in Form.NavGroups)
                {
                    if (!navg.Id.Equals(Guid.Empty) && navg.Label.IsNotEmpty())
                    {
                        _localizedLabelBatchBuilder.Append(solutionId, navg.Label, FormDefaults.ModuleName, "LayoutLabel", navg.Id);
                    }
                    foreach (var item in navg.NavItems)
                    {
                        _localizedLabelBatchBuilder.Append(solutionId, item.Label, FormDefaults.ModuleName, "LayoutLabel", item.Id);
                    }
                }
            }
            if (Form.Panels.NotEmpty())
            {
                //tabs
                foreach (var tab in Form.Panels)
                {
                    if (!tab.Id.Equals(Guid.Empty) && tab.Label.IsNotEmpty())
                    {
                        _localizedLabelBatchBuilder.Append(solutionId, tab.Label, FormDefaults.ModuleName, "LayoutLabel", tab.Id);
                    }
                    foreach (var sec in tab.Sections)
                    {
                        if (!sec.Id.Equals(Guid.Empty) && sec.Label.IsNotEmpty())
                        {
                            _localizedLabelBatchBuilder.Append(solutionId, sec.Label, FormDefaults.ModuleName, "LayoutLabel", sec.Id);
                        }
                        foreach (var row in sec.Rows)
                        {
                            foreach (var cell in row.Cells)
                            {
                                if (!cell.Id.Equals(Guid.Empty) && cell.Label.IsNotEmpty())
                                {
                                    if (cell.Control.ControlType == FormControlType.Standard ||
                                        cell.Control.ControlType == FormControlType.Hidden ||
                                        cell.Control.ControlType == FormControlType.Lookup ||
                                        cell.Control.ControlType == FormControlType.OptionSet)
                                    {
                                        var attr = attributeMetadatas.Find(n => n.Name.IsCaseInsensitiveEqual(cell.Control.Name));
                                        if (attr != null && !cell.Label.IsCaseInsensitiveEqual(attr.LocalizedName))//与字段显示名称不一致时
                                        {
                                            _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                                        }
                                    }
                                    else
                                    {
                                        _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                                    }
                                }
                            }
                        }
                    }
                }
                if (Form.Footer != null && Form.Footer.Rows.NotEmpty())
                {
                    //footer
                    foreach (var row in Form.Footer.Rows)
                    {
                        foreach (var cell in row.Cells)
                        {
                            if (!cell.Id.Equals(Guid.Empty) && cell.Label.IsNotEmpty())
                            {
                                if (cell.Control.ControlType == FormControlType.Standard ||
                                    cell.Control.ControlType == FormControlType.Hidden ||
                                    cell.Control.ControlType == FormControlType.Lookup ||
                                    cell.Control.ControlType == FormControlType.OptionSet)
                                {
                                    var attr = attributeMetadatas.Find(n => n.Name.IsCaseInsensitiveEqual(cell.Control.Name));
                                    if (attr != null && !cell.Label.IsCaseInsensitiveEqual(attr.LocalizedName))//与字段显示名称不一致时
                                    {
                                        _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                                    }
                                }
                                else
                                {
                                    _localizedLabelBatchBuilder.Append(solutionId, cell.Label, FormDefaults.ModuleName, "LayoutLabel", cell.Id);
                                }
                            }
                        }
                    }
                }
            }
            _localizedLabelBatchBuilder.Save();
        }