Exemplo n.º 1
0
 public static string GetLink(GeneratedImageBase p_image)
 {
     string sLink = GeneratedImageSerializer.Serialize(p_image);
     string sHash = GetHash(sLink);
     ProcessCache(sHash, p_image);
     if (CacheManager.Contains(sHash))
         return CacheManager.GetLink(sHash);
     return Configuration.Path + sLink;
 }
Exemplo n.º 2
0
 public static void Add(string p_sKey, GeneratedImageBase p_image)
 {
     if (!string.IsNullOrEmpty(p_sKey) &&
       p_image != null)
       {
     AsyncSaveImage del = SaveImage;
     string sFileName =
     string.Format("{0}.{1}", p_sKey, p_image.ContentType.Substring(p_image.ContentType.IndexOf('/') + 1));
     del.BeginInvoke(sFileName,
                 p_image, EndSaveImage, new KeyValuePair<string, string>(p_sKey, sFileName));
       }
 }
Exemplo n.º 3
0
        private static void SaveImage(string p_sFileName, GeneratedImageBase p_image)
        {
            try
              {
            string sFullPath = Path.Combine(m_sPath, p_sFileName);
            lock (_lockObject)
            {
              if (File.Exists(sFullPath))
              {
            lock (_fileSystemLock)
            {
              File.Delete(sFullPath);
            }
              }

              using (MemoryStream stream = new MemoryStream())
              {
            p_image.Save(stream, true);
            lock (_fileSystemLock)
            {
              using (FileStream fs = new FileStream(sFullPath, FileMode.CreateNew, FileAccess.Write, FileShare.Write))
              {
                stream.WriteTo(fs);
              }
            }
              }
            }
              }
              catch (Exception e)
              {
            AssistLogger.Log<ExceptionHolder>(e);
              }
        }
Exemplo n.º 4
0
 private static void ProcessCache(string p_sHash, GeneratedImageBase p_image)
 {
     if (p_image != null &&
         p_image.Cache)
     {
         if (!CacheManager.Contains(p_sHash))
         {
             lock (_lockObject)
             {
                 CacheManager.Add(p_sHash, p_image);
             }
         }
     }
 }