Пример #1
0
        private void clOriginalList_DragDrop(object sender, DragEventArgs e)
        {
            string[] droppedFiles = ((string[])e.Data.GetData(DataFormats.FileDrop));

            if (droppedFiles.Count() > 0)
            {
                lblDragMessage.Visible = false;
            }

            foreach (var file in droppedFiles)
            {
                btnSelectAll.Enabled = true;

                if (!isFolder(file))
                {
                    if (!isListed(file))
                    {
                        FileInf fileInfo = new FileInf();
                        fileInfo.FullPath      = file;
                        fileInfo.FileName      = Path.GetFileName(file);
                        fileInfo.DirectoryName = Path.GetDirectoryName(file);
                        fileInfo.Extension     = Path.GetExtension(file);
                        originalList.Add(fileInfo);
                        clOriginalList.Items.Add(fileInfo.FileName);
                    }
                }
                if (isFolder(file))
                {
                    FillOriginalListByDrag(file);
                }
            }
        }
Пример #2
0
        public override void Run()
        {
            this.Info("Removing files...");
            FileInf[] files = this.SelectFiles();
            for (int i = files.Length - 1; i > -1; i--)
            {
                FileInf file = files[i];

                try
                {
                    File.Delete(file.Path);
                    this.Workflow.FilesPerTask[file.TaskId].Remove(file);
                    this.InfoFormat("File removed: {0}", file.Path);
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    this.ErrorFormat("An error occured while deleting the file {0}", e, file.Path);
                }
            }
            this.Info("Task finished.");
        }
Пример #3
0
        public override TaskStatus Run()
        {
            Info("Listing files...");
            //System.Threading.Thread.Sleep(10 * 1000);

            bool success = true;

            try
            {
                var xmlPath = Path.Combine(Workflow.WorkflowTempFolder,
                                           string.Format("ListFiles_{0:yyyy-MM-dd-HH-mm-ss-fff}.xml", DateTime.Now));

                var xdoc = new XDocument(new XElement("WexflowProcessing"));

                var xWorkflow = new XElement("Workflow",
                                             new XAttribute("id", Workflow.Id),
                                             new XAttribute("name", Workflow.Name),
                                             new XAttribute("description", Workflow.Description));

                var xFiles = new XElement("Files");
                foreach (List <FileInf> files in Workflow.FilesPerTask.Values)
                {
                    foreach (FileInf file in files)
                    {
                        xFiles.Add(file.ToXElement());
                        Info(file.ToString());
                    }
                }

                xWorkflow.Add(xFiles);
                if (xdoc.Root != null)
                {
                    xdoc.Root.Add(xWorkflow);
                }
                xdoc.Save(xmlPath);

                var xmlFile = new FileInf(xmlPath, Id);
                Files.Add(xmlFile);
                Info(xmlFile.ToString());
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                ErrorFormat("An error occured while listing files. Error: {0}", e.Message);
                success = false;
            }

            var status = Status.Success;

            if (!success)
            {
                status = Status.Error;
            }

            Info("Task finished.");
            return(new TaskStatus(status, false));
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string id  = Request.QueryString["id"];
            string uid = Request.QueryString["uid"];
            string cak = Request.QueryString["callback"];
            int    ret = 0;

            //参数为空
            if (!string.IsNullOrEmpty(id))
            {
                DBFile.complete(id);
                FileInf folder = new FileInf();
                folder.id = id;
                DBFile.read(ref folder);

                //扫描文件夹
                fd_scan sc = new fd_scan();
                sc.scan(folder);

                //合并完毕
                DBFile.merged(id);
                ret = 1;

                //触发事件
                up7_biz_event.folder_post_complete(id);
            }
            Response.Write(cak + "(" + ret + ")");
        }
Пример #5
0
        void mkpath()
        {
            var id      = this.reqString("id");
            var pathLoc = this.reqStringDecode("pathLoc");

            FileInf fileSvr = new FileInf();

            fileSvr.id      = id;
            fileSvr.nameLoc = Path.GetFileName(pathLoc);
            fileSvr.nameSvr = fileSvr.nameLoc;
            fileSvr.pathLoc = pathLoc;

            PathBuilderUuid pb = new PathBuilderUuid();

            fileSvr.pathSvr = pb.genFile(id, fileSvr.nameLoc);
            fileSvr.pathSvr = fileSvr.pathSvr.Replace("\\", "/");

            //数据库存在相同文件
            DBFile  db        = new DBFile();
            FileInf fileExist = new FileInf();

            db.Add(ref fileSvr);
            //触发事件
            up6_biz_event.file_create(fileSvr);

            //
            JObject o = new JObject();

            o["pathSvr"] = fileSvr.pathSvr;
            this.toContent(o);
        }
Пример #6
0
        private void FillOriginalListByDrag(string folderPath)
        {
            if (txtPathFolder.Text.Equals(string.Empty))
            {
                txtPathFolder.Text = folderPath;
            }

            DirectoryInfo dir = new DirectoryInfo(folderPath);

            if (dir.GetFiles().Length > 0)
            {
                lblDragMessage.Visible = false;
            }

            foreach (var file in dir.GetFiles())
            {
                if (!isListed(file.FullName))
                {
                    FileInf fileInfo = new FileInf();
                    fileInfo.FileName      = file.Name;
                    fileInfo.FullPath      = file.FullName;
                    fileInfo.DirectoryName = file.DirectoryName;
                    fileInfo.Extension     = file.Extension;
                    originalList.Add(fileInfo);
                    clOriginalList.Items.Add(fileInfo.FileName);
                }
            }
        }
Пример #7
0
        private void clOriginalList_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            string fileName = clOriginalList.Items[e.Index].ToString();

            if (e.NewValue == CheckState.Checked)
            {
                FileInf fileInfo = FindFileByName(originalList, fileName);
                checkedItems.Add(fileInfo);
                lbRenamedList.Items.Add(fileInfo.FileName);
            }

            if (e.NewValue == CheckState.Unchecked)
            {
                checkedItems.RemoveAll(x => x.FileName == fileName);
                lbRenamedList.Items.Remove(fileName);
            }
            if (isAllChecked())
            {
                btnSelectAll.Text = "Deseleccionar Todo";
            }
            else
            {
                btnSelectAll.Text = "Seleccionar Todo";
            }
        }
Пример #8
0
        /// <summary>
        /// 覆盖同名文件,更新相对路径
        /// </summary>
        /// <param name="inf"></param>
        /// <param name="pathParent"></param>
        public void cover(FileInf inf, string pathParent)
        {
            List <string> files   = new List <string>();
            List <string> folders = new List <string>();

            this.getAllFiles(inf, pathParent, ref files, ref folders);

            this.cover_files(files);
            this.cover_folders(folders);
        }
Пример #9
0
        /// <summary>
        /// 根据文件MD5获取文件信息
        /// 取已上传完的文件
        /// </summary>
        /// <param name="md5"></param>
        /// <param name="inf"></param>
        /// <returns></returns>
        public virtual bool exist_file(string md5, ref FileInf inf)
        {
            if (string.IsNullOrEmpty(md5))
            {
                return(false);
            }

            bool          ret = false;
            StringBuilder sb  = new StringBuilder();

            sb.Append("select top 1 ");
            sb.Append(" f_uid");
            sb.Append(",f_nameLoc");
            sb.Append(",f_nameSvr");
            sb.Append(",f_pathLoc");
            sb.Append(",f_pathSvr");
            sb.Append(",f_pathRel");
            sb.Append(",f_lenLoc");
            sb.Append(",f_sizeLoc");
            sb.Append(",f_pos");
            sb.Append(",f_lenSvr");
            sb.Append(",f_perSvr");
            sb.Append(",f_complete");
            sb.Append(",f_time");
            sb.Append(",f_deleted");
            sb.Append(" from up6_files where f_md5=@f_md5 and f_complete=1 order by f_perSvr desc");

            DbHelper  db  = new DbHelper();
            DbCommand cmd = db.GetCommand(sb.ToString());

            db.AddString(ref cmd, "@f_md5", md5, 40);
            DbDataReader r = db.ExecuteReader(cmd);

            if (r.Read())
            {
                inf.uid      = r.GetInt32(0);
                inf.nameLoc  = r.GetString(1);
                inf.nameSvr  = r.GetString(2);
                inf.pathLoc  = r.GetString(3);
                inf.pathSvr  = r.GetString(4);
                inf.pathRel  = r.GetString(5);
                inf.md5      = md5;
                inf.lenLoc   = r.GetInt64(6);
                inf.sizeLoc  = r.GetString(7);
                inf.offset   = r.GetInt64(8);
                inf.lenSvr   = r.GetInt64(9);
                inf.perSvr   = r.GetString(10);
                inf.complete = r.GetBoolean(11);
                inf.time     = r.GetDateTime(12);
                inf.deleted  = r.GetBoolean(13);
                ret          = true;
            }
            r.Close();
            return(ret);
        }
Пример #10
0
        public override string read(string uid)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("select ");
            sb.Append(" f_id");      //0
            sb.Append(",f_fdTask");  //1
            sb.Append(",f_nameLoc"); //2
            sb.Append(",f_nameSvr"); //3
            sb.Append(",f_pathLoc"); //4
            sb.Append(",f_pathSvr"); //5
            sb.Append(",f_pathRel"); //6
            sb.Append(",f_md5");     //7
            sb.Append(",f_lenLoc");  //8
            sb.Append(",f_sizeLoc"); //9
            sb.Append(",f_pos");     //10
            sb.Append(",f_lenSvr");  //11
            sb.Append(",f_perSvr");  //12
            //
            sb.Append(" from up6_files");
            //
            sb.Append(" where f_uid=:f_uid and f_complete=0 and f_deleted=0 and f_fdChild=0 and f_scan=0");

            DbHelper  db  = new DbHelper();
            DbCommand cmd = db.GetCommand(sb.ToString());

            db.AddInt(ref cmd, ":f_uid", int.Parse(uid));
            DbDataReader r = db.ExecuteReader(cmd);

            while (r.Read())
            {
                var f = new FileInf();
                f.id = r.GetString(0);
                int fdTask = r.GetInt32(1);
                if (fdTask == 1)
                {
                    f.fdTask = true;
                }
                f.nameLoc = r.GetString(2);
                f.nameSvr = r.GetString(3);
                f.pathLoc = r.GetString(4);
                f.pathSvr = r.GetString(5);
                f.pathRel = r.IsDBNull(6) ? string.Empty : r.GetString(6);
                f.md5     = r.IsDBNull(7) ? string.Empty : r.GetString(7);
                f.lenLoc  = r.GetInt64(8);
                f.sizeLoc = r.GetString(9);
                f.offset  = r.GetInt64(10);
                f.lenSvr  = r.GetInt64(11);
                f.perSvr  = r.GetString(12);
                this.files.Add(f);
            }
            r.Close();

            return(this.to_json());//
        }
Пример #11
0
        public override TaskStatus Run()
        {
            this.Info("Loading files...");

            bool success = true;

            try
            {
                foreach (string folder in this.Folders)
                {
                    foreach (string file in Directory.GetFiles(folder))
                    {
                        FileInf fi = new FileInf(file, this.Id);
                        this.Files.Add(fi);
                        this.InfoFormat("File loaded: {0}", file);
                        success &= true;
                    }
                }

                foreach (string file in this.FLFiles)
                {
                    if (File.Exists(file))
                    {
                        this.Files.Add(new FileInf(file, this.Id));
                        this.InfoFormat("File loaded: {0}", file);
                        success &= true;
                    }
                    else
                    {
                        this.ErrorFormat("File not found: {0}", file);
                        success &= false;
                    }
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                this.ErrorFormat("An error occured while loading files.", e);
                success &= false;
            }

            Status status = Status.Success;

            if (!success)
            {
                status = Status.Error;
            }

            this.Info("Task finished.");
            return(new TaskStatus(status, false));
        }
Пример #12
0
        /// <summary>
        /// 计算token,进行授权检查
        /// token = encode( md5(id+nameLoc))
        /// </summary>
        /// <param name="f"></param>
        /// <param name="action">动作:init,block,cmp</param>
        /// <returns></returns>
        public string token(FileInf f, string action = "init")
        {
            string str = f.id + f.nameLoc + action;

            if (action == "block")
            {
                str = f.id + f.pathSvr + action;
            }
            str = this.md5(str);
            str = this.encode(str);
            return(str);
        }
Пример #13
0
        private bool LoadFiles()
        {
            var success = true;

            if (Recursive)
            {
                foreach (string folder in Folders)
                {
                    var files = GetFilesRecursive(folder);

                    foreach (var file in files)
                    {
                        if (string.IsNullOrEmpty(RegexPattern) || Regex.IsMatch(file, RegexPattern))
                        {
                            var fi = new FileInf(file, Id);
                            Files.Add(fi);
                            InfoFormat("File loaded: {0}", file);
                        }
                    }
                }
            }
            else
            {
                foreach (string folder in Folders)
                {
                    foreach (string file in Directory.GetFiles(folder))
                    {
                        if (string.IsNullOrEmpty(RegexPattern) || Regex.IsMatch(file, RegexPattern))
                        {
                            var fi = new FileInf(file, Id);
                            Files.Add(fi);
                            InfoFormat("File loaded: {0}", file);
                        }
                    }
                }
            }

            foreach (string file in FlFiles)
            {
                if (File.Exists(file))
                {
                    Files.Add(new FileInf(file, Id));
                    InfoFormat("File loaded: {0}", file);
                }
                else
                {
                    ErrorFormat("File not found: {0}", file);
                    success = false;
                }
            }

            return(success);
        }
Пример #14
0
        public override void Delete(FileInf file)
        {
            using (var client = new SftpClient(GetConnectionInfo()))
            {
                client.Connect();
                client.ChangeDirectory(Path);

                client.DeleteFile(file.Path);

                client.Disconnect();
            }
        }
Пример #15
0
        public void scan(FileInf inf, string root)
        {
            //扫描文件和目录
            this.GetAllFiles(inf, root);

            DbHelper db = new DbHelper();

            db.connection.Open();
            this.save_files(db);   //保存文件列表
            this.save_folders(db); //保存目录列表
            db.connection.Close();
        }
Пример #16
0
        public void scan(FileInf inf)
        {
            this.db.connection.Open();
            this.makeCmdF();
            this.makeCmdFD();

            this.GetAllFiles(inf, inf.pathSvr);
            this.db.connection.Close();

            this.cmd_add_f.Dispose();
            this.cmd_add_fd.Dispose();
        }
Пример #17
0
        /// <summary>
        /// 根据文件ID获取文件信息
        /// </summary>
        /// <param name="f_id"></param>
        /// <returns></returns>
        public bool read(string f_id, ref FileInf inf)
        {
            bool          ret = false;
            StringBuilder sb  = new StringBuilder();

            sb.Append("select top 1 ");
            sb.Append(" f_uid");
            sb.Append(",f_nameLoc");
            sb.Append(",f_nameSvr");
            sb.Append(",f_pathLoc");
            sb.Append(",f_pathSvr");
            sb.Append(",f_pathRel");
            sb.Append(",f_md5");
            sb.Append(",f_lenLoc");
            sb.Append(",f_sizeLoc");
            sb.Append(",f_pos");
            sb.Append(",f_lenSvr");
            sb.Append(",f_perSvr");
            sb.Append(",f_complete");
            sb.Append(",f_time");
            sb.Append(",f_deleted");
            sb.Append(" from up6_files where f_id=@f_id");

            DbHelper  db  = new DbHelper();
            DbCommand cmd = db.GetCommand(sb.ToString());

            db.AddString(ref cmd, "@f_id", f_id, 32);
            DbDataReader r = db.ExecuteReader(cmd);

            if (r.Read())
            {
                inf.id       = f_id;
                inf.uid      = r.GetInt32(0);
                inf.nameLoc  = r.GetString(1);
                inf.nameSvr  = r.GetString(2);
                inf.pathLoc  = r.GetString(3);
                inf.pathSvr  = r.GetString(4);
                inf.pathRel  = r.IsDBNull(5) ? string.Empty : r.GetString(5);
                inf.md5      = r.GetString(6);
                inf.lenLoc   = r.GetInt64(7);
                inf.sizeLoc  = r.GetString(8);
                inf.offset   = r.GetInt64(9);
                inf.lenSvr   = r.GetInt64(10);
                inf.perSvr   = r.GetString(11);
                inf.complete = r.GetBoolean(12);
                inf.time     = r.GetDateTime(13);
                inf.deleted  = r.GetBoolean(14);
                ret          = true;
            }
            r.Close();
            return(ret);
        }
Пример #18
0
        void savePartFolder()
        {
            FileInf fileSvr = new FileInf();

            fileSvr.id         = id;
            fileSvr.nameLoc    = Path.GetFileName(pathLoc);
            fileSvr.nameSvr    = nameLoc;
            fileSvr.lenLoc     = long.Parse(lenLoc);
            fileSvr.sizeLoc    = sizeLoc;
            fileSvr.pathLoc    = this.pathLoc;
            fileSvr.pathSvr    = this.pathSvr;
            fileSvr.pathRel    = this.pathRel;
            fileSvr.pid        = this.pid;
            fileSvr.pidRoot    = pidRoot;
            fileSvr.blockCount = int.Parse(blockCount);
            fileSvr.blockSize  = int.Parse(blockSize);

            HttpPostedFile part = Request.Files.Get(0);

            //验证大小
            if (part.InputStream.Length != long.Parse(this.blockSize))
            {
                Response.End();
                return;
            }

            //计算块md5
            string md5Svr = string.Empty;

            if (!string.IsNullOrEmpty(this.blockMd5))
            {
                md5Svr = this.mkMD5(part.InputStream);
            }

            //保存块数据
            FileBlockWriter fbw = new FileBlockWriter();

            fbw.write(fileSvr.pathSvr, fileSvr.lenLoc, long.Parse(this.blockOffset), ref part);

            //触发事件
            up7_biz_event.file_post_block(id, int.Parse(blockIndex));

            //返回信息
            JObject o = new JObject();

            o["msg"]    = "ok";
            o["md5"]    = md5Svr;
            o["offset"] = long.Parse(this.blockOffset);
            string json = JsonConvert.SerializeObject(o);//取消格式化

            Response.Write(json);
        }
Пример #19
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        public static void add(ref FileInf f)
        {
            string sql = @"
                insert into up7_files(
                 f_id
                ,f_fdTask
                ,f_uid
                ,f_nameLoc
                ,f_nameSvr
                ,f_pathLoc
                ,f_pathSvr
                ,f_pathRel
                ,f_blockCount
                ,f_blockSize
                ,f_blockPath
                ,f_lenLoc
                ,f_sizeLoc
                ) values (
                 @f_id
                ,@f_fdTask
                ,@f_uid
                ,@f_nameLoc
                ,@f_nameSvr
                ,@f_pathLoc
                ,@f_pathSvr
                ,@f_pathRel
                ,@f_blockCount
                ,@f_blockSize
                ,@f_blockPath
                ,@f_lenLoc
                ,@f_sizeLoc
                ) ";

            DbHelper  db  = new DbHelper();
            DbCommand cmd = db.GetCommand(sql);

            db.AddString(ref cmd, "@f_id", f.id, 36);
            db.AddBool(ref cmd, "@f_fdTask", f.fdTask);
            db.AddInt(ref cmd, "@f_uid", f.uid);
            db.AddString(ref cmd, "@f_nameLoc", f.nameLoc, 255);
            db.AddString(ref cmd, "@f_nameSvr", f.nameSvr, 255);
            db.AddString(ref cmd, "@f_pathLoc", f.pathLoc, 512);
            db.AddString(ref cmd, "@f_pathSvr", f.pathSvr, 512);
            db.AddString(ref cmd, "@f_pathRel", f.pathRel, 512);
            db.AddInt(ref cmd, "@f_blockCount", f.blockCount);
            db.AddInt(ref cmd, "@f_blockSize", f.blockSize);
            db.AddString(ref cmd, "@f_blockPath", f.blockPath, 512);
            db.AddInt64(ref cmd, "@f_lenLoc", f.lenLoc);
            db.AddString(ref cmd, "@f_sizeLoc", f.sizeLoc, 15);

            db.ExecuteNonQuery(cmd);
        }
Пример #20
0
        /// <summary>
        /// 保留原始文件名称
        /// 文件存在重复
        /// 格式:
        ///     upload/uid/年/月/日/uuid/file_name
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="f"></param>
        /// <returns></returns>
        public override string genFile(int uid, ref FileInf f)
        {
            var      uuid    = Guid.NewGuid().ToString("N"); // e0a953c3ee6040eaa9fae2b667060e09
            DateTime timeCur = DateTime.Now;
            string   path    = Path.Combine(this.getRoot(), timeCur.ToString("yyyy"));

            path = Path.Combine(path, timeCur.ToString("MM"));
            path = Path.Combine(path, timeCur.ToString("dd"));
            path = Path.Combine(path, uuid);
            path = Path.Combine(path, f.nameLoc);

            return(path);
        }
Пример #21
0
        /// <summary>
        /// 保留原始文件名称
        /// 文件存在重复
        /// 格式:
        ///     upload/uid/年/月/日/uuid/file_name
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="f"></param>
        /// <returns></returns>
        public override string genFile(int uid, ref FileInf f)
        {
            var      uuid    = f.id;//取消生成ID,使用自已的ID
            DateTime timeCur = DateTime.Now;
            string   path    = Path.Combine(this.getRoot(), timeCur.ToString("yyyy"));

            path = Path.Combine(path, timeCur.ToString("MM"));
            path = Path.Combine(path, timeCur.ToString("dd"));
            path = Path.Combine(path, uuid);
            path = Path.Combine(path, f.nameLoc);

            return(path.Replace("\\", "/"));
        }
Пример #22
0
        public override string genFolder(ref FileInf fd)
        {
            var      uuid    = fd.id; //取消生成新ID,使用原始文件夹ID
            DateTime timeCur = DateTime.Now;
            string   path    = Path.Combine(this.getRoot(), timeCur.ToString("yyyy"));

            path = Path.Combine(path, timeCur.ToString("MM"));
            path = Path.Combine(path, timeCur.ToString("dd"));
            path = Path.Combine(path, uuid);
            path = Path.Combine(path, fd.nameLoc);

            return(path);
        }
Пример #23
0
        public override void Delete(FileInf file)
        {
            using (SftpClient client = new SftpClient(this.GetConnectionInfo()))
            {
                client.Connect();
                client.ChangeDirectory(this.Path);

                client.DeleteFile(file.Path);
                this.Task.InfoFormat("[PluginSFTP] file {0} deleted from {1}.", file.Path, this.Server);

                client.Disconnect();
            }
        }
Пример #24
0
        public static void update(ref FileInf m)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update up7_files set");
            sql.Append(" f_pathSvr=@f_pathSvr");
            sql.Append(",f_pathRel=@f_pathRel");
            sql.Append(",f_md5=@f_md5");
            sql.Append(",f_lenLoc=@f_lenLoc");
            sql.Append(",f_sizeLoc=@f_sizeLoc");
            sql.Append(",f_blockCount=@f_blockCount");
            sql.Append(",f_blockSize=@f_blockSize");
            sql.Append(",f_blockPath=@f_blockPath");
            sql.Append(",f_lenSvr=@f_lenSvr");
            sql.Append(",f_pid=@f_pid");
            sql.Append(",f_perSvr=@f_perSvr");
            sql.Append(",f_deleted=@f_deleted");
            sql.Append(",f_pidRoot=@f_pidRoot");
            sql.Append(",f_fdTask=@f_fdTask");
            sql.Append(",f_fdChild=@f_fdChild");
            sql.Append(",f_uid=@f_uid");
            sql.Append(",f_nameLoc=@f_nameLoc");
            sql.Append(",f_nameSvr=@f_nameSvr");
            sql.Append(",f_pathLoc=@f_pathLoc");
            sql.Append(" where f_id=@f_id ");

            DbHelper db  = new DbHelper();
            var      cmd = db.GetCommand(sql.ToString());

            db.AddString(ref cmd, "@f_pathSvr", m.pathSvr, 512);
            db.AddString(ref cmd, "@f_pathRel", m.pathRel, 512);
            db.AddString(ref cmd, "@f_md5", m.md5, 40);
            db.AddInt64(ref cmd, "@f_lenLoc", m.lenLoc);
            db.AddString(ref cmd, "@f_sizeLoc", m.sizeLoc, 15);
            db.AddInt(ref cmd, "@f_blockCount", m.blockCount);
            db.AddInt(ref cmd, "@f_blockSize", m.blockSize);
            db.AddString(ref cmd, "@f_blockPath", m.blockPath, 2000);
            db.AddInt64(ref cmd, "@f_lenSvr", m.lenSvr);
            db.AddString(ref cmd, "@f_pid", m.pid, 32);
            db.AddString(ref cmd, "@f_perSvr", m.perSvr, 6);
            db.AddBool(ref cmd, "@f_deleted", m.deleted);
            db.AddString(ref cmd, "@f_pidRoot", m.pidRoot, 32);
            db.AddBool(ref cmd, "@f_fdTask", m.fdTask);
            db.AddBool(ref cmd, "@f_fdChild", m.f_fdChild);
            db.AddInt(ref cmd, "@f_uid", m.uid);
            db.AddString(ref cmd, "@f_nameLoc", m.nameLoc, 255);
            db.AddString(ref cmd, "@f_nameSvr", m.nameSvr, 255);
            db.AddString(ref cmd, "@f_pathLoc", m.pathLoc, 512);
            db.AddString(ref cmd, "@f_id", m.id, 32);
            db.ExecuteNonQuery(ref cmd);
        }
Пример #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string uid        = Request.QueryString["uid"];
            string id         = Request.QueryString["id"];
            string lenLoc     = Request.QueryString["lenLoc"];
            string sizeLoc    = Request.QueryString["sizeLoc"];
            string blockSize  = Request.QueryString["blockSize"];
            string blockCount = Request.QueryString["blockCount"];
            string callback   = Request.QueryString["callback"];                  //jsonp参数
            //客户端使用的是encodeURIComponent编码,
            string pathLoc = PathTool.url_decode(Request.QueryString["pathLoc"]); //utf-8解码

            //参数为空
            if (string.IsNullOrEmpty(uid) ||
                string.IsNullOrEmpty(sizeLoc)
                )
            {
                Response.Write(callback + "({\"value\":null,\"inf\":\"参数为空,请检查uid,sizeLoc参数。\"})");
                return;
            }

            FileInf fileSvr = new FileInf();

            fileSvr.id         = id;
            fileSvr.uid        = int.Parse(uid);  //将当前文件UID设置为当前用户UID
            fileSvr.nameLoc    = Path.GetFileName(pathLoc);
            fileSvr.pathLoc    = pathLoc;
            fileSvr.lenLoc     = Convert.ToInt64(lenLoc);
            fileSvr.sizeLoc    = sizeLoc;
            fileSvr.blockSize  = int.Parse(blockSize);
            fileSvr.blockCount = int.Parse(blockCount);
            fileSvr.nameSvr    = fileSvr.nameLoc;

            PathGuidBuilder pb = new PathGuidBuilder();

            fileSvr.pathSvr = pb.genFile(fileSvr.uid, fileSvr.id, fileSvr.nameLoc);

            //添加到任务表
            DBFile.add(ref fileSvr);

            //触发事件
            up7_biz_event.file_create(fileSvr);

            string jv = JsonConvert.SerializeObject(fileSvr);

            jv = HttpUtility.UrlEncode(jv);
            jv = jv.Replace("+", "%20");
            string json = callback + "({\"value\":\"" + jv + "\"})";//返回jsonp格式数据。

            Response.Write(json);
        }
Пример #26
0
        public override void Download(FileInf file)
        {
            var client = new FtpClient {
                Host = Server, Port = Port, Credentials = new NetworkCredential(User, Password)
            };

            client.Connect();
            client.SetWorkingDirectory(Path);

            DownloadFile(client, file, Task);
            Task.InfoFormat("[PluginFTP] file {0} downloaded from {1}.", file.Path, Server);

            client.Disconnect();
        }
Пример #27
0
        public static void UploadFile(FtpClient client, FileInf file)
        {
            using (Stream istream = File.Open(file.Path, FileMode.Open, FileAccess.Read))
                using (Stream ostream = client.OpenWrite(file.RenameToOrName, FtpDataType.Binary))
                {
                    var buffer = new byte[BufferSize];
                    int r;

                    while ((r = istream.Read(buffer, 0, BufferSize)) > 0)
                    {
                        ostream.Write(buffer, 0, r);
                    }
                }
        }
Пример #28
0
        public override void Delete(FileInf file)
        {
            var client = new FtpClient {
                Host = Server, Port = Port, Credentials = new NetworkCredential(User, Password)
            };

            client.Connect();
            client.SetWorkingDirectory(Path);

            client.DeleteFile(file.Path);
            Task.InfoFormat("[PluginFTP] file {0} deleted on {1}.", file.Path, Server);

            client.Disconnect();
        }
Пример #29
0
        protected void save_folder(FileInf f)
        {
            this.cmd_add_fd.Parameters["@f_id"].Value       = f.id;
            this.cmd_add_fd.Parameters["@f_pid"].Value      = f.pid;
            this.cmd_add_fd.Parameters["@f_pidRoot"].Value  = f.pidRoot;
            this.cmd_add_fd.Parameters["@f_uid"].Value      = f.uid;
            this.cmd_add_fd.Parameters["@f_name"].Value     = f.nameSvr;
            this.cmd_add_fd.Parameters["@f_pathLoc"].Value  = f.pathLoc;
            this.cmd_add_fd.Parameters["@f_pathSvr"].Value  = f.pathSvr;
            this.cmd_add_fd.Parameters["@f_pathRel"].Value  = f.pathRel;
            this.cmd_add_fd.Parameters["@f_complete"].Value = f.complete;

            cmd_add_fd.ExecuteNonQuery();
        }
Пример #30
0
        /// <summary>
        /// 所有文件均以md5模式存储
        /// 格式:
        ///     upload/年/月/日/md5.ext
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="f"></param>
        /// <returns></returns>
        public override string genFile(int uid, ref FileInf f)
        {
            DateTime timeCur = DateTime.Now;
            string   path    = Path.Combine(this.getRoot(), timeCur.ToString("yyyy"));

            path = Path.Combine(path, timeCur.ToString("MM"));
            path = Path.Combine(path, timeCur.ToString("dd"));
            string name = f.md5;

            name += Path.GetExtension(f.nameLoc);
            path  = Path.Combine(path, name);

            return(path);
        }
Пример #31
0
 private IList<FileInf> getFine(SqlConnection conn)
 {
     string query = "select * from  _ModuleField";
     SqlCommand cmmd = new SqlCommand(query, conn);
     SqlDataReader read= cmmd.ExecuteReader();
     IList<FileInf> list = new List<FileInf>();
   
     while (read.Read()) {
         string name = read["tf_fieldOrder"].ToString();
         FileInf f = new FileInf() { Name = name };
         list.Add(f);
     
     
     }
     read.Close();
     conn.Close();
     return list;
 
 
 }