• 大小: 0.67M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-27
  • 语言: C#
  • 标签: WinFrom  Csharp  ROM  rp  AR  

资源简介


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Windows.Forms;
using PISDK;

namespace CSharpSnapshotWinFrom
{
    public partial class Form1 : Form
    {

     //
     // Global Data
     //
        PISDK.PISDK piSDK;
        PISDKDlg.Applicationobject piSDKDlgAppobject;   // PISDK dialog app. object
        Server server;

        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender EventArgs e)
        {
            PIConnect();
        }

        private void PIConnect() 
        {

            try
            {
                piSDK = new PISDK.PISDKClass(); //创建PISDKClass对象,并使接口piSDK指向它
                piSDKDlgAppobject = new PISDKDlg.ApplicationobjectClass();

                /*   foreach (Server srv in piSDK.Servers) {
                     lstServer.Items.Add(srv.Name);

                };*/
                // 对ListBox控件lstServer进行初始化,使其列出服务器列表中的所有服务器名
                foreach (Server srv in piSDK.Servers)
                {
                    LstServerBox.Items.Add(srv.Name);

                };
                // 使lstServer控件的选中项为默认服务器名
                LstServerBox.SelectedItem = piSDK.Servers.DefaultServer.Name;
                // 使PI用户为默认服务器的默认用户
                UserName.Text = piSDK.Servers.DefaultServer.DefaultUser;
                // 使接口server指向默认服务器
                // server = piSDK.Servers[LstServerBox.SelectedItem.ToString()];

                if (server!=null && server.Connected)
                {
                    server.Close();
                    ConnectionSataus.Text = “未连接“;
                }

            }
            catch (System.Runtime.InteropServices.COMException comExc)
            {
                MessageBox.Show(comExc.Message comExc.ErrorCode + “Error“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);

            };
        }

        private void LstServerBox_SelectedIndexChanged(object sender EventArgs e)
        {
            server = piSDK.Servers[LstServerBox.SelectedItem.ToString()];
            UserName.Text = server.DefaultUser;
            if (server != null && server.Connected)
            {
                server.Close();
                ConnectionSataus.Text = “请重新建立连接“;
            }
        }

        private void Connect_Click(object sender EventArgs e)
        {
            try
            {
                server = piSDK.Servers[LstServerBox.SelectedItem.ToString()];
                string connectString = string.Format(“UID={0};PWD={1}“ UserName.Text Password.Text);
                server.Open(connectString);
              

                if (server != null && server.Connected)
                {
                    ConnectionSataus.Text = (“通过“ + server.Conn

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-10-22 02:36  CSharpSnapshotWinFrom\
     目录           0  2020-10-10 22:32  CSharpSnapshotWinFrom\.vs\
     目录           0  2020-10-10 22:32  CSharpSnapshotWinFrom\.vs\CSharpSnapshotWinFrom\
     目录           0  2020-10-10 22:32  CSharpSnapshotWinFrom\.vs\CSharpSnapshotWinFrom\v16\
     文件       77824  2020-10-22 02:36  CSharpSnapshotWinFrom\.vs\CSharpSnapshotWinFrom\v16\.suo
     文件         170  2020-10-21 10:42  CSharpSnapshotWinFrom\App.config
     目录           0  2020-10-10 22:32  CSharpSnapshotWinFrom\bin\
     目录           0  2020-10-10 10:00  CSharpSnapshotWinFrom\bin\Debug\
     目录           0  2020-10-10 14:14  CSharpSnapshotWinFrom\bin\Release\
     目录           0  2020-10-10 22:50  CSharpSnapshotWinFrom\bin\x64\
     目录           0  2020-10-10 14:15  CSharpSnapshotWinFrom\bin\x64\Debug\
     目录           0  2020-10-21 18:49  CSharpSnapshotWinFrom\bin\x86\
     目录           0  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\
     文件      194379  2020-10-21 11:18  CSharpSnapshotWinFrom\bin\x86\Debug.zip
     目录           0  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\app.publish\
     文件       22016  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\app.publish\CSharpSnapshotWinFrom.exe
     文件        1686  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\CSharpSnapshotWinFrom.application
     文件       20992  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\CSharpSnapshotWinFrom.exe
     文件         170  2020-10-21 10:42  CSharpSnapshotWinFrom\bin\x86\Debug\CSharpSnapshotWinFrom.exe.config
     文件        7668  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\CSharpSnapshotWinFrom.exe.manifest
     文件       40448  2020-10-22 02:36  CSharpSnapshotWinFrom\bin\x86\Debug\CSharpSnapshotWinFrom.pdb
     文件           0  2020-10-20 09:22  CSharpSnapshotWinFrom\bin\x86\Debug\log.txt
     文件      281376  2019-08-19 07:55  CSharpSnapshotWinFrom\bin\x86\Debug\OSIsoft.PISDK.dll
     文件       56096  2019-08-19 07:55  CSharpSnapshotWinFrom\bin\x86\Debug\OSIsoft.PISDKCommon.dll
     文件       27488  2019-08-19 07:59  CSharpSnapshotWinFrom\bin\x86\Debug\OSIsoft.PISDKCtl.dll
     文件       27488  2019-08-19 07:59  CSharpSnapshotWinFrom\bin\x86\Debug\OSIsoft.PISDKDlg.dll
     文件       47904  2019-08-19 07:55  CSharpSnapshotWinFrom\bin\x86\Debug\OSIsoft.PITimeServer.dll
     目录           0  2020-10-21 18:49  CSharpSnapshotWinFrom\bin\x86\Release\
     目录           0  2020-10-21 18:49  CSharpSnapshotWinFrom\bin\x86\Release\app.publish\
     文件       18432  2020-10-21 10:36  CSharpSnapshotWinFrom\bin\x86\Release\app.publish\CSharpSnapshotWinFrom.exe
     文件        1889  2020-10-21 10:36  CSharpSnapshotWinFrom\bin\x86\Release\CSharpSnapshotWinFrom.application
............此处省略70个文件信息

评论

共有 条评论