private PivotImage CopyCollectionImage(PivotImage sourceImage, String suffix)
            {
                if (sourceImage == null) return null;

                PivotImage newImage = new PivotImage(
                    UriUtility.ExpandRelativeUri(this.BasePath, sourceImage.SourcePath));

                String sourceFileName = UriUtility.GetFileName(newImage.SourcePath);
                String targetFileName = Path.GetFileNameWithoutExtension(m_localTarget.BasePath);
                targetFileName += suffix + Path.GetExtension(sourceFileName);
                String targetDirectoryPath = Directory.GetParent(m_localTarget.BasePath).FullName;
                String targetFilePath = Path.Combine(targetDirectoryPath, targetFileName);
                if (File.Exists(targetFilePath) == false)
                {
                    newImage.Save(targetFilePath);
                }

                newImage.SourcePath = targetFileName;
                return newImage;
            }
Ejemplo n.º 2
0
        public int Submit(PivotImage sourceImage)
        {
            String dziTargetPath = Path.GetFileNameWithoutExtension(sourceImage.SourcePath);
            dziTargetPath = dziTargetPath.Replace(' ', '_');
            dziTargetPath = dziTargetPath.Replace('{', '_');
            dziTargetPath = dziTargetPath.Replace('}', '_');
            dziTargetPath = dziTargetPath.Replace('[', '_');
            dziTargetPath = dziTargetPath.Replace(']', '_');
            dziTargetPath = String.Format(DziFileNameTemplate, dziTargetPath);
            dziTargetPath = Path.Combine(m_outputDirectory, dziTargetPath);

            int index = m_dziPaths.IndexOf(dziTargetPath);
            if (index != -1) return index;

            m_dziPaths.Add(dziTargetPath);

            if (File.Exists(dziTargetPath) == false)
            {
                lock (m_workQueue)
                {
                    lock (m_itemsRemaining)
                    {
                        m_workQueue.Enqueue(new Object[] { new PivotImage(sourceImage.SourcePath), dziTargetPath });
                        m_itemsRemaining[0]++;
                    }
                    Monitor.Pulse(m_workQueue);
                }
            }

            return m_dziPaths.Count - 1;
        }