임의의 값을 삽입하기 위한 NetLogic 개발

임의의 값을 삽입하기 위한 NetLogic 개발

이 NetLogic 스크립트는 데이터베이스의
Table1
테이블에 임의의 값을 삽입합니다.
필수 구성 요소
기본 외부 코드 편집기를 설정합니다. 기본 코드 편집기 설정 항목을 참조하십시오.
  1. NetLogic을 개발하려면
  2. 프로젝트 보기
    에서
    데이터 저장소
    폴더를 확장합니다.
  3. 데이터베이스를 마우스 오른쪽 버튼으로 클릭하고
    새로 만들기
    런타임 NetLogic
    을 선택합니다.
  4. NetLogic 위로 마우스를 가져가서
    Edit
    을 선택하고
    EmbeddedDatabase1NetLogic
    을 입력합니다.
  5. NetLogic을 두 번 클릭합니다.
    외부 코드 편집기가 열립니다.
  6. 코드 편집기에서 기존 코드를 다음 코드로 바꿉니다.
    #region Using directives using System; using FTOptix.HMIProject; using FTOptix.NetLogic; using FTOptix.Store; #endregion public class EmbeddedDatabase1NetLogic : 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 InsertRandomValues (){ // Get the current project folder. var project = Project.Current; // Save the names of the columns of the table to an array string[] columns = { "Column1", "Column2", "Column3" }; // Create and populate a matrix with values to insert into the odbc table var rawValues = new object[1000, 3]; Random randomNumber = new Random (); for (UInt16 i = 0; i < 1000; ++i) { // Column1 rawValues[i, 0] = i; // Column2 rawValues[i, 1] = randomNumber.Next(0, 5000); // Column3 rawValues[i, 2] = randomNumber.NextDouble() * 5000; } var myStore = LogicObject.Owner as Store; // Get Table1 from myStore var table1 = myStore.Tables.Get<Table>("Table1"); // Insert values into table1 table1.Insert(columns, rawValues); } }
  7. 코드를 저장합니다.
의견을 작성 부탁드립니다.
이 자료에 대한 문의사항이나 요청사항이 있습니까? 여기에 요청사항을 작성 부탁드립니다.
Normal