Exemplo n.º 1
0
        public IActionResult submitDataNote(string[] note, string[] path, string[] filename, string[] fundcode, string usersub)
        {
            Console.WriteLine("************* POST DATA **************");
            List <FileDirModel> dataFile = new List <FileDirModel>();

            for (int i = 0; i < path.Length; i++)
            {
                FileDirModel map = new FileDirModel();
                map.path     = path[i];
                map.fileName = filename[i];
                map.fundcode = fundcode[i];
                map.note     = note[i];

                dataFile.Add(map);
            }

            try {
                using (var package = new ExcelPackage())
                {
                    Debug.WriteLine(" dataFile :" + dataFile.Count);
                    Debug.WriteLine(" fund :" + fund.Count);
                    var workbook = package.Workbook;
                    foreach (fundcode fc in getFund())
                    {
                        createExcel(package, dataFile, fc.fundecode);
                    }
                    DateTime currDate = DateTime.Now;
                    string   dateNow  = currDate.Year + "-" + currDate.Month + "-" + currDate.Day;
                    FileInfo newFile  = new FileInfo(@"\\192.168.96.7\Datawarehouse\Report\Upload_Wait_Report_" + dateNow + "___" + usersub + ".xlsx");

                    file_name         = "Upload_Wait_Report_" + dateNow + "___" + usersub + ".xlsx";
                    ViewBag.file_name = file_name;
                    package.SaveAs(newFile);
                }
                return(RedirectToAction("Index", "Home", new { name = file_name }));
            } catch (Exception ex) {
                return(RedirectToAction("Index", "Home", new { name = ex }));
            }

            //file_name = "Upload Wait Report.xlsx";
        }
Exemplo n.º 2
0
        public List <FileDirModel> GetDirInWait(DirectoryInfo rootDir, string fundcode)
        {
            DirectoryInfo[] sub2 = rootDir.GetDirectories("*.*");
            if (sub2.Length > 0)
            {
                foreach (DirectoryInfo sb2 in sub2)
                {
                    // Debug.WriteLine("==================" + sb2.FullName+"===============" );

                    DirectoryInfo[] sub3 = sb2.GetDirectories("*.*");
                    if (sub3.Length > 0)
                    {
                        FileInfo[] getFileW = sb2.GetFiles("*.*");


                        int i = 0;
                        foreach (FileInfo files2 in getFileW)
                        {
                            FileDirModel mapping = new FileDirModel();
                            if (i == 0)
                            {
                                mapping.path     = sb2.FullName;
                                mapping.fileName = files2.Name;
                                mapping.fundcode = fundcode;
                            }
                            else
                            {
                                mapping.path     = "";
                                mapping.fileName = files2.Name;
                                mapping.fundcode = fundcode;
                            }
                            i++;
                            // Debug.WriteLine("************************* " + files2.Name);
                            ListFile.Add(mapping);
                        }


                        GetDirInWait(sb2, fundcode);
                    }
                    else
                    {
                        FileInfo[] getFileW = sb2.GetFiles("*.*");
                        int        i        = 0;
                        foreach (FileInfo files2 in getFileW)
                        {
                            FileDirModel mapping = new FileDirModel();
                            //Debug.WriteLine("************************* " + files2.Name);

                            if (i == 0)
                            {
                                mapping.path     = sb2.FullName;
                                mapping.fileName = files2.Name;
                                mapping.fundcode = fundcode;
                            }
                            else
                            {
                                mapping.path     = "";
                                mapping.fileName = files2.Name;
                                mapping.fundcode = fundcode;
                            }
                            i++;
                            ListFile.Add(mapping);
                        }
                    }
                }
            }
            else
            {
                FileDirModel mapping = new FileDirModel();

                FileInfo[] getFileW = rootDir.GetFiles("*.*");
                int        i        = 0;
                foreach (FileInfo files2 in getFileW)
                {
                    if (i == 0)
                    {
                        mapping.path     = rootDir.FullName;
                        mapping.fileName = files2.Name;
                        mapping.fundcode = fundcode;
                    }
                    else
                    {
                        mapping.path     = " ";
                        mapping.fileName = files2.Name;
                        mapping.fundcode = fundcode;
                    }

                    //  Debug.WriteLine("************************* " + files2.Name);
                    i++;
                }

                ListFile.Add(mapping);
            }

            return(ListFile);
        }
Exemplo n.º 3
0
        public IActionResult Index(string name)
        {
            ViewBag.title = "Datawarehouse";

            string filePath = @"//192.168.96.7/Datawarehouse/";

            Debug.WriteLine("Path : " + filePath);
            DirectoryInfo dirInfo = new DirectoryInfo(filePath);
            DirectoryInfo rootdir = dirInfo.Root;

            DirectoryInfo[] dirInfos = rootdir.GetDirectories("*.*");
            Debug.WriteLine("***************** Directory **************");
            foreach (DirectoryInfo d in dirInfos)
            {
                if (d.Name.Length < 6)
                {
                    //Debug.WriteLine("Direc Name : " + d.Name);

                    DirectoryInfo[] subDir = d.GetDirectories("*.*");
                    foreach (DirectoryInfo sb in subDir)
                    {
                        if (sb.Name == "Wait" || sb.Name == "wait")
                        {
                            //  Debug.WriteLine("---------------- " + sb.Name);
                            fundcode fc = new fundcode();
                            fc.fundecode = d.Name;

                            fund.Add(fc);
                            DirectoryInfo[] sub2 = sb.GetDirectories("*.*");
                            if (sub2.Length > 0)
                            {
                                GetDirInWait(sb, d.Name);
                            }
                            else
                            {
                                FileInfo[] getFileW = sb.GetFiles("*.*");

                                int i = 0;
                                foreach (FileInfo files2 in getFileW)
                                {
                                    FileDirModel map = new FileDirModel();
                                    if (i == 0)
                                    {
                                        map.path     = sb.FullName;
                                        map.fileName = files2.Name;
                                        map.fundcode = d.Name;
                                    }
                                    else
                                    {
                                        map.path     = "";
                                        map.fileName = files2.Name;
                                        map.fundcode = d.Name;
                                    }
                                    i++;
                                    ListFile.Add(map);
                                    //Debug.WriteLine("************************* " + files2.Name);
                                }
                            }
                        }
                    }
                }
            }
            file_name         = name;
            ViewBag.file_name = file_name;
            ViewBag.fund      = fund;
            ViewBag.listfile  = ListFile;


            return(View());
        }