private void GetLargeAttachment(
     string localFileName,
     string remoteFileName)
 {
     // Get attachment
     m_AttachedFileManager.GetAttachment(localFileName, remoteFileName);
 }
Esempio n. 2
0
        //
        //	Private
        //

        #region Import support

        private void CopyNodeAttachments(
            ITisDataLayerTreeNode oSrcTreeNode,
            ITisDataLayerTreeNode oDstTreeNode)
        {
            ISupportsAttachments oSrc = oSrcTreeNode as ISupportsAttachments;
            ISupportsAttachments oDst = oDstTreeNode as ISupportsAttachments;

            EntityBase oSrcEntity = oSrcTreeNode as EntityBase;
            EntityBase oDstEntity = oDstTreeNode as EntityBase;

            if (oSrc == null || oDst == null || oSrcEntity == null || oDstEntity == null)
            {
                return;
            }

            IList <string> oLocalAttachments = oSrc.LocalAttachments;

            ITisAttachedFileManager oSrcAttachedFileManager = (ITisAttachedFileManager)oSrcEntity.GetContextService(
                TisServicesSchema.SetupAttachmentsFileManager.ServiceName);

            ITisAttachedFileManager oDstAttachedFileManager = (ITisAttachedFileManager)oDstEntity.GetContextService(
                TisServicesSchema.SetupAttachmentsFileManager.ServiceName);

            foreach (string sAttachment in oLocalAttachments)
            {
                string sAttType    = AttachmentsUtil.GetAttachmentType(sAttachment);
                string sDstAttName = oDst.GetAttachmentFileName(sAttType) ?? oDst.GetAttachmentNameByFileName(sAttachment);

                try
                {
                    if (!StringUtil.CompareIgnoreCase(sAttachment, sDstAttName))
                    {
                        if (!File.Exists(sAttachment))
                        {
                            oSrcAttachedFileManager.GetAttachment(sAttachment);
                        }

                        if (StringUtil.CompareIgnoreCase(sAttType, "EFI"))
                        {
                            // Special handling for EFIs
                            int nRetVal = FoLearn.CopyToNewEfi(
                                sAttachment,
                                sDstAttName);

                            if (nRetVal != 0)
                            {
                                throw new TisException("FoLearn.CopyToNewEfi failed, Code={0}", nRetVal);
                            }
                        }
                        else
                        {
                            // Copy local (cached)
                            File.Copy(
                                sAttachment,
                                sDstAttName,
                                true // Overwrite
                                );
                        }
                    }
                }
                catch (Exception oExc)
                {
                    Log.WriteException(oExc);

                    throw;
                }

                // Save to server
                oDstAttachedFileManager.SaveAttachment(
                    sDstAttName,
                    TIS_ATTACHMENT_EXISTS_ACTION.TIS_EXISTING_OVERRIDE);
            }
        }