亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? service.cs

?? Asp.net在線WEB文件管理,以及通過WebService在線搜索文件
?? CS
?? 第 1 頁 / 共 3 頁
字號:
    /// <param name="ticket">加密票</param>
    /// <param name="Name">路徑</param>
    /// <returns>成功返回屬性值,否則返回空</returns>
    [WebMethod(Description = "屬性 需要提供合法票據(jù)")]
    public string Attribute(string ticket, string Name)
    {
        if (IsTicketValid(ticket,false))
        {
            string Results = string.Empty;
            string Path = rootdir + FormsAuthentication.Decrypt(ticket).Name + Name;
            UploadPath = rootdir + FormsAuthentication.Decrypt(ticket).Name;
            DirectoryInfo dirAll = new DirectoryInfo(UploadPath);
            long CurrSize = DirSize(dirAll);
            long AllowSize = CheckSize(FormsAuthentication.Decrypt(ticket).Name);
            Results += "總共:" + FormatFileSize(AllowSize);
            Results += "|已用:" + FormatFileSize(CurrSize);
            Results += "|剩余:" + FormatFileSize(AllowSize - CurrSize);

            Results += "|創(chuàng)建時間:" + File.GetCreationTime(Path);
            Results += "|修改時間:" + File.GetLastWriteTime(Path);

            FileInfo file = new FileInfo(Path);
            DirectoryInfo dir = new DirectoryInfo(Path);
            ///判斷當(dāng)前是否是文件夾
            if ((file.Attributes & FileAttributes.Directory) != 0)
            {
                ///如果是文件夾
                Results += "|大小:" + FormatFileSize(DirSize(dir));
                int DirCount = dir.GetDirectories().GetLength(0);
                int FileCount = dir.GetFiles().GetLength(0);

                Results += "|共有文件夾 " + DirCount.ToString() + " 個|";
                Results += "文件 " + FileCount.ToString() + " 個";
            }
            else
            {
                ///如果是文件
                Results += "|大小:" + FormatFileSize(GetFileSize(ticket, Name));
            }
            return Results;
        }
        else return null;
    }

    /// <summary>
    /// 得到目錄大小
    /// </summary>
    /// <param name="d">目錄名</param>
    /// <returns>大小</returns>
    private static long DirSize(DirectoryInfo d)
    {
        long Size = 0;
        /// 所有文件大小.
        FileInfo[] fis = d.GetFiles();
        foreach (FileInfo fi in fis)
        {
            Size += fi.Length;
        }
        /// 遍歷出當(dāng)前目錄的所有文件夾.
        DirectoryInfo[] dis = d.GetDirectories();
        foreach (DirectoryInfo di in dis)
        {
            Size += DirSize(di);   ///遞歸調(diào)用
        }
        return Size;
    }

    /// <summary>
    /// 文件大小格式化
    /// </summary>
    /// <param name="numBytes">原始大小</param>
    /// <returns>格式化后的大小</returns>
    private static string FormatFileSize(long numBytes)
    {
        string fileSize = "";

        if (numBytes > 1073741824)
            fileSize = String.Format("{0:0.00} GB", (double)numBytes / 1073741824);
        else if (numBytes > 1048576)
            fileSize = String.Format("{0:0.00} MB", (double)numBytes / 1048576);
        else
            fileSize = String.Format("{0:0} KB", (double)numBytes / 1024);

        if (fileSize == "0 KB")
            fileSize = "1 KB";							
        return fileSize;
    }

    #endregion

    #region Upload
    /// <summary>
    /// Append a chunk of bytes to a file.
    /// The client must ensure that all messages are in sequence. 
    /// This method always overwrites any existing file with the same name
    /// </summary>
    /// <param name="FileName">The name of the file that this chunk belongs to, e.g. MyImage.TIFF</param>
    /// <param name="buffer">The byte array</param>
    /// <param name="Offset">The size of the file (if the server reports a different size, an exception is thrown)</param>
    /// <param name="BytesRead">The length of the buffer</param>
    [WebMethod(Description = "上傳文件 需要提供合法票據(jù)")]
    public string AppendChunk(string ticket,string FileName, byte[] buffer, long Offset, int BytesRead,long FullSize)
    {
        if (IsTicketValid(ticket,false))
        {
            object username = FormsAuthentication.Decrypt(ticket).Name;
            UploadPath = rootdir + username + "\\";
            DirectoryInfo dir = new DirectoryInfo(UploadPath);
            long CurrSize = DirSize(dir);
            CurrSize += FullSize;
            long AllowSize = CheckSize(username.ToString());

            if (CurrSize > AllowSize)
                return "Not Enough Space";

            string FilePath = UploadPath + FileName;

            // make sure that the file exists, except in the case where the file already exists and offset=0, i.e. a new upload, in this case create a new file to overwrite the old one.
            bool FileExists = File.Exists(FilePath);
            if (!FileExists || (File.Exists(FilePath) && Offset == 0))
                File.Create(FilePath).Close();
            long FileSize = new FileInfo(FilePath).Length;

            // if the file size is not the same as the offset then something went wrong....
            if (FileSize != Offset)
                CustomSoapException("Transfer Corrupted", String.Format("The file size is {0}, expected {1} bytes", FileSize, Offset));
            else
            {
                // offset matches the filesize, so the chunk is to be inserted at the end of the file.
                using (FileStream fs = new FileStream(FilePath, FileMode.Append))
                    fs.Write(buffer, 0, BytesRead);
            }
            return null;
        }
        else
            return "驗(yàn)證失敗!"; 
    }
    #endregion

    #region Check

    /// <summary>
    /// 檢查空間大小
    /// </summary>
    /// <param name="UserName">用戶名</param>
    /// <returns>空間大小</returns>
    private long CheckSize(string UserName)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select disksize from users where name='" + UserName + "'";
        cmd.Connection = conn;
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        long size = 0;
        if (dr.Read())
        {
            size = Convert.ToInt64(dr["disksize"].ToString());
        }
        size = size * 1024 * 1024;
        return size;
    }

    /// <summary>
    /// 檢查下載速度
    /// </summary>
    /// <param name="UserName">用戶名</param>
    /// <returns>速度</returns>
    private int CheckSpeed(string UserName)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnStr"]);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select speed from users where name='" + UserName + "'";
        cmd.Connection = conn;
        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        int size = 0;
        if (dr.Read())
        {
            size = Convert.ToInt32(dr["speed"].ToString());
        }
        size = size * 1024;
        return size;
    }
    #endregion

    #region File Hashing

    /// <summary>
    /// 文件檢查
    /// </summary>
    /// <param name="ticket">加密票</param>
    /// <param name="FileName">文件名</param>
    /// <returns>hash</returns>
    [WebMethod(Description = "檢查文件 需要提供合法票據(jù)")]
    public string CheckFileHash(string ticket,string FileName)
    {
        if (IsTicketValid(ticket,false))
        {
            object username = FormsAuthentication.Decrypt(ticket).Name;
            UploadPath = rootdir + username + "\\" + FileName;

            SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
            byte[] hash;
            using (FileStream fs = new FileStream(UploadPath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096))
                hash = sha1.ComputeHash(fs);
            return BitConverter.ToString(hash);
        }
        else return null;
    }
    #endregion

    #region DownLoad

    /// <summary>
    /// Download a chunk of a file from the Upload folder on the server. 
    /// </summary>
    /// <param name="FileName">The FileName to download</param>
    /// <param name="Offset">The offset at which to fetch the next chunk</param>
    /// <param name="BufferSize">The size of the chunk</param>
    /// <returns>The chunk as a byte[]</returns>
    [WebMethod(Description = "下載文件 需要提供合法票據(jù)")]
    public byte[] DownloadChunk(string ticket, string FileName, long Offset, int BufferSize)
    {
        if (IsTicketValid(ticket,false))
        {
            object username = FormsAuthentication.Decrypt(ticket).Name;
            UploadPath = rootdir + username + "\\";

            string FilePath = UploadPath + FileName;

            /// check that requested file exists
            if (!File.Exists(FilePath))
                CustomSoapException("File not found", "The file " + FilePath + " does not exist");

            long FileSize = new FileInfo(FilePath).Length;

            /// if the requested Offset is larger than the file, bail out.
            if (Offset > FileSize)
                CustomSoapException ("Invalid Download Offset", String.Format("The file size is {0}, received request for offset {1}", FileSize, Offset));

            int pack = 10240;
            int _speed = CheckSpeed(username.ToString());
            int sleep = (int)Math.Floor(Convert.ToDouble(1000 * pack / _speed)) + 1;

            /// open the file to return the requested chunk as a byte[]
            byte[] TmpBuffer;
            int BytesRead;
            using (FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read))
            {
                fs.Seek(Offset, SeekOrigin.Begin);	// this is relevent during a retry. otherwise, it just seeks to the start
                TmpBuffer = new byte[BufferSize];
                BytesRead = fs.Read(TmpBuffer, 0, BufferSize);	// read the first chunk in the buffer (which is re-used for every chunk)
                System.Threading.Thread.Sleep(sleep);
            }
            if (BytesRead != BufferSize)
            {
                // the last chunk will almost certainly not fill the buffer, so it must be trimmed before returning
                byte[] TrimmedBuffer = new byte[BytesRead];
                Array.Copy(TmpBuffer, TrimmedBuffer, BytesRead);
                return TrimmedBuffer;
            }
            else
                return TmpBuffer;
        }
        else return null;
    }

    /// <summary>
    /// Get the number of bytes in a file in the Upload folder on the server.
    /// The client needs to know this to know when to stop downloading
    /// </summary>
    [WebMethod(Description = "取得文件大小 需要提供合法票據(jù)")]
    public long GetFileSize(string ticket, string FileName)
    {
        if (IsTicketValid(ticket,false))
        {
            object username = FormsAuthentication.Decrypt(ticket).Name;
            UploadPath = rootdir + username;

            string FilePath = UploadPath + FileName;

            /// check that requested file exists
            if (!File.Exists(FilePath))
                CustomSoapException("File not found", "The file " + FilePath + " does not exist");

            return new FileInfo(FilePath).Length;
        }
        else return 0;
    }
    #endregion

    #region Exception Handling
    /// <summary>
    /// Throws a soap exception.  It is formatted in a way that is more readable to the client, after being put through the xml serialisation process
    /// Typed exceptions don't work well across web services, so these exceptions are sent in such a way that the client
    /// can determine the 'name' or type of the exception thrown, and any message that went with it, appended after a : character.
    /// </summary>
    /// <param name="exceptionName"></param>
    /// <param name="message"></param>
    public static void CustomSoapException(string exceptionName, string message)
    {
        throw new System.Web.Services.Protocols.SoapException(exceptionName + ": " + message, new System.Xml.XmlQualifiedName("BufferedUpload"));
    }
    #endregion

    #region Register
    /// <summary>
    /// 用戶注冊
    /// </summary>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美另类一区二区三区| 国产 日韩 欧美大片| 欧美四级电影在线观看| 亚洲成人免费影院| 337p亚洲精品色噜噜噜| 久久超级碰视频| 天天综合色天天| 欧美年轻男男videosbes| 日韩av电影天堂| 亚洲精品在线观看网站| 成人h版在线观看| 亚洲女女做受ⅹxx高潮| 精品视频在线免费| 久久精品久久久精品美女| 国产亚洲欧美一区在线观看| 成人黄色av电影| 亚洲午夜一区二区三区| 日韩一区二区中文字幕| 大胆亚洲人体视频| 亚洲午夜一区二区| 久久精品一二三| 91精品办公室少妇高潮对白| 蜜臀精品一区二区三区在线观看 | 国产 欧美在线| 亚洲六月丁香色婷婷综合久久 | 色婷婷国产精品| 蜜桃91丨九色丨蝌蚪91桃色| 国产欧美日韩中文久久| 在线观看免费亚洲| 另类小说综合欧美亚洲| 亚洲欧洲性图库| 日韩精品一区二区三区三区免费| 成人一区在线观看| 亚洲成人中文在线| 欧美激情艳妇裸体舞| 欧美夫妻性生活| 成人免费看的视频| 欧美体内she精高潮| 国内精品伊人久久久久影院对白| 亚洲男人的天堂在线aⅴ视频| 日韩女优电影在线观看| 色综合天天狠狠| 国产一区久久久| 首页国产欧美日韩丝袜| 一色屋精品亚洲香蕉网站| 日韩久久久精品| 色婷婷亚洲精品| 国产精品18久久久久久久网站| 亚洲一区二区三区四区不卡| 亚洲国产激情av| 久久一二三国产| 宅男在线国产精品| 欧美日韩视频在线一区二区| 成a人片亚洲日本久久| 国产一区二区三区免费看| 首页国产欧美日韩丝袜| 樱花影视一区二区| 国产精品久久国产精麻豆99网站| 日韩色在线观看| 欧美性色欧美a在线播放| 成人综合激情网| 国产高清久久久久| 狠狠狠色丁香婷婷综合激情 | 国产一区二区三区高清播放| 亚洲资源在线观看| 136国产福利精品导航| 国产三级三级三级精品8ⅰ区| 日韩一区二区三区四区| 91精品国产一区二区| 欧美亚洲丝袜传媒另类| 91香蕉视频mp4| 成人国产免费视频| 国产伦理精品不卡| 国产综合色产在线精品| 狠狠色丁香久久婷婷综| 老司机精品视频导航| 久久精品国产精品亚洲综合| 久久精品久久99精品久久| 免费日本视频一区| 麻豆精品视频在线观看视频| 日韩av不卡一区二区| 日韩av中文在线观看| 日韩黄色免费电影| 麻豆成人久久精品二区三区小说| 蜜桃免费网站一区二区三区| 蜜桃精品视频在线| 国产精品一区二区91| 国产精品一区二区在线播放 | 日韩精品一区在线| 亚洲精品一区二区三区99| 久久久久高清精品| 一区二区中文视频| 亚洲电影在线免费观看| 日韩中文字幕1| 久久国产日韩欧美精品| 国产一区二区在线观看免费 | 99在线精品视频| 欧日韩精品视频| 日韩视频一区二区| 中文在线一区二区| 亚洲午夜一区二区| 久久99国产精品久久| 粉嫩绯色av一区二区在线观看 | 91久久线看在观草草青青| 在线不卡中文字幕| 久久综合网色—综合色88| 国产精品卡一卡二卡三| 亚洲一区二区三区美女| 欧美在线三级电影| 日韩亚洲欧美成人一区| 国产三级精品三级在线专区| 一区二区三区在线免费观看| 久久黄色级2电影| 99re这里只有精品6| 67194成人在线观看| 国产欧美日韩三级| 亚洲电影一区二区| 国产成人夜色高潮福利影视| 色系网站成人免费| 欧美不卡一二三| 亚洲自拍偷拍综合| 国产精品一区专区| 欧美日韩一区二区三区四区五区 | 国产欧美日韩视频一区二区| 一区二区三区不卡视频| 国产综合色在线| 欧美丝袜第三区| 国产精品丝袜91| 蜜臀av性久久久久av蜜臀妖精| 国产 日韩 欧美大片| 91精品在线免费| 亚洲裸体xxx| 国产黑丝在线一区二区三区| 7777精品伊人久久久大香线蕉完整版 | 国产午夜精品久久久久久久| 图片区日韩欧美亚洲| zzijzzij亚洲日本少妇熟睡| 日韩精品一区二| 亚洲va欧美va人人爽| 成人h动漫精品一区二| 欧美精品一区二| 午夜久久久久久久久| 色88888久久久久久影院野外| 久久久久久久久岛国免费| 日本一区中文字幕| 欧美性一区二区| 亚洲视频网在线直播| 高清国产一区二区三区| 欧美大片拔萝卜| 五月天中文字幕一区二区| 91激情在线视频| 1024成人网| 99久久精品国产一区二区三区| 久久久久久久久久久久久女国产乱| 丝袜亚洲另类丝袜在线| 在线国产电影不卡| 综合婷婷亚洲小说| 成人福利视频网站| 国产精品色呦呦| 不卡的av中国片| 国产精品视频九色porn| 国产成人在线视频免费播放| 久久影音资源网| 国产成人免费在线视频| 久久久国际精品| 国v精品久久久网| 中文子幕无线码一区tr| eeuss鲁片一区二区三区| 国产欧美综合在线观看第十页| 国产精品综合二区| 久久久久久久av麻豆果冻| 国产麻豆精品视频| 国产日韩亚洲欧美综合| 风流少妇一区二区| 久久久久久久久一| 国产成+人+日韩+欧美+亚洲| 中文字幕av一区二区三区| 99久久精品99国产精品| 亚洲精品国产成人久久av盗摄| 色婷婷av一区二区三区软件| 高清不卡在线观看av| 国产精品久久777777| 色综合久久综合网97色综合 | 国产欧美精品在线观看| www.亚洲免费av| 一区二区三区在线视频播放| 欧美日韩久久一区二区| 日本亚洲一区二区| ww久久中文字幕| proumb性欧美在线观看| 亚洲午夜在线视频| 精品欧美一区二区久久| 国产suv一区二区三区88区| 亚洲黄色免费电影| 777亚洲妇女| 大陆成人av片| 亚洲成人精品影院| 国产亚洲一区二区三区| 91久久精品一区二区三| 久久精品国产99|