public new string EServiceSetup(string officeData)
 {
     try {
         WebServiceMainHQProxy.EServiceSetup.SignupOut signupOut = new WebServiceMainHQProxy.EServiceSetup.SignupOut()
         {
             EServices                 = GetEServicesForAll(),
             HasClinics                = PrefC.HasClinicsEnabled,
             ListenerTypeInt           = (int)ListenerServiceType.ListenerServiceProxy,
             MethodNameInt             = (int)WebServiceMainHQProxy.EServiceSetup.SetupMethod.GetSignupOutFull,
             Phones                    = GetPhonesForAll(),
             Prompts                   = new List <string>(),
             SignupPortalPermissionInt = (int)SignupPortalPermission.FullPermission,
             SignupPortalUrl           = GetHostedUrlForCode(eServiceCode.SignupPortal),
         };
         //Write the response out as a plain string. We will deserialize it on the other side.
         return(WebSerializer.SerializePrimitive <string>(WebServiceMainHQProxy.WriteXml(signupOut)));
     }
     catch (Exception ex) {
         StringBuilder strbuild = new StringBuilder();
         using (XmlWriter writer = XmlWriter.Create(strbuild, WebServiceMainHQProxy.CreateXmlWriterSettings(true))) {
             writer.WriteStartElement("Response");
             writer.WriteStartElement("Error");
             writer.WriteString(ex.Message);
             writer.WriteEndElement();
             writer.WriteEndElement();
         }
         return(strbuild.ToString());
     }
 }
예제 #2
0
        public static string WriteXml <T>(T input)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T)); StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, WebServiceMainHQProxy.CreateXmlWriterSettings(true))) {
                writer.WriteStartElement(GetNodeNameFromType(typeof(T)));
                serializer.Serialize(writer, input);
                writer.WriteEndElement();
            }
            return(strbuild.ToString());
        }
예제 #3
0
        ///<summary>Creates an XML string for the payload of the provided content. Currently only useful if you have one thing to include in the payload.
        ///</summary>
        public static string CreatePayloadContent <T>(T content, string tagName)
        {
            System.Xml.Serialization.XmlSerializer xmlListConfirmationRequestSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T));
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, WebServiceMainHQProxy.CreateXmlWriterSettings(true))) {
                writer.WriteStartElement("Payload");
                writer.WriteStartElement(tagName);
                xmlListConfirmationRequestSerializer.Serialize(writer, content);
                writer.WriteEndElement();
                writer.WriteEndElement();                 //Payload
            }
            return(strbuild.ToString());
        }
예제 #4
0
        ///<summary>Surround with try/catch. Returns true if all messages succeded, throws exception if it failed.
        ///All Integrated Texting should use this method, CallFire texting does not use this method.</summary>
        public static bool SendSms(List <SmsToMobile> listMessages)
        {
            //No need to check RemotingRole; no call to db.
            if (Plugins.HookMethod(null, "SmsToMobiles.SendSms_start", listMessages))
            {
                return(true);
            }
            if (listMessages == null || listMessages.Count == 0)
            {
                throw new Exception("No messages to send.");
            }
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, WebServiceMainHQProxy.CreateXmlWriterSettings(true))){
                writer.WriteStartElement("Payload");
                writer.WriteStartElement("ListSmsToMobile");
                System.Xml.Serialization.XmlSerializer xmlListSmsToMobileSerializer = new System.Xml.Serialization.XmlSerializer(typeof(List <SmsToMobile>));
                xmlListSmsToMobileSerializer.Serialize(writer, listMessages);
                writer.WriteEndElement();                 //ListSmsToMobile
                writer.WriteEndElement();                 //Payload
            }
            string result = "";

            try {
                result = WebServiceMainHQProxy.GetWebServiceMainHQInstance()
                         .SmsSend(WebServiceMainHQProxy.CreateWebServiceHQPayload(strbuild.ToString(), eServiceCode.IntegratedTexting));
            }
            catch (Exception ex) {
                ex.DoNothing();
                throw new Exception("Unable to send using web service.");
            }
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(result);
            XmlNode node = doc.SelectSingleNode("//Error");

            if (node != null)
            {
                throw new Exception(node.InnerText);
            }
            node = doc.SelectSingleNode("//Success");
            if (node != null)
            {
                return(true);
            }
            //Should never happen, we didn't get an explicit fail or success
            throw new Exception("Unknown error has occured.");
        }
예제 #5
0
        ///<summary>Creates an XML string for the payload of the provided content. The list passed in is a tuple where the first item is the content to
        ///be serialized and the second item is the tag name for the content.</summary>
        public static string CreatePayloadContent(List <PayloadItem> listPayloadItems)
        {
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, WebServiceMainHQProxy.CreateXmlWriterSettings(true))) {
                writer.WriteStartElement("Payload");
                foreach (PayloadItem payLoadItem in listPayloadItems)
                {
                    XmlSerializer xmlListConfirmationRequestSerializer = new XmlSerializer(payLoadItem.Content.GetType());
                    writer.WriteStartElement(payLoadItem.TagName);
                    xmlListConfirmationRequestSerializer.Serialize(writer, payLoadItem.Content);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();                 //Payload
            }
            return(strbuild.ToString());
        }