Beispiel #1
0
        /// <summary>
        /// tag推荐框选中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TagListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            TagDetail selectedValue = (TagDetail)e.AddedItems[0];

            //选择的tag添加到最后一个空格末尾
            if (this.tagSearchTextBox.Text.Contains(' '))
            {
                int lastSpaceIndex = this.tagSearchTextBox.Text.LastIndexOf(' ');
                //最后一个空格后是否存在+或-
                if (this.tagSearchTextBox.Text.IndexOf(" +", lastSpaceIndex) != -1 || this.tagSearchTextBox.Text.IndexOf(" -", lastSpaceIndex) != -1)
                {
                    this.tagSearchTextBox.Text = string.Format("{0}{1} ", this.tagSearchTextBox.Text.Substring(0, lastSpaceIndex + 2), selectedValue.name);
                }
                else
                {
                    this.tagSearchTextBox.Text = string.Format("{0}{1} ", this.tagSearchTextBox.Text.Substring(0, lastSpaceIndex + 1), selectedValue.name);
                }
            }
            else
            {
                this.tagSearchTextBox.Text = string.Format("{0} ", selectedValue.name);
            }

            //淡出效果
            ListBoxFadeEffect();
        }
Beispiel #2
0
 public ActionResult Extracted(TagDetail tagDetail)
 {
     if (TempData["Tags"] != null)
     {
         tagDetail.Tags = (List <Tag>)TempData["Tags"];
     }
     return(View(tagDetail));
 }
Beispiel #3
0
        public ActionResult Index(string s)
        {
            var files = Request.Files;
            var res   = new TagDetail();

            try
            {
                if (files?.Count > 0)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        var file = files[i];
                        if (file != null)
                        {
                            var    fileName = file.FileName;
                            string filePath = Path.GetFileName(fileName);
                            if (filePath != null)
                            {
                                string fullPath = Path.Combine(Server.MapPath("~/File"), filePath);
                                file.SaveAs(fullPath);
                                var extractedText = Helper.ExtractTextFromPdf(fullPath);
                                if (string.IsNullOrEmpty(extractedText))
                                {
                                    extractedText = ExtractTesseract(fullPath);
                                }
                                var forBank        = _bankContext.GetBankDetail(extractedText);
                                var allIdentifiers = _identifierContext.GetAll();
                                var(noticeTypesName, noticeTypesValue) =
                                    _noticeContext.GetTypes(extractedText?.ToLower(), allIdentifiers);
                                res.NoticeType = string.Join(",", noticeTypesName);
                                res.FileName   = fileName;
                                res.Bank       = forBank.Name;
                                res.Tags       = new List <Tag>();
                                foreach (var notice in noticeTypesValue)
                                {
                                    var resTags =
                                        _tagDetailIdentifierContext.GetTagDetailIdentifier(notice,
                                                                                           extractedText?.ToLower());
                                    res.Tags.AddRange(resTags);
                                }
                            }
                        }
                    }
                }
                TempData["Tags"] = res.Tags;
                res.Executed     = true;
            }
            catch (Exception e)
            {
                throw e;
            }
            int milliseconds = 2000;

            Thread.Sleep(milliseconds);
            //return RedirectToAction("Extracted", res);
            return(View(res));
        }
Beispiel #4
0
        /// <summary>
        /// 获取公众号已创建的标签
        /// </summary>
        /// <returns></returns>
        public async Task <CreateTagDetail> CreateWeiXinTag(TagDetail TAG, string systemToken)
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                string        url           = "https://api.weixin.qq.com/cgi-bin/tags/create?";
                stringBuilder.Append(url);
                stringBuilder.Append("&access_token=" + systemToken);
                var Content     = "{\"tag\":{\"name\":\"" + TAG.name + "\"}}";
                var AccessToken = await httpHelper.PostResponseAsync(stringBuilder.ToString(), Content);

                return(JsonHelper.FromJson <CreateTagDetail>(AccessToken));
            }
            catch (Exception ex)
            {
                return(new CreateTagDetail());
            }
        }
Beispiel #5
0
        // POST: api/Extract
        public ActionResult Post()
        {
            var httpRequest = HttpContext.Current.Request;
            var files       = httpRequest.Files;
            var res         = new TagDetail();

            if (files?.Count > 0)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    var file = files[i];
                    {
                        var    fileName = file.FileName;
                        string filePath = System.IO.Path.GetFileName(fileName);
                        {
                            string fullPath = HttpContext.Current.Server.MapPath("~/File/" + filePath);
                            file.SaveAs(fullPath);
                            var extractedText  = Helper.ExtractTextFromPdf(fullPath);
                            var forBank        = _bankContext.GetBankDetail(extractedText);
                            var allIdentifiers = _identifierContext.GetAll();
                            var(noticeTypesName, noticeTypesValue) = _noticeContext.GetTypes(extractedText.ToLower(), allIdentifiers);
                            res.NoticeType = string.Join(",", noticeTypesName);
                            res.FileName   = fileName;
                            res.Bank       = forBank.Name;
                            res.Tags       = new List <Tag>();
                            foreach (var notice in noticeTypesValue)
                            {
                                var resTags = _tagDetailIdentifierContext.GetTagDetailIdentifier(notice, extractedText.ToLower());
                                res.Tags.AddRange(resTags);
                            }
                        }
                    }
                }
            }
            return(new JsonResult()
            {
                Data = res, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Beispiel #6
0
        public IActionResult AskQuestion(IFormCollection formCollection, AskQuestionViewModel askQuestionViewModel, string submitType)
        {
            using (var unitOfWork = new UnitOfWork(new CuriousDriveContext()))
            {
                int userId = HttpContext.Session.GetInt32("UserId") ?? 0;
                if (submitType == "UpdateQuestion")
                {
                    //new QuestionService().UpdateQuestion(aQuestion, lintUserId);
                    return(RedirectToAction("Question", new
                    {
                        id = askQuestionViewModel.questionId,
                        title = ""
                    }));
                }
                else if (submitType == "CancelUpdateQuestion")
                {
                    return(RedirectToAction("Question", new
                    {
                        id = askQuestionViewModel.questionId,
                        title = ""
                    }));
                }
                else
                {
                    Question question = new Question();

                    question.UserId        = userId;
                    question.QuestionTitle = askQuestionViewModel.questionTitle;
                    question.QuestionHtml  = askQuestionViewModel.questionHtml;

                    question.CreatedBy = question.ModifiedBy = userId;

                    //tag classes
                    string classIds = formCollection["txtClassIds"];

                    if (classIds.Length > 0)
                    {
                        question.QuestionClass = new List <QuestionClass>();

                        foreach (string classId in classIds.Split(','))
                        {
                            QuestionClass questionClass = new QuestionClass();
                            questionClass.ClassId = Convert.ToInt32(classId);

                            question.QuestionClass.Add(questionClass);
                        }
                    }

                    //tag users
                    string taggedUserIds = formCollection["txtUserTags"];

                    if (taggedUserIds.Length > 0)
                    {
                        question.Tag = new List <Tag>();

                        foreach (string taggedUserId in taggedUserIds.Split(','))
                        {
                            Tag tag = new Tag();

                            tag.UserGroupTypeId    = Constant.UserGroupTypeId;
                            tag.UserGroupTypeValue = Constant.UserGroupTypeIndividual;
                            tag.CreatedBy          = tag.ModifiedBy = userId;

                            tag.TagDetail = new List <TagDetail>();

                            TagDetail tagDetail = new TagDetail();
                            tagDetail.TaggedUserId = Convert.ToInt32(taggedUserId);

                            tag.TagDetail.Add(tagDetail);
                            question.Tag.Add(tag);
                        }
                    }

                    unitOfWork.Questions.Add(question);
                    unitOfWork.Complete();

                    return(RedirectToAction("Question", "Question", new { questionId = question.QuestionId }));
                }
            }
        }