public ImageViewModel AddImage(YoYoStudio.Model.Core.ImageWithoutBody img)
 {
     string group = string.IsNullOrEmpty(img.ImageGroup) ? Const.DefaultImageGroup : img.ImageGroup;
     string path = Const.ImageRootFolderName + "\\" + img.ImageType_Id.ToString() + "\\" + group + "\\" + img.Id;
     var vm = new ImageViewModel
     {
         RelativePathWithoutExt = path,
         AbsolutePathWithoutExt = Path.Combine(Root, path),
         Id = img.Id,
         ImageGroup = group,
         Tag = img,
         Ext = img.Ext
     };
     vm.Initialize();
     lock (LocalCache.AllImages)
     {
         LocalCache.AllImages[img.ImageType_Id][img.Id] = vm;
     }            
     return vm;
 }
 public void EnsureImageExist(ImageViewModel ImageVM)
 {
     if (ImageVM != null && !File.Exists(ImageVM.StaticImageFile))
     {
         try
         {
             var img = ChatClient.GetImage(ImageVM.Id);
             if (img != null)
             {
                 string dir = Path.GetDirectoryName(ImageVM.StaticImageFile);
                 if (!Directory.Exists(dir))
                 {
                     Directory.CreateDirectory(dir);
                 }
                 File.WriteAllBytes(ImageVM.StaticImageFile, img.TheImage);
             }
         }
         catch (Exception e)
         {
             Logger.Debug("Wirte Image to local failed." + e.Message);
         }
     }
     
 }