Esempio n. 1
0
        /// <summary>
        /// Check the import mailbox.  Returns the first CSV file in the mailbox.
        /// </summary>
        /// <returns></returns>
        public async Task CheckMailBoxForImport(PerformContext hangfireContext)
        {
            Pop3Client pop3Client = new Pop3Client();
            await pop3Client.ConnectAsync(Configuration["SPD_IMPORT_POP3_SERVER"],
                                          Configuration["SPD_IMPORT_POP3_USERNAME"],
                                          Configuration["SPD_IMPORT_POP3_PASSWORD"], true);

            List <Pop3Message> messages = (await pop3Client.ListAndRetrieveAsync()).ToList();

            foreach (Pop3Message message in messages)
            {
                var attachments = message.Attachments.ToList();
                if (attachments.Count > 0)
                {
                    // string payload = null; // File.ReadAllText("C:\\tmp\\testimport.csv");

                    string payload = Encoding.Default.GetString(attachments[0].GetData());
                    if (payload != null) // parse the payload
                    {
                        List <WorkerResponse> responses = WorkerResponseParser.ParseWorkerResponse(payload);
                        foreach (WorkerResponse workerResponse in responses)
                        {
                            // search for the Personal History Record.
                            MicrosoftDynamicsCRMadoxioPersonalhistorysummary record = _dynamics.Personalhistorysummaries.GetByWorkerJobNumber(workerResponse.RecordIdentifier);

                            if (record != null)
                            {
                                // update the record.
                                MicrosoftDynamicsCRMadoxioPersonalhistorysummary patchRecord = new MicrosoftDynamicsCRMadoxioPersonalhistorysummary()
                                {
                                    AdoxioSecuritystatus = SPDResultTranslate.GetTranslatedSecurityStatus(workerResponse.Result),
                                    AdoxioCompletedon    = workerResponse.DateProcessed
                                };

                                try
                                {
                                    _dynamics.Personalhistorysummaries.Update(record.AdoxioPersonalhistorysummaryid, patchRecord);
                                }
                                catch (OdataerrorException odee)
                                {
                                    hangfireContext.WriteLine("Error updating worker personal history");
                                    hangfireContext.WriteLine("Request:");
                                    hangfireContext.WriteLine(odee.Request.Content);
                                    hangfireContext.WriteLine("Response:");
                                    hangfireContext.WriteLine(odee.Response.Content);
                                }
                            }
                        }
                    }
                }

                await pop3Client.DeleteAsync(message);

                hangfireContext.WriteLine("Deleted message:");
            }
        }
        public async Task DeleteFailNotConnectAsync()
        {
            Pop3Client pop3Client = new Pop3Client(new DummyNetworkOperations("+OK"));

            Assert.IsFalse(pop3Client.IsConnected);

            await pop3Client.DeleteAsync(new Pop3Message()
            {
                Number = 1
            });
        }
        public async Task DeleteFailNullArgumentAsync()
        {
            Pop3Client pop3Client = new Pop3Client(new DummyNetworkOperations("+OK"));

            Assert.IsFalse(pop3Client.IsConnected);

            await pop3Client.ConnectAsync("SERVER", "USERNAME", "PASSWORD", true);

            Assert.IsTrue(pop3Client.IsConnected);

            await pop3Client.DeleteAsync(null);
        }
        public async Task DeleteOkAsync()
        {
            Pop3Client pop3Client = new Pop3Client(new DummyNetworkOperations("+OK"));

            Assert.IsFalse(pop3Client.IsConnected);

            await pop3Client.ConnectAsync("SERVER", "USERNAME", "PASSWORD", false);

            await pop3Client.DeleteAsync(new Pop3Message()
            {
                Number = 1
            });
        }
Esempio n. 5
0
        public async Task DeleteFailNullArgumentAsync( )
        {
            Pop3Client pop3Client = new Pop3Client( new DummyNetworkOperations( "+OK" ) );
            Assert.IsFalse( pop3Client.IsConnected );

            await pop3Client.ConnectAsync( "SERVER", "USERNAME", "PASSWORD", true );
            Assert.IsTrue( pop3Client.IsConnected );

            await pop3Client.DeleteAsync( null );
        }
Esempio n. 6
0
        public async Task DeleteFailNotConnectAsync( )
        {
            Pop3Client pop3Client = new Pop3Client( new DummyNetworkOperations( "+OK" ) );
            Assert.IsFalse( pop3Client.IsConnected );

            await pop3Client.DeleteAsync( new Pop3Message( ) { Number = 1 } );
        }
Esempio n. 7
0
        public async Task DeleteOkAsync( )
        {
            Pop3Client pop3Client = new Pop3Client( new DummyNetworkOperations( "+OK" ) );
            Assert.IsFalse( pop3Client.IsConnected );

            await pop3Client.ConnectAsync( "SERVER", "USERNAME", "PASSWORD", false );

            await pop3Client.DeleteAsync( new Pop3Message( ) { Number = 1 } );
        }