Example #1
0
        /// <summary>
        /// 删除订单目录
        /// </summary>
        /// <param name="ftpServerIP">FTP 主机地址</param>
        /// <param name="folderToDelete">FTP 用户名</param>
        /// <param name="ftpUserID">FTP 用户名</param>
        /// <param name="ftpPassword">FTP 密码</param>
        public static void DeleteOrderDirectory(string ftpServerIP, string folderToDelete, string ftpUserID, string ftpPassword)
        {
            try{
                if (!string.IsNullOrEmpty(ftpServerIP) && !string.IsNullOrEmpty(folderToDelete) && !string.IsNullOrEmpty(ftpUserID) && !string.IsNullOrEmpty(ftpPassword))
                {
                    FtpWeb fw = new FtpWeb(ftpServerIP, folderToDelete, ftpUserID, ftpPassword);
                    //进入订单目录
                    fw.GotoDirectory(folderToDelete, true);
                    //获取规格目录
                    string[] folders = fw.GetDirectoryList();
                    foreach (string folder in folders)
                    {
                        if (!string.IsNullOrEmpty(folder) || folder != "")
                        {
                            //进入订单目录
                            string subFolder = folderToDelete + "/" + folder;
                            fw.GotoDirectory(subFolder, true);
                            //获取文件列表
                            string[] files = fw.GetFileList("*.*");
                            if (files != null)
                            {
                                //删除文件
                                foreach (string file in files)
                                {
                                    fw.Delete(file);
                                }
                            }
                            //删除冲印规格文件夹
                            fw.GotoDirectory(folderToDelete, true);
                            fw.RemoveDirectory(folder);
                        }
                    }

                    //删除订单文件夹
                    string parentFolder = folderToDelete.Remove(folderToDelete.LastIndexOf('/'));
                    string orderFolder  = folderToDelete.Substring(folderToDelete.LastIndexOf('/') + 1);
                    fw.GotoDirectory(parentFolder, true);
                    fw.RemoveDirectory(orderFolder);
                }
                else
                {
                    throw new Exception("FTP 及路径不能为空!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("删除订单时发生错误,错误信息为:" + ex.Message);
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (tB_Serial.Text == "")
            {
                MessageBox.Show("产品序列号不能为空!");
                return;
            }

            pi.sn   = tB_Serial.Text;
            pi.type = tB_Type.Text;
            pi.time = DateTime.Now.ToString();

            if (cb_UpLoad.Checked)
            {
                try
                {
                    string path = App_Configure.Cnfgs.Path_Rpt_Pim + "\\" + "pdf\\" + pi.sn + "_" + pi.device + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".pdf";
                    if (!del_SavePdf(path))
                    {
                        MessageBox.Show("save faile");
                        return;
                    }
                    FtpWeb ftp = new FtpWeb(si.ftpaddr, "", si.ftpuser, si.ftppw);
                    ftp.Upload(path);
                    pi.savepdf = "True";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            try
            {
                SqlConnection conn = new SqlConnection();
                //conn.ConnectionString = "Data Source=SAN-PC;Initial Catalog=Jointcom;User Id=sa;Password=sa";
                conn.ConnectionString = "Data Source=" + si.sqladdr + ";Initial Catalog=" + si.sqlname + ";User Id=" + si.sqluser + ";Password="******"insert into " + pi.device + " (SN,Type,Op,Pim,Result,Fpim,\"Power\",Mode,\"Order\",Band,Limit,Time,Remark) "
                             + "values('"
                             + pi.sn + "','"
                             + pi.type + "','"
                             + pi.tester + "','"
                             + pi.pim + "','"
                             + pi.result + "','"
                             + pi.fpim + "','"
                             + pi.power + "','"
                             + pi.mode + "','"
                             + pi.order + "','"
                             + band + "','"
                             + pi.limit + "','"
                             + pi.time + "','"
                             + pi.savepdf + "')";
                SqlCommand cmd = new SqlCommand(sql, conn);
                int        n   = cmd.ExecuteNonQuery();

                conn.Close();
                MessageBox.Show("Success!");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("数据库连接失败:" + ex.Message);
            }
        }