Ejemplo n.º 1
0
        public async Task StartupAsync()
        {
            logger.Info("Starting...");

            DiscordClient = new DiscordClient(new DiscordConfiguration {
                Token         = Arguments[0],
                TokenType     = TokenType.Bot,
                AutoReconnect = true,
                Intents       = DiscordIntents.All
            });

            SetupCommands();

            DiscordClient.SocketErrored  += CommonEvents.SocketErrorEvent;
            DiscordClient.Ready          += CommonEvents.ReadyEvent;
            DiscordClient.UnknownEvent   += CommonEvents.UnknownEvent;
            DiscordClient.MessageCreated += MessageEvents.MessageCreatedEvent;
            DiscordClient.Resumed        += CommonEvents.ResumedEvent;
            DiscordClient.SocketClosed   += CommonEvents.SocketClosedEvent;
            SekiDiscord.Commands.NotifyEvent.NotifyEventManager.LoadAndEnableEvents();

            // Connect to Discord:
            await DiscordClient.ConnectAsync().ConfigureAwait(false);

            BotName = DiscordClient.CurrentUser.Username;

            CommonEvents.StartStatusTimer();

            await Update().ConfigureAwait(false);

            //Disconnect
            await DiscordClient.DisconnectAsync().ConfigureAwait(false);
        }
Ejemplo n.º 2
0
    private bool SendPasswordEmail()
    {
        bool result = false;

        try
        {
            // Creating HTML Mail from HTML Template.
            Hashtable templateVars = new Hashtable();

            templateVars.Add("FIRST_NAME", registrationInfo.FirstName);
            templateVars.Add("PASSWORD", registrationInfo.Password);
            templateVars.Add("URL", CommonEvents.GetDynamicPath(Request));

            Parser parser = new Parser(AppDomain.CurrentDomain.BaseDirectory + "\\HTMLTemplate\\Email_ForgotPassword.html",
                                       templateVars);

            // Creating Mail Message Body.
            MailMessage mailmsg = new MailMessage();

            mailmsg.To.Add(registrationInfo.Email);
            mailmsg.From       = new MailAddress("*****@*****.**");
            mailmsg.Subject    = "Your Mailing Cycle Account Password";
            mailmsg.IsBodyHtml = true;
            mailmsg.Body       = parser.Parse();
            mailmsg.Priority   = MailPriority.Normal;

            Configuration config =
                WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
            MailSettingsSectionGroup mailSettings =
                config.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;

            if (mailSettings != null)
            {
                int    port     = mailSettings.Smtp.Network.Port;
                string host     = mailSettings.Smtp.Network.Host;
                string password = mailSettings.Smtp.Network.Password;
                string username = mailSettings.Smtp.Network.UserName;

                SmtpClient smtpclient = new SmtpClient(host, 587);
                smtpclient.Credentials = new NetworkCredential(username, password);
                smtpclient.EnableSsl   = true;

                smtpclient.Send(mailmsg);
            }

            result = true;
        }
        catch (Exception ex)
        {
            PageDescriptionLabel.Text = "Failure sending email.";
            SuccessText.InnerHtml     = "Unable to reset your password due to failure in sending mail." +
                                        "<br /><br />Please try again or contact your system administrator.";

            log.Error("Unknown Error", ex);
        }

        return(result);
    }
Ejemplo n.º 3
0
    protected void SendRegistrationEmail(RegistrationService.RegistrationInfo registration)
    {
        bool   IsDevelopmentPC = true;
        string URLAddress      = "";

        try
        {
            URLAddress = CommonEvents.GetDynamicPath(Request);
            ///Creating HTML MAil from HTML Template
            Hashtable templateVars          = new Hashtable();
            String    emailTemplateFilePath = AppDomain.CurrentDomain.BaseDirectory + "\\HTMLTemplate\\Email_CreateAccount.html";
            templateVars.Add("FIRST_NAME", registration.FirstName);
            templateVars.Add("LAST_NAME", registration.LastName);
            templateVars.Add("USER_NAME", registration.UserName);
            templateVars.Add("PASSWORD", registration.Password);
            templateVars.Add("URL", URLAddress);
            templateVars.Add("IMAGE_PATH", AppDomain.CurrentDomain.BaseDirectory);
            Parser parser = new Parser(emailTemplateFilePath, templateVars);

            ServiceAccess serviceLoader           = ServiceAccess.GetInstance();
            CommonService.CommonService      cs   = serviceLoader.GetCommon();
            IList <CommonService.LookupInfo> info = cs.GetLookups("FeedBackEmailTo");
            string toAddress = info[1].Name;

            //Creating Mail Message Body
            MailMessage mailmsg = new MailMessage();
            mailmsg.To.Add(registration.Email);
            mailmsg.Bcc.Add("*****@*****.**");
            mailmsg.From       = new MailAddress("*****@*****.**");
            mailmsg.Subject    = "MailingCycle Registration Confirmation";
            mailmsg.IsBodyHtml = true;
            mailmsg.Body       = parser.Parse();
            mailmsg.Priority   = MailPriority.Normal;

            Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);

            MailSettingsSectionGroup mailSettings = config.GetSectionGroup("system.net/mailSettings") as MailSettingsSectionGroup;
            if (mailSettings != null)
            {
                int    port     = mailSettings.Smtp.Network.Port;
                string host     = mailSettings.Smtp.Network.Host;
                string password = mailSettings.Smtp.Network.Password;
                string username = mailSettings.Smtp.Network.UserName;

                SmtpClient smtpclient = new SmtpClient(host, 587);
                smtpclient.Credentials = new NetworkCredential(username, password);
                smtpclient.EnableSsl   = true;
                smtpclient.Send(mailmsg);
            }
        }
        catch (Exception ex)
        {
            log.Error("User Registration Email Sending Failed", ex);
            ErrorLiteral.Text = "User registration Successful. But Confirmation email could not be sent !!! ";
        }
    }
Ejemplo n.º 4
0
    private void SendACCAMail(AccaInfo[] allACCAInfo)
    {
        List <AccaInfo> successInfo = new List <AccaInfo>();
        List <AccaInfo> failureInfo = new List <AccaInfo>();

        foreach (AccaInfo accaInfo in allACCAInfo)
        {
            if (accaInfo.EventStatus != ScheduleEventStatus.InProgress)
            {
                bool isfEvent = false;
                foreach (AccaInfo fInfo in failureInfo)
                {
                    if (fInfo.EventId == accaInfo.EventId)
                    {
                        isfEvent = true;
                        break;
                    }
                }
                if (!isfEvent)
                {
                    failureInfo.Add(accaInfo);
                }
            }
            else
            {
                bool issEvent = false;
                foreach (AccaInfo fInfo in successInfo)
                {
                    if (fInfo.EventId == accaInfo.EventId)
                    {
                        issEvent = true;
                        break;
                    }
                }
                if (!issEvent)
                {
                    successInfo.Add(accaInfo);
                }
            }
        }
        Hashtable templateVars = new Hashtable();
        string    URLAddress   = CommonEvents.GetDynamicPath(Request);

        templateVars.Add("URL", URLAddress);
        String emailTemplateFilePath = AppDomain.CurrentDomain.BaseDirectory + "\\HTMLTemplate\\Email_AccaCompleted.html";
        Parser parser = new Parser(emailTemplateFilePath, templateVars);
        int    index  = parser.TemplateBlock.IndexOf("<!-- for inserting here-->");

        AssignTemplateBlock(successInfo, parser, index);
        index = parser.TemplateBlock.IndexOf("<!-- for inserting cancelled here-->");
        AssignTemplateBlock(failureInfo, parser, index);
        SendEmail(parser.Parse());
    }
Ejemplo n.º 5
0
 public ItemDal(CommonEvents commonEvents)
 {
     _commonEvents = commonEvents;
 }