Beispiel #1
0
        private void btnadddecision_Click(object sender, EventArgs e)
        {
            DecisionForm dform = new DecisionForm(txb_num_pl.Text, this);

            dform.ShowDialog();
        }
Beispiel #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()); }
            }
        }