Exemplo n.º 1
0
        public static string getFilePic0(string filePath)
        {
            //MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().Location);
            //MessageBox.Show("检测PICs"+filePath);
            string savePath = null;

            try
            {
                //string savePicPath = Path.GetDirectoryName(filePath);
                string savePicName = Path.GetFileName(filePath);
                savePath = filePath.Replace(savePicName, ReviewLocalFamily.getFileMD5Hash(filePath)) + ".png";


                ShellFile shellFile = ShellFile.FromFilePath(filePath);

                Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;

                shellThumb = resizeImage((Image)shellThumb, new Size(120, 120));

                shellThumb.Save(savePath, ImageFormat.Png);
            }
            catch (Exception de)
            {
                MessageBox.Show(de.ToString());
            }

            return(savePath);
        }
Exemplo n.º 2
0
        private void btn_UploadFamily_Click(object sender, EventArgs e)
        {
            LogMonitor.logMonitorUpdate(sqlConnectionLocation, "族库平台:上传,专业:" + lbl_ProText.Text.ToString() + ",类型:" + lbl_TypeText.Text.ToString() + "," + txt_SelectedFamilyName.Text.ToString());
            //cmb_allFamilyTypes.Text = lbl_TypeText.Text.ToString();
            //if (cmb_allFamilyTypes.Text.ToString() == null)
            //{ MessageBox.Show("请选择族类型"); }
            if (lbl_ProText.Text.ToString() == "NA" || lbl_TypeText.Text.ToString() == "NA")
            {
                MessageBox.Show("请选择族类型");
            }
            else
            {
                try
                {
                    //sql链接初始化
                    SqlCompose        SqlCompose        = new SqlCompose(sqlConnectionLocation);
                    ReviewLocalFamily ReviewLocalFamily = new ReviewLocalFamily();
                    string            familyHash        = ReviewLocalFamily.getFileMD5Hash(familyPath.ToString());


                    //判断库内是否已有相同模型
                    string checkSameFamilySQL = "SELECT * FROM table_p_Family WHERE f_Hash=" + "'" + familyHash + "'";
                    //MessageBox.Show(checkSameFamilySQL);
                    DataSet   ds = SqlCompose.ExecuteSqlQuery(checkSameFamilySQL);
                    DataTable dt = new DataTable();
                    dt = ds.Tables[0];
                    //MessageBox.Show(ds.Tables[0].Rows[0]["f_Name"].ToString());
                    //MessageBox.Show(dt.Rows.Count.ToString());
                    DecisionForm DecisionForm = new DecisionForm(dt);
                    DecisionForm.Continue = true;
                    if (dt.Rows.Count.ToString() != "0")
                    {
                        MessageBox.Show("库中已经存在相同模型文件" + dt.Rows.Count.ToString() + "个");
                        DecisionForm.ShowDialog();
                    }


                    #region  判断信息完整性
                    int    upLoadKey          = 0;
                    string familyValLevel     = null;
                    string familyManufacturer = null;
                    string familySource       = null;
                    string familyDeviceType   = null;
                    string familyName0        = null;

                    if (cmb_ValLevel.Text == null)
                    {
                        MessageBox.Show("请选择电压等级");
                    }
                    else
                    {
                        familyValLevel = cmb_ValLevel.Text.ToString();
                        upLoadKey++;
                    }

                    if (txt_Manufacturer.Text == null || txt_Manufacturer.Text == "NA")
                    {
                        MessageBox.Show("请填写厂家");
                    }
                    else
                    {
                        familyManufacturer = txt_Manufacturer.Text.ToString();
                        upLoadKey++;
                    }

                    if (cmb_Source.Text == null || cmb_Source.Text == "NA")
                    {
                        MessageBox.Show("请填写需要上传的族来源");
                    }
                    else
                    {
                        familySource = cmb_Source.Text.ToString();
                        upLoadKey++;
                    }


                    if (txt_DeviceType == null || txt_DeviceType.Text == "NA")
                    {
                        MessageBox.Show("请填写设备型号");
                    }
                    else
                    {
                        familyDeviceType = txt_DeviceType.Text.ToString();
                        upLoadKey++;
                    }

                    if (txt_SelectedFamilyName.Text == null && txt_SelectedFamilyName.Text == "NA")
                    {
                        MessageBox.Show("请填写设备名称");
                    }
                    else
                    {
                        //familyName0 = txt_SelectedFamilyName.Text.ToString();
                        upLoadKey++;
                    }
                    if (upLoadKey < 5)
                    {
                        MessageBox.Show("请将信息填写完整,否则无法上传!");
                    }

                    #endregion

                    #region 判断族名和表名问题

                    bool isSameName = true;

                    #endregion


                    for (int k = 0; k < familyInfo.Rows.Count; k++)
                    {
                        originFamilyPath = familyInfo.Rows[k]["familyPathss"].ToString();
                        originFamilyName = Path.GetFileName(originFamilyPath);
                        originParaPath   = familyInfo.Rows[k]["familyParass"].ToString();
                        originParaName   = Path.GetFileName(originParaPath);
                        localPicPath     = familyInfo.Rows[k]["familyPicss"].ToString();

                        familyName0 = originFamilyName;

                        if (DecisionForm.Continue == false)
                        {
                            //等待其他操作
                        }
                        else if (DecisionForm.Continue == true && upLoadKey >= 5 && isSameName == true)
                        {
                            //FTP操作  需确定上传至文件服务器路径
                            var ftp = new FtpHelper0(serverIP, ftpUserName, ftpPassword);
                            //string tagetFtpDir = @"DB_Family_Library_FTP\" + familyPro + "\\" + familyType + "\\";
                            string tagetFtpDir = @"DB_Family_Library_FTP\" + familyPro + "\\" + lbl_TypeText.Text.ToString() + "\\";
                            //MessageBox.Show(familyPro);
                            //MessageBox.Show(familyType);
                            string tagetFtpDirPara = @"DB_Family_Library_FTP\paracast\";
                            //处理族文件名称路径
                            modifyFamilyPath = originFamilyPath.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originFamilyPath) + ".rfa";
                            modifyFamilyName = originFamilyName.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originFamilyPath) + ".rfa";
                            File.Copy(originFamilyPath, modifyFamilyPath, true);
                            //MessageBox.Show("族路径已处理" + modifyFamilyPath.ToString());

                            //处理表文件名称路径

                            //modifyParaPath = originParaPath.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originParaPath) + ".rfa";
                            //modifyParaName = originParaName.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originParaName) + ".rfa";
                            modifyParaPath = originParaPath.Replace(".xls", "") + ReviewLocalFamily.getFileMD5Hash(originParaPath) + ".xls";
                            modifyParaName = originParaName.Replace(".xls", "") + ReviewLocalFamily.getFileMD5Hash(originParaPath) + ".xls";
                            //modifyParaPath = originParaPath.Replace(originParaName, originFamilyName);
                            File.Copy(originParaPath, modifyParaPath, true);
                            //MessageBox.Show("族路径已处理" + modifyParaPath.ToString());

                            //MessageBox.Show("族路径已处理\n\n" + modifyFamilyPath.ToString());
                            //MessageBox.Show("族路径已处理\n\n" + tagetFtpDir.ToString());
                            ftp.UploadFile(modifyFamilyPath.ToString(), tagetFtpDir);
                            ftp.UploadFile(modifyParaPath.ToString(), tagetFtpDirPara);
                            ftp.UploadFile(localPicPath, @"DB_Family_Library_FTP\pics\");


                            //sql同步操作

                            //SqlHelper.Con.Close();
                            //获取需填写内容
                            string familyLocation = ftpConnectionLocation + tagetFtpDir.Replace("\\", "/") + modifyFamilyName;

                            string familySize       = (ReviewLocalFamily.getFileSize(modifyFamilyPath) / 1024).ToString() + "KB";
                            string familyUploadDate = DateTime.Now.ToString();



                            string familyParaLocation       = null;
                            string familyConfigParaLocation = ftpConnectionLocation + "DB_Family_Library_FTP/paracast/" + modifyParaName;
                            string familyPicLocation        = ftpConnectionLocation + "DB_Family_Library_FTP/pics/" + Path.GetFileName(localPicPath);
                            //MessageBox.Show(familyPicLocation);

                            //开始sql语句操作
                            bool queryNum = false;
                            //string getFamilySQLSync = "INSERT INTO table_ParameterDefault (pmd_Resource,pmd_Location,pmd_Hash,pmd_Date) VALUES ('Administraror','" + paraLocation + "','" + paraHash + "','" + paraUploadDate + "'" + ");";
                            string getFamilySQLSync = "INSERT INTO table_p_Family "
                                                      + "(f_Name,f_Path,f_Value,f_Pro,f_ValLevel,f_Cat,f_Hash,f_UploadDate,f_ParaLocation,f_ConfigParaLocation,f_manufacturer,f_Source,f_DeviceType,f_Pic) "
                                                      + "VALUES ('" + familyName0
                                                      + "','" + familyLocation
                                                      + "','" + familySize
                                                      + "','" + familyPro
                                                      + "','" + familyValLevel
                                                      + "','" + familyType
                                                      + "','" + familyHash
                                                      + "','" + familyUploadDate
                                                      + "','" + familyParaLocation
                                                      + "','" + familyConfigParaLocation
                                                      + "','" + familyManufacturer
                                                      + "','" + familySource
                                                      + "','" + familyDeviceType
                                                      + "','" + familyPicLocation + "')";
                            //MessageBox.Show(getFamilySQLSync);
                            //SqlHelper.Con.Close();
                            queryNum = SqlCompose.ExecuteSqlNonQuery(getFamilySQLSync);

                            if (queryNum != false)
                            {
                                MessageBox.Show("上传完成");
                            }
                            //清除临时哈文件项
                            File.Delete(modifyFamilyPath);
                            File.Delete(modifyParaPath);
                            //File.Delete(localPicPath);
                        }
                        else
                        {
                            MessageBox.Show("由于信息填写不全,目前无法上传。");
                        }
                    }
                }
                catch (Exception efc)
                { MessageBox.Show(efc.ToString()); }
            }
        }
        private void btn_uploadx_Click(object sender, EventArgs e)
        {
            count = 0;
            LogMonitor LogMonitor = new LogMonitor();
            DataTable  dtUpload   = DataUB.dataTempTable;

            if (lbl_ProText.Text.ToString() == "NA" || lbl_TypeText.Text.ToString() == "NA")
            {
                MessageBox.Show("请选择族类型");
            }

            for (int i = 0; i < dtUpload.Rows.Count; i++)
            {
                LogMonitor.logMonitorUpdate(sqlConnectionLocation, "族库平台:上传,专业:" + lbl_ProText.Text.ToString() + ",类型:" + lbl_TypeText.Text.ToString() + "," + dtUpload.Rows[i]["familyNamess"].ToString());

                //sql链接初始化
                SqlCompose        SqlCompose        = new SqlCompose(sqlConnectionLocation);
                ReviewLocalFamily ReviewLocalFamily = new ReviewLocalFamily();
                string            familyHash        = ReviewLocalFamily.getFileMD5Hash(familyPath.ToString());

                ////判断库内是否已有相同模型
                //string checkSameFamilySQL = "SELECT * FROM table_p_Family WHERE f_Hash=" + "'" + familyHash + "'";

                //DataSet ds = SqlCompose.ExecuteSqlQuery(checkSameFamilySQL);
                //DataTable dt = new DataTable();
                //dt = ds.Tables[0];

                //for (int j = 0; j < dt.Rows.Count; j++)
                //{
                //    string exsistFamilyInfo = dt.Rows[i]["f_Name"].ToString() + "; " + dt.Rows[i]["f_UploadDate"].ToString() + "; " + dt.Rows[i]["f_ValLevel"].ToString() + "; " + dt.Rows[i]["f_DeviceType"].ToString() + "; " + dt.Rows[i]["f_manufacturer"].ToString();
                //    MessageBox.Show(exsistFamilyInfo + "___更新版本");
                //}

                #region  判断信息完整性
                int    upLoadKey          = 0;
                string familyValLevel     = null;
                string familyManufacturer = null;
                string familySource       = null;
                string familyDeviceType   = null;
                string familyName0        = null;

                if (cmb_ValLevel.Text == null)
                {
                    MessageBox.Show("请选择电压等级");
                }
                else
                {
                    familyValLevel = cmb_ValLevel.Text.ToString();
                    upLoadKey++;
                }

                if (txt_Manufacturer.Text == null || txt_Manufacturer.Text == "NA")
                {
                    MessageBox.Show("请填写厂家");
                }
                else
                {
                    familyManufacturer = txt_Manufacturer.Text.ToString();
                    upLoadKey++;
                }

                if (cmb_Source.Text == null || cmb_Source.Text == "NA")
                {
                    MessageBox.Show("请填写需要上传的族来源");
                }
                else
                {
                    familySource = cmb_Source.Text.ToString();
                    upLoadKey++;
                }


                if (txt_DeviceType == null || txt_DeviceType.Text == "NA")
                {
                    MessageBox.Show("请填写设备型号");
                }
                else
                {
                    familyDeviceType = txt_DeviceType.Text.ToString();
                    upLoadKey++;
                }

                familyName0 = dtUpload.Rows[i]["familyNamess"].ToString();

                if (upLoadKey < 4)
                {
                    MessageBox.Show("请将信息填写完整,否则无法上传!");
                }

                #endregion

                if (upLoadKey >= 4)
                {
                    originFamilyPath = dtUpload.Rows[i]["familyPathss"].ToString();
                    originFamilyName = dtUpload.Rows[i]["familyNamess"].ToString();
                    originParaPath   = dtUpload.Rows[i]["familyParass"].ToString();
                    originParaName   = Path.GetFileName(dtUpload.Rows[i]["familyParass"].ToString());
                    localPicPath     = dtUpload.Rows[i]["familyPicss"].ToString();

                    //FTP操作  需确定上传至文件服务器路径
                    var    ftp             = new FtpHelper0(serverIP, ftpUserName, ftpPassword);
                    string tagetFtpDir     = @"DB_Family_Library_FTP\" + lbl_ProText.Text + "\\" + lbl_TypeText.Text + "\\";
                    string tagetFtpDirPara = @"DB_Family_Library_FTP\paracast\";
                    //处理族文件名称路径
                    modifyFamilyPath = originFamilyPath.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originFamilyPath) + ".rfa";
                    modifyFamilyName = originFamilyName.Replace(".rfa", "") + "_" + ReviewLocalFamily.getFileMD5Hash(originFamilyPath) + ".rfa";
                    File.Copy(originFamilyPath, modifyFamilyPath, true);
                    //MessageBox.Show("族路径已处理" + modifyFamilyPath.ToString());

                    //处理表文件名称路径

                    modifyParaPath = originParaPath.Replace(".xls", "").Replace(originParaName, originFamilyName) + "_" + ReviewLocalFamily.getFileMD5Hash(originParaPath) + ".xls";
                    modifyParaName = originParaName.Replace(".xls", "").Replace(originParaName, originFamilyName) + "_" + ReviewLocalFamily.getFileMD5Hash(originParaPath) + ".xls";

                    File.Copy(originParaPath, modifyParaPath, true);
                    //MessageBox.Show("族路径已处理" + modifyParaPath.ToString());

                    //MessageBox.Show("族路径已处理\n\n" + modifyFamilyPath.ToString());
                    //MessageBox.Show("族路径已处理\n\n" + tagetFtpDir.ToString());
                    ftp.UploadFile(modifyFamilyPath.ToString(), tagetFtpDir);
                    ftp.UploadFile(modifyParaPath.ToString(), tagetFtpDirPara);
                    ftp.UploadFile(localPicPath, @"DB_Family_Library_FTP\pics\");

                    //sql同步操作

                    //SqlHelper.Con.Close();
                    //获取需填写内容
                    string familyLocation = ftpConnectionLocation + tagetFtpDir.Replace("\\", "/") + modifyFamilyName;

                    string familySize       = (ReviewLocalFamily.getFileSize(modifyFamilyPath) / 1024).ToString() + "KB";
                    string familyUploadDate = DateTime.Now.ToString();

                    string familyParaLocation       = null;
                    string familyConfigParaLocation = ftpConnectionLocation + "DB_Family_Library_FTP/paracast/" + modifyParaName;
                    string familyPicLocation        = ftpConnectionLocation + "DB_Family_Library_FTP/pics/" + Path.GetFileName(localPicPath);
                    //MessageBox.Show(familyPicLocation);

                    //开始sql语句操作
                    bool queryNum = false;
                    //string getFamilySQLSync = "INSERT INTO table_ParameterDefault (pmd_Resource,pmd_Location,pmd_Hash,pmd_Date) VALUES ('Administraror','" + paraLocation + "','" + paraHash + "','" + paraUploadDate + "'" + ");";
                    string getFamilySQLSync = "INSERT INTO table_p_Family "
                                              + "(f_Name,f_Path,f_Value,f_Pro,f_ValLevel,f_Cat,f_Hash,f_UploadDate,f_ParaLocation,f_ConfigParaLocation,f_manufacturer,f_Source,f_DeviceType,f_Pic) "
                                              + "VALUES ('" + familyName0
                                              + "','" + familyLocation
                                              + "','" + familySize
                                              + "','" + familyPro
                                              + "','" + familyValLevel
                                              + "','" + familyType
                                              + "','" + familyHash
                                              + "','" + familyUploadDate
                                              + "','" + familyParaLocation
                                              + "','" + familyConfigParaLocation
                                              + "','" + familyManufacturer
                                              + "','" + familySource
                                              + "','" + familyDeviceType
                                              + "','" + familyPicLocation + "')";
                    //MessageBox.Show(getFamilySQLSync);
                    //SqlHelper.Con.Close();
                    queryNum = SqlCompose.ExecuteSqlNonQuery(getFamilySQLSync);

                    if (queryNum != false)
                    {
                        count++;
                    }
                    //清除临时文件项
                    File.Delete(modifyFamilyPath);
                    File.Delete(modifyParaPath);
                }
                else
                {
                    MessageBox.Show("由于信息填写不全,目前无法上传。");
                }
            }
            MessageBox.Show("完成上传项" + count + "个");
        }