Exemplo n.º 1
0
        public static List <OrderDocument> GetNew()
        {
            if (_imap == null)
            {
                return(null);
            }

            var orders = new List <OrderDocument>();

            var messageHeads = _imap.GetNewMessageHeads();

            if (messageHeads == null)
            {
                return(null);
            }
            foreach (var head in messageHeads)
            {
                var message = _imap.GetMessage(head.UID);
                if (message?.Attachments == null)
                {
                    continue;
                }
                var fileNames = new List <string>();
                foreach (var attach in message.Attachments)
                {
                    if (attach == null)
                    {
                        continue;
                    }
                    var attachFileName = FileArchiveTransport.GetCustomerOrderPath() + attach.Text;
                    try {
                        File.WriteAllBytes(attachFileName, attach.Body);
                        fileNames.Add(attachFileName);
                    } catch (Exception ex) {
                        //Debug.WriteLine("NewOrderTransport.GetNew: " + ex.Message);
                        AppJournal.Write("NewOrderTransport.GetNew: " + ex.Message);
                    }
                }
                orders.Add(new OrderDocument()
                {
                    OrderFileNames = fileNames
                });
            }
            return(orders);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Copies single income report file to archive.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>file to which copied</returns>
        public static FileInfo CopyReport(string filename)
        {
            var outFileName = FileArchiveTransport.GetIncomingReportFileName(filename.Substring(filename.LastIndexOf(@"\", StringComparison.Ordinal) + 1));

            try {
                if (File.Exists(outFileName))
                {
                    File.Delete(outFileName);
                }
                File.Move(filename, outFileName);
            } catch (Exception ex) {
                AppJournal.Write(System.Reflection.MethodBase.GetCurrentMethod().Name, "ReportTransport: CopyReport: " + ex.Message);
                return(null);
            }
            var info = new FileInfo(outFileName);

            return(info);
        }
Exemplo n.º 3
0
        private static FileInfo CopyReport(string filename)
        {
            string outFileName = FileArchiveTransport.GetIncomingReportFileName(filename.Substring(filename.LastIndexOf("\\") + 1));

            try {
                if (File.Exists(outFileName))
                {
                    File.Delete(outFileName);
                }
                File.Move(filename, outFileName);
            } catch (Exception ex) {
                Debug.WriteLine("EDOTransport: CopyReport: " + ex.Message);
                return(null);
            }
            FileInfo info = new FileInfo(outFileName);

            return(info);
        }