コード例 #1
0
        private void SendEmail(CPCOfficialFile cpcOfficialFile)
        {
            var message  = new MailMessage();
            var fromAddr = new MailAddress("*****@*****.**");

            message.From = fromAddr;
            message.To.Add(HtEmails[cpcOfficialFile.CPCOfficialFileConfig.Dealer].ToString());
            if (cpcOfficialFile.FileCode == "210305" || cpcOfficialFile.FileCode == "210308")
            {
                var objDate = DbHelperOra.GetSingle($"select FIRST_HK_CANCELLED from PATENTCASE where OURNO = '{cpcOfficialFile.CaseSerial}'");
                if (objDate?.ToString().ToUpper() != "Y")
                {
                    message.To.Add("*****@*****.**");
                }
            }
            var objClient = DbHelperOra.GetSingle($"select CLIENT from PATENTCASE where OURNO = '{cpcOfficialFile.CaseSerial}'");

            if (objClient?.ToString() == "3443")
            {
                message.To.Add("*****@*****.**");
            }
            message.CC.Add("*****@*****.**");
            message.Headers.Add("Disposition-Notification-To", "*****@*****.**");

            var listSubject = new List <string>();

            listSubject.Add(cpcOfficialFile.CaseSerial);
            if (cpcOfficialFile.Applicants.Count > 0)
            {
                listSubject.Add(cpcOfficialFile.Applicants.Cast <DictionaryEntry>().ToList()[0].Key.ToString());
            }
            listSubject.Add(cpcOfficialFile.FileName);
            if (cpcOfficialFile.CPCOfficialFileConfig.CreateDeadline &&
                cpcOfficialFile.CPCOfficialFileConfig.DeadlineFiled != "PRE_EXAM_PASSED" &&
                !(cpcOfficialFile.FileCode == "200702" && !IsValidCase(cpcOfficialFile.AppNo)))
            {
                listSubject.Add(
                    cpcOfficialFile.SendDate.AddDays(cpcOfficialFile.CPCOfficialFileConfig.AddDays)
                    .AddMonths(cpcOfficialFile.CPCOfficialFileConfig.AddMonths)
                    .ToString("yyyy/MM/dd"));
            }
            else if (cpcOfficialFile.FileCode == "200103")//缴纳申请费通知书
            {
                listSubject.Add((cpcOfficialFile.DivFilingDate ?? cpcOfficialFile.AppDate).AddMonths(2).ToString("yyyy/MM/dd"));
            }
            else if (cpcOfficialFile.FileCode == "200021")//费用减缓通知书
            {
                listSubject.Add((cpcOfficialFile.DivFilingDate ?? cpcOfficialFile.AppDate).AddMonths(2).ToString("yyyy/MM/dd"));
            }
            if (!string.IsNullOrWhiteSpace(cpcOfficialFile.WithDrew))
            {
                listSubject.Add(cpcOfficialFile.WithDrew);
            }
            message.Subject = string.Join(";", listSubject);

            var listBody = new List <string>();

            listBody.Add(
                $"申请人:{string.Join("; ", cpcOfficialFile.Applicants.Cast<DictionaryEntry>().Select(a => a.Key + "," + a.Value).ToList())}");
            listBody.Add($"委托人:{cpcOfficialFile.ClientNo},{cpcOfficialFile.ClientName}");
            listBody.Add($@"文件地址:\\PTFILE\PATENT\Cases-CN\{cpcOfficialFile.CaseSerial.Substring(0, cpcOfficialFile.CaseSerial.IndexOf("-", StringComparison.Ordinal))}\From_Office");
            message.Body = string.Join("\r\n", listBody);

            var client = new SmtpClient("smtp.beijingeastip.com", 25);

            client.Credentials = new NetworkCredential("*****@*****.**", "O@notice");
            //client.EnableSsl = true;
            client.Send(message);
        }
コード例 #2
0
        public void GeneratePDFFile(CPCOfficialFile cpcOfficialFile)
        {
            if (!Directory.Exists(cpcOfficialFile.FilePath))
            {
                return;
            }
            var sCPCFilePath = $@"{cpcOfficialFile.FilePath}\{cpcOfficialFile.FileSerial}\{cpcOfficialFile.FileSerial}";

            if (!Directory.Exists(sCPCFilePath))
            {
                return;
            }
            var files = Directory.GetFiles(sCPCFilePath, "*.tif").ToList();

            Directory.GetFiles(cpcOfficialFile.FilePath, "*.tif", SearchOption.AllDirectories).ToList().ForEach(s =>
            {
                if (files.Contains(s))
                {
                    return;
                }
                files.Add(s);
            });
            if (files.Count == 0)
            {
                return;
            }
            var sGenerateFile = $@"D:\GenerateFolder\{DateTime.Now:yyyyMMddtt}\{cpcOfficialFile.CaseSerial.Substring(0, cpcOfficialFile.CaseSerial.IndexOf("-", StringComparison.Ordinal))}-{DateTime.Now:yyyyMMdd}-{(cpcOfficialFile.CPCOfficialFileConfig == null ? cpcOfficialFile.FileName : cpcOfficialFile.CPCOfficialFileConfig.Rename)}.pdf";
            int i             = 1;

            while (File.Exists(sGenerateFile))
            {
                sGenerateFile = $@"D:\GenerateFolder\{DateTime.Now:yyyyMMddtt}\{cpcOfficialFile.CaseSerial.Substring(0, cpcOfficialFile.CaseSerial.IndexOf("-", StringComparison.Ordinal))}-{DateTime.Now:yyyyMMdd}-{(cpcOfficialFile.CPCOfficialFileConfig == null ? cpcOfficialFile.FileName : cpcOfficialFile.CPCOfficialFileConfig.Rename)}{i}.pdf";
                i++;
            }
            try
            {
                var document = new Document(PageSize.A4, 25, 25, 25, 25);
                if (!Directory.Exists(Path.GetDirectoryName(sGenerateFile)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(sGenerateFile));
                }
                PdfWriter.GetInstance(document, new FileStream(sGenerateFile, FileMode.Create));
                document.Open();
                foreach (var p in files)
                {
                    var image = iTextSharp.text.Image.GetInstance(p);
                    if (image.Height > PageSize.A4.Height - 25)
                    {
                        image.ScaleToFit(PageSize.A4.Width - 25, PageSize.A4.Height - 25);
                    }
                    else if (image.Width > PageSize.A4.Width - 25)
                    {
                        image.ScaleToFit(PageSize.A4.Width - 25, PageSize.A4.Height - 25);
                    }
                    image.Alignment = Element.ALIGN_MIDDLE;
                    document.NewPage();
                    document.Add(image);
                }
                document.Close();
            }
            catch (Exception e)
            {
                cpcOfficialFile.Note = e.ToString();
            }
            cpcOfficialFile.BizFilePath = sGenerateFile;
        }