initial source commit

This commit is contained in:
Gary Sharp
2013-02-01 12:35:28 +11:00
parent 543a005d31
commit 0a93429800
1103 changed files with 285609 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DiscoDataContext" connectionString="data source=(local);Initial Catalog=Disco;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=.\SQLEXPRESS; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Data.Configuration
{
public abstract class ConfigurationBase
{
private ConfigurationContext _context;
public ConfigurationContext Context
{
get
{
return _context;
}
}
public abstract string Scope { get; }
public ConfigurationBase(ConfigurationContext Context)
{
this._context = Context;
}
protected void SetValue<ValueType>(string Key, ValueType Value)
{
this.Context.SetConfigurationValue(this.Scope, Key, Value);
}
protected ValueType GetValue<ValueType>(string Key, ValueType Default)
{
return this.Context.GetConfigurationValue(this.Scope, Key, Default);
}
}
}
@@ -0,0 +1,472 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Data.Repository;
using Disco.Models.Repository;
using System.IO;
using System.Security.Cryptography;
using Disco.Models.BI.Interop.Community;
using Newtonsoft.Json;
namespace Disco.Data.Configuration
{
public class ConfigurationContext
{
private DiscoDataContext _dbContext;
private DiscoDataContext dbContext
{
get
{
if (_dbContext != null)
return _dbContext;
else
throw new InvalidOperationException("Cache-miss where Configuration Item requested from Cache-Only Configuration Context");
}
}
public bool CacheOnly
{
get
{
return _dbContext == null;
}
}
public ConfigurationContext(DiscoDataContext dbContext)
{
this._dbContext = dbContext;
// Init Modules
this.moduleBootstrapperConfiguration = new Lazy<Modules.BootstrapperConfiguration>(() => new Modules.BootstrapperConfiguration(this));
this.moduleDeviceProfilesConfiguration = new Lazy<Modules.DeviceProfilesConfiguration>(() => new Modules.DeviceProfilesConfiguration(this));
this.moduleOrganisationAddressesConfiguration = new Lazy<Modules.OrganisationAddressesConfiguration>(() => new Modules.OrganisationAddressesConfiguration(this));
this.moduleWirelessConfiguration = new Lazy<Modules.WirelessConfiguration>(() => new Modules.WirelessConfiguration(this));
}
#region Item Cache
private static Dictionary<String, Dictionary<String, ConfigurationItem>> configDictionary = new Dictionary<string, Dictionary<string, ConfigurationItem>>();
private static List<ConfigurationItem> configurationItems = new List<ConfigurationItem>();
private static object configurationItemsLock = new object();
private void loadConfigurationItems(string Scope, bool Reload)
{
if (Reload || !configDictionary.ContainsKey(Scope))
{
lock (configurationItemsLock)
{
if (Reload || !configDictionary.ContainsKey(Scope))
{
var newItems = this.dbContext.ConfigurationItems.Where(ci => ci.Scope == Scope).ToArray();
if (configDictionary.ContainsKey(Scope))
{
var existingItems = configDictionary[Scope];
foreach (var existingItem in existingItems.Values)
{
configurationItems.Remove(existingItem);
}
}
configurationItems.AddRange(newItems);
configDictionary[Scope] = newItems.ToDictionary(ci => ci.Key);
}
}
}
}
public Dictionary<string, Dictionary<string, ConfigurationItem>> ConfigurationDictionary(string IncludingScope)
{
this.loadConfigurationItems(IncludingScope, false);
return configDictionary;
}
public ConfigurationItem ConfigurationItem(string Scope, string Key)
{
Dictionary<string, ConfigurationItem> scopeDict = default(Dictionary<string, ConfigurationItem>);
if (this.ConfigurationDictionary(Scope).TryGetValue(Scope, out scopeDict))
{
ConfigurationItem item = default(ConfigurationItem);
if (scopeDict.TryGetValue(Key, out item))
return item;
}
return null;
}
private List<ConfigurationItem> ConfigurationItems(string IncludingScope)
{
this.loadConfigurationItems(IncludingScope, false);
return configurationItems;
}
#endregion
#region Helpers
public ValueType GetConfigurationValue<ValueType>(string Scope, string Key, ValueType Default)
{
var ci = this.ConfigurationItem(Scope, Key);
if (ci == null)
return Default;
else
return (ValueType)Convert.ChangeType(ci.Value, typeof(ValueType));
}
public void SetConfigurationValue<ValueType>(string Scope, string Key, ValueType Value)
{
if (CacheOnly)
throw new InvalidOperationException("Cannot save changes with a CacheOnly Context");
var ci = this.ConfigurationItem(Scope, Key);
if (ci == null && Value != null)
{
lock (configurationItemsLock)
{
ci = this.ConfigurationItem(Scope, Key);
if (ci == null)
{
// Create Configuration Item
ci = new ConfigurationItem() { Scope = Scope, Key = Key, Value = Value.ToString() };
// Add Item to DB & Internal Collections
this.dbContext.ConfigurationItems.Add(ci);
this.ConfigurationItems(Scope).Add(ci);
this.ConfigurationDictionary(Scope)[Scope].Add(Key, ci);
ci = null;
}
}
}
if (ci != null)
{
lock (configurationItemsLock)
{
var entityInfo = dbContext.Entry(ci);
if (entityInfo.State == System.Data.EntityState.Detached)
{
// Reload Scope from DB
this.loadConfigurationItems(Scope, true);
ci = this.ConfigurationItem(Scope, Key);
}
if (Value == null)
{
dbContext.ConfigurationItems.Remove(ci);
configurationItems.Remove(ci);
configDictionary[Scope].Remove(Key);
}
else
{
ci.Value = Value.ToString();
}
}
}
}
public static string ObsfucateValue(string Value)
{
if (string.IsNullOrEmpty(Value))
return Value;
else
return Convert.ToBase64String(Encoding.Unicode.GetBytes(Value));
}
public static string DeobsfucateValue(string ObsfucatedValue)
{
if (string.IsNullOrEmpty(ObsfucatedValue))
return ObsfucatedValue;
else
return Encoding.Unicode.GetString(Convert.FromBase64String(ObsfucatedValue));
}
#endregion
#region Configuration Modules
private Lazy<Modules.BootstrapperConfiguration> moduleBootstrapperConfiguration;
private Lazy<Modules.DeviceProfilesConfiguration> moduleDeviceProfilesConfiguration;
private Lazy<Modules.OrganisationAddressesConfiguration> moduleOrganisationAddressesConfiguration;
private Lazy<Modules.WirelessConfiguration> moduleWirelessConfiguration;
public Modules.BootstrapperConfiguration Bootstrapper
{
get
{
return moduleBootstrapperConfiguration.Value;
}
}
public Modules.DeviceProfilesConfiguration DeviceProfiles
{
get
{
return moduleDeviceProfilesConfiguration.Value;
}
}
public Modules.OrganisationAddressesConfiguration OrganisationAddresses
{
get
{
return moduleOrganisationAddressesConfiguration.Value;
}
}
public Modules.WirelessConfiguration Wireless
{
get
{
return moduleWirelessConfiguration.Value;
}
}
#endregion
#region System Configuration Items
public string Scope { get { return "System"; } }
public string DataStoreLocation
{
get
{
var result = this.GetConfigurationValue<string>(this.Scope, "DataStoreLocation", null);
if (result == null)
{
var appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
if (appDataPath.EndsWith("\\"))
return appDataPath;
else
return string.Concat(appDataPath, '\\');
}
else
return result;
}
set
{
if (value == null)
throw new ArgumentNullException("value");
if (!System.IO.Directory.Exists(value))
throw new System.IO.DirectoryNotFoundException(string.Format("DataStoreLocation: '{0}' could not be found", value));
string storePath;
if (value.EndsWith("\\"))
storePath = value;
else
storePath = string.Concat(value, '\\');
this.SetConfigurationValue(this.Scope, "DataStoreLocation", storePath);
}
}
public string PluginsLocation
{
get
{
return System.IO.Path.Combine(this.DataStoreLocation, @"Plugins\");
}
}
public string PluginStorageLocation
{
get
{
return System.IO.Path.Combine(this.DataStoreLocation, @"PluginStorage\");
}
}
#region Organisation Logo
private string OrganisationLogoPath
{
get
{
return System.IO.Path.Combine(DataStoreLocation, "OrganisationLogo.png");
}
}
//private static string _OrganisationLogoHash;
//private static byte[] _OrganisationLogo;
//private static object _OrganisationLogoLock = new object();
//private static void LoadOrganisationLogo(ConfigurationContext context, bool reload = false)
//{
// if (_OrganisationLogoHash == null || reload)
// {
// lock (_OrganisationLogoLock)
// {
// if (_OrganisationLogoHash == null || reload)
// {
// _OrganisationLogo = null;
// _OrganisationLogoHash = null;
// string organisationLogoPath = context.OrganisationLogoPath;
// if (System.IO.File.Exists(organisationLogoPath))
// _OrganisationLogo = System.IO.File.ReadAllBytes(organisationLogoPath);
// }
// if (_OrganisationLogo == null || _OrganisationLogo.Length == 0)
// {
// _OrganisationLogo = Disco.Data.Properties.Resources.EmptyLogo;
// }
// if (_OrganisationLogoHash == null)
// {
// using (SHA256 h = SHA256.Create())
// {
// _OrganisationLogoHash = Convert.ToBase64String(h.ComputeHash(_OrganisationLogo));
// }
// }
// }
// }
//}
public string OrganisationLogoHash
{
get
{
var path = this.OrganisationLogoPath;
if (File.Exists(path))
return File.GetLastWriteTimeUtc(path).ToBinary().ToString();
else
return "-1";
}
}
public Stream OrganisationLogo
{
get
{
//LoadOrganisationLogo(this);
//if (_OrganisationLogo == null || _OrganisationLogo.Length != 0)
// return new MemoryStream(_OrganisationLogo);
//else
// return null;
var path = this.OrganisationLogoPath;
if (File.Exists(path))
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
else
return new MemoryStream(Disco.Data.Properties.Resources.EmptyLogo);
}
set
{
string organisationLogoPath = this.OrganisationLogoPath;
if (value == null)
{
if (System.IO.File.Exists(organisationLogoPath))
System.IO.File.Delete(organisationLogoPath);
}
else
{
using (FileStream fs = new FileStream(organisationLogoPath, FileMode.Create, FileAccess.Write, FileShare.None))
{
value.CopyTo(fs);
}
}
//LoadOrganisationLogo(this, true);
}
}
#endregion
public string OrganisationName
{
get
{
return this.GetConfigurationValue<string>(this.Scope, "OrganisationName", null);
}
set
{
this.SetConfigurationValue(this.Scope, "OrganisationName", value);
}
}
public bool MultiSiteMode
{
get
{
return this.GetConfigurationValue<bool>(this.Scope, "MultiSiteMode", false);
}
set
{
this.SetConfigurationValue(this.Scope, "MultiSiteMode", value);
}
}
#region Proxy Configuration
public string ProxyAddress
{
get
{
return this.GetConfigurationValue<string>(this.Scope, "ProxyAddress", null);
}
set
{
this.SetConfigurationValue(this.Scope, "ProxyAddress", value);
}
}
public int ProxyPort
{
get
{
return this.GetConfigurationValue(this.Scope, "ProxyPort", 8080);
}
set
{
this.SetConfigurationValue(this.Scope, "ProxyPort", value);
}
}
public string ProxyUsername
{
get
{
return this.GetConfigurationValue<string>(this.Scope, "ProxyUsername", null);
}
set
{
this.SetConfigurationValue(this.Scope, "ProxyUsername", value);
}
}
public string ProxyPassword
{
get
{
return DeobsfucateValue(this.GetConfigurationValue<string>(this.Scope, "ProxyPassword", null));
}
set
{
this.SetConfigurationValue(this.Scope, "ProxyPassword", ObsfucateValue(value));
}
}
#endregion
#region UpdateCheck
public string DeploymentId
{
get
{
return this.GetConfigurationValue<string>(this.Scope, "DeploymentId", null);
}
}
public UpdateResponse UpdateLastCheck
{
get
{
var json = this.GetConfigurationValue<string>(this.Scope, "UpdateLastCheck", null);
if (json != null)
{
try
{
return JsonConvert.DeserializeObject<UpdateResponse>(json);
}
catch (Exception)
{ }// Ignore Serialization Issues
}
return null;
}
set
{
if (value == null)
this.SetConfigurationValue<string>(this.Scope, "UpdateLastCheck", null);
var json = JsonConvert.SerializeObject(value);
this.SetConfigurationValue<string>(this.Scope, "UpdateLastCheck", json);
}
}
public bool UpdateBetaDeployment
{
get
{
return this.GetConfigurationValue<bool>(this.Scope, "UpdateBetaDeployment", false);
}
}
public string InstalledDatabaseVersion
{
get
{
return this.GetConfigurationValue<string>(this.Scope, "InstalledDatabaseVersion", null);
}
set
{
this.SetConfigurationValue<string>(this.Scope, "InstalledDatabaseVersion", value);
}
}
#endregion
#endregion
}
}
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Data.Configuration.Modules
{
public class BootstrapperConfiguration : ConfigurationBase
{
public BootstrapperConfiguration(ConfigurationContext Context) : base(Context) { }
public override string Scope
{
get { return "Bootstrapper"; }
}
public string MacSshUsername
{
get
{
return this.GetValue("MacSshUsername", "root");
}
set
{
this.SetValue("MacSshUsername", value);
}
}
public string MacSshPassword
{
get
{
return ConfigurationContext.DeobsfucateValue(this.GetValue("MacSshPassword", string.Empty));
}
set
{
this.SetValue("MacSshPassword", ConfigurationContext.ObsfucateValue(value));
}
}
}
}
@@ -0,0 +1,86 @@
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
//
//
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Disco.Models.Repository;
//namespace Disco.Data.Configuration.Modules
//{
// public class DeviceProfileConfiguration : ConfigurationBase
// {
// private DeviceProfilesConfiguration deviceProfilesConfig;
// private DeviceProfile deviceProfile;
// public DeviceProfileConfiguration(ConfigurationContext Context, DeviceProfile DeviceProfile)
// : base(Context)
// {
// this.deviceProfilesConfig = Context.DeviceProfiles;
// this.deviceProfile = DeviceProfile;
// }
// public override string Scope
// {
// get
// {
// return string.Format("DeviceProfile:{0}", this.deviceProfile.Id);
// }
// }
// public string ComputerNameTemplate
// {
// get
// {
// return this.GetValue("ComputerNameTemplate", "DeviceProfile.ShortName + '-' + SerialNumber");
// }
// set
// {
// this.SetValue("ComputerNameTemplate", value);
// }
// }
// public enum DeviceProfileDistributionTypes : int
// {
// OneToMany = 0,
// OneToOne = 1
// }
// public DeviceProfileDistributionTypes DistributionType
// {
// get
// {
// return (DeviceProfileDistributionTypes)this.GetValue("DistributionType", (int)DeviceProfileDistributionTypes.OneToMany);
// }
// set
// {
// this.SetValue("DistributionType", (int)value);
// }
// }
// public string OrganisationalUnit
// {
// get
// {
// return this.GetValue<string>("OrganisationalUnit", null);
// }
// set
// {
// this.SetValue("OrganisationalUnit", value);
// }
// }
// public bool AllocateWirelessCertificate
// {
// get
// {
// return this.GetValue("AllocateWirelessCertificate", false);
// }
// set
// {
// this.SetValue("AllocateWirelessCertificate", value);
// }
// }
// }
//}
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
namespace Disco.Data.Configuration.Modules
{
public class DeviceProfilesConfiguration : ConfigurationBase
{
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
//private Dictionary<int, DeviceProfileConfiguration> deviceProfileConfigurations;
public DeviceProfilesConfiguration(ConfigurationContext Context)
: base(Context)
{
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
//this.deviceProfileConfigurations = new Dictionary<int, DeviceProfileConfiguration>();
}
public override string Scope
{
get { return "DeviceProfiles"; }
}
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
//public DeviceProfileConfiguration DeviceProfile(DeviceProfile Profile)
//{
// DeviceProfileConfiguration dpc = default(DeviceProfileConfiguration);
// if (!this.deviceProfileConfigurations.TryGetValue(Profile.Id, out dpc))
// {
// dpc = new DeviceProfileConfiguration(this.Context, Profile);
// this.deviceProfileConfigurations[Profile.Id] = dpc;
// }
// return dpc;
//}
public int DefaultDeviceProfileId
{
get
{
var v = this.GetValue("DefaultDeviceProfileId", 1);
if (v > 0)
return v;
else
return 1;
}
set
{
if (value < 1)
throw new ArgumentOutOfRangeException("value", "Expected >= 1");
this.SetValue("DefaultDeviceProfileId", value);
}
}
public int DefaultAddDeviceOfflineDeviceProfileId
{
get
{
return this.GetValue("DefaultAddDeviceOfflineDeviceProfileId", 0);
}
set
{
if (value < 0)
throw new ArgumentOutOfRangeException("value", "Expected >= 0");
this.SetValue("DefaultAddDeviceOfflineDeviceProfileId", value);
}
}
}
}
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.BI.Config;
using Disco.Models.Repository;
using Newtonsoft.Json;
namespace Disco.Data.Configuration.Modules
{
public class OrganisationAddressesConfiguration : ConfigurationBase
{
public OrganisationAddressesConfiguration(ConfigurationContext Context) : base(Context) { }
public override string Scope
{
get { return "OrganisationAddresses"; }
}
public OrganisationAddress GetAddress(int Id)
{
var address = default(OrganisationAddress);
var addressString = this.GetValue<string>(Id.ToString(), null);
if (addressString != null)
{
if (addressString.StartsWith("{"))
{
// Assume Json
address = JsonConvert.DeserializeObject<OrganisationAddress>(addressString);
}
else
{
// Assume Old Storage Method
address = OrganisationAddress.FromConfigurationEntry(Id, addressString);
}
}
return address;
}
public OrganisationAddress SetAddress(OrganisationAddress Address)
{
if (!Address.Id.HasValue)
{
Address.Id = NextOrganisationAddressId;
}
string addressString = JsonConvert.SerializeObject(Address);
this.SetValue(Address.Id.ToString(), addressString); //Address.ToConfigurationEntry());
return Address;
}
public void RemoveAddress(int Id)
{
// Set Config Item to null = Remove Configuration Item
this.SetValue<string>(Id.ToString(), null);
}
public List<OrganisationAddress> Addresses
{
get
{
Dictionary<string, ConfigurationItem> configAddress = default(Dictionary<string, ConfigurationItem>);
if (this.Context.ConfigurationDictionary(this.Scope).TryGetValue(this.Scope, out configAddress))
return configAddress.Select(
ca => ca.Value.Value.StartsWith("{") ?
JsonConvert.DeserializeObject<OrganisationAddress>(ca.Value.Value) :
OrganisationAddress.FromConfigurationEntry(int.Parse(ca.Key), ca.Value.Value)
).ToList();
else
return new List<OrganisationAddress>(); // Empty List - No Addresses
}
}
private int NextOrganisationAddressId
{
get
{
int nextId = 0;
while (true)
{
if (this.Context.ConfigurationItem(this.Scope, nextId.ToString()) == null)
break;
nextId++;
}
return nextId;
}
}
}
}
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Data.Configuration.Modules
{
public class WirelessConfiguration : ConfigurationBase
{
public const string Provider_eduSTAR = "eduSTAR";
public const string Provider_eduPaSS = "eduPaSS";
public WirelessConfiguration(ConfigurationContext Context) : base(Context) { }
public override string Scope
{
get { return "Wireless"; }
}
public int CertificateAutoBufferMax
{
get
{
return this.GetValue("CertificateAutoBufferMax", 50);
}
set
{
this.SetValue("CertificateAutoBufferMax", value);
}
}
public int CertificateAutoBufferLow
{
get
{
return this.GetValue("CertificateAutoBufferLow", 10);
}
set
{
this.SetValue("CertificateAutoBufferLow", value);
}
}
public string Provider
{
get
{
return this.GetValue("Provider", Provider_eduSTAR);
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
if (value.Equals(Provider_eduSTAR, StringComparison.InvariantCultureIgnoreCase))
this.SetValue("Provider", Provider_eduSTAR);
else
throw new NotSupportedException(string.Format("Unsupported Wireless Provider: ", value));
}
}
#region eduSTAR Configuration
public string eduSTAR_Scope
{
get { return "Wireless_eduSTAR"; }
}
public string eduSTAR_ServiceAccountSchoolId
{
get
{
return this.Context.GetConfigurationValue<string>(this.eduSTAR_Scope, "ServiceAccountSchoolId", null);
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountSchoolId", value);
}
}
public string eduSTAR_ServiceAccountUsername
{
get
{
return this.Context.GetConfigurationValue<string>(this.eduSTAR_Scope, "ServiceAccountUsername", null);
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountUsername", value);
}
}
public string eduSTAR_ServiceAccountPassword
{
get
{
return ConfigurationContext.DeobsfucateValue(this.Context.GetConfigurationValue<string>(this.eduSTAR_Scope, "ServiceAccountPassword", null));
}
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentNullException("value");
this.Context.SetConfigurationValue(this.eduSTAR_Scope, "ServiceAccountPassword", ConfigurationContext.ObsfucateValue(value));
}
}
#endregion
}
}
+147
View File
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Disco.Data</RootNamespace>
<AssemblyName>Disco.Data</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\ConfigurationBase.cs" />
<Compile Include="Configuration\ConfigurationContext.cs" />
<Compile Include="Configuration\Modules\BootstrapperConfiguration.cs" />
<Compile Include="Configuration\Modules\DeviceProfileConfiguration.cs" />
<Compile Include="Configuration\Modules\DeviceProfilesConfiguration.cs" />
<Compile Include="Configuration\Modules\OrganisationAddressesConfiguration.cs" />
<Compile Include="Configuration\Modules\WirelessConfiguration.cs" />
<Compile Include="Migrations\201204250418485_DBv0.cs" />
<Compile Include="Migrations\201204250418485_DBv0.Designer.cs">
<DependentUpon>201204250418485_DBv0.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201205100307196_DBv1.cs" />
<Compile Include="Migrations\201205100307196_DBv1.Designer.cs">
<DependentUpon>201205100307196_DBv1.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201205290205162_DBv2.cs" />
<Compile Include="Migrations\201205290205162_DBv2.Designer.cs">
<DependentUpon>201205290205162_DBv2.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201206140712161_DBv3.cs" />
<Compile Include="Migrations\201206140712161_DBv3.Designer.cs">
<DependentUpon>201206140712161_DBv3.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201206280337277_DBv4.cs" />
<Compile Include="Migrations\201206280337277_DBv4.Designer.cs">
<DependentUpon>201206280337277_DBv4.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201211090325116_DBv5.cs" />
<Compile Include="Migrations\201211090325116_DBv5.Designer.cs">
<DependentUpon>201211090325116_DBv5.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201301150107063_DBv6.cs" />
<Compile Include="Migrations\201301150107063_DBv6.Designer.cs">
<DependentUpon>201301150107063_DBv6.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Repository\DiscoDatabaseConnectionFactory.cs" />
<Compile Include="Repository\DiscoDataContext.cs" />
<Compile Include="Repository\DiscoDataContextInitializer.cs" />
<Compile Include="Repository\DiscoDataSeeder.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Disco.Models\Disco.Models.csproj">
<Project>{FBC05512-FCCA-4B16-9E76-8C413C5DE6C9}</Project>
<Name>Disco.Models</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Migrations\201211090325116_DBv5.resx">
<DependentUpon>201211090325116_DBv5.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201301150107063_DBv6.resx">
<DependentUpon>201301150107063_DBv6.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\EmptyLogo.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_StartDate="2001/1/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="True" BuildVersion_BuildAction="ReBuild" />
</VisualStudio>
</ProjectExtensions>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+20
View File
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Disco.Data", "Disco.Data.csproj", "{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85A6BD19-2C64-4746-8F2C-A68A86E8C2D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File diff suppressed because one or more lines are too long
@@ -0,0 +1,604 @@
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
public partial class DBv0 : DbMigration
{
public override void Up()
{
CreateTable(
"Configuration",
c => new
{
Scope = c.String(nullable: false, maxLength: 80),
Key = c.String(nullable: false, maxLength: 80),
Value = c.String(),
})
.PrimaryKey(t => new { t.Scope, t.Key });
CreateTable(
"DocumentTemplates",
c => new
{
Id = c.String(nullable: false, maxLength: 30),
Description = c.String(nullable: false, maxLength: 250),
Scope = c.String(nullable: false, maxLength: 6),
FilterExpression = c.String(maxLength: 250),
})
.PrimaryKey(t => t.Id);
CreateTable(
"JobSubTypes",
c => new
{
Id = c.String(nullable: false, maxLength: 20),
JobTypeId = c.String(nullable: false, maxLength: 5),
Description = c.String(nullable: false, maxLength: 100),
})
.PrimaryKey(t => new { t.Id, t.JobTypeId })
.ForeignKey("JobTypes", t => t.JobTypeId)
.Index(t => t.JobTypeId);
CreateTable(
"DeviceComponents",
c => new
{
Id = c.Int(nullable: false, identity: true),
DeviceModelId = c.Int(),
Description = c.String(maxLength: 100),
Cost = c.Decimal(nullable: false, precision: 18, scale: 2),
})
.PrimaryKey(t => t.Id)
.ForeignKey("DeviceModels", t => t.DeviceModelId)
.Index(t => t.DeviceModelId);
CreateTable(
"DeviceModels",
c => new
{
Id = c.Int(nullable: false, identity: true),
Description = c.String(maxLength: 500),
Manufacturer = c.String(maxLength: 200),
Model = c.String(maxLength: 200),
ModelType = c.String(maxLength: 40),
Image = c.Binary(),
DefaultPurchaseDate = c.DateTime(),
DeviceCost = c.Decimal(precision: 18, scale: 2),
DefaultWarrantyProvider = c.String(maxLength: 40),
})
.PrimaryKey(t => t.Id);
CreateTable(
"Devices",
c => new
{
SerialNumber = c.String(nullable: false, maxLength: 40),
AssetNumber = c.String(maxLength: 40),
Location = c.String(maxLength: 250),
DeviceModelId = c.Int(),
DeviceProfileId = c.Int(nullable: false),
DeviceBatchId = c.Int(),
ComputerName = c.String(maxLength: 24),
AssignedUserId = c.String(maxLength: 50),
LastNetworkLogonDate = c.DateTime(),
CertificateStoreReference = c.String(maxLength: 24),
AllowUnauthenticatedEnrol = c.Boolean(nullable: false),
Active = c.Boolean(nullable: false),
CreatedDate = c.DateTime(nullable: false),
EnrolledDate = c.DateTime(),
LastEnrolDate = c.DateTime(),
DecommissionedDate = c.DateTime(),
})
.PrimaryKey(t => t.SerialNumber)
.ForeignKey("DeviceModels", t => t.DeviceModelId)
.ForeignKey("DeviceProfiles", t => t.DeviceProfileId)
.ForeignKey("DeviceBatches", t => t.DeviceBatchId)
.ForeignKey("Users", t => t.AssignedUserId)
.Index(t => t.DeviceModelId)
.Index(t => t.DeviceProfileId)
.Index(t => t.DeviceBatchId)
.Index(t => t.AssignedUserId);
CreateTable(
"DeviceProfiles",
c => new
{
Id = c.Int(nullable: false, identity: true),
Name = c.String(nullable: false, maxLength: 100),
ShortName = c.String(nullable: false, maxLength: 10),
Description = c.String(maxLength: 500),
DefaultOrganisationAddress = c.Int(),
})
.PrimaryKey(t => t.Id);
CreateTable(
"DeviceBatches",
c => new
{
Id = c.Int(nullable: false, identity: true),
Name = c.String(maxLength: 500),
PurchaseDate = c.DateTime(nullable: false),
Supplier = c.String(maxLength: 200),
PurchaseDetails = c.String(maxLength: 500),
UnitCost = c.Decimal(precision: 18, scale: 2),
UnitQuantity = c.Int(),
DefaultDeviceModelId = c.Int(),
WarrantyValidUntil = c.DateTime(),
WarrantyDetails = c.String(),
InsuredDate = c.DateTime(),
InsuranceSupplier = c.String(maxLength: 200),
InsuredUntil = c.DateTime(),
InsuranceDetails = c.String(),
Comments = c.String(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("DeviceModels", t => t.DefaultDeviceModelId)
.Index(t => t.DefaultDeviceModelId);
CreateTable(
"Users",
c => new
{
Id = c.String(nullable: false, maxLength: 50),
DisplayName = c.String(maxLength: 200),
Surname = c.String(maxLength: 200),
GivenName = c.String(maxLength: 200),
Type = c.String(maxLength: 8),
PhoneNumber = c.String(maxLength: 100),
EmailAddress = c.String(maxLength: 150),
})
.PrimaryKey(t => t.Id);
CreateTable(
"UserDetails",
c => new
{
UserId = c.String(nullable: false, maxLength: 50),
Scope = c.String(nullable: false, maxLength: 100),
Key = c.String(nullable: false, maxLength: 100),
Value = c.String(),
})
.PrimaryKey(t => new { t.UserId, t.Scope, t.Key })
.ForeignKey("Users", t => t.UserId)
.Index(t => t.UserId);
CreateTable(
"UserAttachments",
c => new
{
Id = c.Int(nullable: false, identity: true),
UserId = c.String(maxLength: 50),
TechUserId = c.String(nullable: false, maxLength: 50),
Filename = c.String(nullable: false, maxLength: 500),
MimeType = c.String(nullable: false, maxLength: 500),
Timestamp = c.DateTime(nullable: false),
Comments = c.String(nullable: false, maxLength: 500),
DocumentTemplateId = c.String(maxLength: 30),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Users", t => t.UserId)
.ForeignKey("Users", t => t.TechUserId)
.ForeignKey("DocumentTemplates", t => t.DocumentTemplateId)
.Index(t => t.UserId)
.Index(t => t.TechUserId)
.Index(t => t.DocumentTemplateId);
CreateTable(
"DeviceUserAssignments",
c => new
{
DeviceSerialNumber = c.String(nullable: false, maxLength: 40),
AssignedDate = c.DateTime(nullable: false),
AssignedUserId = c.String(maxLength: 50),
UnassignedDate = c.DateTime(),
})
.PrimaryKey(t => new { t.DeviceSerialNumber, t.AssignedDate })
.ForeignKey("Users", t => t.AssignedUserId)
.ForeignKey("Devices", t => t.DeviceSerialNumber)
.Index(t => t.AssignedUserId)
.Index(t => t.DeviceSerialNumber);
CreateTable(
"Jobs",
c => new
{
Id = c.Int(nullable: false, identity: true),
JobTypeId = c.String(nullable: false, maxLength: 5),
DeviceSerialNumber = c.String(maxLength: 40),
UserId = c.String(maxLength: 50),
OpenedTechUserId = c.String(nullable: false, maxLength: 50),
OpenedDate = c.DateTime(nullable: false),
ExpectedClosedDate = c.DateTime(),
ClosedTechUserId = c.String(maxLength: 50),
ClosedDate = c.DateTime(),
DeviceHeld = c.DateTime(),
DeviceHeldTechUserId = c.String(maxLength: 50),
DeviceHeldLocation = c.String(maxLength: 100),
DeviceReadyForReturn = c.DateTime(),
DeviceReadyForReturnTechUserId = c.String(maxLength: 50),
DeviceReturnedDate = c.DateTime(),
DeviceReturnedTechUserId = c.String(maxLength: 50),
WaitingForUserAction = c.DateTime(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("JobTypes", t => t.JobTypeId)
.ForeignKey("Users", t => t.OpenedTechUserId)
.ForeignKey("Users", t => t.ClosedTechUserId)
.ForeignKey("Users", t => t.DeviceHeldTechUserId)
.ForeignKey("Users", t => t.DeviceReadyForReturnTechUserId)
.ForeignKey("Users", t => t.DeviceReturnedTechUserId)
.ForeignKey("Users", t => t.UserId)
.ForeignKey("Devices", t => t.DeviceSerialNumber)
.Index(t => t.JobTypeId)
.Index(t => t.OpenedTechUserId)
.Index(t => t.ClosedTechUserId)
.Index(t => t.DeviceHeldTechUserId)
.Index(t => t.DeviceReadyForReturnTechUserId)
.Index(t => t.DeviceReturnedTechUserId)
.Index(t => t.UserId)
.Index(t => t.DeviceSerialNumber);
CreateTable(
"JobTypes",
c => new
{
Id = c.String(nullable: false, maxLength: 5),
Description = c.String(maxLength: 100),
})
.PrimaryKey(t => t.Id);
CreateTable(
"JobAttachments",
c => new
{
Id = c.Int(nullable: false, identity: true),
JobId = c.Int(nullable: false),
TechUserId = c.String(nullable: false, maxLength: 50),
Filename = c.String(nullable: false, maxLength: 500),
MimeType = c.String(nullable: false, maxLength: 500),
Timestamp = c.DateTime(nullable: false),
Comments = c.String(nullable: false, maxLength: 500),
DocumentTemplateId = c.String(maxLength: 30),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Jobs", t => t.JobId)
.ForeignKey("Users", t => t.TechUserId)
.ForeignKey("DocumentTemplates", t => t.DocumentTemplateId)
.Index(t => t.JobId)
.Index(t => t.TechUserId)
.Index(t => t.DocumentTemplateId);
CreateTable(
"JobComponents",
c => new
{
Id = c.Int(nullable: false, identity: true),
JobId = c.Int(nullable: false),
TechUserId = c.String(nullable: false, maxLength: 50),
Description = c.String(maxLength: 500),
Cost = c.Decimal(nullable: false, precision: 18, scale: 2),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Jobs", t => t.JobId)
.ForeignKey("Users", t => t.TechUserId)
.Index(t => t.JobId)
.Index(t => t.TechUserId);
CreateTable(
"JobLogs",
c => new
{
Id = c.Int(nullable: false, identity: true),
JobId = c.Int(nullable: false),
TechUserId = c.String(nullable: false, maxLength: 50),
Timestamp = c.DateTime(nullable: false),
Comments = c.String(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Jobs", t => t.JobId)
.ForeignKey("Users", t => t.TechUserId)
.Index(t => t.JobId)
.Index(t => t.TechUserId);
CreateTable(
"JobMetaInsurances",
c => new
{
JobId = c.Int(nullable: false),
LossOrDamageDate = c.DateTime(),
EventLocation = c.String(maxLength: 200),
Description = c.String(),
ThirdPartyCaused = c.Boolean(nullable: false),
ThirdPartyCausedName = c.String(maxLength: 200),
ThirdPartyCausedWhy = c.String(maxLength: 600),
WitnessesNamesAddresses = c.String(maxLength: 1200),
BurglaryTheftMethodOfEntry = c.String(maxLength: 200),
PropertyLastSeenDate = c.DateTime(),
PoliceNotified = c.Boolean(nullable: false),
PoliceNotifiedStation = c.String(maxLength: 200),
PoliceNotifiedDate = c.DateTime(),
PoliceNotifiedCrimeReportNo = c.String(maxLength: 400),
RecoverReduceAction = c.String(maxLength: 800),
OtherInterestedParties = c.String(maxLength: 500),
DateOfPurchase = c.DateTime(),
ClaimFormSentDate = c.DateTime(),
ClaimFormSentUserId = c.String(maxLength: 50),
})
.PrimaryKey(t => t.JobId)
.ForeignKey("Jobs", t => t.JobId)
.ForeignKey("Users", t => t.ClaimFormSentUserId)
.Index(t => t.JobId)
.Index(t => t.ClaimFormSentUserId);
CreateTable(
"JobMetaWarranties",
c => new
{
JobId = c.Int(nullable: false),
ExternalName = c.String(maxLength: 100),
ExternalLoggedDate = c.DateTime(),
ExternalReference = c.String(maxLength: 100),
ExternalCompletedDate = c.DateTime(),
})
.PrimaryKey(t => t.JobId)
.ForeignKey("Jobs", t => t.JobId)
.Index(t => t.JobId);
CreateTable(
"JobMetaNonWarranties",
c => new
{
JobId = c.Int(nullable: false),
IsInsuranceClaim = c.Boolean(nullable: false),
AccountingChargeAddedDate = c.DateTime(),
AccountingChargeAddedUserId = c.String(maxLength: 50),
AccountingChargePaidDate = c.DateTime(),
AccountingChargePaidUserId = c.String(maxLength: 50),
PurchaseOrderRaisedDate = c.DateTime(),
PurchaseOrderRaisedUserId = c.String(maxLength: 50),
PurchaseOrderReference = c.String(maxLength: 20),
PurchaseOrderSentDate = c.DateTime(),
PurchaseOrderSentUserId = c.String(maxLength: 50),
InvoiceReceivedDate = c.DateTime(),
InvoiceReceivedUserId = c.String(maxLength: 50),
RepairerName = c.String(maxLength: 100),
RepairerLoggedDate = c.DateTime(),
RepairerReference = c.String(maxLength: 100),
RepairerCompletedDate = c.DateTime(),
})
.PrimaryKey(t => t.JobId)
.ForeignKey("Users", t => t.AccountingChargeAddedUserId)
.ForeignKey("Users", t => t.AccountingChargePaidUserId)
.ForeignKey("Users", t => t.PurchaseOrderRaisedUserId)
.ForeignKey("Users", t => t.PurchaseOrderSentUserId)
.ForeignKey("Users", t => t.InvoiceReceivedUserId)
.ForeignKey("Jobs", t => t.JobId)
.Index(t => t.AccountingChargeAddedUserId)
.Index(t => t.AccountingChargePaidUserId)
.Index(t => t.PurchaseOrderRaisedUserId)
.Index(t => t.PurchaseOrderSentUserId)
.Index(t => t.InvoiceReceivedUserId)
.Index(t => t.JobId);
CreateTable(
"DeviceDetails",
c => new
{
DeviceSerialNumber = c.String(nullable: false, maxLength: 40),
Scope = c.String(nullable: false, maxLength: 100),
Key = c.String(nullable: false, maxLength: 100),
Value = c.String(),
})
.PrimaryKey(t => new { t.DeviceSerialNumber, t.Scope, t.Key })
.ForeignKey("Devices", t => t.DeviceSerialNumber)
.Index(t => t.DeviceSerialNumber);
CreateTable(
"DeviceAttachments",
c => new
{
Id = c.Int(nullable: false, identity: true),
DeviceSerialNumber = c.String(maxLength: 40),
TechUserId = c.String(nullable: false, maxLength: 50),
Filename = c.String(nullable: false, maxLength: 500),
MimeType = c.String(nullable: false, maxLength: 500),
Timestamp = c.DateTime(nullable: false),
Comments = c.String(nullable: false, maxLength: 500),
DocumentTemplateId = c.String(maxLength: 30),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Devices", t => t.DeviceSerialNumber)
.ForeignKey("Users", t => t.TechUserId)
.ForeignKey("DocumentTemplates", t => t.DocumentTemplateId)
.Index(t => t.DeviceSerialNumber)
.Index(t => t.TechUserId)
.Index(t => t.DocumentTemplateId);
CreateTable(
"WirelessCertificates",
c => new
{
Id = c.Int(nullable: false, identity: true),
Index = c.Int(nullable: false),
Name = c.String(maxLength: 28),
Content = c.Binary(),
Enabled = c.Boolean(nullable: false),
ExpirationDate = c.DateTime(),
AllocatedDate = c.DateTime(),
DeviceSerialNumber = c.String(maxLength: 40),
})
.PrimaryKey(t => t.Id)
.ForeignKey("Devices", t => t.DeviceSerialNumber)
.Index(t => t.DeviceSerialNumber);
CreateTable(
"Jobs_JobSubTypes",
c => new
{
Job_Id = c.Int(nullable: false),
JobSubType_Id = c.String(nullable: false, maxLength: 20),
JobSubType_JobTypeId = c.String(nullable: false, maxLength: 5),
})
.PrimaryKey(t => new { t.Job_Id, t.JobSubType_Id, t.JobSubType_JobTypeId })
.ForeignKey("Jobs", t => t.Job_Id, cascadeDelete: true)
.ForeignKey("JobSubTypes", t => new { t.JobSubType_Id, t.JobSubType_JobTypeId }, cascadeDelete: true)
.Index(t => t.Job_Id)
.Index(t => new { t.JobSubType_Id, t.JobSubType_JobTypeId });
CreateTable(
"DeviceComponents_JobSubTypes",
c => new
{
DeviceComponent_Id = c.Int(nullable: false),
JobSubType_Id = c.String(nullable: false, maxLength: 20),
JobSubType_JobTypeId = c.String(nullable: false, maxLength: 5),
})
.PrimaryKey(t => new { t.DeviceComponent_Id, t.JobSubType_Id, t.JobSubType_JobTypeId })
.ForeignKey("DeviceComponents", t => t.DeviceComponent_Id, cascadeDelete: true)
.ForeignKey("JobSubTypes", t => new { t.JobSubType_Id, t.JobSubType_JobTypeId }, cascadeDelete: true)
.Index(t => t.DeviceComponent_Id)
.Index(t => new { t.JobSubType_Id, t.JobSubType_JobTypeId });
CreateTable(
"DocumentTemplates_JobSubTypes",
c => new
{
DocumentTemplate_Id = c.String(nullable: false, maxLength: 30),
JobSubType_Id = c.String(nullable: false, maxLength: 20),
JobSubType_JobTypeId = c.String(nullable: false, maxLength: 5),
})
.PrimaryKey(t => new { t.DocumentTemplate_Id, t.JobSubType_Id, t.JobSubType_JobTypeId })
.ForeignKey("DocumentTemplates", t => t.DocumentTemplate_Id, cascadeDelete: true)
.ForeignKey("JobSubTypes", t => new { t.JobSubType_Id, t.JobSubType_JobTypeId }, cascadeDelete: true)
.Index(t => t.DocumentTemplate_Id)
.Index(t => new { t.JobSubType_Id, t.JobSubType_JobTypeId });
}
public override void Down()
{
DropIndex("DocumentTemplates_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" });
DropIndex("DocumentTemplates_JobSubTypes", new[] { "DocumentTemplate_Id" });
DropIndex("DeviceComponents_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" });
DropIndex("DeviceComponents_JobSubTypes", new[] { "DeviceComponent_Id" });
DropIndex("Jobs_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" });
DropIndex("Jobs_JobSubTypes", new[] { "Job_Id" });
DropIndex("WirelessCertificates", new[] { "DeviceSerialNumber" });
DropIndex("DeviceAttachments", new[] { "DocumentTemplateId" });
DropIndex("DeviceAttachments", new[] { "TechUserId" });
DropIndex("DeviceAttachments", new[] { "DeviceSerialNumber" });
DropIndex("DeviceDetails", new[] { "DeviceSerialNumber" });
DropIndex("JobMetaNonWarranties", new[] { "JobId" });
DropIndex("JobMetaNonWarranties", new[] { "InvoiceReceivedUserId" });
DropIndex("JobMetaNonWarranties", new[] { "PurchaseOrderSentUserId" });
DropIndex("JobMetaNonWarranties", new[] { "PurchaseOrderRaisedUserId" });
DropIndex("JobMetaNonWarranties", new[] { "AccountingChargePaidUserId" });
DropIndex("JobMetaNonWarranties", new[] { "AccountingChargeAddedUserId" });
DropIndex("JobMetaWarranties", new[] { "JobId" });
DropIndex("JobMetaInsurances", new[] { "ClaimFormSentUserId" });
DropIndex("JobMetaInsurances", new[] { "JobId" });
DropIndex("JobLogs", new[] { "TechUserId" });
DropIndex("JobLogs", new[] { "JobId" });
DropIndex("JobComponents", new[] { "TechUserId" });
DropIndex("JobComponents", new[] { "JobId" });
DropIndex("JobAttachments", new[] { "DocumentTemplateId" });
DropIndex("JobAttachments", new[] { "TechUserId" });
DropIndex("JobAttachments", new[] { "JobId" });
DropIndex("Jobs", new[] { "DeviceSerialNumber" });
DropIndex("Jobs", new[] { "UserId" });
DropIndex("Jobs", new[] { "DeviceReturnedTechUserId" });
DropIndex("Jobs", new[] { "DeviceReadyForReturnTechUserId" });
DropIndex("Jobs", new[] { "DeviceHeldTechUserId" });
DropIndex("Jobs", new[] { "ClosedTechUserId" });
DropIndex("Jobs", new[] { "OpenedTechUserId" });
DropIndex("Jobs", new[] { "JobTypeId" });
DropIndex("DeviceUserAssignments", new[] { "DeviceSerialNumber" });
DropIndex("DeviceUserAssignments", new[] { "AssignedUserId" });
DropIndex("UserAttachments", new[] { "DocumentTemplateId" });
DropIndex("UserAttachments", new[] { "TechUserId" });
DropIndex("UserAttachments", new[] { "UserId" });
DropIndex("UserDetails", new[] { "UserId" });
DropIndex("DeviceBatches", new[] { "DefaultDeviceModelId" });
DropIndex("Devices", new[] { "AssignedUserId" });
DropIndex("Devices", new[] { "DeviceBatchId" });
DropIndex("Devices", new[] { "DeviceProfileId" });
DropIndex("Devices", new[] { "DeviceModelId" });
DropIndex("DeviceComponents", new[] { "DeviceModelId" });
DropIndex("JobSubTypes", new[] { "JobTypeId" });
DropForeignKey("DocumentTemplates_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" }, "JobSubTypes");
DropForeignKey("DocumentTemplates_JobSubTypes", "DocumentTemplate_Id", "DocumentTemplates");
DropForeignKey("DeviceComponents_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" }, "JobSubTypes");
DropForeignKey("DeviceComponents_JobSubTypes", "DeviceComponent_Id", "DeviceComponents");
DropForeignKey("Jobs_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" }, "JobSubTypes");
DropForeignKey("Jobs_JobSubTypes", "Job_Id", "Jobs");
DropForeignKey("WirelessCertificates", "DeviceSerialNumber", "Devices");
DropForeignKey("DeviceAttachments", "DocumentTemplateId", "DocumentTemplates");
DropForeignKey("DeviceAttachments", "TechUserId", "Users");
DropForeignKey("DeviceAttachments", "DeviceSerialNumber", "Devices");
DropForeignKey("DeviceDetails", "DeviceSerialNumber", "Devices");
DropForeignKey("JobMetaNonWarranties", "JobId", "Jobs");
DropForeignKey("JobMetaNonWarranties", "InvoiceReceivedUserId", "Users");
DropForeignKey("JobMetaNonWarranties", "PurchaseOrderSentUserId", "Users");
DropForeignKey("JobMetaNonWarranties", "PurchaseOrderRaisedUserId", "Users");
DropForeignKey("JobMetaNonWarranties", "AccountingChargePaidUserId", "Users");
DropForeignKey("JobMetaNonWarranties", "AccountingChargeAddedUserId", "Users");
DropForeignKey("JobMetaWarranties", "JobId", "Jobs");
DropForeignKey("JobMetaInsurances", "ClaimFormSentUserId", "Users");
DropForeignKey("JobMetaInsurances", "JobId", "Jobs");
DropForeignKey("JobLogs", "TechUserId", "Users");
DropForeignKey("JobLogs", "JobId", "Jobs");
DropForeignKey("JobComponents", "TechUserId", "Users");
DropForeignKey("JobComponents", "JobId", "Jobs");
DropForeignKey("JobAttachments", "DocumentTemplateId", "DocumentTemplates");
DropForeignKey("JobAttachments", "TechUserId", "Users");
DropForeignKey("JobAttachments", "JobId", "Jobs");
DropForeignKey("Jobs", "DeviceSerialNumber", "Devices");
DropForeignKey("Jobs", "UserId", "Users");
DropForeignKey("Jobs", "DeviceReturnedTechUserId", "Users");
DropForeignKey("Jobs", "DeviceReadyForReturnTechUserId", "Users");
DropForeignKey("Jobs", "DeviceHeldTechUserId", "Users");
DropForeignKey("Jobs", "ClosedTechUserId", "Users");
DropForeignKey("Jobs", "OpenedTechUserId", "Users");
DropForeignKey("Jobs", "JobTypeId", "JobTypes");
DropForeignKey("DeviceUserAssignments", "DeviceSerialNumber", "Devices");
DropForeignKey("DeviceUserAssignments", "AssignedUserId", "Users");
DropForeignKey("UserAttachments", "DocumentTemplateId", "DocumentTemplates");
DropForeignKey("UserAttachments", "TechUserId", "Users");
DropForeignKey("UserAttachments", "UserId", "Users");
DropForeignKey("UserDetails", "UserId", "Users");
DropForeignKey("DeviceBatches", "DefaultDeviceModelId", "DeviceModels");
DropForeignKey("Devices", "AssignedUserId", "Users");
DropForeignKey("Devices", "DeviceBatchId", "DeviceBatches");
DropForeignKey("Devices", "DeviceProfileId", "DeviceProfiles");
DropForeignKey("Devices", "DeviceModelId", "DeviceModels");
DropForeignKey("DeviceComponents", "DeviceModelId", "DeviceModels");
DropForeignKey("JobSubTypes", "JobTypeId", "JobTypes");
DropTable("DocumentTemplates_JobSubTypes");
DropTable("DeviceComponents_JobSubTypes");
DropTable("Jobs_JobSubTypes");
DropTable("WirelessCertificates");
DropTable("DeviceAttachments");
DropTable("DeviceDetails");
DropTable("JobMetaNonWarranties");
DropTable("JobMetaWarranties");
DropTable("JobMetaInsurances");
DropTable("JobLogs");
DropTable("JobComponents");
DropTable("JobAttachments");
DropTable("JobTypes");
DropTable("Jobs");
DropTable("DeviceUserAssignments");
DropTable("UserAttachments");
DropTable("UserDetails");
DropTable("Users");
DropTable("DeviceBatches");
DropTable("DeviceProfiles");
DropTable("Devices");
DropTable("DeviceModels");
DropTable("DeviceComponents");
DropTable("JobSubTypes");
DropTable("DocumentTemplates");
DropTable("Configuration");
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,25 @@
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
public partial class DBv1 : DbMigration
{
public override void Up()
{
AddColumn("DocumentTemplates", "FlattenForm", c => c.Boolean(nullable: false, defaultValue: false));
AddColumn("JobMetaNonWarranties", "AccountingChargeRequiredDate", c => c.DateTime());
AddColumn("JobMetaNonWarranties", "AccountingChargeRequiredUserId", c => c.String(maxLength: 50));
AddForeignKey("JobMetaNonWarranties", "AccountingChargeRequiredUserId", "Users", "Id");
CreateIndex("JobMetaNonWarranties", "AccountingChargeRequiredUserId");
}
public override void Down()
{
DropIndex("JobMetaNonWarranties", new[] { "AccountingChargeRequiredUserId" });
DropForeignKey("JobMetaNonWarranties", "AccountingChargeRequiredUserId", "Users");
DropColumn("JobMetaNonWarranties", "AccountingChargeRequiredUserId");
DropColumn("JobMetaNonWarranties", "AccountingChargeRequiredDate");
DropColumn("DocumentTemplates", "FlattenForm");
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,17 @@
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
public partial class DBv2 : DbMigration
{
public override void Up()
{
AddColumn("Jobs", "Flags", c => c.Long());
}
public override void Down()
{
DropColumn("Jobs", "Flags");
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,30 @@
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
public partial class DBv3 : DbMigration
{
public override void Up()
{
AddColumn("DeviceProfiles", "ComputerNameTemplate", c => c.String(nullable: true));
Sql(@"UPDATE DeviceProfiles SET ComputerNameTemplate='DeviceProfile.ShortName + ''-'' + SerialNumber'");
AlterColumn("DeviceProfiles", "ComputerNameTemplate", c => c.String(nullable: false));
AddColumn("DeviceProfiles", "DistributionType", c => c.Int(nullable: false));
AddColumn("DeviceProfiles", "OrganisationalUnit", c => c.String());
AddColumn("DeviceProfiles", "AllocateWirelessCertificate", c => c.Boolean(nullable: false));
AddColumn("DeviceProfiles", "EnforceComputerNameConvention", c => c.Boolean(nullable: false));
AddColumn("DeviceProfiles", "EnforceOrganisationalUnit", c => c.Boolean(nullable: false));
}
public override void Down()
{
DropColumn("DeviceProfiles", "EnforceOrganisationalUnit");
DropColumn("DeviceProfiles", "EnforceComputerNameConvention");
DropColumn("DeviceProfiles", "AllocateWirelessCertificate");
DropColumn("DeviceProfiles", "OrganisationalUnit");
DropColumn("DeviceProfiles", "DistributionType");
DropColumn("DeviceProfiles", "ComputerNameTemplate");
}
}
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,52 @@
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
public partial class DBv4 : DbMigration
{
public override void Up()
{
AddColumn("DeviceProfiles", "ProvisionADAccount", c => c.Boolean(nullable: false));
Sql(@"UPDATE [DeviceProfiles] SET [ProvisionADAccount]=1;");
DropColumn("Devices", "CertificateStoreReference");
RenameTable(name: "WirelessCertificates", newName: "DeviceCertificates");
AddColumn("DeviceCertificates", "ProviderId", c => c.String(maxLength: 64));
RenameColumn("DeviceCertificates", "Index", "ProviderIndex");
Sql("UPDATE DeviceCertificates SET ProviderId='EduSTARnetCertificateProvider'");
AlterColumn("DeviceCertificates", "ProviderId", c => c.String(nullable: false, maxLength: 64));
//RenameColumn("DeviceProfiles", "AllocateWirelessCertificate", "AllocateCertificate");
AddColumn("DeviceProfiles", "CertificateProviderId", c => c.String(maxLength: 64));
Sql(@"UPDATE [DeviceProfiles] SET [CertificateProviderId]='EduSTARnetCertificateProvider' WHERE [AllocateWirelessCertificate]=1;");
// Migrate eduSTAR.net Configuration
Sql(@"UPDATE [Configuration] SET [Scope]='CertificateProvider_eduSTAR.net', [Key]='AutoBufferMin' WHERE [Scope]='Wireless' AND [Key]='CertificateAutoBufferLow';
UPDATE [Configuration] SET [Scope]='CertificateProvider_eduSTAR.net', [Key]='AutoBufferMax' WHERE [Scope]='Wireless' AND [Key]='CertificateAutoBufferMax';
UPDATE [Configuration] SET [Scope]='CertificateProvider_eduSTAR.net', [Key]='ServicePassword' WHERE [Scope]='Wireless_eduSTAR' AND [Key]='ServiceAccountPassword';
UPDATE [Configuration] SET [Scope]='CertificateProvider_eduSTAR.net', [Key]='SchoolId' WHERE [Scope]='Wireless_eduSTAR' AND [Key]='ServiceAccountSchoolId';
UPDATE [Configuration] SET [Scope]='CertificateProvider_eduSTAR.net', [Key]='ServiceUsername' WHERE [Scope]='Wireless_eduSTAR' AND [Key]='ServiceAccountUsername';"
);
Sql(@"UPDATE [DeviceModels] SET [DefaultWarrantyProvider]='LWTWarrantyProvider' WHERE [DefaultWarrantyProvider]='LWT';");
DropColumn("DeviceProfiles", "AllocateWirelessCertificate");
}
public override void Down()
{
AddColumn("DeviceProfiles", "AllocateWirelessCertificate", c => c.Boolean(nullable: false));
RenameColumn("DeviceCertificates", "ProviderIndex", "Index");
DropColumn("DeviceCertificates", "ProviderId");
RenameTable(name: "DeviceCertificates", newName: "WirelessCertificates");
DropColumn("DeviceProfiles", "CertificateProviderId");
AddColumn("Devices", "CertificateStoreReference", c => c.String(maxLength: 24));
DropColumn("DeviceProfiles", "ProvisionADAccount");
}
}
}
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv5 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv5));
string IMigrationMetadata.Id
{
get { return "201211090325116_DBv5"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,96 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv5 : DbMigration
{
public override void Up()
{
// Drop Foreign Keys
// 2012-11-09 - G#
// ForeignKey Names are not consistant among databases - Especially version 4.3.1 -> 5.0.0.net45
#region "Support inconsistant foreign key names"
// DeviceCertificates was renamed from WirelessCertificates
Sql(@"
BEGIN TRY
ALTER TABLE [dbo].[DeviceCertificates] DROP CONSTRAINT [FK_dbo.DeviceCertificates_dbo.Devices_DeviceSerialNumber];
END TRY
BEGIN CATCH
ALTER TABLE [dbo].[DeviceCertificates] DROP CONSTRAINT [FK_WirelessCertificates_Devices_DeviceSerialNumber];
END CATCH;", true);
// DeviceAttachments
Sql(@"
BEGIN TRY
ALTER TABLE [dbo].[DeviceAttachments] DROP CONSTRAINT [FK_dbo.DeviceAttachments_dbo.Devices_DeviceSerialNumber];
END TRY
BEGIN CATCH
ALTER TABLE [dbo].[DeviceAttachments] DROP CONSTRAINT [FK_DeviceAttachments_Devices_DeviceSerialNumber];
END CATCH;", true);
// DeviceDetails
Sql(@"
BEGIN TRY
ALTER TABLE [dbo].[DeviceDetails] DROP CONSTRAINT [FK_dbo.DeviceDetails_dbo.Devices_DeviceSerialNumber];
END TRY
BEGIN CATCH
ALTER TABLE [dbo].[DeviceDetails] DROP CONSTRAINT [FK_DeviceDetails_Devices_DeviceSerialNumber];
END CATCH;", true);
// Jobs
Sql(@"
BEGIN TRY
ALTER TABLE [dbo].[Jobs] DROP CONSTRAINT [FK_dbo.Jobs_dbo.Devices_DeviceSerialNumber];
END TRY
BEGIN CATCH
ALTER TABLE [dbo].[Jobs] DROP CONSTRAINT [FK_Jobs_Devices_DeviceSerialNumber];
END CATCH;", true);
// DeviceUserAssignments
Sql(@"
BEGIN TRY
ALTER TABLE [dbo].[DeviceUserAssignments] DROP CONSTRAINT [FK_dbo.DeviceUserAssignments_dbo.Devices_DeviceSerialNumber];
END TRY
BEGIN CATCH
ALTER TABLE [dbo].[DeviceUserAssignments] DROP CONSTRAINT [FK_DeviceUserAssignments_Devices_DeviceSerialNumber];
END CATCH;", true);
#endregion
AlterColumn("dbo.Devices", "SerialNumber", c => c.String(nullable: false, maxLength: 60));
AlterColumn("dbo.DeviceUserAssignments", "DeviceSerialNumber", c => c.String(nullable: false, maxLength: 60));
AlterColumn("dbo.Jobs", "DeviceSerialNumber", c => c.String(maxLength: 60));
AlterColumn("dbo.DeviceDetails", "DeviceSerialNumber", c => c.String(nullable: false, maxLength: 60));
AlterColumn("dbo.DeviceAttachments", "DeviceSerialNumber", c => c.String(maxLength: 60));
AlterColumn("dbo.DeviceCertificates", "DeviceSerialNumber", c => c.String(maxLength: 60));
// Re-create Foreign Keys
AddForeignKey("dbo.DeviceCertificates", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceAttachments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceDetails", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.Jobs", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceUserAssignments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
}
public override void Down()
{
// Drop Foreign Keys
DropForeignKey("dbo.DeviceCertificates", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
DropForeignKey("dbo.DeviceAttachments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
DropForeignKey("dbo.DeviceDetails", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
DropForeignKey("dbo.Jobs", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
DropForeignKey("dbo.DeviceUserAssignments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AlterColumn("dbo.DeviceCertificates", "DeviceSerialNumber", c => c.String(maxLength: 40));
AlterColumn("dbo.DeviceAttachments", "DeviceSerialNumber", c => c.String(maxLength: 40));
AlterColumn("dbo.DeviceDetails", "DeviceSerialNumber", c => c.String(nullable: false, maxLength: 40));
AlterColumn("dbo.Jobs", "DeviceSerialNumber", c => c.String(maxLength: 40));
AlterColumn("dbo.DeviceUserAssignments", "DeviceSerialNumber", c => c.String(nullable: false, maxLength: 40));
AlterColumn("dbo.Devices", "SerialNumber", c => c.String(nullable: false, maxLength: 40));
// Re-create Foreign Keys
AddForeignKey("dbo.DeviceCertificates", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceAttachments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceDetails", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.Jobs", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
AddForeignKey("dbo.DeviceUserAssignments", "DeviceSerialNumber", "dbo.Devices", "SerialNumber");
}
}
}
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv6 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv6));
string IMigrationMetadata.Id
{
get { return "201301150107063_DBv6"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,18 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv6 : DbMigration
{
public override void Up()
{
DropColumn("dbo.DeviceModels", "Image");
}
public override void Down()
{
AddColumn("dbo.DeviceModels", "Image", c => c.Binary());
}
}
}
File diff suppressed because one or more lines are too long
+21
View File
@@ -0,0 +1,21 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using Disco.Data.Repository;
internal sealed class Configuration : DbMigrationsConfiguration<DiscoDataContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(DiscoDataContext context)
{
context.SeedDatabase();
}
}
}
@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using Disco.Data.Repository;
namespace Disco.Data.Migrations
{
public static class DiscoDataMigrator
{
private static DbMigrator GetMigrator()
{
var migContext = new DbMigrationsConfiguration<DiscoDataContext>();
migContext.MigrationsAssembly = typeof(DiscoDataMigrator).Assembly;
migContext.MigrationsNamespace = "Disco.Data.Migrations";
return new DbMigrator(migContext);
}
public static void MigrateLatest(bool Seed)
{
var migrator = GetMigrator();
migrator.Update();
if (Seed)
SeedDatabase();
}
public static void ForceMigration(string TargetMigration, bool Seed)
{
var migrator = GetMigrator();
migrator.Update(TargetMigration);
if (Seed)
SeedDatabase();
}
public static string MigrationScript(string CurrentMigration, string TargetMigration)
{
var migrator = GetMigrator();
var scriptor = new MigratorScriptingDecorator(migrator);
return scriptor.ScriptUpdate(CurrentMigration, TargetMigration);
}
public static void SeedDatabase()
{
// Seed/Update Database
using (DiscoDataContext dbContext = new DiscoDataContext())
{
dbContext.SeedDatabase();
try
{
dbContext.SaveChanges();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
throw;
}
}
}
public static MigrationStatus Status()
{
var migrator = GetMigrator();
var appliedMigrations = migrator.GetDatabaseMigrations().ToList();
var pendingMigrations = migrator.GetPendingMigrations().ToList();
var currentMigration = appliedMigrations.LastOrDefault();
return new MigrationStatus()
{
CurrentMigration = currentMigration,
AppliedMigrations = appliedMigrations,
PendingMigrations = pendingMigrations,
AllMigrations = appliedMigrations.Union(pendingMigrations)
};
}
public class MigrationStatus
{
public string CurrentMigration { get; internal set; }
public IEnumerable<string> AppliedMigrations { get; internal set; }
public IEnumerable<string> PendingMigrations { get; internal set; }
public IEnumerable<string> AllMigrations { get; internal set; }
internal MigrationStatus()
{
// Private Constructor
}
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Disco - Data")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Disco")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("77cc3aa4-5055-44aa-97b1-c42e5f5e1acd")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0131.2002")]
[assembly: AssemblyFileVersion("1.2.0131.2002")]
+73
View File
@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17929
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Data.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Disco.Data.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] EmptyLogo {
get {
object obj = ResourceManager.GetObject("EmptyLogo", resourceCulture);
return ((byte[])(obj));
}
}
}
}
+124
View File
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="EmptyLogo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\EmptyLogo.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
+72
View File
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Disco.Models.Repository;
using System.Data.Entity.ModelConfiguration.Conventions;
namespace Disco.Data.Repository
{
public class DiscoDataContext : DbContext
{
private Lazy<Configuration.ConfigurationContext> _Configuration;
public DiscoDataContext()
{
this._Configuration = new Lazy<Configuration.ConfigurationContext>(() => new Configuration.ConfigurationContext(this));
}
public virtual DbSet<ConfigurationItem> ConfigurationItems { get; set; }
public virtual DbSet<DocumentTemplate> DocumentTemplates { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserAttachment> UserAttachments { get; set; }
public virtual DbSet<DeviceUserAssignment> DeviceUserAssignments { get; set; }
public virtual DbSet<Device> Devices { get; set; }
public virtual DbSet<DeviceDetail> DeviceDetails { get; set; }
public virtual DbSet<DeviceModel> DeviceModels { get; set; }
public virtual DbSet<DeviceProfile> DeviceProfiles { get; set; }
public virtual DbSet<DeviceBatch> DeviceBatches { get; set; }
public virtual DbSet<DeviceComponent> DeviceComponents { get; set; }
public virtual DbSet<DeviceAttachment> DeviceAttachments { get; set; }
public virtual DbSet<DeviceCertificate> DeviceCertificates { get; set; }
public virtual DbSet<Job> Jobs { get; set; }
public virtual DbSet<JobType> JobTypes { get; set; }
public virtual DbSet<JobSubType> JobSubTypes { get; set; }
public virtual DbSet<JobLog> JobLogs { get; set; }
public virtual DbSet<JobAttachment> JobAttachments { get; set; }
public virtual DbSet<JobComponent> JobComponents { get; set; }
public virtual DbSet<JobMetaWarranty> JobMetaWarranties { get; set; }
public virtual DbSet<JobMetaNonWarranty> JobMetaNonWarranties { get; set; }
public virtual DbSet<JobMetaInsurance> JobMetaInsurances { get; set; }
public Configuration.ConfigurationContext DiscoConfiguration
{
get
{
return this._Configuration.Value;
}
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
modelBuilder.Entity<DeviceComponent>().HasMany(m => m.JobSubTypes).WithMany(m => m.DeviceComponents).Map(m => m.ToTable("DeviceComponents_JobSubTypes"));
modelBuilder.Entity<DocumentTemplate>().HasMany(m => m.JobSubTypes).WithMany(m => m.AttachmentTypes).Map(m => m.ToTable("DocumentTemplates_JobSubTypes"));
modelBuilder.Entity<Job>().HasMany(m => m.JobSubTypes).WithMany(m => m.Jobs).Map(m => m.ToTable("Jobs_JobSubTypes"));
modelBuilder.Entity<User>().HasMany(m => m.Jobs).WithOptional(m => m.User);
modelBuilder.Entity<Device>().HasMany(m => m.Jobs).WithOptional(m => m.Device);
modelBuilder.Entity<DeviceProfile>().Property(DeviceProfile.PropertyAccessExpressions.DistributionTypeDb);
}
}
}
@@ -0,0 +1,19 @@
// Shouldn't Need this => Moved to Entity Migrations...
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Data.Entity;
//namespace Disco.Data.Repository
//{
// class DiscoDataContextInitializer : CreateDatabaseIfNotExists<DiscoDataContext>
// {
// protected override void Seed(DiscoDataContext context)
// {
// context.SeedDatabase();
// context.SaveChanges();
// }
// }
//}
+270
View File
@@ -0,0 +1,270 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.Repository;
namespace Disco.Data.Repository
{
public static class DiscoDataSeeder
{
public static void SeedDatabase(this DiscoDataContext context)
{
context.SeedDeploymentId();
context.SeedDeviceModels();
context.SeedDeviceProfiles();
context.SeedJobTypes();
context.SeedJobSubTypes();
}
public static void SeedDeploymentId(this DiscoDataContext context)
{
if (context.ConfigurationItems.Count(ci => ci.Scope == "System" && ci.Key == "DeploymentId") == 0)
{
var deploymentId = Guid.NewGuid().ToString("D");
context.ConfigurationItems.Add(new ConfigurationItem { Scope = "System", Key = "DeploymentId", Value = deploymentId });
}
}
public static void SeedJobTypes(this DiscoDataContext context)
{
if (context.JobTypes.Count() == 0)
{
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.HWar, Description = "Hardware - Warranty" });
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.HNWar, Description = "Hardware - Non-Warranty" });
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.HMisc, Description = "Hardware - Misc" });
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.SImg, Description = "Software - Reimage" });
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.SApp, Description = "Software - Application" });
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.SOS, Description = "Software - Operating System" });
}
// 2012-05-22
#region "User Management" Added
if (context.JobTypes.Count(jt => jt.Id == JobType.JobTypeIds.UMgmt) == 0)
context.JobTypes.Add(new JobType { Id = JobType.JobTypeIds.UMgmt, Description = "User - Management" });
#endregion
// End
}
public static void SeedDeviceModels(this DiscoDataContext context)
{
if (context.DeviceModels.Count() == 0)
{
context.DeviceModels.Add(new DeviceModel { Manufacturer = "Unknown", Model = "Unknown", Description = "Unknown Device Model" });
}
UpdateDeviceModelConfiguration(context);
// Removed: 2013-01-14 G#
//UpdateDeviceModelImageStorage(context);
}
public static void SeedDeviceProfiles(this DiscoDataContext context)
{
if (context.DeviceProfiles.Count() == 0)
{
context.DeviceProfiles.Add(new DeviceProfile { ShortName = "WS", Name = "Default", Description = "Initial Default Workstation Profile", ComputerNameTemplate = "DeviceProfile.ShortName + ''-'' + SerialNumber" });
}
}
public static void SeedJobSubTypes(this DiscoDataContext context)
{
if (context.JobSubTypes.Count() == 0)
{
context.JobSubTypes.Add(new JobSubType { Id = "Bag", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bag" });
context.JobSubTypes.Add(new JobSubType { Id = "Battery", JobTypeId = JobType.JobTypeIds.HWar, Description = "Battery" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelCaseBottom", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bezel - Case Bottom" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelCaseTop", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bezel - Case Top" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelScreenInner", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bezel - Screen Inner" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelScreenTop", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bezel - Screen Top" });
context.JobSubTypes.Add(new JobSubType { Id = "BluetoothAdapter", JobTypeId = JobType.JobTypeIds.HWar, Description = "Bluetooth Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "CPU", JobTypeId = JobType.JobTypeIds.HWar, Description = "CPU" });
context.JobSubTypes.Add(new JobSubType { Id = "HardDrive", JobTypeId = JobType.JobTypeIds.HWar, Description = "Hard Drive" });
context.JobSubTypes.Add(new JobSubType { Id = "Keyboard", JobTypeId = JobType.JobTypeIds.HWar, Description = "Keyboard" });
context.JobSubTypes.Add(new JobSubType { Id = "Motherboard", JobTypeId = JobType.JobTypeIds.HWar, Description = "Motherboard" });
context.JobSubTypes.Add(new JobSubType { Id = "Mouse", JobTypeId = JobType.JobTypeIds.HWar, Description = "Mouse/Track Pad" });
context.JobSubTypes.Add(new JobSubType { Id = "PowerAdapter", JobTypeId = JobType.JobTypeIds.HWar, Description = "Power Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "PowerCord", JobTypeId = JobType.JobTypeIds.HWar, Description = "Power Cord/Socket" });
context.JobSubTypes.Add(new JobSubType { Id = "RAM", JobTypeId = JobType.JobTypeIds.HWar, Description = "RAM" });
context.JobSubTypes.Add(new JobSubType { Id = "ReplacementDevice", JobTypeId = JobType.JobTypeIds.HWar, Description = "Replacement Device" });
context.JobSubTypes.Add(new JobSubType { Id = "Screen", JobTypeId = JobType.JobTypeIds.HWar, Description = "Screen" });
context.JobSubTypes.Add(new JobSubType { Id = "Speakers", JobTypeId = JobType.JobTypeIds.HWar, Description = "Speakers" });
context.JobSubTypes.Add(new JobSubType { Id = "WebCamera", JobTypeId = JobType.JobTypeIds.HWar, Description = "Web Camera" });
context.JobSubTypes.Add(new JobSubType { Id = "WirelessAdapter", JobTypeId = JobType.JobTypeIds.HWar, Description = "Wireless Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.HWar, Description = "Other" });
context.JobSubTypes.Add(new JobSubType { Id = "Bag", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bag" });
context.JobSubTypes.Add(new JobSubType { Id = "Battery", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Battery" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelCaseBottom", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bezel - Case Bottom" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelCaseTop", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bezel - Case Top" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelScreenInner", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bezel - Screen Inner" });
context.JobSubTypes.Add(new JobSubType { Id = "BezelScreenTop", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bezel - Screen Top" });
context.JobSubTypes.Add(new JobSubType { Id = "BluetoothAdapter", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Bluetooth Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "CPU", JobTypeId = JobType.JobTypeIds.HNWar, Description = "CPU" });
context.JobSubTypes.Add(new JobSubType { Id = "HardDrive", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Hard Drive" });
context.JobSubTypes.Add(new JobSubType { Id = "Keyboard", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Keyboard" });
context.JobSubTypes.Add(new JobSubType { Id = "Motherboard", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Motherboard" });
context.JobSubTypes.Add(new JobSubType { Id = "Mouse", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Mouse/Track Pad" });
context.JobSubTypes.Add(new JobSubType { Id = "PowerAdapter", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Power Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "PowerCord", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Power Cord/Socket" });
context.JobSubTypes.Add(new JobSubType { Id = "RAM", JobTypeId = JobType.JobTypeIds.HNWar, Description = "RAM" });
context.JobSubTypes.Add(new JobSubType { Id = "ReplacementDevice", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Replacement Device" });
context.JobSubTypes.Add(new JobSubType { Id = "Screen", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Screen" });
context.JobSubTypes.Add(new JobSubType { Id = "Speakers", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Speakers" });
context.JobSubTypes.Add(new JobSubType { Id = "WebCamera", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Web Camera" });
context.JobSubTypes.Add(new JobSubType { Id = "WirelessAdapter", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Wireless Adapter" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Other" });
context.JobSubTypes.Add(new JobSubType { Id = "ExternalHardDrive", JobTypeId = JobType.JobTypeIds.HMisc, Description = "External Hard Drive" });
context.JobSubTypes.Add(new JobSubType { Id = "IWB", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Interactive Whiteboard" });
context.JobSubTypes.Add(new JobSubType { Id = "InternetDongle", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Internet Dongle" });
context.JobSubTypes.Add(new JobSubType { Id = "Keyboard", JobTypeId = JobType.JobTypeIds.HMisc, Description = "External Keyboard" });
context.JobSubTypes.Add(new JobSubType { Id = "MobilePhone", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Mobile Phone" });
context.JobSubTypes.Add(new JobSubType { Id = "Mouse", JobTypeId = JobType.JobTypeIds.HMisc, Description = "External Mouse" });
context.JobSubTypes.Add(new JobSubType { Id = "MP3Player", JobTypeId = JobType.JobTypeIds.HMisc, Description = "MP3 Player" });
context.JobSubTypes.Add(new JobSubType { Id = "PrinterScanner", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Printer/Scanner" });
context.JobSubTypes.Add(new JobSubType { Id = "Projector", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Projector" });
context.JobSubTypes.Add(new JobSubType { Id = "USBFlashDrive", JobTypeId = JobType.JobTypeIds.HMisc, Description = "USB Flash Drive" });
context.JobSubTypes.Add(new JobSubType { Id = "WebCamera", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Web Camera" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Other" });
context.JobSubTypes.Add(new JobSubType { Id = "ContentIllegal", JobTypeId = JobType.JobTypeIds.SImg, Description = "Content - Illegal" });
context.JobSubTypes.Add(new JobSubType { Id = "ContentInappropriate", JobTypeId = JobType.JobTypeIds.SImg, Description = "Content - Inappropriate" });
context.JobSubTypes.Add(new JobSubType { Id = "CorruptOS", JobTypeId = JobType.JobTypeIds.SImg, Description = "Corrupt Operating System" });
context.JobSubTypes.Add(new JobSubType { Id = "HardwareChanges", JobTypeId = JobType.JobTypeIds.SImg, Description = "Hardware Changes" });
context.JobSubTypes.Add(new JobSubType { Id = "Malware", JobTypeId = JobType.JobTypeIds.SImg, Description = "Malware" });
context.JobSubTypes.Add(new JobSubType { Id = "Performance", JobTypeId = JobType.JobTypeIds.SImg, Description = "Performance" });
context.JobSubTypes.Add(new JobSubType { Id = "UserRequest", JobTypeId = JobType.JobTypeIds.SImg, Description = "User Request" });
context.JobSubTypes.Add(new JobSubType { Id = "UpdatedImage", JobTypeId = JobType.JobTypeIds.SImg, Description = "Updated Image" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.SImg, Description = "Other" });
context.JobSubTypes.Add(new JobSubType { Id = "CurriculumTool", JobTypeId = JobType.JobTypeIds.SApp, Description = "Curriculum Tool" });
context.JobSubTypes.Add(new JobSubType { Id = "GamingEntertainment", JobTypeId = JobType.JobTypeIds.SApp, Description = "Gaming/Entertainment" });
context.JobSubTypes.Add(new JobSubType { Id = "ImageManipulation", JobTypeId = JobType.JobTypeIds.SApp, Description = "Image Manipulation" });
context.JobSubTypes.Add(new JobSubType { Id = "MultimediaPlayback", JobTypeId = JobType.JobTypeIds.SApp, Description = "Multimedia Playback" });
context.JobSubTypes.Add(new JobSubType { Id = "Presentation", JobTypeId = JobType.JobTypeIds.SApp, Description = "Presentation" });
context.JobSubTypes.Add(new JobSubType { Id = "Spreadsheet", JobTypeId = JobType.JobTypeIds.SApp, Description = "Spreadsheet" });
context.JobSubTypes.Add(new JobSubType { Id = "StaffTool", JobTypeId = JobType.JobTypeIds.SApp, Description = "Staff Tool" });
context.JobSubTypes.Add(new JobSubType { Id = "StudentReporting", JobTypeId = JobType.JobTypeIds.SApp, Description = "Student Reporting" });
context.JobSubTypes.Add(new JobSubType { Id = "VideoEditing", JobTypeId = JobType.JobTypeIds.SApp, Description = "Video Editing" });
context.JobSubTypes.Add(new JobSubType { Id = "WebBrowser", JobTypeId = JobType.JobTypeIds.SApp, Description = "Web Browser" });
context.JobSubTypes.Add(new JobSubType { Id = "WebBrowserPlugin", JobTypeId = JobType.JobTypeIds.SApp, Description = "Web Browser Plugin" });
context.JobSubTypes.Add(new JobSubType { Id = "WordProcessing", JobTypeId = JobType.JobTypeIds.SApp, Description = "Word Processing" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.SApp, Description = "Other" });
context.JobSubTypes.Add(new JobSubType { Id = "Appearance", JobTypeId = JobType.JobTypeIds.SOS, Description = "Appearance & Personalisation" });
context.JobSubTypes.Add(new JobSubType { Id = "DisplaySettings", JobTypeId = JobType.JobTypeIds.SOS, Description = "Display Settings" });
context.JobSubTypes.Add(new JobSubType { Id = "DriversIWB", JobTypeId = JobType.JobTypeIds.SOS, Description = "Drivers - Interactive Whiteboard" });
context.JobSubTypes.Add(new JobSubType { Id = "DriversPrintScan", JobTypeId = JobType.JobTypeIds.SOS, Description = "Drivers - Printers/Scanners" });
context.JobSubTypes.Add(new JobSubType { Id = "DriversSystem", JobTypeId = JobType.JobTypeIds.SOS, Description = "Drivers - System" });
context.JobSubTypes.Add(new JobSubType { Id = "DriversOther", JobTypeId = JobType.JobTypeIds.SOS, Description = "Drivers - Other" });
context.JobSubTypes.Add(new JobSubType { Id = "Group Policy", JobTypeId = JobType.JobTypeIds.SOS, Description = "Group Policy" });
context.JobSubTypes.Add(new JobSubType { Id = "KeyboardMouseConfig", JobTypeId = JobType.JobTypeIds.SOS, Description = "Keyboard/Mouse Configuration" });
context.JobSubTypes.Add(new JobSubType { Id = "MalwareProtection", JobTypeId = JobType.JobTypeIds.SOS, Description = "Malware Protection" });
context.JobSubTypes.Add(new JobSubType { Id = "NetworkDrives", JobTypeId = JobType.JobTypeIds.SOS, Description = "Network Drives" });
context.JobSubTypes.Add(new JobSubType { Id = "NetworkWired", JobTypeId = JobType.JobTypeIds.SOS, Description = "Network - Wired" });
context.JobSubTypes.Add(new JobSubType { Id = "NetworkWireless", JobTypeId = JobType.JobTypeIds.SOS, Description = "Network - Wireless" });
context.JobSubTypes.Add(new JobSubType { Id = "NetworkOther", JobTypeId = JobType.JobTypeIds.SOS, Description = "Network - Other" });
context.JobSubTypes.Add(new JobSubType { Id = "PatchUpdate", JobTypeId = JobType.JobTypeIds.SOS, Description = "Patches/Updates" });
context.JobSubTypes.Add(new JobSubType { Id = "PowerManagement", JobTypeId = JobType.JobTypeIds.SOS, Description = "Power Management" });
context.JobSubTypes.Add(new JobSubType { Id = "PrintersScanners", JobTypeId = JobType.JobTypeIds.SOS, Description = "Printers/Scanners" });
context.JobSubTypes.Add(new JobSubType { Id = "SoundConfig", JobTypeId = JobType.JobTypeIds.SOS, Description = "Sound Configuration" });
context.JobSubTypes.Add(new JobSubType { Id = "Other", JobTypeId = JobType.JobTypeIds.SOS, Description = "Other" });
}
// Feature Request 2012-04-27 by Elijah: https://disco.uservoice.com/forums/159707-feedback/suggestions/2803945-customisable-job-sub-types
#region "Optical Drive" Added
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HNWar && jst.Id == "OpticalDrive") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "OpticalDrive", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Optical Drive" });
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HWar && jst.Id == "OpticalDrive") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "OpticalDrive", JobTypeId = JobType.JobTypeIds.HWar, Description = "Optical Drive" });
#endregion
// End Feature Request
// 2012-05-22
#region "User Management" Added
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.UMgmt) == 0)
{
context.JobSubTypes.Add(new JobSubType { Id = JobSubType.UserManagementJobSubTypes.Infringement, JobTypeId = JobType.JobTypeIds.UMgmt, Description = JobSubType.UserManagementJobSubTypes.Infringement });
context.JobSubTypes.Add(new JobSubType { Id = JobSubType.UserManagementJobSubTypes.Contact, JobTypeId = JobType.JobTypeIds.UMgmt, Description = JobSubType.UserManagementJobSubTypes.Contact });
}
#endregion
// End
// 2012-05-29 - Audits
#region "Audit" Added
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HMisc && jst.Id == "Audit") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "Audit", JobTypeId = JobType.JobTypeIds.HMisc, Description = "Audit" });
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.SApp && jst.Id == "Audit") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "Audit", JobTypeId = JobType.JobTypeIds.SApp, Description = "Audit" });
#endregion
// End
// Feature Request 2012-06-16 by James: https://disco.uservoice.com/forums/159707-feedback/suggestions/3002911-add-in-microphone-in-hardware-warranty-and-non-war
#region "Microphone" Added
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HNWar && jst.Id == "Microphone") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "Microphone", JobTypeId = JobType.JobTypeIds.HNWar, Description = "Microphone" });
if (context.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HWar && jst.Id == "Microphone") == 0)
context.JobSubTypes.Add(new JobSubType { Id = "Microphone", JobTypeId = JobType.JobTypeIds.HWar, Description = "Microphone" });
#endregion
// End Feature Request
}
private static void UpdateDeviceModelConfiguration(this DiscoDataContext context)
{
if (context.ConfigurationItems.Where(c => c.Scope.StartsWith("DeviceProfile:")).Count() > 0)
{
var configurationItems = context.ConfigurationItems.Where(c => c.Scope.StartsWith("DeviceProfile:")).ToList();
var deviceProfiles = context.DeviceProfiles.ToDictionary(dp => dp.Id);
foreach (var configurationItem in configurationItems)
{
int profileId = int.Parse(configurationItem.Scope.Substring(configurationItem.Scope.IndexOf(":") + 1));
DeviceProfile dp;
if (deviceProfiles.TryGetValue(profileId, out dp))
{
switch (configurationItem.Key)
{
case "ComputerNameTemplate":
dp.ComputerNameTemplate = configurationItem.Value;
break;
case "DistributionType":
dp.DistributionType = (DeviceProfile.DistributionTypes)(int.Parse(configurationItem.Value));
break;
case "OrganisationalUnit":
dp.OrganisationalUnit = configurationItem.Value;
break;
case "AllocateWirelessCertificate":
if (bool.Parse(configurationItem.Value))
dp.CertificateProviderId = "";
else
dp.CertificateProviderId = null;
break;
default:
continue; // Unknown Configuration Item - Leave in DB & Ignore
}
}
// Remove from DB
context.ConfigurationItems.Remove(configurationItem);
}
}
}
// Removed: 2013-01-14 G#
// private static void UpdateDeviceModelImageStorage(this DiscoDataContext dbContext)
// {
//#pragma warning disable 0618
// var updateModels = dbContext.DeviceModels.Where(dm => dm.Image != null);
// if (updateModels.Count() > 0)
// {
// var dataStoreLocation = dbContext.ConfigurationItems.Where(ci => ci.Scope == "System" && ci.Key == "DataStoreLocation").Select(ci => ci.Value).FirstOrDefault();
// if (!string.IsNullOrEmpty(dataStoreLocation) && System.IO.Directory.Exists(dataStoreLocation))
// {
// var deviceModelImagesLocation = System.IO.Path.Combine(dataStoreLocation, "DeviceModelImages");
// if (!System.IO.Directory.Exists(deviceModelImagesLocation))
// System.IO.Directory.CreateDirectory(deviceModelImagesLocation);
// foreach (var model in updateModels)
// {
// var modelpath = System.IO.Path.Combine(deviceModelImagesLocation, string.Format("{0}.png", model.Id));
// if (model.Image != null && model.Image.Length > 0)
// {
// System.IO.File.WriteAllBytes(modelpath, model.Image);
// }
// model.Image = null;
// }
// }
// }
//#pragma warning restore 0618
// }
}
}
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.Infrastructure;
using Microsoft.Win32;
using System.Data.Common;
using System.Security;
using System.Security.Permissions;
namespace Disco.Data.Repository
{
public class DiscoDatabaseConnectionFactory : IDbConnectionFactory
{
private const string DiscoRegistryKey = @"SOFTWARE\Disco";
private IDbConnectionFactory DefaultConnectionFactory;
private IDbConnectionFactory SqlCeConnectionFactory;
private static string _DiscoDataContextConnectionString;
public static string DiscoDataContextConnectionString
{
get
{
if (_DiscoDataContextConnectionString == null)
{
// Retrieve from Registry
using (var key = Registry.LocalMachine.OpenSubKey(DiscoRegistryKey))
{
if (key != null)
_DiscoDataContextConnectionString = (string)key.GetValue("DatabaseConnectionString", null);
}
}
return _DiscoDataContextConnectionString;
}
}
public static void SetDiscoDataContextConnectionString(string ConnectionString, bool Persist)
{
// Set to Local Cache
_DiscoDataContextConnectionString = ConnectionString;
if (Persist)
{
// Set to Registry
try
{
using (var key = Registry.LocalMachine.CreateSubKey(DiscoRegistryKey))
{
key.SetValue("DatabaseConnectionString", ConnectionString, RegistryValueKind.String);
}
}
catch (UnauthorizedAccessException ex)
{
throw new SecurityException(string.Format("Unable to write to the Registry Location: HKML\\{0}[DatabaseConnectionString]", DiscoRegistryKey), ex);
}
}
}
public DiscoDatabaseConnectionFactory(IDbConnectionFactory Default)
{
this.DefaultConnectionFactory = Default;
this.SqlCeConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
}
public System.Data.Common.DbConnection CreateConnection(string nameOrConnectionString)
{
if (nameOrConnectionString == "Disco.Data.Repository.DiscoDataContext")
{
var connectionString = DiscoDataContextConnectionString;
if (connectionString == null)
{
throw new InvalidOperationException("The Disco DataContext Connection String has not been configured");
}
// Build DiscoDataContext - Use Default Connection Factory (SQLClient)
//return this.DefaultConnectionFactory.CreateConnection(connectionString);
var connection = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateConnection();
connection.ConnectionString = connectionString;
return connection;
}
return SqlCeConnectionFactory.CreateConnection(nameOrConnectionString);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="5.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net45" />
</packages>