コード例 #1
0
        private void FtpTrans(SysBackupServerEntity model, string backupPath, string virtualPath, string strPath, string chkDrop)
        {
            Task.Run(() =>
            {
                if (model != null)
                {
                    FTPHelper ftp = new FTPHelper(model.F_FtpServerIp, "", model.F_FtpUserId, model.F_FtpPassword);
                    if (!ftp.IsDirectoryExist(backupPath))
                    {
                        ftp.CreateDirectory(backupPath);
                    }
                    ftp = new FTPHelper(model.F_FtpServerIp, backupPath, model.F_FtpUserId, model.F_FtpPassword);

                    ZipFloClass Zc = new ZipFloClass();               //将文件夹进行GZip压缩
                    Zc.ZipFile(Server.MapPath(virtualPath), strPath); //生成压缩包

                    if (chkDrop == "true")
                    {
                        //遍历删除当前目录文件
                        List <FileStruct> ListFiles = ftp.ListFiles();
                        if (ListFiles.Count > 0)
                        {
                            foreach (var item in ListFiles)
                            {
                                ftp.DeleteFile(item.Name);
                            }
                        }
                    }
                    ftp.Upload(strPath);            //通过ftp传到服务器
                    FileHelper.DeleteFile(strPath); //删除临时压缩包
                }
            });
        }
コード例 #2
0
 public ActionResult SubmitForm(SysBackupServerEntity model, string keyValue)
 {
     app.SubmitForm(model, keyValue);
     if (!string.IsNullOrEmpty(keyValue))
     {
         base.OperateLog("编辑备份服务器:F_Id:" + keyValue, "/SystemSecurity/BackupServer/SubmitForm", "备份服务器", Application.DbLogType.Update);
     }
     else
     {
         base.OperateLog("新增备份服务器", "/SystemSecurity/BackupServer/SubmitForm", "备份服务器", Application.DbLogType.Create);
     }
     return(Success("操作成功。"));
 }
コード例 #3
0
 public void SubmitForm(SysBackupServerEntity entity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         entity.Modify(keyValue);
         service.Update(entity);
     }
     else
     {
         entity.Create();
         service.Insert(entity);
     }
 }
コード例 #4
0
 public ActionResult EnabledConents(string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         List <string> lstid = StringHelper.GetStrArray(keyValue, ',', false);
         for (int i = 0; i < lstid.Count; i++)
         {
             SysBackupServerEntity model = new SysBackupServerEntity();
             model.F_Id          = lstid[i];
             model.F_EnabledMark = true;
             app.UpdateForm(model);
         }
         base.OperateLog("备份服务器启用:" + keyValue, "/SystemSecurity/BackupServer/EnabledConents", "备份服务器", Application.DbLogType.Submit);
         return(Success("启用成功"));
     }
     return(Success("请选择启用项"));
 }
コード例 #5
0
        public ActionResult DoConnect(string keyValue)
        {
            if (!string.IsNullOrEmpty(keyValue))
            {
                SysBackupServerEntity model = new SysBackupServerEntity();
                model = app.GetForm(keyValue);

                FTPHelper help = new FTPHelper(model.F_FtpServerIp, "", model.F_FtpUserId, model.F_FtpPassword);
                try
                {
                    help.IsDirectoryExist("test");
                    return(Success("连接成功"));
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                }
            }
            return(Error("连接失败"));
        }
コード例 #6
0
 public void UpdateForm(SysBackupServerEntity entity)
 {
     service.Update(entity);
 }
コード例 #7
0
 public void Delete(SysBackupServerEntity entity)
 {
     service.Delete(entity);
 }