コード例 #1
0
        /// <summary>
        /// 文件上传
        /// </summary>
        /// <param name="file"></param>
        private static void uploadFile(string file)
        {
            NCFTP  ftp = new NCFTP();
            string url = Path.Combine(ftpserver, Path.GetFileName(file));

            ftp.uploadFile(url, file, userName, password);
        }
コード例 #2
0
        /**
         *FTPアップロードタスク
         *アップロードしないタスクを実行する
         */
        private static void FtpUpload()
        {
            DataSet ds       = new DataSet();
            String  strWhere = "上传状态='未上传'";

            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();
                    setUpload(uploadid, "上传中");
                    if (ftp.uploadFile(url, filename, dr["用户"].ToString(), dr["密码"].ToString()))
                    {
                        setUpload(uploadid, "上传完");
                    }
                    else
                    {
                        setUpload(uploadid, "未上传");
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// 文件下载
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private static 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);
        }
コード例 #4
0
        /// <summary>
        /// 文件一览更新
        /// </summary>
        /// <param name="file"></param>
        private static 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), file);
                ftp.uploadFile(Path.Combine(ftpserver, remote_file), local_file, userName, password);
            }
        }
コード例 #5
0
        /// <summary>
        /// 取得要下载文件列表
        /// </summary>
        /// <returns></returns>
        private static 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);
        }
コード例 #6
0
        /// <summary>
        /// 上传合成文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private string uploadfile(string pdffile, string magId, string publishid)
        {
            if (pdffile == "")
            {
                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 = pdffile;
                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 + "," + publishid + ",'未上传','" + filename + "','" + db.UserID + "'";
                    int    id        = 0;
                    if (db.SetFTPUpload(0, 0, fieldlist,
                                        "", valuelist, out id))
                    //if (ftp.uploadFile(url, filename, dr["用户"].ToString(), dr["密码"].ToString()))
                    {
                        return(url);
                        //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);
            }
            return("");
        }
コード例 #7
0
        /// <summary>
        /// 期刊发行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Publish(string magId, string sMagId, string magNo, string mediaType, string mediaId)
        {
            DataSet ds = new DataSet();

            if (db.GetPublish(0, 0, "发行编号,期刊编号,发行期号,发行日期,期刊状态,文件链接,本地文件,FTP文件,图片链接,本地图片,FTP图片,文本内容,邮件内容,S期刊编号,S发行编号",
                              "期刊编号=" + magId + " and 发行期号='" + magNo + "'", "", ref ds) && ds.Tables[0].Rows.Count == 1)
            {
                string strState = ds.Tables[0].Rows[0]["期刊状态"].ToString();
                if (strState.Trim() != "新建" && strState.Trim() != "发行中")
                {
                    string msg = String.Format(NCMessage.GetInstance(db.Language).GetMessageById("CM0083I", db.Language), strState);
                    MessageBox.Show(msg);
                    return;
                }
                string strPublishId  = ds.Tables[0].Rows[0]["发行编号"].ToString();
                string strMagId      = magId;
                string strSPublishId = ds.Tables[0].Rows[0]["S发行编号"].ToString();
                string txtFileLink   = ds.Tables[0].Rows[0]["文件链接"].ToString();
                string txtFileLocal  = ds.Tables[0].Rows[0]["本地文件"].ToString();
                string txtFileFTP    = ds.Tables[0].Rows[0]["FTP文件"].ToString();
                string txtPicLink    = ds.Tables[0].Rows[0]["图片链接"].ToString();
                string txtPicLocal   = ds.Tables[0].Rows[0]["本地图片"].ToString();
                string txtPicFTP     = ds.Tables[0].Rows[0]["FTP图片"].ToString();
                string txtText       = ds.Tables[0].Rows[0]["文本内容"].ToString();
                string txtMail       = ds.Tables[0].Rows[0]["邮件内容"].ToString();

                int id = 0;
                if (chkMailSend.Checked && db.GetCustomer(0, 0, "id", "subscripted='Y'", "", ref ds))
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        String customerid = row["id"].ToString();
                        String fieldlist  = "客户编号,期刊编号,发行编号,送信状态,UserID";
                        String valuelist  = customerid + "," + strMagId + "," + strPublishId + ",'未送信','" + db.UserID + "'";
                        db.SetSend(0, 0, fieldlist,
                                   "", valuelist, out id);
                    }
                }
                else if (chkMailSend.Checked)
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0074I", db.Language);
                    MessageBox.Show(msg);
                }

                ///发行同步
                ds = new DataSet();
                if (db.GetSPublish(0, 0, "S发行编号", "发行编号=" + strPublishId + " and 期刊编号=" + strMagId + " and S期刊编号='" + sMagId + "'", "", ref ds) && ds.Tables[0].Rows.Count > 0)
                {
                    String wheresql = "S发行编号='" + ds.Tables[0].Rows[0][0].ToString() + "'";
                    String valuesql = "发行期号='" + magNo
                                      + "',期刊状态='" + strState
                                      + "',文件链接='" + txtFileLink
                                      + "',本地文件='" + txtFileLocal
                                      + "',FTP文件='" + txtFileFTP
                                      + "',图片链接='" + txtPicLink
                                      + "',本地图片='" + txtPicLocal
                                      + "',FTP图片='" + txtPicFTP
                                      + "',文本内容='" + txtText + "',邮件内容='" + txtMail + "'";
                    db.SetSPublish(0, 1, "", wheresql, valuesql, out id);
                }
                else
                {
                    String fieldlist = "S发行编号,S期刊编号,期刊编号,发行编号,发行期号,发行日期,文件链接,本地文件,FTP文件,图片链接,本地图片,FTP图片,文本内容,邮件内容,期刊状态,UserID";
                    String valuelist = "'" + strSPublishId + "','" + sMagId + "',"
                                       + magId + "," + strPublishId + ",'" + magNo + "','"
                                       + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "','"
                                       + txtFileLink + "','"
                                       + txtFileLocal + "','"
                                       + txtFileFTP + "','"
                                       + txtPicLink + "','"
                                       + txtPicLocal + "','"
                                       + txtPicFTP + "','"
                                       + txtText + "','"
                                       + txtMail + "','新建','" + db.UserID + "'";
                    db.SetSPublish(0, 0, fieldlist,
                                   "", valuelist, out id);
                }
                ///启动FTP上传
                if (chkFtpUpload.Checked)
                {
                    ds = new DataSet();
                    String strWhere = "上传状态='未上传' and 期刊编号=" + magId + " and 发行编号=" + strPublishId;
                    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();
                            setUpload(uploadid, "上传中");
                            if (ftp.uploadFile(url, filename, dr["用户"].ToString(), dr["密码"].ToString()))
                            {
                                setUpload(uploadid, "上传完");
                            }
                            else
                            {
                                setUpload(uploadid, "未上传");
                            }
                        }
                    }
                }
                if (chkMediaPublish.Checked)
                {
                    //媒体发布
                    ds = new DataSet();
                    string wheresql = "published='Y' and MediaType='" + mediaType + "'";
                    if (mediaId != null)
                    {
                        wheresql += " and id=" + mediaId;
                    }
                    if (db.GetMedia(0, 0, "*", wheresql, "", ref ds))
                    {
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            String mediaId1   = row["id"].ToString();
                            String mediaType1 = row["MediaType"].ToString();

                            String fieldlist = "媒体编号,期刊编号,发行编号,发行状态,媒体名称,UserID";
                            String valuelist = mediaId1 + "," + strMagId + "," + strPublishId + ",'未发行','" + mediaType1 + "','" + db.UserID + "'";
                            db.SetMediaPublish(0, 0, fieldlist,
                                               "", valuelist, out id);
                        }
                    }
                }
                ///发行状态更新
                String wheresql1 = "发行编号=" + strPublishId;
                String valuesql1 = "期刊状态='发行中'";
                if (db.SetPublish(0, 1, "", wheresql1, valuesql1, out id) && id == 1)
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0081I", db.Language);
                    MessageBox.Show(msg);
                }
                else
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0082I", db.Language);
                    MessageBox.Show(msg);
                }
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0069I", db.Language);
                MessageBox.Show(msg);
            }
        }