示例#1
0
        public bool PrepareInput()
        {
            //int dataSourceId = 0;
            //int.TryParse(e.ApplicationParameters["DataSourceId"].ToString(), out dataSourceId);
            //if (dataSourceId == 0)
            //    return;


            InputFileNameOnly = Path.GetFileNameWithoutExtension(InputFileName);
            //string InputFileExtension = Path.GetExtension(InputFileName);


            Keys = Cache.Instance.Bag[DataSourceId + ".keys"] as List <IdpeKey>;
            if (Keys == null)
            {
                Keys = DataSource.LoadKeys(DataSourceId);
            }


            OutputFolder       = DataSource.GetOutputFolder(DataSourceId, Keys);
            ActualOutputFolder = OutputFolder;
            OutputFileName     = DataSource.GetOutputFileName(DataSourceId, Keys, OutputFolder, InputFileNameOnly);



            string appWatchFilter = Keys.GetKeyValue(IdpeKeyTypes.WatchFilter);

            ZipInterfaceName = Keys.GetKeyValue(IdpeKeyTypes.ZipInterfaceName);

            if ((InputFileExtension.ToLower() == ".zip") || (InputFileExtension.ToLower() == ".rar") || (InputFileExtension.ToLower() == ".tar"))
            {
                OutputFolder = Path.Combine(EyediaCoreConfigurationSection.CurrentConfig.TempDirectory, Constants.IdpeBaseFolderName);
                OutputFolder = Path.Combine(OutputFolder, "RedirectedOutput");
                OutputFolder = Path.Combine(OutputFolder, DateTime.Now.ToDBDateFormat());
                OutputFolder = Path.Combine(OutputFolder, DataSourceId.ToString());
            }

            if ((!string.IsNullOrEmpty(appWatchFilter)) &&
                (appWatchFilter != Pullers.FileExtensionSupportAll))
            {
                List <string> filters = new List <string>();
                if (appWatchFilter.Contains("|"))
                {
                    filters.AddRange(appWatchFilter.ToLower().Split("|".ToCharArray()));
                }
                else
                {
                    filters.Add(appWatchFilter.ToLower());
                }

                var filterOrNot = (from f in filters
                                   where f == InputFileExtension.ToLower()
                                   select f).SingleOrDefault();
                if (filterOrNot == null)
                {
                    if (!InputFileNameOnly.StartsWith(Constants.UnzippedFilePrefix))
                    {
                        IdpeMessage warn       = new IdpeMessage(IdpeMessageCodes.IDPE_FILE_TYPE_NOT_SUPPORTED);
                        DataSource  dataSource = new DataSource(DataSourceId, string.Empty);
                        WithWarning = string.Format(warn.Message, dataSource.Name, appWatchFilter, Path.GetFileName(InputFileName));
                        ExtensionMethods.TraceInformation(WithWarning);
                        new PostMan(dataSource).Send(PostMan.__warningStartTag + WithWarning + PostMan.__warningEndTag, "File Ignored");
                        return(false);
                    }
                }
            }

            if (InputFileNameOnly.StartsWith(Constants.WCFFilePrefix))
            {
                IsRequestFromWCF = true;
                JobId            = InputFileNameOnly.Replace(Constants.WCFFilePrefix, "");
                JobId            = JobId.Replace(InputFileExtension, "");
            }
            else if (InputFileNameOnly.StartsWith(Constants.UnzippedFilePrefix))
            {
                ZipUniuqeId  = ZipFileWatcher.ExtractUniqueId(InputFileNameOnly);
                OutputFolder = Path.Combine(OutputFolder, ZipUniuqeId);
                if (!Directory.Exists(OutputFolder))
                {
                    Directory.CreateDirectory(OutputFolder);
                }

                OutputFileName = Path.Combine(OutputFolder, InputFileNameOnly + Path.GetExtension(OutputFileName));
                OutputFileName = ZipFileWatcher.ExtractActualFileName(OutputFileName);
            }

            return(true);
        }