Add project files.

This commit is contained in:
Thomas Savine
2020-03-06 16:07:06 +00:00
parent e7b186c7e3
commit 70de9715ce
300 changed files with 43679 additions and 0 deletions
@@ -0,0 +1,87 @@
using Sarand.Core.Tasks;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
// Operations Web Service Client
// Make requests to OperationsMgr Web Service hosted by Windows Service application.
//-----------------------------------------------------------------------
// Threading:
// Ref. https://blog.xamarin.com/getting-started-with-async-await/
//=======================================================================
public class OpnWebServiceClient
{
//-------------------------------------------------------------------
// Definitions.
public class RequestData : SacsTaskData
{
/// <summary>
/// Web Service Request data.
/// <para>Cancellation token can optionally be supplied if available higher up the chain.</para>
/// </summary>
public RequestData (OpnWebServiceInstanceDefinition instanceDefinition, CancellationToken? cancellationToken) :
base(cancellationToken)
{
InstanceDefintion = instanceDefinition;
}
public OpnWebServiceInstanceDefinition InstanceDefintion { get; }
public String Data { get; set; } = "";
}
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceClient ()
{
}
//-------------------------------------------------------------------
// Properties.
//-------------------------------------------------------------------
// I s A l i v e
//-------------------------------------------------------------------
public async Task<bool> RequestIsAlive (OpnWebServiceInstanceDefinition instanceDefinition)
{
return false;
}
//-------------------------------------------------------------------
// I t e m C o u n t R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// Q u e r y L i s t R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// I t e m L i s t R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// I t e m D a t a R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// E x t r a c t I t e m
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// S t o r e I t e m R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
// W e b S e r v i c e R e q u e s t
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public static class OpnWebServiceDfn
{
//-------------------------------------------------------------------
// Web Service XML element names.
public class ElementNameData
{
}
public static ElementNameData ElementName { get; } = new ElementNameData();
//-------------------------------------------------------------------
// Web Service XML attribute names.
public class AttributeNameData
{
}
public static AttributeNameData AttributeName { get; } = new AttributeNameData();
//-------------------------------------------------------------------
// Properties.
public static String IsAliveResponse { get; } = "Hello";
public static String StatusSuccess { get; } = "OK";
public static String StatusFatal { get; } = "Fatal";
public static String StatusError { get; } = "Error";
public static String StatusWarning { get; } = "Warning";
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public class OpnWebServiceInstanceDefinition
{
//-------------------------------------------------------------------
// Definitions.
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceInstanceDefinition (String caption, String url)
{
Caption = caption;
URL = url;
}
//-------------------------------------------------------------------
// Properties.
public String Caption { get; }
public String URL { get; }
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,119 @@
using Sarand.Core.Base;
using Sarand.Core.Bus;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public class OpnWebServiceItemData
{
//-------------------------------------------------------------------
// Data members.
private readonly Dictionary<String, String> values = new Dictionary<String, String>();
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceItemData (String itemType)
{
ItemType = itemType;
}
//-------------------------------------------------------------------
// Properties.
public String ItemType { get; }
//-------------------------------------------------------------------
// Population.
public void AddValue (String name, String value)
{
values[name] = value;
}
//-------------------------------------------------------------------
// Value exists.
public bool HasValue<T> (T name)
{
return HasValue(name.ToString());
}
public bool HasValue (string name)
{
return values.ContainsKey(name);
}
//-------------------------------------------------------------------
// String value.
public String GetValue<T> (T name)
{
return GetValue(name.ToString());
}
public String GetValue (string name)
{
return values.GetValue(name, "");
}
//-------------------------------------------------------------------
// SysId value.
public SysId GetIdValue<T> (T name)
{
return GetIdValue(name.ToString());
}
public SysId GetIdValue (string name)
{
return new SysId(StringUtil.ToInt(GetValue(name)));
}
//-------------------------------------------------------------------
// Bool value.
public bool GetBoolValue<T> (T name)
{
return GetBoolValue(name.ToString());
}
public bool GetBoolValue (string name)
{
return StringUtil.ToBool(GetValue(name));
}
// Int value.
public int GetIntValue<T> (T name)
{
return GetIntValue(name.ToString());
}
public int GetIntValue (string name)
{
return StringUtil.ToInt(GetValue(name));
}
// Decimal value.
public decimal GetDecimalValue<T> (T name)
{
return GetDecimalValue(name.ToString());
}
public decimal GetDecimalValue (string name)
{
return StringUtil.ToDecimal(GetValue(name));
}
//-------------------------------------------------------------------
// Date value.
public DateTime GetDateValue<T> (T name)
{
return GetDateValue(name.ToString());
}
public DateTime GetDateValue (string name)
{
return DateUtil.ParseXmlDate(GetValue(name));
}
// DateTime value.
public DateTime GetDateTimeValue<T> (T name)
{
return GetDateTimeValue(name.ToString());
}
public DateTime GetDateTimeValue (string name)
{
return DateUtil.ParseXmlDateTime(GetValue(name));
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,38 @@
using Sarand.Core.Base;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public class OpnWebServiceMessage
{
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceMessage (string context, String code, String message, SaMessageLevel level = SaMessageLevel.Info)
{
Level = level;
Context = context;
Code = code;
Message = message;
}
//-------------------------------------------------------------------
// Properties.
public SaMessageLevel Level { get; }
public string Context { get; }
public string Code { get; }
public string Message { get; }
//-------------------------------------------------------------------
}
//=======================================================================
public static class OpnWebServiceMessageList
{
}
//=======================================================================
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public class OpnWebServiceRequest
{
//-------------------------------------------------------------------
// Definitions.
public enum RequestType
{
Unknown,
IsAlive,
/// <summary>Item count</summary>
Count,
/// <summary>Query list - specific columns, compressed (csv etc) response data</summary>
QueryList,
/// <summary>Item list - full xml for each item with optional associated items.</summary>
ItemList,
/// <summary>Single Item with optional associated items.</summary>
Item,
/// <summary>Validate item properties without update.</summary>
Validate,
/// <summary>Validate properties and store (insert/update) item.</summary>
Store,
/// <summary>Delete item.</summary>
Delete,
}
public enum DataType
{
Unknown,
}
//-------------------------------------------------------------------
/// <summary>
/// Sort column identified by column name with ascending flag.
/// </summary>
public class SortColumnData
{
public SortColumnData (String columnName, bool ascending)
{
ColumnName = columnName;
Ascending = ascending;
}
public String ColumnName { get; }
public bool Ascending { get; }
}
//-------------------------------------------------------------------
// Configuration.
public class Config
{
public bool SoapEnvelope { get; set; }
public String SoapPrefix { get; set; }
public DataType DataType { get; set; }
public RequestType RequestType { get; set; }
public class ContextProperties
{
public bool Commit { get; set; }
public bool Debug { get; set; }
}
public ContextProperties Context { get; } = new ContextProperties();
}
//-------------------------------------------------------------------
// Data members.
private readonly Config config;
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceRequest (Config config)
{
this.config = config;
}
//-------------------------------------------------------------------
// Properties.
public Dictionary<String, String> Filters { get; } = new Dictionary<string, string>();
public List<String> Columns { get; } = new List<String>();
public List<String> SortColumns { get; } = new List<String>();
public XElement ItemElement { get; set; }
//-------------------------------------------------------------------
// D a t a G e n e r a t i o n
//-------------------------------------------------------------------
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,42 @@
using Sarand.Core.Net;
using System;
using System.Collections.Generic;
using System.Text;
namespace Sarand.OperationsMgr.Core.WebService
{
//=======================================================================
public class OpnWebServiceResponse
{
//-------------------------------------------------------------------
// Definitions.
//-------------------------------------------------------------------
// Configuration.
public class Config
{
public DateTime RequestStarted { get; set; } = DateTime.Now;
public DateTime RequestCompleted { get; set; }
public SacsHttpResponseData HttpResponseData { get; set; }
}
//-------------------------------------------------------------------
// Data members.
protected readonly Config config;
//-------------------------------------------------------------------
// Construction.
public OpnWebServiceResponse (Config config)
{
}
public OpnWebServiceResponse (OpnWebServiceResponse serviceResponse)
{
}
//-------------------------------------------------------------------
// Properties.
//-------------------------------------------------------------------
}
//=======================================================================
}