Пример #1
0
/*
        private const String OK_RESULT = MailAdapter.OK_RESULT;
*/

        /// <summary>
        /// Initial the webservice API.
       /// </summary>
       /// <param name="client">client</param>
       /// <param name="userName">user name</param>
       /// <param name="password">password</param>
        public SubscribeAction(String client, String userName, String password, System.Net.WebProxy oWebProxy)
        {
            subscriptionService = new SubscriptionService();
            subscriptionAuthInfo = new cn.tripolis.dialogue.subscription.AuthInfo
                 {
                     client = client,
                     username = userName,
                     password = password
                 };
            subscriptionService.authInfo = subscriptionAuthInfo;
            subscriptionService.Proxy = oWebProxy;
        }
Пример #2
0
        /// <summary>
        /// Send single mail
        /// </summary>
        /// <param name="projectName">projectName</param>
        /// <param name="emailId">emailId</param>
        /// <param name="fromName">sender</param>
        /// <param name="emailFrom">emailFrom</param>
        /// <param name="emailTo">emailTo</param>
        /// <param name="emailSubject">emailSubject</param>
        /// <param name="emailBody">emailBody</param>
        /// <returns></returns>       

        private String sendSingleEmail_Old(String projectName, String emailId, String fromName, String emailFrom, String emailTo, String emailSubject, String emailBody)
        {
            logger.Debug("************send Single Mail***************");
            String result = OK_RESULT;
            try
            {
                if (String.IsNullOrEmpty(projectName))
                {
                    return "No project Name";
                }
                if (String.IsNullOrEmpty(emailId))
                {
                    return "No Email Id";
                }
                ContactDatabaseAction contactDatabaseAction = new ContactDatabaseAction(client, userName, password);
                String contactDatabaseId = contactDatabaseAction.createContactDatabase(projectName);

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

                ContactDatabaseFieldAction contactDatabaseFieldAction = new ContactDatabaseFieldAction(client, userName, password);
                Hashtable ht = contactDatabaseFieldAction.getContactDatabaseFields(contactDatabaseId);
                String toEmailFieldId; //Properties.Settings.Default.toEmailFieldId;// "MTExMzYxMTEfCGWCBaFKyA";
                if (ht[EMAIL] != null)
                {
                    toEmailFieldId = ht[EMAIL].ToString();
                }
                else
                {
                    return "Database:" + projectName + " is not exist";
                }
                const string pattern = "\\{.+?\\}";
                List<string> tempList = Regex.Matches(emailBody, pattern).Cast<Match>().Select(a => a.Value).ToList();
                foreach (string str in tempList)
                {
                    emailBody = emailBody.Replace(str, str.ToLower());
                }

                //查找<A的html标记,如果里面没有title属性,则增加这个属性.
                emailBody = Util.addTitleInAFlagHtml(emailBody);

                String sequence = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                ContactGroupAction contactGroupAction = new ContactGroupAction(client, userName, password);
                String contactGroupId = contactGroupAction.createContactGroup(contactDatabaseId, emailId, emailId);

                DirectEmailTypeAction directEmailTypeAction = new DirectEmailTypeAction(client, userName, password);
                String directEmailTypeId = directEmailTypeAction.createDirectEmailType(workspaceId, "IPSOS Email Type for " + projectName, "ipsos_mail_type_" + projectName, emailFrom, fromName, toEmailFieldId);

                DirectEmailAction directEmailAction = new DirectEmailAction(client, userName, password);
                String directEmailId = directEmailAction.createDirectEmail(directEmailTypeId, "IPSOS Mail" + sequence, "ipsos_mail" + sequence, emailSubject, "Send mail by IPSOS", fromName, emailFrom, emailBody);


                cn.tripolis.dialogue.subscription.SubscriptionService subscriptionService = new cn.tripolis.dialogue.subscription.SubscriptionService();
                cn.tripolis.dialogue.subscription.AuthInfo subscriptionAuthInfo = new cn.tripolis.dialogue.subscription.AuthInfo
                {
                    client = client,
                    username = userName,
                    password = password
                };
                subscriptionService.authInfo = subscriptionAuthInfo;
                cn.tripolis.dialogue.subscription.subscribeContactRequest request = new cn.tripolis.dialogue.subscription.subscribeContactRequest();
                request.contactDatabase = new cn.tripolis.dialogue.subscription.IdNameModel();
                request.contactDatabase.id = contactDatabaseId;
                request.workspace = new cn.tripolis.dialogue.subscription.IdNameModel();
                request.workspace.id = workspaceId;

                request.contactFields = new cn.tripolis.dialogue.subscription.ContactFieldValue[2];
                cn.tripolis.dialogue.subscription.ContactFieldValue contactFieldValue = new cn.tripolis.dialogue.subscription.ContactFieldValue();
                contactFieldValue.name = EMAIL;
                contactFieldValue.value = emailTo;
                request.contactFields.SetValue(contactFieldValue, 0);

                contactFieldValue = new cn.tripolis.dialogue.subscription.ContactFieldValue();
                contactFieldValue.name = EMAIL_ID;
                contactFieldValue.value = emailId;
                request.contactFields.SetValue(contactFieldValue, 1);

                request.directEmail = new cn.tripolis.dialogue.subscription.IdNameModel();
                request.directEmail.id = directEmailId;

                request.ip = "127.0.0.1";

                request.contactGroupSubscriptions = new cn.tripolis.dialogue.subscription.ContactGroupSubscription[1];
                cn.tripolis.dialogue.subscription.ContactGroupSubscription contactGroupSubscription = new cn.tripolis.dialogue.subscription.ContactGroupSubscription();
                contactGroupSubscription.confirmed = true;
                contactGroupSubscription.contactGroup = new cn.tripolis.dialogue.subscription.IdNameModel();
                contactGroupSubscription.contactGroup.id = contactGroupId;
                request.contactGroupSubscriptions.SetValue(contactGroupSubscription, 0);

                subscriptionService.subscribeContact(request);
                //result = response.id;
            }
            catch (Exception ex)
            {
                result = ex.Message;
                logger.Debug("error happen in send mail, error is " + result);
                // return ex.Message;

            }
            logger.Debug("************end sendMail ************");
            return result;
        }