Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="queryString">关键字</param>
        /// <param name="documentType">文档类型</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        public List <DocumentSearchResult> Query(string queryString,
                                                 string documentType,
                                                 string userId,
                                                 string depId,
                                                 int?start    = null,
                                                 int?takeSize = null)
        {
            _logger.InfoFormat("SearchService 查询条件:{0},{1}", queryString, documentType);

            if (string.IsNullOrWhiteSpace(queryString))
            {
                return(new List <DocumentSearchResult>());
            }

            var results = _searchProvider.Query <DocumentSearchResult>(queryString.Trim(), start, takeSize);

            if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(depId))
            {
                results = results.FindAll(f => f.CreateUserId == userId || (f.DepId == depId && f.Visible == (int)Visible.Dep) ||
                                          f.Visible == (int)Visible.Public);
            }


            if (!string.IsNullOrWhiteSpace(documentType))
            {
                results = results.FindAll(f => f.DocumentType == documentType);
            }

            foreach (var result in results)
            {
                result.Name    = SplitContent.HightLightTitle(queryString, result.Name);
                result.Content = SplitContent.HightLight(queryString, result.Content);
            }
            return(results);
        }
Example #2
0
        public ActionResult Search(string searchText, string onlySearchMine, int?page)
        {
            int pageSize   = PAGE_SIZE;
            int pageNumber = page ?? 1;

            ViewBag.CurrentFilter    = searchText;
            ViewBag.IsOnlySearchMine = onlySearchMine != null && onlySearchMine.Equals("on", StringComparison.InvariantCultureIgnoreCase);

            if (!String.IsNullOrWhiteSpace(searchText))
            {
                bool isOnlySearchMine = ViewBag.IsOnlySearchMine;
                var  result           = docMgr.Search(searchText, UserId, isOnlySearchMine);
                if (result != null && result.Count > 0)
                {
                    foreach (var r in result)
                    {
                        r.title    = SplitContent.HightLight(searchText, r.title);
                        r.content  = SplitContent.HightLight(searchText, r.content != null ? r.content.StripHTML() : "");
                        r.category = SplitContent.HightLight(searchText, r.category);
                    }

                    return(View(result.ToPagedList(pageNumber, pageSize)));
                }
            }

            return(View());
        }
Example #3
0
        private void SearchFromIndexSelf()
        {
            int    max  = new SUC_NEWS().MaxID();
            int    rand = new Random().Next(max);
            string name = new SUC_NEWS().FindByCondition(new SUC_NEWS()
            {
                ID = rand
            })[0].TITLE;

            string[] titles = SplitContent.SplitWords(name);
            rand = new Random().Next(titles.Length);
            SearchFromIndexData(titles[rand]);
        }
Example #4
0
        private void SearchFromIndexData(string searchkey)
        {
            string        indexPath = Context.Server.MapPath("~/IndexData");
            FSDirectory   directory = FSDirectory.Open(new DirectoryInfo(indexPath), new NoLockFactory());
            IndexReader   reader    = IndexReader.Open(directory, true);
            IndexSearcher searcher  = new IndexSearcher(reader);
            //搜索条件
            PhraseQuery query = new PhraseQuery();

            //把用户输入的关键字进行分词
            foreach (string word in SplitContent.SplitWords(searchkey))
            {
                query.Add(new Term("TITLE", word));
            }
            //query.Add(new Term("content", "C#"));//多个查询条件时 为且的关系
            query.SetSlop(100);  //指定关键词相隔最大距离

            //TopScoreDocCollector盛放查询结果的容器
            TopScoreDocCollector collector = TopScoreDocCollector.create(1000, true);

            searcher.Search(query, null, collector);                                    //根据query查询条件进行查询,查询结果放入collector容器
            //TopDocs 指定0到GetTotalHits() 即所有查询结果中的文档 如果TopDocs(20,10)则意味着获取第20-30之间文档内容 达到分页的效果
            ScoreDoc[] docs = collector.TopDocs(0, collector.GetTotalHits()).scoreDocs; //collector.GetTotalHits()

            //展示数据实体对象集合
            for (int i = 0; i < docs.Length; i++)
            {
                int      docID = docs[i].doc;         //得到查询结果文档的ID(Lucene内部分配的ID)
                Document doc   = searcher.Doc(docID); //根据文档ID来获得文档对象Document
                SUC_NEWS mod   = new SUC_NEWS();
                mod.TITLE = SplitContent.HightLight(searchkey, doc.Get("TITLE"));
                mod.TITLE = string.IsNullOrEmpty(mod.TITLE) ? doc.Get("TITLE") : mod.TITLE;
                //book.ContentDESCRPTION = doc.Get("content");//未使用高亮
                //搜索关键字高亮显示 使用盘古提供高亮插件
                mod.CONTENT     = SplitContent.HightLight(searchkey, doc.Get("CONTENT"));
                mod.CONTENT     = string.IsNullOrEmpty(mod.CONTENT) ? doc.Get("CONTENT") : mod.CONTENT;
                mod.CONTENT     = mod.CONTENT.Replace("<b>", "");
                mod.ID          = Convert.ToInt32(doc.Get("ID"));
                mod.pandaWebUrl = doc.Get("URL");
                modResult.Add(mod);
            }
        }
Example #5
0
        public ActionResult SearchByCategory(string category, bool byOwner, int?page)
        {
            ViewBag.CurrentFilter = category;

            if (!String.IsNullOrWhiteSpace(category))
            {
                int pageSize   = PAGE_SIZE;
                int pageNumber = page ?? 1;
                var result     = docMgr.SearchByCategory(category, byOwner ? UserId : "");
                foreach (var r in result)
                {
                    r.title    = r.title;
                    r.content  = r.content.StripHTML().GetShortDesc();
                    r.category = SplitContent.HightLight(category, r.category);
                }

                return(View("Search", result.ToPagedList(pageNumber, pageSize)));
            }

            return(View("Search"));
        }
Example #6
0
        public async Task TestSplitReservationOrder()
        {
            var response = await Collection.GetAsync(ReservationOrderId);

            Assert.AreEqual(200, response.GetRawResponse().Status);
            Assert.IsNotNull(response.Value);
            Assert.IsNotNull(response.Value.Data);
            Assert.IsNotNull(response.Value.Data.Reservations);
            Assert.AreEqual(1, response.Value.Data.Reservations.Count);

            var fullyQualifiedId    = response.Value.Data.Reservations[0].Id.ToString();
            var reservationId       = fullyQualifiedId.Substring(fullyQualifiedId.LastIndexOf("/"));
            var reservationResponse = await response.Value.GetReservationResponses().GetAsync(reservationId);

            var reservation = reservationResponse.Value;

            Assert.IsNotNull(reservation.Data);
            Assert.IsNotNull(reservation.Data.Properties);
            Assert.IsNotNull(reservation.Data.Properties.Quantity);
            Assert.IsTrue(reservation.Data.Properties.Quantity > 1);

            var splitContent = new SplitContent
            {
                ReservationId = fullyQualifiedId
            };

            splitContent.Quantities.Add(1);
            splitContent.Quantities.Add((int)reservation.Data.Properties.Quantity - 1);

            var splitResponse = await response.Value.SplitReservationAsync(WaitUntil.Completed, splitContent);

            Assert.IsNotNull(splitResponse.Value);
            Assert.AreEqual(3, splitResponse.Value.Count);
            Assert.AreEqual(1, splitResponse.Value[0].Properties.Quantity);
            Assert.AreEqual(ProvisioningState.Succeeded, splitResponse.Value[0].Properties.ProvisioningState);
            Assert.AreEqual(9, splitResponse.Value[1].Properties.Quantity);
            Assert.AreEqual(ProvisioningState.Succeeded, splitResponse.Value[1].Properties.ProvisioningState);
            Assert.AreEqual(10, splitResponse.Value[2].Properties.Quantity);
            Assert.AreEqual(ProvisioningState.Cancelled, splitResponse.Value[2].Properties.ProvisioningState);
        }
Example #7
0
        public ActionResult SearchBook(string searchText)
        {
            ViewBag.CurrentFilter = searchText;

            if (!String.IsNullOrWhiteSpace(searchText))
            {
                var result = docMgr.SearchBook(searchText, UserId);
                if (result != null && result.Count > 0)
                {
                    foreach (var r in result)
                    {
                        r.name = SplitContent.HightLight(searchText, r.name);

                        r.description = SplitContent.HightLight(searchText, r.description.StripHTML());

                        r.category = SplitContent.HightLight(searchText, r.category);
                    }

                    return(View(result));
                }
            }

            return(View());
        }
Example #8
0
        /// <summary>
        /// Creates the daigram
        /// </summary>
        /// <param name="businessType">Type of the List to be added</param>
        private void CreateDiagram(string businessType)
        {
            RectangleF rect           = new RectangleF(10, 10, 1400, 60);
            TextNode   nodeRectHeader = new TextNode("Safety", rect);

            nodeRectHeader.BackgroundStyle.Color = Color.FromArgb(84, 167, 167);
            nodeRectHeader.LineStyle.LineWidth   = 1;
            nodeRectHeader.FontStyle.Size        = 32;
            nodeRectHeader.FontStyle.Bold        = true;
            nodeRectHeader.FontStyle.Italic      = true;
            nodeRectHeader.FontColorStyle.Color  = Color.White;
            nodeRectHeader.ReadOnly              = true;
            nodeRectHeader.HorizontalAlignment   = StringAlignment.Near;
            nodeRectHeader.VerticalAlignment     = StringAlignment.Center;
            nodeRectHeader.EditStyle.AllowSelect = false;
            //FY10 goal is to  provide a safe working environment for our employees.Achieve this through improvement in the key categorie of severity and frequency rates.
            EllipseRectGroup erg = new EllipseRectGroup(1, "Vision", "Vision-1", Color.Red, Color.Black, Color.LightBlue, Color.White);
            GridGroup        gg  = new GridGroup();

            HeaderandEllipse he1 = new HeaderandEllipse(2, "Goals", Color.Red, Color.LightBlue, 13);
            HeaderandEllipse he2 = new HeaderandEllipse(3, "Objectives", Color.Red, Color.LightBlue, 13);
            HeaderandEllipse he3 = new HeaderandEllipse(4, "Key Tasks", Color.Red, Color.LightBlue, 12);

            SplitContent             spc  = new SplitContent("Who \n(leader)", "Resources Investor", Color.LightBlue, true, 12, true);
            GridGroupShapesandNumber ggsn = new GridGroupShapesandNumber("Schedule(Month)", Color.LightBlue);
            SplitContent             spc2 = new SplitContent("Comments", "Cost Savings", Color.LightBlue, true, 12, true);

            int nameIndex = 0;
            List <HoshinKanriListItem> hoshinList = GenerateList(businessType);
            float contentPinPointY = 400, splitContentPinpointY = 400, gridSymbolPinpointY = 390, subContentPinPointY = 400;

            for (int i = 0; i < hoshinList.Count; i++)
            {
                ContentRectangle content = new ContentRectangle(hoshinList[i].Content, Color.Black, Color.LightGreen, false, 13, true);
                content.PinPoint = new PointF(10 + content.BoundingRectangle.Width / 2, contentPinPointY + content.BoundingRectangle.Height / 2);
                diagram1.Model.AppendChild(content);

                ContentRectangle content1 = new ContentRectangle(hoshinList[i].Content1, Color.Black, Color.LightGreen, false, 10, true);
                content1.PinPoint = new PointF(230 + content1.BoundingRectangle.Width / 2, contentPinPointY + content1.BoundingRectangle.Height / 2);
                diagram1.Model.AppendChild(content1);

                lineconnector = getLineConnectorOrdinary(content.PinPoint, content1.PinPoint);
                content.CentralPort.TryConnect(lineconnector.HeadEndPoint);
                content1.CentralPort.TryConnect(lineconnector.TailEndPoint);
                this.diagram1.Model.AppendChild(lineconnector);

                for (int j = 0; j < hoshinList[i].Leader.Count; j++)
                {
                    SplitContent splitContent = new SplitContent(hoshinList[i].Leader[j], hoshinList[i].Resources[j], Color.Gray, false, 10, false);
                    splitContent.Name     = "splitContent" + (nameIndex + 1);
                    splitContent.PinPoint = new PointF(690 + splitContent.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent.BoundingRectangle.Height / 2);
                    diagram1.Model.AppendChild(splitContent);

                    GridSymbols gridSymbol = new GridSymbols(hoshinList[i].Plan[j], hoshinList[i].Actual[j], hoshinList[i].ToolTip[j]);
                    gridSymbol.Name     = "gridSymbol" + (nameIndex + 1);
                    gridSymbol.PinPoint = new PointF(920 + gridSymbol.BoundingRectangle.Width / 2, 2 + gridSymbolPinpointY + gridSymbol.BoundingRectangle.Height / 2);
                    diagram1.Model.AppendChild(gridSymbol);

                    SplitContent splitContent1 = new SplitContent(hoshinList[i].Comments[j], hoshinList[i].CostSavings[j], Color.LightGray, false, 10, false);
                    splitContent1.Name     = "splitContent1" + (nameIndex + 1);
                    splitContent1.PinPoint = new PointF(1160 + splitContent1.BoundingRectangle.Width / 2, splitContentPinpointY + splitContent1.BoundingRectangle.Height / 2);
                    diagram1.Model.AppendChild(splitContent1);

                    if (!hoshinList[i].IsOuterRectangle[j])
                    {
                        ContentRectangle subContent = new ContentRectangle(hoshinList[i].SubContent[j], Color.Black, Color.LightGreen, false, 10, true);
                        subContent.PinPoint = new PointF(460 + subContent.BoundingRectangle.Width / 2, subContentPinPointY + subContent.BoundingRectangle.Height / 2);
                        diagram1.Model.AppendChild(subContent);

                        lineconnector = getLineConnectorOrdinary(content1.PinPoint, subContent.PinPoint);
                        content1.CentralPort.TryConnect(lineconnector.TailEndPoint);
                        subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint);
                        this.diagram1.Model.AppendChild(lineconnector);

                        lineconnector = getLineConnectorOrdinary(subContent.PinPoint, splitContent.PinPoint);
                        splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint);
                        subContent.CentralPort.TryConnect(lineconnector.HeadEndPoint);
                        this.diagram1.Model.AppendChild(lineconnector);
                    }
                    else
                    {
                        ContentWithOuterRectangle subContent1 = new ContentWithOuterRectangle(hoshinList[i].SubContent[j], "A3", Color.LightGreen, Color.Pink);
                        subContent1.PinPoint = new PointF(460 + subContent1.BoundingRectangle.Width / 2, subContentPinPointY + subContent1.BoundingRectangle.Height / 2 - 20);
                        diagram1.Model.AppendChild(subContent1);

                        orthogoanlConnector = getOrthogonalConnector(content1.PinPoint, subContent1.PinPoint);
                        content1.CentralPort.TryConnect(orthogoanlConnector.TailEndPoint);
                        subContent1.CentralPort.TryConnect(orthogoanlConnector.HeadEndPoint);
                        this.diagram1.Model.AppendChild(orthogoanlConnector);

                        lineconnector = getLineConnectorOrdinary(subContent1.PinPoint, splitContent.PinPoint);
                        splitContent.CentralPort.TryConnect(lineconnector.TailEndPoint);
                        subContent1.CentralPort.TryConnect(lineconnector.HeadEndPoint);
                        this.diagram1.Model.AppendChild(lineconnector);
                    }
                    nameIndex++;
                    //if (!hoshinList[i].IsOuterRectangle[j])
                    //{
                    //    contentPinPointY += 65;
                    //    splitContentPinpointY += 65; gridSymbolPinpointY += 65; subContentPinPointY += 65;
                    //}
                    //else
                    //{

                    //}
                    contentPinPointY      += 85;
                    splitContentPinpointY += 85; gridSymbolPinpointY += 85; subContentPinPointY += 85;
                    //if (j < hoshinList[i].Leader.Count)
                    //{
                    //    if (hoshinList[i].IsOuterRectangle[j])
                    //    {
                    //        contentPinPointY += (120-85);
                    //        splitContentPinpointY += (130 - 85); gridSymbolPinpointY += (130 - 85); subContentPinPointY += (120 - 85);
                    //    }
                    //}
                }
            }

            HeaderRectangleActual actualrect = new HeaderRectangleActual();
            HeaderRectanglePlan   planrect   = new HeaderRectanglePlan();

            erg.PinPoint            = new PointF(10 + erg.BoundingRectangle.Width / 2, erg.BoundingRectangle.Height / 2 + 120);
            erg.CentralPort.OffsetX = he1.PinPoint.X;
            he1.PinPoint            = new PointF(10 + he1.BoundingRectangle.Width / 2, 330 + he1.BoundingRectangle.Height / 2);
            he2.PinPoint            = new PointF(230 + he2.BoundingRectangle.Width / 2, 330 + he2.BoundingRectangle.Height / 2);
            he3.PinPoint            = new PointF(460 + he3.BoundingRectangle.Width / 2, 330 + he3.BoundingRectangle.Height / 2);
            spc.PinPoint            = new PointF(690 + spc.BoundingRectangle.Width / 2, 330 + spc.BoundingRectangle.Height / 2);
            ggsn.PinPoint           = new PointF(920 + ggsn.BoundingRectangle.Width / 2, 330 + ggsn.BoundingRectangle.Height / 2);
            spc2.PinPoint           = new PointF(1160 + spc2.BoundingRectangle.Width / 2, 330 + spc2.BoundingRectangle.Height / 2);
            actualrect.PinPoint     = new PointF(630 + actualrect.BoundingRectangle.Width / 2, actualrect.BoundingRectangle.Height / 2 + 103);
            planrect.PinPoint       = new PointF(400 + planrect.BoundingRectangle.Width / 2, planrect.BoundingRectangle.Height / 2 + 103);
            gg.PinPoint             = new PointF(900 + gg.BoundingRectangle.Width / 2, gg.BoundingRectangle.Height / 2 + 143);

            this.diagram1.Model.AppendChild(erg);
            this.diagram1.Model.AppendChild(gg);
            this.diagram1.Model.AppendChild(ggsn);
            this.diagram1.Model.AppendChild(he1);
            this.diagram1.Model.AppendChild(he2);
            this.diagram1.Model.AppendChild(he3);
            this.diagram1.Model.AppendChild(spc);
            this.diagram1.Model.AppendChild(spc2);

            this.diagram1.Model.AppendChild(planrect);
            this.diagram1.Model.AppendChild(actualrect);

            this.diagram1.Model.AppendChild(nodeRectHeader);

            lineconnector = getLineConnector(erg.PinPoint, he1.PinPoint);
            erg.CentralPort.TryConnect(lineconnector.TailEndPoint);
            he1.CentralPort.TryConnect(lineconnector.HeadEndPoint);

            this.diagram1.Model.AppendChild(lineconnector);

            lineconnector = getLineConnector(he1.PinPoint, he2.PinPoint);
            he1.CentralPort.TryConnect(lineconnector.TailEndPoint);
            he2.CentralPort.TryConnect(lineconnector.HeadEndPoint);
            this.diagram1.Model.AppendChild(lineconnector);

            lineconnector = getLineConnector(he2.PinPoint, he3.PinPoint);
            he2.CentralPort.TryConnect(lineconnector.TailEndPoint);
            he3.CentralPort.TryConnect(lineconnector.HeadEndPoint);
            this.diagram1.Model.AppendChild(lineconnector);

            lineconnector = getLineConnector(he3.PinPoint, spc.PinPoint);
            he3.CentralPort.TryConnect(lineconnector.TailEndPoint);
            spc.CentralPort.TryConnect(lineconnector.HeadEndPoint);
            this.diagram1.Model.AppendChild(lineconnector);
        }
        public virtual ArmOperation <IList <ReservationResponseData> > SplitReservation(WaitUntil waitUntil, SplitContent content, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(content, nameof(content));

            using var scope = _reservationResponseReservationClientDiagnostics.CreateScope("ReservationOrderResponseResource.SplitReservation");
            scope.Start();
            try
            {
                var response  = _reservationResponseReservationRestClient.Split(Id.Name, content, cancellationToken);
                var operation = new ReservationsArmOperation <IList <ReservationResponseData> >(new IListOperationSource(), _reservationResponseReservationClientDiagnostics, Pipeline, _reservationResponseReservationRestClient.CreateSplitRequest(Id.Name, content).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }