Filter:   InfoImg
download ManagerMain.aspx.cs
Language: C#
LOC: 517
Project Info
common-component-mng-sys - Common Componen...e ...(common-component-mng-sys)
Server: Google
Type: svn
...on‑component‑mng‑sys\trunk\
   AddNewComponent.aspx
   AddNewComponent.aspx.cs
   ADLogin.aspx
   ADLogin.aspx.cs
   ...SearchActionChoice.aspx
   ...rchActionChoice.aspx.cs
   CathayBkRSS.xml
   Comment.aspx
   Comment.aspx.cs
   ...n-component-mng-sys.sln
   ...onent-mng-sys_Model.tgs
   ComponentsList.html
   Default.aspx
   Default.aspx.cs
   Downloading.aspx
   Downloading.aspx.cs
   ErrorPage.htm
   Global.asax
   Logon.aspx
   Logon.aspx.cs
   ManagerMain.aspx
   ManagerMain.aspx.cs
   MasterPage.master
   MasterPage.master.cs
   ReviseComponent.aspx
   ReviseComponent.aspx.cs
   SearchComponent.aspx
   SearchComponent.aspx.cs
   SearchResult.aspx
   SearchResult.aspx.cs
   StatisticsReport.aspx
   StatisticsReport.aspx.cs
   ...oDownloadComponent.aspx
   ...wnloadComponent.aspx.cs
   web.config
   Web.sitemap
   ...ejectReasonAndMail.aspx
   ...ctReasonAndMail.aspx.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;

public partial class ManagerMain : System.Web.UI.Page
{
    private string strFileSavePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // NFormView ܴInsertҦ
            fvComponentDetails.ChangeMode(FormViewMode.Edit);
            //FormViewRow fvRow = (FormViewRow)fvAddNewComponent.Row;
            //btnAudit.Enabled = false;
            lblBanner.Visible = false;
        }
    }
    
    #region Uf䪺ʧ@
    protected void btnAudit_Click(object sender, EventArgs e)
    {
        //ofvComponentDetails WUȡAçsComponent TableP@CompoenntID 

        //A@ǭnJ쵹X
        FormView myFormView = (FormView)Page.FindControl("fvComponentDetails");
        Label myLblComponentID = (Label)myFormView.FindControl("lblComponentID");
        TextBox myTbxName = (TextBox)myFormView.FindControl("tbxName");
        TextBox myTbxVersion = (TextBox)myFormView.FindControl("tbxVersion");        
        TextBox myTbxPath = (TextBox)myFormView.FindControl("tbxPath");    
        
        DropDownList myDdlFramework = (DropDownList)myFormView.FindControl("ddlFramework");

        Label myLblContributor = (Label)myFormView.FindControl("lblContributor");        
        TextBox myTbxContributor = (TextBox)myFormView.FindControl("tbxContributor");      
        
        DropDownList myDdlType = (DropDownList)myFormView.FindControl("ddlType");

        TextBox myTbxNote = (TextBox)myFormView.FindControl("tbxNote");
        TextBox myTbxToDo = (TextBox)myFormView.FindControl("tbxToDo");      
        
        DropDownList myDdlIDE = (DropDownList)myFormView.FindControl("ddlIDE");

        TextBox myTbxDescription = (TextBox)myFormView.FindControl("tbxDescription");
        TextBox myTbxSynposis = (TextBox)myFormView.FindControl("tbxSynposis");       
        
        DropDownList myDdlTestEnv = (DropDownList)myFormView.FindControl("ddlTestEnv");
               
        DropDownList myDdlCopyright = (DropDownList)myFormView.FindControl("ddlCopyright");

        TextBox myTbxAcknowledgement = (TextBox)myFormView.FindControl("tbxAcknowledgement");
        TextBox myTbxSeeAlso = (TextBox)myFormView.FindControl("tbxSeeAlso");
        TextBox myTbxAP_ID = (TextBox)myFormView.FindControl("tbxAP_ID");
        TextBox myTbxAP_Name = (TextBox)myFormView.FindControl("tbxAP_Name");
        TextBox myTbxEmail = (TextBox)myFormView.FindControl("tbxEmail");
        TextBox myTbxPhone = (TextBox)myFormView.FindControl("tbxPhone");
        TextBox myIsValid1 = (TextBox)myFormView.FindControl("tbxIsValid1");
        TextBox myIsValid2 = (TextBox)myFormView.FindControl("tbxIsValid2");
        CheckBox myCbxIsBuggy = (CheckBox)myFormView.FindControl("cbxIsBuggy");

        if (String.IsNullOrEmpty(myIsValid1.Text) && String.IsNullOrEmpty(myIsValid2.Text))
        {
            myIsValid1.Text = Context.User.Identity.Name;            
            myIsValid1 = (TextBox)myFormView.FindControl("tbxIsValid1");
            myIsValid2 = (TextBox)myFormView.FindControl("tbxIsValid2");
        }
        else if (myIsValid1.Text != myIsValid2.Text && string.IsNullOrEmpty(myIsValid1.Text) && myIsValid2.Text != Context.User.Identity.Name)             
        {
            myIsValid1.Text = Context.User.Identity.Name;
            myIsValid1 = (TextBox)myFormView.FindControl("tbxIsValid1");
        }
        else if (myIsValid1.Text != myIsValid2.Text && string.IsNullOrEmpty(myIsValid2.Text) && myIsValid1.Text != Context.User.Identity.Name) 
        {
            myIsValid2.Text = Context.User.Identity.Name;
            myIsValid2 = (TextBox)myFormView.FindControl("tbxIsValid2");
        }
        else if (myIsValid1.Text == myIsValid2.Text)
        {
            showMsg("fֻAiP@޲z̼fw");
            return;
        }

        //next ,we all insert the all available data into database

        ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
        string CCSConnectionString = connSettings.ConnectionString;

       // string componentID = Request.QueryString["componentID"];   //γoӴե\઺i       
        string UpdateCommand = "UPDATE COMPONENT SET NAME = " + "'" + myTbxName.Text.Trim() + "'" + ", "
                                + "TYPE = " + "'" + myDdlFramework.Text.Trim() + "'" + ", "
                                + "CONTRIBUTOR = " + "'" + myLblContributor.Text.Trim() + "'" + ", "
                                + "FRAMEWORK = " + "'" + myDdlFramework.Text.Trim() + "'" + ", "
                                + "PATH = " + "'" + myTbxPath.Text.Trim() + "'" + ", "
                                + "VERSION = " + "'" + myTbxVersion.Text.Trim() + "'" + ", "
                                + "SYNPOSIS = " + "'" + myTbxSynposis.Text.Trim().Replace('\'',' ' )+ "'" + ", "
                                + "DESCRIPTION = " + "'" + myTbxDescription.Text.Trim() + "'" + ", "
                                + "TEST_ENVIRONMENT = " + "'" + myDdlTestEnv.Text.Trim() + "'" + ", "
                                + "IDE = " + "'" + myDdlIDE.Text.Trim() + "'" + ", "
                                + "NOTE = " + "'" + myTbxNote.Text.Trim() + "'" + ", "
                                + "TODO = " + "'" + myTbxToDo.Text.Trim() + "'" + ", "
                                + "SEE_ALSO  = " + "'" + myTbxSeeAlso.Text.Trim() + "'" + ", "
                                + "ACKNOWLEDGEMENT = " + "'" + myTbxAcknowledgement.Text.Trim() + "'" + ", "
                                + "COPYRIGHT = " + "'" + myDdlCopyright.Text.Trim() + "'" + ", "
                                + "AP_ID = " + "'" + myTbxAP_ID.Text.Trim() + "'" + ", "
                                + "AP_NAME = " + "'" + myTbxAP_Name.Text.Trim() + "'" + ", "
                                + "EMAIL = " + "'" + myTbxEmail.Text.Trim() + "'" + ", "
                                + "PHONE = " + "'" + myTbxPhone.Text.Trim() + "'" + ", "
                                + "IS_VALID1 =" + "'" + myIsValid1.Text.Trim() + "'" + ", "
                                + "IS_VALID2 =" + "'" + myIsValid2.Text.Trim() + "'" + ", "
                                + "IS_BUGGY =" + "'" + myCbxIsBuggy.Text.Trim() + "'" + ", "
                                + "STATUS =" + "'P'" 
                                + "WHERE COMPONENT_ID = '" + myLblComponentID.Text.Trim() + "' ";


        SqlConnection Conn = new SqlConnection(CCSConnectionString);

        try
        {
            Conn.Open();
        }
        catch (SqlException ex)
        {
            // Connection failed
            showMsg(ex.Message);
        }

        try
        {
            SqlCommand command = new SqlCommand(UpdateCommand, Conn);
            command.CommandType = System.Data.CommandType.Text;
            command.ExecuteNonQuery();
        }      
        catch (Exception ex)
        {
            showMsg(ex.Message);
        }
        finally
        {
            Conn.Close();    //remember to close the db connection
            generateRSSFeed("i", myLblComponentID.Text);
        }
        showMsg("f֧");
        fvComponentDetails.ChangeMode(FormViewMode.ReadOnly);


        if (!String.IsNullOrEmpty(myIsValid1.Text) && !String.IsNullOrEmpty(myIsValid2.Text))
        {
            GenerateComponentsPage(""); //ͭneު
            Publish2WorkSiteMP();//oGުխ

            //HoEmail줸}o
            SendMail2ContributorAboutPublish(myLblComponentID.Text);
        }


    }
    #endregion


    protected void showMsg(string AlertMessage)
    {
        Literal txtMsg = new Literal();
        txtMsg.Text = "<script>alert('" + AlertMessage + "')</script>" + "<br/>";
        Page.Controls.Add(txtMsg);
    }
     


    #region ͦRSS Feed z
    private void generateRSSFeed(string strMsgLevel, string strComponentName)
    {
        SqlConnection conn = null;
        SqlCommand cmd = null;
        SqlDataReader reader = null;
        RSSChannel channel = null;
        StreamWriter sw = null;
        StreamReader sr = null;
        int a = 0;

        try
        {
            channel = new RSSChannel();
            channel.title = "@ظTBG@Τ޲zt Feed";
            channel.webMaster = "jiing.deng@cathaybk.com.tw";
            channel.managingEditor = "jiing.deng@cathaybk.com.tw";
            //channel.link = "http://www.cathaybk.com.tw";
            channel.description = "@ظTBUx@Τ󤽧i";

            ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
            string CCSConnectionString = connSettings.ConnectionString;

            conn = new SqlConnection(CCSConnectionString);
            cmd = new SqlCommand("SELECT NAME,FRAMEWORK,VERSION,DL_LINK,DESCRIPTION " +
                                   "FROM COMPONENT WHERE NAME ='" + strComponentName + "' AND STATUS ='P' " + "WITH (NOLOCK) ORDER BY NAME,VERSION DESC",
                                   conn);

            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                channel.AppendRSSItem("[" + strMsgLevel + "]" + reader["NAME"].ToString().Trim() + " for "
                                          + reader["FRAMEWORK"].ToString().Trim() + " Ver." +
                                            reader["VERSION"].ToString().Trim(),
                                        //    reader["DL_LINK"].ToString().Trim(),
                                            reader["DESCRIPTION"].ToString().Trim(), string.Empty);
            }
            reader.Close();
            conn.Close();

            bool isAppend = File.Exists(strFileSavePath + "CathayBkRSS.xml");
            if (!isAppend)
            {
                sw = new StreamWriter(strFileSavePath + "CathayBkRSS.xml", false,
                               System.Text.Encoding.GetEncoding("utf-8"));
                sw.WriteLine(channel.GenerateChannel());
            }
            else
            {
                sr = new StreamReader(strFileSavePath + "CathayBkRSS.xml", System.Text.Encoding.GetEncoding("utf-8"));
                string original = sr.ReadToEnd();
                sr.DiscardBufferedData();
                sr.Dispose();

                string newTxt = string.Empty;
                for (a = 0; a < channel.itemLst.Count; a++)
                {
                    newTxt += ((RSSItem)channel.itemLst[a]).GenerateItem();
                }

                //夤Ĥ@Item
                int thePos = original.IndexOf("<item>");
                if (thePos > 0)
                {
                    //NHUeUguidXﻼW
                    int target1 = original.IndexOf("<guid>", thePos);
                    int target2 = 0;
                    while (target1 > thePos)
                    {
                        target2 = original.IndexOf("</guid>", target1 + "<guid>".Length);
                        string match = original.Substring(target1 + "<guid>".Length, target2 - (target1 + "<guid>".Length));
                        int lastSharp = match.LastIndexOf('#');
                        int newNum = int.Parse(match.Substring(lastSharp + "#".Length)) + a;
                        string newMatch = match.Substring(0, lastSharp) + "#" + newNum.ToString().Trim();

                        original = original.Replace("<guid>" + match + "</guid>", "<guid>" + newMatch + "</guid>");

                        target1 = original.IndexOf("<guid>", target2 + "</guid>".Length);
                    }

                    original = original.Insert(thePos, newTxt);
                }

                sw = new StreamWriter(strFileSavePath + "CathayBkRSS.xml", false, System.Text.Encoding.GetEncoding("utf-8"));
                sw.WriteLine(original);
            }
            sw.Flush();
            sw.Close();

            sw.Dispose();
            reader.Dispose();
            cmd.Dispose();
            conn.Dispose();
        }
        catch (Exception exp)
        {
            showMsg(exp.Message);
        }
        finally
        {
            reader = null;
            cmd = null;
            conn = null;
            channel = null;
            sw = null;
            sr = null;
        }
    }
    #endregion

    protected void gvComToDoList_SelectedIndexChanged1(object sender, EventArgs e)
    {
        //btnAudit.Enabled = true;
        fvComponentDetails.ChangeMode(FormViewMode.Edit);
        lblBanner.Visible = true;
        Panel1.Visible = false;
      //  gvComToDoList.Visible = false;

    }

 
       
    protected void btnReject_Click(object sender, EventArgs e)
    {
        // oOaNjob quere rejectAiHisbuggyӼХܡH
        // ҥHreject AR
        //na@QueryStringih
        FormView myFormView = (FormView)Page.FindControl("fvComponentDetails");
        Label myLblComponentID = (Label)myFormView.FindControl("lblComponentID");
        Label myLblContributor = (Label)myFormView.FindControl("lblContributor");
        TextBox myTbxVersion = (TextBox)myFormView.FindControl("tbxVersion");
        string strFramework = queryFrameworkByComponentID(myLblComponentID.Text);

        //ڵA]D (Delete^nF
        UpdateComponentStatusToDelete(myLblComponentID.Text);

        Server.Transfer("~/WriteRejectReasonAndMail.aspx?ComponentID=" + myLblComponentID.Text + "&Contributor=" + myLblContributor.Text + "&Framework=" + strFramework + "&Version=" + myTbxVersion.Text);
    }

    private void UpdateComponentStatusToDelete(string strComponentID) {
        ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
        string CCSConnectionString = connSettings.ConnectionString;

        // string componentID = Request.QueryString["componentID"];   //γoӴե\઺i       
        string UpdateCommand = "UPDATE COMPONENT SET STATUS = 'D'"
                                + "WHERE COMPONENT_ID = '" + strComponentID + "' ";


        SqlConnection Conn = new SqlConnection(CCSConnectionString);

        try
        {
            Conn.Open();
        }
        catch (SqlException ex)
        {
            // Connection failed
            showMsg(ex.Message);
        }

        try
        {
            SqlCommand command = new SqlCommand(UpdateCommand, Conn);
            command.CommandType = System.Data.CommandType.Text;
            command.ExecuteNonQuery();
        }
        catch (SqlException ex)
        {
            showMsg(ex.Message);
        }        
        finally
        {
            Conn.Close();    //remember to close the db connection
          
        }
    
    }


    private string queryFrameworkByComponentID(string strComponentID)
    {
        string strFramework = "";
        SqlConnection conn = null;
        SqlCommand cmd = null;
        SqlDataReader reader = null;
        try
        {
            ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
            string CCSConnectionString = connSettings.ConnectionString;

            conn = new SqlConnection(CCSConnectionString);
            cmd = new SqlCommand("SELECT FRAMEWORK FROM COMPONENT WHERE COMPONENT_ID ='" + strComponentID + "'", conn);

            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                strFramework = reader["FRAMEWORK"].ToString().Trim();
            }
        }
        catch (Exception ex)
        {
            showMsg(ex.Message);
        }
        finally 
        {
            reader.Close();
            conn.Close();
        }

        return strFramework;
    }
  
    protected void btnGo2Main_Click(object sender, EventArgs e)
    {
        Server.Transfer("~/Default.aspx");
    }

    #region oGިt
    private void Publish2WorkSiteMP()
    {
        // Get the full file path
        string strFilePath = strFileSavePath + "compNews\\start.bat";
        // Create the ProcessInfo object
        System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");
        psi.UseShellExecute = false;
        psi.RedirectStandardOutput = true;
        psi.RedirectStandardInput = true;
        psi.RedirectStandardError = true;
        psi.WorkingDirectory = strFileSavePath + "compNews\\";

        try
        {
            if (File.Exists(strFilePath))
            {


                // Start the process
                System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);

                // Open the batch file for reading
                System.IO.StreamReader strm = System.IO.File.OpenText(strFilePath);

                // Attach the output for reading
                System.IO.StreamReader sOut = proc.StandardOutput;

                // Attach the in for writing
                System.IO.StreamWriter sIn = proc.StandardInput;

                // Write each line of the batch file to standard input
                while (strm.Peek() != -1)
                {
                    sIn.WriteLine(strm.ReadLine());
                }

                strm.Close();

                // Exit CMD.EXE
                string stEchoFmt = "# {0} run successfully. Exiting";

                sIn.WriteLine(String.Format(stEchoFmt, strFilePath));
                sIn.WriteLine("EXIT");

                // Close the process
                proc.Close();

                // Read the sOut to a string.
                string results = sOut.ReadToEnd().Trim();

                // Close the io Streams;
                sIn.Close();
                sOut.Close();

                // Write out the results.
                //   string fmtStdOut = "<font face=courier size=0>{0}</font>";
                //  this.Response.Write(String.Format(fmtStdOut,results.Replace(System.Environment.NewLine, "<br>")));

            }
            else
            {
                showMsg("j䤣");
            }
        }
        catch (Exception ex)
        {
            showMsg(ex.Message);
        }

    }
    #endregion


    #region `ରHtmlAݰިt
    public void GenerateComponentsPage(string outputPath)
    {
        SqlDataAdapter ada = null;
        DataTable tbl = null;
        StreamWriter sw = null;
        ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
        string CCSConnectionString = connSettings.ConnectionString;
        SqlConnection DBConnection = new SqlConnection(CCSConnectionString);
        try
        {
            string tblHTML = string.Empty;
            //ȿeTQ
            string sqlTxt = "SELECT TOP 30 NAME,VERSION,TYPE,PATH,CONTRIBUTOR,PHONE,DL_LINK," +
                            "MYDATETIME,DESCRIPTION FROM COMPONENT WITH (NOLOCK)" +
                            " WHERE STATUS ='P' ORDER BY MYDATETIME DESC";
            ada = new SqlDataAdapter(sqlTxt, DBConnection);
            tbl = new DataTable();
            ada.Fill(tbl);

            foreach (DataRow dr in tbl.Rows)
            {
                tblHTML += "<DIV ALIGN='CENTER'><TABLE BORDER='1'>\n" +
                        "<CAPTION><H1>" + dr["NAME"].ToString().Trim() + "</H1></CAPTION>\n" +
                        "<TR><TD COLSPAN='4'>" + dr["DESCRIPTION"].ToString().Trim() + "</TD></TR>\n" +
                        "<TR><TD></TD><TD>" + dr["VERSION"].ToString().Trim() + "</TD>" +
                        "<TD></TD><TD>" + dr["TYPE"].ToString().Trim() + "</TD></TR>\n" +
                        "<TR><TD>𪬹ϸ|</TD><TD COLSPAN='3'>" + dr["PATH"].ToString().Trim() +
                        "</TD></TR>\n" +
                        "<TR><TD>^m</TD><TD>" + dr["CONTRIBUTOR"].ToString().Trim() + "</TD>" +
                        "<TD>q/</TD><TD>" + dr["PHONE"].ToString().Trim() + "</TD></TR>\n" +
                        "<TR><TD>U</TD><TD>" + dr["DL_CNT"].ToString().Trim() + "</TD></TR>\n" +
                         "<TR><TD>ثe`</TD><TD>" + dr["TOTAL_SCORE"].ToString().Trim() + "</TD>" +
                        "<TR><TD>sW</TD><TD>" + dr["MYDATETIME"].ToString().Trim() + "</TD>" +
                        "</TR>\n" +
                        "</TABLE></DIV>\n" +
                        "<BR /><BR />\n";
            }

            if (tblHTML.Length > 0)
            {
                sw = new StreamWriter(strFileSavePath + "\\ComponentsList.html", false,
                                    System.Text.Encoding.GetEncoding("utf-8"));
                sw.WriteLine("<HTML>\n" +
                            "<HEAD>\n" +
                            "<TITLE>s@ΤoG</TITLE>\n" +
                            "</HEAD>\n" +
                            "<BODY>\n");
                sw.WriteLine(tblHTML);
                sw.WriteLine("</BODY>\n" +
                            "</HTML>\n");
                sw.Flush();
                sw.Close();
            }

            tbl.Clear();

            tbl.Dispose();
            ada.Dispose();
            sw.Dispose();
        }
        catch (Exception exp)
        {
            throw new Exception(exp.Message);
        }
        finally
        {
            tbl = null;
            ada = null;
            sw = null;
        }
    }
    #endregion


    #region Heemail󪺶}o̡AiwG
    private void SendMail2ContributorAboutPublish(string strComponentID)
    {

        //Step 1. dEmail
        string strEmailAddress = "";
        SqlConnection conn = null;
        SqlCommand cmd = null;
        SqlDataReader reader = null;
        try
        {
            ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
            string CCSConnectionString = connSettings.ConnectionString;

            conn = new SqlConnection(CCSConnectionString);
            cmd = new SqlCommand("SELECT EMAIL FROM COMPONENT WHERE COMPONENT_ID ='" + strComponentID + "'", conn);

            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                strEmailAddress = reader["EMAIL"].ToString().Trim();
            }
        }
        catch (Exception ex)
        {
            showMsg(ex.Message);
        }
        finally
        {
            reader.Close();
            conn.Close();
        }

        //Step 2.HoEmail 󪺶}o    
        sendEMail("", strEmailAddress);

    }

    #endregion


    #region HeEmailiT
    private void sendEMail(string strMailBody, string strMailToAddress)
    {

        //PɱHe޲z̻PϥΪ  
        String strTo = "<jiing.deng@cathaybk.com.tw>;" + strMailToAddress;
        //ӷO@Τ޲ztΩM޲z
        String strFrom = "<CCOM@cathaybk.com.tw>";
        String strMailSubject = "[@Τ]@Τ޲ztΪAqHI";

        if (String.IsNullOrEmpty(strMailBody))
        {
            strMailBody = "oOѦ@Τ޲ztγqT</b>A<b><font color=\"blue\">zҭק諸AثewQG@Τ</font><br>";

        }
        System.Net.Mail.SmtpClient client = new SmtpClient();
        client.Host = "PIEX2K05.cathaybk.intra.uwccb";
        client.Port = 25;
        client.UseDefaultCredentials = false;
        client.Credentials = new System.Net.NetworkCredential("uid", "pwd");  //uid, pwd please replace as yours
        client.DeliveryMethod = SmtpDeliveryMethod.Network;

        System.Net.Mail.MailMessage message = new MailMessage(strFrom, strTo, strMailSubject, strMailBody);
        message.BodyEncoding = System.Text.Encoding.UTF8;
        message.IsBodyHtml = true;

        try
        {
            client.Send(message);
            Response.Write("<font color=\"blue\">Email successfully sent.</font>");
        }
        catch (Exception ex)
        {
            Response.Write("Send Email Failed." + ex.ToString()); ;
        }
    }
    #endregion

    protected void cbxIsBuggy_CheckedChanged(object sender, EventArgs e)
    {
        //oQĿɡANbug

        FormView myFormView = (FormView)Page.FindControl("fvComponentDetails");
        Label myLblComponentID = (Label)myFormView.FindControl("lblComponentID");
        string strComponentID = myLblComponentID.Text;

        //Step 1. dEmail
        string strEmailAddress = "";
        SqlConnection conn = null;
        SqlCommand cmd = null;
        SqlDataReader reader = null;
        try
        {
            ConnectionStringSettings connSettings = ConfigurationManager.ConnectionStrings["CCSConnectionString"];
            string CCSConnectionString = connSettings.ConnectionString;

            conn = new SqlConnection(CCSConnectionString);
            cmd = new SqlCommand("SELECT EMAIL FROM COMPONENT WHERE COMPONENT_ID ='" + strComponentID + "'", conn);

            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                strEmailAddress = reader["EMAIL"].ToString().Trim();
            }
        }
        catch (Exception ex)
        {
            showMsg(ex.Message);
        }
        finally
        {
            reader.Close();
            conn.Close();
        }

    }
}