//only got the path: 1. search for file, if none found create new.
        public MainWindowViewModel FromDirectory(string path)
        {
            ConfigHost.workingDirectory   = path;
            ConfigHost.workingProjectFile = ""; //mark empty to begin with.

            foreach (string file in Directory.GetFiles(path + "/"))
            {
                if (file.EndsWith(".disgui")) //this is a disgui file.
                {
                    ConfigHost.workingProjectFile = file;
                    break;
                }
            }

            //no file could be found, create a new one
            if (string.IsNullOrEmpty(ConfigHost.workingProjectFile))
            {
                ConfigHost.workingProjectFile = ConfigHost.CreateNewIn(path);
            }
            else
            {
                ConfigHost.Reload(ConfigHost.workingProjectFile);
            }

            return(this);
        }
 //existing file, initialize.
 public MainWindowViewModel FromFile(string filePath)
 {
     ConfigHost.workingProjectFile = filePath;
     ConfigHost.workingDirectory   = System.IO.Path.GetDirectoryName(filePath);
     ConfigHost.Reload(filePath);
     return(this);
 }
Esempio n. 3
0
 public void CreateHost(ConfigHost host)
 {
     Host = new SMTP_Client();
     Host.Connect(host.Server, host.Port, host.EnableSsl);
     Host.EhloHelo(host.Server);
     Host.Auth(Host.AuthGetStrongestMethod(host.Username, host.Password));
 }
Esempio n. 4
0
 public void CreateHost(ConfigHost host)
 {
     if (host.EnableSsl)
     {
         this.host = new SmtpClient(host.Server);
         this.host.UseDefaultCredentials = true;
         this.host.EnableSsl             = host.EnableSsl;
     }
     else
     {
         this.host = new SmtpClient(host.Server, host.Port);
         this.host.UseDefaultCredentials = false;
         this.host.EnableSsl             = host.EnableSsl;
         this.host.Credentials           = new System.Net.NetworkCredential(host.Username, host.Password);
     }
 }
Esempio n. 5
0
        private static void SendEmail()
        {
            string ciphertext = "Ll8OtEc/+uh5wySpAkur6e7MQ/ZtdbFNY8xsUu/7fY3if11Yuy6wH0Veg5MZJL5T6b1hFDKX0w+uSzGYkU0r/w2dG+hsNKaGaVufoCis9s38RNkShrmGCrz+8Se2pBw/Wh6Q3rf53S2bhYKS915fcRHR94LeM9kLMCglLHg/iN4=";
            string style      = "<span style='color:red;font-size:36px; '>{0}</span>";
            //style = "<p style=\"font-size: 10pt\">{0} 以下内容为系统自动发送,请勿直接回复,谢谢。</p><table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" bgcolor=\"000000\" style=\"font-size: 10pt;line-height: 15px;\">";
            var h1 = new ConfigHost()
            {
                Server    = "smtp.163.com",
                Port      = 25,
                Username  = "******",
                Password  = EncryptionControll.DecipherRSA(ciphertext),
                EnableSsl = false
            };
            var m1 = new ConfigMail()
            {
                Subject = "Test",
                Body    = string.Format(style, "你好!"),
                From    = "*****@*****.**",
                To      = new string[] { "*****@*****.**" },
            };

            var agents = new List <IEMailBase>()
            {
                new EMailBase()
            };

            foreach (var agent in agents)
            {
                var output = "Send m1 via h1 " + agent.GetType().Name + " ";
                Console.WriteLine(output + "start");
                try
                {
                    agent.CreateHost(h1);
                    m1.Subject = output;
                    agent.CreateMail(m1);
                    agent.SendMail();
                    Console.WriteLine(output + "success");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Console.WriteLine(output + "end");
                Console.WriteLine("-----------------------------------");
            }
            Console.Read();
        }
 public MainWindowViewModel()
 {
     ConfigHost.Empty();
     ConfigView = new ConfigViewModel();
 }
Esempio n. 7
0
        public static void _main()
        {
            var h2 = new ConfigHost()
            {
                Server    = "smtp.qq.com",
                Port      = 25,
                Username  = "******",
                Password  = "******",
                EnableSsl = false
            };
            var eventNo          = "xxx";
            var sDate            = "";
            var sTime            = "";
            var sStatu           = "";
            var checkType        = "";
            var oiRestaurantName = "";
            var oiLocation       = "";
            var province         = "";
            var city             = "";
            var oiConName        = "";
            var oiConPhone       = "";
            var oiExecuteName    = "";
            var body             = $"<p>您好!</p><p>以下是Bayer Opera编号<span style='background:#FFFF00'>{eventNo}</span>的活动最新信息,";

            body += "请在执行审核前确认以下<span style='text-decoration:underline'>红色变更信息</span>,如无法执行,请即刻反馈项目负责人,谢谢。</p>";
            body += "<div>活动基本信息:</div>";
            body += $"<div>Opera编号:{eventNo}</div>";
            body += $"<div>活动日期:{sDate}</div>";
            body += $"<div>活动时间:{sTime}</div>";
            body += $"<div>活动状态:{sStatu}</div>";
            body += $"<div>审核形式:{checkType}</div>";
            body += $"<div>餐厅名:{oiRestaurantName}</div>";
            body += $"<div>餐厅地址:{province} / {city} / {oiLocation}</div>";
            body += $"<div>活动申请人:{oiConName} / {oiConPhone}</div>";
            body += $"<div>HDBC执行人员:{oiExecuteName}</div>";
            body += "<p></p>";
            body += "<p></p>";
            body += "<p><span style='font-weight:600;font-size:13px'>Classification: </span><span style='font-weight:600;color:#004F71;font-size:13px'>Internal Use Only</span></p>";
            body += "<img src='cid:" + Convert.ToBase64String(Encoding.Default.GetBytes("2.jpg")) + "' alt=''/>";
            var m2 = new ConfigMail()
            {
                Body        = body,
                From        = "*****@*****.**",
                To          = new string[] { "*****@*****.**" },
                Attachments = new string[] { },
                Resources   = new string[] { "C:\\Users\\cspactera\\Pictures\\2.jpg" }
            };

            var agent = new NetMail();

            Console.WriteLine("start");
            try
            {
                agent.CreateHost(h2);
                m2.Subject = $"<活动变更提醒> Bayer Opera编号{eventNo}, " + DateTime.Now.ToString("MM/dd HH:mm");
                agent.CreateMultiMail(m2);
                agent.SendMail();

                Console.WriteLine("success");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.InnerException?.Message);
            }

            Console.WriteLine("end");
        }