Exemplo n.º 1
0
        public IList <MyFileInfo> GetAllFilesFromDirectory(string Dir, string patern)
        {
            Regex rgx = new Regex(patern);
            IList <MyFileInfo> result = new List <MyFileInfo>();

            //tablica sciezek dostepu do kolejnych plikow z tego folderu
            var listFiles = Directory.GetFiles(Dir);

            //przechowuje pojedynczy rekord z tablicy fileDirArray

            //metoda szukająca właściwego ciągu znaków
            foreach (var path in listFiles)
            {
                if (rgx.IsMatch(path))
                {
                    MyFileInfo myFileInfo = new MyFileInfo();
                    myFileInfo.FilePath = path;
                    myFileInfo.FileName = Path.GetFileName(path);

                    myFileInfo.CreateData  = File.GetCreationTime(path);
                    myFileInfo.LastModData = File.GetLastWriteTime(path);

                    result.Add(myFileInfo);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            MyFileInfo myFileInfo = new MyFileInfo();

            try
            {
                int row = e.RowIndex;
                myFileInfo.FileId         = Convert.ToInt32(dataGridView1["FileId", row].Value);
                myFileInfo.FileName       = dataGridView1["FileName", row].Value.ToString();
                myFileInfo.Directory      = dataGridView1["Directory", row].Value.ToString();
                myFileInfo.DirectoryName  = dataGridView1["DirectoryName", row].Value.ToString();
                myFileInfo.Extension      = dataGridView1["Extension", row].Value.ToString();
                myFileInfo.LastAccessTime = dataGridView1["LastAccessTime", row].Value.ToString();
                myFileInfo.LastWriteTime  = dataGridView1["LastWriteTime", row].Value.ToString();
                myFileInfo.Length         = Convert.ToInt32(dataGridView1["length", row].Value);
                myFileInfo.Mark           = dataGridView1["mark", row].Value.ToString();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            if (FileDAL.Update(myFileInfo) > 0)
            {
                //MessageBox.Show("Seccess");
                ;
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index(IFormFile files)
        {
            /*
             * Console.WriteLine(files.Length);
             * Console.WriteLine(files.FileName);
             */

            var filePath = Path.GetTempFileName();

            using (var stream = System.IO.File.Create(filePath))
            {
                await files.CopyToAsync(stream);
            }
            Console.WriteLine(filePath);

            /*
             * StreamReader streamReader = new StreamReader(filePath);
             * Console.WriteLine(streamReader.ReadLine());
             */

            MyFileInfo fileInfo   = new MyFileInfo(filePath, files.FileName, files.Length);
            JsonHelper jsonHelper = new JsonHelper();

            jsonHelper.Save(fileInfo);


            return(StatusCode(201));
        }
Exemplo n.º 4
0
        public static int ExecuteInsert_SP(string spName, MyFileInfo fi)
        {
            // using (SqlConnection conn = new SqlConnection(connstr))
            //{
            SqlCommand objCommand = new SqlCommand(spName, conn);

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.Parameters.Add("@fileName", SqlDbType.VarChar, 300).Value      = fi.FileName;
            objCommand.Parameters.Add("@extension", SqlDbType.VarChar, 50).Value      = fi.Extension;
            objCommand.Parameters.Add("@directoryName", SqlDbType.VarChar, 500).Value = fi.DirectoryName;
            objCommand.Parameters.Add("@directory", SqlDbType.VarChar, 500).Value     = fi.Directory;
            objCommand.Parameters.Add("@length", SqlDbType.Float).Value = fi.Length;
            objCommand.Parameters.Add("@lastAccessTime", SqlDbType.VarChar, 50).Value = fi.LastAccessTime;
            objCommand.Parameters.Add("@lastWriteTime", SqlDbType.VarChar, 50).Value  = fi.LastWriteTime;
            objCommand.Parameters.Add("@mark", SqlDbType.Text).Value = fi.Mark;
            conn.Open();
            int i = objCommand.ExecuteNonQuery();

            conn.Close();

            //conn.Dispose();
            return(i);

            //}
        }
Exemplo n.º 5
0
        private static List <MyFileInfo> convertToMyFilesLinq(List <FileInfo> files)
        {
            //not necessary, use Select
            //List<MyFileInfo> myFiles = new List<MyFileInfo>(files.Count);

            //files.ForEach(file =>
            //{
            //    MyFileInfo my = new MyFileInfo();
            //    my.Name = file.Name;
            //    my.Length = file.Length;
            //    my.Created = file.CreationTime;
            //    my.Extension = file.Extension;

            //    myFiles.Add(my);
            //});

            //return myFiles;

            return(files.Select(file =>
            {
                MyFileInfo my = new MyFileInfo();
                my.Name = file.Name;
                my.Length = file.Length;
                my.Created = file.CreationTime;
                my.Extension = file.Extension;

                return my;
            }).ToList());
        }
Exemplo n.º 6
0
    //读子文件
    public Byte[] Read(string DescFileName)
    {
        using (FileStream fileRead = new FileStream("MyFinelFile", FileMode.Open, FileAccess.ReadWrite))
        {
            //fileRead.Seek(8,SeekOrigin.Begin);
            //读多少信息
            MyFileInfo m_fileInfo = Find(DescFileName);
            if (m_fileInfo != null)
            {
                //定位 文件在其中的位置
                long offset = 8 + filecount * 96;                //定义文件头 偏移量
                for (int i = 0; i < m_fileInfo.index; i++)
                {
                    offset += m_fileinfoList[i].Size;
                }
                //定位到偏移量的位置
                fileRead.Seek(offset, SeekOrigin.Begin);
                //创建 缓冲区
                Byte[] temp = new Byte[m_fileInfo.Size];
                fileRead.Read(temp, 0, temp.Length);            //读出数据 然后返回
                return(temp);
            }
        }

        return(null);
    }
Exemplo n.º 7
0
        public static List <MyFileInfo> InsertFiles(string directoryStr)
        {
            String[]  path = Directory.GetFiles(directoryStr, "*", SearchOption.AllDirectories);
            ArrayList fis  = new ArrayList();
            String    lowerCase;

            String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf", ".vob", ".rar", ".mpg", ".mpeg", ".mds", ".jpg", ".bmp", ".jpeg", ".mkv", ".dat", ".tif", ".mp4", "zip", ".mov", ".mpe", ".dat", ".bik", ".asx", ".wvx", ".mpa", ".bt!", ".m4v", ".divx", ".asf", ".nrg", ".ogm", ".mdf", ".md0", ".md1", ".md2", ".md3", ".md4", ".m4v", ".ogv", ".exe", ".rar", ".msi", ".7z", ".r00", ".m2ts" };

            foreach (String p in path)
            {
                FileInfo fileInfo = new FileInfo(p);

                string sub = fileInfo.Extension;
                lowerCase = sub.ToLower();
                Console.WriteLine(fileInfo.Extension);


                if (extensions.Contains(lowerCase))
                {
                    MyFileInfo myFileInfo = new MyFileInfo();
                    myFileInfo.FileName       = fileInfo.Name.Replace("'", "''");
                    myFileInfo.Directory      = fileInfo.Directory.Name;
                    myFileInfo.DirectoryName  = fileInfo.DirectoryName;
                    myFileInfo.Extension      = fileInfo.Extension;
                    myFileInfo.LastAccessTime = fileInfo.LastAccessTime.ToString();
                    myFileInfo.LastWriteTime  = fileInfo.LastWriteTime.ToString();
                    myFileInfo.Length         = (double)((int)(fileInfo.Length / 1024.0 / 1024.0 * 100)) / 100;

                    myFileInfo.Mark = "";
                    fis.Add(myFileInfo);
                }
            }

            return(FileDAL.Insert(fis));
        }
Exemplo n.º 8
0
 public long Size;               //文件 所占大小    public MyFileStream(MyFileInfo info)
 public MyFileStream(MyFileInfo info, FileMode mode, FileAccess access)
 {
     Allpath  = @"D:\C#Project\11-21\11-21\bin\Debug\MyAllLua";
     FileName = info.FileFullName;
     Position = info.Position;
     Size     = info.Size;
     file     = new FileStream(Allpath, mode, access);
 }
Exemplo n.º 9
0
        public static int Update(MyFileInfo fi)
        {
            int    res;
            string sql = "update files set fileName='" + fi.FileName + "',extension='" + fi.Extension + "', directoryName='" + fi.DirectoryName + "',directory='" + fi.Directory + "',length=" + fi.Length + ",lastAccessTime='" + fi.LastAccessTime + "',lastWriteTime='" + fi.LastWriteTime + "',mark='" + fi.Mark + "', vid='" + fi.Vid + "' where fileId=" + fi.FileId;

            Console.WriteLine(sql);
            res = DBHelper.ExecuteSql(sql);
            return(res);
        }
Exemplo n.º 10
0
        private TreeNode AddFileTreeNode(TreeNodeCollection nodes, MyFileInfo file)
        {
            TreeNode tn = new TreeNode(file.Name);

            tn.ImageIndex         = 2;
            tn.SelectedImageIndex = 2;
            tn.Name = file.Name;
            nodes.Add(tn);
            return(tn);
        }
Exemplo n.º 11
0
		/// <summary>
		/// TODO - doesnt seem like we're using this...
		/// </summary>
		public void SetHardcodeResolve(IDictionary<string, string> hardcodes)
		{
			IsHardcodedResolve = true;
			fisBaseDir = new MyFileInfo[hardcodes.Count];
			int i = 0;
			foreach (var kvp in hardcodes)
			{
				fisBaseDir[i++] = new MyFileInfo { FullName = kvp.Key, FileInfo = new FileInfo(kvp.Value) };
			}
		}
Exemplo n.º 12
0
		MyFileInfo[] MyFileInfosFromFileInfos(FileInfo[] fis)
		{
			var myfis = new MyFileInfo[fis.Length];
			for (int i = 0; i < fis.Length; i++)
			{
				myfis[i].FileInfo = fis[i];
				myfis[i].FullName = fis[i].FullName;
			}
			return myfis;
		}
Exemplo n.º 13
0
            public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo)
            {
                if (Path.GetExtension(subpath) != string.Empty)
                {
                    fileInfo = new MyFileInfo(0);
                    return true;
                }

                fileInfo = null;
                return false;
            }
        private MyFileInfo[] MyFileInfosFromFileInfos(FileInfo[] fis)
        {
            var myfis = new MyFileInfo[fis.Length];

            for (int i = 0; i < fis.Length; i++)
            {
                myfis[i].FileInfo = fis[i];
                myfis[i].FullName = fis[i].FullName;
            }
            return(myfis);
        }
Exemplo n.º 15
0
            public bool TryGetFileInfo(string subpath, out IFileInfo fileInfo)
            {
                if (Path.GetExtension(subpath) != string.Empty)
                {
                    fileInfo = new MyFileInfo(0);
                    return(true);
                }

                fileInfo = null;
                return(false);
            }
Exemplo n.º 16
0
        public static List <MyFileInfo> InsertFiles(string directoryStr)
        {
            String[]  path = Directory.GetFiles(directoryStr, "*", SearchOption.TopDirectoryOnly);
            ArrayList fis  = new ArrayList();
            String    lowerCase;

            //String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf",".mpg","mpeg" };
            String[] extensions = { ".avi", ".wmv", ".rmvb", ".iso", ".rm", ".afs", ".flv", ".pdf", ".vob", ".rar", ".mpg", ".mpeg", ".mds", ".jpg", ".bmp", ".jpeg", ".mkv", ".dat", ".tif", ".mp4", "zip", ".mov", ".mpe", ".dat", ".bik", ".asx", ".wvx", ".mpa", ".bt!", "m4v", ".nrg", ".ogm", ".mdf" };

            foreach (String p in path)
            {
                FileInfo fileInfo = new FileInfo(p);

                //Console.WriteLine(f);
                //Console.WriteLine(f.LastIndexOf("."));
                string sub = fileInfo.Extension;
                lowerCase = sub.ToLower();
                Console.WriteLine(fileInfo.Extension);

                //if (sub == "avi" || sub=="wmv"||sub=="rmvb"||sub=="iso"||sub=="rm"||sub=="afs"||sub=="flv"||sub.Contains("md")||sub=="pdf")
                if (extensions.Contains(lowerCase))
                {
                    //Console.WriteLine(f.Substring(f.LastIndexOf(".")));
                    //Console.WriteLine(p);
                    //listStr += p + "\n";
                    //fis.Add(myFileInfo);
                    MyFileInfo myFileInfo = new MyFileInfo();
                    myFileInfo.FileName       = fileInfo.Name.Replace("'", "''");
                    myFileInfo.Directory      = fileInfo.Directory.Name;
                    myFileInfo.DirectoryName  = fileInfo.DirectoryName;
                    myFileInfo.Extension      = fileInfo.Extension;
                    myFileInfo.LastAccessTime = fileInfo.LastAccessTime.ToString();
                    myFileInfo.LastWriteTime  = fileInfo.LastWriteTime.ToString();
                    myFileInfo.Length         = (double)((int)(fileInfo.Length / 1024.0 / 1024.0 * 100)) / 100;

                    myFileInfo.Mark = "";
                    fis.Add(myFileInfo);
                }
            }

            StreamReader sr      = new StreamReader(@"D:\pages\02-2\25.htm");
            string       content = sr.ReadToEnd();

            sr.Close();
            string content1 = content.Split(new string[] { "<div class=\"image\">", "</span></div>" }, StringSplitOptions.RemoveEmptyEntries)[1];

            Console.WriteLine(content1);



            return(FileDAL.Insert(fis));
        }
        /// <summary>
        /// TODO - doesnt seem like we're using this...
        /// </summary>
        public void SetHardcodeResolve(IDictionary <string, string> hardcodes)
        {
            IsHardcodedResolve = true;
            fisBaseDir         = new MyFileInfo[hardcodes.Count];
            int i = 0;

            foreach (var kvp in hardcodes)
            {
                fisBaseDir[i++] = new MyFileInfo {
                    FullName = kvp.Key, FileInfo = new FileInfo(kvp.Value)
                };
            }
        }
Exemplo n.º 18
0
        public void addMyFileInfo(MyFileInfo myFileInfo)
        {
            // 新增数据的sql
            sql = "insert into TB_files values ('" + myFileInfo.seq
                  + "', '" + myFileInfo.file_name
                  + "', '" + myFileInfo.file_parent_name
                  + "', '" + myFileInfo.create_date
                  + "')";

            SqlCommand sc = DBTools.getSqlCommand(sql);

            sc = DBTools.getSqlCommand(sql);
            sc.ExecuteNonQuery();
        }
Exemplo n.º 19
0
        private void moveFile(MyFileInfo myFileInfo)
        {
            if (!Directory.Exists(myFileInfo.DirectoryName[0] + ":\\duplicate\\"))
            {
                Directory.CreateDirectory(myFileInfo.DirectoryName[0] + ":\\duplicate\\");
            }
            string newPath = Path.Combine(myFileInfo.DirectoryName[0] + ":\\duplicate\\", myFileInfo.FileName);

            while (File.Exists(newPath))
            {
                newPath += "1";
            }

            File.Move(Path.Combine(myFileInfo.DirectoryName, myFileInfo.FileName), newPath);
        }
Exemplo n.º 20
0
        private void GetInfo(string path)
        {
            // get file info
            FileInfo   fi         = new FileInfo(Server.MapPath(path));
            MyFileInfo myFileInfo = new MyFileInfo()
            {
                FileName = fi.Name,
                FileType = fi.Extension,
                FileSize = (fi.Length / long.Parse("1024")).ToString(),
                Error    = "null"
            };

            Response.Write(GetJson(myFileInfo));
            Response.End();
        }
Exemplo n.º 21
0
        private static bool Check(MyFileInfo fi)
        {
            bool   flag = false;
            string sql  = "select * from files where [fileName] = '" + fi.FileName + "' and [length]= " + fi.Length;
            //string sql = "select * from files where [fileName] = '" + fi.FileName + "' or [mark]='" + fi.Mark+"'";
            SqlDataReader sdr = DBHelper.SearchSql(sql);

            if (sdr.Read())
            {
                flag = true;
            }
            sdr.Close();
            sdr.Dispose();
            DBHelper.conn.Close();
            return(flag);
        }
Exemplo n.º 22
0
        private static List <MyFileInfo> convertToMyFilesPlain(List <FileInfo> files)
        {
            List <MyFileInfo> myFiles = new List <MyFileInfo>(files.Count);

            foreach (var file in files)
            {
                MyFileInfo my = new MyFileInfo();
                my.Name      = file.Name;
                my.Length    = file.Length;
                my.Created   = file.CreationTime;
                my.Extension = file.Extension;

                myFiles.Add(my);
            }

            return(myFiles);
        }
Exemplo n.º 23
0
        //public static bool Validate(MyFileInfo fi)
        //{
        //    if (fi.Directory.Name != fi.Directory.Root.Name)
        //        return false;
        //    else
        //        return true;
        //}

        //public static bool Check(MyFileInfo fi)
        //{
        //    bool flag=true;
        //    string name=fi.Name.Substring(0,fi.Name.LastIndexOf("."));
        //    string directory=fi.Directory.Name;
        //    Regex   r1=new   Regex("^[0-9]+$");
        //    Match   m1=r1.Match(name);
        //    Console.WriteLine(fi.Extension);


        //    if (!(name.Length < 4 && m1.Success))
        //    {
        //        if (name.Length > 7)
        //            name = name.Substring(name.Length - 6);
        //        else if (name.Length > 6)
        //            name = name.Substring(name.Length - 5);


        //        if (directory.Length > 7)
        //            directory = directory.Substring(name.Length - 6);
        //        else if (directory.Length > 6)
        //            directory = directory.Substring(name.Length - 5);
        //        string sql = "select * from files where [fileName] like '%" + name + "%' or [directoryName] like '%"+directory+"%' or [fileName] like '%"+directory+"%' or [directoryName] like '%"+name+"'";

        //        Console.WriteLine(sql);
        //        if (DBHelper.ExecuteSql(sql) <= 0)
        //            flag = false;

        //    }
        //    return flag;
        //}

        public static List <MyFileInfo> selectMyFileInfo(string sortBy)
        {
            string sql = "";

            if (sortBy != "")
            {
                sql = "select * from [cdfile],[files] where [cdfile].fileId=[files].fileId order by " + sortBy;

                if (sortBy == "FileId")
                {
                    sql = "select * from [cdfile],[files] where [cdfile].fileId=[files].fileId order by files." + sortBy;
                }
            }
            else
            {
                sql = "select * from  [files] where  ([files].length>=400 or [files].fileName like '%.mds')";
            }
            List <MyFileInfo> MyFileInfoList = new List <MyFileInfo>();

            SqlDataReader sdr = DBHelper.SearchSql(sql);

            while (sdr.Read())
            {
                //FileInfo fileInfo=new FileInfo(sdr["directory"].ToString());

                MyFileInfo myFileInfo = new MyFileInfo();
                myFileInfo.Directory      = sdr["directory"].ToString();
                myFileInfo.DirectoryName  = sdr["directoryName"].ToString();
                myFileInfo.FileName       = sdr["fileName"].ToString();
                myFileInfo.Extension      = sdr["extension"].ToString();
                myFileInfo.LastAccessTime = sdr["lastAccessTime"].ToString();
                myFileInfo.LastWriteTime  = sdr["lastWriteTime"].ToString();
                myFileInfo.FileId         = Convert.ToInt32(sdr["fileId"]);
                myFileInfo.Length         = Convert.ToDouble(sdr["length"]);
                myFileInfo.Mark           = sdr["mark"].ToString();
                myFileInfo.Vid            = sdr["vid"].ToString();
                MyFileInfoList.Add(myFileInfo);
            }
            sdr.Close();
            sdr.Dispose();
            DBHelper.conn.Close();
            //DBHelper.conn.Dispose();
            return(MyFileInfoList);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 添加到数据库
        /// </summary>
        private void addToDB()
        {
            string     format           = "00000;-#;(0)";
            int        count            = 0;
            string     seq              = "";
            string     file_name        = "";
            string     file_parent_name = "";
            string     create_date      = AutoCreateTool.getNowDate("yyyyMMdd");
            MyFileInfo myFileInfo       = null;

            foreach (var file in files)
            {
                seq              = AutoCreateTool.getSeq() + (++count).ToString(format);
                file_name        = file.Key;
                file_parent_name = file.Value;
                myFileInfo       = new MyFileInfo(seq, file_name, file_parent_name, create_date);
                myFileInfoService.addMyFileInfo(myFileInfo);
            }
        }
Exemplo n.º 25
0
        public IActionResult Index()
        {
            int gpu    = 0;
            int cpu    = 0;
            int cl_mem = 0;

            JsonHelper     jsonHelper     = new JsonHelper();
            AnalyzerHelper analyzerHelper = new AnalyzerHelper();

            MyFileInfo myfileInfo = jsonHelper.Read();

            FileInfo fileInfo = new FileInfo(myfileInfo.path);

            if (myfileInfo.size != fileInfo.Length)
            {
                Console.WriteLine(fileInfo.Length.ToString() + myfileInfo.size.ToString());
                return(StatusCode(500));
            }

            StreamReader streamReader = new StreamReader(myfileInfo.path);

            //general searches
            string wholeText = streamReader.ReadToEnd();

            gpu += analyzerHelper.SearchFor(wholeText, "CL_DEVICE_TYPE_GPU");
            cpu += analyzerHelper.SearchFor(wholeText, "CL_DEVICE_TYPE_CPU");

            //reset the streamreader
            streamReader.BaseStream.Position = 0;
            streamReader.DiscardBufferedData();
            string line;
            int    i = 0;

            while ((line = streamReader.ReadLine()) != null)
            {
                Console.WriteLine(line);
                cl_mem += analyzerHelper.SearchFor(line, "cl_mem");
                i++;
            }

            return(StatusCode(200));
        }
Exemplo n.º 26
0
        private static List <MyFileInfo> IntSort(List <MyFileInfo> oldList, string sortBy)
        {
            List <MyFileInfo> newList       = new List <MyFileInfo>();
            MyFileInfo        minMyFileInfo = oldList[0];

            while (oldList.Count > 1)
            {
                for (int i = 0; i < oldList.Count - 1; i++)
                {
                    //Console.WriteLine("for");
                    if (Convert.ToInt32(minMyFileInfo.GetType().GetProperty(sortBy).GetValue(minMyFileInfo, null)) > Convert.ToInt32(oldList[i + 1].GetType().GetProperty(sortBy).GetValue(oldList[i + 1], null)))
                    {
                        minMyFileInfo = oldList[i + 1];
                    }
                }
                newList.Add(minMyFileInfo);
                oldList.Remove(minMyFileInfo);
                minMyFileInfo = oldList[0];
            }
            newList.Add(oldList[0]);
            return(newList);
        }
Exemplo n.º 27
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            MyFileInfo myFileInfo = new MyFileInfo();

            try
            {
                int row = e.RowIndex;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            if (FileDAL.Update(myFileInfo) > 0)
            {
                //MessageBox.Show("Seccess");
                ;
            }
            else
            {
                MessageBox.Show("Fail");
            }
        }
Exemplo n.º 28
0
        public void test()
        {
            //string s = "中文にほんニホンABC심판";
            //foreach (char c in s)

            //{

            //    if (c >= 0x4E00 && c <= 0x9FA5) Console.WriteLine(c + "是汉字");

            //    else if (c >= 0x3040 && c <= 0x309F) Console.WriteLine(c + "是平假名");

            //    else if (c >= 0x30A0 && c <= 0x30FF) Console.WriteLine(c + "是片假名");

            //    else if(c>= 0x3100&&c<= 0x31BF||c>0xAC00 && c<=0xD7A3) Console.WriteLine(c + "是韩文");

            //}
            List <MyFileInfo> MyFileInfoList = new List <MyFileInfo>();
            SqlDataReader     sdr            = DBHelper.SearchSql("select * from files where length>=100");

            while (sdr.Read())
            {
                MyFileInfo myFileInfo = new MyFileInfo();
                myFileInfo.Directory      = sdr["directory"].ToString();
                myFileInfo.DirectoryName  = sdr["directoryName"].ToString();
                myFileInfo.FileName       = sdr["fileName"].ToString();
                myFileInfo.Extension      = sdr["extension"].ToString();
                myFileInfo.LastAccessTime = sdr["lastAccessTime"].ToString();
                myFileInfo.LastWriteTime  = sdr["lastWriteTime"].ToString();
                myFileInfo.FileId         = Convert.ToInt32(sdr["fileId"]);
                myFileInfo.Length         = Convert.ToDouble(sdr["length"]);
                myFileInfo.Mark           = sdr["mark"].ToString();
                MyFileInfoList.Add(myFileInfo);
            }
            //foreach(MyFileInfo myFileInfo in MyFileInfoList)
            //{
            //    if()
            //}
        }
Exemplo n.º 29
0
        private static void UpdateRefreshUi(int jobId = 0)
        {
            Random ran     = new Random();
            int    count   = 1;
            string sukebei = JavINIClass.IniReadValue("Mag", "sukebei");

            Parallel.ForEach(models, new ParallelOptions {
                MaxDegreeOfParallelism = 10
            }, rm =>
            {
                RemoteScanMag entity = new RemoteScanMag();
                entity.JobId         = jobId;

                Console.Write("处理 --> " + rm.Name + " " + count++ + "/" + models.Count);

                var token = ScanDataBaseManager.GetToken();

                var htmlResult = HtmlManager.GetHtmlContentViaUrl($"http://www.cainqs.com:8087/avapi/EverythingSearch?token={token.Token}&content=" + rm.Id);

                Model.ScanModels.EverythingResult searchResult = new Model.ScanModels.EverythingResult();
                List <MyFileInfo> matchFiles = new List <MyFileInfo>();

                if (htmlResult.Success)
                {
                    searchResult = JsonConvert.DeserializeObject <Model.ScanModels.EverythingResult>(htmlResult.Content);

                    if (searchResult != null && searchResult.results != null)
                    {
                        foreach (var result in searchResult.results)
                        {
                            var temp = new MyFileInfo();

                            if (result.location == "本地")
                            {
                                temp.Length   = long.Parse(result.size);
                                temp.FullName = result.path + "\\" + result.name;
                            }
                            else
                            {
                                temp.Length   = long.Parse(result.size);
                                temp.FullName = "网盘" + long.Parse(result.size);
                            }

                            matchFiles.Add(temp);
                        }
                    }
                }

                List <SeedMagnetSearchModel> list = new List <SeedMagnetSearchModel>();

                if (sukebei == "pro" || sukebei == "si")
                {
                    list = MagService.SearchSukebei(id: rm.Id, web: sukebei);
                }
                else
                {
                    list = MagService.SearchJavBus(rm.Id, null);
                }

                if (list != null && list.Count > 0)
                {
                    if (matchFiles.Count > 0)
                    {
                        var biggestFile     = matchFiles.FirstOrDefault(x => x.Length == matchFiles.Max(y => y.Length));
                        entity.SearchStatus = 2;
                        entity.MatchFile    = biggestFile.FullName;
                    }
                    else
                    {
                        entity.SearchStatus = 1;
                    }

                    foreach (var seed in list)
                    {
                        entity.AvId     = rm.Id;
                        entity.AvName   = FileUtility.ReplaceInvalidChar(rm.Name);
                        entity.AvUrl    = rm.Url;
                        entity.MagDate  = seed.Date;
                        entity.MagSize  = seed.Size;
                        entity.MagTitle = FileUtility.ReplaceInvalidChar(seed.Title);
                        entity.MagUrl   = seed.MagUrl;

                        try
                        {
                            if (entity.MagTitle.Contains(rm.Id) || entity.MagTitle.Contains(rm.Id.Replace("-", "")))
                            {
                                ScanDataBaseManager.InsertRemoteScanMag(entity);
                            }
                        }
                        catch (Exception ee)
                        {
                            entity.MatchFile    = "";
                            entity.SearchStatus = 1;
                            ScanDataBaseManager.InsertRemoteScanMag(entity);
                        }
                    }
                }
                else
                {
                    Console.Write(" 没搜到");
                    entity.SearchStatus = 0;
                }

                Console.WriteLine();
            });
        }
Exemplo n.º 30
0
        private void GetFileList(string dauvao)// lay danh sach file
        {
            try
            {
                string[] filePaths = Directory.GetFiles(dauvao);

                // image list

                // imageList1.ColorDepth = ColorDepth.Depth32Bit; //todo
                //imageList1.ImageSize = new Size(16, 16);//todo
                //listviewFile.Invoke(new MethodInvoker(() =>
                //{
                //    listviewFile.SmallImageList = imageList1;
                //}));

                var items = new List <MyFileInfo>();
                // tongSofile += filePaths.Length;
                foreach (string filename in filePaths)
                {
                    if (chkKeepFile.IsChecked == false)
                    {
                        // Set a default icon for the file.
                        // System.Drawing.Icon iconForFile = SystemIcons.WinLogo;
                        FileInfo info       = new FileInfo(filename);
                        var      myFileInfo = new MyFileInfo()
                        {
                            OldName       = System.IO.Path.GetFileName(filename),
                            NewName       = "",
                            Path          = filename,
                            LastWriteTime = info.LastWriteTime.ToString("yyyy-MM-dd"),
                        };



                        //listviewFile.Invoke(new MethodInvoker(() =>
                        //{
                        //    listviewFile.Items.Add(item);
                        //    sofile += 1;
                        //    lbFileNumber.Text = String.Format("Đã load {0} file", sofile);
                        //}));
                        items.Add(myFileInfo);
                    }
                }

                string[] _thuMuccon = Directory.GetDirectories(dauvao);
                foreach (string thumucconcon in _thuMuccon)
                {
                    if (chkKeepFolder.IsChecked == false)
                    {
                        FileInfo info       = new FileInfo(thumucconcon);
                        var      myFileInfo = new MyFileInfo()
                        {
                            OldName       = System.IO.Path.GetFileName(thumucconcon),
                            NewName       = "",
                            Path          = thumucconcon,
                            LastWriteTime = info.LastWriteTime.ToString("yyyy-MM-dd"),
                        };
                        items.Add(myFileInfo);
                    }
                    if (chkIncludeSubfolder.IsChecked == true)
                    {
                        GetFileList(thumucconcon);
                    }
                }
                listviewFile.ItemsSource = items;
                sofile += items.Count;
                lbFileNumber.Content = String.Format("Đã load {0} file", sofile);
            }
            catch
            {
                // ignored
            }
            //return tongSofile;
        }
Exemplo n.º 31
0
        public void Save(MyFileInfo myfile)
        {
            string jsonString = JsonSerializer.Serialize(myfile);

            File.WriteAllText("FileInfo.json", jsonString);
        }
Exemplo n.º 32
0
        public static void UpdateVid(MyFileInfo fi)
        {
            string sql = "update files set vid='" + fi.Vid + "' where fileId=" + fi.FileId;

            DBHelper.ExecuteSql(sql);
        }
Exemplo n.º 33
0
 public void addMyFileInfo(MyFileInfo myFileInfo)
 {
     myFileInfoDao.addMyFileInfo(myFileInfo);
 }