private void setGridSource() { if (txtFromDate.Value.ToString() != "" && txtToDate.Value.ToString() != "") { AssetBusiness asset = new AssetBusiness(); DataTable dtnotExistRecords = new DataTable(); var dtAsset = asset.GetFileCount(txtFromDate.Value.ToString(), txtToDate.Value.ToString(), cmbTerm.SelectedItem.Value); string date, path; dtnotExistRecords.Columns.Add("Class_Code"); dtnotExistRecords.Columns.Add("term"); dtnotExistRecords.Columns.Add("FileDate"); foreach (DataRow dr in dtAsset.Rows) { date = dr["FileDate"].ToString().Replace('/', '-'); path = Server.MapPath("../content/" + dr["Term"].ToString() + "/" + dr["Class_Code"].ToString() + "/" + date); if (Directory.Exists(path) == true) { DirectoryInfo di = new DirectoryInfo(path); // Get a reference to each file in that directory. FileInfo[] fiArrZip = di.GetFiles("*.zip"); if ((di.GetFiles("*.mp3").Count() == 0 || di.GetFiles("*.avi").Count() == 0 || di.GetFiles("*.flv").Count() == 0) && fiArrZip.Count() == 0) { DataRow drNotExistRecordsrow = dtnotExistRecords.NewRow(); drNotExistRecordsrow["Class_Code"] = dr["Class_Code"].ToString(); drNotExistRecordsrow["term"] = dr["term"].ToString(); drNotExistRecordsrow["FileDate"] = dr["FileDate"].ToString(); dtnotExistRecords.Rows.Add(drNotExistRecordsrow); } } } grd_NonExistFolder.DataSource = dtnotExistRecords; } }
protected void btn_ShowCount_Click(object sender, EventArgs e) { AssetBusiness asset = new AssetBusiness(); DataTable dtAsset = new DataTable(); DataRow dtnotExistRecordsrow = dtnotExistRecords.NewRow(); if (dtnotExistFolder.Rows.Count > 0) { dtnotExistFolder.Clear(); } if (dtnotExistRecords.Rows.Count > 0) { dtnotExistRecords.Clear(); } DataRow dtnotExistFolderRow = dtnotExistFolder.NewRow(); int notExist = 0, mp3Count = 0, ExistFolder = 0, NotExistmp3Count = 0, mp3Length = 0, LowLengthCorrect = 0; dtAsset = asset.GetFileCount(date_input_1.Value.ToString(), date_input_2.Value.ToString(), rcb_Term.SelectedValue); lblAllCount.Text = dtAsset.Rows.Count.ToString(); for (int i = 0; i < dtAsset.Rows.Count; i++) { string d = dtAsset.Rows[i]["FileDate"].ToString().Replace('/', '-'); string path = Server.MapPath("../content/" + dtAsset.Rows[i]["Term"].ToString() + "/" + dtAsset.Rows[i]["Class_Code"].ToString() + "/" + d); if (Directory.Exists(path) == false) { notExist++; dtnotExistFolderRow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString(); dtnotExistFolderRow["Session"] = dtAsset.Rows[i]["Session"].ToString(); dtnotExistFolderRow["FileDate"] = dtAsset.Rows[i]["FileDate"].ToString(); dtnotExistFolder.Rows.Add(dtnotExistFolderRow); dtnotExistFolderRow = dtnotExistFolder.NewRow(); } else { ExistFolder++; DirectoryInfo di = new DirectoryInfo(path); // Get a reference to each file in that directory. FileInfo[] fiArr = di.GetFiles("mp3.zip"); if (fiArr.Count() > 0) { foreach (FileInfo f in fiArr) { if (f.Length > 1000000) { mp3Count++; } else { if (!bool.Parse(dtAsset.Rows[i]["IsArchive"].ToString())) { mp3Length++; dtnotExistRecordsrow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString(); dtnotExistRecordsrow["Session"] = dtAsset.Rows[i]["Session"].ToString(); dtnotExistRecordsrow["FileDate"] = dtAsset.Rows[i]["FileDate"].ToString(); dtnotExistRecordsrow["LowLength"] = "1"; dtnotExistRecords.Rows.Add(dtnotExistRecordsrow); dtnotExistRecordsrow = dtnotExistRecords.NewRow(); } else { mp3Count++; LowLengthCorrect++; } } } } else { NotExistmp3Count++; dtnotExistRecordsrow["Class_Code"] = dtAsset.Rows[i]["Class_Code"].ToString(); dtnotExistRecordsrow["Session"] = dtAsset.Rows[i]["Session"].ToString(); dtnotExistRecordsrow["FileDate"] = dtAsset.Rows[i]["FileDate"].ToString(); dtnotExistRecordsrow["LowLength"] = "0"; dtnotExistRecords.Rows.Add(dtnotExistRecordsrow); dtnotExistRecordsrow = dtnotExistRecords.NewRow(); } } } lblExistFolder.Text = ExistFolder.ToString(); lblRecordCount.Text = mp3Count.ToString(); lblNotExistFolder.Text = notExist.ToString(); lblNotExistRecords.Text = NotExistmp3Count.ToString(); lbl_Mp3Length.Text = mp3Length.ToString(); lbl_LowLengthCorrect.Text = LowLengthCorrect.ToString(); grd_Records.DataSource = dtnotExistRecords; grd_Records.DataBind(); Grd_Folders.DataSource = dtnotExistFolder; Grd_Folders.DataBind(); }