Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

603 lines
15 KiB

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. namespace XReports
  13. {
  14. /// <summary>
  15. /// Summary description for languagereport.
  16. /// </summary>
  17. public class languagereport : System.Web.UI.Page
  18. {
  19. protected System.Web.UI.WebControls.Table tblUploads;
  20. protected System.Web.UI.WebControls.DropDownList ddlLangs;
  21. protected System.Web.UI.WebControls.Calendar Calendar1;
  22. private void Page_Load(object sender, System.EventArgs e)
  23. {
  24. if(Page.IsPostBack == false)
  25. {
  26. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  27. SqlConnection cn2 = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  28. SqlCommand cm = new SqlCommand();
  29. SqlDataReader dr;
  30. int rowCtr=0;
  31. int cellCtr=0;
  32. int cellCnt = 5;
  33. int x = 0;
  34. double dbDays = -7;
  35. DateTime dDate = DateTime.Now;
  36. cn.Open();
  37. cm.CommandType = CommandType.StoredProcedure;
  38. cm.CommandTimeout = 240;
  39. cm.CommandText = "GetOSLangReport";
  40. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  41. dDate = dDate.AddDays(dbDays);
  42. cm.Parameters[0].Value = dDate.ToShortDateString();
  43. cm.Connection = cn;
  44. dr = cm.ExecuteReader();
  45. Calendar1.SelectedDate = dDate;
  46. SqlCommand cm2 = new SqlCommand();
  47. SqlDataReader dr2;
  48. ArrayList strLanguages = new ArrayList();
  49. // dr.Read();
  50. cn2.Open();
  51. cm2.CommandType = CommandType.StoredProcedure;
  52. cm2.CommandTimeout = 240;
  53. cm2.CommandText = "GetOSLanguageHeaders";
  54. cm2.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  55. cm2.Parameters[0].Value = dDate.ToShortDateString();
  56. cm2.Connection = cn2;
  57. dr2 = cm2.ExecuteReader();
  58. ddlLangs.DataSource = dr2;
  59. ddlLangs.Items.Add("ALL");
  60. dr2.Read();
  61. do
  62. {
  63. // ddlLanguages.Items.Add(dr2.GetString(0));
  64. try
  65. {
  66. strLanguages.Add(dr2.GetString(0));
  67. }
  68. catch
  69. {
  70. }
  71. }while(dr2.Read() == true);
  72. strLanguages.Sort();
  73. for(x = 0; x < strLanguages.Count; x++)
  74. {
  75. // ddlLanguages.Items.Add(dr2.GetString(0));
  76. try
  77. {
  78. ddlLangs.Items.Add(strLanguages[x].ToString());
  79. }
  80. catch
  81. {
  82. ddlLangs.Items.Add("Unknown" + strLanguages[x].ToString());
  83. }
  84. }
  85. do
  86. {
  87. TableRow tRow = new TableRow();
  88. tblUploads.Rows.Add(tRow);
  89. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  90. {
  91. TableCell tCell = new TableCell();
  92. if(rowCtr == 0)
  93. {
  94. switch(cellCtr)
  95. {
  96. case 1:
  97. tCell.Text = "OS Lang";
  98. break;
  99. case 2 :
  100. tCell.Text = "Total";
  101. break;
  102. case 3 :
  103. tCell.Text = "OS Version";
  104. break;
  105. case 4:
  106. tCell.Text = "OS Name";
  107. break;
  108. case 5:
  109. tCell.Text = "Date";
  110. break;
  111. default:
  112. tCell.Text = "";
  113. break;
  114. }
  115. tCell.Style["font-size"] = "small";
  116. tCell.Height = 20;
  117. }
  118. else
  119. {
  120. switch(cellCtr)
  121. {
  122. case 1 :
  123. tCell.Text = dr.GetString(0).ToString();
  124. break;
  125. case 2 :
  126. tCell.Text = dr.GetInt32(1).ToString();
  127. break;
  128. case 3 :
  129. tCell.Text = dr.GetString(2).ToString();
  130. break;
  131. case 4 :
  132. tCell.Text = dr.GetString(3).ToString();
  133. break;
  134. case 5 :
  135. if(dr.IsDBNull(4))
  136. {
  137. tCell.Text = "";
  138. }
  139. else
  140. {
  141. tCell.Text = dr.GetDateTime(4).ToShortDateString();
  142. }
  143. break;
  144. default:
  145. tCell.Text = "0";
  146. break;
  147. }
  148. tCell.Style["background-color"] = "white";
  149. tCell.Style["font-size"] = "small-x";
  150. tCell.Style["color"] = "#6487dc";
  151. tCell.Style["font-weight"] = "Bold";
  152. tCell.Height = 20;
  153. }
  154. tCell.Style["font-family"] = "Tahoma";
  155. tRow.Cells.Add(tCell);
  156. }
  157. rowCtr++;
  158. }while(dr.Read() == true);
  159. }
  160. }
  161. #region Web Form Designer generated code
  162. override protected void OnInit(EventArgs e)
  163. {
  164. //
  165. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  166. //
  167. InitializeComponent();
  168. base.OnInit(e);
  169. }
  170. /// <summary>
  171. /// Required method for Designer support - do not modify
  172. /// the contents of this method with the code editor.
  173. /// </summary>
  174. private void InitializeComponent()
  175. {
  176. this.Calendar1.VisibleMonthChanged += new System.Web.UI.WebControls.MonthChangedEventHandler(this.Calendar1_VisibleMonthChanged);
  177. this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
  178. this.ddlLangs.SelectedIndexChanged += new System.EventHandler(this.ddlLangs_SelectedIndexChanged);
  179. this.Load += new System.EventHandler(this.Page_Load);
  180. }
  181. #endregion
  182. private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
  183. {
  184. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  185. SqlCommand cm = new SqlCommand();
  186. SqlDataReader dr;
  187. DateTime dDate = DateTime.Now;
  188. int rowCtr=0;
  189. int cellCtr=0;
  190. int cellCnt = 5;
  191. int iLang = 0;
  192. string sLang;
  193. TableRow tRow;
  194. TableCell tCell;
  195. cn.Open();
  196. cm.CommandType = CommandType.StoredProcedure;
  197. cm.CommandTimeout = 240;
  198. cm.CommandText = "GetOSLangReport";
  199. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  200. dDate = Calendar1.SelectedDate;
  201. cm.Parameters[0].Value = dDate.ToShortDateString();
  202. cm.Connection = cn;
  203. dr = cm.ExecuteReader();
  204. //dr.Read();
  205. do
  206. {
  207. if(rowCtr > 0)
  208. {
  209. sLang = dr.GetString(0);
  210. if(sLang == "")
  211. {
  212. iLang = 0;
  213. }
  214. else
  215. {
  216. iLang = System.Convert.ToInt16(dr.GetString(0), 10);
  217. }
  218. }
  219. if(rowCtr == 0 || ddlLangs.SelectedItem.Value == "ALL" || iLang.ToString() == ddlLangs.SelectedItem.Value)
  220. {
  221. tRow = new TableRow();
  222. // }
  223. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  224. {
  225. tblUploads.Rows.Add(tRow);
  226. tCell = new TableCell();
  227. if(rowCtr == 0)
  228. {
  229. switch(cellCtr)
  230. {
  231. case 1:
  232. tCell.Text = "OS Lang2";
  233. break;
  234. case 2 :
  235. tCell.Text = "Total";
  236. break;
  237. case 3 :
  238. tCell.Text = "OS Version";
  239. break;
  240. case 4:
  241. tCell.Text = "OS Name";
  242. break;
  243. case 5:
  244. tCell.Text = "Date";
  245. break;
  246. default:
  247. tCell.Text = "";
  248. break;
  249. }
  250. tCell.Style["font-size"] = "small";
  251. tCell.Height = 20;
  252. }
  253. else
  254. {
  255. switch(cellCtr)
  256. {
  257. case 1 :
  258. // tCell.Text = dr.GetString(0).ToString();
  259. try
  260. {
  261. tCell.Text = dr.GetString(0);
  262. }
  263. catch
  264. {
  265. tCell.Text = "Unknown" + dr.GetString(0);
  266. }
  267. break;
  268. case 2 :
  269. tCell.Text = dr.GetInt32(1).ToString();
  270. break;
  271. case 3 :
  272. tCell.Text = dr.GetString(2).ToString();
  273. break;
  274. case 4 :
  275. tCell.Text = dr.GetString(3).ToString();
  276. break;
  277. case 5 :
  278. if(dr.IsDBNull(4))
  279. {
  280. tCell.Text = "";
  281. }
  282. else
  283. {
  284. tCell.Text = dr.GetDateTime(4).ToShortDateString();
  285. }
  286. break;
  287. default:
  288. tCell.Text = "0";
  289. break;
  290. }
  291. tCell.Style["background-color"] = "white";
  292. tCell.Style["font-size"] = "small-x";
  293. tCell.Style["color"] = "#6487dc";
  294. tCell.Style["font-weight"] = "Bold";
  295. tCell.Height = 20;
  296. }
  297. tCell.Style["font-family"] = "Tahoma";
  298. tRow.Cells.Add(tCell);
  299. }//for
  300. }
  301. rowCtr++;
  302. }while(dr.Read() == true);
  303. }
  304. private void Calendar1_VisibleMonthChanged(object sender, System.Web.UI.WebControls.MonthChangedEventArgs e)
  305. {
  306. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  307. SqlCommand cm = new SqlCommand();
  308. SqlDataReader dr;
  309. DateTime dDate = DateTime.Now;
  310. int rowCtr=0;
  311. int cellCtr=0;
  312. int cellCnt = 5;
  313. int iLang = 0;
  314. string sLang;
  315. TableRow tRow;
  316. TableCell tCell;
  317. cn.Open();
  318. cm.CommandType = CommandType.StoredProcedure;
  319. cm.CommandTimeout = 240;
  320. cm.CommandText = "GetOSLangReport";
  321. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  322. dDate = Calendar1.SelectedDate;
  323. cm.Parameters[0].Value = dDate.ToShortDateString();
  324. cm.Connection = cn;
  325. dr = cm.ExecuteReader();
  326. //dr.Read();
  327. do
  328. {
  329. if(rowCtr > 0)
  330. {
  331. sLang = dr.GetString(0);
  332. if(sLang == "")
  333. {
  334. iLang = 0;
  335. }
  336. else
  337. {
  338. iLang = System.Convert.ToInt16(dr.GetString(0), 10);
  339. }
  340. }
  341. if(rowCtr == 0 || ddlLangs.SelectedItem.Value == "ALL" || iLang.ToString() == ddlLangs.SelectedItem.Value)
  342. {
  343. tRow = new TableRow();
  344. // }
  345. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  346. {
  347. tblUploads.Rows.Add(tRow);
  348. tCell = new TableCell();
  349. if(rowCtr == 0)
  350. {
  351. switch(cellCtr)
  352. {
  353. case 1:
  354. tCell.Text = "OS Lang2";
  355. break;
  356. case 2 :
  357. tCell.Text = "Total";
  358. break;
  359. case 3 :
  360. tCell.Text = "OS Version";
  361. break;
  362. case 4:
  363. tCell.Text = "OS Name";
  364. break;
  365. case 5:
  366. tCell.Text = "Date";
  367. break;
  368. default:
  369. tCell.Text = "";
  370. break;
  371. }
  372. tCell.Style["font-size"] = "small";
  373. tCell.Height = 20;
  374. }
  375. else
  376. {
  377. switch(cellCtr)
  378. {
  379. case 1 :
  380. // tCell.Text = dr.GetString(0).ToString();
  381. try
  382. {
  383. tCell.Text = dr.GetString(0);
  384. }
  385. catch
  386. {
  387. tCell.Text = "Unknown" + dr.GetString(0);
  388. }
  389. break;
  390. case 2 :
  391. tCell.Text = dr.GetInt32(1).ToString();
  392. break;
  393. case 3 :
  394. tCell.Text = dr.GetString(2).ToString();
  395. break;
  396. case 4 :
  397. tCell.Text = dr.GetString(3).ToString();
  398. break;
  399. case 5 :
  400. if(dr.IsDBNull(4))
  401. {
  402. tCell.Text = "";
  403. }
  404. else
  405. {
  406. tCell.Text = dr.GetDateTime(4).ToShortDateString();
  407. }
  408. break;
  409. default:
  410. tCell.Text = "0";
  411. break;
  412. }
  413. tCell.Style["background-color"] = "white";
  414. tCell.Style["font-size"] = "small-x";
  415. tCell.Style["color"] = "#6487dc";
  416. tCell.Style["font-weight"] = "Bold";
  417. tCell.Height = 20;
  418. }
  419. tCell.Style["font-family"] = "Tahoma";
  420. tRow.Cells.Add(tCell);
  421. }//for
  422. }
  423. rowCtr++;
  424. }while(dr.Read() == true);
  425. }
  426. private void ddlLangs_SelectedIndexChanged(object sender, System.EventArgs e)
  427. {
  428. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  429. SqlCommand cm = new SqlCommand();
  430. SqlDataReader dr;
  431. DateTime dDate = DateTime.Now;
  432. int rowCtr=0;
  433. int cellCtr=0;
  434. int cellCnt = 5;
  435. int iLang = 0;
  436. string sLang;
  437. TableRow tRow;
  438. TableCell tCell;
  439. cn.Open();
  440. cm.CommandType = CommandType.StoredProcedure;
  441. cm.CommandTimeout = 240;
  442. cm.CommandText = "GetOSLangReport";
  443. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  444. dDate = Calendar1.SelectedDate;
  445. cm.Parameters[0].Value = dDate.ToShortDateString();
  446. cm.Connection = cn;
  447. dr = cm.ExecuteReader();
  448. //dr.Read();
  449. do
  450. {
  451. if(rowCtr > 0)
  452. {
  453. sLang = dr.GetString(0);
  454. if(sLang == "")
  455. {
  456. iLang = 0;
  457. }
  458. else
  459. {
  460. iLang = System.Convert.ToInt16(dr.GetString(0), 10);
  461. }
  462. }
  463. if(rowCtr == 0 || ddlLangs.SelectedItem.Value == "ALL" || iLang.ToString() == ddlLangs.SelectedItem.Value)
  464. {
  465. tRow = new TableRow();
  466. // }
  467. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  468. {
  469. tblUploads.Rows.Add(tRow);
  470. tCell = new TableCell();
  471. if(rowCtr == 0)
  472. {
  473. switch(cellCtr)
  474. {
  475. case 1:
  476. tCell.Text = "OS Lang2";
  477. break;
  478. case 2 :
  479. tCell.Text = "Total";
  480. break;
  481. case 3 :
  482. tCell.Text = "OS Version";
  483. break;
  484. case 4:
  485. tCell.Text = "OS Name";
  486. break;
  487. case 5:
  488. tCell.Text = "Date";
  489. break;
  490. default:
  491. tCell.Text = "";
  492. break;
  493. }
  494. tCell.Style["font-size"] = "small";
  495. tCell.Height = 20;
  496. }
  497. else
  498. {
  499. switch(cellCtr)
  500. {
  501. case 1 :
  502. // tCell.Text = dr.GetString(0).ToString();
  503. try
  504. {
  505. tCell.Text = dr.GetString(0);
  506. }
  507. catch
  508. {
  509. tCell.Text = "Unknown" + dr.GetString(0);
  510. }
  511. break;
  512. case 2 :
  513. tCell.Text = dr.GetInt32(1).ToString();
  514. break;
  515. case 3 :
  516. tCell.Text = dr.GetString(2).ToString();
  517. break;
  518. case 4 :
  519. tCell.Text = dr.GetString(3).ToString();
  520. break;
  521. case 5 :
  522. if(dr.IsDBNull(4))
  523. {
  524. tCell.Text = "";
  525. }
  526. else
  527. {
  528. tCell.Text = dr.GetDateTime(4).ToShortDateString();
  529. }
  530. break;
  531. default:
  532. tCell.Text = "0";
  533. break;
  534. }
  535. tCell.Style["background-color"] = "white";
  536. tCell.Style["font-size"] = "small-x";
  537. tCell.Style["color"] = "#6487dc";
  538. tCell.Style["font-weight"] = "Bold";
  539. tCell.Height = 20;
  540. }
  541. tCell.Style["font-family"] = "Tahoma";
  542. tRow.Cells.Add(tCell);
  543. }//for
  544. }
  545. rowCtr++;
  546. }while(dr.Read() == true);
  547. }
  548. }
  549. }