init
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using DTS.Common.Interface;
|
||||
// ReSharper disable CheckNamespace
|
||||
|
||||
namespace DTS.Common.Classes.Viewer.TestMetadata
|
||||
{
|
||||
public class TestGraphs: ITestGraphs
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string HardwareChannelName { get; set; }
|
||||
public List<string> ChannelIds { get; set; }
|
||||
public List<ITestChannel> Channels { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace DTS.Common.Converters
|
||||
{
|
||||
[ValueConversion(typeof(List<string>), typeof(Visibility))]
|
||||
public class StringListToVisibilityConverter: IValueConverter
|
||||
{
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (targetType != typeof(Visibility))
|
||||
throw new InvalidOperationException("The target must be a Visibility");
|
||||
|
||||
return (((List<string>)value) ?? throw new InvalidOperationException()).Any() ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Base
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Base class used to create ViewModel objects that implement their own commands/verbs/actions.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the Model object.</typeparam>
|
||||
public abstract class ViewModelBase<T> : DependencyObject, INotifyPropertyChanged, IViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Model object.
|
||||
/// </summary>
|
||||
public object Model { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create new instance of base class used to create ViewModel objects that implement their own commands/verbs/actions.
|
||||
/// </summary>
|
||||
public ViewModelBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this object is executing an asynchronous process.
|
||||
/// </summary>
|
||||
public bool IsBusy { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the Model has been changed.
|
||||
/// </summary>
|
||||
public virtual bool IsDirty { get; protected set; }
|
||||
|
||||
|
||||
// Summary:
|
||||
// Event raised when an error occurs during processing.
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public virtual event EventHandler<ErrorEventArgs> ErrorOccurred;
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when a property changes.
|
||||
/// </summary>
|
||||
public virtual event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to implement async initialization of the model object.
|
||||
/// The result of this method is used to set the Model property of the viewmodel.
|
||||
/// </summary>
|
||||
/// <returns>A Task that creates the model object.</returns>
|
||||
[DebuggerStepThrough]
|
||||
protected abstract Task<T> InitializeAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Creates or retrieves a new instance of the Model by invoking a static factory method.
|
||||
/// </summary>
|
||||
/// <param name="factoryMethod">Static factory method function.</param>
|
||||
protected abstract void DoRefresh(Func<T> factoryMethod);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Raises ErrorOccurred event when an error occurs during processing.
|
||||
/// </summary>
|
||||
/// <param name="error"></param>
|
||||
protected abstract void OnError(Exception error);
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the Model changes, allowing event handlers to be unhooked from the old object and hooked on the new object.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Previous Model reference.</param>
|
||||
/// <param name="newValue">New Model reference.</param>
|
||||
protected abstract void OnModelChanged(T oldValue, T newValue);
|
||||
|
||||
/// <summary>
|
||||
/// Raise the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="propertyName">Name of the changed property.</param>
|
||||
protected abstract void OnPropertyChanged(string propertyName);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
|
||||
namespace DTS.Common.Classes
|
||||
{
|
||||
public abstract class TagAwareBase : Base.BasePropertyChanged
|
||||
{
|
||||
public enum TagTypes
|
||||
{
|
||||
User,
|
||||
Group,
|
||||
Template,
|
||||
TestSetup,
|
||||
Sensors,
|
||||
SensorModels
|
||||
}
|
||||
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.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
//if (string.IsNullOrEmpty(tagText)) { return; } // http://fogbugz/fogbugz/default.asp?7176
|
||||
SetTags(tagText.Split(','), getSqlCommand);
|
||||
}
|
||||
public virtual void SetTags(string[] tagsText, Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
Tags.AddRange(tagsText, getSqlCommand);
|
||||
TagIDs = Tags.GetIDsFromTagText(tagsText, getSqlCommand);
|
||||
OnPropertyChanged("TagIDs");
|
||||
}
|
||||
public string GetTagsAsCommaSeparatedString(Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var tagArray = GetTagsArray(getSqlCommand);
|
||||
foreach (var s in tagArray)
|
||||
{
|
||||
if (sb.Length > 0) { sb.Append(","); }
|
||||
sb.Append(s);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
#region ITagAware
|
||||
|
||||
public virtual string[] GetTagsArray(Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
return Tags.GetTagTextFromIDs(TagIDs, getSqlCommand);
|
||||
}
|
||||
public virtual int[] GetTagIDs() { return TagIDs; }
|
||||
public virtual void RemoveTags(string[] tagsText)
|
||||
{
|
||||
// remove tags!!!
|
||||
//-;
|
||||
}
|
||||
|
||||
public bool TagCompatible(string tags, Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
//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 (newTagsArray.All(string.IsNullOrWhiteSpace)) return true;
|
||||
|
||||
var comparisonArray = GetTagsArray(getSqlCommand);
|
||||
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.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
SetTagsFromCommaSeparatedString(tags, getSqlCommand);
|
||||
Commit(id, tagType, getSqlCommand);
|
||||
}
|
||||
|
||||
public void Commit(int id, TagTypes tagType, Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = @"sp_TagAssignmentsDelete";
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ObjectID", SqlDbType.Int) { Value = id });
|
||||
cmd.Parameters.Add(new SqlParameter("@ObjectType", SqlDbType.SmallInt) { Value = tagType });
|
||||
var errorNumberParam = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (!TagIDs.Any()) return;
|
||||
|
||||
foreach (var tagId in TagIDs)
|
||||
{
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = @"sp_TagAssignmentsInsert";
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ObjectID", SqlDbType.Int) { Value = id });
|
||||
cmd.Parameters.Add(new SqlParameter("@ObjectType", SqlDbType.SmallInt) { Value = tagType });
|
||||
cmd.Parameters.Add(new SqlParameter("@TagID", SqlDbType.Int) { Value = tagId });
|
||||
var errorNumberParam = new SqlParameter("@errorNumber", SqlDbType.Int) { Direction = ParameterDirection.Output };
|
||||
cmd.Parameters.Add(errorNumberParam);
|
||||
var errorMessageParam = new SqlParameter("@errorMessage", SqlDbType.NVarChar, 250)
|
||||
{
|
||||
Direction = ParameterDirection.Output
|
||||
};
|
||||
cmd.Parameters.Add(errorMessageParam);
|
||||
|
||||
#endregion params
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
if (int.Parse(errorNumberParam.Value.ToString()) != 0)
|
||||
{
|
||||
//errorMessageParam.Value
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<int> GetTagIdList(int objectId, TagTypes tagType, Tags.GetSqlCommandDelegate getSqlCommand)
|
||||
{
|
||||
var tagIdList = new List<int>();
|
||||
|
||||
try
|
||||
{
|
||||
using (var cmd = getSqlCommand(true))
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandType = CommandType.StoredProcedure;
|
||||
cmd.CommandText = @"sp_TagAssignmentsGet";
|
||||
|
||||
#region params
|
||||
|
||||
cmd.Parameters.Add(new SqlParameter("@ObjectType", SqlDbType.Int) { Value = tagType });
|
||||
|
||||
#endregion params
|
||||
|
||||
//cmd.ExecuteNonQuery();
|
||||
|
||||
var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
if (Convert.ToInt32(reader["ObjectID"]) != objectId) continue;
|
||||
var tagId = Convert.ToInt32(reader["TagID"]);
|
||||
if (!tagIdList.Contains(tagId))
|
||||
{
|
||||
tagIdList.Add(tagId);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Connection.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("failed to retrieve object tags", ex);
|
||||
}
|
||||
|
||||
return tagIdList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface ITRLReportInputView : IBaseView { }
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace DTS.Common.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the converter that converts Boolean values to and from <see cref="Visibility">Visibility</see> enumeration values.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Use the BooleanToVisibilityConverter class to convert a Boolean to and from a <see cref="Visibility">Visibility</see> value.
|
||||
/// The Convert method returns <see cref="Visibility.Visible">Visibility.Visible</see> when <b>true</b> is passed in
|
||||
/// or <see cref="Visibility.Collapsed">Visibility.Collapsed</see> when <b>false</b> is passed in.
|
||||
/// Note that the <see cref="Visibility.Collapsed">Visibility.Collapsed</see> value hides the control and does not reserve space for it in a layout.
|
||||
/// When you call the ConvertBack method and specify a reference to an object, it returns <b>true</b>
|
||||
/// if the object is <see cref="Visibility.Visible">Visible</see>; otherwise, it returns <b>false</b>.
|
||||
/// </remarks>
|
||||
///
|
||||
public class BooleanToVisibilityConverter : IValueConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a Boolean value to a Visibility enumeration value.
|
||||
/// </summary>
|
||||
/// <param name="value">The Boolean value to convert. This value can be a standard Boolean value or a nullable Boolean value.</param>
|
||||
/// <param name="targetType">This parameter is not used.</param>
|
||||
/// <param name="parameter">The converter parameter to use.</param>
|
||||
/// <param name="culture">This parameter is not used.</param>
|
||||
/// <returns>The value to be passed to the target dependency property.</returns>
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var useFalseAsVisible = parameter != null && parameter.ToString().ToUpper() == "FALSE";
|
||||
var hideNotCollapse = parameter != null && parameter.ToString().ToUpper() == "HIDE";
|
||||
|
||||
if (!useFalseAsVisible)
|
||||
{
|
||||
if ((bool)value)
|
||||
return Visibility.Visible;
|
||||
return hideNotCollapse ? Visibility.Hidden : Visibility.Collapsed;
|
||||
}
|
||||
if ((bool)value)
|
||||
return hideNotCollapse ? Visibility.Hidden : Visibility.Collapsed;
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Visibility enumeration value to a Boolean value.
|
||||
/// </summary>
|
||||
/// <param name="value">A Visibility enumeration value.</param>
|
||||
/// <param name="targetType">This parameter is not used.</param>
|
||||
/// <param name="parameter">This parameter is not used.</param>
|
||||
/// <param name="culture">This parameter is not used.</param>
|
||||
/// <returns>The value to be passed to the source object.</returns>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace DTS.Common.Classes
|
||||
{
|
||||
public enum ImportPageType
|
||||
{
|
||||
ImportSensor,
|
||||
ImportTestSetup
|
||||
}
|
||||
public class SensorImportData
|
||||
{
|
||||
public Dictionary<string, List<string>> GroupNameSensorListLookup { get; set; }
|
||||
public Dictionary<string, string> SensorGroupNameLookup { get; set; }
|
||||
public Dictionary<string, string> SensorGroupTypeLookup { get; set; }
|
||||
public Dictionary<string, string> GroupNameTestObjectLookup { get; set; }
|
||||
public List<string> Errors { get; set; } = new List<string>();
|
||||
public Dictionary<string, string> SensorISOCode { get; set; }
|
||||
public Dictionary<string, string> SensorISOChannelName { get; set; }
|
||||
public Dictionary<string, string> SensorUserCode { get; set; }
|
||||
public Dictionary<string, string> SensorUserChannelName { get; set; }
|
||||
public Dictionary<string, string> SensorDASSerialNumber { get; set; }
|
||||
public Dictionary<string, int> SensorChannelIndex { get; set; }
|
||||
}
|
||||
public class TestSetupImportData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double SamplesPerSecond { get; set; }
|
||||
public double PosttriggerSeconds { get; set; }
|
||||
public double PretriggerSeconds { get; set; }
|
||||
public RecordingModes RecordingMode { get; set; }
|
||||
public CalibrationBehaviors CalibrationBehavior { get; set; }
|
||||
public int Version { get; set; }
|
||||
public List<string> TestChannelOrders { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
public InputClockSource ClockMasterInput { get; set; } = InputClockSource.None;
|
||||
public OutputClockSource ClockMasterOutput { get; set; } = OutputClockSource.None;
|
||||
public bool ManageClocksOutsideOfDataPROMaster { get; set; } = false;
|
||||
public bool ManageClocksOutsideOfDataPROSlave { get; set; } = false;
|
||||
public OutputClockSource ClockSlaveInput { get; set; } = OutputClockSource.None;
|
||||
public OutputClockSource ClockSlaveOutput { get; set; } = OutputClockSource.None;
|
||||
public Dictionary<string, int> SampleRateForDAS { get; } = new Dictionary<string, int>();
|
||||
public Dictionary<string, uint> DomainIdForDAS { get; } = new Dictionary<string, uint>();
|
||||
public Dictionary<string, bool> IsClockMaster { get; } = new Dictionary<string, bool>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface IStatsView : IBaseView { }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using DTS.Common.Base;
|
||||
|
||||
namespace DTS.Common.Interface
|
||||
{
|
||||
public interface ISystemSettingsViewModel : IBaseViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Shell View.
|
||||
/// </summary>
|
||||
ISystemSettingsView View { get; }
|
||||
List<FrameworkElement> GetRegions();
|
||||
Object ContextMenuRegion { get; set; }
|
||||
Object ContextMainRegion { get; set; }
|
||||
Object ContextNavigationRegion { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user