Ejemplo n.º 1
0
        /// <summary>
        /// Create contact group
        /// </summary>
        /// <param name="contactDatabaseId">contact database id</param>
        /// <param name="groupLable">contact group lable</param>
        /// <param name="groupName">contact group name</param>
        /// <returns>contact group id</returns>
        public String createContactGroup(String contactDatabaseId, String groupLable, String groupName)
        {
            ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);

            return contactGroupAction.createContactGroup(contactDatabaseId, groupLable, groupName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// publish Small Scale email,, mail quantity <50,000
        /// </summary>
        /// <param name="dialogueSetting">Dialogue setting, such as database Id, workspaceId</param>
        /// <param name="contactGroup">Contact Group information</param>
        /// <param name="contacts">Contact Information</param>
        /// <param name="directEmail">parameters related with direct email, such as subject, fromaddress</param>
        /// <returns></returns>
        public String publishingSmallScaleEmail(DialogueSetting dialogueSetting, ContactGroup contactGroup, ContactFileInfo importFiles, DirectEmail directEmail)
        {

            logger.Debug(System.Environment.NewLine+"Begin sending Small Scale Email.");
            String result = "OK";
            try
            {
                String contactDatabaseId = dialogueSetting.contactDatabaseId;
                String workspaceId = dialogueSetting.workspaceId;
                String emailTypeId = dialogueSetting.emailTypeId;
                //String directEmailId = dialogueSetting.directEmailId;

                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);
                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, contactGroup.groupLabel, contactGroup.groupName);

                String importId = this.importContact(contactDatabaseId, contactGroupId, directEmail.reportReceiveAddress, importFiles);              

                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(emailTypeId, directEmail.emailLabel, directEmail.emailName, directEmail.subject, directEmail.description, directEmail.fromName, directEmail.fromAddress, directEmail.htmlContent);


                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);
                result = publishId;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
                // return ex.Message;

            }
            logger.Debug("Finish sending Small Scale Email. Publish Id is " + result);
            return result;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// publish Small Scale email, mail quantity >=50,000
        /// </summary>
        /// <param name="dialogueSetting">Dialogue setting, such as database Id, workspaceId</param>
        /// <param name="contactGroup">Contact Group information</param>
        /// <param name="contacts">Contact Information</param>
        /// <param name="directEmail">parameters related with direct email, such as subject, fromaddress</param>
        /// <returns></returns>
        public String publishingBulkEmail(DialogueSetting dialogueSetting, ContactGroup contactGroup, String fileName, DirectEmail directEmail)
        {

            logger.Debug(System.Environment.NewLine+"Begin sending Bulk Scale Email.");
            String result = "OK";
            try
            {
                String contactDatabaseId = dialogueSetting.contactDatabaseId;
                String workspaceId = dialogueSetting.workspaceId;
                String emailTypeId = dialogueSetting.emailTypeId;
              //  String directEmailId = "";

                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);
                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, contactGroup.groupLabel, contactGroup.groupName);

                DateTime scheduleAt = DateTime.Now;
                ImportContactAction importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                String importId = importContactAction.importContactFromFTP(contactDatabaseId, contactGroupId, fileName, directEmail.reportReceiveAddress, dialogueSetting.ftpAccountId, scheduleAt);
                Thread.Sleep(5 * 1000);
                while (true)
                {
                    importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                    importStatus status = importContactAction.getImportStatus(importId);

                    if (status.Equals(importStatus.ENDED))
                    {
                        logger.InfoFormat("import contact File " + fileName + " successfully");
                        break;
                    }
                    if (status.Equals(importStatus.STOPPED) || status.Equals(importStatus.ABORTED))
                    {
                        logger.InfoFormat("fail to import contact File " + fileName  + " as import status is " + status.ToString());
                        // throw new Exception("fail to import contact File " + fileName + " for transid " + transId + " as import status is " + status.ToString());
                        return "";
                        //break;
                    }
                    logger.InfoFormat("Checking the import status, and current import status is " + status.ToString() );
                    Thread.Sleep(60 * 1000);
                }
                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(emailTypeId, directEmail.emailLabel, directEmail.emailName, directEmail.subject, directEmail.description, directEmail.fromName, directEmail.fromAddress, directEmail.htmlContent);


                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);
                result = publishId;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in sending Small Scale mail, error is " + result);
                // return ex.Message;

            }
            logger.Debug("Finish sending Small Scale Email. Publish Id is " + result);
            return result;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// send batch mail
        /// </summary>
        /// <param name="databaseName">databaseName</param>
        /// <param name="mailData">mailData</param>
        /// <returns></returns>
        public String sendBatchMail(String databaseName, MailData mailData)
        {
            logger.Debug("************send Batch Mail***************");
            String result = OK_RESULT;
            try
            {
                if (String.IsNullOrEmpty(databaseName))
                {
                    return "No database Name";
                }
                if (mailData == null || mailData.ContactJsonList == null || mailData.ContactJsonList.Count <= 0)
                {
                    return "No Contact";
                }
                ContactDatabaseAction contactDatabaseAction = new ContactDatabaseAction(client, userName, password, oWebProxy);
                String contactDatabaseId = contactDatabaseAction.createContactDatabase(databaseName);


                WorkspaceAction workspaceAction = new WorkspaceAction(client, userName, password, oWebProxy);
                String workspaceId = workspaceAction.createWorkspace(contactDatabaseId, databaseName);

                ContactDatabaseFieldAction contactDatabaseFieldAction = new ContactDatabaseFieldAction(client, userName, password, oWebProxy);
                Hashtable ht = contactDatabaseFieldAction.getContactDatabaseFields(contactDatabaseId);

                String toEmailFieldId; //Properties.Settings.Default.toEmailFieldId;// "MTExMzYxMTEfCGWCBaFKyA";
                if (ht[EMAIL] != null)
                {
                    toEmailFieldId = ht[EMAIL].ToString();
                }
                else
                {
                    return "Database:" + databaseName + " is not exist";
                }

                const string pattern = "\\{.+?\\}";
                List<string> tempList = Regex.Matches(mailData.mailBody, pattern).Cast<Match>().Select(a => a.Value).ToList();
                foreach (string str in tempList)
                {
                    mailData.mailBody = mailData.mailBody.Replace(str, str.ToLower());
                }
                //查找<A的html标记,如果里面没有title属性,则增加这个属性.
                mailData.mailBody = Util.addTitleInAFlagHtml(mailData.mailBody);


                String sequence = DateTime.Now.ToString("yyyyMMddhhmmss");
                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);

                // ContactGroup[] temp = contactGroupAction.getContactGroup(contactDatabaseId);

                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, "Mail Group" + sequence, "mail_group" + sequence);

                this.importContact(contactDatabaseId, contactGroupId, mailData);

                DirectEmailTypeAction directEmailTypeAction = new DirectEmailTypeAction(client, userName, password, oWebProxy);
                String directEmailTypeId = directEmailTypeAction.createDirectEmailType(workspaceId, "Email Type for" + databaseName, "mail_type_" + databaseName, mailData.fromAddress, mailData.sender, toEmailFieldId);

                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password, oWebProxy);
                String directEmailId = directEmailAction.createDirectEmail(directEmailTypeId, "Mail" + sequence, "mail" + sequence, mailData.subject, "Send mail", mailData.sender, mailData.fromAddress, mailData.mailBody);

                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, DateTime.Now);

                logger.Debug("publishId=" + publishId);

            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in send mail, error is " + result);

            }
            logger.Debug("************end sendMail ************");
            return result;
        }
Ejemplo n.º 5
0
        public String  importContact(String transId, String fileName, String contactDatabaseId,String reportReceiverAddress, String ftpAccountId)
        {
            logger.InfoFormat("***********Begin importing contact File " + fileName + " for transid " + transId+"***********");
           
            String strDate = DateTime.Now.ToString("yyyyMMdd");
            String groupName = strDate + "_" + transId;
           
            //Create Group             
            ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);
            String groupId = contactGroupAction.createContactGroup(contactDatabaseId, groupName, groupName);
            logger.InfoFormat("Create Group " + groupName + " successfully");

          
            DateTime scheduleAt = DateTime.Now;
            ImportContactAction importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
            String importId = importContactAction.importContactFromFTP(contactDatabaseId, groupId, fileName, reportReceiverAddress, ftpAccountId, scheduleAt);
            Thread.Sleep(5 * 1000);
            while (true)
            {
                importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                importStatus status = importContactAction.getImportStatus(importId);

                if (status.Equals(importStatus.ENDED))
                {
                    logger.InfoFormat("import contact File " + fileName + " for transid" + transId + " successfully");
                    break;
                }
                if (status.Equals(importStatus.STOPPED) || status.Equals(importStatus.ABORTED))
                {
                    logger.InfoFormat("fail to import contact File " + fileName + " for transid " + transId + " as import status is " + status.ToString());
                   // throw new Exception("fail to import contact File " + fileName + " for transid " + transId + " as import status is " + status.ToString());
                    return "";
                    //break;
                }
                logger.InfoFormat("Checking the import status, and current import status is " + status.ToString() + " for transid " + transId);
                Thread.Sleep(60 * 1000);
            }
            return groupId;

        }
Ejemplo n.º 6
0
        /// <summary>
        /// send batch mail
        /// </summary>
        /// <param name="databaseName">databaseName</param>
        /// <param name="mailData">mailData</param>
        /// <returns></returns>
        public String sendBatchMail(String contactDatabaseId,String workspaceId, String directEmailId,MailData mailData, DateTime scheduleAt)
        {
            logger.Debug("************send Batch Mail***************");
            String result = OK_RESULT;
            try
            {
                if (String.IsNullOrEmpty(contactDatabaseId))
                {
                    return "No database ";
                }
                if (mailData == null || mailData.ContactJsonList == null || mailData.ContactJsonList.Count <= 0)
                {
                    return "No Contact";
                }     

                //const string pattern = "\\{.+?\\}";
                //List<string> tempList = Regex.Matches(mailData.mailBody, pattern).Cast<Match>().Select(a => a.Value).ToList();
                //foreach (string str in tempList)
                //{
                //    mailData.mailBody = mailData.mailBody.Replace(str, str.ToLower());
                //}
                ////查找<A的html标记,如果里面没有title属性,则增加这个属性.
                //mailData.mailBody = Util.addTitleInAFlagHtml(mailData.mailBody);


                String sequence = DateTime.Now.ToString("yyyyMMddhhmmss");
                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password, oWebProxy);               

                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, "月度佣金" + sequence, "monthly_fee" + sequence);

                String importId= this.importContact(contactDatabaseId, contactGroupId, mailData);

                Thread.Sleep(5 * 1000);
                while (true)
                {
                    ImportContactAction importContactAction = new ImportContactAction(client, userName, password, oWebProxy);
                    importStatus status = importContactAction.getImportStatus(importId);

                    if (status.Equals(importStatus.ENDED))
                    {
                        logger.InfoFormat("import contact File  successfully");
                        break;
                    }
                    if (status.Equals(importStatus.STOPPED) || status.Equals(importStatus.ABORTED))
                    {
                        logger.InfoFormat("fail to import contact File  as import status is " + status.ToString());
                         throw new Exception("fail to import contact File  as import status is " + status.ToString());
                      
                        //break;
                    }
                    logger.InfoFormat("Checking the import status, and current import status is " + status.ToString() );
                    Thread.Sleep(5 * 1000);
                }

              
                PublishingAction publishingAction = new PublishingAction(client, userName, password, oWebProxy);
                String publishId = publishingAction.publishingEmail(contactGroupId, directEmailId, scheduleAt);

                logger.Debug("publishId=" + publishId);
                result = "OK:"+publishId;

            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in send mail, error is " + result);
            }
            logger.Debug("************end sendMail ************");
            return result;
        }