Пример #1
0
        private void bindingData()
        {
            job_info jobInfo = new job_info();

            jobInfo.sample_id = this.SampleID;
            searchResult      = jobInfo.SearchData();
            gvJob.DataSource  = searchResult;
            gvJob.DataBind();
        }
Пример #2
0
        private void bindingData()
        {
            job_info jobInfo = new job_info();

            jobInfo.sample_id = this.SampleID;
            searchResult      = jobInfo.SearchData();
            gvJob.DataSource  = searchResult;
            gvJob.DataBind();

            //Show file.
            try
            {
                job_info jInfo = new job_info();
                jInfo = jInfo.SelectByID(this.jobSample.job_id);
                ///


                String rootPath    = Configurations.PATH_SOURCE.Replace("{0}\\{1}\\{2}\\{3}\\{4}", "");
                String correctPath = String.Empty;

                for (int y = DateTime.Now.Year; y > DateTime.Now.Year - 2; y--)
                {
                    for (int m = 1; m <= 12; m++)
                    {
                        for (int dd = 1; dd <= DateTime.DaysInMonth(y, m); dd++)
                        {
                            String checkPath = String.Format("{0}{1}\\{2}\\{3}\\{4}", rootPath, y, m.ToString("00"), dd.ToString("00"), this.jobSample.job_number);
                            if (Directory.Exists(checkPath))
                            {
                                correctPath = String.Format(Configurations.PATH_SOURCE, y, m.ToString("00"), dd.ToString("00"), this.jobSample.job_number, String.Empty);
                                break;
                            }
                        }
                    }
                }

                List <FileList> listOfFile = new List <FileList>();
                //String year = jInfo.create_date.Value.Year.ToString();
                //String month = jInfo.create_date.Value.Month.ToString("00");
                //String day = jInfo.create_date.Value.Day.ToString("00");
                //String job = this.jobSample.job_number;

                DirectoryInfo d             = new DirectoryInfo(correctPath); //Assuming Test is your Folder
                FileInfo[]    Files         = d.GetFiles("*.*");              //Getting Text files
                string        str           = "";
                int           index         = 1;
                List <String> keepExtension = new List <String>();
                keepExtension.Add(".xls");
                keepExtension.Add(".jpg");
                keepExtension.Add(".xlt");
                keepExtension.Add(".csv");

                foreach (FileInfo file in Files)
                {
                    FileList fl = new FileList();
                    fl.order = index;
                    fl.name  = Path.GetFileName(file.FullName);
                    fl.url   = String.Concat(Configurations.HOST, "/uploads/", file.FullName.Replace(rootPath, "").Replace("\\", "/"));
                    //str = str + ", " + file.Name;
                    index++;
                    if (keepExtension.Contains(Path.GetExtension(file.FullName)))
                    {
                        listOfFile.Add(fl);
                    }
                }

                gvFileList.DataSource = listOfFile;
                gvFileList.DataBind();
                lbShowListText.Text = "";
            }
            catch (Exception ex)
            {
                lbShowListText.Text = "-";
            }
        }