public static void SendSms(string cellNo, string taxrefNo, string year, string message) { var correspondance = new CorrespondenceManagementRequestStructure { RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE, OutChannel = CorrespondenceManagementRequestStructureOutChannel.SMS, SMS = new CorrespondenceManagementRequestStructureSMS { CellularNos = new[] { cellNo }, Message = message } }; var messageId = Guid.NewGuid(); var corXml = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance); var soapMessage = FdrCommon.CreateSoapSms(corXml, taxrefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.CorrespondenceOutQManagerName, Channel = MQConfigurationSettings.CorrespondenceOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.CorrespondenceOutPortNumber, HostName = MQConfigurationSettings.CorrespondenceOutHostName, QueueName = MQConfigurationSettings.CorrespondenceOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); }
protected void btnSave_Click(object sender, EventArgs e) { var fileReceivedBody = FdrCommon.WrapHtmlElement(txtFileReceived.Text); var fileAcceptedBody = FdrCommon.WrapHtmlElement(txtFileAccepted.Text); var fileRejectedBody = FdrCommon.WrapHtmlElement(txtFileRejected.Text); var fileAcceptedWithWarningsBody = FdrCommon.WrapHtmlElement(txtFileAcceptedWithWarnings.Text); var saved = DBWriteManager.SaveMasterLocalFileNotificationEmailBodyTemplates(new MasterLocalFileNotificationEmailBodyTemplate { Id = 0, AcceptedBody = fileAcceptedBody, AcceptedWithWarningsBody = fileAcceptedWithWarningsBody, RejectedBody = fileRejectedBody, ReceivedBody = fileReceivedBody, CreatedBy = Sars.Systems.Security.ADUser.CurrentSID, DateLastModified = DateTime.Now, LastModifiedBy = Sars.Systems.Security.ADUser.CurrentSID }); MessageBox.Show(saved > 0 ? "Master/Local File Notification Email Templates saved successfully" : "Issues reported during saving"); btnSave.Enabled = false; txtFileAccepted.Enabled = false; txtFileRejected.Enabled = false; txtFileReceived.Enabled = false; txtFileAcceptedWithWarnings.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var xml = DBReadManager.GetLetterXml(Request["Id"]); txtXml.SetValue(FdrCommon.FormatXml(xml)); } }
protected void Page_Load(object sender, EventArgs e) { var file = @"D:\SARS\Validate\IE_SCHEMA_VALIDATION4.txt"; var cbcXml = FdrCommon.FormatXml(File.ReadAllText(file)); var _client = new ESBMessagingServiceClient("basic"); var cbcSchemaVal = _client.ValidateSchema(Configurations.CbCValidationServiceID, cbcXml); _client.Close(); }
public static void SendLetter(string taxrefNo, string year) { var correspondance = new CorrespondenceManagementRequestStructure { RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE, TaxRef = new TaxRefStructure { TaxRefNo = taxrefNo, TypeOfTax = TypeOfTaxType.INCOME_TAX }, OutChannel = CorrespondenceManagementRequestStructureOutChannel.EFL, TaxYear = year }; //optional var letter = new CorrespondenceManagementRequestStructureLetter { }; var ret = File.ReadAllBytes(@"D:\Rejection of Master Files and Local Files.pdf"); letter.Content = Convert.ToBase64String(ret); var letters = new List <CorrespondenceManagementRequestStructureLetter> { letter }; correspondance.Letters = letters.ToArray(); var messageId = Guid.NewGuid(); var corXml = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance); var soapMessage = FdrCommon.CreateSoapLetter(corXml, taxrefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.CorrespondenceOutQManagerName, Channel = MQConfigurationSettings.CorrespondenceOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.CorrespondenceOutPortNumber, HostName = MQConfigurationSettings.CorrespondenceOutHostName, QueueName = MQConfigurationSettings.CorrespondenceOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); }
public void SendEmail(string messageBody, string subject, string emailAddress, byte[] attachement, string fileName, string taxrefNo, int year) { if (!Configurations.SendToEmails) { return; } var correspondance = new CorrespondenceManagementRequestStructure { RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE, OutChannel = CorrespondenceManagementRequestStructureOutChannel.EMAIL, Email = new CorrespondenceManagementRequestStructureEmail { ToAddresses = new[] { emailAddress }, Body = messageBody, Subject = subject, Attachments = attachement == null?null: new CorrespondenceManagementRequestStructureEmailAttachment[1] { new CorrespondenceManagementRequestStructureEmailAttachment { Content = attachement,//FdrCommon.GetRejectionLetter("1"), Type = DocumentType.PDF, Filename = string.Format("{0}.pdf", fileName) } } } }; var messageId = Guid.NewGuid(); var message = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance); var soapMessage = FdrCommon.CreateSoapEmail(message, emailAddress, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.CorrespondenceOutQManagerName, Channel = MQConfigurationSettings.CorrespondenceOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.CorrespondenceOutPortNumber, HostName = MQConfigurationSettings.CorrespondenceOutHostName, QueueName = MQConfigurationSettings.CorrespondenceOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); DBWriteManager.SaveCorrespondanceTrail(messageId.ToString(), taxrefNo, year, soapMessage); }
public static void SendNotification(string reportingPeriod, string countryFrom, RecordSet rolesToNotify) { if (rolesToNotify.HasRows) { var x = (from s in rolesToNotify.Tables[0].Rows.OfType <DataRow>() where s["EmailAddress"] != null && s["EmailAddress"].ToString().IsValid(StringValidationType.Email) select s["EmailAddress"].ToString()).ToArray(); var messageBody = string.Format( File.ReadAllText(Path.Combine(Configurations.EmailTemplateBaseFolder, "CBCArrivalNotification.htm")) , countryFrom , reportingPeriod , SARSDataSettings.Settings.ApplicationName); FdrCommon.SendEmail(x, messageBody, "CBC Declaration"); } }
public void SendSms(string cellNo, string taxrefNo, string message, int year) { if (!Configurations.SendToSms) { return; } if (Convert.ToInt64(cellNo) == 0) { //MessageBox.Show(string.Format("SMS will not be sent to this number {0}", cellNo)); return; } var correspondance = new CorrespondenceManagementRequestStructure { RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE, OutChannel = CorrespondenceManagementRequestStructureOutChannel.SMS, SMS = new CorrespondenceManagementRequestStructureSMS { CellularNos = new[] { cellNo }, Message = message } }; var messageId = Guid.NewGuid(); var corXml = XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance); var soapMessage = FdrCommon.CreateSoapSms(corXml, taxrefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.CorrespondenceOutQManagerName, Channel = MQConfigurationSettings.CorrespondenceOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.CorrespondenceOutPortNumber, HostName = MQConfigurationSettings.CorrespondenceOutHostName, QueueName = MQConfigurationSettings.CorrespondenceOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); DBWriteManager.SaveCorrespondanceTrail(messageId.ToString(), taxrefNo, year, soapMessage); }
private static string CreateXml(string header, Sars.ESBSchema.ApplicationInformation.v31.ApplicationInformationStructure appInfo, string body) { //var applicationInformationStructure = new Sars.ESBSchema.ApplicationInformation.v31.ApplicationInformationStructure //{ // ApplicationInformationResult = new Sars.ESBSchema.ApplicationInformation.v31.ApplicationInformationStructureApplicationInformationResult[1] //}; //applicationInformationStructure.ApplicationInformationResult[0] = // new Sars.ESBSchema.ApplicationInformation.v31.ApplicationInformationStructureApplicationInformationResult // { // Code = "0000", // Description = "Processed", // MessageType = Sars.ESBSchema.ApplicationInformation.v31.MessageTypeEnum.INFORMATION // }; var applicationInformationStructureXml = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(appInfo, "fdri", "http://www.egovernment.gov.za/GMD/ApplicationInformation/xml/schemas/version/3.1"); var xmlBuilder = new StringBuilder(); xmlBuilder.Append( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> " + "<soap12:Envelope xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\" " + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:esb=\"http://www.egovernment.gov.za/GMD/MessageIdentification/xml/schemas/version/7.1\">" ); xmlBuilder.AppendFormat( "{0}" + " <soap12:Body>" + "{1}" + "{2}" + "</soap12:Body>" + "</soap12:Envelope>", header, applicationInformationStructureXml, body ); return(FdrCommon.FormatXml(xmlBuilder.ToString())); }
public string GetTaxpayerRegistrationData(string taxRefNo) { var reg = new RegistrationManagementRequestStructure { RequestOperation = RegistrationManagementRequestStructureRequestOperation.RETRIEVE_ENTITY_DETAILS, PartyIdentifiers = new[] { new RegistrationManagementRequestStructurePartyIdentifier { IdentifierType = "REFERENCE_NO", Value = taxRefNo } } }; var messageId = Guid.NewGuid(); var corXml = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(reg); var soapMessage = FdrCommon.CreateSoapRegistrationQuery(corXml, taxRefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.RegistrationOutQManagerName, Channel = MQConfigurationSettings.RegistrationOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.RegistrationOutPortNumber, HostName = MQConfigurationSettings.RegistrationOutHostName, QueueName = MQConfigurationSettings.RegistrationOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); return(messageId.ToString()); }
protected void Page_Load(object sender, EventArgs e) { var uid = Request["uid"].ToUpper(); var source = Request["src"].ToUpper(); if (string.IsNullOrEmpty(uid) || string.IsNullOrEmpty(source)) { Response.Write("PARAMETER MISSING"); return; } Guid guid; if (!Guid.TryParse(uid, out guid)) { Response.Write("UID PARAMETER IN NOT VALID"); return; } var procedureName = string.Empty; switch (source) { case "IN": { procedureName = "usp_READ_ReportXml_IN"; break; } case "OUT": { procedureName = "usp_READ_ReportXml_OUT"; break; } case "MNE": { procedureName = "usp_READ_ReportXml_MNE"; break; } default: { procedureName = null; break; } } if (string.IsNullOrEmpty(procedureName)) { MessageBox.Show("PROCEDURE NAME IS NOT VALID"); return; } var recordSet = new RecordSet(procedureName, QueryType.StoredProcedure, new DBParamCollection { { "@UID", guid.ToString() } }); if (!recordSet.HasRows) { MessageBox.Show("THER IS NO DATA AVAILABLE"); return; } var xmlData = recordSet[0][0].ToString(); var cbcXml = ""; if (source.Equals("MNE", StringComparison.CurrentCultureIgnoreCase)) { var doc = new XmlDocument(); doc.LoadXml(xmlData); var cbCXmlNodeList = doc.GetElementsByTagName("CBC_OECD", "*"); if (cbCXmlNodeList.Count > 0) { cbcXml = cbCXmlNodeList[0].OuterXml; } } else { cbcXml = xmlData; } var client = new ESBMessagingServiceClient("basic"); //cbcXml = File.ReadAllText(@"D:\FDR\Report\CBC_OUT_KR.xml"); cbcXml = FdrCommon.FormatXml(cbcXml); var cbcSchemaVal = client.ValidateSchema(Configurations.CbCValidationServiceID, cbcXml); if (!cbcSchemaVal.IsValid) { return; } cbcXml = cbcXml.Replace("<CBC_OECD>", "<CBC_OECD xmlns=\"urn:oecd:ties:cbc:v1\">"); cbcXml = FdrCommon.FormatXml(cbcXml); var cbcMessage = XmlObjectSerializer.ConvertXmlToObject <CBC_OECD>(cbcXml); if (cbcMessage == null) { return; } var overAllReport = new StringBuilder(); overAllReport.Append(CreateMessageSpec(cbcMessage)); foreach (var cbcBody in cbcMessage.CbcBody) { var reportingEntity = cbcBody.ReportingEntity; var reportingEntityHeader = CreateReportingEntityHeader(); var reportingEntityRowAndData = CreateReportingEntityRowAndData(reportingEntity); if (cbcBody.CbcReports != null && cbcBody.CbcReports.Any()) { reportingEntityRowAndData.AppendFormat("<tr><td {0}></td><td colspan=\"11\">", GetColumnAttributes()); var cbcReportHeaderRow = CreatCbCReportHeader(); var cbcReportDataRows = CreateCbCReportRowsAndData(cbcBody); reportingEntityRowAndData.AppendFormat("<table width=\"100%\">{0}{1}</table></td></tr>", cbcReportHeaderRow, cbcReportDataRows); } overAllReport.Append(reportingEntityHeader); overAllReport.Append(reportingEntityRowAndData); //if (cbcBody.AdditionalInfo != null && cbcBody.AdditionalInfo.Any()) //{ // var additionalInfoHeaderRow = CreatAdditionalInfoHeader(); // var additionalInfoDataRow = new StringBuilder(); // foreach (var infoType in cbcBody.AdditionalInfo) // { // additionalInfoDataRow.Append(CreatAdditionalInfoRowAndData(infoType)); // } // overAllReport.AppendFormat("<table width=\"100%\">{0}{1}</table></td></tr>", additionalInfoHeaderRow, additionalInfoDataRow); //} } overAllReport.Append("</table></div>"); Export(overAllReport); }
public void LookUpRegistrationDetails(string taxReferenceNo) { var serviceClient = new FDRQueueService(); var id = serviceClient.GetTaxpayerRegistrationData(taxReferenceNo); var data = DBReadManager.GetResponse(id); var i = 1; while (!data.HasRows && i <= Configurations.QueueResponseTime) { Thread.Sleep(1); i++; data = DBReadManager.GetResponse(id); } if (!data.HasRows && i >= Configurations.QueueResponseTime) { DetailsFound = false; Message = Configurations.QueueTimeoutMessage; return; } if (Convert.ToInt32(data[0]["ReturnCode"]) != 0) { DetailsFound = false; Message = data[0]["ReturnMessage"].ToString(); //MessageBox.Show(data[0]["ReturnMessage"].ToString()); return; } DetailsFound = true; var xml = data[0]["Message"].ToString(); RegistrationData = xml; const string _namespace = "http://www.sars.gov.za/enterpriseMessagingModel/RegistrationManagement/xml/schemas/version/3.3"; var registrationManagementResponse = FdrCommon.SelectNode(xml, "ns0", _namespace, "RegistrationManagementResponse"); if (registrationManagementResponse != null) { var reg = Sars.Systems.Serialization.XmlObjectSerializer .ConvertXmlToObject <RegistrationManagementResponseStructure> ( registrationManagementResponse.OuterXml ); if (reg != null) { if (reg.Registration != null && reg.Registration.Parties != null && reg.Registration.Parties.Any()) { if (reg.Registration.Parties[0].Addresses != null && reg.Registration.Parties[0].Addresses.Any()) { foreach (var addressStructure in reg.Registration.Parties[0].Addresses) { if (addressStructure.PhysicalAddress != null) { PhysicalAddresses.Add(addressStructure.PhysicalAddress); } if (addressStructure.PostalAddress != null) { PostalAddresses.Add(addressStructure.PostalAddress); } } } if (reg.Registration.Parties[0].TradingNameDetails != null && reg.Registration.Parties[0].TradingNameDetails.Any()) { foreach (var tradingNameDetailStructure in reg.Registration.Parties[0].TradingNameDetails) { if (!string.IsNullOrWhiteSpace(tradingNameDetailStructure.Name)) { RegistrationName = tradingNameDetailStructure.Name; break; } } } } } } if (PhysicalAddresses.Any()) { foreach (var address in PhysicalAddresses) { if ( !string.IsNullOrEmpty(address.PostalCode) && !string.IsNullOrEmpty(address.StreetName) && (!string.IsNullOrEmpty(address.Suburb) || !string.IsNullOrEmpty(address.City)) ) { PreferredAddress = address; break; } } if (PreferredAddress == null) { PreferredAddress = PhysicalAddresses.Find( a => !string.IsNullOrEmpty(a.StreetName) || !string.IsNullOrEmpty(a.ComplexName) || !string.IsNullOrEmpty(a.UnitNo)); } } RecordSet.ReadXml(new StringReader(xml)); }
protected void btnSubmit_Click(object sender, EventArgs e) { int j = 0, k = 0; var listOfFiles = new List <FileValidationOutcomeDetails>(); foreach (GridViewRow row in gvMasterFiles.Rows) { var ddlOutcome = row.FindControl("ddlOutcome") as DropDownList; var txtOutcomeReason = row.FindControl("txtOutcomeReason") as TextBox; if (ddlOutcome != null && txtOutcomeReason != null) { ddlOutcome.BackColor = Color.Transparent; if (ddlOutcome.SelectedIndex <= 0) { ddlOutcome.BackColor = Color.Red; k++; break; } var dataKey = gvMasterFiles.DataKeys[row.RowIndex]; if (dataKey != null) { var fileId = Convert.ToDecimal(dataKey.Value); listOfFiles.Add(new FileValidationOutcomeDetails { Id = 0, SubmissionId = Convert.ToDecimal(SubmissionId), FileId = fileId, ValidationOutcomeId = Convert.ToInt32(ddlOutcome.SelectedValue), SID = Sars.Systems.Security.ADUser.CurrentSID, OutcomeReason = string.IsNullOrEmpty(txtOutcomeReason.Text) ? null : txtOutcomeReason.Text } ); } } } foreach (GridViewRow row in gvLocalFiles.Rows) { var ddlOutcome = row.FindControl("ddlOutcome") as DropDownList; var txtOutcomeReason = row.FindControl("txtOutcomeReason") as TextBox; if (ddlOutcome != null && txtOutcomeReason != null) { ddlOutcome.BackColor = Color.Transparent; if (ddlOutcome.SelectedIndex <= 0) { ddlOutcome.BackColor = Color.Red; j++; break; } var dataKey = gvLocalFiles.DataKeys[row.RowIndex]; if (dataKey != null) { var fileId = Convert.ToDecimal(dataKey.Value); listOfFiles.Add( new FileValidationOutcomeDetails { Id = 0, SubmissionId = Convert.ToDecimal(SubmissionId), FileId = fileId, ValidationOutcomeId = Convert.ToInt32(ddlOutcome.SelectedValue), SID = Sars.Systems.Security.ADUser.CurrentSID, OutcomeReason = string.IsNullOrEmpty(txtOutcomeReason.Text) ? null : txtOutcomeReason.Text } ); } } } if (k > 0) { tbMain.ActiveTabIndex = 0; MessageBox.Show("Please select validation outcome for all the files."); return; } if (j > 0) { tbMain.ActiveTabIndex = 1; MessageBox.Show("Please select validation outcome for all the files."); return; } if (listOfFiles.Any()) { var numSaved = 0; foreach (var detailse in listOfFiles) { numSaved += DBWriteManager.SaveFileValidationOutcome(detailse); } if (_fileSubmission == null) { _fileSubmission = DBReadManager.GeFileSubmissionById(Convert.ToDecimal(SubmissionId)); } if (numSaved == (gvLocalFiles.Rows.Count + gvMasterFiles.Rows.Count)) { btnSave.Enabled = false; btnSubmit.Enabled = false; MessageBox.Show("Validation submitted successfully"); } var status = 0; var accepted = listOfFiles.Count(a => a.ValidationOutcomeId == 1); var rejected = listOfFiles.Count(a => a.ValidationOutcomeId == 2); if (accepted == listOfFiles.Count()) { // accepted = 3 status = 3; try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(2); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { byte[] attachment = null;//FdrCommon.GetFileAcceptenceLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format(DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(2), _fileSubmission.TaxRefNo); service.SendEmail ( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } try{ var attachment = FdrCommon.GetEfilingAcceptanceLetter(_fileSubmission.Year); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Acceptance of Master Files and Local Files" , true , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception) { ; } } else if (rejected == listOfFiles.Count()) { //rejected = 4 status = 4; try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(3); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms ( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { //var attachment = FdrCommon.GetFileRejectionLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format( DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(3), _fileSubmission.TaxRefNo); service.SendEmail( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } //SEND EFILING REJECTION LETTERS try{ var attachment = FdrCommon.GetEfilingRejectionLetter(_fileSubmission.TaxRefNo, _fileSubmission.Year, Convert.ToDecimal(SubmissionId)); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Rejection of Master Files and Local Files" , false , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } else { try { if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(4); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms ( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try { if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { //var attachment = FdrCommon.GetFileRejectionLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format( DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(4), _fileSubmission.TaxRefNo); service.SendEmail( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } //SEND EFILING ACCEPTANCE LETTERS try { var attachment = FdrCommon.GetEfilingRejectionLetter(_fileSubmission.TaxRefNo, _fileSubmission.Year, Convert.ToDecimal(SubmissionId)); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Rejection of Master Files and Local Files" , false , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception) { ; } //Accepted With Warnings = 5 status = 5; } if (status != 0) { DBWriteManager.ChangeSubmissionStatus(Convert.ToDecimal(SubmissionId), status); } } else { MessageBox.Show("No validation was submitted"); } }
public XmlElement EnquireRegistration(string taxRefNo) { var reg = new RegistrationManagementRequestStructure { RequestOperation = RegistrationManagementRequestStructureRequestOperation.RETRIEVE_ENTITY_DETAILS, PartyIdentifiers = new[] { new RegistrationManagementRequestStructurePartyIdentifier { IdentifierType = "REFERENCE_NO", Value = taxRefNo } } }; var doc = new XmlDocument(); var messageId = Guid.NewGuid(); var corXml = XmlObjectSerializer.GetXmlWithNoDeclaration(reg); var soapMessage = FdrCommon.CreateSoapRegistrationQuery(corXml, taxRefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.RegistrationOutQManagerName, Channel = MQConfigurationSettings.RegistrationOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.RegistrationOutPortNumber, HostName = MQConfigurationSettings.RegistrationOutHostName, QueueName = MQConfigurationSettings.RegistrationOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; var message = string.Empty; FdrMessaging.SendMessageToQueue(queueInfo); Thread.Sleep(1); var data = DBReadManager.GetResponse(messageId.ToString()); var i = 1; while (!data.HasRows && i <= Configurations.QueueResponseTime) { Thread.Sleep(1); i++; data = DBReadManager.GetResponse(messageId.ToString()); } if (!data.HasRows && i >= Configurations.QueueResponseTime) { doc.LoadXml(string.Format("<Errors><Error message=\"{0}\" /></Errors>", Configurations.QueueTimeoutMessage)); return(doc.DocumentElement); } if (string.IsNullOrEmpty(message)) { if (Convert.ToInt32(data[0]["ReturnCode"]) != 0) { message = data[0]["ReturnMessage"].ToString(); doc.LoadXml(string.Format("<Errors><Error message=\"{0}\" /></Errors>", message)); return(doc.DocumentElement); } } var xml = data[0]["Message"].ToString(); doc.LoadXml(xml); return(doc.DocumentElement); }
public void SendLetter(decimal submissionId, string taxrefNo, int year, string letterContent, string letterHead, bool isAcceptance, string userSid) { if (!Configurations.SendToEfiling) { return; } var currentUser = Sars.Systems.Security.ADUser.CurrentUser; if (currentUser == null) { return; } var correspondance = new CorrespondenceManagementRequestStructure { OutChannel = CorrespondenceManagementRequestStructureOutChannel.EFL, RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE, TaxRef = new TaxRefStructure { TaxRefNo = taxrefNo, TypeOfTax = TypeOfTaxType.INCOME_TAX }, TaxYear = year.ToString() }; RegistrationQueryDetails registration = null; try{ registration = new RegistrationQueryDetails(); registration.LookUpRegistrationDetails(taxrefNo); if (!registration.DetailsFound) { MessageBox.Show(registration.Message); return; } } catch (Exception) { } if (registration == null) { return; } if (!registration.DetailsFound) { MessageBox.Show(string.Format("Letter could not be sent because FDR could not get registration details for the number {0} \n U3TM reason : {1}", taxrefNo, registration.Message)); return; } if (registration.PreferredAddress == null) { MessageBox.Show("Letter could not be sent because FDR could not get registration address."); return; } var sarsSysgenltr = new SARS_SYSGENLTR { ADDRESSEE_DETAILS = new SARS_SYSGENLTRADDRESSEE_DETAILS { //ADDRESS_FIELD_F001 = "What is Here", //ADDRESS_FIELD_F002 = "Pretoria", //ADDRESS_FIELD_F003 = "299 Bronkhorst street", //ADDRESS_FIELD_F004 = "QA TESTING", //ADDRESS_FIELD_F005 = "Brooklyn", //ADDRESS_FIELD_F006 = "2000", //ADDRESS_FIELD_F007 = "" ADDRESS_FIELD_F001 = registration.RegistrationName, ADDRESS_FIELD_F002 = "", ADDRESS_FIELD_F003 = string.Format("{0} {1}", registration.PreferredAddress.StreetNo, registration.PreferredAddress.StreetName), ADDRESS_FIELD_F004 = registration.PreferredAddress.Suburb, ADDRESS_FIELD_F005 = registration.PreferredAddress.City, ADDRESS_FIELD_F006 = registration.PreferredAddress.PostalCode, ADDRESS_FIELD_F007 = "" }, FORM_INFORMATION = new FORM_INFORMATION { FORM_ID = "CBC_LET_GEN", GUID = new GlobalUniqueIDStructure { UniqueIdentifier = Guid.NewGuid().ToString() }, TIMESTAMP = DateTime.Now, TAX_REF_NO = taxrefNo, TAX_YEAR = year.ToString(), LANGUAGE = "english", FORM_TYPE = isAcceptance ? "CBCACC" : "CBCREJ", CASE_NUMBER = string.Empty }, CONTACT_DETAILS = new SARS_SYSGENLTRCONTACT_DETAILS { HeaderLabel = "Contact Detail", ADDRESS_CD01 = "SARS Head Office", TEL_NO_CD02 = currentUser.Telephone, WEB_ADDRESS_CD03 = "SARS online: www.sars.gov.za", TOLL_FREE_NO_CD04 = "", FAX_NO_CD05 = "", EMAIL_ADDRESS_CD06 = currentUser.Name }, LETTER_CONTENT = new SARS_SYSGENLTRLETTER_CONTENT { CONTENT = letterContent.Replace(Environment.NewLine, "") }, DETAILS = new SARS_SYSGENLTRDETAILS { TAXREF_NO = new SARS_SYSGENLTRDETAILSTAXREF_NO { TAXREF_FIELD_F004 = taxrefNo, TAXREF_LABEL_L003 = "Tax Reference No.:" }, DATE = new SARS_SYSGENLTRDETAILSDATE { DATE_LABEL_L008 = "Date:", DATE_FIELD_F009 = DateTime.Now.ToString("yyyy-MM-dd") }, ENQUIRY_NOTE = new SARS_SYSGENLTRDETAILSENQUIRY_NOTE { NOTE_LABEL_L005 = "Always quote this reference number when contacting SARS" } }, LETTER_HEADER = new SARS_SYSGENLTRLETTER_HEADER { LETTER_HEADER_LABEL = letterHead }, LETTER_NAME_HEADER = new SARS_SYSGENLTRLETTER_NAME_HEADER { LETTER_NAME = string.Empty //letterHead.ToUpper() } //, //Paragraphs = new string[2] //{ // "Paragraph 1", // "Paragraph 2" //}, }; var letterDetails = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(sarsSysgenltr, "SARS", "http://www.sars.gov.za/forms/").Replace(Environment.NewLine, ""); var letters = new List <CorrespondenceManagementRequestStructureLetter> { new CorrespondenceManagementRequestStructureLetter { Content = string.Format("<![CDATA[{0}]]>", letterDetails), TemplateDetails = new TemplateDetailsStructure { Language = LanguageType.ENGLISH, Name = "SARS_SysGenOutLet_RO_E_v2012.01.05" }, Type = isAcceptance ? "CBCACC" : "CBCREJ" } }; correspondance.Letters = letters.ToArray(); var messageId = Guid.NewGuid(); var corXml = XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance); var soapMessage = FdrCommon.CreateSoapLetter(corXml, taxrefNo, messageId.ToString()); soapMessage = FdrCommon.FormatXml(soapMessage).Replace("<", "<").Replace(">", ">").Replace("&lt;", "<").Replace("&gt;", ">"); var queueInfo = new QueueInfo { Manager = MQConfigurationSettings.CorrespondenceOutQManagerName, Channel = MQConfigurationSettings.CorrespondenceOutQChannelName, UseManagerName = false, Port = MQConfigurationSettings.CorrespondenceOutPortNumber, HostName = MQConfigurationSettings.CorrespondenceOutHostName, QueueName = MQConfigurationSettings.CorrespondenceOutQName, CorrelationId = messageId.ToString(), Message = soapMessage }; FdrMessaging.SendMessageToQueue(queueInfo); DBWriteManager.SaveLetter(submissionId, soapMessage, taxrefNo, year, userSid); DBWriteManager.SaveCorrespondanceTrail(messageId.ToString(), taxrefNo, year); }