Create a NetLogic that adds random data

This NetLogic generates random strings and adds them into the default embedded database.
Prerequisites
Set the default external code editor. See Set the default code editor.
  1. In
    Project view
    , right-click the
    NetLogic
    folder and select
    New
    Runtime NetLogic
    .
  2. Hover-over the NetLogic, select
    Edit
    Edit
    , and enter
    GenerateRandomStrings
    .
  3. Double-click the NetLogic.
    The external code editor opens.
  4. In the code editor, replace the existing code with the following code:
    #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"); } } }
  5. Save the code.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.