Пример #1
0
        /// <summary>
        /// 获取当前对象
        /// </summary>
        /// <param name="iItem"></param>
        /// <returns></returns>
        public DEBusinessItem GetDEBusinessItem(IBizItem iItem)
        {
            IActionContext context = ActionContext2.GetInstance().GetCurrentContext();
            DEPSOption     option  = null;

            if (context != null && context.NavContext.Option != null)
            {
                option = context.NavContext.Option;
            }
            if (option == null)
            {
                option = ClientData.UserGlobalOption;
            }
            if (iItem == null)
            {
                return(null);
            }
            DEBusinessItem bItem = iItem as DEBusinessItem;

            if (bItem == null && iItem is DESmartBizItem)
            {
                DESmartBizItem sb = iItem as DESmartBizItem;
                bItem = (DEBusinessItem)PLItem.Agent.GetBizItem(sb.MasterOid, sb.RevOid, sb.IterOid,
                                                                option.CurView, ClientData.LogonUser.Oid,
                                                                BizItemMode.BizItem);
            }
            return(bItem);
        }
Пример #2
0
        public bool Display(object obizItem, DEPSOption psOption, ThumbnailSetting thumSetting)
        {
            if (obizItem is TreeNode)
            {
                obizItem = ((TreeNode)obizItem).Tag;
            }
            if (obizItem is DataRowView)
            {
                DataRowView view = (DataRowView)obizItem;
                obizItem = PLItem.Agent.GetBizItemByMaster(new Guid((byte[])view[0]), 0, psOption.CurView, ClientData.LogonUser.Oid, BizItemMode.BizItem) as DEBusinessItem;
            }
            if (!(obizItem is IBizItem))
            {
                this.bizItem = null;
                this.InitFileRelaData();
                int generation = GC.GetGeneration(this.pnlViewer);
                BrowserPool.BrowserManager.RemoveBrowser(this.pnlViewer);
                this.pnlViewer.Controls.Clear();
                GC.Collect(generation);
                return(this.toolStrip1.Visible = false);
            }
            bool flag = false;

            if (this.bizItem == null)
            {
                flag = true;
            }
            else if (((IBizItem)obizItem).MasterOid != this.bizItem.MasterOid)
            {
                flag = true;
            }
            this.bizItem            = PSConvert.ToBizItem(obizItem as IBizItem, psOption.CurView, ClientData.LogonUser.Oid);
            this.toolStrip1.Visible = true;
            this.psOption           = psOption;
            this.thumSetting        = thumSetting;
            bool flag2 = this.InitFiles();

            if (!flag)
            {
                flag = flag2;
            }
            if (!flag)
            {
                this.toolStrip1.Visible = (this.curFile != null) && this.thumSetting.IsShowToolBar;
                return(this.curFile != null);
            }
            this.SetShowTypeContent(this.thumSetting);
            this.ShowFile();
            this.toolStrip1.Visible = (this.curFile != null) && this.thumSetting.IsShowToolBar;
            return(this.curFile != null);
        }
Пример #3
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);
        }
Пример #4
0
 public void ShowThum(object objItem, DEPSOption option)
 {
     if (this.ucThumbnail != null)
     {
         try
         {
             Cursor.Current = Cursors.WaitCursor;
             this.ucThumbnail.Display(objItem, option, this.thumSetting);
         }
         catch (Exception exception)
         {
             PrintException.Print(exception);
         }
         finally
         {
             Cursor.Current = Cursors.Default;
         }
     }
 }
Пример #5
0
        public DEFullRelationBizItem1[] GetPSItems(string prjId, Guid rootMasterOid, long child_pos_id, DEPSOption option, int level, bool isLight, Guid userOid)
        {
            //try
            //{
            if (!this.isInTrans)
                this.dbParam.Open();

            // 获取用户的全局有效性选项
            if (option == null)
            {
                PRPSOption prOption = new PRPSOption(this.dbParam);
                option = prOption.GetUserGlobalOption(userOid);
            }
            //if (option == null)
            //    throw new PLMException(ExceptionManager.E_PDT_CANNOT_GET_USERGLOBALOPTION);
            string msg = "";
            DateTime start = DateTime.Now;
            DARouteProcess daRouteProcess = new DARouteProcess(this.dbParam);
            List<Guid> masterOids = null;
            List<int> revs = null;
            List<DEFullRelationBizItem1> l_fullItems = daRouteProcess.GetPSItems(prjId, rootMasterOid, child_pos_id, level, out masterOids, out revs);
            msg += "GetPSItems:" + l_fullItems.Count.ToString() + ":" + DateTime.Now.Subtract(start).ToString();
            start = DateTime.Now;
            //if (l_fullItems == null && l_fullItems.Count > 0)
            //{
            //    Guid masterOid = Guid.Empty;
            //    int rev = 0;
            //    DEFullRelationBizItem1 fullItem1 = daRouteProcess.GetPSRootItem(prjId, l_fullItems[0].child_posid, out masterOid, out rev);
            //    msg += "GetPSRootItem1:" + DateTime.Now.Subtract(start).ToString();
            //    start = DateTime.Now;
            //    if (fullItem1 != null)
            //    {
            //        l_fullItems.Insert(0, fullItem1);
            //        if (!masterOids.Contains(masterOid))
            //        {
            //            masterOids.Insert(0, masterOid);
            //            revs.Insert(0, rev);
            //        }
            //    }
            //    msg += "GetPSRootItem2:" + DateTime.Now.Subtract(start).ToString();
            //    start = DateTime.Now;
            //}
            //    ArrayList bizitems = new ArrayList();
            //    if (isLight)
            //    {
            //        bizitems = daRouteProcess.GetRoutePartItem(l_fullItems);
            //        msg += "GetRoutePartItem:" + bizitems.Count.ToString() + ":" +DateTime.Now.Subtract(start).ToString();
            //        start = DateTime.Now;
            //    }
            //    else
            //    {
            //        QRItem qrItem = new QRItem(this.dbParam);
            //        List<int> iters = new List<int>();
            //        for (int i = 0; i < masterOids.Count; i++)
            //            iters.Add(0);
            //        bizitems = qrItem.GetBizItems(masterOids.ToArray(), revs.ToArray(), iters.ToArray(), option.CurView, userOid, BizItemMode.BizItem);
            //        msg += "GetBizItems:" + bizitems .Count.ToString()+ ":" + DateTime.Now.Subtract(start).ToString();
            //        start = DateTime.Now;
            //    }
            //    foreach (DEFullRelationBizItem1 f in l_fullItems)
            //    {
            //        foreach (DEBusinessItem bizitem in bizitems)
            //        {
            //            if (bizitem.MasterOid == f.partMasterOid)
            //            {
            //                f.RightItem = bizitem;
            //                break;
            //            }
            //        }
            //    }
            //    msg += "foreach:" + DateTime.Now.Subtract(start).ToString();
            //    try
            //    {
            //        System.Diagnostics.EventLog.WriteEntry("TiPLM",msg);
            //    }
            //    catch { }
            //    return l_fullItems.ToArray();
            //}
            //catch (Exception ex)
            //{
            //    //if (ex is PLMException)
            //    //    throw ex;
            //    //else
            //    //{
            //    //    PLMEventLog.WriteExceptionLog(ex);
            //    //    throw new PLMException(ExceptionManager.E_PDT_CANNOT_GET_PSTREE, ex);
            //    //}
            //}
            //finally
            //{
            //    if (!this.isInTrans)
            //        this.dbParam.Close();
            //}
            return null;
        }
Пример #6
0
        public DEFullRelationBizItem1[] GetPSItems(string prjId, Guid rootMasterOid, long child_pos_id, DEPSOption option, int level, bool isLight, Guid userOid)
        {
            //try
            //{
            if (!this.isInTrans)
            {
                this.dbParam.Open();
            }

            // 获取用户的全局有效性选项
            if (option == null)
            {
                PRPSOption prOption = new PRPSOption(this.dbParam);
                option = prOption.GetUserGlobalOption(userOid);
            }
            //if (option == null)
            //    throw new PLMException(ExceptionManager.E_PDT_CANNOT_GET_USERGLOBALOPTION);
            string         msg                        = "";
            DateTime       start                      = DateTime.Now;
            DARouteProcess daRouteProcess             = new DARouteProcess(this.dbParam);
            List <Guid>    masterOids                 = null;
            List <int>     revs                       = null;
            List <DEFullRelationBizItem1> l_fullItems = daRouteProcess.GetPSItems(prjId, rootMasterOid, child_pos_id, level, out masterOids, out revs);

            msg  += "GetPSItems:" + l_fullItems.Count.ToString() + ":" + DateTime.Now.Subtract(start).ToString();
            start = DateTime.Now;
            //if (l_fullItems == null && l_fullItems.Count > 0)
            //{
            //    Guid masterOid = Guid.Empty;
            //    int rev = 0;
            //    DEFullRelationBizItem1 fullItem1 = daRouteProcess.GetPSRootItem(prjId, l_fullItems[0].child_posid, out masterOid, out rev);
            //    msg += "GetPSRootItem1:" + DateTime.Now.Subtract(start).ToString();
            //    start = DateTime.Now;
            //    if (fullItem1 != null)
            //    {
            //        l_fullItems.Insert(0, fullItem1);
            //        if (!masterOids.Contains(masterOid))
            //        {
            //            masterOids.Insert(0, masterOid);
            //            revs.Insert(0, rev);
            //        }
            //    }
            //    msg += "GetPSRootItem2:" + DateTime.Now.Subtract(start).ToString();
            //    start = DateTime.Now;
            //}
            //    ArrayList bizitems = new ArrayList();
            //    if (isLight)
            //    {
            //        bizitems = daRouteProcess.GetRoutePartItem(l_fullItems);
            //        msg += "GetRoutePartItem:" + bizitems.Count.ToString() + ":" +DateTime.Now.Subtract(start).ToString();
            //        start = DateTime.Now;
            //    }
            //    else
            //    {
            //        QRItem qrItem = new QRItem(this.dbParam);
            //        List<int> iters = new List<int>();
            //        for (int i = 0; i < masterOids.Count; i++)
            //            iters.Add(0);
            //        bizitems = qrItem.GetBizItems(masterOids.ToArray(), revs.ToArray(), iters.ToArray(), option.CurView, userOid, BizItemMode.BizItem);
            //        msg += "GetBizItems:" + bizitems .Count.ToString()+ ":" + DateTime.Now.Subtract(start).ToString();
            //        start = DateTime.Now;
            //    }
            //    foreach (DEFullRelationBizItem1 f in l_fullItems)
            //    {
            //        foreach (DEBusinessItem bizitem in bizitems)
            //        {
            //            if (bizitem.MasterOid == f.partMasterOid)
            //            {
            //                f.RightItem = bizitem;
            //                break;
            //            }
            //        }
            //    }
            //    msg += "foreach:" + DateTime.Now.Subtract(start).ToString();
            //    try
            //    {
            //        System.Diagnostics.EventLog.WriteEntry("TiPLM",msg);
            //    }
            //    catch { }
            //    return l_fullItems.ToArray();
            //}
            //catch (Exception ex)
            //{
            //    //if (ex is PLMException)
            //    //    throw ex;
            //    //else
            //    //{
            //    //    PLMEventLog.WriteExceptionLog(ex);
            //    //    throw new PLMException(ExceptionManager.E_PDT_CANNOT_GET_PSTREE, ex);
            //    //}
            //}
            //finally
            //{
            //    if (!this.isInTrans)
            //        this.dbParam.Close();
            //}
            return(null);
        }