Пример #1
0
 void TitleList_FetchCompleted(object sender, Natsuhime.Events.ReturnCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         Dictionary <string, string> posts = e.ReturnObject as Dictionary <string, string>;
         foreach (KeyValuePair <string, string> post in posts)
         {
             string sql = string.Format(
                 "INSERT INTO posts(`title`,`url`) VALUES('{0}','{1}')",
                 post.Value,
                 post.Key
                 );
             try
             {
                 Natsuhime.Data.DbHelper.ExecuteNonQuery(CommandType.Text, sql);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
         }
         MessageBox.Show(string.Format("{0} Completed!", posts.Count));
     }
     else
     {
         MessageBox.Show(e.Error.Message);
     }
 }
Пример #2
0
        void FileList_FetchCompleted(object sender, Natsuhime.Events.ReturnCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                int           postId = int.Parse(e.UserState.ToString());
                List <string> files  = e.ReturnObject as List <string>;
                foreach (string file in files)
                {
                    string sqlFile = string.Format(
                        "INSERT INTO files(`url`) VALUES('{0}');select last_insert_rowid()",
                        file
                        );
                    try
                    {
                        //Natsuhime.Data.DbHelper.ExecuteNonQuery(CommandType.Text, sqlFile);
                        object fileId = Natsuhime.Data.DbHelper.ExecuteScalar(
                            CommandType.Text,
                            sqlFile
                            );


                        string sqlFile2Post = string.Format(
                            "INSERT INTO file2post(`postid`,`fileid`) VALUES({0},{1})",
                            postId,
                            Convert.ToInt32(fileId)
                            );
                        Natsuhime.Data.DbHelper.ExecuteNonQuery(
                            CommandType.Text,
                            sqlFile2Post
                            );
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                MessageBox.Show(string.Format("{0} Files Completed!", files.Count));
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Пример #3
0
        void ps_Completed(object sender, Natsuhime.Events.ReturnCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                ShowMessage("获取列表", "完成.", "");
                List <ProxyInfo> list = (List <ProxyInfo>)e.ReturnObject;

                List <ProxyInfo> oldList = ProxyUtility.GetProxyList_FromConfig(_ProxyListFilePath);
                if (oldList != null && oldList.Count > 0)
                {
                    list.AddRange(oldList);
                }
                ProxyUtility.SaveProxyList_ToConfig(RemoveExitsProxy(list), _ProxyListFilePath);
                ShowMessage("获取列表", "保存配置成功.", "");
            }
            else
            {
                //TODO
            }
        }