Пример #1
0
 public void DisplyListItemThum(ListViewItem lvItem)
 {
     if (((((lvItem != null) && (this.ThumSetting != null)) && (this.ThumSetting.DisplayStyle != DisplayStyle.Detail)) && ((base.Bounds.Bottom > lvItem.Bounds.Bottom) && (lvItem.Index >= base.TopItem.Index))) && (lvItem.Tag is IBizItem))
     {
         IBizItem tag  = lvItem.Tag as IBizItem;
         string   path = UIThumbnailHelper.Instance.DownLoadThumFile(tag, this.ThumPSOption);
         string   str2 = Path.Combine(ConstConfig.GetTempfilePath(), "Thum");
         if (!Directory.Exists(str2))
         {
             Directory.CreateDirectory(str2);
         }
         string key          = "";
         Image  reducedImage = null;
         if (File.Exists(path))
         {
             key          = Path.GetFileName(path);
             reducedImage = UIThumbnailHelper.Instance.GetReducedImage(path);
             if (reducedImage != null)
             {
                 if (this.ThumImageList.Images.ContainsKey(key))
                 {
                     int num = this.ThumImageList.Images.IndexOfKey(key);
                     this.ThumImageList.Images[num] = reducedImage;
                 }
                 else
                 {
                     this.ThumImageList.Images.Add(key, reducedImage);
                 }
                 reducedImage.Dispose();
             }
         }
         else
         {
             int objectImage = ClientData.ItemImages.GetObjectImage(tag.ClassName, PLDataModel.GetStateByMasterInfo(tag.ExactState, tag.HasFile));
             if (!this.ThumImageList.Images.ContainsKey(objectImage.ToString()))
             {
                 string filename = Path.Combine(str2, objectImage.ToString() + ".jpg");
                 reducedImage = ClientData.ItemImages.GetObjectImage1(tag.ClassName, PLDataModel.GetStateByMasterInfo(tag.ExactState, tag.HasFile));
                 reducedImage.Save(filename);
                 this.ThumImageList.Images.Add(objectImage.ToString() + ".jpg", reducedImage);
                 reducedImage.Dispose();
             }
         }
         lvItem.ImageIndex = this.ThumImageList.Images.IndexOfKey(key);
     }
 }
Пример #2
0
        public Dictionary <Guid, string> DownLoadThumFiles(List <IBizItem> bizItems, DEPSOption psOption)
        {
            List <Guid>   list  = new List <Guid>();
            List <string> list2 = new List <string>();

            for (int i = 0; i < bizItems.Count; i++)
            {
                list.Add(bizItems[i].IterOid);
                list2.Add(bizItems[i].ClassName);
            }
            DEItemIteration2[] thumBizitemIters = null;
            DESecureFile[]     files            = null;
            PLItem.Agent.GetThumbnailFiles(list.ToArray(), list2.ToArray(), ClientData.LogonUser.Oid, (psOption == null) ? ClientData.UserGlobalOption.CloneAsLocal() : psOption, out thumBizitemIters, out files);
            Dictionary <Guid, string> dictionary = new Dictionary <Guid, string>();

            for (int j = 0; j < list.Count; j++)
            {
                if (files[j] != null)
                {
                    bizItems[j].ThumBizitemIterOid = thumBizitemIters[j].Oid;
                    string str = ViewFileHelper.DownloadFileByDir(thumBizitemIters[j], files[j], null, psOption, true, true, "ClaRel_BROWSE");
                    if (!string.IsNullOrEmpty(str))
                    {
                        string path = Path.Combine(ConstConfig.GetTempfilePath(), "Thum");
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        string destFileName = Path.Combine(path, files[j].FileOid.ToString() + ".jpg");
                        if (File.Exists(str))
                        {
                            File.Copy(str, destFileName, true);
                            dictionary.Add(list[j], destFileName);
                        }
                        else if (!string.IsNullOrEmpty(files[j].FullPath) && File.Exists(files[j].FullPath))
                        {
                            File.Copy(files[j].FullPath, destFileName, true);
                            dictionary.Add(list[j], destFileName);
                        }
                    }
                }
            }
            return(dictionary);
        }
Пример #3
0
 public string CopyToTemp(string securityPath)
 {
     if (PLSystemParam.SecurityDiskIsUse && ConstCommon.FUNCTION_SECURITYDISK)
     {
         string tempfilePath = ConstConfig.GetTempfilePath();
         if (!File.Exists(securityPath))
         {
             return(securityPath);
         }
         securityPath = tempfilePath.Substring(0, 1) + securityPath.Substring(1, securityPath.Length - 1);
         if (!Directory.Exists(Path.GetDirectoryName(securityPath)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(securityPath));
         }
         try {
             File.Copy(securityPath, tempfilePath.Substring(0, 1) + securityPath.Substring(1, securityPath.Length - 1), true);
         } catch {
         }
     }
     return(securityPath);
 }
Пример #4
0
 public static void FillItemImage(ThumbnailListView lvw)
 {
     try {
         try {
             if ((!lvw.Visible || (lvw.TopItem == null)) || (lvw.TopItem.Index == -1))
             {
                 return;
             }
         } catch {
             return;
         }
         Cursor.Current = Cursors.WaitCursor;
         if ((lvw.SmallImageList == null) || (lvw.SmallImageList != lvw.ThumImageList))
         {
             lvw.SmallImageList = lvw.ThumImageList;
         }
         int             generation = GC.GetGeneration(lvw.ThumImageList);
         List <IBizItem> bizItems   = new List <IBizItem>();
         ArrayList       masterOids = new ArrayList();
         ArrayList       revNums    = new ArrayList();
         for (int i = lvw.TopItem.Index; i < lvw.Items.Count; i++)
         {
             if ((lvw.Items[i] != null) && (lvw.Bounds.Bottom > lvw.Items[i].Bounds.Top))
             {
                 ListViewItem item = lvw.Items[i];
                 IBizItem     tag  = null;
                 if (item.Tag is IBizItem)
                 {
                     tag = item.Tag as IBizItem;
                 }
                 else if (item.Tag is DataRowView)
                 {
                     try {
                         masterOids.Add(new Guid((byte[])((DataRowView)item.Tag)[0]));
                         revNums.Add(0);
                     } catch {
                     }
                 }
                 if (tag != null)
                 {
                     bizItems.Add(tag);
                 }
             }
         }
         if (masterOids.Count > 0)
         {
             ArrayList list4 = PLItem.Agent.GetBizItemsByMasters(masterOids, revNums, lvw.ThumPSOption.CurView, ClientData.LogonUser.Oid, BizItemMode.BizItem);
             if (list4.Count > 0)
             {
                 bizItems.AddRange((IBizItem[])list4.ToArray(typeof(IBizItem)));
             }
         }
         Dictionary <Guid, string> dictionary = new Dictionary <Guid, string>();
         if (bizItems.Count > 0)
         {
             try {
                 dictionary = UIThumbnailHelper.Instance.DownLoadThumFiles(bizItems, lvw.ThumPSOption);
             } catch (Exception exception) {
                 PLMEventLog.WriteExceptionLog(exception);
             }
         }
         string key = 0.ToString() + ".jpg";
         if (!lvw.ThumImageList.Images.ContainsKey(key))
         {
             string path = Path.Combine(ConstConfig.GetTempfilePath(), "Thum");
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             string filename = Path.Combine(path, key);
             Image  image    = ClientData.ItemImages.imageList.Images[0];
             image.Save(filename);
             lock (typeof(ImageList)) {
                 lvw.ThumImageList.Images.Add(key, image);
             }
             image.Dispose();
         }
         for (int j = lvw.TopItem.Index; j < lvw.Items.Count; j++)
         {
             if ((lvw.Items[j] != null) && (lvw.Bounds.Bottom > lvw.Items[j].Bounds.Top))
             {
                 ListViewItem item3 = lvw.Items[j];
                 IBizItem     item4 = null;
                 if (item3.Tag is IBizItem)
                 {
                     item4 = item3.Tag as IBizItem;
                 }
                 else if (item3.Tag is DataRowView)
                 {
                     try {
                         Guid masterOid = new Guid((byte[])((DataRowView)item3.Tag)[0]);
                         item4 = FindBizItems(bizItems, masterOid);
                     } catch {
                     }
                 }
                 if (item4 != null)
                 {
                     string str4         = "";
                     string fileName     = "";
                     Image  reducedImage = null;
                     if (dictionary.ContainsKey(item4.IterOid))
                     {
                         str4 = dictionary[item4.IterOid];
                         if (File.Exists(str4))
                         {
                             fileName     = Path.GetFileName(str4);
                             reducedImage = UIThumbnailHelper.Instance.GetReducedImage(str4);
                             if (reducedImage != null)
                             {
                                 if (lvw.ThumImageList.Images.ContainsKey(fileName))
                                 {
                                     int num5 = lvw.ThumImageList.Images.IndexOfKey(fileName);
                                     lvw.ThumImageList.Images[num5] = reducedImage;
                                 }
                                 else
                                 {
                                     lock (typeof(ImageList)) {
                                         lvw.ThumImageList.Images.Add(fileName, reducedImage);
                                     }
                                 }
                                 reducedImage.Dispose();
                             }
                         }
                     }
                     else
                     {
                         fileName = ClientData.ItemImages.GetObjectImage(item4.ClassName, PLDataModel.GetStateByMasterInfo(item4.ExactState, item4.HasFile)).ToString() + ".jpg";
                         if (!lvw.ThumImageList.Images.ContainsKey(fileName))
                         {
                             string str6 = Path.Combine(ConstConfig.GetTempfilePath(), "Thum");
                             if (!Directory.Exists(str6))
                             {
                                 Directory.CreateDirectory(str6);
                             }
                             string str7 = Path.Combine(str6, fileName);
                             reducedImage = ClientData.ItemImages.GetObjectImage1(item4.ClassName, PLDataModel.GetStateByMasterInfo(item4.ExactState, item4.HasFile));
                             reducedImage.Save(str7);
                             lock (typeof(ImageList)) {
                                 lvw.ThumImageList.Images.Add(fileName, reducedImage);
                             }
                             reducedImage.Dispose();
                         }
                     }
                     item3.ImageIndex = lvw.ThumImageList.Images.IndexOfKey(fileName);
                 }
             }
         }
         lvw.Refresh();
         GC.GetGeneration(generation);
     } finally {
         Cursor.Current = Cursors.Default;
     }
 }