예제 #1
0
            public string GetFileName(IInFileDef fileDef, ExternalFileDef extDef = null)
            {
                if (fileDef == null)
                {
                    throw new PackageBaseException("InFileDef is null");
                }

                string placeIn = fileDef.Path;

                if (placeIn == null)
                {
                    Log.Warn(String.Format("Path is null for file '{0}'", fileDef.Name));
                    placeIn = "";
                }

                string folder = placeIn.Trim(new[] { '/', '\\' }) + "/";

                if (folder == "/")
                {
                    folder = "";
                }

                string defaultName       = fileDef.ExpectedName;
                string userSpecifiedName = (extDef != null)? extDef.FileName: "";
                string fileName          = folder + (String.IsNullOrEmpty(defaultName)? userSpecifiedName: defaultName);

                return(fileName.Replace('\\', '/'));
            }
예제 #2
0
            public OpenFileResult InputFileOpenRead(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                OpenFileResult result;

                string storageId = externalFileDefinition.Locator;

                if (String.IsNullOrEmpty(storageId))
                {
                    result = new OpenFileResult
                    {
                        FilePath = "", // note: or fileName
                        Stream   = null,
                    };
                }
                else
                {
                    string tmpFileName = Path.GetTempFileName();
                    _tmpFilesToDel.Add(tmpFileName);

                    Log.Debug("Loading input file from storage for PB: " + storageId);
                    IOProxy.Storage.Download(storageId, tmpFileName);
                    Log.Debug("Loading done for file: " + storageId);

                    result = new OpenFileResult
                    {
                        FilePath = tmpFileName, // note: or fileName
                        Stream   = File.OpenRead(tmpFileName),
                    };
                }

                return(result);
            }
예제 #3
0
            public string GetSlotName(IInFileDef fileDef)
            {
                if (fileDef == null)
                {
                    throw new PackageBaseException("InFileDef is null");
                }

                return(fileDef.Name);
            }
예제 #4
0
            public long InputFileCopy(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                long fileSize = 0;

                string storageId = externalFileDefinition.Locator;

                if (!String.IsNullOrEmpty(storageId))
                {
                    _filesToCopyFromStorage.Add(new TaskFileDescription
                    {
                        FileName  = GetFileName(fileDef, externalFileDefinition),
                        SlotName  = GetSlotName(fileDef),
                        StorageId = storageId,
                    });

                    fileSize = IOProxy.Storage.GetFileSize(storageId); // todo : 0?
                }

                return(fileSize);
            }
            public string GetFileName(IInFileDef fileDef, ExternalFileDef extDef = null)
            {
                if (fileDef == null)
                    throw new PackageBaseException("InFileDef is null");

                string placeIn = fileDef.Path;
                if (placeIn == null)
                {
                    Log.Warn(String.Format("Path is null for file '{0}'", fileDef.Name));
                    placeIn = "";
                }

                string folder = placeIn.Trim(new[] { '/', '\\' }) + "/";
                if (folder == "/")
                    folder = "";

                string defaultName = fileDef.ExpectedName;
                string userSpecifiedName = (extDef != null)? extDef.FileName: "";
                string fileName = folder + (String.IsNullOrEmpty(defaultName)? userSpecifiedName: defaultName);

                return fileName.Replace('\\', '/');
            }
예제 #6
0
            public OpenFileResult InputFileOpenWrite(IInFileDef fileDef, DynamicContext ctx)
            {
                string tmpFilePath = Path.GetTempFileName();

                _tmpFilesToDel.Add(tmpFilePath);

                _filesToCopyFromTmp.Add(Tuple.Create(
                                            new TaskFileDescription
                {
                    FileName = GetFileName(fileDef),
                    SlotName = GetSlotName(fileDef)
                },
                                            tmpFilePath
                                            ));

                var res = new OpenFileResult()
                {
                    FilePath = tmpFilePath, // note: or fileName
                    Stream   = File.OpenWrite(tmpFilePath)
                };

                return(res);
            }
            public OpenFileResult InputFileOpenWrite(IInFileDef fileDef, DynamicContext ctx)
            {
                string tmpFilePath = Path.GetTempFileName();
                _tmpFilesToDel.Add(tmpFilePath);

                _filesToCopyFromTmp.Add(Tuple.Create(
                    new TaskFileDescription
                    {
                        FileName = GetFileName(fileDef),
                        SlotName = GetSlotName(fileDef)
                    },
                    tmpFilePath
                ));

                var res = new OpenFileResult()
                {
                    FilePath = tmpFilePath, // note: or fileName
                    Stream = File.OpenWrite(tmpFilePath)
                };

                return res;
            }
            public OpenFileResult InputFileOpenRead(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                OpenFileResult result;

                string storageId = externalFileDefinition.Locator;
                if (String.IsNullOrEmpty(storageId))
                {
                    result = new OpenFileResult
                    {
                        FilePath = "", // note: or fileName
                        Stream = null,
                    };
                }
                else
                {
                    string tmpFileName = Path.GetTempFileName();
                    _tmpFilesToDel.Add(tmpFileName);

                    Log.Debug("Loading input file from storage for PB: " + storageId);
                    IOProxy.Storage.Download(storageId, tmpFileName);
                    Log.Debug("Loading done for file: " + storageId);

                    result = new OpenFileResult
                    {
                        FilePath = tmpFileName, // note: or fileName
                        Stream = File.OpenRead(tmpFileName),
                    };
                }

                return result;
            }
            public long InputFileCopy(IInFileDef fileDef, ExternalFileDef externalFileDefinition, DynamicContext ctx)
            {
                long fileSize = 0;

                string storageId = externalFileDefinition.Locator;
                if (!String.IsNullOrEmpty(storageId))
                {
                    _filesToCopyFromStorage.Add(new TaskFileDescription
                    {
                        FileName = GetFileName(fileDef, externalFileDefinition),
                        SlotName = GetSlotName(fileDef),
                        StorageId = storageId,
                    });

                    fileSize = IOProxy.Storage.GetFileSize(storageId); // todo : 0?
                }

                return fileSize;
            }
            public string GetSlotName(IInFileDef fileDef)
            {
                if (fileDef == null)
                    throw new PackageBaseException("InFileDef is null");

                return fileDef.Name;
            }