ReSharper: - ServiceCore, RelatePcb
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using ByteArrayStyle;
|
||||
using Newtonsoft.Json;
|
||||
using Service.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -9,6 +8,7 @@ using System.Text;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.Csd;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.Vako;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
|
||||
namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using Service.Core;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.KitronTestResults;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
|
||||
namespace Xylem.Common.Logic.ProductionOrderCore.OrderData
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using Service.Core;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
|
||||
namespace Xylem.Common.Logic.ProductionOrderCore.Vako
|
||||
{
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Xylem.Common.Logic.RelatePcb
|
||||
}
|
||||
using (var sr = new StreamReader(responseStream))
|
||||
{
|
||||
var responseJson = sr.ReadToEnd();
|
||||
sr.ReadToEnd();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Service.Core
|
||||
{
|
||||
}
|
||||
@@ -82,7 +82,6 @@
|
||||
<Compile Include="..\..\.shared\SharedAssemblyInfo.cs">
|
||||
<Link>Properties\SharedAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="DatabaseApiController.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SqlDataAccess.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -5,22 +5,22 @@ using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Service.Core
|
||||
namespace Xylem.Common.Logic.ServiceCore
|
||||
{
|
||||
public class SqlDataAccess : IDisposable
|
||||
{
|
||||
private string _connectionString = "";
|
||||
public SqlDataAccess(string ConnectionString)
|
||||
private readonly String _connectionString;
|
||||
public SqlDataAccess(String connectionString)
|
||||
{
|
||||
_connectionString = ConnectionString;
|
||||
_connectionString = connectionString;
|
||||
}
|
||||
|
||||
public string GenerateParam<T>(string name, string typeName,T value)
|
||||
public String GenerateParam<T>(String name, String typeName,T value)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"Declare @{name} as {typeName}" );
|
||||
|
||||
if (value is string)
|
||||
if (value is String)
|
||||
{
|
||||
sb.AppendLine($"set @{name} = '%{value.ToString()}%' ");
|
||||
return sb.ToString();
|
||||
@@ -32,12 +32,12 @@ namespace Service.Core
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
if (value is int)
|
||||
if (value is Int32)
|
||||
{
|
||||
var tmp = Convert.ToInt32(value);
|
||||
sb.Append(tmp.ToString());
|
||||
}
|
||||
if (value is bool)
|
||||
if (value is Boolean)
|
||||
{
|
||||
var tmp = Convert.ToBoolean(value);
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Service.Core
|
||||
/// Creating a database connection if there is none.
|
||||
/// </summary>
|
||||
/// <remarks>Working with a global connection variable to make sure the connection would be closed at the end of working with it.</remarks>
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
private void CreateConnection()
|
||||
{
|
||||
if (_con == null)
|
||||
@@ -67,7 +68,7 @@ namespace Service.Core
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable ExecuteQuery(string sqlStatement, List<SqlParameter> parameter = null)
|
||||
public DataTable ExecuteQuery(String sqlStatement, List<SqlParameter> parameter = null)
|
||||
{
|
||||
DataTable ret;
|
||||
SqlConnection connection = null;
|
||||
@@ -92,7 +93,7 @@ namespace Service.Core
|
||||
}
|
||||
}
|
||||
reader = cmd.ExecuteReader();
|
||||
var entries = new object[reader.FieldCount];
|
||||
var entries = new Object[reader.FieldCount];
|
||||
ret = new DataTable();
|
||||
|
||||
var jcount = 0;
|
||||
@@ -107,11 +108,11 @@ namespace Service.Core
|
||||
var headline = reader.GetName(i);
|
||||
if (!ret.Columns.Contains(headline))
|
||||
{
|
||||
ret.Columns.Add(headline, Type.GetType("System.Object"));
|
||||
ret.Columns.Add(headline, Type.GetType("System.Object") ?? typeof(String));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.Columns.Add(headline + Guid.NewGuid().ToString(), Type.GetType("System.Object"));
|
||||
ret.Columns.Add(headline + Guid.NewGuid(), Type.GetType("System.Object") ?? typeof(String));
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +145,10 @@ namespace Service.Core
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
if (connection != null && connection.State == ConnectionState.Open)
|
||||
{
|
||||
@@ -155,13 +159,6 @@ namespace Service.Core
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
/// Executing Stored Procedure
|
||||
/// </summary>
|
||||
/// <param name="storedProcedure"> The Name of Stored Procedure</param>
|
||||
/// <param name="values">Parameter names and values</param>
|
||||
/// <returns>Result Set</returns>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Closing and disposing the connection.
|
||||
@@ -183,7 +180,8 @@ namespace Service.Core
|
||||
/// </summary>
|
||||
/// <param name="parameter">array to work on</param>
|
||||
/// <returns>comma seperated string with parameters.</returns>
|
||||
private string GenerateParameter(string[] parameter)
|
||||
// ReSharper disable once UnusedMember.Local
|
||||
private String GenerateParameter(String[] parameter)
|
||||
{
|
||||
var list = new StringBuilder();
|
||||
var ret = "";
|
||||
@@ -198,8 +196,8 @@ namespace Service.Core
|
||||
|
||||
var result = param;
|
||||
var content = param;
|
||||
const string mitpat = @"(?:^@\w[\w_\s]*=[\s]*(?:'(.*)'$|(.*)$)|^(?:'(.*)'$|(.*)$))";
|
||||
const string numbpat = @"^[+-]?(?:\d+\.?|,?\d*|\d*(\.?|,?)\d+)[\r\n]*$";
|
||||
const String mitpat = @"(?:^@\w[\w_\s]*=[\s]*(?:'(.*)'$|(.*)$)|^(?:'(.*)'$|(.*)$))";
|
||||
const String numbpat = @"^[+-]?(?:\d+\.?|,?\d*|\d*(\.?|,?)\d+)[\r\n]*$";
|
||||
|
||||
if (!first || !result.Contains(","))
|
||||
{
|
||||
@@ -212,7 +210,7 @@ namespace Service.Core
|
||||
var mch = Regex.Replace(orig, "[']+", "'");
|
||||
mch = Regex.Replace(mch, "[']+", "''");
|
||||
|
||||
result = !String.IsNullOrEmpty(mch) ? content.Replace(orig, mch) : content;
|
||||
result = !string.IsNullOrEmpty(mch) ? content.Replace(orig, mch) : content;
|
||||
}
|
||||
else if (mtch.Groups[2].Success)
|
||||
{
|
||||
@@ -220,7 +218,7 @@ namespace Service.Core
|
||||
var mch = Regex.Replace(orig, "[']+", "'");
|
||||
mch = Regex.Replace(mch, "[']+", "''");
|
||||
|
||||
if (!String.IsNullOrEmpty(mch))
|
||||
if (!string.IsNullOrEmpty(mch))
|
||||
{
|
||||
if (Regex.IsMatch(mch, numbpat) || mch.ToLower() == "null")
|
||||
{
|
||||
@@ -242,7 +240,7 @@ namespace Service.Core
|
||||
var mch = Regex.Replace(orig, "[']+", "'");
|
||||
mch = Regex.Replace(mch, "[']+", "''");
|
||||
|
||||
result = !String.IsNullOrEmpty(mch) ? content.Replace(orig, mch) : content;
|
||||
result = !string.IsNullOrEmpty(mch) ? content.Replace(orig, mch) : content;
|
||||
}
|
||||
else if (mtch.Groups[4].Success)
|
||||
{
|
||||
@@ -250,7 +248,7 @@ namespace Service.Core
|
||||
var mch = Regex.Replace(orig, "[']+", "'");
|
||||
mch = Regex.Replace(mch, "[']+", "''");
|
||||
|
||||
if (!String.IsNullOrEmpty(mch))
|
||||
if (!string.IsNullOrEmpty(mch))
|
||||
{
|
||||
if (Regex.IsMatch(mch, numbpat) || mch.ToLower() == "null")
|
||||
{
|
||||
@@ -280,7 +278,7 @@ namespace Service.Core
|
||||
|
||||
|
||||
|
||||
public string GetConnectionString()
|
||||
public String GetConnectionString()
|
||||
{
|
||||
//if (_conifg.SupportConnectionString)
|
||||
//{
|
||||
|
||||
Reference in New Issue
Block a user