init
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,162 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Classes.Tags;
|
||||
using DTS.Common.Interface.Tags;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Classes
|
||||
{
|
||||
public abstract class TagAwareBase : Base.BasePropertyChanged
|
||||
{
|
||||
public abstract TagTypes TagType { get; }
|
||||
|
||||
#region Tags
|
||||
public byte[] TagsBlobBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
var result = new byte[TagIDs.Length * sizeof(int)];
|
||||
Buffer.BlockCopy(TagIDs, 0, result, 0, result.Length);
|
||||
return result;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.Length < sizeof(int)) return;
|
||||
var tagsBlob = new int[value.Length / sizeof(int)];
|
||||
try
|
||||
{
|
||||
Buffer.BlockCopy(value, 0, tagsBlob, 0, value.Length);
|
||||
TagIDs = tagsBlob;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private int[] _tagIDs = new int[0];
|
||||
public int[] TagIDs
|
||||
{
|
||||
get => _tagIDs;
|
||||
set => _tagIDs = value ?? new int[0];
|
||||
}
|
||||
|
||||
public void SetTagsFromCommaSeparatedString(string tagText,
|
||||
Tags.TagsInstance.GetSqlCommandDelegate getSqlCommand,
|
||||
Tags.TagsInstance.TagsGetDelegate tagsGet,
|
||||
Tags.TagsInstance.TagsGetIdDelegate tagsGetId,
|
||||
Tags.TagsInstance.TagsInsertDelegate tagsInsert)
|
||||
{
|
||||
//if (string.IsNullOrEmpty(tagText)) { return; } // http://fogbugz/fogbugz/default.asp?7176
|
||||
SetTags(tagText.Split(','), getSqlCommand, tagsGet, tagsGetId, tagsInsert);
|
||||
}
|
||||
public virtual void SetTags(string[] tagsText, Tags.TagsInstance.GetSqlCommandDelegate getSqlCommand,
|
||||
Tags.TagsInstance.TagsGetDelegate tagsGet, Tags.TagsInstance.TagsGetIdDelegate tagsGetId,
|
||||
Tags.TagsInstance.TagsInsertDelegate tagsInsert)
|
||||
{
|
||||
Tags.TagsInstance.AddRange(tagsText, getSqlCommand, tagsGet, tagsGetId, tagsInsert);
|
||||
TagIDs = Tags.TagsInstance.GetIDsFromTagText(tagsText, tagsGet, tagsGetId);
|
||||
OnPropertyChanged("TagIDs");
|
||||
}
|
||||
public string GetTagsAsCommaSeparatedString(Tags.TagsInstance.TagsGetDelegate tagsGet)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var tagArray = GetTagsArray(tagsGet);
|
||||
foreach (var s in tagArray)
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
#region ITagAware
|
||||
|
||||
public virtual string[] GetTagsArray(Tags.TagsInstance.TagsGetDelegate tagsGet)
|
||||
{
|
||||
return Tags.TagsInstance.GetTagTextFromIDs(TagIDs, tagsGet);
|
||||
}
|
||||
public virtual int[] GetTagIDs() { return TagIDs; }
|
||||
public virtual void RemoveTags(string[] tagsText)
|
||||
{
|
||||
// remove tags!!!
|
||||
//-;
|
||||
}
|
||||
|
||||
public bool TagCompatible(string tags, Tags.TagsInstance.TagsGetDelegate tagsGet)
|
||||
{
|
||||
//Make sure there are Tags to check
|
||||
if (string.IsNullOrWhiteSpace(tags)) return true;
|
||||
var newTagsArray = tags.Split(',');
|
||||
|
||||
//Make sure all Tags are not empty strings
|
||||
if (Array.TrueForAll(newTagsArray, string.IsNullOrWhiteSpace)) return true;
|
||||
|
||||
var comparisonArray = GetTagsArray(tagsGet);
|
||||
foreach (var tag in newTagsArray)
|
||||
{
|
||||
//If a Tag is an empty string, ignore it
|
||||
if (string.IsNullOrWhiteSpace(tag)) continue;
|
||||
if (comparisonArray.Contains(tag.Trim()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public virtual bool TagCompatible(int[] tags)
|
||||
{
|
||||
return !tags.Any() || HasIntersectingTag(tags);
|
||||
}
|
||||
public virtual bool HasIntersectingTag(int[] tags)
|
||||
{
|
||||
return tags.Intersect(TagIDs).Any();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public void InsertTagsFromCommaSeparatedString(int id, TagTypes tagType, string tags,
|
||||
Tags.TagsInstance.GetSqlCommandDelegate getSqlCommand, Tags.TagsInstance.TagsGetDelegate tagsGet,
|
||||
Tags.TagsInstance.TagsGetIdDelegate tagsIdGet, Tags.TagsInstance.TagsInsertDelegate tagsInsert,
|
||||
Tags.TagsInstance.TagAssignmentsDelete tagAssignmentsDelete, Tags.TagsInstance.TagAssignmentsInsert tagAssignmentsInsert)
|
||||
{
|
||||
SetTagsFromCommaSeparatedString(tags, getSqlCommand, tagsGet, tagsIdGet, tagsInsert);
|
||||
Commit(id, tagType, tagAssignmentsDelete, tagAssignmentsInsert);
|
||||
}
|
||||
|
||||
public void Commit(int id, TagTypes tagType,
|
||||
Tags.TagsInstance.TagAssignmentsDelete tagAssignmentsDelete,
|
||||
Tags.TagsInstance.TagAssignmentsInsert tagAssignmentInsert)
|
||||
{
|
||||
_ = tagAssignmentsDelete(tagType, id);
|
||||
|
||||
if (!TagIDs.Any()) return;
|
||||
|
||||
foreach (var tagId in TagIDs)
|
||||
{
|
||||
_ = tagAssignmentInsert(new TagAssignment() { ObjectID = id, ObjectType = tagType, TagID = tagId });
|
||||
}
|
||||
}
|
||||
|
||||
public List<int> GetTagIdList(int objectId, TagTypes tagType,
|
||||
Tags.TagsInstance.TagAssignmentsGet tagAssignmentsGet)
|
||||
{
|
||||
var tagIdList = new List<int>();
|
||||
var hr = tagAssignmentsGet(tagType, out var records);
|
||||
if (0 == hr && null != records && records.Any())
|
||||
{
|
||||
foreach (var record in records)
|
||||
{
|
||||
if (record.ObjectID != objectId) { continue; }
|
||||
if (!tagIdList.Contains(record.TagID))
|
||||
{
|
||||
tagIdList.Add(record.TagID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tagIdList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IMainLiteViewModel : IBaseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Main View.
|
||||
/// </summary>
|
||||
IMainView View { get; }
|
||||
object ContextMainRegion { get; set; }
|
||||
object ContextNavigationRegion { get; set; }
|
||||
object ContextHorizontalTabRegion { get; set; }
|
||||
object ContextVerticalTabRegion { get; set; }
|
||||
List<FrameworkElement> GetRegions();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// ReSharper disable CheckNamespace
|
||||
namespace DTS.Common.Interface.TestDefinition
|
||||
{
|
||||
public interface ITestMetadata
|
||||
{
|
||||
ITestRunMetadata TestRun { get; set; }
|
||||
ITestSetupMetadata TestSetup { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Classes.Sensors
|
||||
{
|
||||
public enum KnownChannelTypes
|
||||
{
|
||||
VS,
|
||||
VU,
|
||||
SB,
|
||||
TI,
|
||||
TC,
|
||||
CT,
|
||||
XP,
|
||||
P4,
|
||||
VF,
|
||||
NB,
|
||||
EX,
|
||||
X1,
|
||||
R1,
|
||||
VO,
|
||||
CO,
|
||||
CP
|
||||
}
|
||||
public static class ChannelTypeUtility
|
||||
{
|
||||
//FB 44299
|
||||
public static string ParseSensorKnownChannelType(string sensorName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sensorName)) return string.Empty;
|
||||
|
||||
if (sensorName.Length < 2) return string.Empty;
|
||||
|
||||
var parsedCode = sensorName.Substring(0, 2).ToUpper();
|
||||
var knownsCodes = Enum.GetValues(typeof(KnownChannelTypes)).Cast<KnownChannelTypes>().Select(x => x.ToString()).ToArray();
|
||||
if (knownsCodes.Contains(parsedCode)) return parsedCode;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.BusyIndicatorManager
|
||||
{
|
||||
public class BusyIndicatorManager : BindableBase
|
||||
{
|
||||
#region Membervariables
|
||||
|
||||
private Dictionary<int, string> busyParameters;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
private BusyIndicatorManager()
|
||||
{
|
||||
_isBusy = false;
|
||||
_message = string.Empty;
|
||||
busyParameters = new Dictionary<int, string>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Singleton Implementation
|
||||
|
||||
private static BusyIndicatorManager _instance;
|
||||
private static readonly object SyncRoot = new object();
|
||||
|
||||
public static BusyIndicatorManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (SyncRoot)
|
||||
{
|
||||
return _instance ?? (_instance = new BusyIndicatorManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
private bool _isBusy;
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => _isBusy;
|
||||
private set
|
||||
{
|
||||
_isBusy = value;
|
||||
RaisePropertyChanged("IsBusy");
|
||||
}
|
||||
}
|
||||
|
||||
private string _message;
|
||||
|
||||
public string Message
|
||||
{
|
||||
get => _message;
|
||||
private set
|
||||
{
|
||||
_message = value;
|
||||
RaisePropertyChanged("Message");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void ShowBusy(int id, string busyMessage)
|
||||
{
|
||||
if (!busyParameters.ContainsKey(id))
|
||||
{
|
||||
busyParameters.Add(id, busyMessage);
|
||||
IsBusy = true;
|
||||
Message = busyMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
busyParameters[id] = busyMessage;
|
||||
IsBusy = true;
|
||||
Message = busyMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseBusy(int id)
|
||||
{
|
||||
if (busyParameters.ContainsKey(id))
|
||||
busyParameters.Remove(id);
|
||||
|
||||
if (busyParameters.Count == 0)
|
||||
{
|
||||
IsBusy = false;
|
||||
Message = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsBusy = true;
|
||||
Message = busyParameters.Last().Value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user