コード例 #1
0
ファイル: ctrPost.cs プロジェクト: thachgiasoft/qlcongviec
 private void PostTopic()
 {
     while (dtTable.Rows.Count > 0)
     {
         if (isAbort == false)
         {
             if (isLock == false)
             {
                 if (dtTable.Rows.Count > 0)
                 {
                     try
                     {
                         isLock = true;
                         string strErr = "";
                         long   id     = long.Parse(dtTable.Rows[0]["ID"].ToString());
                         dtTable.Rows.RemoveAt(0);
                         hashTable.Add(id, false);
                         WebLink weblink = WebLink.Get(id);
                         isLock = false;
                         StatusObj statusObj = new StatusObj();
                         if (weblink != null)
                         {
                             DataRow dtRow = dtLogEntries.NewRow();
                             dtRow["ID"]       = id;
                             dtRow["DateTime"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                             dtLogEntries.Rows.Add(dtRow);
                             if (_Type == NumCode.POS)
                             {
                                 strErr = "Post to " + weblink.Url + " ....................";
                                 dtRow["LogEntries"] = strErr;
                                 try
                                 {
                                     WebBrowser webBrowser = (WebBrowser)panelControl1.Controls[id.ToString()];
                                     AutoPost   post       = new AutoPost(webBrowser, multiforum, weblink, Subject, Content, Tag);
                                     statusObj = post.PostTopic();
                                     strErr    = strErr + statusObj.Message;
                                 }
                                 catch
                                 {
                                     strErr = strErr + "Error.";
                                 }
                             }
                             else
                             {
                                 strErr = "Up to " + weblink.Url + " [ " + weblink.Topic + " ] " + "....................";
                                 dtRow["LogEntries"] = strErr;
                                 try
                                 {
                                     WebBrowser webBrowser = (WebBrowser)panelControl1.Controls[id.ToString()];
                                     AutoPost   post       = new AutoPost(webBrowser, multiforum, weblink, Subject, Content, Tag);
                                     statusObj = post.UpTopic();
                                     strErr    = strErr + statusObj.Message;
                                 }
                                 catch
                                 {
                                     strErr = strErr + "Error.";
                                 }
                             }
                             dtRow["LogEntries"] = strErr;
                             dtRow["LinkUp"]     = statusObj.Value;
                             dtRow["Status"]     = statusObj.Status;
                             if (statusObj.Status == "Successful")
                             {
                                 haveSuccessful = true;
                             }
                             hashTable[id] = true;
                         }
                     }
                     catch
                     { isLock = false; }
                 }
             }
         }
     }
     try
     {
         if (Thread.CurrentThread.IsAlive)
         {
             Thread.CurrentThread.Abort();
         }
     }
     catch { }
 }