예제 #1
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="termbaseInfo"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        public void SetData(string termbaseInfo, TermInfo info)
        {
            try
            {
                _Terms.Clear();

                txtTermBaseInfo.ForeColor = Color.Black;
                txtTermBaseInfo.Text = termbaseInfo;

                txtID.Text = info.TermID == null ? "" : info.TermID.ToString();

                string html = MakeHTML(info);
            #if true
                webControl.DocumentText = html;
            #else
                // When AllowNavigation is set to false we need to use OpenNew/Write to replace existing content
                // But this steals the focus
                if (webControl.Document == null)
                {
                    webControl.DocumentText = html;
                }
                else
                {
                    webControl.Document.OpenNew(true);
                    webControl.Document.Write(html);
                }
            #endif

            }
            catch (Exception ex)
            {
                txtTermBaseInfo.Text = ex.Message;
                txtTermBaseInfo.ForeColor = Color.Red;
            }
        }
예제 #2
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (_LangIndex1 < 0 || _LangIndex2 < 0)
                return false;

            if (termID < 0 || termID >= _Terms.Count)
                return false;

            info = new TermInfo();
            info.TermID = termID;

            TermInfo.LangSet langset1 = info.AddLanguage(_Languages[_LangIndex1]);
            if (langset1 == null)
                return false;

            langset1.AddTerm(_Terms[termID].Item1);

            TermInfo.LangSet langset2 = info.AddLanguage(_Languages[_LangIndex2]);
            if (langset2 == null)
                return false;

            langset2.AddTerm(_Terms[termID].Item2);

            return true;
        }
예제 #3
0
		internal void  Set(TermInfo ti)
		{
			docFreq = ti.docFreq;
			freqPointer = ti.freqPointer;
			proxPointer = ti.proxPointer;
			skipOffset = ti.skipOffset;
		}
예제 #4
0
        internal override void Seek(TermInfo ti, Term term)
        {
            base.Seek(ti, term);
            if (ti != null)
            {
                LazySkipPointer = ti.ProxPointer;
            }

            LazySkipProxCount = 0;
            ProxCount = 0;
            PayloadLength_Renamed = 0;
            NeedToLoadPayload = false;
        }
예제 #5
0
        /// <summary>
        /// 단말을 리스트뷰에 추가한다.
        /// </summary>
        /// <param name="termInfo"></param>
        private void AddTermListView(TermInfo eachTermInfo)
        {
            NCasListViewItem lvi = null;

            foreach (NCasListViewItem eachLvi in this.selectTermListView.Items)
            {
                if (eachLvi.Name == eachTermInfo.IpAddrToSring)
                {
                    lvi = eachLvi;
                    break;
                }
            }

            if (lvi != null)
            {
                return;
            }

            lvi = null;

            if (eachTermInfo.UseFlag != NCasDefineUseStatus.Use)
            {
                return;
            }

            lvi           = new NCasListViewItem();
            lvi.Name      = eachTermInfo.IpAddrToSring;
            lvi.Text      = eachTermInfo.Name;
            lvi.TextAlign = HorizontalAlignment.Left;
            lvi.Tag       = eachTermInfo;

            NCasListViewItem.NCasListViewSubItem sub = new NCasListViewItem.NCasListViewSubItem();
            sub.Text      = eachTermInfo.IpAddrToSring;
            sub.TextAlign = HorizontalAlignment.Center;
            lvi.SubItems.Add(sub);

            sub           = new NCasListViewItem.NCasListViewSubItem();
            sub.Text      = eachTermInfo.DistInfo.Name;
            sub.TextAlign = HorizontalAlignment.Center;
            lvi.SubItems.Add(sub);

            this.selectTermListView.Items.Add(lvi);

            if (this.selectTermListView.Items.Count == this.provInfo.GetUsableAlarmTermCnt())
            {
                if (this.TermAllSelectEvent != null)
                {
                    this.TermAllSelectEvent(this, new EventArgs());
                }
            }
        }
예제 #6
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (termID < 0 || termID >= _Langset1.Count)
                return false;

            try
            {
                info = new TermInfo();
                info.TermID = termID;

                XmlNode nodeLangset1 = _Langset1[termID];

                // Entry
                XmlNode nodeEntry = nodeLangset1.ParentNode;
                ReadProps(nodeEntry, ref info._Props);

                // Language 1
                int lcid1 = GetLCIDFromAttributeName(_LangAttribute1);
                if (lcid1 < 0)
                    return false;

                TermInfo.LangSet langset1 = info.AddLanguage(lcid1);
                ReadLangset(nodeLangset1, langset1);

                // Language 2
                int lcid2 = GetLCIDFromAttributeName(_LangAttribute2);
                if (lcid2 < 0)
                    return true;

                string xpath = string.Format("./langSet[@xml:lang='{0}']", _LangAttribute2);
                XmlNode nodeLangset2 = nodeLangset1.ParentNode.SelectSingleNode(xpath, _NamespaceManager);

                if (nodeLangset2 != null)
                {
                    TermInfo.LangSet langset2 = info.AddLanguage(lcid2);
                    ReadLangset(nodeLangset2, langset2);
                }

                return true;
            }
            catch (Exception ex)
            {
                info = new TermInfo();
                info._Props = new TermInfo.Properties();
                info._Props.Definition = ex.Message;
                return true;
            }
        }
예제 #7
0
        public void UnInit()
        {
            D("UnInit");

            if (!m_initialized)
            {
                Dbg.WriteLine("WARNING Terminal not initialized");
                return;
            }

            GNUReadLine.rl_callback_handler_remove();
            TermInfo.UnInit();
            m_initialized = false;

            Save();
        }
예제 #8
0
    private static void TermThreadProc(object data)
    {
        TermInfo tinfo = (TermInfo)data;

        Console.WriteLine("Term[{0}] is starting...", tinfo.order);
        // set the precalculation
        int preValue = DateTime.Now.Millisecond + tinfo.order;

        // wait for base value to be ready
        tinfo.trigger.WaitOne();
        Random rnd = new Random(tinfo.baseValue);

        tinfo.terms[tinfo.order] = preValue * rnd.Next(10000);
        Console.WriteLine("Term[{0}] has finished with a value of: {1}",
                          tinfo.order, tinfo.terms[tinfo.order]);
    }
예제 #9
0
        /// <summary>
        /// 단말을 리스트뷰에서 제거한다.
        /// </summary>
        /// <param name="termInfo"></param>
        private void RemoveTermListView(TermInfo termInfo)
        {
            NCasListViewItem lvi = null;

            foreach (NCasListViewItem eachLvi in this.selectTermListView.Items)
            {
                if (eachLvi.Name == termInfo.IpAddrToSring)
                {
                    lvi = eachLvi;
                    break;
                }
            }

            if (lvi != null)
            {
                this.selectTermListView.Items.Remove(lvi);
            }
        }
예제 #10
0
        /// <summary>
        /// Method to take a term configured as a term driven page to a simple link url.
        /// </summary>
        /// <param name="web">The web for which we want to change a term's target URL in its taxonomy navigation term set</param>
        /// <param name="termInfo">The metadata term to reset</param>
        public void ResetTermDrivenPageToSimpleLinkUrl(SPWeb web, TermInfo termInfo)
        {
            // Get the web-specific navigation settings
            var webNavigationSettings = new WebNavigationSettings(web);

            var taxonomySession = new TaxonomySession(web.Site);
            var defaultStore    = taxonomySession.TermStores[webNavigationSettings.GlobalNavigation.TermStoreId];
            var termSet         = defaultStore.GetTermSet(webNavigationSettings.GlobalNavigation.TermSetId);

            // Get the taxonomy term
            var term = termSet.GetTerm(termInfo.Id);

            if (term != null)
            {
                term.SetLocalCustomProperty(SystemTargetUrl, string.Empty);
                term.TermSet.TermStore.CommitAll();
            }
        }
예제 #11
0
        /// <inheritdoc cref="AbstractCommand.Execute" />
        public override ServerResponse Execute
        (
            ClientQuery query
        )
        {
            Sure.NotNull(query, nameof(query));

            ServerResponse result = base.Execute(query);

            CheckResponse(result);

            // ReSharper disable CoVariantArrayConversion
            Terms = string.IsNullOrEmpty(Format)
                ? TermInfo.Parse(result)
                : TermInfoEx.ParseEx(result);
            // ReSharper restore CoVariantArrayConversion

            return(result);
        }
예제 #12
0
        /// <summary>
        /// Deletes all refiners for the specified term and its reuses regardless previous configuration
        /// </summary>
        /// <param name="site">The site</param>
        /// <param name="term">The term info object</param>
        public void RemoveFacetedRefinersForTerm(SPSite site, TermInfo term)
        {
            // Get the term
            var termItem = this.taxonomyService.GetTermForId(site, term.Id);

            var properties = new[] { "_Sys_Facet_FullRefinementString", "_Sys_Facet_RefinementConfig", "_Sys_Facet_RefinerConfig" };

            foreach (var prop in properties)
            {
                string tmp;
                termItem.CustomProperties.TryGetValue(prop, out tmp);
                if (tmp != null)
                {
                    termItem.DeleteCustomProperty(prop);
                }
            }

            termItem.TermStore.CommitAll();
        }
예제 #13
0
        static void AnalyzeTerms()
        {
            TermParameters parameters = new TermParameters
            {
                Database      = connection.Database,
                StartTerm     = "RD=",
                NumberOfTerms = 10000
            };

            TermInfo[] terms = connection.ReadTerms(parameters);
            terms = terms.Where(ti => ti.Text.SafeStarts("RD=201"))
                    .ToArray();
            terms = TermInfo.TrimPrefix(terms, "RD=");
            foreach (TermInfo term in terms)
            {
                DateTime date = IrbisDate.ConvertStringToDate(term.Text);
                Console.WriteLine("{0:yyyy-MM-dd}\t{1}", date, term.Count);
            }
        }
예제 #14
0
        private void termListView_ItemChecked(object sender, NCasItemCheckedEventArgs e)
        {
            TermInfo ti = null;

            for (int i = 0; i < this.termListView.Items.Count; i++)
            {
                if (e.Item.Name == this.termListView.Items[i].Name)
                {
                    ti = this.termListView.Items[i].Tag as TermInfo;
                }
            }

            if (e.Item.Checked)
            {
                if (this.AddTermDestinationEvent != null)
                {
                    this.AddTermDestinationEvent(this, new TermSelectEventArgs(ti));
                }
            }
            else
            {
                if (this.RemoveTermDestinationEvent != null)
                {
                    this.RemoveTermDestinationEvent(this, new TermSelectEventArgs(ti));
                }
            }

            if (this.termListView.Items.Count == this.termListView.CheckedItems.Count)
            {
                if (this.TermAllSelectEvent != null)
                {
                    this.TermAllSelectEvent(this, new EventArgs());
                }
            }

            if (this.termListView.CheckedItems.Count == 0)
            {
                if (this.TermAllCancelEvent != null)
                {
                    this.TermAllCancelEvent(this, new EventArgs());
                }
            }
        }
예제 #15
0
        private async void _newPartyBox_Click
        (
            object sender,
            EventArgs e
        )
        {
            DataGridViewRow currentRow = _ksuGrid.CurrentRow;

            if (ReferenceEquals(currentRow, null))
            {
                return;
            }

            TermInfo register = currentRow.DataBoundItem as TermInfo;

            if (ReferenceEquals(register, null))
            {
                return;
            }

            try
            {
                _busyStripe.Moving  = true;
                _busyStripe.Visible = true;

                string ksu = register.Text.ThrowIfNull("ksu");

                WriteLine("Партия: {0}", ksu);

                List <ExemplarInfo> exemplars = await Task.Run
                                                (
                    () => ControlCenter.GetExemplars(ksu)
                                                );

                SetExemplars(exemplars);
            }
            finally
            {
                _busyStripe.Visible = false;
                _busyStripe.Moving  = false;
            }
        }
예제 #16
0
 public TermDrivenPageSettingInfo(
     TermInfo term,
     string targetUrl,
     string catalogTargetUrl,
     string targetUrlForChildTerms,
     string catalogTargetUrlForChildTerms,
     bool excludeFromGlobalNav,
     bool excludeFromCurrentNav)
 {
     this.TargetUrlForChildTerms        = targetUrlForChildTerms;
     this.CatalogTargetUrlForChildTerms = catalogTargetUrlForChildTerms;
     this.Term                         = term;
     this.TargetUrl                    = targetUrl;
     this.CatalogTargetUrl             = catalogTargetUrl;
     this.IsTermSet                    = false;
     this.IsTerm                       = true;
     this.ExcludeFromGlobalNavigation  = excludeFromGlobalNav;
     this.ExcludeFromCurrentNavigation = excludeFromCurrentNav;
     this.IsSimpleLinkOrHeader         = false;
 }
예제 #17
0
        /// <summary>
        /// 제거 화살표 버튼 클릭 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void removeBtn_Click(object sender, EventArgs e)
        {
            if (this.selectTermListView.SelectedItems.Count == 0)
            {
                MessageBox.Show("취소할 발령대상 단말을 선택하세요.", "개별 단말 선택", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            TermInfo termInfo = this.selectTermListView.SelectedItems[0].Tag as TermInfo;

            if (this.RemoveTermDestinationEvent != null)
            {
                this.RemoveTermDestinationEvent(this, new TermSelectEventArgs(termInfo));
            }

            this.RemoveTermListView(termInfo);

            foreach (TreeNode treeNode in this.termListTreeView.Nodes)
            {
                if (treeNode.Name == termInfo.IpAddrToSring)
                {
                    treeNode.Checked = false;
                    break;
                }

                foreach (TreeNode subTreeNode in treeNode.Nodes)
                {
                    if (subTreeNode.Name == termInfo.IpAddrToSring)
                    {
                        subTreeNode.Checked = false;

                        if (treeNode.Checked == true)
                        {
                            treeNode.Checked = false;
                        }

                        return;
                    }
                }
            }
        }
예제 #18
0
        /// <summary>
        /// 리스트뷰를 더블클릭할 때 발생하는 이벤트
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void selectTermListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (this.selectTermListView.SelectedItems.Count == 0)
            {
                return;
            }

            TermInfo termInfo = this.selectTermListView.SelectedItems[0].Tag as TermInfo;

            if (this.RemoveTermDestinationEvent != null)
            {
                this.RemoveTermDestinationEvent(this, new TermSelectEventArgs(termInfo));
            }

            this.RemoveTermListView(termInfo);

            foreach (TreeNode treeNode in this.termListTreeView.Nodes)
            {
                if (treeNode.Name == termInfo.IpAddrToSring)
                {
                    treeNode.Checked = false;
                    break;
                }

                foreach (TreeNode subTreeNode in treeNode.Nodes)
                {
                    if (subTreeNode.Name == termInfo.IpAddrToSring)
                    {
                        subTreeNode.Checked = false;

                        if (treeNode.Checked == true)
                        {
                            treeNode.Checked = false;
                        }

                        return;
                    }
                }
            }
        }
예제 #19
0
        ///<summary>Function to fetch data from tblTerm based on parameters</summary>
        ///<param name="termId"></param>

        public TermInfo TermViewOne(decimal termId)
        {
            TermInfo termInfo = new TermInfo();

            try
            {
                MySqlDataReader sqlreader = null;


                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }

                MySqlCommand sqlcmd = new MySqlCommand("TermViewOne", sqlcon);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter sqlparam = new MySqlParameter();
                sqlparam       = sqlcmd.Parameters.Add("?termId", MySqlDbType.Int32);
                sqlparam.Value = termId;
                sqlreader      = sqlcmd.ExecuteReader();

                while (sqlreader.Read())
                {
                    termInfo.TermName  = sqlreader[1].ToString();
                    termInfo.DateStart = Convert.ToDateTime(sqlreader[2].ToString());
                    termInfo.DateEnd   = Convert.ToDateTime(sqlreader[3].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            finally
            {
                sqlcon.Close();
            }
            return(termInfo);
        }
예제 #20
0
        /// <summary>
        /// 경보단말 ListView 업데이트
        /// </summary>
        private void setTermStatusUpdate()
        {
            foreach (NCasListViewItem listViewItem in this.termStatusListView.Items)
            {
                if (listViewItem == null)
                {
                    continue;
                }

                if (listViewItem.Name == string.Empty)
                {
                    continue;
                }

                TermInfo pTermInfo = this.main.MmfMng.GetTermInfoByIp(listViewItem.Name);

                if (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.Noraml)
                {
                    listViewItem.ImageIndex = 1;
                }
                else
                {
                    listViewItem.ImageIndex = 0;
                }

                listViewItem.SubItems[3].Text = (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.None) ? "없음" :
                                                (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.NoAnswer) ? "무응답" :
                                                (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.Abnormal) ? "이상" : "정상";

                if ((pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.Abnormal) || (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.NoAnswer))
                {
                    listViewItem.SubItems[4].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.DevStsInfo.OccurTimeToDateTime);
                }
                else if (pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.Noraml || pTermInfo.DevStsInfo.Status == NCasDefineNormalStatus.None)
                {
                    listViewItem.SubItems[4].Text = string.Empty;
                }
            }
        }
        public Task <AttendanceGrid> GetReportAttendance(int batchID, int studentID)
        {
            return(Task.Run(async() =>
            {
                using (MIUEntities db = new MIUEntities())
                {
                    //try
                    //{
                    if (batchID != 0)
                    {
                        string modulecodelist = "";
                        AttendanceGrid grid = new AttendanceGrid();

                        //var terms = db.Terms.AsNoTracking().Where(x => x.BatchID == batchID).Select(x => new { ID = x.ID, TermName = x.TermName, StartDate = x.StartDate, sortOrer = x.sortOrder }).OrderBy(y => y.sortOrer).ToList();
                        List <Term> terms = db.Terms.AsNoTracking().Where(x => x.BatchID == batchID).OrderBy(y => y.sortOrder).ToList();

                        AttRateAndPercent attRateAndPercent = new AttRateAndPercent();
                        attRateAndPercent = await GetAttRateAndPercent(batchID, studentID);

                        grid.AttendanceRateTermName = attRateAndPercent.AttendanceRateTermName;
                        grid.AttendanceRatePercent = attRateAndPercent.AttenddanceRatePercent;

                        List <TermInfo> terminfo = new List <TermInfo>();

                        foreach (var data in terms)
                        {
                            TermInfo info = new TermInfo();
                            PropertyCopier <Term, TermInfo> .Copy(data, info);
                            //info.IsFavorite = db.FavoriteLists.Any(a => a.FavoriteID == data.ID && a.UserID == userID && a.FavoriteType == "Announcement");
                            terminfo.Add(info);
                        }

                        var termlist = db.Terms.AsNoTracking().Where(x => x.BatchID == batchID).Select(x => x.ID).ToList();
                        var frommonth = DateTime.Now.AddMonths(-24);
                        var tomonth = DateTime.Now.AddMonths(24);
                        var attendances = db.Attendances.AsNoTracking().Where(x => x.Date >= frommonth && x.Date <= tomonth && termlist.Contains(x.TermID)).ToList();

                        grid.TermDetail = terminfo;

                        //For Module Code List Of Header

                        foreach (var term in terms)
                        {
                            List <TermDetail> tds = db.TermDetails.AsNoTracking().Where(td => td.TermID == term.ID && td.Attendence == true).ToList();

                            modulecodelist = "";
                            foreach (var td in tds)
                            {
                                if (modulecodelist != "")
                                {
                                    modulecodelist += ",";
                                }
                                modulecodelist += td.Module.ModuleCode;
                            }

                            foreach (TermInfo item in grid.TermDetail)
                            {
                                if (item.ID == term.ID)
                                {
                                    item.ModuleCodeList = modulecodelist;
                                }
                            }

                            //grid.ModuleCodeList.Add(modulecodelist);

                            int count = attendances.Where(a => a.TermID == term.ID).GroupBy(a => a.Month).Count();
                            grid.MonthList.Add(count);
                        }


                        //For Row of Grid
                        List <UserInfo> stdList = new List <UserInfo>();
                        if (studentID != 0)
                        {
                            stdList = (from a in db.BatchDetails
                                       join b in db.Users on a.StudentID equals b.ID
                                       where a.BatchID == batchID && b.ID == studentID && b.UserType == 1 && b.IsDelete != true
                                       select new UserInfo {
                                ID = b.ID, FullName = b.FullName, LoginName = b.LoginName, ProfilePicture = b.ProfilePicture, ProfilePicture2 = b.ProfilePicture2
                            }).ToList();
                        }
                        else
                        {
                            stdList = (from a in db.BatchDetails
                                       join b in db.Users on a.StudentID equals b.ID
                                       where a.BatchID == batchID && b.UserType == 1 && b.IsDelete != true
                                       select new UserInfo {
                                ID = b.ID, FullName = b.FullName, LoginName = b.LoginName, ProfilePicture = b.ProfilePicture, ProfilePicture2 = b.ProfilePicture2
                            }).ToList();
                            //stdList = db.BatchDetails.AsNoTracking().Where(x => x.BatchID == batchID).Select(x => x.User).Where(x => x.UserType == 1 && x.IsDelete == null || x.IsDelete != true).ToList();
                        }

                        //var frommonth = DateTime.Now.AddMonths(-6);
                        //var tomonth = DateTime.Now.AddMonths(6);
                        //var attendances = db.Attendances.Where(x => x.Date >= frommonth && x.Date <= tomonth);

                        //decimal SutdentCountYear1 = 0;
                        //decimal SutdentCountYear2 = 0;
                        //decimal StudentLastYear = 0;
                        //decimal StudentFoundation = 0;

                        if (stdList.Count() > 0)
                        {
                            foreach (UserInfo student in stdList)
                            {
                                //AttendanceGridRow row = new AttendanceGridRow();
                                //row.StudentName = student.FullName;
                                //row.StudentID = student.LoginName;
                                var attendance = attendances.Where(x => x.StudentID == student.ID);

                                decimal TotalYear1 = 0;
                                decimal TotalYear2 = 0;
                                decimal TotalLastYear = 0;
                                decimal TotalFoundation = 0;
                                int Year2Count = 0;
                                int LastYearCount = 0;
                                int FoundationCount = 0;
                                foreach (var term in terms)
                                {
                                    int percentageValue1 = 0; int percentageValue2 = 0;

                                    //double attendingCount = 0;
                                    double totalCount1 = 0; double totalCount2 = 0; double totalCount = 0; double attendingTotalCount = 0;

                                    int daysOfFirstMonth = endOfMonth(term.StartDate.Value.Month, term.StartDate.Value.Year) - term.StartDate.Value.Day;
                                    int firstMonth = daysOfFirstMonth > 5 ? term.StartDate.Value.Month : term.StartDate.Value.AddMonths(1).Month;
                                    totalCount1 = attendance.Where(x => x.TermID == term.ID && x.Month <= firstMonth).Select(y => y.ID).Count();
                                    totalCount2 = attendance.Where(x => x.TermID == term.ID && x.Month > firstMonth).Select(y => y.ID).Count();
                                    totalCount = attendance.Where(x => x.TermID == term.ID).Select(y => y.ID).Count();

                                    AttendanceCell cell1 = new AttendanceCell();
                                    AttendanceCell cell2 = new AttendanceCell();
                                    AttendanceCell totalcell = new AttendanceCell();

                                    totalCount1 = attendance.Where(x => x.TermID == term.ID && x.Month <= firstMonth).Select(y => y.ID).Count();
                                    if (totalCount1 > 0)
                                    {
                                        var attendingList1 = attendance.Where(x => x.TermID == term.ID && x.IsAttending == true && x.Month <= firstMonth).Select(y => y.ID).Count();

                                        if (attendingList1 != 0 && attendingList1 > 0)
                                        {
                                            attendingTotalCount += attendingList1;
                                            percentageValue1 = (int)Math.Round(((attendingList1 / totalCount1) * 100));
                                        }
                                    }
                                    if (totalCount2 > 0)
                                    {
                                        var attendingList2 = attendance.Where(x => x.TermID == term.ID && x.IsAttending == true && x.Month > firstMonth).Select(y => y.ID).Count();
                                        if (attendingList2 != 0 && attendingList2 > 0)
                                        {
                                            //attendingCount = count2;
                                            attendingTotalCount += attendingList2;
                                            percentageValue2 = (int)Math.Round(((attendingList2 / totalCount2) * 100));
                                            //percentageValue2 = (int)(((attendingCount / totalCount2) * 100));
                                            //percentagedouble2 = (count2 / totalCount2) * 100;
                                        }
                                    }
                                    cell1.Value = percentageValue1;
                                    cell2.Value = percentageValue2;
                                    //totalcell.Value = (int)Math.Round((((double)percentageValue1+(double)percentageValue2)*100)/200);
                                    //totalcell.Value = (int)Math.Round((((double)percentagedouble1 + (double)percentagedouble2) * 100) / 200);
                                    if (totalCount > 0)
                                    {
                                        //totalCount = attendance.Where(x => x.TermID == term.ID).Count();
                                        totalcell.Value = (int)Math.Round(((attendingTotalCount / totalCount) * 100));

                                        if (term.TermCode == "Term-2" || term.TermCode == "Term-3" || term.TermCode == "Term-4" || term.TermCode == "Term-5")
                                        {
                                            TotalYear1 += totalcell.Value;
                                        }
                                        else if (term.TermCode == "Term-6" || term.TermCode == "Term-7" || term.TermCode == "Term-8" || term.TermCode == "Term-9")
                                        {
                                            Year2Count++;
                                            TotalYear2 += totalcell.Value;
                                        }
                                        else if (term.TermCode == "Term-10" || term.TermCode == "Term-11" || term.TermCode == "Term-12" || term.TermCode == "Term-13")
                                        {
                                            LastYearCount++;
                                            TotalLastYear += totalcell.Value;
                                        }
                                        else
                                        {
                                            FoundationCount++;
                                            TotalFoundation += totalcell.Value;
                                        }
                                    }
                                    else
                                    {
                                        totalcell.Value = 0;

                                        if (term.TermCode == "Term-2" || term.TermCode == "Term-3" || term.TermCode == "Term-4" || term.TermCode == "Term-5")
                                        {
                                            TotalYear1 += totalcell.Value;
                                        }
                                        else if (term.TermCode == "Term-6" || term.TermCode == "Term-7" || term.TermCode == "Term-8" || term.TermCode == "Term-9")
                                        {
                                            Year2Count++;
                                            TotalYear2 += totalcell.Value;
                                        }
                                        else if (term.TermCode == "Term-10" || term.TermCode == "Term-11" || term.TermCode == "Term-12" || term.TermCode == "Term-13")
                                        {
                                            LastYearCount++;
                                            TotalLastYear += totalcell.Value;
                                        }
                                        else
                                        {
                                            FoundationCount++;
                                            TotalFoundation += totalcell.Value;
                                        }
                                    }
                                    //row.cells.Add(cell1);
                                    //row.cells.Add(cell2);
                                    //row.cells.Add(totalcell);
                                    grid.StudentID = student.ID;
                                    grid.StudentName = student.FullName;
                                    grid.LoginName = student.LoginName;
                                    grid.BatchName = term.Batch.BatchName;
                                    grid.CourseName = term.Batch.Course.CourseName;
                                    grid.ProfilePicture = MIUFileServer.GetFileUrl("ProfileImages", student.ProfilePicture);
                                    grid.ProfilePicture2 = MIUFileServer.GetFileUrl("ProfileImages", student.ProfilePicture2);
                                    //grid.ProfilePicture2 = student.ProfilePicture2;
                                    foreach (TermInfo item in grid.TermDetail)
                                    {
                                        if (item.ID == term.ID)
                                        {
                                            //item.StudentID = student.ID;
                                            //item.StudentName = student.FullName;
                                            item.First = percentageValue1;
                                            item.Second = percentageValue2;
                                            item.Total = totalcell.Value;
                                        }
                                    }
                                }
                                //decimal a = 0;
                                //decimal b = 0;
                                //decimal c = 0;
                                //decimal d = 0;

                                //if (TotalYear1 > 0)
                                //{
                                //    a = Math.Round(TotalYear1 / 4);
                                //}
                                //if (TotalYear2 > 0)
                                //{
                                //    b = Math.Round(TotalYear2 / Year2Count);
                                //}
                                //if (TotalFoundation > 0)
                                //{
                                //    c = Math.Round(TotalFoundation / FoundationCount);
                                //}
                                //if (TotalLastYear > 0)
                                //{
                                //    d = Math.Round(TotalLastYear / LastYearCount);
                                //}

                                //if (a >= 70)
                                //{
                                //    SutdentCountYear1++;
                                //}
                                //if (b >= 70)
                                //{
                                //    SutdentCountYear2++;
                                //}
                                //if (c >= 70)
                                //{
                                //    StudentFoundation++;
                                //}
                                //if (d >= 70)
                                //{
                                //    StudentLastYear++;
                                //}
                                //grid.Rows.Add(row);
                            }
                        }
                        int index = 0;
                        foreach (var item in grid.TermDetail)
                        {
                            if (index == 0)
                            {
                                item.YearName = "Foundation";
                            }
                            else if (index > 0 && index <= 4)
                            {
                                item.YearName = "Year 1";
                            }
                            else if (index > 4 && index <= 8)
                            {
                                item.YearName = "Year 2";
                            }
                            else
                            {
                                item.YearName = "";
                            }
                            index++;
                        }
                        return grid;
                    }
                    else
                    {
                        return null;
                    }
                    //}
                    //catch (Exception)
                    //{
                    //    return null;
                    //}
                }
            }));
        }
예제 #22
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        private string MakeHTML(TermInfo info)
        {
            TermInfoHTMLBuilder hb = new TermInfoHTMLBuilder();

            hb.AppendHeader();

            hb.AppendProperties(info.Props);

            foreach (TermInfo.LangSet langset in info.LanguageSets)
            {
                hb.AppendLanguage(langset.Language.DisplayName);

                hb.AppendProperties(langset.Props);

                foreach (TermInfo.Term term in langset.Terms)
                {
                    int iTerm = _Terms.Count;
                    _Terms.Add(term.Text);

                    hb.AppendTerm(term.Text, iTerm);
                    hb.AppendProperties(term.Props);
                }
            }

            hb.AppendFooter();

            return hb.ToString();
        }
예제 #23
0
        /// <summary>
        /// 발령결과 ListView 업데이트
        /// </summary>
        private void setTermStatusUpdate()
        {
            foreach (NCasListViewItem listViewItem in this.orderResultListView.Items)
            {
                if (listViewItem == null)
                {
                    continue;
                }

                if (listViewItem.Name == string.Empty)
                {
                    continue;
                }

                TermInfo pTermInfo = this.main.MmfMng.GetTermInfoByIp(listViewItem.Name);

                if (pTermInfo.AlarmOrderInfo.OccurTimeToDateTime > pTermInfo.WwsAlarmOrderInfo.OccurTimeToDateTime)
                {
                    listViewItem.ImageIndex = (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmStandby) ? 0 :         //예비
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmWatch) ? 1 :           //경계
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmAttack) ? 2 :          //공습
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmBiochemist) ? 3 :      //화생방
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmCancel) ? 4 :          //해제
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterWatch) ? 5 :        //재난위험(사이렌)
                                              (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterBroadcast) ? 6 : 4; //재난경계(방송)

                    listViewItem.SubItems[3].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderMode2String(pTermInfo.AlarmOrderInfo.Mode);
                    listViewItem.SubItems[4].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(pTermInfo.AlarmOrderInfo.Source);
                    listViewItem.SubItems[5].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(pTermInfo.AlarmOrderInfo.Kind);
                    listViewItem.SubItems[6].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderMedia2String(pTermInfo.AlarmOrderInfo.Media);
                    listViewItem.SubItems[7].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.AlarmOrderInfo.OccurTimeToDateTime);

                    if (pTermInfo.AlarmResponseInfo.AlarmResponse == NCasDefineResponse.None)
                    {
                        listViewItem.SubItems[8].Text = string.Empty;
                    }
                    else
                    {
                        listViewItem.SubItems[8].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.AlarmResponseInfo.RespTimeToDateTime);
                    }
                }
                else
                {
                    listViewItem.ImageIndex = (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmStandby) ? 0 :         //예비
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmWatch) ? 1 :           //경계
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmAttack) ? 2 :          //공습
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmBiochemist) ? 3 :      //화생방
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmCancel) ? 4 :          //해제
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterWatch) ? 5 :        //재난위험(사이렌)
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.WmaAutoAlarm) ? 6 :         //재난위험(사이렌)
                                              (pTermInfo.WwsAlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterBroadcast) ? 6 : 4; //재난경계(방송)

                    listViewItem.SubItems[3].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderMode2String(pTermInfo.WwsAlarmOrderInfo.Mode);
                    listViewItem.SubItems[4].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(pTermInfo.WwsAlarmOrderInfo.Source);
                    listViewItem.SubItems[5].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(pTermInfo.WwsAlarmOrderInfo.Kind);
                    listViewItem.SubItems[6].Text = NCasUtilityMng.INCasCommUtility.NCasDefineOrderMedia2String(pTermInfo.WwsAlarmOrderInfo.Media);
                    listViewItem.SubItems[7].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.WwsAlarmOrderInfo.OccurTimeToDateTime);

                    if (pTermInfo.WwsAlarmResponseInfo.AlarmResponse == NCasDefineResponse.None)
                    {
                        listViewItem.SubItems[8].Text = string.Empty;
                    }
                    else
                    {
                        listViewItem.SubItems[8].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.WwsAlarmResponseInfo.RespTimeToDateTime);
                    }
                }
            }
        }
예제 #24
0
        public void Process()
        {
            string database = Connection.Database;

            AppendLog("База данных: {0}, префикс: {1}", database, Prefix);

            TermParameters parameters = new TermParameters
            {
                Database      = database,
                StartTerm     = Prefix,
                NumberOfTerms = 1000
            };

            bool first = true;

            while (true)
            {
                if (Cancel)
                {
                    AppendLog("Пользователь прервал выполнение");
                    break;
                }

                TermInfo[] terms = Connection.ReadTerms(parameters);
                if (terms.Length == 0)
                {
                    break;
                }

                Window.SetStatus(terms[0].Text);

                int start = first ? 0 : 1;
                for (int i = start; i < terms.Length; i++)
                {
                    if (Cancel)
                    {
                        break;
                    }

                    TermInfo term = terms[i];
                    if (!term.Text.SafeStarts(Prefix))
                    {
                        break;
                    }
                    if (term.Count > 1)
                    {
                        DumpTerm(term.Text);
                    }
                }

                if (terms.Length < 2)
                {
                    break;
                }
                string lastTerm = terms.Last().Text;
                if (!lastTerm.SafeStarts(Prefix))
                {
                    break;
                }
                parameters.StartTerm = lastTerm;
                first = false;
            }

            AppendLog("Отключение от сервера");
            Connection.Dispose();
        }
예제 #25
0
 int PosComparer(TermInfo t1, TermInfo t2)
 {
     return(t1.GetPosition() - t2.GetPosition());
 }
예제 #26
0
 /// <summary>
 /// Creates a new FacetedNavigationInfo object
 /// </summary>
 /// <param name="term">The term information</param>
 /// <param name="refiners">The refiners</param>
 public FacetedNavigationInfo(TermInfo term, IList <RefinerInfo> refiners)
 {
     this.Term     = term;
     this.Refiners = refiners;
 }
예제 #27
0
        public void AddField(string field, TextReader indexedValue = null, string storedValue = null, FieldOptions options = FieldOptions.None)
        {
            if (storedValue != null)
            {
                var num = _parent.GetFieldNumber(field);
                _binaryWriter.Write(num);
                _binaryWriter.Write(storedValue);
                _currentStoredCount++;
            }

            if (indexedValue == null)
            {
                if (storedValue == null)
                {
                    throw new ArgumentException("It isn't meaningful to pass null for both indexedValue and storedValue");
                }
                return;
            }

            _source = _analyzer.CreateTokenSource(field, _source);
            _source.SetReader(indexedValue);
            while (_source.Next())
            {
                if (options.HasFlag(FieldOptions.NoAnalyzer) == false)
                {
                    if (_analyzer.Process(field, _source) == false)
                    {
                        continue;
                    }
                }

                var byteCount = Encoding.UTF8.GetByteCount(_source.Buffer, 0, _source.Size);
                var bytes     = _bufferPool.Take(byteCount);
                Encoding.UTF8.GetBytes(_source.Buffer, 0, _source.Size, bytes, 0);
                Debug.Assert(byteCount < ushort.MaxValue);
                _currentTermCount++;

                var key = Tuple.Create(field, new ArraySegmentKey <byte>(bytes, byteCount));

                TermInfo info;
                if (_currentTerms.TryGetValue(key, out info))
                {
                    _bufferPool.Return(bytes);
                }
                else
                {
                    _currentTerms[key] = info = new TermInfo {
                        Boost = 1.0f
                    };
                    _usedBuffers.Add(bytes);
                }

                info.Freq++;

                if (options.HasFlag(FieldOptions.TermPositions))
                {
                    if (info.Positions == null)
                    {
                        info.Positions = new List <int>();
                    }
                    info.Positions.Add(_source.Position);
                }
            }
        }
예제 #28
0
        void RedrawOutputLines2()
        {
            if (m_paragraphContainer.Count == 0)
            {
                return;
            }

            //TermInfo.SaveCursor();
            //TermInfo.SetScrollRegion(0, m_outputLines + 1);

            int l = 0;
            int p = m_paragraphContainer.Count - 1;

            for (; p >= 0; p--)
            {
                if (l >= m_currentLine)
                {
                    break;
                }

                l += m_paragraphContainer[p].m_lines;
            }

            //Dbg.WriteLine("bottom para {0}, lines {1}", p, l - m_currentLine);

            int linesLastPara = l - m_currentLine;

            l = linesLastPara;

            for (; p >= 0; p--)
            {
                l += m_paragraphContainer[p].m_lines;

                if (l >= m_outputLines)
                {
                    break;
                }
            }

            //Dbg.WriteLine("top p {0}, total l {1}", p, l);

            if (p < 0)
            {
                p = 0;
            }

            //Dbg.WriteLine("upmost paragraph {0}", p);

            l = m_outputLines - l;

            if (l < 0)
            {
                // top paragraph is partial
                int       start = Math.Abs(l) * m_columns;
                Paragraph para  = m_paragraphContainer[p];
                string    str   = para.ToAnsiString(m_256colors, start, para.m_text.Length - start);
                //Dbg.WriteLine("topmost ({1},{2}) '{0}'", str, start, para.m_text.Length - start);

                TermInfo.MoveCursor(0, 0);
                Console.Write(str);

                l = m_paragraphContainer[p].m_lines - Math.Abs(l);

                p++;
            }


            //Dbg.WriteLine("starting to draw from line {0}, para {1}", l, p);

            for (; p <= m_paragraphContainer.Count - 1; p++)
            {
                string str = m_paragraphContainer[p].ToAnsiString(m_256colors);

                TermInfo.MoveCursor(l, 0);
                Console.Write(str);

                l += m_paragraphContainer[p].m_lines;
                if (l >= m_outputLines)
                {
                    break;
                }
            }

            //TermInfo.SetScrollRegion(m_lines - m_editLines, m_lines);
            //TermInfo.RestoreCursor();
        }
예제 #29
0
        /// <summary>
        /// 발령결과 ListView 업데이트
        /// </summary>
        private void setTermStatusUpdate()
        {
            foreach (NCasListViewItem listViewItem in this.orderResultListView.Items)
            {
                if (listViewItem == null)
                {
                    continue;
                }

                if (listViewItem.Name == string.Empty)
                {
                    continue;
                }

                TermInfo pTermInfo = this.main.MmfMng.GetTermInfoByIp(listViewItem.Name);

                listViewItem.ImageIndex = (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmStandby) ? 0 :         //예비
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmWatch) ? 1 :           //경계
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmAttack) ? 2 :          //공습
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmBiochemist) ? 3 :      //화생방
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmCancel) ? 4 :          //해제
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterWatch) ? 5 :        //재난위험(사이렌)
                                          (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterBroadcast) ? 6 : 4; //재난경계(방송)

                listViewItem.SubItems[3].Text = (pTermInfo.AlarmOrderInfo.Mode == NCasDefineOrderMode.RealMode) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderMode2String(NCasDefineOrderMode.RealMode) :
                                                (pTermInfo.AlarmOrderInfo.Mode == NCasDefineOrderMode.TestMode) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderMode2String(NCasDefineOrderMode.TestMode) : "";

                listViewItem.SubItems[4].Text = (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.CentCtrlRoom) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.CentCtrlRoom) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.CentCtrlRoom2) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.CentCtrlRoom2) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.CentCtrlRoom3) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.CentCtrlRoom3) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.DistCtrlRoom) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.DistCtrlRoom) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.ProvBroadSelf) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.ProvBroadSelf) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.ProvCtrlRoom) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.ProvCtrlRoom) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.ProvDistribution) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.ProvDistribution) :
                                                (pTermInfo.AlarmOrderInfo.Source == NCasDefineOrderSource.ProvTermSelf) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderSource2String(NCasDefineOrderSource.ProvTermSelf) : "";

                listViewItem.SubItems[5].Text = (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmStandby) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmStandby) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmWatch) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmWatch) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmAttack) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmAttack) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmBiochemist) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmBiochemist) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmCancel) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmCancel) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmClose) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmClose) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterWatch) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.DisasterWatch) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.VoiceLineTest) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.VoiceLineTest) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.BroadPublicVoice) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.BroadPublicVoice) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.BroadMessage) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.BroadMessage) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.TermTts) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.TermTts) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.CenterTts) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.CenterTts) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.AlarmRecover) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.AlarmRecover) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterBoradRecover) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.DisasterBoradRecover) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterStandby) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.DisasterStandby) :
                                                (pTermInfo.AlarmOrderInfo.Kind == NCasDefineOrderKind.DisasterBroadcast) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderKind2String(NCasDefineOrderKind.DisasterBroadcast) : "";

                listViewItem.SubItems[6].Text = (pTermInfo.AlarmOrderInfo.Media == NCasDefineOrderMedia.MediaAll) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderMedia2String(NCasDefineOrderMedia.MediaAll) :
                                                (pTermInfo.AlarmOrderInfo.Media == NCasDefineOrderMedia.MediaLine) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderMedia2String(NCasDefineOrderMedia.MediaLine) :
                                                (pTermInfo.AlarmOrderInfo.Media == NCasDefineOrderMedia.MediaSate) ? NCasUtilityMng.INCasCommUtility.NCasDefineOrderMedia2String(NCasDefineOrderMedia.MediaSate) : "";

                listViewItem.SubItems[7].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.AlarmOrderInfo.OccurTimeToDateTime);

                if (pTermInfo.AlarmResponseInfo.AlarmResponse == NCasDefineResponse.None)
                {
                    listViewItem.SubItems[8].Text = string.Empty;
                }
                else
                {
                    listViewItem.SubItems[8].Text = NCasUtilityMng.INCasCommUtility.MakeDateTimeFormatForCasSystem(pTermInfo.AlarmResponseInfo.RespTimeToDateTime);
                }
            }
        }
예제 #30
0
 private void AddPrefixKey(TermInfo.Database db, string extendedNamePrefix, ConsoleKey key)
 {
     AddKey(db, extendedNamePrefix + "3", key, shift: false, alt: true,  control: false);
     AddKey(db, extendedNamePrefix + "4", key, shift: true,  alt: true,  control: false);
     AddKey(db, extendedNamePrefix + "5", key, shift: false, alt: false, control: true);
     AddKey(db, extendedNamePrefix + "6", key, shift: true,  alt: false, control: true);
     AddKey(db, extendedNamePrefix + "7", key, shift: false, alt: false, control: true);
 }
예제 #31
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <param name="abort"></param>
        /// <returns></returns>
        /// <created>UPh,20.03.2016</created>
        /// <changed>UPh,20.03.2016</changed>
        // ********************************************************************************
        internal bool GetTermStatus(TermListItem item, IAbortTermQuery abort)
        {
            TermInfo info = new TermInfo();
            if (!GetTermInfo(item.TermID, out info, abort))
                return false;

            // Find term in first language set
            if (info.LanguageSets.Count == 0)
                return false;

            foreach (EasyTermCore.TermInfo.Term term in info.LanguageSets[0].Terms)
            {
                if (term.Props != null && term.Text == item.Term)
                {
                    item.Status = term.Props.Status;
                    return true;
                }
            }

            return true;
        }
예제 #32
0
 private void AddKey(TermInfo.Database db, TermInfo.WellKnownStrings keyId, ConsoleKey key)
 {
     AddKey(db, keyId, key, shift: false, alt: false, control: false);
 }
예제 #33
0
            public TerminalFormatStrings(TermInfo.Database db)
            {
                if (db == null)
                    return;

                KeypadXmit = db.GetString(TermInfo.WellKnownStrings.KeypadXmit);
                Foreground = db.GetString(TermInfo.WellKnownStrings.SetAnsiForeground);
                Background = db.GetString(TermInfo.WellKnownStrings.SetAnsiBackground);
                Reset = db.GetString(TermInfo.WellKnownStrings.OrigPairs) ?? db.GetString(TermInfo.WellKnownStrings.OrigColors);
                Bell = db.GetString(TermInfo.WellKnownStrings.Bell);
                Clear = db.GetString(TermInfo.WellKnownStrings.Clear);
                Columns = db.GetNumber(TermInfo.WellKnownNumbers.Columns);
                Lines = db.GetNumber(TermInfo.WellKnownNumbers.Lines);
                CursorVisible = db.GetString(TermInfo.WellKnownStrings.CursorVisible);
                CursorInvisible = db.GetString(TermInfo.WellKnownStrings.CursorInvisible);
                CursorAddress = db.GetString(TermInfo.WellKnownStrings.CursorAddress);
                CursorLeft = db.GetString(TermInfo.WellKnownStrings.CursorLeft);

                Title = GetTitle(db);

                CursorPositionRequest = db.GetString(TermInfo.WellKnownStrings.CursorPositionRequest) == KnownCursorPositionRequest ?
                    KnownCursorPositionRequest :
                    string.Empty;

                int maxColors = db.GetNumber(TermInfo.WellKnownNumbers.MaxColors);
                MaxColors = // normalize to either the full range of all ANSI colors, just the dark ones, or none
                    maxColors >= 16 ? 16 :
                    maxColors >= 8 ? 8 :
                    0;

                KeyFormatToConsoleKey = new Dictionary<StringOrCharArray, ConsoleKeyInfo>();
                AddKey(db, TermInfo.WellKnownStrings.KeyF1, ConsoleKey.F1);
                AddKey(db, TermInfo.WellKnownStrings.KeyF2, ConsoleKey.F2);
                AddKey(db, TermInfo.WellKnownStrings.KeyF3, ConsoleKey.F3);
                AddKey(db, TermInfo.WellKnownStrings.KeyF4, ConsoleKey.F4);
                AddKey(db, TermInfo.WellKnownStrings.KeyF5, ConsoleKey.F5);
                AddKey(db, TermInfo.WellKnownStrings.KeyF6, ConsoleKey.F6);
                AddKey(db, TermInfo.WellKnownStrings.KeyF7, ConsoleKey.F7);
                AddKey(db, TermInfo.WellKnownStrings.KeyF8, ConsoleKey.F8);
                AddKey(db, TermInfo.WellKnownStrings.KeyF9, ConsoleKey.F9);
                AddKey(db, TermInfo.WellKnownStrings.KeyF10, ConsoleKey.F10);
                AddKey(db, TermInfo.WellKnownStrings.KeyF11, ConsoleKey.F11);
                AddKey(db, TermInfo.WellKnownStrings.KeyF12, ConsoleKey.F12);
                AddKey(db, TermInfo.WellKnownStrings.KeyF13, ConsoleKey.F13);
                AddKey(db, TermInfo.WellKnownStrings.KeyF14, ConsoleKey.F14);
                AddKey(db, TermInfo.WellKnownStrings.KeyF15, ConsoleKey.F15);
                AddKey(db, TermInfo.WellKnownStrings.KeyF16, ConsoleKey.F16);
                AddKey(db, TermInfo.WellKnownStrings.KeyF17, ConsoleKey.F17);
                AddKey(db, TermInfo.WellKnownStrings.KeyF18, ConsoleKey.F18);
                AddKey(db, TermInfo.WellKnownStrings.KeyF19, ConsoleKey.F19);
                AddKey(db, TermInfo.WellKnownStrings.KeyF20, ConsoleKey.F20);
                AddKey(db, TermInfo.WellKnownStrings.KeyF21, ConsoleKey.F21);
                AddKey(db, TermInfo.WellKnownStrings.KeyF22, ConsoleKey.F22);
                AddKey(db, TermInfo.WellKnownStrings.KeyF23, ConsoleKey.F23);
                AddKey(db, TermInfo.WellKnownStrings.KeyF24, ConsoleKey.F24);
                AddKey(db, TermInfo.WellKnownStrings.KeyBackspace, ConsoleKey.Backspace);
                AddKey(db, TermInfo.WellKnownStrings.KeyBackTab, ConsoleKey.Tab, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyBegin, ConsoleKey.Home);
                AddKey(db, TermInfo.WellKnownStrings.KeyClear, ConsoleKey.Clear);
                AddKey(db, TermInfo.WellKnownStrings.KeyDelete, ConsoleKey.Delete);
                AddKey(db, TermInfo.WellKnownStrings.KeyDown, ConsoleKey.DownArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyEnd, ConsoleKey.End);
                AddKey(db, TermInfo.WellKnownStrings.KeyEnter, ConsoleKey.Enter);
                AddKey(db, TermInfo.WellKnownStrings.KeyHelp, ConsoleKey.Help);
                AddKey(db, TermInfo.WellKnownStrings.KeyHome, ConsoleKey.Home);
                AddKey(db, TermInfo.WellKnownStrings.KeyInsert, ConsoleKey.Insert);
                AddKey(db, TermInfo.WellKnownStrings.KeyLeft, ConsoleKey.LeftArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyPageDown, ConsoleKey.PageDown);
                AddKey(db, TermInfo.WellKnownStrings.KeyPageUp, ConsoleKey.PageUp);
                AddKey(db, TermInfo.WellKnownStrings.KeyPrint, ConsoleKey.Print);
                AddKey(db, TermInfo.WellKnownStrings.KeyRight, ConsoleKey.RightArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyScrollForward, ConsoleKey.PageDown, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyScrollReverse, ConsoleKey.PageUp, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySBegin, ConsoleKey.Home, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySDelete, ConsoleKey.Delete, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySHome, ConsoleKey.Home, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySelect, ConsoleKey.Select);
                AddKey(db, TermInfo.WellKnownStrings.KeySLeft, ConsoleKey.LeftArrow, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySPrint, ConsoleKey.Print, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySRight, ConsoleKey.RightArrow, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyUp, ConsoleKey.UpArrow);
                AddPrefixKey(db, "kLFT", ConsoleKey.LeftArrow);
                AddPrefixKey(db, "kRIT", ConsoleKey.RightArrow);
                AddPrefixKey(db, "kUP", ConsoleKey.UpArrow);
                AddPrefixKey(db, "kDN", ConsoleKey.DownArrow);
                AddPrefixKey(db, "kDC", ConsoleKey.Delete);
                AddPrefixKey(db, "kEND", ConsoleKey.End);
                AddPrefixKey(db, "kHOM", ConsoleKey.Home);
                AddPrefixKey(db, "kNXT", ConsoleKey.PageDown);
                AddPrefixKey(db, "kPRV", ConsoleKey.PageUp);

                if (KeyFormatToConsoleKey.Count > 0)
                {
                    MaxKeyFormatLength = KeyFormatToConsoleKey.Keys.Max(key => key.Length);
                    MinKeyFormatLength = KeyFormatToConsoleKey.Keys.Min(key => key.Length);
                }
            }
예제 #34
0
 /// <summary>
 /// Puts a <see cref="TermInfo"/> onto the top of the stack
 /// </summary>
 /// <param name="termInfo">the <see cref="TermInfo"/> object to be put on the top of the stack</param>
 public virtual void Push(TermInfo termInfo)
 {
     termList.Insert(0, termInfo);
 }
예제 #35
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="termID"></param>
        /// <param name="info"></param>
        /// <param name="abort"></param>
        /// <returns></returns>
        /// <created>UPh,01.11.2015</created>
        /// <changed>UPh,01.11.2015</changed>
        // ********************************************************************************
        internal override bool GetTermInfo(int termID, out TermInfo info, IAbortTermQuery abort)
        {
            info = null;

            if (_DataBase == null)
                return false;

            if (string.IsNullOrEmpty(_LangAttribute1))
                return false;

            try
            {
                string sql = "SELECT text FROM mtConcepts WHERE conceptid = @id";

                using (OleDbCommand cmd = new OleDbCommand(sql, _DataBase))
                {
                    cmd.Parameters.AddWithValue("@id", termID);

                    string text = cmd.ExecuteScalar() as string;

                    XmlDocument doc = new XmlDocument();
                    doc.XmlResolver = null;
                    doc.LoadXml(text);

                    info = new TermInfo();
                info.TermID = termID;

                    XmlNode nodeProps = doc.SelectSingleNode("./cG");
                    if (nodeProps != null)
                        ReadProps(nodeProps, ref info._Props);

                    // Language 1
                    string xpath1 = string.Format("/cG/lG/l[@type='{0}']", _LangAttribute1);
                    XmlNode nodeLangset1 = doc.SelectSingleNode(xpath1);

                    if (nodeLangset1 != null)
                    {
                        int lcid1 = GetLCIDFromAttributeName(_LangAttribute1);
                        if (lcid1 >= 0)
                        {
                            TermInfo.LangSet langset1 = info.AddLanguage(lcid1);
                            ReadLangset(nodeLangset1.ParentNode, langset1);
                        }
                    }

                    // Language 2
                    string xpath2 = string.Format("/cG/lG/l[@type='{0}']", _LangAttribute2);
                    XmlNode nodeLangset2 = doc.SelectSingleNode(xpath2);

                    if (nodeLangset2 != null)
                    {
                        int lcid2 = GetLCIDFromAttributeName(_LangAttribute2);
                        if (lcid2 >= 0)
                        {
                            TermInfo.LangSet langset2 = info.AddLanguage(lcid2);
                            ReadLangset(nodeLangset2.ParentNode, langset2);
                        }
                    }

                }
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
예제 #36
0
 int PosComparer(TermInfo t1, TermInfo t2)
 {
     return(t1.Position - t2.Position);
 }
예제 #37
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>There is a potential problem here. If a user attempts to view a term that is not used in the module (need to investigate).</remarks>
        protected void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                var objTermApprove =
                    ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymApproveCount.ToString());
                var objTermReject = ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymRejectCount.ToString());
                var objMaxSynonym = ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymMaxCount.ToString());
                var synonymCount  = 0;

                var urlTerm =
                    (from t in Controller.GetTermsByContentType(ModuleContext.PortalId, ModuleContext.ModuleId, VocabularyId)
                     where t.Name.ToLower() == Tag.ToLower()
                     select t).SingleOrDefault();

                if (urlTerm != null)
                {
                    var portalSynonyms = Controller.GetTermSynonyms(ModuleContext.PortalId);
                    var activeSynonyms =
                        (from t in portalSynonyms
                         where t.MasterTermId == urlTerm.TermId && t.Score >= objTermApprove.Value
                         select t)
                        .ToList();
                    View.Model.SuggestedTermSynonyms =
                        (from t in portalSynonyms
                         where ((t.MasterTermId == urlTerm.TermId) && ((t.Score < objTermApprove.Value) && (t.Score > -objTermReject.Value))) select t).ToList();
                    View.Model.SelectedTerm = urlTerm;
                    var colTerms = new List <TermInfo>();

                    foreach (var objSynonym in activeSynonyms)
                    {
                        var synonym = objSynonym;

                        var termTerm = (from t in Controller.GetTermsByContentType(ModuleContext.PortalId, ModuleContext.ModuleId, VocabularyId)
                                        where t.TermId == synonym.RelatedTermId
                                        select t).SingleOrDefault();

                        if (termTerm == null)
                        {
                            // the term is not currently used within this module, go to core taxonomy store
                            var objTerm = (from t in Util.GetTermController().GetTermsByVocabulary(1)
                                           where t.TermId == synonym.RelatedTermId
                                           select t).SingleOrDefault();

                            var objTermInfo = new TermInfo
                            {
                                DayTermUsage   = 0,
                                TotalTermUsage = 0,
                                MonthTermUsage = 0,
                                WeekTermUsage  = 0,
                                TermId         = objTerm.TermId,
                                Name           = objTerm.Name,
                                Description    = objTerm.Description
                            };

                            colTerms.Add(objTermInfo);
                        }
                        else
                        {
                            // in taxonomy
                            colTerms.Add(termTerm);
                        }
                    }

                    View.Model.ActiveTermSynonyms = colTerms;
                    // we need to make sure we don't go above the max synonym count;
                    synonymCount = View.Model.ActiveTermSynonyms.Count + View.Model.SuggestedTermSynonyms.Count;
                }
                else
                {
                    // check to make sure this is a term in taxonomy (maybe it just wasn't associated with the content type)
                    var objTerm = (from t in Util.GetTermController().GetTermsByVocabulary(1)
                                   where t.Name.ToLower() == Tag.ToLower()
                                   select t).SingleOrDefault();
                    if (objTerm != null)
                    {
                        var objTermInfo = new TermInfo();

                        View.Model.ActiveTermSynonyms    = new List <TermInfo>();
                        View.Model.SuggestedTermSynonyms = new List <TermSynonymInfo>();
                        objTermInfo.DayTermUsage         = 0;
                        objTermInfo.TotalTermUsage       = 0;
                        objTermInfo.MonthTermUsage       = 0;
                        objTermInfo.WeekTermUsage        = 0;
                        objTermInfo.TermId      = objTerm.TermId;
                        objTermInfo.Name        = objTerm.Name;
                        objTermInfo.Description = objTerm.Description;
                        View.Model.SelectedTerm = objTermInfo;
                    }
                    else
                    {
                        Response.Redirect(Globals.AccessDeniedURL("AccessDenied"), false);
                    }
                }

                View.Model.SelectedView = ControlView;
                View.ItemDataBound     += ItemDataBound;
                View.AddSynonym        += AddSynonym;
                View.DeleteSynonym     += DeleteSynonym;

                View.ShowActiveSynonyms(View.Model.ActiveTermSynonyms.Count > 0);

                if (synonymCount < objMaxSynonym.Value)
                {
                    // check priv.
                    var objSuggestPriv = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.CreateTagSynonym.ToString());

                    if (objSuggestPriv != null)
                    {
                        //        var objMinSynonymCreateAnswer =
                        //colOpThresholds.Single(s => s.Key == Constants.OpThresholds.UserTermSynonymCreateMinAnswerCount.ToString());

                        if ((UserScore.Score >= objSuggestPriv.Value || ModuleContext.IsEditable))
                        {
                            View.ShowAddSynonym(true);
                            View.ShowSuggestedSynonyms(true);
                        }
                        else
                        {
                            View.ShowAddSynonym(false);
                            View.ShowSuggestedSynonyms(View.Model.SuggestedTermSynonyms.Count > 0);
                        }
                    }
                }
                else
                {
                    View.ShowAddSynonym(false);
                    View.ShowSuggestedSynonyms(View.Model.SuggestedTermSynonyms.Count > 0);
                }

                switch (View.Model.SelectedView.ToLower())
                {
                case "termsynonyms":
                    View.Model.PageTitle       = Localization.GetString("SynonymMetaTitle", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);
                    View.Model.PageDescription = Localization.GetString("SynonymMetaDescription", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);
                    break;

                default:
                    View.Model.PageTitle       = Localization.GetString("DetailMetaTitle", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);;
                    View.Model.PageDescription = View.Model.SelectedTerm.Description;
                    break;
                }

                // this should only factor in privileges/moderation + any op thresholds

                View.Refresh();
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
예제 #38
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="termInfo">the TermInfo object to be put on the top of the stack</param>
 public void Push(TermInfo termInfo)
 {
     // termList.push( termInfo );  // avoid Java 1.6 feature
     termList.AddFirst(termInfo);
 }
예제 #39
0
 /// <summary>
 /// Initializes a new instance of <see cref="TaxonomyValue"/> with a
 /// default TaxonomyContext determined by the parent term set of the TermInfo
 /// </summary>
 /// <param name="termInfo">The term metadata corresponding to the taxonomy value</param>
 public TaxonomyValue(TermInfo termInfo)
 {
     this.Term    = termInfo;
     this.Context = new TaxonomyContext(termInfo.TermSet);
 }
예제 #40
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="props"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        public void AppendProperties(TermInfo.Properties props)
        {
            if (props == null)
                return;
            if (!string.IsNullOrEmpty(props.Definition))
                AppendDefinition(props.Definition);

            if (props.Status != TermStatus.none)
            {
                if (props.Status == TermStatus.prohibited)
                {
                    AppendValueWithImage("Status", props.Status.ToString(), "Prohibited");
                }
                else
                {
                    AppendValue("Status", props.Status.ToString());
                }
            }

            if (props.Values != null)
            {
                foreach (var value in props.Values)
                {
                    AppendValue(value.Key, value.Value);
                }
            }

            _SB.AppendLine("");
        }
예제 #41
0
파일: Indexer.cs 프로젝트: votrongdao/Corax
        public void AddField(string field, TextReader indexedValue = null, string storedValue = null, FieldOptions options = FieldOptions.None)
        {
            if (storedValue != null)
            {
                var num = _parent.GetFieldNumber(field);
                _binaryWriter.Write(num);
                _binaryWriter.Write(storedValue);
                _currentStoredCount++;
            }

            if (indexedValue == null)
            {
                if (storedValue == null)
                    throw new ArgumentException("It isn't meaningful to pass null for both indexedValue and storedValue");
                return;
            }

            _source = _analyzer.CreateTokenSource(field, _source);
            _source.SetReader(indexedValue);
            while (_source.Next())
            {
                if (options.HasFlag(FieldOptions.NoAnalyzer) == false)
                {
                    if (_analyzer.Process(field, _source) == false)
                        continue;
                }

                var byteCount = Encoding.UTF8.GetByteCount(_source.Buffer, 0, _source.Size);
                var bytes = _bufferPool.Take(byteCount);
                Encoding.UTF8.GetBytes(_source.Buffer, 0, _source.Size, bytes, 0);
                Debug.Assert(byteCount < ushort.MaxValue);
                _currentTermCount++;

                var key = Tuple.Create(field, new ArraySegmentKey<byte>(bytes, byteCount));

                TermInfo info;
                if (_currentTerms.TryGetValue(key, out info))
                {
                    _bufferPool.Return(bytes);
                }
                else
                {
                    _currentTerms[key] = info = new TermInfo {Boost = 1.0f};
                    _usedBuffers.Add(bytes);
                }

                info.Freq++;

                if (options.HasFlag(FieldOptions.TermPositions))
                {
                    if (info.Positions == null)
                        info.Positions = new List<int>();
                    info.Positions.Add(_source.Position);
                }
            }
        }
예제 #42
0
 /// <summary>
 /// 생성자
 /// </summary>
 /// <param name="termInfo"></param>
 public TermSelectEventArgs(TermInfo termInfo)
 {
     this.termInfo = termInfo;
 }
예제 #43
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <param name="props"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        private void ReadProps(XmlNode node, ref TermInfo.Properties props)
        {
            foreach (XmlNode nodeDescrip in node.SelectNodes("./descripGrp/descrip"))
            {
                XmlAttribute attType = nodeDescrip.Attributes["type"];
                if (attType == null)
                    continue;

                if (props == null)
                    props = new TermInfo.Properties();

                if (!props.TrySetDefinition(attType.InnerText, nodeDescrip.InnerText) &&
                    !props.TrySetStatus(attType.InnerText, nodeDescrip.InnerText))
                {
                    props.AddValue(attType.InnerText, nodeDescrip.InnerText);
                }
            }

            foreach (XmlNode nodeDescrip in node.SelectNodes("./descrip"))
            {
                XmlAttribute attType = nodeDescrip.Attributes["type"];
                if (attType == null)
                    continue;

                if (props == null)
                    props = new TermInfo.Properties();

                if (!props.TrySetDefinition(attType.InnerText, nodeDescrip.InnerText) &&
                    !props.TrySetStatus(attType.InnerText, nodeDescrip.InnerText))
                {
                    props.AddValue(attType.InnerText, nodeDescrip.InnerText);
                }
            }
        }
예제 #44
0
            public TerminalFormatStrings(TermInfo.Database db)
            {
                if (db == null)
                    return;

                KeypadXmit = db.GetString(TermInfo.WellKnownStrings.KeypadXmit);
                Foreground = db.GetString(TermInfo.WellKnownStrings.SetAnsiForeground);
                Background = db.GetString(TermInfo.WellKnownStrings.SetAnsiBackground);
                Reset = db.GetString(TermInfo.WellKnownStrings.OrigPairs) ?? db.GetString(TermInfo.WellKnownStrings.OrigColors);
                Bell = db.GetString(TermInfo.WellKnownStrings.Bell);
                Clear = db.GetString(TermInfo.WellKnownStrings.Clear);
                Columns = db.GetNumber(TermInfo.WellKnownNumbers.Columns);
                Lines = db.GetNumber(TermInfo.WellKnownNumbers.Lines);
                CursorVisible = db.GetString(TermInfo.WellKnownStrings.CursorVisible);
                CursorInvisible = db.GetString(TermInfo.WellKnownStrings.CursorInvisible);
                CursorAddress = db.GetString(TermInfo.WellKnownStrings.CursorAddress);
                CursorLeft = db.GetString(TermInfo.WellKnownStrings.CursorLeft);

                Title = GetTitle(db);

                Debug.WriteLineIf(db.GetString(TermInfo.WellKnownStrings.CursorPositionReport) != CursorPositionReport,
                    "Getting the cursor position will only work if the terminal supports the CPR sequence," +
                    "but the terminfo database does not contain an entry for it.");

                int maxColors = db.GetNumber(TermInfo.WellKnownNumbers.MaxColors);
                MaxColors = // normalize to either the full range of all ANSI colors, just the dark ones, or none
                    maxColors >= 16 ? 16 :
                    maxColors >= 8 ? 8 :
                    0;

                AddKey(db, TermInfo.WellKnownStrings.KeyF1, ConsoleKey.F1);
                AddKey(db, TermInfo.WellKnownStrings.KeyF2, ConsoleKey.F2);
                AddKey(db, TermInfo.WellKnownStrings.KeyF3, ConsoleKey.F3);
                AddKey(db, TermInfo.WellKnownStrings.KeyF4, ConsoleKey.F4);
                AddKey(db, TermInfo.WellKnownStrings.KeyF5, ConsoleKey.F5);
                AddKey(db, TermInfo.WellKnownStrings.KeyF6, ConsoleKey.F6);
                AddKey(db, TermInfo.WellKnownStrings.KeyF7, ConsoleKey.F7);
                AddKey(db, TermInfo.WellKnownStrings.KeyF8, ConsoleKey.F8);
                AddKey(db, TermInfo.WellKnownStrings.KeyF9, ConsoleKey.F9);
                AddKey(db, TermInfo.WellKnownStrings.KeyF10, ConsoleKey.F10);
                AddKey(db, TermInfo.WellKnownStrings.KeyF11, ConsoleKey.F11);
                AddKey(db, TermInfo.WellKnownStrings.KeyF12, ConsoleKey.F12);
                AddKey(db, TermInfo.WellKnownStrings.KeyF13, ConsoleKey.F13);
                AddKey(db, TermInfo.WellKnownStrings.KeyF14, ConsoleKey.F14);
                AddKey(db, TermInfo.WellKnownStrings.KeyF15, ConsoleKey.F15);
                AddKey(db, TermInfo.WellKnownStrings.KeyF16, ConsoleKey.F16);
                AddKey(db, TermInfo.WellKnownStrings.KeyF17, ConsoleKey.F17);
                AddKey(db, TermInfo.WellKnownStrings.KeyF18, ConsoleKey.F18);
                AddKey(db, TermInfo.WellKnownStrings.KeyF19, ConsoleKey.F19);
                AddKey(db, TermInfo.WellKnownStrings.KeyF20, ConsoleKey.F20);
                AddKey(db, TermInfo.WellKnownStrings.KeyF21, ConsoleKey.F21);
                AddKey(db, TermInfo.WellKnownStrings.KeyF22, ConsoleKey.F22);
                AddKey(db, TermInfo.WellKnownStrings.KeyF23, ConsoleKey.F23);
                AddKey(db, TermInfo.WellKnownStrings.KeyF24, ConsoleKey.F24);
                AddKey(db, TermInfo.WellKnownStrings.KeyBackspace, ConsoleKey.Backspace);
                AddKey(db, TermInfo.WellKnownStrings.KeyBackTab, ConsoleKey.Tab, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyBegin, ConsoleKey.Home);
                AddKey(db, TermInfo.WellKnownStrings.KeyClear, ConsoleKey.Clear);
                AddKey(db, TermInfo.WellKnownStrings.KeyDelete, ConsoleKey.Delete);
                AddKey(db, TermInfo.WellKnownStrings.KeyDown, ConsoleKey.DownArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyEnd, ConsoleKey.End);
                AddKey(db, TermInfo.WellKnownStrings.KeyEnter, ConsoleKey.Enter);
                AddKey(db, TermInfo.WellKnownStrings.KeyHelp, ConsoleKey.Help);
                AddKey(db, TermInfo.WellKnownStrings.KeyHome, ConsoleKey.Home);
                AddKey(db, TermInfo.WellKnownStrings.KeyInsert, ConsoleKey.Insert);
                AddKey(db, TermInfo.WellKnownStrings.KeyLeft, ConsoleKey.LeftArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyPageDown, ConsoleKey.PageDown);
                AddKey(db, TermInfo.WellKnownStrings.KeyPageUp, ConsoleKey.PageUp);
                AddKey(db, TermInfo.WellKnownStrings.KeyPrint, ConsoleKey.Print);
                AddKey(db, TermInfo.WellKnownStrings.KeyRight, ConsoleKey.RightArrow);
                AddKey(db, TermInfo.WellKnownStrings.KeyScrollForward, ConsoleKey.PageDown, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyScrollReverse, ConsoleKey.PageUp, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySBegin, ConsoleKey.Home, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySDelete, ConsoleKey.Delete, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySHome, ConsoleKey.Home, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySelect, ConsoleKey.Select);
                AddKey(db, TermInfo.WellKnownStrings.KeySLeft, ConsoleKey.LeftArrow, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySPrint, ConsoleKey.Print, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeySRight, ConsoleKey.RightArrow, shift: true, alt: false, control: false);
                AddKey(db, TermInfo.WellKnownStrings.KeyUp, ConsoleKey.UpArrow);
                AddPrefixKey(db, "kLFT", ConsoleKey.LeftArrow);
                AddPrefixKey(db, "kRIT", ConsoleKey.RightArrow);
                AddPrefixKey(db, "kUP", ConsoleKey.UpArrow);
                AddPrefixKey(db, "kDN", ConsoleKey.DownArrow);
                AddPrefixKey(db, "kDC", ConsoleKey.Delete);
                AddPrefixKey(db, "kEND", ConsoleKey.End);
                AddPrefixKey(db, "kHOM", ConsoleKey.Home);
                AddPrefixKey(db, "kNXT", ConsoleKey.PageDown);
                AddPrefixKey(db, "kPRV", ConsoleKey.PageUp);

                if (KeyFormatToConsoleKey.Count > 0)
                {
                    MaxKeyFormatLength = int.MinValue;
                    MinKeyFormatLength = int.MaxValue;

                    foreach (KeyValuePair<StringOrCharArray, ConsoleKeyInfo> entry in KeyFormatToConsoleKey)
                    {
                        if (entry.Key.Length > MaxKeyFormatLength)
                        {
                            MaxKeyFormatLength = entry.Key.Length;
                        }
                        if (entry.Key.Length < MinKeyFormatLength)
                        {
                            MinKeyFormatLength = entry.Key.Length;
                        }
                    }
                }
            }
예제 #45
0
        //public static void main( string[] args ) throws Exception {
        //  Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
        //  QueryParser parser = new QueryParser(Version.LUCENE_CURRENT,  "f", analyzer );
        //  Query query = parser.parse( "a x:b" );
        //  FieldQuery fieldQuery = new FieldQuery( query, true, false );

        //  Directory dir = new RAMDirectory();
        //  IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer));
        //  Document doc = new Document();
        //  IndexableFieldType ft = new IndexableFieldType(TextField.TYPE_STORED);
        //  ft.setStoreTermVectors(true);
        //  ft.setStoreTermVectorOffsets(true);
        //  ft.setStoreTermVectorPositions(true);
        //  doc.add( new Field( "f", ft, "a a a b b c a b b c d e f" ) );
        //  doc.add( new Field( "f", ft, "b a b a f" ) );
        //  writer.addDocument( doc );
        //  writer.close();

        //  IndexReader reader = IndexReader.open(dir1);
        //  new FieldTermStack( reader, 0, "f", fieldQuery );
        //  reader.close();
        //}

        /// <summary>
        /// a constructor.
        /// </summary>
        /// <param name="reader"><see cref="IndexReader"/> of the index</param>
        /// <param name="docId">document id to be highlighted</param>
        /// <param name="fieldName">field of the document to be highlighted</param>
        /// <param name="fieldQuery"><see cref="FieldQuery"/> object</param>
        /// <exception cref="IOException">If there is a low-level I/O error</exception>
        public FieldTermStack(IndexReader reader, int docId, string fieldName, FieldQuery fieldQuery)
        {
            this.fieldName = fieldName;

            ISet <string> termSet = fieldQuery.GetTermSet(fieldName);

            // just return to make null snippet if un-matched fieldName specified when fieldMatch == true
            if (termSet == null)
            {
                return;
            }

            Fields vectors = reader.GetTermVectors(docId);

            if (vectors == null)
            {
                // null snippet
                return;
            }

            Terms vector = vectors.GetTerms(fieldName);

            if (vector == null)
            {
                // null snippet
                return;
            }

            CharsRef             spare     = new CharsRef();
            TermsEnum            termsEnum = vector.GetEnumerator();
            DocsAndPositionsEnum dpEnum    = null;
            BytesRef             text;

            int numDocs = reader.MaxDoc;

            while (termsEnum.MoveNext())
            {
                text = termsEnum.Term;
                UnicodeUtil.UTF8toUTF16(text, spare);
                string term = spare.ToString();
                if (!termSet.Contains(term))
                {
                    continue;
                }
                dpEnum = termsEnum.DocsAndPositions(null, dpEnum);
                if (dpEnum == null)
                {
                    // null snippet
                    return;
                }

                dpEnum.NextDoc();

                // For weight look here: http://lucene.apache.org/core/3_6_0/api/core/org/apache/lucene/search/DefaultSimilarity.html
                float weight = (float)(Math.Log(numDocs / (double)(reader.DocFreq(new Term(fieldName, text)) + 1)) + 1.0);

                int freq = dpEnum.Freq;

                for (int i = 0; i < freq; i++)
                {
                    int pos = dpEnum.NextPosition();
                    if (dpEnum.StartOffset < 0)
                    {
                        return; // no offsets, null snippet
                    }
                    termList.Add(new TermInfo(term, dpEnum.StartOffset, dpEnum.EndOffset, pos, weight));
                }
            }

            // sort by position
            CollectionUtil.TimSort(termList);

            // now look for dups at the same position, linking them together
            int      currentPos = -1;
            TermInfo previous   = null;
            TermInfo first      = null;

            for (int i = 0; i < termList.Count;)
            {
                TermInfo current = termList[i];
                if (current.Position == currentPos)
                {
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(previous != null);
                    }
                    previous.SetNext(current);
                    previous = current;
                    //iterator.Remove();

                    // LUCENENET NOTE: Remove, but don't advance the i position (since removing will advance to the next item)
                    termList.RemoveAt(i);
                }
                else
                {
                    if (previous != null)
                    {
                        previous.SetNext(first);
                    }
                    previous   = first = current;
                    currentPos = current.Position;

                    // LUCENENET NOTE: Only increment the position if we don't do a delete.
                    i++;
                }
            }

            if (previous != null)
            {
                previous.SetNext(first);
            }
        }
예제 #46
0
        public static TermInfo[] GetHighFreqTerms(Directory dir, 
            Hashtable junkWords,
            int numTerms,
            String[] fields)
        {
            if (dir == null || fields == null) return new TermInfo[0];

            IndexReader reader = IndexReader.Open(dir, true);
            TermInfoQueue tiq = new TermInfoQueue(numTerms);
            TermEnum terms = reader.Terms();

            int minFreq = 0;

            while (terms.Next())
            {
                String field = terms.Term().Field();

                if (fields != null && fields.Length > 0)
                {
                    bool skip = true;

                    for (int i = 0; i < fields.Length; i++)
                    {
                        if (field.Equals(fields[i]))
                        {
                            skip = false;
                            break;
                        }
                    }
                    if (skip) continue;
                }

                if (junkWords != null && junkWords[terms.Term().Text()] != null)
                    continue;

                if (terms.DocFreq() > minFreq)
                {
                    TermInfo top = (TermInfo)tiq.Add(new TermInfo(terms.Term(), terms.DocFreq()));
                    if (tiq.Size() >= numTerms) 		     // if tiq overfull
                    {
                        tiq.Pop();				     // remove lowest in tiq
                        minFreq = top.DocFreq; // reset minFreq
                    }
                }
            }

            TermInfo[] res = new TermInfo[tiq.Size()];

            for (int i = 0; i < res.Length; i++)
            {
                res[res.Length - i - 1] = (TermInfo)tiq.Pop();
            }

            reader.Close();

            return res;
        }
예제 #47
0
            private static string GetTitle(TermInfo.Database db)
            {
                // Try to get the format string from tsl/fsl and use it if they're available
                string tsl = db.GetString(TermInfo.WellKnownStrings.ToStatusLine);
                string fsl = db.GetString(TermInfo.WellKnownStrings.FromStatusLine);
                if (tsl != null && fsl != null)
                {
                    return tsl + "%p1%s" + fsl;
                }

                string term = db.Term;
                if (term == null)
                {
                    return string.Empty;
                }

                if (term.StartsWith("xterm", StringComparison.Ordinal)) // normalize all xterms to enable easier matching
                {
                    term = "xterm";
                }

                switch (term)
                {
                    case "aixterm":
                    case "dtterm":
                    case "linux":
                    case "rxvt":
                    case "xterm":
                        return "\x1B]0;%p1%s\x07";
                    case "cygwin":
                        return "\x1B];%p1%s\x07";
                    case "konsole":
                        return "\x1B]30;%p1%s\x07";
                    case "screen":
                        return "\x1Bk%p1%s\x1B";
                    default:
                        return string.Empty;
                }
            }
 bool CanUseAsImpl(
     TermInfo info,
     AttrCase channel,
     TermFlavor flavor)
 {
     var left = info._left;
     var right = info._right;
     bool canUseLeft = CanUseAs(left, channel, flavor);
     bool canUseRight = CanUseAs(right, channel, flavor);
     return canUseLeft || canUseRight;
 }
예제 #49
0
 private void AddKey(TermInfo.Database db, TermInfo.WellKnownStrings keyId, ConsoleKey key, bool shift, bool alt, bool control)
 {
     string keyFormat = db.GetString(keyId);
     if (!string.IsNullOrEmpty(keyFormat))
         KeyFormatToConsoleKey[keyFormat] = new ConsoleKeyInfo('\0', key, shift, alt, control);
 }
        D3D11_BLEND GetTermBlendDescImpl(
            TermInfo info,
            AttrCase channel,
            TermFlavor flavor)
        {
            // Need to look for a match on our target type
            var left = info._left;
            var right = info._right;

            AttrInfo factor = null;
            if (left.IsFactor(flavor, channel))
            {
                factor = right;
            }
            else if (right.IsFactor(flavor, channel))
            {
                factor = left;
            }
            else
            {
                throw OperationTooComplexError(info.Range);
            }

            return GetFactorBlendDesc(
                factor,
                channel );
        }
예제 #51
0
 private void AddKey(TermInfo.Database db, string extendedName, ConsoleKey key, bool shift, bool alt, bool control)
 {
     string keyFormat = db.GetExtendedString(extendedName);
     if (!string.IsNullOrEmpty(keyFormat))
         KeyFormatToConsoleKey[keyFormat] = new ConsoleKeyInfo('\0', key, shift, alt, control);
 }
예제 #52
0
        // ********************************************************************************
        /// <summary>
        /// 
        /// </summary>
        /// <param name="nodeLangset"></param>
        /// <param name="langset"></param>
        /// <returns></returns>
        /// <created>UPh,31.10.2015</created>
        /// <changed>UPh,31.10.2015</changed>
        // ********************************************************************************
        private void ReadLangset(XmlNode nodeLangset, TermInfo.LangSet langset)
        {
            // Read description
            ReadProps(nodeLangset, ref langset._Props);

            // Read terms
            foreach (XmlNode nodeTig in nodeLangset.SelectNodes("./tig"))
            {
                XmlNode nodeTerm = nodeTig.SelectSingleNode("./term");
                if (nodeTerm == null)
                    return;

                TermInfo.Term term = langset.AddTerm(nodeTerm.InnerText);

                ReadProps(nodeTig, ref term._Props);
            }

            // Read terms
            foreach (XmlNode nodeTig in nodeLangset.SelectNodes("./ntig"))
            {
                XmlNode nodeTerm = nodeTig.SelectSingleNode("./termGrp/term");
                if (nodeTerm == null)
                    return;

                TermInfo.Term term = langset.AddTerm(nodeTerm.InnerText);

                ReadProps(nodeTig, ref term._Props);
            }
        }