Esempio n. 1
0
        public cSync()
        {
            fh = new FTPHelper(cConfig.FTP_IP, cConfig.strFtpRoot, cConfig.FTP_user, cConfig.FTP_password);
            if (!fh.FtpIsExistsFile(""))
                if (fh.MakeDir(""))
                    System.Diagnostics.Debug.Write("OK");

            getFtpFileList();
        }
Esempio n. 2
0
 public static void DeleteFile(string type, string fileName)
 {
     FTPHelper ftp= new FTPHelper(cConfig.FTP_IP, cConfig.strFtpRoot, cConfig.FTP_user, cConfig.FTP_password);
     try
     {
         ftp.GotoDirectory(cConfig.strFtpRoot + "/" + type, true);
         ftp.Delete(fileName);
     }
     catch { }
     finally
     {
         if (ftp != null)
             ftp = null;
     }
 }
Esempio n. 3
0
		/// <summary>
		/// Execute the task
		/// </summary>
		protected override void ExecuteTask()
		{
			OverwriteCondition overwriteCondition = OverwriteCondition;

			// Note: this should have been a nullable, but it's not straight-forward how to convince NAnt to use it.
			if (overwriteCondition == Core.OverwriteCondition.Default)
			{
				overwriteCondition = Core.OverwriteCondition.DifferentSizeOrMoreRecentLocalFile;
			}

			if (CopyFileSet != null && CopyFileSet.BaseDirectory == null)
			{
				CopyFileSet.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
			}

			FTPHelper ftpHelper = new FTPHelper(Username, Password, this);

			FileMapping[] fileMappings = (SourceFile != null ? PrepareSingleFile() : PrepareMultipleFiles()).ToArray();

			// for every URL, make sure the folder exists
			ftpHelper.EnsureFolders(fileMappings.Select(pair => pair.RemoteUri));

			// upload files, without checking for folder existence
			FtpStatusCode status = ftpHelper.UploadFiles(fileMappings, overwriteCondition);

			HandleResult(status);
		}
Esempio n. 4
0
        /// <summary>
        /// 从来源获取公文
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="Url">来源</param>
        /// <param name="type">公文类型</param>
        /// <param name="rlDate"></param>
        /// <param name="provider"></param>
        /// <param name="notes"></param>
        /// <param name="isAddRecord">是否记录进数据库</param>
        public static bool GetDoc(string Title, string Url, string type = "", string rlDate = "",
            string provider = "", string notes = "", bool isAddRecord = true)
        {
            try
            {
                Uri u = new Uri(Url);
                if (u.Scheme.ToLower() == "http")
                {//网址
                    List<cWord> lw = new List<cWord>();
                    lw.Add(new cWord(Title, u.AbsoluteUri, type, rlDate, provider, notes, isAddRecord));
                    cMakeWord mw = new cMakeWord(lw);
                    Thread th = new Thread(new System.Threading.ThreadStart(mw.makeWord));
                    th.Start();
                }
                else if (u.Scheme.ToLower() == "ftp")
                {
                    string ap = u.AbsolutePath.Substring(0, u.AbsolutePath.LastIndexOf('/'));
                    string file = u.AbsolutePath.Replace(ap, "");
                    //暂时不提供ftp文件的下载
                    FTPHelper _fh = new FTPHelper(u.Authority, ap, "", "");

                    _fh.Download(cConfig.strWorkPath + "\\" + type, file);
                    if (isAddRecord)
                        cAccess.add(Title, u.AbsoluteUri, cConfig.strWorkPath + "\\" + type + "\\" + file, type, rlDate, provider, notes);
                }
                else if (u.Scheme.ToLower() == "file")
                {//本地文件
                    string HouZui = u.LocalPath.Substring(u.LocalPath.LastIndexOf('.'));

                    string pFilePath;
                    if (type == "")
                        type = cConfig.strNoType;
                    pFilePath = cConfig.strWorkPath + "\\" + type;

                    if (!(Directory.Exists(pFilePath)))
                        Directory.CreateDirectory(pFilePath);

                    pFilePath += "\\" + Title + HouZui;
                    if (File.Exists(pFilePath))
                    {
                        //MessageBox.Show("公文库中已有同名公文,请修改公文标题或类型!");
                        return true;
                    }
                    File.Copy(Url, pFilePath);
                    if (isAddRecord)
                        cAccess.add(Title, u.LocalPath, pFilePath, type, rlDate, provider, notes);
                }
                else { return false; }
                frmMain.fm.initialize();
                return true;
            }
            catch
            {
                return false;
                throw;
            }
        }