using framework_library; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Activation; using System.ServiceModel.Web; using System.Text; using System.Web.Hosting; using System.Web.Services.Protocols; using System.Xml; [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class framework_service : Iframework_service { /// /// Private Method to raise a soap exception /// /// /// /// /// /// /// /// SoapException private SoapException RaiseException(string uri, string webServiceNamespace, string errorMessage, string errorNumber, string errorSource, string specificFaultCode) { XmlQualifiedName faultCodeLocation = null; //Create fault code that is specific to the Application exception. faultCodeLocation = new XmlQualifiedName(specificFaultCode, "http://service.evolutionsoftware.co.za/"); XmlDocument xmlDoc = new XmlDocument(); //Create the Detail node. XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace); //Build specific details for the SoapException. //Add the first child of the detail XML element. XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error", uri); //Create and then set the value for the ErrorNumber node. XmlNode errorNumberNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber", uri); errorNumberNode.InnerText = errorNumber; //Create and then set the value for the ErrorMessage node. XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorMessage", uri); errorMessageNode.InnerText = errorMessage; //Create and then set the value for the ErrorSource node. XmlNode errorSourceNode = xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource", uri); errorSourceNode.InnerText = errorSource; //Append the Error child element nodes to the root detail node. errorNode.AppendChild(errorNumberNode); errorNode.AppendChild(errorMessageNode); errorNode.AppendChild(errorSourceNode); //Append the Detail node to the root node. rootNode.AppendChild(errorNode); //Construct the exception. SoapException soapEx = new SoapException(errorMessage, faultCodeLocation, uri, rootNode); //Raise the exception back to the caller. return soapEx; } /// /// byte Array to Process an Interaction /// /// /// /// /// /// /// public byte[] ProcessInteraction(byte[] interactionData, string connectionKey, bool isTransactional, string tablePrefix, bool isCollection) { byte[] result; try { dynamicInteraction dynaInteract = new dynamicInteraction(); result = dynaInteract.ProcessInteraction(interactionData, connectionKey, isTransactional, tablePrefix, isCollection); } catch (Exception ex) { throw RaiseException("http://service.evolutionsoftware.co.za", "http://service.evolutionsoftware.co.za/", ex.Message, "0", MethodBase.GetCurrentMethod().Name, ex.Source); } return result; } /// /// Byte Array to get a version /// /// /// /// /// /// public byte[] GetVersion(string customerCode, string licenceKey, string versionNo, string file) { byte[] result = null; Stream fs = new MemoryStream(); string path = String.Empty; try { result = xService.GetVersion(customerCode, licenceKey, versionNo, file); } catch (Exception ex) { throw RaiseException("http://service.evolutionsoftware.co.za", "http://service.evolutionsoftware.co.za/", ex.Message, "0", MethodBase.GetCurrentMethod().Name, ex.Source); } return result; } /// /// Save Version /// /// /// /// /// public bool SaveVersion(byte[] versionData, string versionNo, string file) { bool result = false; try { result = xService.SaveVersion(versionData, versionNo, file); } catch (Exception ex) { throw RaiseException("http://service.evolutionsoftware.co.za", "http://service.evolutionsoftware.co.za/", ex.Message, "0", MethodBase.GetCurrentMethod().Name, ex.Source); } return result; } }