/// <summary>
        /// 版本检查
        /// </summary>
        /// <returns></returns>
        private bool checkVersionForRelease(ref string version)
        {
            string localpath =
                Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "version.ini");

            if (!File.Exists(localpath))
            {
                return(false);
            }
            byte[] content = null;
            ReadFile(out content, localpath);
            if (content != null)
            {
                string localversion = System.Text.Encoding.Default.GetString(content);
                NCFTP  ftp          = new NCFTP();
                if (ftp.download(Path.Combine(upgradeurl, "version.ini"), @"c:\cjw\version.ini", userName, password))
                {
                    ReadFile(out content, @"c:\cjw\version.ini");
                    string remoteversion = System.Text.Encoding.Default.GetString(content);

                    if (float.Parse(remoteversion) < float.Parse(localversion))
                    {
                        version = localversion;
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="file"></param>
        private void uploadFile(string file)
        {
            NCFTP  ftp = new NCFTP();
            string url = Path.Combine(ftpserver, Path.GetFileName(file));

            ftp.uploadFile(url, file, userName, password);
        }
        /// <summary>
        /// FTP服务器测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTest_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                if (txtTestTo.Text == "")
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0019I", db.Language);
                    MessageBox.Show(msg);
                    return;
                }
                NCFTP  ftp      = new NCFTP();
                String filename = txtTestTo.Text;
                String url      = "ftp://" + txtAddress.Text + "/" + txtFolder.Text + "/" + System.IO.Path.GetFileName(filename);

                if (ftp.uploadFile(url, filename, txtUser.Text, txtPassword.Text))
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0027I", db.Language);
                    MessageBox.Show(msg);
                }
                else
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0028I", db.Language);
                    MessageBox.Show(msg);
                }
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0019I", db.Language);
                MessageBox.Show(msg);
            }
        }
 /// <summary>
 /// FTP上传
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnTest_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < dataGridView3.SelectedRows.Count; i++)
     {
         string  id       = dataGridView3.SelectedRows[i].Cells[0].Value.ToString();
         DataSet ds       = new DataSet();
         String  strWhere = "上传编号=" + id;
         if (db.GetFTPUploadVW(0, 0, "*", strWhere, "", ref ds))
         {
             NCFTP ftp = new NCFTP();
             foreach (DataRow dr in ds.Tables[0].Rows)
             {
                 String filename = dr["上传名称"].ToString();
                 String url      = dr["FTP文件"].ToString();
                 string uploadid = dr["上传编号"].ToString();
                 if (ftp.uploadFile(url, filename, dr["用户"].ToString(), dr["密码"].ToString()))
                 {
                     setUpload(uploadid, "上传完");
                 }
             }
         }
         Application.DoEvents();
     }
     init();
 }
        /// <summary>
        /// Zip文件上传
        /// </summary>
        private void uploadZipFile(string version)
        {
            string path    = Path.GetDirectoryName(Application.ExecutablePath);
            string zipname = Path.Combine(path, version + Path.GetFileName(fileName));
            string url     = Path.Combine(upgradeurl, Path.GetFileName(zipname));
            NCFTP  ftp     = new NCFTP();

            ftp.uploadFile(url, zipname, userName, password);
        }
Beispiel #6
0
        /// <summary>
        /// 文件下载
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private bool downloadFile(string file)
        {
            NCFTP  ftp = new NCFTP();
            string src = Path.GetFileName(file);

            if (ftp.download(Path.Combine(ftpserver, src), file, userName, password))
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 更新服务器版本
        /// </summary>
        private void changeServerVersion()
        {
            string localpath =
                Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "version.ini");

            if (File.Exists(localpath))
            {
                string url = Path.Combine(upgradeurl, "version.ini");
                NCFTP  ftp = new NCFTP();
                ftp.uploadFile(url, localpath, userName, password);
            }
        }
Beispiel #8
0
        /// <summary>
        /// 取得要下载文件列表
        /// </summary>
        /// <returns></returns>
        private string[] getFileListFromFtp()
        {
            byte[] content = null;
            NCFTP  ftp     = new NCFTP();

            if (ftp.download(Path.Combine(ftpserver, remote_file), local_file, userName, password))
            {
                ReadFile(out content, local_file);
                string   remotefilelist = System.Text.Encoding.Default.GetString(content);
                string[] files          = remotefilelist.Split(';');
                return(files);
            }
            return(null);
        }
Beispiel #9
0
        /// <summary>
        /// 文件一览更新
        /// </summary>
        /// <param name="file"></param>
        private void updateFilelist(string file)
        {
            byte[] content = null;
            NCFTP  ftp     = new NCFTP();

            if (ftp.download(Path.Combine(ftpserver, remote_file), local_file, userName, password))
            {
                ReadFile(out content, local_file);
                string remotefilelist = System.Text.Encoding.Default.GetString(content);
                remotefilelist += ";" + Path.GetFileName(file);
                WritetoFile(System.Text.Encoding.Default.GetBytes(remotefilelist), local_file);
                ftp.uploadFile(Path.Combine(ftpserver, remote_file), local_file, userName, password);
            }
            else
            {
                WritetoFile(System.Text.Encoding.Default.GetBytes(Path.GetFileName(file)), file);
                ftp.uploadFile(Path.Combine(ftpserver, remote_file), local_file, userName, password);
            }
        }
        /// <summary>
        /// 上传合成文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (txtMagPDF.Text == "")
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0085I", db.Language);
                MessageBox.Show(msg);
                return;
            }
            DataSet ftpds = new DataSet();

            if (db.GetFTPServer(0, 0, "*", "", "", ref ftpds))
            {
                NCFTP  ftp      = new NCFTP();
                String filename = txtMagPDF.Text;
                foreach (DataRow dr in ftpds.Tables[0].Rows)
                {
                    String url       = "ftp://" + dr["地址"].ToString() + "/" + dr["文件夹"].ToString() + "/" + System.IO.Path.GetFileName(filename);
                    String fieldlist = "FTP编号,期刊编号,发行编号,上传状态,上传名称,UserID";
                    String valuelist = dr["编号"].ToString() + "," + MagId.ToString() + "," + PublishId.ToString() + ",'未上传','" + filename + "','" + db.UserID + "'";
                    int    id        = 0;
                    if (db.SetFTPUpload(0, 0, fieldlist,
                                        "", valuelist, out id))
                    //if (ftp.uploadFile(url, filename, dr["用户"].ToString(), dr["密码"].ToString()))
                    {
                        string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0027I", db.Language);
                        MessageBox.Show(msg);
                    }
                    else
                    {
                        string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0028I", db.Language);
                        MessageBox.Show(msg);
                    }
                }
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0084I", db.Language);
                MessageBox.Show(msg);
            }
        }