0% found this document useful (0 votes)
2 views

CodeParsing_Script

Uploaded by

treekengmanow
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CodeParsing_Script

Uploaded by

treekengmanow
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Text;
using System.Collections;
using System.Collections.Generic;
using ETS.Core.Api;
using ETS.Core.Extensions;
using ETS.Core.Scripting;
using System.Text.RegularExpressions;
using System.Data;
using BDF.Mes.Global;

namespace ETS.Core.Scripting.Modules
{
public class CodeParsing
{
private ETS.Core.Api.ApiService _api;
private int FREEFORMTEXT_MAX = 16;
private int TOTALTEXT_MAX = 30;
/// ******************************************************************
public CodeParsing(ETS.Core.Api.ApiService api)
{
_api = api;
}

///*************************************************************
public string GetIPAddr(int systemID)
{
var deviceType =
_api.Data.DbDeviceType.Load.ByKey((string)BdfConstants.DeviceTypeKey.DBC);
int deviceTypeID = deviceType.ID;

string sql = @"DECLARE @SystemID INT = {0}


SELECT DISTINCT d.Identifier, d.Name
FROM tDevice d
INNER JOIN viewCustomPropertyDevice vwCP ON vwCP.ID = d.ID
WHERE
d.SystemID = @SystemID
AND vwCP.[{1}] = {2}
AND d.DeviceTypeID = {3}".FormatWith(systemID.ToSql(),
BdfConstants.CustomPropertyKey.DeviceEnabled, 1, deviceTypeID);

var result = _api.Util.Db.ExecuteScalar<string>(sql);


if(!result.Success) { _api.Util.Log.WriteWarningsFromResultObject(result,
"DBC DMS Module"); }

return result.Return;
}

///*************************************************************
public int GetPortNumber(int systemID)
{
var deviceType =
_api.Data.DbDeviceType.Load.ByKey((string)BdfConstants.DeviceTypeKey.DBC);
int deviceTypeID = deviceType.ID;
string columnName = (string)BdfConstants.CustomPropertyKey.DeviceDbcPort;

string sql = @"DECLARE @SystemID INT = {0}


SELECT vwCP.{3}
FROM tDevice d
INNER JOIN viewCustomPropertyDevice vwCP ON d.ID = vwCP.ID
WHERE d.SystemID = @SystemID
AND vwCP.[{4}] = {1}
AND d.DeviceTypeID = {2}".FormatWith(systemID.ToSql(), 1, deviceTypeID,
columnName, BdfConstants.CustomPropertyKey.DeviceEnabled);

var result = _api.Util.Db.ExecuteScalar<int>(sql);


if(!result.Success) { _api.Util.Log.WriteWarningsFromResultObject(result,
"DBC DMS Module"); }

return result.Return;
}

///*************************************************************

}
}

You might also like