Esempio n. 1
0
 private void browseButton_Click(object sender, EventArgs e)
 {
     if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
     {
         bool   oldLastSuccess = lastLoadSuccess;
         string oldOsuFolder   = osuFolder;
         osuFolder = folderBrowserDialog1.SelectedPath + "\\";
         //Console.WriteLine("Folder selected: " + osuFolder);
         treeView1.Nodes.Clear();
         statusLabel.Text = "Loading new data...";
         OsuDB.cleanUp();
         CollectionDB.cleanUp();
         loadFiles();
         if (!lastLoadSuccess)
         {
             osuFolder       = oldOsuFolder;
             lastLoadSuccess = oldLastSuccess;
             MessageBox.Show("Going back to old path", "Reverting");
             statusLabel.Text = "Loading previous data...";
             treeView1.Nodes.Clear();
             runWorker();
         }
         else
         {
             populateForm();
             statusLabel.Text = "Loaded new osu! folder, osu.db has " + OsuDB.Songs.Count + " entries, " + CollectionDB.Collections.Count() + " collections loaded";
         }
         folderBrowserDialog1.SelectedPath = osuFolder;
         //Console.WriteLine(osuFolder);
     }
 }
        public AgentTrade GetAgentTrade(AgentTrade model)
        {
            #region sql
            string wherestr = string.Empty;
            if (!string.IsNullOrWhiteSpace(model.TradeOrderId))
            {
                wherestr += " AND TradeOrderId = @0 ";
            }
            if (!string.IsNullOrWhiteSpace(model.OrderId))
            {
                wherestr += " AND OrderId = @1 ";
            }
            if (model.AgentId > 0)
            {
                wherestr += " AND AgentId = @2 ";
            }
            string sql = string.Format(@"
SELECT  *
FROM    [dbo].[AgentTrade]
WHERE   1 = 1
        {0} ", wherestr);
            #endregion
            var agentTrade = CollectionDB.GetInstance().FirstOrDefault <AgentTrade>(sql,
                                                                                    model.TradeOrderId, model.OrderId, model.AgentId);
            return(agentTrade);
        }
Esempio n. 3
0
 private void toggleDeleteState(TreeNode node)
 {
     //mark entry for deletion
     //get song
     if (node.Tag != null)
     {
         MapHash tag  = (MapHash)node.Tag;
         string  hash = tag.hash;
         if (OsuDB.songExists(hash))
         {
             //flip the alive state
             CollectionDB.setAlive(tag, !tag.alive);
             //set the text to red or black
             if (tag.alive)
             {
                 node.ForeColor = Color.Black;
             }
             else
             {
                 node.ForeColor = Color.Red;
             }
             //node.ForeColor =
         }
     }
 }
Esempio n. 4
0
        private void treeView1_KeyDown(object sender, KeyEventArgs e)
        {
            //Console.WriteLine("---------");
            //Console.WriteLine(e.KeyValue);
            switch (e.KeyValue)
            {
            case 46:
                toggleDeleteState(treeView1.SelectedNode);
                break;

            case 8:
                toggleDeleteState(treeView1.SelectedNode);
                break;

            case 116:                    //F5 refresh
                OsuDB.cleanUp();
                CollectionDB.cleanUp();
                treeView1.Nodes.Clear();
                statusLabel.Text = "Refreshing Data...";
                runWorker();
                break;

            default:
                break;
            }
        }
Esempio n. 5
0
        public List <Trade> GetTradeLists(int?UserAccountId, int State, int?IsQrcode, DateTime?BeginTime, DateTime?EndTime)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            if (UserAccountId != null)
            {
                wherestr += "and UserAccountId =@0 ";
            }
            if (State > -1)
            {
                wherestr += "and State =@1 ";
            }
            if (IsQrcode != null)
            {
                wherestr += " and IsQrcode =@2 ";
            }
            if (BeginTime != null)
            {
                wherestr += " and TradeTime >=@3 ";
            }
            if (EndTime != null)
            {
                wherestr += " and TradeTime <@4 ";
            }
            sql = string.Format(@"
SELECT  *
FROM    dbo.Trade
WHERE 1=1 {0}
", wherestr);
            return(CollectionDB.GetInstance().Fetch <Trade>(sql, UserAccountId, State, IsQrcode, BeginTime, EndTime?.AddDays(1)));
        }
Esempio n. 6
0
        public int UpdateProblem(Problem model)
        {
            string sql = string.Empty;

            sql = "SET Title=@0,Body=@1,MotifyTime=@2 WHERE ProblemId = @3";
            return(CollectionDB.GetInstance().Update <Problem>(sql, model.Title, model.Body, model.MotifyTime, model.ProblemId));
        }
Esempio n. 7
0
        private void loadFiles()
        {
            bool gotFiles = true;

            //pic is osu/data/bt/[setId]l.jpg

            if (File.Exists(osuFolder + "collection.db"))
            {
                CollectionDB.ReadCollectionDB();
            }
            else
            {
                gotFiles = false;
            }

            if (File.Exists(osuFolder + "osu!.db"))
            {
                OsuDB.ReadOsuDB(osuFolder + "osu!.db");
            }
            else
            {
                gotFiles = false;
            }

            if (!gotFiles)
            {
                MessageBox.Show("Could not find osu files, please select your osu path manually", "Oops!");
                lastLoadSuccess = false;
            }
            else
            {
                lastLoadSuccess = true;
            }
        }
        public static void LoadCollectionIDsFormFile()
        {
            string filePath = System.Environment.CurrentDirectory + @"\CollectionID.txt";

            if (File.Exists(filePath))
            {
                string fileStr = File.ReadAllText(filePath);
                IEnumerable <CollectionInfo> infos = CollectionDB.GetAllCollectionInfos().ToList();
                foreach (var ci in infos)
                {
                    fileStr = fileStr.Replace(ci.CollectionID.ToString() + ":" + ci.QuestionCount, "");
                }
                string[] collectionIds = fileStr.Replace(";", "|").Split('|');
                foreach (string id in collectionIds)
                {
                    if (!String.IsNullOrEmpty(id))
                    {
                        string[]       ids = id.Split(':');
                        CollectionInfo ci  = CollectionDB.GetCollectionInfoById(ids[0]);
                        if (ci != null)
                        {
                            ci.QuestionCount = int.Parse(ids[1]);
                            CollectionDB.SaveOrUpdateCollectionInfo(ci);
                        }
                        else
                        {
                            string url = string.Format(CollectionInfoBaseUrl, ids[0]);
                            GetCollectionInfoFormHtml(BusinessUtils.GetByUrl(url), ids[0]);
                        }
                    }
                }
            }
        }
 public static void GetCollectionInfoFormHtml(string html, string collectionId)
 {
     if (!String.IsNullOrWhiteSpace(html))
     {
         HtmlDocument doc = new HtmlDocument();
         doc.LoadHtml(html);
         HtmlNode           nameNode     = doc.DocumentNode.SelectSingleNode(@"//h2[@id='zh-fav-head-title']");
         HtmlNodeCollection fllowerNodes = doc.DocumentNode.SelectNodes(@"//div[@class='zg-gray-normal']");
         HtmlNode           creatorNode  = doc.DocumentNode.SelectSingleNode(@"//h2[@class='zm-list-content-title']");
         string             fllowercount = ((HtmlNode)fllowerNodes[2]).SelectSingleNode(@"a").InnerText.Replace("\n", "");
         CollectionInfo     ci           = new CollectionInfo()
         {
             CollectionID   = int.Parse(collectionId),
             CollectionName = nameNode.InnerText.Replace("\n", ""),
             CollectionUrl  = string.Format(CollectionInfoBaseUrl, collectionId),
             FllowersCount  = int.Parse(fllowercount),
             QuestionCount  = 0,
             CreatorName    = creatorNode.InnerText.Replace("\n", ""),
             ModefiedTime   = DateTime.Now.ToString(),
         };
         CollectionDB.SaveOrUpdateCollectionInfo(ci);
         Console.WriteLine("收藏夹:" + ci.CollectionID + " " + ci.CollectionName + " 于" + ci.ModefiedTime + "保存完成");
         Thread.Sleep(1000 * 5);
     }
 }
        public static void GetCollectionAnswerInfoFromHtml(string html, CollectionInfo ci)
        {
            if (!String.IsNullOrWhiteSpace(html))
            {
                try
                {
                    HtmlDocument doc = new HtmlDocument();
                    doc.LoadHtml(html);
                    HtmlNodeCollection answerNodes = doc.DocumentNode.SelectNodes(@"//div[@class='zm-item-rich-text js-collapse-body']");
                    foreach (HtmlNode answer in answerNodes)
                    {
                        string ids = answer.Attributes.FirstOrDefault(p => p.Name == "data-entry-url").Value;

                        string[] idsArr = ids.Split('/');
                        CollectionQuestionAndAnswer cqa = new CollectionQuestionAndAnswer()
                        {
                            CollectionID = ci.CollectionID,
                            QuestionID   = int.Parse(idsArr[2]),
                            AnswerID     = int.Parse(idsArr[4]),
                            ModefiedTime = DateTime.Now.ToString(),
                        };
                        CollectionDB.SaveOrUpdateCollectionAnswer(cqa);
                        Console.WriteLine("答案:" + cqa.AnswerID + " 于" + DateTime.Now.ToString() + "保存成功");
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 11
0
        public List <UserAccount> GetUserList(string UserName, string Phone, int UserAccountId, int IsQrcode)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            if (!string.IsNullOrWhiteSpace(UserName))
            {
                wherestr += " and UserName =@0 ";
            }
            if (!string.IsNullOrWhiteSpace(Phone))
            {
                wherestr += " and Phone =@1 ";
            }
            if (UserAccountId > 0)
            {
                wherestr += " and UserAccountId =@2 ";
            }
            if (IsQrcode > 0)
            {
                wherestr += " and IsQrcode =@3 ";
            }
            sql = string.Format(@"
SELECT  *
FROM    dbo.UserAccount
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Fetch <UserAccount>(sql, UserName, Phone, UserAccountId, IsQrcode));
        }
Esempio n. 12
0
 public Agent GetAgentLogin(Agent model)
 {
     #region sql
     string wherestr = string.Empty;
     if (!string.IsNullOrEmpty(model.UserName))
     {
         wherestr += " AND UserName = @0";
     }
     if (!string.IsNullOrEmpty(model.UserPwd))
     {
         wherestr += " AND UserPwd = @1 ";
     }
     if (model.AgentId > 0)
     {
         wherestr += " AND AgentId  = @2";
     }
     string sql = string.Format(@"
     SELECT  *
     FROM    dbo.Agent
     WHERE   1 = 1
     {0}
     ", wherestr);
     #endregion
     return(CollectionDB.GetInstance().SingleOrDefault <Agent>(sql,
                                                               model.UserName, model.UserPwd, model.AgentId));
 }
Esempio n. 13
0
        public List <AgentTrade> GetAgentTradeLists(int AgentId, int State, string TradeOrderId, DateTime?BeginTime, DateTime?EndTime)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            if (AgentId > 0)
            {
                wherestr += " and AgentId =@0 ";
            }
            if (State > -1)
            {
                wherestr += " and State =@1 ";
            }
            if (!string.IsNullOrWhiteSpace(TradeOrderId))
            {
                wherestr += " and TradeOrderId =@2 ";
            }
            if (BeginTime != null)
            {
                wherestr += " and TradeTime >=@3 ";
            }
            if (EndTime != null)
            {
                wherestr += " and TradeTime <@4 ";
            }
            sql = string.Format(@"
SELECT  *
FROM    dbo.AgentTrade
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Fetch <AgentTrade>(sql, AgentId, State, TradeOrderId, BeginTime, EndTime?.AddDays(1)));
        }
Esempio n. 14
0
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (lastLoadSuccess && File.Exists(osuFolder + "collection.db"))
     {
         //copy collection file BEFORE ANYTHING ELSE
         bool backup = true;
         int  count  = 0;
         while (backup)
         {
             if (!Directory.Exists(osuFolder + "collection backups"))
             {
                 Directory.CreateDirectory(osuFolder + "collection backups");
             }
             if (!File.Exists(osuFolder + "collection backups\\collection" + count + ".db"))
             {
                 File.Copy(osuFolder + "collection.db", osuFolder + "collection backups\\collection" + count + ".db");
                 backup = false;
             }
             else
             {
                 count++;
             }
         }
         //now that it is backed up we can delete the current collection and write our own
         File.Delete(osuFolder + "collection.db");
         CollectionDB.writeCollectionDB(osuFolder + "collection.db");
         MessageBox.Show("Collection succesfully saved and old version backed up as " + osuFolder + "collection backups\\collection" + count + ".db", "Saved!");
     }
 }
Esempio n. 15
0
        public int UpdateMemberlevel(int UserAccountId, int Memberlevel)
        {
            string wherestr = string.Empty;

            wherestr = " AND UserAccountId=" + UserAccountId;
            string sql = string.Format("SET Memberlevel={0} WHERE 1=1 {1}", Memberlevel, wherestr);

            return(CollectionDB.GetInstance().Update <UserAccount>(sql));
        }
Esempio n. 16
0
        public int UpdateRate(int UserAccountId, decimal Rate, decimal UserDrawFee)
        {
            string wherestr = string.Empty;

            wherestr = " AND UserAccountId=" + UserAccountId;
            string sql = string.Format("SET UserRate={0},UserDrawFee = {2} WHERE 1=1 {1}", Rate, wherestr, UserDrawFee);

            return(CollectionDB.GetInstance().Update <UserAccount>(sql));
        }
Esempio n. 17
0
        public int UpdateIsQrcode(int UserAccountId, int IsQrcode, decimal Rate, decimal DrawFee)
        {
            string wherestr = string.Empty;

            wherestr = " AND UserAccountId=" + UserAccountId;
            string sql = string.Format("SET IsQrcode={0},Rate={2},DrawFee = {3} WHERE 1=1 {1}", IsQrcode, wherestr, Rate, DrawFee);

            return(CollectionDB.GetInstance().Update <UserAccount>(sql));
        }
Esempio n. 18
0
        public Page <Advice> GetAdviceList(int pageindex, int pagesize)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            sql = string.Format(@"
SELECT  *
FROM    dbo.Advice
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Page <Advice>(pageindex, pagesize, sql));
        }
Esempio n. 19
0
        public List <BankCard> GetBankCardList(int UserAccountId)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            wherestr += "and UserAccountId =@0";
            sql       = string.Format(@"
SELECT  *
FROM    dbo.BankCard
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Fetch <BankCard>(sql, UserAccountId));
        }
Esempio n. 20
0
 public List <Agent> GetAgentList()
 {
     #region sql
     string wherestr = string.Empty;
     string sql      = string.Format(@"
     SELECT  *
     FROM    dbo.Agent
     WHERE   1 = 1
     {0}
     ORDER BY CreateTime DESC
     ", wherestr);
     #endregion
     return(CollectionDB.GetInstance().Fetch <Agent>(sql));
 }
Esempio n. 21
0
 public Page <Agent> GetAgentListByPage(int pageindex, int pagesize)
 {
     #region sql
     string wherestr = string.Empty;
     string sql      = string.Format(@"
     SELECT  *
     FROM    dbo.Agent
     WHERE   1 = 1
     {0}
     ORDER BY CreateTime DESC
     ", wherestr);
     #endregion
     return(CollectionDB.GetInstance().Page <Agent>(pageindex, pagesize, sql));
 }
Esempio n. 22
0
 public int UpdateAgentState(int AgentId, int State)
 {
     #region sql
     string wherestr = string.Empty;
     wherestr += "AND AgentId = " + AgentId;
     string modifystr = string.Empty;
     string sql       = string.Format(@"
     SET State=@0
     WHERE 1 = 1
     {0}
      ", wherestr);
     #endregion
     return(CollectionDB.GetInstance().Update <Agent>(sql, State));
 }
Esempio n. 23
0
 public int UpdateAgent(Agent agent)
 {
     #region sql
     string wherestr = string.Empty;
     wherestr += "AND AgentId = " + agent.AgentId;
     string modifystr = string.Empty;
     string sql       = string.Format(@"
     SET MerchantName=@0,Rate = @1,Phone=@2
     WHERE 1 = 1
     {0}
      ", wherestr);
     #endregion
     return(CollectionDB.GetInstance().Update <Agent>(sql, agent.MerchantName, agent.Rate, agent.Phone));
 }
Esempio n. 24
0
        public BankCard GetBankCard(BankCard model)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            wherestr += " and CardId =@0 ";
            wherestr += " and UserAccountId =@1 ";
            sql       = string.Format(@"
SELECT  *
FROM    dbo.BankCard
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Fetch <BankCard>(sql, model.CardId, model.UserAccountId).FirstOrDefault());
        }
Esempio n. 25
0
        public Problem GetProblem(Problem model)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            wherestr += "and ProblemId =@0";

            sql = string.Format(@"
SELECT  *
FROM    dbo.Problem
WHERE 1=1 {0}
ORDER BY MotifyTime DESC", wherestr);
            return(CollectionDB.GetInstance().SingleOrDefault <Problem>(sql, model.ProblemId));
        }
Esempio n. 26
0
        public int AddIntegral(int UserAccountId, int Integral, int?Memberlevel)
        {
            string wherestr = string.Empty;

            wherestr += " AND UserAccountId=" + UserAccountId;
            string setstr = string.Empty;

            if (Memberlevel != null)
            {
                setstr += ",Memberlevel=" + Memberlevel;
            }
            string sql = string.Format("SET Integral={0}{2} WHERE 1=1 {1}", Integral, wherestr, setstr);

            return(CollectionDB.GetInstance().Update <UserAccount>(sql));
        }
 public static void GetCollectionAnswerInfos(CollectionInfo ci)
 {
     if (CollectionDB.GetAnswerCountByCollectionId(ci.CollectionID.ToString()) != ci.QuestionCount)
     {
         int count = GetCollectionPageCount(ci);
         ci.QuestionCount = count;
         CollectionDB.SaveOrUpdateCollectionInfo(ci);
         for (int i = count; i >= 1; i--)
         {
             string url = string.Format(CollectionInfoAnswerUrl, ci.CollectionID, i);
             GetCollectionAnswerInfoFromHtml(BusinessUtils.GetByUrl(url), ci);
             Thread.Sleep(1000 * 5);
         }
     }
 }
Esempio n. 28
0
        public Page <Problem> GetProblemList(int pageindex, int pagesize, string Title)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            if (!string.IsNullOrWhiteSpace(Title))
            {
                wherestr += "and Title =@0";
            }
            sql = string.Format(@"
SELECT  *
FROM    dbo.Problem
WHERE 1=1 {0}
ORDER BY MotifyTime DESC", wherestr);
            return(CollectionDB.GetInstance().Page <Problem>(pageindex, pagesize, sql, Title));
        }
Esempio n. 29
0
        public Page <UserAccount> GetUserList(int pageindex, int pagesize, string UserName, string Phone, int UserAccountId)
        {
            string sql      = string.Empty;
            string wherestr = string.Empty;

            if (!string.IsNullOrWhiteSpace(UserName))
            {
                wherestr += " and UserName =@0 ";
            }
            if (!string.IsNullOrWhiteSpace(Phone))
            {
                wherestr += " and Phone =@1 ";
            }
            if (UserAccountId > 0)
            {
                wherestr += " and UserAccountId =@2 ";
            }
            sql = string.Format(@"
SELECT  *
FROM    dbo.UserAccount
WHERE 1=1 {0}
ORDER BY CreateTime DESC", wherestr);
            return(CollectionDB.GetInstance().Page <UserAccount>(pageindex, pagesize, sql, UserName, Phone, UserAccountId));
        }
Esempio n. 30
0
        public Agent GetAgent(Agent model)
        {
            #region sql
            string wherestr = string.Empty;

            if (model.AgentId > 0)
            {
                wherestr += " AND AgentId = @0 ";
            }
            if (!string.IsNullOrWhiteSpace(model.UserPwd))
            {
                wherestr += " AND UserPwd = @1 ";
            }
            string sql = string.Format(@"
SELECT  *
FROM    [dbo].[Agent]
WHERE   1 = 1 AND State=1
        {0} ", wherestr);
            #endregion

            var agent = CollectionDB.GetInstance().FirstOrDefault <Agent>(sql,
                                                                          model.AgentId, model.UserPwd);
            return(agent);
        }