Beispiel #1
0
        public string GetFullPathToFileAttachment(StoreItem item, string fileName)
        {
            try
            {
                DatastoreItem dsItem = item.DSItem;
                OpenForRead(dsItem);
                ProductStudio.Files files = dsItem.Files;
                foreach (ProductStudio.File file in files)
                {
                    if (StringUtils.StringsMatch(fileName, file.FileName))
                    {
                        string tempFile = FileUtils.GetFullPathToTempFile(file.FileName);
                        file.SaveToFile(tempFile, true);
                        return(tempFile);
                    }
                }

                return(null);
            }
            catch (Exception e)
            {
                item.CommitErrorState = CommitErrorStates.ErrorAccessingAttachmentShare;
                Planner.Instance.HandleStoreItemException(item, e);
                return(null);
            }
        }
Beispiel #2
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// If an attached file exists in the given item with the filename given in the
        /// specified full path, this routine removes it.
        /// </summary
        //------------------------------------------------------------------------------------
        private void RemoveAttachedFile(DatastoreItem dsItem, string fullFilePath)
        {
            string fileName = Path.GetFileName(fullFilePath);

            if (dsItem != null)
            {
                ProductStudio.Files files = dsItem.Files;

                int indexToRemove = 0;
                foreach (ProductStudio.File file in files)
                {
                    if (file.FileName == fileName)
                    {
                        dsItem.Files.Remove(indexToRemove);
                        return;
                    }

                    indexToRemove++;
                }
            }
        }