Exemplo n.º 1
0
        public override bool Initialize()
        {
            if (!IsInitialized)
            {
                m_NodeParams = NodeParams.Extract(NodeParamList);
            }

            return(base.Initialize());
        }
Exemplo n.º 2
0
        public override void ReturnResponse(AdapterMessage message, object state)
        {
            try
            {
                Tracer.WriteBegin();
                if (m_NodeParams.IsTwoWay)
                {
                    m_NodeParams = NodeParams.Extract(NodeParamList);

                    string filepath = Path.Combine(m_NodeParams.ReplyPath, m_NodeParams.ReplyFilename);

                    Tracer.WriteLine($"Writing response-file: '{filepath}'");
                    System.IO.File.WriteAllBytes(filepath, message.GetDataAsArray());
                }
            }
            finally
            {
                Tracer.WriteEnd();
            }
        }
Exemplo n.º 3
0
        public override void ReceiveMessages()
        {
            m_NodeParams = NodeParams.Extract(NodeParamList);

            using (FileSystemEnumerator fse = new FileSystemEnumerator(m_NodeParams.Path, m_NodeParams.Filter, m_NodeParams.IncludeSubFolders))
            {
                fse.IncludeEmptyFiles = m_NodeParams.IncludeEmptyFiles;
                TimeSpan minfileAge = TimeSpan.FromSeconds(m_NodeParams.MinFileAge);

                var matches      = fse.Matches(m_NodeParams.SortOptions, minfileAge, base.MaxReceiveCount);
                int matchesCount = matches.Count();
                if (matchesCount > 0)
                {
                    if (base.MultiThreadingEnabled && base.MaxThreads > 1)
                    {
                        var result = Parallel.ForEach(matches,
                                                      new ParallelOptions {
                            MaxDegreeOfParallelism = base.MaxThreads, CancellationToken = CancellationToken
                        },
                                                      (fi, state, index) =>
                        {
                            HandleMessage(fi);
                        });
                    }
                    else
                    {
                        foreach (FileInfo fi in matches)
                        {
                            // Break if we're stopping or suspending
                            if (!IsRunning || IsSuspended)
                            {
                                break;
                            }

                            HandleMessage(fi);
                        }
                    }
                }
            }
        }