Esempio n. 1
0
        /// <summary>
        /// 表单定义保存操作
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public EntityDefEntity SaveEntityDef(EntityDefEntity entity)
        {
            EntityDefEntity returnEntity = null;

            if (entity.ID == 0)
            {
                entity.EntityCode  = PinyinConverter.ConvertFirst(entity.EntityName);
                entity.CreatedDate = System.DateTime.Now;
                var entityDefID = QuickRepository.Insert <EntityDefEntity>(entity);
                entity.ID = entityDefID;

                returnEntity = entity;
            }
            else
            {
                var updEntity = QuickRepository.GetById <EntityDefEntity>(entity.ID);
                updEntity.EntityTitle     = entity.EntityTitle;
                updEntity.EntityName      = entity.EntityName;
                updEntity.EntityCode      = PinyinConverter.ConvertFirst(entity.EntityName);
                updEntity.Description     = entity.Description;
                updEntity.LastUpdatedDate = System.DateTime.Now;
                QuickRepository.Update <EntityDefEntity>(updEntity);

                returnEntity = updEntity;
            }
            return(returnEntity);
        }
        public void Initialize()
        {
            _pinyinBeautifierMock = new Mock <IPinyinBeautifier>();

            _objectUnderTest            = new PinyinConverter();
            _objectUnderTest.Beautifier = _pinyinBeautifierMock.Object;
        }
Esempio n. 3
0
        public void TestPinyin()
        {
            //中英文混合,带空格(空格会在处理UserKey时被替换,因此这里不处理)
            Assert.AreEqual("Lai-Zi-Kooboo Team-De-Ce-Shi-Title", PinyinConverter.GetPinyin("来自Kooboo Team的测试Title", "-"));

            //英文开头的中英混合
            Assert.AreEqual(PinyinConverter.GetPinyin("Kooboo Team的测试标题", "-"), "Kooboo Team-De-Ce-Shi-Biao-Ti");

            Assert.AreEqual(PinyinConverter.GetPinyin(" "), " ");

            Assert.AreEqual(PinyinConverter.GetPinyin("123456"), "123456");

            Assert.AreEqual(PinyinConverter.GetPinyin(",./!@#"), ",./!@#");

            Assert.AreEqual(PinyinConverter.GetPinyin("abcde"), "abcde");

            //测试分隔符
            Assert.AreEqual(PinyinConverter.GetPinyin("纯中文测试", "_"), "Chun_Zhong_Wen_Ce_Shi");

            Assert.AreEqual(PinyinConverter.GetPinyin("Kooboo Team的测试标题"), "Kooboo TeamDeCeShiBiaoTi");
        }
        /// <summary>
        /// 保存字段
        /// </summary>
        /// <param name="conn">链接</param>
        /// <param name="entity">实体</param>
        /// <param name="trans">事务</param>
        /// <returns></returns>
        internal EntityAttributeEntity SaveAttribute(IDbConnection conn, EntityAttributeEntity entity,
                                                     IDbTransaction trans)
        {
            var fem    = new EntityAttributeManager();
            int attrID = IsExistKey(conn, entity, trans);

            if (attrID > 0)
            {
                entity.ID       = attrID;
                entity.AttrCode = PinyinConverter.ConvertFirst(entity.AttrName);
                Repository.Update <EntityAttributeEntity>(conn, entity, trans);
            }
            else
            {
                entity.AttrCode = PinyinConverter.ConvertFirst(entity.AttrName);
                var newAttrID = Repository.Insert <EntityAttributeEntity>(conn, entity, trans);
                entity.ID = newAttrID;
            }

            return(entity);
        }
        public void ShouldInitializeBeautifierToDefault()
        {
            _objectUnderTest = new PinyinConverter();

            Assert.IsInstanceOf <PinyinBeautifier>(_objectUnderTest.Beautifier);
        }