Пример #1
0
        /// <summary>
        /// Get all (collection level) attachments.
        /// </summary>
        /// <param name="csm"></param>
        /// <param name="fm"></param>
        /// <returns></returns>
        public static String[] GetAttachments(ITisClientServicesModule csm, ITisAttachedFileManager fm)
        {
            List <String> result = new List <String>();

            try
            {
                IStringVectorReadOnly rvc = fm.QueryAllAttachments();
                if (rvc != null && rvc.Count > 0)
                {
                    foreach (String s in rvc)
                    {
                        String fullPath = csm == null ? s : Path.Combine(csm.PathLocator.get_Path(CCEnums.CCFilesExt.TIF.ToString()), s);
                        if (csm == null || File.Exists(fullPath))
                        {
                            result.Add(fullPath);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(result.ToArray());
        }
 public AttachmentsSynchronizer(
     ITisAttachedFileManager attachedFileManager,
     IPathProvider localPathProvider,
     string inputDir,
     List <ITisAttachmentsSynchronizationContext> attachmentsSynchronizationContexts)
     : this(attachedFileManager, localPathProvider, inputDir)
 {
     foreach (ITisAttachmentsSynchronizationContext attachmentsSynchronizationContext in attachmentsSynchronizationContexts)
     {
         AddAttachmentsSynchronizationContext(attachmentsSynchronizationContext);
     }
 }
Пример #3
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);
            }
        }
        //
        //	Public
        //

        public AttachmentsSynchronizer(ITisAttachedFileManager attachedFileManager, IPathProvider localPathProvider, string inputDir)
        {
            m_LocalPathProvider   = localPathProvider;
            m_AttachedFileManager = attachedFileManager;
            m_InputDir            = inputDir;
        }