Beispiel #1
0
        private bool MatchProgram(Bookmark bookmark, Query query)
        {
            if (bookmark.Name.ToLower().Contains(query.RawQuery.ToLower()) || bookmark.Url.ToLower().Contains(query.RawQuery.ToLower()))
            {
                return(true);
            }
            if (ChineseToPinYin.ToPinYin(bookmark.Name).Replace(" ", "").ToLower().Contains(query.RawQuery.ToLower()))
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog FBD = new FolderBrowserDialog();
            string music            = "";

            music = this.listBox1.SelectedItem.ToString();
            music = ChineseToPinYin.ToPinYin(music);
            string address        = this.listBox1.SelectedItem.ToString();
            string format         = ".mp3";
            string folderlocation = router;

            // judge if the selected file is mp3 file
            if (address.IndexOf(format) > -1)
            {
                //当rename button第二次点击时,因为listbox中未更新,所以显示错误!!需要修改!!
                File.Move(@address, @music);
                music = address;

                // check if the file has been renamed

                if (this.listBox1.SelectedItem.ToString() == music)
                {
                    MessageBox.Show("The selected music has been renamed!");
                    listBox1.Items.Clear();
                    //display the renewed music
                    string[] files = Directory.GetFiles(folderlocation);

                    foreach (string file in files)
                    {
                        listBox1.Items.Add(file);
                    }
                }

                else
                {
                    MessageBox.Show("The selected music is not renamed!");
                }
            }

            else
            {
                MessageBox.Show("The selected file is not mp3 file");
            }



            //       File.Move(this.listBox1.SelectedItem.ToString(),music);
            //        music = ChineseToPinYin.ToPinYin(music);
        }
Beispiel #3
0
        private bool MatchProgram(Program program, FuzzyMatcher matcher)
        {
            program.Score = matcher.Score(program.Title);
            if (program.Score > 0)
            {
                return(true);
            }
            program.Score = matcher.Score(ChineseToPinYin.ToPinYin(program.Title).Replace(" ", ""));
            if (program.Score > 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            int ranknum = allmusic.GetLength(0);
            int i       = 0;

            for (i = 0; i < ranknum; i++)
            {
                string chinesemusic = allmusic[i];
                string musicpinyin  = ChineseToPinYin.ToPinYin(chinesemusic);
                File.Move(@chinesemusic, @musicpinyin);
            }
            string message = string.Format("{0} musics have been renamed!", ranknum);

            listBox1.Items.Clear();
            //display the renewed music
            string[] files = Directory.GetFiles(router);

            foreach (string file in files)
            {
                listBox1.Items.Add(file);
            }
            MessageBox.Show(message);
        }
        public static bool ImportStoreSuggestDataBulk(string IndexNew)
        {
            int        PageSize   = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());
            int        PageNumber = 1;
            var        clinet     = GetClient(IndexNew);
            List <int> rs         = new List <int>();

            Utils.WriteLogFile("ImportStoreSuggestDataBulk开始导入数据(" + IndexNew + ")页大小" + PageSize);
            while (true)
            {
                SQLinq.Dynamic.DynamicSQLinq sql = new SQLinq.Dynamic.DynamicSQLinq("v_ProductInfo_s ");
                sql = sql.Select("storeid,StoreName name").GroupBy("storeid,StoreName");
                sql = sql.Skip(PageSize * (PageNumber - 1)).Take(PageSize).OrderByDescending("storeid");
                var list = db.Query <dynamic>(sql);
                if (list.Count == 0)
                {
                    break;
                }
                string initials     = "";
                var    keywordslist = list.Select(a => new { keywords = new { input = new List <string>()
                                                                              {
                                                                                  a.name, ChineseToPinYin.ToPinYin(a.name, ref initials), initials
                                                                              }, output = a.name, payload = new { id = a.storeid.ToString(), type = "store", keyword = "" }, weight = 10 } });
                var bk = clinet.Bulk(a => a.IndexMany <object>(keywordslist));
                if (bk.Errors)
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入有错误,数据来源sql语句--" + sql.ToSQL().ToQuery());
                    rs.Add(0);
                }
                else
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入成功");
                    rs.Add(1);
                }
                PageNumber++;
            }
            Utils.WriteLogFile("ImportStoreSuggestDataBulk导入数据结束(" + IndexNew + ")");
            return(rs.Where(a => a == 0).Count() == 0);
        }
        public static bool ImportBrandSuggestDataBulk(string IndexNew)
        {
            int        PageSize   = int.Parse(ConfigurationManager.AppSettings["PageSize"].ToString());
            int        PageNumber = 1;
            var        clinet     = GetClient(IndexNew);
            List <int> rs         = new List <int>();

            Utils.WriteLogFile("ImportBrandSuggestDataBulk开始导入数据(" + IndexNew + ")页大小" + PageSize);
            while (true)
            {
                SQLinq.Dynamic.DynamicSQLinq sql = new SQLinq.Dynamic.DynamicSQLinq("v_ProductInfo_s ");
                sql = sql.Select("brandid,BrandName name").GroupBy("brandid,BrandName");
                sql = sql.Skip(PageSize * (PageNumber - 1)).Take(PageSize).OrderByDescending("brandid");
                var list = db.Query <dynamic>(sql);
                if (list.Count == 0)
                {
                    break;
                }
                List <object> keywordslist = new List <object>();
                string        initials     = "";
                string        pinyin       = "";
                string        output       = "";

                SQLinq.Dynamic.DynamicSQLinq sqlkeywords = new SQLinq.Dynamic.DynamicSQLinq("bma_brands ");
                sqlkeywords = sqlkeywords.Select("brandid,keywords");
                var listkeywords = db.Query <dynamic>(sqlkeywords).ToList();

                foreach (var item in list)
                {
                    output   = item.name;
                    initials = "";
                    pinyin   = ChineseToPinYin.ToPinYin(output, ref initials);
                    keywordslist.Add(new { keywords = new { input = new List <string>()
                                                            {
                                                                output, pinyin, initials
                                                            }, output = output, payload = new { id = item.brandid.ToString(), type = "brand", keyword = "" }, weight = 20 } });

                    //添加关键词
                    var brandinfo = listkeywords.FirstOrDefault(a => a.brandid == item.brandid);
                    if (brandinfo != null && brandinfo.keywords != null)
                    {
                        List <string> brandkeywords = ((string)brandinfo.keywords).Split(',').ToList();
                        foreach (var key in brandkeywords)
                        {
                            if (key == "")
                            {
                                continue;
                            }
                            output   = item.name + key;
                            initials = "";
                            pinyin   = ChineseToPinYin.ToPinYin(output, ref initials);
                            keywordslist.Add(new { keywords = new { input = new List <string>()
                                                                    {
                                                                        output, pinyin, initials
                                                                    }, output = output, payload = new { id = item.brandid.ToString(), type = "brand", keyword = key }, weight = 20 } });
                        }
                    }
                }
                var bk = clinet.Bulk(a => a.IndexMany <object>(keywordslist));
                if (bk.Errors)
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入有错误,数据来源sql语句--" + sql.ToSQL().ToQuery());
                    rs.Add(0);
                }
                else
                {
                    Utils.WriteLogFile("(页码" + PageNumber + "数据量" + list.Count + ")(" + IndexNew + ")导入成功");
                    rs.Add(1);
                }
                PageNumber++;
            }
            Utils.WriteLogFile("ImportBrandSuggestDataBulk导入数据结束(" + IndexNew + ")");
            return(rs.Where(a => a == 0).Count() == 0);
        }