public XmlDocument CreateBuyerRole(string GUID, string requestXML) { string methodName = "CreateBuyerRole"; XmlWriter xmlWriter = null; StringWriter strWriter = null; XmlDocument xmlResponse = new XmlDocument(); XmlDocument xmlInput = null; string errMsg = ""; try { Startup(); m_connectorInc.Init_ResponseXML(methodName, ref strWriter, ref xmlWriter); if (!m_authInc.Is_Valid_GUID(GUID)) { m_logger.WriteError(m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_GUID, m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName), false); } else if (!m_connectorInc.ConvertStringToXML(requestXML, ref xmlInput)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXML")); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXML"), false); } else if (!m_connectorInc.IsValidXmlDocument("BuyerRoleData.xsd", xmlInput, out errMsg)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXML", "BuyerRoleData.xsd: " + errMsg)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXML", "BuyerRoleData.xsd: " + errMsg), false); } else { var buyerRole = ParseBuyerRoleDetails(xmlInput); var response = m_buyerRole.CreateBuyerRole(buyerRole); CMS.CMSException.StatusCodes statusCode = CMS.CMSException.StatusCodes.GENERAL_ERROR; if (response.ResultType.CompareTo(AMSResultType.Success) == 0) { statusCode = CMS.CMSException.StatusCodes.SUCCESS; xmlWriter.WriteStartElement("Buyer"); xmlWriter.WriteElementString("ID", Convert.ToString(response.Result)); xmlWriter.WriteEndElement(); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, statusCode, response.MessageString, true); } else { m_logger.WriteError(response.MessageString); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, statusCode, response.MessageString, false); } } } catch (Exception ex) { m_logger.WriteError("Failed to create Buyer roler- please see the error log!"); m_errHandler.ProcessError(ex); ProcessException(ex, methodName, ref xmlWriter, ref strWriter); } CloseResponseXml(ref xmlWriter, ref strWriter, ref xmlResponse); Shutdown(); return(xmlResponse); }
public XmlDocument CreateCoupons(string GUID, string requestXml) { const string methodName = "CreateCoupons"; XmlWriter xmlWriter = null; StringWriter strWriter = null; var xmlResponse = new XmlDocument(); XmlDocument xmlInput = null; string errMsg = ""; try { Startup(); m_connectorInc.Init_ResponseXML(ref strWriter, ref xmlWriter); if (!m_authInc.Is_Valid_GUID(GUID)) { m_logger.WriteError(m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_GUID, m_phraseLib.Detokenize("term.guidnotvalid", GUID, m_common.Get_AppInfo().AppName), false); } else if (!m_connectorInc.ConvertStringToXML(requestXml, ref xmlInput)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXml")); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidparameterxmldocument", "requestXml"), false); } else if (!m_connectorInc.IsValidXmlDocument("TrackableCouponsExternalCreateCouponsRequest.xsd", xmlInput, out errMsg)) { m_logger.WriteError(m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXml", "TrackableCouponsExternalCreateCouponsRequest.xsd: " + errMsg)); m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMS.CMSException.StatusCodes.INVALID_XML_DOCUMENT, m_phraseLib.Detokenize("term.invalidxmlconformxsd", "requestXml", "TrackableCouponsExternalCreateCouponsRequest.xsd: " + errMsg), false); } else { var couponList = ConvertXmlToCreateCouponListRequest(requestXml, "Coupon"); if (RequestItemsAreUnderCap(xmlWriter, methodName, m_CreateCap, couponList.Count)) { var response = m_trackableCoupon.AddTrackableCouponsExternal(couponList); new XmlSerializer(response.Result.GetType(), new XmlRootAttribute(methodName)).Serialize(xmlWriter, response.Result); } } } catch (Exception ex) { //MsgOut.PrintLine(ex.StackTrace); ProcessException(ex, methodName, xmlWriter, strWriter); } CloseResponseXml(xmlWriter, strWriter, xmlResponse); Shutdown(); return(xmlResponse); }
public XmlDocument QueryCoupon(string requestXml) { const string methodName = "QueryCoupon"; XmlWriter xmlWriter = null; StringWriter strWriter = null; var xmlResponse = new XmlDocument(); XmlDocument xmlInput = null; try { Startup(); m_connectorInc.Init_ResponseXML(ref strWriter, ref xmlWriter); if (IsValidXmlInput(xmlInput, xmlWriter, methodName, requestXml)) { var request = m_connectorInc.ConvertXmlToList(requestXml, "Code"); var response = m_trackableCoupon.QueryCoupon(request); XmlSerializerCache.Create(response.Result.GetType(), new XmlRootAttribute(methodName)).Serialize(xmlWriter, response.Result); //m_connectorInc.Generate_Status_XML(ref xmlWriter, methodName, CMSException.StatusCodes.SUCCESS, m_phraseLib.Lookup("term.success"), true); } } catch (Exception ex) { ProcessException(ex, methodName, xmlWriter, strWriter); } CloseResponseXml(xmlWriter, strWriter, xmlResponse); Shutdown(); return(xmlResponse); }