示例#1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
示例#2
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _dbContext.Dispose();
         }
     }
     _disposed = true;
 }
        private void ProcessResourceType <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>(string ResourceName)
            where ResCurrentType : ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexStringType : ResourceIndexString <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexTokenType : ResourceIndexToken <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexUriType : ResourceIndexUri <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexReferenceType : ResourceIndexReference <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexQuantityType : ResourceIndexQuantity <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexDateTimeType : ResourceIndexDateTime <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
        {
            try
            {
                Hl7.Fhir.Serialization.FhirXmlSerializer FhirXmlSerializer = new Hl7.Fhir.Serialization.FhirXmlSerializer();

                bool Running = true;
                while (Running)
                {
                    IPyroDbContext context = new MsSqlContext();
                    var            Query   = context.Set <ResCurrentType>().Where(x => x.XmlBlob != null && x.IsDeleted == false && x.Resource == null).Take(200).ToList();
                    if (Query == null || Query.Count == 0)
                    {
                        Running = false;
                    }
                    else
                    {
                        foreach (var ResourceEntity in Query)
                        {
                            if (!string.IsNullOrWhiteSpace(ResourceEntity.XmlBlob))
                            {
                                Resource Res      = Common.Tools.FhirResourceSerializationSupport.DeSerializeFromXml(ResourceEntity.XmlBlob);
                                byte[]   ResBytes = FhirXmlSerializer.SerializeToBytes(Res);
                                ResourceEntity.Resource = Common.Tools.GZip.GZipper.Compress(ResBytes);
                                ResourceEntity.XmlBlob  = null;
                                context.Set <ResCurrentType>().AddOrUpdate(ResourceEntity);
                            }
                        }
                        context.SaveChanges();
                        context.Dispose();
                    }
                }
            }
            catch (Exception Exec)
            {
                throw new Exception($"The Resource Type {ResourceName}", Exec);
            }
        }
示例#4
0
 public void Dispose()
 {
     _context.Dispose();
 }
示例#5
0
 public void Cleanup()
 {
     _chloeContext.Dispose();
 }