コード例 #1
0
        private void btnSavePCBFOVSetting_Click(object sender, EventArgs e)
        {
            string strOnLinePCBFOVIniFilePath = Path.Combine(strConfigIniPath, "FOVPCB.ini");


            string strLineInfo1  = this.tbxLineName1.Text + RS_AT + this.tbxLineIP1.Text + RS_AT + this.chkLineDis1.Checked.ToString().ToUpper();
            string strLineInfo2  = this.tbxLineName2.Text + RS_AT + this.tbxLineIP2.Text + RS_AT + this.chkLineDis2.Checked.ToString().ToUpper();
            string strLineInfo3  = this.tbxLineName3.Text + RS_AT + this.tbxLineIP3.Text + RS_AT + this.chkLineDis3.Checked.ToString().ToUpper();
            string strLineInfo4  = this.tbxLineName4.Text + RS_AT + this.tbxLineIP4.Text + RS_AT + this.chkLineDis4.Checked.ToString().ToUpper();
            string strLineInfo5  = this.tbxLineName5.Text + RS_AT + this.tbxLineIP5.Text + RS_AT + this.chkLineDis5.Checked.ToString().ToUpper();
            string strLineInfo6  = this.tbxLineName6.Text + RS_AT + this.tbxLineIP6.Text + RS_AT + this.chkLineDis6.Checked.ToString().ToUpper();
            string strLineInfo7  = this.tbxLineName7.Text + RS_AT + this.tbxLineIP7.Text + RS_AT + this.chkLineDis7.Checked.ToString().ToUpper();
            string strLineInfo8  = this.tbxLineName8.Text + RS_AT + this.tbxLineIP8.Text + RS_AT + this.chkLineDis8.Checked.ToString().ToUpper();
            string strLineInfo9  = this.tbxLineName9.Text + RS_AT + this.tbxLineIP9.Text + RS_AT + this.chkLineDis9.Checked.ToString().ToUpper();
            string strLineInfo10 = this.tbxLineName10.Text + RS_AT + this.tbxLineIP10.Text + RS_AT + this.chkLineDis10.Checked.ToString().ToUpper();
            string strLineInfo11 = this.tbxLineName11.Text + RS_AT + this.tbxLineIP11.Text + RS_AT + this.chkLineDis11.Checked.ToString().ToUpper();
            string strLineInfo12 = this.tbxLineName12.Text + RS_AT + this.tbxLineIP12.Text + RS_AT + this.chkLineDis12.Checked.ToString().ToUpper();
            string strLineInfo13 = this.tbxLineName13.Text + RS_AT + this.tbxLineIP13.Text + RS_AT + this.chkLineDis13.Checked.ToString().ToUpper();
            string strLineInfo14 = this.tbxLineName14.Text + RS_AT + this.tbxLineIP14.Text + RS_AT + this.chkLineDis14.Checked.ToString().ToUpper();
            string strLineInfo15 = this.tbxLineName15.Text + RS_AT + this.tbxLineIP15.Text + RS_AT + this.chkLineDis15.Checked.ToString().ToUpper();
            string strLineInfo16 = this.tbxLineName16.Text + RS_AT + this.tbxLineIP16.Text + RS_AT + this.chkLineDis16.Checked.ToString().ToUpper();



            if (File.Exists(strOnLinePCBFOVIniFilePath))
            {
                INIFileHelper.WriteIniData(iniSec, iniKeyLine1, strLineInfo1, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine2, strLineInfo2, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine3, strLineInfo3, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine4, strLineInfo4, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine5, strLineInfo5, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine6, strLineInfo6, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine7, strLineInfo7, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine8, strLineInfo8, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine9, strLineInfo9, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine10, strLineInfo10, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine11, strLineInfo11, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine12, strLineInfo12, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine13, strLineInfo13, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine14, strLineInfo14, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine15, strLineInfo15, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine16, strLineInfo16, strOnLinePCBFOVIniFilePath);
                //INIFileHelper.WriteIniData(iniSec, iniKeyLine17, strLineInfo2, strOnLinePCBFOVIniFilePath);
                //INIFileHelper.WriteIniData(iniSec, iniKeyLine2, strLineInfo2, strOnLinePCBFOVIniFilePath);
            }
            else
            {
                File.WriteAllText(strOnLinePCBFOVIniFilePath, string.Empty, Encoding.Default);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine1, strLineInfo1, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine2, strLineInfo2, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine3, strLineInfo3, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine4, strLineInfo4, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine5, strLineInfo5, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine6, strLineInfo6, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine7, strLineInfo7, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine8, strLineInfo8, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine9, strLineInfo9, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine10, strLineInfo10, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine11, strLineInfo11, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine12, strLineInfo12, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine13, strLineInfo13, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine14, strLineInfo14, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine15, strLineInfo15, strOnLinePCBFOVIniFilePath);
                INIFileHelper.WriteIniData(iniSec, iniKeyLine16, strLineInfo16, strOnLinePCBFOVIniFilePath);
            }
            int    iCount      = 0;
            string strRealInfo = string.Empty;

            if (this.chkLineDis1.Checked)
            {
                iCount++; strRealInfo += strLineInfo1 + RS_UP;
            }
            if (this.chkLineDis2.Checked)
            {
                iCount++; strRealInfo += strLineInfo2 + RS_UP;
            }
            if (this.chkLineDis3.Checked)
            {
                iCount++; strRealInfo += strLineInfo3 + RS_UP;
            }
            if (this.chkLineDis4.Checked)
            {
                iCount++; strRealInfo += strLineInfo4 + RS_UP;
            }
            if (this.chkLineDis5.Checked)
            {
                iCount++; strRealInfo += strLineInfo5 + RS_UP;
            }
            if (this.chkLineDis6.Checked)
            {
                iCount++; strRealInfo += strLineInfo6 + RS_UP;
            }
            if (this.chkLineDis7.Checked)
            {
                iCount++; strRealInfo += strLineInfo7 + RS_UP;
            }
            if (this.chkLineDis8.Checked)
            {
                iCount++; strRealInfo += strLineInfo8 + RS_UP;
            }
            if (this.chkLineDis9.Checked)
            {
                iCount++; strRealInfo += strLineInfo9 + RS_UP;
            }
            if (this.chkLineDis10.Checked)
            {
                iCount++; strRealInfo += strLineInfo10 + RS_UP;
            }
            if (this.chkLineDis11.Checked)
            {
                iCount++; strRealInfo += strLineInfo11 + RS_UP;
            }
            if (this.chkLineDis12.Checked)
            {
                iCount++; strRealInfo += strLineInfo12 + RS_UP;
            }
            if (this.chkLineDis13.Checked)
            {
                iCount++; strRealInfo += strLineInfo13 + RS_UP;
            }
            if (this.chkLineDis14.Checked)
            {
                iCount++; strRealInfo += strLineInfo14 + RS_UP;
            }
            if (this.chkLineDis15.Checked)
            {
                iCount++; strRealInfo += strLineInfo15 + RS_UP;
            }
            if (this.chkLineDis16.Checked)
            {
                iCount++; strRealInfo += strLineInfo16;
            }

            INIFileHelper.WriteIniData("fovpcb", "iCount", iCount + "", strOnLinePCBFOVIniFilePath);
            INIFileHelper.WriteIniData("fovpcb", "realInfo", strRealInfo, strOnLinePCBFOVIniFilePath);
            bool bTmp = true;

            if (iCount > 0)
            {
                string[] arrStrReal = strRealInfo.Split('|');
                foreach (string LineInfo in arrStrReal)
                {
                    if (string.IsNullOrEmpty(LineInfo))
                    {
                        continue;
                    }
                    string strTmpIP = LineInfo.Split('@')[1];
                    if (Directory.Exists("\\\\" + strTmpIP + "\\EYSPI"))
                    {
                    }
                    else
                    {
                        bTmp = false;
                        MessageBox.Show("网络链接错误 或 设备共享文件夹设置错误 !IP=>" + strTmpIP + "  线体=>" + LineInfo.Split('@')[0]);
                    }
                }
            }
            if (bTmp)
            {
                MessageBox.Show("保存成功");
            }
        }