Preprocessing of types (activation methods, features, environment data); exception preprocessing missing

This commit is contained in:
Christoph Wille 2010-02-25 11:17:18 +00:00
Родитель 04223e1fb5
Коммит 09b0828f6a
8 изменённых файлов: 351 добавлений и 135 удалений

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="UsageDatabase" connectionString="metadata=res://*/Collector.CollectorModel.csdl|res://*/Collector.CollectorModel.ssdl|res://*/Collector.CollectorModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=UsageDataAnalysis;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
<add name="UDCContext" connectionString="metadata=res://*/Collector.CollectorModel.csdl|res://*/Collector.CollectorModel.ssdl|res://*/Collector.CollectorModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=localhost;Initial Catalog=UsageDataAnalysis;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>

Просмотреть файл

@ -46,6 +46,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Import\BulkImport.cs" />
<Compile Include="Import\CrackAndStoreMessage.cs" />
<Compile Include="Import\ExceptionGroupImport.cs" />
<Compile Include="Import\ExceptionHelpers.cs" />
<Compile Include="Import\FileImporter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

Просмотреть файл

@ -20,26 +20,23 @@ namespace ICSharpCode.UsageDataCollector.ServiceLibrary.Import
public static void SketchOut()
{
// wrong schema errors by moving contracts to /contracts namespace
// UsageDataMessage currentMessage = FileImporter.ReadMessage(@"D:\Daten\SharpDevelop\trunk\SharpDevelopServers\UsageDataCollector\Project\Collector\CollectorServiceTestClient\SharpDevelopUsageData.xml.gz");
UsageDataMessage message =
FileImporter.ReadMessage(@"D:\Daten\SharpDevelop\trunk\SharpDevelopServers\UsageDataCollector\SampleData\_Debugger_Exception_ab7a92f4-3d0e-44ac-afc9-a4d6090603b0.xml.gz");
using (var context = CollectorRepository.CreateContext())
{
CollectorRepository repo = new CollectorRepository();
repo.Context = context;
CrackAndStoreMessage processor = new CrackAndStoreMessage(message, repo);
processor.ProcessMessage();
// Dictionary<string,int> features = context.Features.ToDictionary(f => f.Name, f => f.Id);
// var features = context.Features.ToList().AsReadOnly();
// features: a, b, c
// usage features: b, c, d --> find d
List<string> knownFeatures = context.Features.Select(f => f.Name).ToList();
/*
var activationMethod = new ActivationMethod()
{
Name = "test"
};
context.ActivationMethods.AddObject(activationMethod);
context.SaveChanges();
*/
// List<string> knownFeatures = context.Features.Select(f => f.Name).ToList();
}
}
}

Просмотреть файл

@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.UsageDataCollector.Contracts;
using ICSharpCode.UsageDataCollector.DataAccess.Collector;
namespace ICSharpCode.UsageDataCollector.ServiceLibrary.Import
{
public class CrackAndStoreMessage
{
UsageDataMessage message = null;
CollectorRepository repository = null;
public CrackAndStoreMessage(UsageDataMessage msg, CollectorRepository repo)
{
message = msg;
repository = repo;
}
public void ProcessMessage()
{
string userGuid = message.UserID.ToString();
if (String.IsNullOrEmpty(userGuid))
{
return;
}
// Preprocessing of type tables (don't insert any usage data unless type updates went through properly)
PreProcessEnvironmentDataNames();
PreProcessActivationMethods();
PreProcessFeatures();
// TODO: Exceptions
User modelUser = repository.FindUserByGuid(userGuid);
if (null == modelUser)
{
modelUser = new User()
{
AssociatedGuid = userGuid
};
repository.Context.Users.AddObject(modelUser);
// we intentionally don't build the full model in memory first (user -> sessions -> data tables)
// avoiding concurrency issues (eg type tables) is more important than fewer database writes
repository.Context.SaveChanges();
}
}
protected void PreProcessEnvironmentDataNames()
{
List<string> distinctMsgEnvProperties = (from s in message.Sessions
from p in s.EnvironmentProperties
select p.Name).Distinct().ToList();
// did we receive environment data at all?
if (distinctMsgEnvProperties.Count > 0)
{
List<string> knownDataNames = repository.GetEnvironmentDataNames().ToList(); // cacheable
List<string> missing = distinctMsgEnvProperties.Except(knownDataNames).ToList();
// this happens rarely for environment data names
if (missing.Count > 0)
{
foreach (string envdn in missing)
{
EnvironmentDataName modelEdn = new EnvironmentDataName()
{
Name = envdn
};
repository.Context.EnvironmentDataNames.AddObject(modelEdn);
}
repository.Context.SaveChanges();
}
}
}
protected void PreProcessActivationMethods()
{
List<string> distinctMsgActivationMethods = (from s in message.Sessions
from fu in s.FeatureUses
select fu.ActivationMethod).Distinct().ToList();
if (distinctMsgActivationMethods.Count > 0)
{
List<string> knownActivationMethods = repository.GetActivationMethodNames().ToList(); // cacheable
List<string> missing = distinctMsgActivationMethods.Except(knownActivationMethods).ToList();
if (missing.Count > 0)
{
foreach (string am in missing)
{
ActivationMethod modelAM = new ActivationMethod()
{
Name = am
};
repository.Context.ActivationMethods.AddObject(modelAM);
}
repository.Context.SaveChanges();
}
}
}
protected void PreProcessFeatures()
{
List<string> distinctMsgFeatures = (from s in message.Sessions
from fu in s.FeatureUses
select fu.FeatureName).Distinct().ToList();
if (distinctMsgFeatures.Count > 0)
{
List<string> knownFeatures = repository.GetFeatureNames().ToList(); // cacheable
List<string> missing = distinctMsgFeatures.Except(knownFeatures).ToList();
if (missing.Count > 0)
{
foreach (string fn in missing)
{
Feature modelFeature = new Feature()
{
Name = fn
};
repository.Context.Features.AddObject(modelFeature);
}
repository.Context.SaveChanges();
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSharpCode.UsageDataCollector.ServiceLibrary.Import
{
sealed class ExceptionGroupImport
{
public string Fingerprint;
public string CrashID
{
get { return unchecked((uint)this.Fingerprint.GetHashCode() % 10000u).ToString("d4"); }
}
public string Type
{
get
{
return ExceptionHelpers.SplitLines(this.Fingerprint).First();
}
}
static readonly Type[] argumentExceptions = { typeof(ArgumentException), typeof(ArgumentNullException), typeof(ArgumentOutOfRangeException) };
public string Location
{
get
{
List<string> stackTrace = ExceptionHelpers.SplitLines(this.Fingerprint).Skip(1).ToList();
// ignore any ThrowHelper (etc.) methods at the top of the stack
if (stackTrace.Count > 0 && GetFunctionName(stackTrace[0]).Contains("Throw"))
stackTrace.RemoveAt(0);
if (stackTrace.Count == 0)
return "unknown";
string type = this.Type;
if (argumentExceptions.Any(e => e.FullName == type) && ExceptionHelpers.IsUserCode(stackTrace[0]))
{
// find first stack frame supplying the invalid argument
string functionName = GetFunctionName(stackTrace[0]);
string result = stackTrace.FirstOrDefault(l => GetFunctionName(l) != functionName);
// report it if it's user code
if (result != null && ExceptionHelpers.IsUserCode(result))
return result;
else
return stackTrace[0];
}
else
{
// report first user-code stack frame
return stackTrace.FirstOrDefault(ExceptionHelpers.IsUserCode) ?? stackTrace[0];
}
}
}
static string GetFunctionName(string stackTraceLine)
{
int pos = stackTraceLine.IndexOf('(');
if (pos > 0)
return stackTraceLine.Substring(0, pos);
else
return stackTraceLine;
}
}
}

Просмотреть файл

@ -65,22 +65,6 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
#region ObjectSet Properties
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<ActivationMethod> ActivationMethods
{
get
{
if ((_ActivationMethods == null))
{
_ActivationMethods = base.CreateObjectSet<ActivationMethod>("ActivationMethods");
}
return _ActivationMethods;
}
}
private ObjectSet<ActivationMethod> _ActivationMethods;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
@ -145,22 +129,6 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
}
private ObjectSet<FeatureUse> _FeatureUses;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<Session> Sessions
{
get
{
if ((_Sessions == null))
{
_Sessions = base.CreateObjectSet<Session>("Sessions");
}
return _Sessions;
}
}
private ObjectSet<Session> _Sessions;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
@ -208,18 +176,42 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
}
}
private ObjectSet<Exception> _Exceptions;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<Session> Sessions
{
get
{
if ((_Sessions == null))
{
_Sessions = base.CreateObjectSet<Session>("Sessions");
}
return _Sessions;
}
}
private ObjectSet<Session> _Sessions;
/// <summary>
/// No Metadata Documentation available.
/// </summary>
public ObjectSet<ActivationMethod> ActivationMethods
{
get
{
if ((_ActivationMethods == null))
{
_ActivationMethods = base.CreateObjectSet<ActivationMethod>("ActivationMethods");
}
return _ActivationMethods;
}
}
private ObjectSet<ActivationMethod> _ActivationMethods;
#endregion
#region AddTo Methods
/// <summary>
/// Deprecated Method for adding a new object to the ActivationMethods EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
public void AddToActivationMethods(ActivationMethod activationMethod)
{
base.AddObject("ActivationMethods", activationMethod);
}
/// <summary>
/// Deprecated Method for adding a new object to the EnvironmentDatas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
@ -252,14 +244,6 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
base.AddObject("FeatureUses", featureUse);
}
/// <summary>
/// Deprecated Method for adding a new object to the Sessions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
public void AddToSessions(Session session)
{
base.AddObject("Sessions", session);
}
/// <summary>
/// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
@ -283,6 +267,22 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
{
base.AddObject("Exceptions", exception);
}
/// <summary>
/// Deprecated Method for adding a new object to the Sessions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
public void AddToSessions(Session session)
{
base.AddObject("Sessions", session);
}
/// <summary>
/// Deprecated Method for adding a new object to the ActivationMethods EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
/// </summary>
public void AddToActivationMethods(ActivationMethod activationMethod)
{
base.AddObject("ActivationMethods", activationMethod);
}
#endregion
}
@ -306,12 +306,10 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
/// Create a new ActivationMethod object.
/// </summary>
/// <param name="id">Initial value of the Id property.</param>
/// <param name="name">Initial value of the Name property.</param>
public static ActivationMethod CreateActivationMethod(global::System.Int32 id, global::System.String name)
public static ActivationMethod CreateActivationMethod(global::System.Int32 id)
{
ActivationMethod activationMethod = new ActivationMethod();
activationMethod.Id = id;
activationMethod.Name = name;
return activationMethod;
}
@ -348,7 +346,7 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public global::System.String Name
{
@ -360,7 +358,7 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
{
OnNameChanging(value);
ReportPropertyChanging("Name");
_Name = StructuralObject.SetValidValue(value, false);
_Name = StructuralObject.SetValidValue(value, true);
ReportPropertyChanged("Name");
OnNameChanged();
}
@ -1256,14 +1254,14 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
/// <summary>
/// Create a new Session object.
/// </summary>
/// <param name="id">Initial value of the Id property.</param>
/// <param name="sessionId">Initial value of the SessionId property.</param>
/// <param name="clientSessionId">Initial value of the ClientSessionId property.</param>
/// <param name="startTime">Initial value of the StartTime property.</param>
/// <param name="userId">Initial value of the UserId property.</param>
public static Session CreateSession(global::System.Int32 id, global::System.Int32 clientSessionId, global::System.DateTime startTime, global::System.Int32 userId)
public static Session CreateSession(global::System.Int32 sessionId, global::System.Int64 clientSessionId, global::System.DateTime startTime, global::System.Int32 userId)
{
Session session = new Session();
session.Id = id;
session.SessionId = sessionId;
session.ClientSessionId = clientSessionId;
session.StartTime = startTime;
session.UserId = userId;
@ -1278,34 +1276,34 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Int32 Id
public global::System.Int32 SessionId
{
get
{
return _Id;
return _SessionId;
}
set
{
if (_Id != value)
if (_SessionId != value)
{
OnIdChanging(value);
ReportPropertyChanging("Id");
_Id = StructuralObject.SetValidValue(value);
ReportPropertyChanged("Id");
OnIdChanged();
OnSessionIdChanging(value);
ReportPropertyChanging("SessionId");
_SessionId = StructuralObject.SetValidValue(value);
ReportPropertyChanged("SessionId");
OnSessionIdChanged();
}
}
}
private global::System.Int32 _Id;
partial void OnIdChanging(global::System.Int32 value);
partial void OnIdChanged();
private global::System.Int32 _SessionId;
partial void OnSessionIdChanging(global::System.Int32 value);
partial void OnSessionIdChanged();
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
[DataMemberAttribute()]
public global::System.Int32 ClientSessionId
public global::System.Int64 ClientSessionId
{
get
{
@ -1320,8 +1318,8 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
OnClientSessionIdChanged();
}
}
private global::System.Int32 _ClientSessionId;
partial void OnClientSessionIdChanging(global::System.Int32 value);
private global::System.Int64 _ClientSessionId;
partial void OnClientSessionIdChanging(global::System.Int64 value);
partial void OnClientSessionIdChanged();
/// <summary>

Просмотреть файл

@ -20,14 +20,14 @@
<Key>
<PropertyRef Name="ActivationMethodId" />
</Key>
<Property Name="ActivationMethodId" Type="int" Nullable="false" />
<Property Name="ActivationMethodName" Type="nvarchar" Nullable="false" MaxLength="255" />
<Property Name="ActivationMethodId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="ActivationMethodName" Type="nvarchar" MaxLength="255" />
</EntityType>
<EntityType Name="EnvironmentData">
<Key>
<PropertyRef Name="EnvironmentDataId" />
</Key>
<Property Name="EnvironmentDataId" Type="int" Nullable="false" />
<Property Name="EnvironmentDataId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="SessionId" Type="int" Nullable="false" />
<Property Name="EnvironmentDataNameId" Type="int" Nullable="false" />
<Property Name="EnvironmentDataValue" Type="nvarchar" Nullable="false" MaxLength="255" />
@ -36,14 +36,14 @@
<Key>
<PropertyRef Name="EnvironmentDataNameId" />
</Key>
<Property Name="EnvironmentDataNameId" Type="int" Nullable="false" />
<Property Name="EnvironmentDataNameId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="EnvironmentDataName" Type="nvarchar" Nullable="false" MaxLength="255" />
</EntityType>
<EntityType Name="ExceptionGroups">
<Key>
<PropertyRef Name="ExceptionGroupId" />
</Key>
<Property Name="ExceptionGroupId" Type="int" Nullable="false" />
<Property Name="ExceptionGroupId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="TypeFingerprintSha256Hash" Type="nvarchar" Nullable="false" MaxLength="128" />
<Property Name="ExceptionType" Type="nvarchar" Nullable="false" MaxLength="255" />
<Property Name="ExceptionFingerprint" Type="nvarchar(max)" Nullable="false" />
@ -55,7 +55,7 @@
<Key>
<PropertyRef Name="ExceptionId" />
</Key>
<Property Name="ExceptionId" Type="int" Nullable="false" />
<Property Name="ExceptionId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="SessionId" Type="int" Nullable="false" />
<Property Name="ExceptionGroupId" Type="int" Nullable="false" />
<Property Name="ThrownAt" Type="datetime" Nullable="false" />
@ -66,14 +66,14 @@
<Key>
<PropertyRef Name="FeatureId" />
</Key>
<Property Name="FeatureId" Type="int" Nullable="false" />
<Property Name="FeatureId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="FeatureName" Type="nvarchar" Nullable="false" MaxLength="255" />
</EntityType>
<EntityType Name="FeatureUse">
<Key>
<PropertyRef Name="FeatureUseId" />
</Key>
<Property Name="FeatureUseId" Type="int" Nullable="false" />
<Property Name="FeatureUseId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="SessionId" Type="int" Nullable="false" />
<Property Name="UseTime" Type="datetime" Nullable="false" />
<Property Name="EndTime" Type="datetime" />
@ -84,8 +84,8 @@
<Key>
<PropertyRef Name="SessionId" />
</Key>
<Property Name="SessionId" Type="int" Nullable="false" />
<Property Name="ClientSessionId" Type="int" Nullable="false" />
<Property Name="SessionId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="ClientSessionId" Type="bigint" Nullable="false" />
<Property Name="StartTime" Type="datetime" Nullable="false" />
<Property Name="EndTime" Type="datetime" />
<Property Name="UserId" Type="int" Nullable="false" />
@ -94,7 +94,7 @@
<Key>
<PropertyRef Name="UserId" />
</Key>
<Property Name="UserId" Type="int" Nullable="false" />
<Property Name="UserId" Type="int" Nullable="false" StoreGeneratedPattern="Identity" />
<Property Name="AssociatedGuid" Type="nvarchar" Nullable="false" MaxLength="50" />
</EntityType>
</Schema></edmx:StorageModels>
@ -102,23 +102,16 @@
<edmx:ConceptualModels>
<Schema Namespace="CollectorModel" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
<EntityContainer Name="UDCContext" annotation:LazyLoadingEnabled="true">
<EntitySet Name="ActivationMethods" EntityType="CollectorModel.ActivationMethod" />
<EntitySet Name="EnvironmentDatas" EntityType="CollectorModel.EnvironmentData" />
<EntitySet Name="EnvironmentDataNames" EntityType="CollectorModel.EnvironmentDataName" />
<EntitySet Name="Features" EntityType="CollectorModel.Feature" />
<EntitySet Name="FeatureUses" EntityType="CollectorModel.FeatureUse" />
<EntitySet Name="Sessions" EntityType="CollectorModel.Session" />
<EntitySet Name="Users" EntityType="CollectorModel.User" />
<EntitySet Name="ExceptionGroups" EntityType="CollectorModel.ExceptionGroup" />
<EntitySet Name="Exceptions" EntityType="CollectorModel.Exception" />
<EntitySet Name="Sessions" EntityType="CollectorModel.Session" />
<EntitySet Name="ActivationMethods" EntityType="CollectorModel.ActivationMethod" />
</EntityContainer>
<EntityType Name="ActivationMethod">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" />
<Property Type="String" Name="Name" Nullable="false" MaxLength="255" FixedLength="false" Unicode="true" />
</EntityType>
<EntityType Name="EnvironmentData">
<Key>
<PropertyRef Name="Id" />
@ -153,16 +146,6 @@
<Property Type="Int32" Name="FeatureId" Nullable="false" />
<Property Type="Int32" Name="ActivationMethodId" Nullable="false" />
</EntityType>
<EntityType Name="Session">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" />
<Property Type="Int32" Name="ClientSessionId" Nullable="false" />
<Property Type="DateTime" Name="StartTime" Nullable="false" />
<Property Type="DateTime" Name="EndTime" />
<Property Type="Int32" Name="UserId" Nullable="false" />
</EntityType>
<EntityType Name="User">
<Key>
<PropertyRef Name="Id" />
@ -193,20 +176,29 @@
<Property Type="String" Name="Stacktrace" Nullable="false" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Type="Boolean" Name="IsFirstInSession" Nullable="false" />
</EntityType>
<EntityType Name="Session">
<Key>
<PropertyRef Name="SessionId" />
</Key>
<Property Type="Int32" Name="SessionId" Nullable="false" />
<Property Type="Int64" Name="ClientSessionId" Nullable="false" />
<Property Type="DateTime" Name="StartTime" Nullable="false" />
<Property Type="DateTime" Name="EndTime" />
<Property Type="Int32" Name="UserId" Nullable="false" />
</EntityType>
<EntityType Name="ActivationMethod">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Type="String" Name="Name" MaxLength="255" FixedLength="false" Unicode="true" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
<EntityContainerMapping StorageEntityContainer="CollectorModelStoreContainer" CdmEntityContainer="UDCContext">
<EntitySetMapping Name="ActivationMethods">
<EntityTypeMapping TypeName="CollectorModel.ActivationMethod">
<MappingFragment StoreEntitySet="ActivationMethods">
<ScalarProperty Name="Name" ColumnName="ActivationMethodName" />
<ScalarProperty Name="Id" ColumnName="ActivationMethodId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="EnvironmentDatas">
<EntityTypeMapping TypeName="CollectorModel.EnvironmentData">
<MappingFragment StoreEntitySet="EnvironmentData">
@ -245,17 +237,6 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Sessions">
<EntityTypeMapping TypeName="CollectorModel.Session">
<MappingFragment StoreEntitySet="Sessions">
<ScalarProperty Name="UserId" ColumnName="UserId" />
<ScalarProperty Name="EndTime" ColumnName="EndTime" />
<ScalarProperty Name="StartTime" ColumnName="StartTime" />
<ScalarProperty Name="ClientSessionId" ColumnName="ClientSessionId" />
<ScalarProperty Name="Id" ColumnName="SessionId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Users">
<EntityTypeMapping TypeName="CollectorModel.User">
<MappingFragment StoreEntitySet="Users">
@ -289,6 +270,25 @@
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="Sessions">
<EntityTypeMapping TypeName="CollectorModel.Session">
<MappingFragment StoreEntitySet="Sessions">
<ScalarProperty Name="UserId" ColumnName="UserId" />
<ScalarProperty Name="EndTime" ColumnName="EndTime" />
<ScalarProperty Name="StartTime" ColumnName="StartTime" />
<ScalarProperty Name="ClientSessionId" ColumnName="ClientSessionId" />
<ScalarProperty Name="SessionId" ColumnName="SessionId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="ActivationMethods">
<EntityTypeMapping TypeName="CollectorModel.ActivationMethod">
<MappingFragment StoreEntitySet="ActivationMethods">
<ScalarProperty Name="Name" ColumnName="ActivationMethodName" />
<ScalarProperty Name="Id" ColumnName="ActivationMethodId" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
@ -310,15 +310,15 @@
<!-- Diagram content (shape and connector positions) -->
<Diagrams>
<Diagram Name="CollectorModel">
<EntityTypeShape EntityType="CollectorModel.ActivationMethod" Width="2.5" PointX="7.5" PointY="0.5" Height="1.4033821614583353" />
<EntityTypeShape EntityType="CollectorModel.EnvironmentData" Width="2" PointX="4.5" PointY="3.75" Height="1.7879850260416674" />
<EntityTypeShape EntityType="CollectorModel.EnvironmentDataName" Width="2.5" PointX="7.5" PointY="2" Height="1.4033821614583388" />
<EntityTypeShape EntityType="CollectorModel.Feature" Width="1.625" PointX="5.625" PointY="0.5" Height="1.4033821614583388" />
<EntityTypeShape EntityType="CollectorModel.FeatureUse" Width="1.5" PointX="1" PointY="3.75" Height="2.1725878906250031" />
<EntityTypeShape EntityType="CollectorModel.Session" Width="1.5" PointX="2.625" PointY="1.25" Height="1.9802864583333388" />
<EntityTypeShape EntityType="CollectorModel.User" Width="1.5" PointX="0.875" PointY="0.5" Height="1.4033821614583388" />
<EntityTypeShape EntityType="CollectorModel.ExceptionGroup" Width="2.5" PointX="7.5" PointY="3.5" Height="2.3648893229166674" />
<EntityTypeShape EntityType="CollectorModel.Exception" Width="1.5" PointX="2.75" PointY="3.75" Height="2.1725878906250031" />
<EntityTypeShape EntityType="CollectorModel.Session" Width="1.5" PointX="3.375" PointY="0.75" Height="1.9802864583333317" />
<EntityTypeShape EntityType="CollectorModel.ActivationMethod" Width="2.5" PointX="7.5" PointY="0.5" Height="1.4033821614583353" />
</Diagram>
</Diagrams>
</Designer>

Просмотреть файл

@ -19,6 +19,19 @@ namespace ICSharpCode.UsageDataCollector.DataAccess.Collector
return Context.Users.FirstOrDefault(u => u.AssociatedGuid == guid);
}
public IEnumerable<string> GetEnvironmentDataNames()
{
return Context.EnvironmentDataNames.Select(dn => dn.Name);
}
public IEnumerable<string> GetActivationMethodNames()
{
return Context.ActivationMethods.Select(am => am.Name);
}
public IEnumerable<string> GetFeatureNames()
{
return Context.Features.Select(f => f.Name);
}
}
}