开发用于处理登录的 NetLogic

此 NetLogic 用于验证用户名和密码。
先决条件
设置默认外部代码编辑器。请参见设置默认代码编辑器
  1. 开发用于处理登录的 NetLogic
  2. 项目视图
    中,双击
    LoginFormNetLogic
    将在单独的选项卡中打开外部代码编辑器。
  3. 在代码编辑器中,使用以下代码替换现有代码:
    #region Using directives using System; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.HMIProject; using FTOptix.UI; using FTOptix.NativeUI; using FTOptix.Core; using FTOptix.CoreBase; using FTOptix.NetLogic; #endregion public class LoginFormNetLogic : BaseNetLogic { public override void Start() { // Insert code to be executed when the user-defined logic is started } public override void Stop() { // Insert code to be executed when the user-defined logic is stopped } [ExportMethod] public void Login(string username, string password) { if (!PerformLogin(username, password)) { // Set incorrect login message var messageVariable = LogicObject.GetVariable("Message"); messageVariable.Value = "Incorrect login"; return; } // Check the correct type of PanelLoader PanelLoader panelLoader = (PanelLoader)Owner.Owner; if (panelLoader == null) { Log.Error(panelLoader + " is not a PanelLoader"); return; } // Retrieve Panel variable var panelVariable = (NodeId)LogicObject.GetVariable("Panel").Value; if (panelVariable == NodeId.Empty) { Log.Error("Panel variable is empty"); return; } // Perform ChangePanel panelLoader.ChangePanel(panelVariable, NodeId.Empty); } private bool PerformLogin(string username, string password) { return Session.ChangeUser(username, password); } }
  4. 保存代码。
提供反馈
对本文档有问题或反馈吗? 请在这里提交您的反馈