コード例 #1
0
        public ActionResult Create()
        {
            bool result = false;

            AspectF.Define
            .Log(log, "RecordController-Create[post]开始", "RecordController-Create[post]结束")
            .HowLong(log)
            .Retry(log)
            .Do(() =>
            {
                var reader          = new StreamReader(Request.InputStream).ReadToEnd();
                var model           = JsonConvert.DeserializeObject <ViewRecord>(reader);
                BizRecord bizRecord = new BizRecord();
                ViewToDBForModel(bizRecord, model);
                result = recordService.Add(bizRecord);
            });
            if (result)
            {
                return(Json(new { status = "y" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { status = "n" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public void Add(BizRecordDTO dto)
        {
            using (var uow = new UnitOfWork(new DataContext()))
            {
                var obj = new BizRecord();
                obj.Address        = dto.BizAddress;
                obj.BusinessName   = dto.BizName;
                obj.ContactNumber  = dto.BizContactNumber;
                obj.ImageName      = dto.ImageName;
                obj.PersonalInfoID = dto.OwnerID;

                uow.BizRecords.Add(obj);
                uow.Complete();
                dto.ID = obj.BizRecordID;
            }
        }
コード例 #3
0
        public ActionResult Index(BizRecord bizRecord, int page = 1)
        {
            Page <BizRecord>  recordList = new Page <BizRecord>();
            Page <ViewRecord> viewlist   = new Page <ViewRecord>();

            AspectF.Define
            .Log(log, "RecordController-Index[post]开始", "RecordController-Index[post]结束")
            .HowLong(log)
            .Retry(log)
            .Do(() =>
            {
                recordList = recordService.PageList(bizRecord, PageHelper.PageSize, page);
                ViewPageList(recordList, viewlist);
            });
            return(new JsonResultPro(viewlist, JsonRequestBehavior.AllowGet, "yyyy-MM-dd HH:mm:ss"));
        }
コード例 #4
0
        public ActionResult Edit()
        {
            BizAnswerBank bizAnswerBank = new BizAnswerBank();
            bool          result        = false;

            AspectF.Define
            .Log(log, "AnswerBankController-Edit[post]开始", "AnswerBankController-Edit[post]结束")
            .HowLong(log)
            .Retry(log)
            .Do(() =>
            {
                var reader = new StreamReader(Request.InputStream).ReadToEnd();
                var model  = JsonConvert.DeserializeObject <ViewAnswerBank>(reader);
                ViewToDBForModel(bizAnswerBank, model);
                if (string.IsNullOrEmpty(model.id))
                {
                    result = answerBankService.Add(bizAnswerBank);
                    if (!string.IsNullOrEmpty(model.countID))
                    {
                        BizRecord bizRecord         = new BizRecord();
                        bizRecord.RecordID          = model.countID;
                        RecordService recordService = new RecordService();
                        recordService.Delete(new string[] { bizRecord.RecordID });
                    }
                }
                else
                {
                    bizAnswerBank.UpdateTime = DateTime.Now;
                    result = answerBankService.Update(bizAnswerBank);
                }
            });
            if (result)
            {
                return(Json(new { status = "y" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { status = "n" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
ファイル: RuleController.cs プロジェクト: zhu1994829/AiRobot
        public ActionResult GetAnswer(BizRule bizRule, string text)
        {
            RuleResult     ruleResult   = new RuleResult();
            TuLingResult   tuLingResult = new TuLingResult();
            BizRecord      bizRecord    = new BizRecord();
            List <BizRule> bizRules     = new List <BizRule>();

            AspectF.Define
            .Log(log, "RuleController-QueryRule[post]开始", "RuleController-QueryRule[post]结束")
            .HowLong(log)
            .Retry(log)
            .Do(() =>
            {
                text     = RegularRemoveSign(text);
                bizRules = ruleService.List(bizRule).ToList();
                Dictionary <string, string> keyValues = new Dictionary <string, string>();
                foreach (var item in bizRules)
                {
                    //关键字一为Null
                    if (item.KeyWordOne == null)
                    {
                        if (text.Contains(item.KeyWordTwo))
                        {
                            text = text.Substring(0, text.IndexOf(item.KeyWordTwo) + item.KeyWordTwo.Length);
                            string keyWordTwo = item.KeyWordTwo;
                            text    = text.Replace(keyWordTwo, "");
                            bizRule = ruleService.SingleTwo(keyWordTwo);
                        }
                    }
                    //关键字二为Null
                    else if (item.KeyWordTwo == null)
                    {
                        if (text.Contains(item.KeyWordOne))
                        {
                            text    = text.Substring(text.IndexOf(item.KeyWordOne));
                            text    = text.Replace(item.KeyWordOne, "");
                            bizRule = ruleService.SingleOne(item.KeyWordOne);
                        }
                    }
                    //关键字均不为空
                    else if (text.Contains(item.KeyWordOne))
                    {
                        if (text.Contains(item.KeyWordTwo))
                        {
                            text = text.Substring(text.IndexOf(item.KeyWordOne));
                            text = text.Substring(0, text.IndexOf(item.KeyWordTwo) + item.KeyWordTwo.Length);
                            text = text.Replace(item.KeyWordOne, "");
                            text = text.Replace(item.KeyWordTwo, "");
                            keyValues.Add(item.KeyWordOne, item.KeyWordTwo);
                            bizRule = ruleService.Single(keyValues.Keys.SingleOrDefault(), keyValues.Values.SingleOrDefault());
                        }
                    }
                }
            });
            if (bizRule.RuleID == null)
            {
                //图灵机器人回复
                ruleResult.text           = ConnectTu(text).text;
                bizRecord.QuestionContent = text;
                recordService.Add(bizRecord);
            }
            else
            {
                ruleResult.text    = bizRule.Answer;
                ruleResult.url     = bizRule.Website;
                ruleResult.type    = bizRule.AnswerTypes;
                ruleResult.keyword = text;
            }
            return(new JsonResultPro(ruleResult, JsonRequestBehavior.AllowGet, "yyyy-MM-dd"));
        }