Exemple #1
0
        private void SendCatalogRequest()
        {
            try
            {
                // Delete all previous content requests
                FoeClientRequest.DeleteOldRequest(_requestInterval);

                // Create Foe Message
                string requestId = FoeClientRequest.GenerateId();

                FoeClientMessage.SendMessage(
                    FoeClientMessage.GetSmtpServer(),
                    FoeClientRegistry.GetEntry("useremail").Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Catalog, requestId, FoeClientRegistry.GetEntry("userid").Value),
                    "");

                // save requestid to DB
                FoeClientRequestItem reqItem = new FoeClientRequestItem();
                reqItem.Id          = requestId;
                reqItem.Type        = "catalog";
                reqItem.DtRequested = DateTime.Now;
                FoeClientRequest.Add(reqItem);

                // remember when the request was sent
                _lastRequestSent = DateTime.Now;
                // Set status
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested catalog.";
            }
            catch (Exception)
            {
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request.";
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            FoeDebug.Print("Creating Foe Message content.");
            string catalog = "VOAENGLISH";

            FoeDebug.Print("Generating a random request ID.");
            string requestId = RandomString.Generate(10);

            FoeDebug.Print("Setting up SMTP configuration.");
            SmtpServer server = new SmtpServer();

            server.ServerName   = "smtp.gmail.com";
            server.Port         = 587;
            server.AuthRequired = true;
            server.SslEnabled   = true;
            server.UserName     = "******";
            server.Password     = "******";

            FoeDebug.Print("Sending content request message.");
            string subject = SubjectGenerator.RequestSubject(RequestType.Content, requestId, _userId);

            MessageManager.SendMessage(
                server,
                _userEmail,
                _processorEmail,
                subject,
                catalog);
        }
Exemple #3
0
        public static void SendRegistration()
        {
            // Check if user's email is available
            FoeClientRegistryEntry email = FoeClientRegistry.GetEntry("useremail");

            if ((email == null) || (email.Value == null) || (email.Value.Length < 3))
            {
                // Invalid user email
                return;
            }

            // Prepare message to send to server
            FoeMessage message = new FoeMessage();

            message.Add(new FoeMessageItem("UserEmail", email.Value));

            // Get SMTP server configurations
            SmtpServer server = null;

            try
            {
                server = FoeClientMessage.GetSmtpServer();
            }
            catch (Exception except)
            {
                throw new Exception("Invalid SMTP configurations.\r\n" + except.ToString());
            }

            // Send email
            try
            {
                string requestId = FoeClientRequest.GenerateId();
                FoeClientMessage.SendMessage(
                    server,
                    email.Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Registration, requestId, "Newbie"),
                    message);

                // Save request info
                FoeClientRequestItem req = new FoeClientRequestItem();
                req.Id          = requestId;
                req.Type        = "reg";
                req.DtRequested = DateTime.Now;
                FoeClientRequest.Add(req);
            }
            catch (Exception except)
            {
                throw new Exception("Error sending message.\r\n" + except.ToString());
            }
        }
Exemple #4
0
        private void SendSubscriptionRequest()
        {
            try
            {
                // Delete all previous content requests
                FoeClientRequest.DeleteOldRequest(_requestInterval);

                // Create Foe Message
                string catalogs = "";
                List <FoeClientCatalogItem> catalog = FoeClientCatalog.GetAll();
                if (catalog.Count == 0)
                {
                    return;
                }
                foreach (FoeClientCatalogItem item in catalog)
                {
                    if (item.IsSubscribed)
                    {
                        catalogs += item.Code + ",";
                    }
                }
                string requestId = FoeClientRequest.GenerateId();

                FoeClientMessage.SendMessage(
                    FoeClientMessage.GetSmtpServer(),
                    FoeClientRegistry.GetEntry("useremail").Value,
                    FoeClientRegistry.GetEntry("processoremail").Value,
                    SubjectGenerator.RequestSubject(RequestType.Content, requestId, FoeClientRegistry.GetEntry("userid").Value),
                    catalogs);

                // save requestid to DB
                FoeClientRequestItem reqItem = new FoeClientRequestItem();
                reqItem.Id          = requestId;
                reqItem.Type        = "content";
                reqItem.DtRequested = DateTime.Now;
                FoeClientRequest.Add(reqItem);

                // remember when the request was sent
                _lastRequestSent = DateTime.Now;
                // Set status
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " requested update.";
            }
            catch (Exception)
            {
                tssStatus.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " error sending request.";
            }
        }
        static void Main(string[] args)
        {
            FoeDebug.Print("Generating a random request ID.");
            string requestId = RandomString.Generate(10);

            FoeDebug.Print("Setting up SMTP configuration.");
            SmtpServer server = new SmtpServer();

            server.ServerName   = "doraemon";
            server.Port         = 25;
            server.AuthRequired = true;
            server.SslEnabled   = false;
            server.UserName     = "******";
            server.Password     = "******";

            FoeDebug.Print("Sending registration message.");
            MessageManager.SendMessage(
                server,
                _userEmail,
                _processorEmail,
                SubjectGenerator.RequestSubject(RequestType.Registration, requestId, "Newbie"),
                "");
        }