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.
- InProject view, right-click theNetLogicfolder and select .
- Hover-over the NetLogic, selectEditGenerateRandomStrings.
- Double-click the NetLogic.The external code editor opens.
- 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"); } } }
- Save the code.
Provide Feedback