public bool GetSubscriptionStatus(string email, int domainID) { CommuniGatorService.AuthHeader header = null; CommuniGatorService.SDKSoapClient client = GetClient(domainID, out header); if (client == null) { return(false); } try { string result = (string)client.ReturnContactRecord(header, email); if (String.IsNullOrEmpty(result)) { return(false); } XmlDocument document = new XmlDocument(); document.LoadXml(result); var elements = document.GetElementsByTagName("id"); return(elements != null && elements.Count > 0 ? true : false); } catch (Exception e) { Log.Error("CommuniGator Status Exception", e); } return(false); }
private CommuniGatorService.SDKSoapClient GetClient(int domainID, out CommuniGatorService.AuthHeader header) { tbl_Domains domain = DomainsRepository.GetByID(domainID); if (domain == null || !domain.DO_EnableCommuniGator) { header = null; return(null); } header = new CommuniGatorService.AuthHeader(); header.Password = domain.DO_CommuniGatorPassword; header.Username = domain.DO_CommuniGatorUserName; try { CommuniGatorService.SDKSoapClient client = new CommuniGatorService.SDKSoapClient(); var result = client.AuthenticationCheck(header); if (!String.IsNullOrEmpty(result) && result.Equals("Success")) { return(client); } else { return(null); } } catch (Exception e) { Log.Error("CommuniGator Client Exception", e); } return(null); }
public bool Subscribe(string email, int domainID) { CommuniGatorService.AuthHeader header = null; CommuniGatorService.SDKSoapClient client = GetClient(domainID, out header); if (client == null) { return(false); } var userService = (IUser)DependencyResolver.Current.GetService(typeof(IUser)); var customer = userService.GetCustomerByEmail(email, domainID); string contactXML = "<?xml version=\"1.0\"?>" + (customer != null ? CreateContactXML(email, customer.CU_FirstName, customer.CU_Surname) : CreateContactXML(email, String.Empty, String.Empty)); try { var result = client.UpdateContact(header, contactXML); return(!String.IsNullOrEmpty(result) && !result.StartsWith("Error Message") && result != "0" ? true : false); } catch (Exception e) { Log.Error("CommuniGator Subscribe Exception", e); } return(false); }