init
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace DatabaseExport
|
||||
{
|
||||
public class TemplateRegion
|
||||
{
|
||||
public string TemplateName { get; }
|
||||
|
||||
public string TemplateZone { get; }
|
||||
|
||||
public int RegionNumber { get; set; }
|
||||
|
||||
public string RegionName { get; set; }
|
||||
|
||||
public string RegionDescription { get; set; }
|
||||
|
||||
public string TestObject { get; set; }
|
||||
|
||||
public string Position { get; set; }
|
||||
|
||||
public string MainLocation { get; set; }
|
||||
|
||||
public string FineLocation1 { get; set; }
|
||||
|
||||
public string FineLocation2 { get; set; }
|
||||
|
||||
public string FineLocation3 { get; set; }
|
||||
|
||||
public string PhysicalDimension { get; set; }
|
||||
|
||||
public string Direction { get; set; }
|
||||
|
||||
public string FilterClass { get; set; }
|
||||
|
||||
public bool LocalOnly { get; } = false;
|
||||
|
||||
private int _upperLeftX = 0;
|
||||
private int _upperLeftY = 0;
|
||||
private int _lowerRightX = 0;
|
||||
private int _lowerRightY = 0;
|
||||
|
||||
public System.Drawing.Point UpperLeft
|
||||
{
|
||||
get => new System.Drawing.Point(_upperLeftX, _upperLeftY);
|
||||
set { _upperLeftX = value.X; _upperLeftY = value.Y; }
|
||||
}
|
||||
|
||||
public System.Drawing.Point LowerRight
|
||||
{
|
||||
get => new System.Drawing.Point(_lowerRightX, _lowerRightY);
|
||||
set { _lowerRightX = value.X; _lowerRightY = value.Y; }
|
||||
}
|
||||
|
||||
public TemplateRegion(string templateName, string zoneName, bool bLocalOnly)
|
||||
{
|
||||
TemplateName = templateName;
|
||||
TemplateZone = zoneName;
|
||||
LocalOnly = bLocalOnly;
|
||||
}
|
||||
|
||||
public TemplateRegion(DataRow dr)
|
||||
{
|
||||
TemplateName = (string)dr["TemplateName"];
|
||||
RegionNumber = Convert.ToInt32(dr["RegionNumber"]);
|
||||
RegionName = (string)dr["RegionName"];
|
||||
RegionDescription = (string)dr["RegionDescription"];
|
||||
TestObject = (string)dr["TestObject"];
|
||||
Position = (string)dr["Position"];
|
||||
MainLocation = (string)dr["MainLocation"];
|
||||
FineLocation1 = (string)dr["FineLocation1"];
|
||||
FineLocation2 = (string)dr["FineLocation2"];
|
||||
FineLocation3 = (string)dr["FineLocation3"];
|
||||
PhysicalDimension = (string)dr["PhysicalDimension"];
|
||||
Direction = (string)dr["Direction"];
|
||||
FilterClass = (string)dr["FilterClass"];
|
||||
LocalOnly = Convert.ToBoolean(dr["LocalOnly"]);
|
||||
_upperLeftX = Convert.ToInt32(dr["UpperLeftX"]);
|
||||
_upperLeftY = Convert.ToInt32(dr["UpperLeftY"]);
|
||||
_lowerRightX = Convert.ToInt32(dr["LowerRightX"]);
|
||||
_lowerRightY = Convert.ToInt32(dr["LowerRightY"]);
|
||||
TemplateZone = (string)dr["ZoneName"];
|
||||
}
|
||||
|
||||
internal static TemplateRegion[] GetAllRegions(string templateName, string zoneName)
|
||||
{
|
||||
var regions = new List<TemplateRegion>();
|
||||
try
|
||||
{
|
||||
using (var sql = DbOperations.GetCommand())
|
||||
{
|
||||
DbOperations.CreateParam(sql, "@TemplateName", SqlDbType.NVarChar, templateName);
|
||||
DbOperations.CreateParam(sql, "@ZoneName", SqlDbType.NVarChar, zoneName);
|
||||
|
||||
sql.CommandText = "SELECT * from tblTemplateRegions where [TemplateName]=@TemplateName and [ZoneName]=@ZoneName";
|
||||
using (var ds = DbOperations.Connection.QueryDataSet(sql))
|
||||
{
|
||||
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow dr in ds.Tables[0].Rows)
|
||||
{
|
||||
try
|
||||
{
|
||||
regions.Add(new TemplateRegion(dr));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve a region", templateName, ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//DTS.Utilities.Logging.APILogger.Log("Failed to retrieve regions", templateName, ex);
|
||||
}
|
||||
return regions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user