Example #1
0
        private int GetColumnImageIndex(IBizItem item)
        {
            if (item == null)
            {
                return(-1);
            }
            ItemState state = (item.LastRevision == item.RevNum) ? item.State : ItemState.Release;

            if (item.LastRevision == item.RevNum)
            {
                state = (item.LastIteration == item.IterNum) ? item.State : ItemState.CheckIn;
            }
            return(ClientData.ItemImages.GetObjectImage(item.ClassName, PLDataModel.GetStateByMasterInfo(state, item.HasFile)));
        }
Example #2
0
        public void FillTemplateListView(string headClassName, string mainClassName, SortableListView lvwTemplates, Guid uOid, bool isDialog)
        {
            lvwTemplates.Items.Clear();
            DEItemMaster2[]   masters     = null;
            DEItemRevision2[] revs        = null;
            ArrayList         mastersList = new ArrayList();
            ArrayList         revsList    = new ArrayList();

            string[]      fieldNames = null;
            string[]      operators  = null;
            object[]      values     = null;
            PLMDataType[] attrTypes  = null;
            if (mainClassName == null)
            {
                //20180823 modifiedy by kexp 加入过程流程图
                if ((headClassName == null) || (!ModelContext.MetaModel.IsCard(headClassName) && !ModelContext.MetaModel.IsForm(headClassName) && !ModelContext.MetaModel.IsChild("PROFLOWCHART", headClassName)))
                {
                    if (headClassName == null)
                    {
                        this.GetItemMasRev(out masters, out revs, null, null, null, null);
                    }
                    else
                    {
                        if (this.virtualClsName != "")
                        {
                            fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE", "I.PLM_VIRTUALCLASSNAME" };
                            operators  = new string[] { "=", "=", "=" };
                            values     = new object[] { headClassName, 'R', this.virtualClsName };
                            attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char, PLMDataType.String };
                            this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                        }
                        if ((this.virtualClsName == "") || (masters.Length == 0))
                        {
                            fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE" };
                            operators  = new string[] { "=", "=" };
                            values     = new object[] { headClassName, 'R' };
                            attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char };
                            this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                        }
                    }
                    if (masters != null)
                    {
                        for (int i = 0; i < masters.Length; i++)
                        {
                            if (this.IsOutPutTemplate(revs[i], this.user.Oid))
                            {
                                int          objectImage = ClientData.ItemImages.GetObjectImage(masters[i].ClassName, PLDataModel.GetStateByMasterInfo(masters[i].State, true));
                                ListViewItem lvi         = new ListViewItem(masters[i].Id, objectImage);
                                this.FillListViewItem(lvi, masters[i], revs[i]);
                                lvi.Tag = new DEBusinessItem(masters[i], revs[i], null);
                                lvwTemplates.Items.Add(lvi);
                            }
                        }
                        this.lvwTemplates.SetColumnSortFormat(1, SortedListViewFormatType.Numeric);
                        this.lvwTemplates.SetColumnSortFormat(2, SortedListViewFormatType.Numeric);
                    }
                    return;
                }
                if (!isDialog)
                {
                    fieldNames = new string[] { "I.PLM_TEMPLATETYPE" };
                    operators  = new string[] { "=" };
                    values     = new object[] { headClassName };
                    attrTypes  = new PLMDataType[] { PLMDataType.String };
                    this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                }
                else
                {
                    if (this.virtualClsName != "")
                    {
                        fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE", "I.PLM_VIRTUALCLASSNAME" };
                        operators  = new string[] { "=", "=", "=" };
                        values     = new object[] { headClassName, 'R', this.virtualClsName };
                        attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char, PLMDataType.String };
                        this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                    }
                    if ((this.virtualClsName == "") || (masters.Length == 0))
                    {
                        fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE" };
                        operators  = new string[] { "=", "=" };
                        values     = new object[] { headClassName, 'R' };
                        attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char };
                        this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                    }
                }
                mastersList.AddRange(masters);
                revsList.AddRange(revs);
            }
            else if (headClassName == null)
            {
                this.GetMasRevList(mainClassName, mastersList, revsList);
            }
            else
            {
                this.GetMasRevList(mainClassName, mastersList, revsList);
                if (this.virtualClsName != "")
                {
                    fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE", "I.PLM_VIRTUALCLASSNAME" };
                    operators  = new string[] { "=", "=", "=" };
                    values     = new object[] { headClassName, 'R', this.virtualClsName };
                    attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char, PLMDataType.String };
                    this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                }
                if ((this.virtualClsName == "") || (masters.Length == 0))
                {
                    fieldNames = new string[] { "I.PLM_TEMPLATETYPE", "M.PLM_M_STATE" };
                    operators  = new string[] { "=", "=" };
                    values     = new object[] { headClassName, 'R' };
                    attrTypes  = new PLMDataType[] { PLMDataType.String, PLMDataType.Char };
                    this.GetItemMasRev(out masters, out revs, fieldNames, operators, values, attrTypes);
                }
                for (int j = 0; j < revs.Length; j++)
                {
                    if (!this.HasSameTemplate(revs[j], revsList))
                    {
                        mastersList.Add(masters[j]);
                        revsList.Add(revs[j]);
                    }
                }
            }
            this.FillTemplateListView(isDialog, mastersList, revsList, lvwTemplates);
        }
Example #3
0
 private void FillTemplateListView(bool isDialog, ArrayList masters, ArrayList revs, SortableListView lvwTemplates)
 {
     if (masters != null)
     {
         for (int i = 0; i < masters.Count; i++)
         {
             DEItemMaster2   mas = masters[i] as DEItemMaster2;
             DEItemRevision2 rev = revs[i] as DEItemRevision2;
             if (isDialog)
             {
                 int          objectImage = ClientData.ItemImages.GetObjectImage(mas.ClassName, "release");
                 ListViewItem item        = new ListViewItem(mas.Id, objectImage);
                 this.FillListViewItemSimple(item, mas, rev);
                 item.Tag = new DEBusinessItem(mas, rev, null);
                 lvwTemplates.Items.Add(item);
             }
             else
             {
                 int          imageIndex = ClientData.ItemImages.GetObjectImage(mas.ClassName, PLDataModel.GetStateByMasterInfo(mas.State, true));
                 ListViewItem lvi        = new ListViewItem(mas.Id, imageIndex);
                 this.FillListViewItem(lvi, mas, rev);
                 lvi.Tag = new DEBusinessItem(mas, rev, null);
                 lvwTemplates.Items.Add(lvi);
             }
         }
         this.lvwTemplates.SetColumnSortFormat(1, SortedListViewFormatType.Numeric);
         if (!isDialog)
         {
             this.lvwTemplates.SetColumnSortFormat(2, SortedListViewFormatType.Numeric);
         }
     }
 }
Example #4
0
 private void AfterItemCreated(object sender, PLMOperationArgs e)
 {
     if ((e.Items != null) && (((DEBusinessItem)e.Items[0]).ClassName == "PPCRDTEMPLATE"))
     {
         string         className = "";
         DEBusinessItem item      = e.Items[0] as DEBusinessItem;
         if (item.Iteration == null)
         {
             className = PLCardTemplate.GetTemplateType(item.Revision, this.user.Oid);
         }
         else
         {
             className = (string)item.Iteration.GetAttrValue("TEMPLATETYPE");
         }
         if ((this.headClass == className) || (((this.headClass == null) && !ModelContext.MetaModel.IsForm(className)) && !ModelContext.MetaModel.IsCard(className)))
         {
             int          objectImage = ClientData.ItemImages.GetObjectImage(item.Master.ClassName, PLDataModel.GetStateByMasterInfo(item.Master.State, true));
             ListViewItem lvi         = new ListViewItem(item.Master.Id, objectImage);
             this.FillListViewItem(lvi, item.Master, item.Revision);
             lvi.Tag = item;
             this.lvwTemplates.Items.Add(lvi);
             lvi.Selected = true;
         }
     }
 }
Example #5
0
 private void AfterCloned(object sender, PLMOperationArgs e)
 {
     if (((e.BizItems != null) && (e.BizItems.Length != 0)) && (e.BizItems[0].ClassName == "PPCRDTEMPLATE"))
     {
         DEBusinessItem item      = e.BizItems[0] as DEBusinessItem;
         string         attrValue = (string)item.Iteration.GetAttrValue("TEMPLATETYPE");
         if ((this.headClass == attrValue) || (this.headClass == null))
         {
             ListViewItem lvi = new ListViewItem(item.Master.Id, ClientData.ItemImages.GetObjectImage(item.Master.ClassName, PLDataModel.GetStateByMasterInfo(item.Master.State, true)));
             this.FillListViewItem(lvi, item.Master, item.Revision);
             lvi.Tag = e.Items[0];
             this.lvwTemplates.Items.Add(lvi);
             lvi.Selected = true;
         }
     }
 }
Example #6
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);
     }
 }
Example #7
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;
     }
 }