Ejemplo n.º 1
0
        internal static FileInformationResponse GetFileInformation(FileInformationRequest fileInformation)
        {
            var filename        = Path.GetFileNameWithoutExtension(fileInformation.File);
            var filenamext      = Path.GetFileName(fileInformation.File);
            var ext             = Path.GetExtension(fileInformation.File);
            var processedpath   = fileInformation.File_path + "\\processed-files\\" + fileInformation.Day;
            var procesedpath1   = fileInformation.File_path + "\\processed-files\\" + fileInformation.Day + "\\" + filenamext;
            var unProcessedpath = fileInformation.File_path + "\\Unprocessed-files\\" + fileInformation.Day;
            var unProcesedpath1 = fileInformation.File_path + "\\Unprocessed-files\\" + fileInformation.Day + "\\" + filenamext;
            var origPath        = fileInformation.File_path + "\\" + filenamext;
            var splitedpath     = "" + fileInformation.File_path + "\\Splitfiles\\" + fileInformation.Day + ""; //the local directory for splitted files
            var path            = "" + splitedpath + "\\" + filename + filenamext;

            return(new FileInformationResponse
            {
                Filename = filename,
                Filenamext = filenamext,
                Extension = ext,
                Processedpath = processedpath,
                ProcessedpathFile = procesedpath1,
                UnProcessedpath = unProcessedpath,
                UnProcessedpathFile = unProcesedpath1,
                Splitedpath = splitedpath,
                SplitedpathFile = path,
            });
        }
Ejemplo n.º 2
0
        /*public async override Task<FileGetReply> Get(FileGetRequest request, ServerCallContext context)
         * {
         *  // await Server.FileRegistry.Instance.Register(new Server.File(request.Filename));
         *  Guid parsed;
         *  var reply = new FileGetReply {
         *   };
         *  if (Guid.TryParse(request.Id, out parsed)) {
         *      reply.Where2Get.Add("bla");
         *  }
         *  return (await Task.FromResult(reply));
         * }*/

        // Dummy Functions
        public async override Task <FileInformationReply> GetFileInformation(FileInformationRequest request, ServerCallContext context)
        {
            // await Server.FileRegistry.Instance.Register(new Server.File(request.Filename));
            Guid parsed;
            var  reply = new FileInformationReply {
            };

            if (Guid.TryParse(request.Id, out parsed))
            {
            }
            return(await Task.FromResult(reply));
        }
Ejemplo n.º 3
0
        public override void HandleRequest(Request request)
        {
            if (request is FileInformationRequest)
            {
                FileInformationRequest fi_request = request as FileInformationRequest;
                FileRetriever          retriever  = new FileRetriever(fi_request.Type, fi_request.Name);
                FileRecord             frecord    = retriever.Get();
                if (frecord != null)
                {
                    fi_request.ID      = frecord.ID;
                    fi_request.Details = frecord.Details;
                }

                request.Handled();
            }
        }
Ejemplo n.º 4
0
        public List <DailyFileInfo> DoRead()
        {
            List <DailyFileInfo> reports   = new List <DailyFileInfo>();
            DirectoryTraverser   traverser = new DirectoryTraverser(BaseDirectory, "*.json");
            List <FileInfo>      files     = traverser.files;

            foreach (FileInfo file in files)
            {
                try
                {
                    FileInformationRequest req = new FileInformationRequest(EFileType.COMMONDailyFile, file.FullName);
                    RequestBus.Instance.MakeRequest(req);
                    if (req.IsHandled)
                    {
                        // Return a report if the ID isn't in the database, or if it has changed since it's been put in the database
                        bool return_report =
                            req.Details == null ||
                            req.ID < 0 ||
                            req.Details.Size != (ulong)file.Length ||
                            req.Details.Modification != file.LastWriteTime;

                        if (return_report)
                        {
                            DailyFileInfo file_info = new DailyFileInfo()
                            {
                                Info    = file,
                                Details = req.Details,
                            };
                            reports.Add(file_info);
                        }
                    }
                }
                catch (Exception e)
                {
                    ILog log = LogManager.GetLogger(typeof(Reader));
                    log.Error(e);
                }
            }

            return(reports);
        }