-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
310 changed files
with
37,027 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<Description>Agni OS Main Assembly</Description> | ||
</PropertyGroup> | ||
|
||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<OutputPath>..\..\out\Debug\</OutputPath> | ||
<DocumentationFile>..\..\out\Debug\Agni.xml</DocumentationFile> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<OutputPath>..\..\out\Release\</OutputPath> | ||
<DocumentationFile>..\..\out\Release\Agni.xml</DocumentationFile> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> | ||
<Exec Command="$(ProjectDir)pre-build $(SolutionDir) $(ConfigurationName)" /> | ||
</Target> | ||
|
||
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> | ||
<Exec Command="$(ProjectDir)post-build $(SolutionDir) $(ConfigurationName)" /> | ||
</Target> | ||
|
||
<ItemGroup> | ||
<None Remove="BUILD_INFO.txt" /> | ||
<None Remove="Hosts\agdida\Welcome.txt" /> | ||
<None Remove="Hosts\ahgov\Welcome.txt" /> | ||
<None Remove="Hosts\aph\Welcome.txt" /> | ||
<None Remove="Hosts\ash\Welcome.txt" /> | ||
<None Remove="Hosts\aws\Welcome.txt" /> | ||
<None Remove="Hosts\azgov\Welcome.txt" /> | ||
<None Remove="Tools\agm\Help.txt" /> | ||
<None Remove="Tools\agm\Welcome.txt" /> | ||
<None Remove="Tools\amm\Help.txt" /> | ||
<None Remove="Tools\amm\Welcome.txt" /> | ||
<None Remove="Tools\ascon\Help.txt" /> | ||
<None Remove="Tools\ascon\Welcome.txt" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="BUILD_INFO.txt" /> | ||
<EmbeddedResource Include="Hosts\agdida\Welcome.txt" /> | ||
<EmbeddedResource Include="Hosts\ahgov\Welcome.txt" /> | ||
<EmbeddedResource Include="Hosts\aph\Welcome.txt" /> | ||
<EmbeddedResource Include="Hosts\ash\Welcome.txt" /> | ||
<EmbeddedResource Include="Hosts\aws\Welcome.txt" /> | ||
<EmbeddedResource Include="Hosts\azgov\Welcome.txt" /> | ||
<EmbeddedResource Include="Tools\agm\Help.txt" /> | ||
<EmbeddedResource Include="Tools\agm\Welcome.txt" /> | ||
<EmbeddedResource Include="Tools\amm\Help.txt" /> | ||
<EmbeddedResource Include="Tools\amm\Welcome.txt" /> | ||
<EmbeddedResource Include="Tools\ascon\Help.txt" /> | ||
<EmbeddedResource Include="Tools\ascon\Welcome.txt" /> | ||
<EmbeddedResource Include="WebManager\Site\**" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="WebManager\Pages\.tc\*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="NFX"> | ||
<HintPath>..\lib\nfx\NFX.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NFX.Wave"> | ||
<HintPath>..\lib\nfx\NFX.Wave.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NFX.Web"> | ||
<HintPath>..\lib\nfx\NFX.Web.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="agdida.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="agm.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Agnivo.win.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ahgov.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="aph.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ascon-nolog.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ascon.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="ash.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="aws.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="azgov.laconf"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Runtime.Serialization; | ||
|
||
using NFX; | ||
|
||
namespace Agni | ||
{ | ||
/// <summary> | ||
/// Marker interfaces for all Agni exceptions | ||
/// </summary> | ||
public interface IAgniException | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Base exception thrown by the framework | ||
/// </summary> | ||
[Serializable] | ||
public class AgniException : NFXException, IAgniException | ||
{ | ||
public const string SENDER_FLD_NAME = "AE-S"; | ||
public const string TOPIC_FLD_NAME = "AE-T"; | ||
|
||
public static string DefaultSender; | ||
public static string DefaultTopic; | ||
|
||
public readonly string Sender; | ||
public readonly string Topic; | ||
|
||
|
||
public AgniException() | ||
{ | ||
Sender = DefaultSender; | ||
Topic = DefaultTopic; | ||
} | ||
|
||
public AgniException(int code) | ||
{ | ||
Code = code; | ||
Sender = DefaultSender; | ||
Topic = DefaultTopic; | ||
} | ||
|
||
public AgniException(int code, string message) : this(message, null, code, null, null) {} | ||
public AgniException(string message) : this(message, null, 0, null, null) { } | ||
public AgniException(string message, Exception inner) : this(message, inner, 0, null, null) { } | ||
|
||
public AgniException(string message, Exception inner, int code, string sender, string topic) : base(message, inner) | ||
{ | ||
Code = code; | ||
Sender = sender ?? DefaultSender; | ||
Topic = topic ?? DefaultTopic; | ||
} | ||
|
||
protected AgniException(SerializationInfo info, StreamingContext context) : base(info, context) | ||
{ | ||
Sender = info.GetString(SENDER_FLD_NAME); | ||
Topic = info.GetString(TOPIC_FLD_NAME); | ||
} | ||
|
||
public override void GetObjectData(SerializationInfo info, StreamingContext context) | ||
{ | ||
if (info == null) | ||
throw new NFXException(StringConsts.ARGUMENT_ERROR + GetType().Name + ".GetObjectData(info=null)"); | ||
info.AddValue(SENDER_FLD_NAME, Sender); | ||
info.AddValue(TOPIC_FLD_NAME, Topic); | ||
base.GetObjectData(info, context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
using NFX; | ||
using NFX.Glue; | ||
using NFX.Environment; | ||
|
||
namespace Agni | ||
{ | ||
public static class AgniExtensions | ||
{ | ||
/// <summary> | ||
/// Tries to resolve mnemonic name of the Agni service into port, i.e. "hgov" into int port number | ||
/// </summary> | ||
public static Node ToResolvedServiceNode(this string connectString, bool appTerminal = false) | ||
{ | ||
return ToResolvedServiceNode(new Node(connectString), appTerminal); | ||
} | ||
|
||
/// <summary> | ||
/// Tries to resolve mnemonic name of the Agni service into port, i.e. "hgov" into int port number | ||
/// </summary> | ||
public static Node ToResolvedServiceNode(this Node node, bool appTerminal = false) | ||
{ | ||
if (!node.Assigned ) return node; | ||
|
||
if (node.Binding.IsNullOrWhiteSpace()) | ||
node = new Node("{0}://{1}:{2}".Args(SysConsts.DEFAULT_BINDING, node.Host, node.Service)); | ||
|
||
int p; | ||
if (int.TryParse(node.Service, out p)) return node; | ||
|
||
var sync = node.Binding.Trim().EqualsIgnoreCase(SysConsts.SYNC_BINDING); | ||
var port = ServiceNameToPort(node.Service, sync, appTerminal); | ||
return new Node("{0}://{1}:{2}".Args(node.Binding, node.Host, port)); | ||
} | ||
|
||
/// <summary> | ||
/// Translates mnemonic name of the major service (i.e. "hgov") into its default port | ||
/// </summary> | ||
public static int ServiceNameToPort(string service, bool sync, bool appTerminal) | ||
{ | ||
var result = SysConsts.DEFAULT_ZONE_GOV_SVC_SYNC_PORT; | ||
if (service.IsNotNullOrWhiteSpace()) | ||
{ | ||
service = service.Trim().ToLowerInvariant(); | ||
if (service=="ahgov" || | ||
service=="hgov" || | ||
service=="hgv" || | ||
service=="h") result = SysConsts.DEFAULT_HOST_GOV_SVC_SYNC_PORT; | ||
|
||
else if (service=="azgov" || | ||
service=="zgov" || | ||
service=="zgv" || | ||
service=="z") result = SysConsts.DEFAULT_ZONE_GOV_SVC_SYNC_PORT; | ||
|
||
else if (service=="agdida" || | ||
service == "gdida" || | ||
service == "gdid" || | ||
service=="id" || | ||
service=="g") result = SysConsts.DEFAULT_GDID_AUTH_SVC_SYNC_PORT; | ||
|
||
else if (service=="aws" || | ||
service=="www" || | ||
service=="web" || | ||
service=="http") result = SysConsts.DEFAULT_AWS_SVC_SYNC_PORT; | ||
|
||
else if (service=="aph" || | ||
service=="proc" || | ||
service=="ph") result = SysConsts.DEFAULT_PH_SVC_SYNC_PORT; | ||
|
||
else if (service=="log") result = SysConsts.DEFAULT_LOG_SVC_SYNC_PORT; | ||
|
||
else if (service=="telem" || | ||
service=="telemetry" || | ||
service=="tlm") result = SysConsts.DEFAULT_TELEMETRY_SVC_SYNC_PORT; | ||
|
||
else if (service=="wm" || | ||
service=="msg" || | ||
service=="wmsg") result = SysConsts.DEFAULT_WEB_MESSAGE_SYSTEM_SVC_APPTERM_PORT; | ||
|
||
else if (service=="ash" || service=="sh") | ||
{ | ||
if (appTerminal) return SysConsts.DEFAULT_ASH_APPTERM_PORT; | ||
else throw new AgniException("Not supported ASH service"); | ||
} | ||
else throw new AgniException("Not supported service: `{0}`".Args(service)); | ||
} | ||
|
||
return appTerminal ? result + SysConsts.APP_TERMINAL_PORT_OFFSET : sync ? result : result+1; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Checks two strings for region paths that reference the same regional entity disregarding entity extensions (such as '.r' or '.noc'). | ||
/// Note: this method DOES NOT check whether this path resolves to actual catalog entity as it only compares names. | ||
/// This function should be used in conjunction with GetRegionPathHashCode() while implementing Equals/GetHashCode. | ||
/// Ignores dynamic host name suffixes | ||
/// </summary> | ||
public static bool IsSameRegionPath(this string path1, string path2) | ||
{ | ||
if (path1==null || path2==null) return false; | ||
|
||
var segs1 = path1.Split('/').Where(s=>s.IsNotNullOrWhiteSpace()).ToList(); | ||
var segs2 = path2.Split('/').Where(s=>s.IsNotNullOrWhiteSpace()).ToList(); | ||
|
||
if (segs1.Count!=segs2.Count) return false; | ||
|
||
for(var i=0; i<segs1.Count; i++) | ||
{ | ||
var seg1 = segs1[i].Trim(); | ||
var seg2 = segs2[i].Trim(); | ||
|
||
if (i==segs1.Count-1)//last segment | ||
{ | ||
var si = seg1.LastIndexOf(Metabase.Metabank.HOST_DYNAMIC_SUFFIX_SEPARATOR); if (si>0) seg1 = seg1.Substring(0, si).Trim(); | ||
si = seg2.LastIndexOf(Metabase.Metabank.HOST_DYNAMIC_SUFFIX_SEPARATOR); if (si>0) seg2 = seg2.Substring(0, si).Trim(); | ||
} | ||
|
||
var di = seg1.LastIndexOf('.'); if (di>0) seg1 = seg1.Substring(0, di); | ||
di = seg2.LastIndexOf('.'); if (di>0) seg2 = seg2.Substring(0, di); | ||
|
||
if (!seg1.EqualsIgnoreCase( seg2 )) return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// Deletes region extensions (such as '.r' or '.noc') from path | ||
/// Ignores dynamic host name suffixes | ||
/// </summary> | ||
public static string StripPathOfRegionExtensions(this string path) | ||
{ | ||
if (path==null) return null; | ||
|
||
var segs = path.Split('/').Where(s=>s.IsNotNullOrWhiteSpace()).ToList(); | ||
var result = new StringBuilder(); | ||
for(var i=0; i<segs.Count; i++) | ||
{ | ||
var seg = segs[i]; | ||
|
||
if (i==segs.Count-1)//last segment | ||
{ | ||
var si = seg.LastIndexOf(Metabase.Metabank.HOST_DYNAMIC_SUFFIX_SEPARATOR); | ||
if (si>0) seg = seg.Substring(0, si).Trim(); | ||
} | ||
|
||
var di = seg.LastIndexOf('.'); | ||
if (di>0) seg = seg.Substring(0, di); | ||
|
||
if (i>0) result.Append('/'); | ||
result.Append(seg.Trim()); | ||
} | ||
|
||
return result.ToString(); | ||
} | ||
|
||
/// <summary> | ||
/// Computes has code for region path string disregarding case and extensions (such as '.r' or '.noc') | ||
/// Note: This function should be used in conjunction with IsSameRegionPath() while implementing Equals/GetHashCode | ||
/// Ignores dynamic host name suffixes | ||
/// </summary> | ||
public static int GetRegionPathHashCode(this string path) | ||
{ | ||
var stripped = path.StripPathOfRegionExtensions(); | ||
if (stripped==null) return 0; | ||
return stripped.ToLowerInvariant().GetHashCode(); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Returns true if the supplied string is a valid name | ||
/// a name that does not contain SysConsts.NAME_INVALID_CHARS | ||
/// </summary> | ||
public static bool IsValidName(this string name) | ||
{ | ||
if (name==null) return false; | ||
|
||
var started = false; | ||
var ws = false; | ||
|
||
for(var i=0; i<name.Length; i++) | ||
{ | ||
var c = name[i]; | ||
ws = Char.IsWhiteSpace(c); | ||
if (!started && ws) return false;//no leading whitespace | ||
if (!ws) started = true; | ||
if (SysConsts.NAME_INVALID_CHARS.Contains(c)) return false; | ||
} | ||
|
||
if (!started || ws) return false;//trailing whitespace | ||
|
||
return true; | ||
} | ||
} | ||
} |
Oops, something went wrong.