Ejemplo n.º 1
0
 private static Template ToTemplate(KeysDataRow keysDataRow)
 {
     return(new Template()
     {
         TemplateId = keysDataRow.Id,
         Data = keysDataRow.FaceKey
     });
 }
 public IEnumerable<KeysDataRow> EnumerateTemplates()
 {
   string templatesFolder = TemplateCashProvider.TemplatesFolder();
   foreach (string path in Directory.EnumerateFiles(templatesFolder, "*.dbo"))
   {
     Guid id;
     if (!Guid.TryParse(Path.GetFileNameWithoutExtension(path), out id))
       this._log.Warn((object) ("Unable to parse id from file name" + Path.GetFileName(path)));
     KeysDataRow template = this.TryReadTemplateFromCache(id);
     if (template != null)
       yield return template;
   }
 }
 public bool TryAdd(KeysDataRow templateData)
 {
   try
   {
     using (FileStream fileStream = new FileStream(TemplateCashProvider.GetCachedTemplateFileName(templateData.Id), FileMode.Create, FileAccess.Write))
       new BinaryFormatter().Serialize((Stream) fileStream, (object) templateData);
     return true;
   }
   catch (Exception ex)
   {
     this._log.Warn((object) ex.Message);
     return false;
   }
 }
Ejemplo n.º 4
0
 private static TemplateInfo ToTemplateData(KeysDataRow keysDataRow)
 {
     return(new TemplateInfo()
     {
         Id = keysDataRow.Id,
         ImageId = keysDataRow.ImageId,
         FaceId = keysDataRow.FaceId,
         AccessId = keysDataRow.AccessId,
         Ksid = keysDataRow.Ksid,
         Sex = keysDataRow.Sex,
         Surname = keysDataRow.Surname,
         Birthday = keysDataRow.Birthday,
         Score = keysDataRow.Score
     });
 }
Ejemplo n.º 5
0
 public void UpdateTemplateInfo(KeysDataRow keysDataRow)
 {
     try
     {
         this._engine.UploadTemplate("MainStream", EngineWorker.ToTemplate(keysDataRow));
     }
     catch (SdkException ex)
     {
         if ((int)ex.ErrorCode != 518)
         {
             this.LogSdkError(ex, "UpdateTemplateInfo");
         }
     }
     this._templateDatas[keysDataRow.Id] = EngineWorker.ToTemplateData(keysDataRow);
     this._templateCashProvider.TryAdd(keysDataRow);
 }
 public bool TryUpdate(KeysDataRow templateData)
 {
   return this.TryRemove(templateData.Id) && this.TryAdd(templateData);
 }