コード例 #1
0
        public int AddWithContext(IEntityContext entityContext, CRestaurantPO po, string operatorName)
        {
            if (entityContext == null)
            {
                throw new ArgumentNullException("entityContext");
            }
            if (po == null)
            {
                throw new ArgumentNullException("对象不能为空");
            }
            if (string.IsNullOrWhiteSpace(operatorName))
            {
                throw new ArgumentNullException("操作人不能为空");
            }
            if (po.Id > 0)
            {
                throw new BusinessException("添加对象错误,Id不能大于0");
            }
            if (string.IsNullOrWhiteSpace(po.ResUUID))
            {
                po.ResUUID = System.Guid.NewGuid().ToString();
            }
            if (string.IsNullOrWhiteSpace(po.Name))
            {
                throw new BusinessException("餐厅名称不能为空");
            }

            WordPinYin wordPinYin1 = WordPinYinManager.Instance.GetWord_Pinyin(po.Name);

            //if (wordPinYin1 != null && !string.IsNullOrWhiteSpace(wordPinYin1.PinYin))
            //{
            //    po.Alphabet = wordPinYin1.PinYin + ";" + wordPinYin1.FirstLetter;
            //}
            po.Alphabet   = po.Alphabet;
            po.IsDelete   = false;
            po.CreateTime = DateTime.Now;
            po.CreateName = operatorName;
            po.UpdateTime = DateTime.Now;
            po.UpdateName = operatorName;

            CRestaurantPOManager.Instance.AddWithContext(entityContext, po);
            COperationLogManager.Instance.AddOperationLogWithContext(entityContext, po.Id, EnumOperationLogType.CPropertyCategory, EnumOperationLogAction.Add, null, po, operatorName);

            return(po.Id);
        }
コード例 #2
0
ファイル: WordPinYin.CS プロジェクト: sjgtongji/CoffeeService
        /// <summary>
        /// 转化关键字
        /// </summary>
        /// <param name="sIn"></param>
        /// <returns></returns>
        public WordPinYin GetWord_Pinyin(string sIn)
        {
            sIn = FormatSearchKey(sIn);
            if (String.IsNullOrWhiteSpace(sIn))
            {
                return(null);
            }

            WordPinYin objRslt         = new WordPinYin();
            string     sInWithoutSpace = sIn.Replace(" ", "").ToLower();

            objRslt.Word          = sIn.Replace(" ", "");
            objRslt.WordWithSpace = sIn;
            if (sInWithoutSpace.IsOnlyEnglishLetterOrDigital())
            {
                if (sIn.Length > 30)
                {
                    return(null);
                }
                objRslt.Word                 = "";
                objRslt.PinYin               = sInWithoutSpace;
                objRslt.PinYinWithSpace      = sIn;
                objRslt.FirstLetter          = sInWithoutSpace;
                objRslt.FirstLetterWithSpace = sIn;
                return(objRslt);
            }
            if (sIn.Length > 20)
            {
                return(null);
            }
            HanziStringPinyin objPinyin = HanziStringPinyinManager.Instance.GetPinyinFromHanziString(sIn, 1);

            if (objPinyin != null)
            {
                string sPinyin = objPinyin.Pinyin[0].Replace("eng", "en").Replace("ing", "in");
                objRslt.FirstLetter     = objPinyin.FirstLetter[0];
                objRslt.PinYin          = sPinyin.Replace(" ", "");
                objRslt.PinYinWithSpace = sPinyin;
            }
            return(objRslt);
        }