创建用于添加随机数据的 NetLogic

此 NetLogic 生成随机字符串,并将它们添加到默认的嵌入式数据库中。
先决条件
设置默认外部代码编辑器。请参见设置默认代码编辑器
  1. 创建用于添加随机数据的 NetLogic
  2. 项目视图
    中,右键单击
    NetLogic
    文件夹,然后选择
    新建
    运行时 NetLogic
  3. 将光标悬停在 NetLogic 上,选择
    Edit
    并输入
    GenerateRandomStrings
  4. 双击 NetLogic。
    外部代码编辑器将打开。
  5. 在代码编辑器中,使用以下代码替换现有代码:
    #region StandardUsing using System; using FTOptix.HMIProject; using UAManagedCore; using FTOptix.SQLiteStore; using FTOptix.Store; #endregion public class GenerateRandomStrings : FTOptix.NetLogic.BaseNetLogic { [FTOptix.NetLogic.ExportMethod] public void RunQuery() { Guid g = new Guid(); Random random = new Random(); var store = Project.Current.GetObject("DataStores"); ; string[] columnName = { "Column1" }; var internalDatabase = store.Children.Get<FTOptix.Store.Store>("RandomStringsDataStore"); var table = internalDatabase.Tables.Get<FTOptix.Store.Table>("Table1"); var numbers = new object[150, 1]; for (int i = 0; i < 150; i++) { numbers[i, 0] = Guid.NewGuid().ToString(); //numbers[i, 0] = random.Next(); } table.Insert(columnName, numbers); if (store == null || table == null) { Log.Info("Something is null"); } } }
  6. 保存代码。
提供反馈
对本文档有问题或反馈吗? 请在这里提交您的反馈