コード例 #1
0
        public async void AddOrUpdateDocument(DriverClassification driverClassification)
        {
            var driverStyle = Get(driverClassification.DriverId);

            if (driverStyle == null)
            {
                var newDriverStyle = DriverStyle.CreateFromDriverClassification(driverClassification);
                await client.CreateDocumentAsync(documentCollectionDocumentsLink, newDriverStyle);
            }
            else
            {
                DriverStyle driverStyleToUpdate = driverStyle;

                var classifications = driverStyleToUpdate.Classifications
                    .OrderByDescending(x => x.Timestamp)
                    .Take(MaxClassificationsPerDriver - 1)
                    .ToList();

                classifications.Insert(0, Classification.CreateFromDriverClassification(driverClassification));

                driverStyleToUpdate.ClassificationAvg = Convert.ToInt32(classifications.Average(x => x.Value));
                driverStyleToUpdate.Classifications = classifications.ToArray();

                await client.ReplaceDocumentAsync(driverStyle.SelfLink, driverStyleToUpdate);
            }
        }
コード例 #2
0
 public static Classification CreateFromDriverClassification(DriverClassification driverClassification)
 {
     return(new Classification
     {
         Timestamp = driverClassification.Timestamp,
         Value = driverClassification.Classification
     });
 }
コード例 #3
0
 public static Classification CreateFromDriverClassification(DriverClassification driverClassification)
 {
     return new Classification
     {
         Timestamp = driverClassification.Timestamp,
         Value = driverClassification.Classification
     };
 }
コード例 #4
0
 public static DriverStyle CreateFromDriverClassification(DriverClassification driverClassification)
 {
     return(new DriverStyle
     {
         DriverId = driverClassification.DriverId,
         ClassificationAvg = driverClassification.Classification,
         Classifications = new[]
         {
             new Classification
             {
                 Timestamp = driverClassification.Timestamp,
                 Value = driverClassification.Classification
             }
         }
     });
 }
コード例 #5
0
ファイル: DriverStyle.cs プロジェクト: EmiiFont/MyShuttle_RC
 public static DriverStyle CreateFromDriverClassification(DriverClassification driverClassification)
 {
     return new DriverStyle
     {
         DriverId = driverClassification.DriverId,
         ClassificationAvg = driverClassification.Classification,
         Classifications = new[]
             {
                 new Classification
                 {
                     Timestamp = driverClassification.Timestamp,
                     Value = driverClassification.Classification
                 }
             }
     };
 }