Exemple #1
0
    public static DA.Run ToEntity(DT.Run source, DA.OKBDataContext okb) {
      if (source == null) return null;

      List<DA.BinaryData> binCache = new List<DA.BinaryData>();

      DA.Run entity = new DA.Run { Id = 0, AlgorithmId = source.AlgorithmId, ProblemId = source.ProblemId, CreatedDate = source.CreatedDate, UserId = source.UserId, ClientId = source.ClientId };
      foreach (var value in source.ParameterValues)
        entity.Values.Add(Convert.ToEntity(value, entity, DA.ValueNameCategory.Parameter, okb, binCache));
      foreach (var value in source.ResultValues)
        entity.Values.Add(Convert.ToEntity(value, entity, DA.ValueNameCategory.Result, okb, binCache));
      return entity;
    }
Exemple #2
0
 private static DA.Value ToEntity(DT.Value source, DA.Run run, DA.ValueNameCategory category, DA.OKBDataContext okb, List<DA.BinaryData> binCache) {
   if (source == null) return null;
   var entity = new DA.Value();
   entity.Run = run;
   entity.DataType = Convert.ToEntity(source.DataType, okb);
   if (source is DT.BoolValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Bool, okb);
     entity.BoolValue = ((DT.BoolValue)source).Value;
   } else if (source is DT.IntValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Int, okb);
     entity.IntValue = ((DT.IntValue)source).Value;
   } else if (source is DT.TimeSpanValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.TimeSpan, okb);
     entity.LongValue = ((DT.TimeSpanValue)source).Value;
   } else if (source is DT.LongValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Long, okb);
     entity.LongValue = ((DT.LongValue)source).Value;
   } else if (source is DT.FloatValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Float, okb);
     entity.FloatValue = ((DT.FloatValue)source).Value;
   } else if (source is DT.DoubleValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Double, okb);
     entity.DoubleValue = ((DT.DoubleValue)source).Value;
   } else if (source is DT.PercentValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Percent, okb);
     entity.DoubleValue = ((DT.PercentValue)source).Value;
   } else if (source is DT.StringValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.String, okb);
     entity.StringValue = ((DT.StringValue)source).Value;
   } else if (source is DT.BinaryValue) {
     entity.ValueName = Convert.ToEntity(source.Name, category, DA.ValueNameType.Binary, okb);
     entity.BinaryData = Convert.ToEntity(((DT.BinaryValue)source).Value, okb, binCache);
   } else {
     throw new ArgumentException("Unknown value type.", "source");
   }
   return entity;
 }
Exemple #3
0
 private static DA.DataType ToEntity(DT.DataType source, DA.OKBDataContext okb) {
   if (source == null) return null;
   var entity = okb.DataTypes.Where(x => (x.Name == source.Name) && (x.TypeName == source.TypeName)).FirstOrDefault();
   if (entity == null)
     entity = new DA.DataType() { Id = 0, Name = source.Name, TypeName = source.TypeName };
   return entity;
 }