/// <summary> /// 加密模块的创建 /// </summary> /// <param name="type">加密类型</param> /// <param name="key">加密密钥</param> private static ICryptography GetService(ServiceType type, string key) { ICryptography _cryptography = null; if (type.Equals(ServiceType.AES)) { AESService aes = new AESService(); aes.Key = key; _cryptography = aes; } else if (type.Equals(ServiceType.DES)) { ThreeDesService des = new ThreeDesService(); des.Key = key; _cryptography = des; } else if (type.Equals(ServiceType.RSA)) { RSAService rsa = new RSAService(); rsa.PublicKey = key; _cryptography = rsa; } else { } return(_cryptography); }
public static void PostMessage(ServiceType type, string text, string url) { string packageName = string.Empty; if(type.Equals(ServiceType.Twitter)){ packageName = "com.twitter.android"; }else if (type.Equals(ServiceType.Facebook)){ packageName = "com.facebook.katana"; } AndroidJavaObject intent = new AndroidJavaObject ( "android.content.Intent" ); intent.Call<AndroidJavaObject> ( "setPackage", packageName ); intent.Call<AndroidJavaObject> ( "setType", "text/plain" ); intent.Call<AndroidJavaObject> ( "putExtra", "android.intent.extra.TEXT" , text + "\t" + url ); activity.Call ("startActivity", intent.CallStatic<AndroidJavaObject>( "createChooser", intent, "Sorry" )); intent.Dispose (); }
public override IService GetService(ServiceType serviceType) { if (serviceType.Equals(ServiceType.NativePathServiceType)) { var retval = ((ShadowNodeContent)GetContent()).GetReadFile(TimeSpan.FromMinutes(1)).GetService(serviceType); if (retval != null) { return retval; } } try { return this.FileSystem.GetService(this, serviceType); } catch (NotSupportedException) { } return base.GetService (serviceType); }
public override IService GetService(ServiceType serviceType) { if (serviceType.Equals(ServiceType.NativePathServiceType)) { var retval = ((ShadowNodeContent)GetContent()).GetReadFile(TimeSpan.FromMinutes(1)).GetService(serviceType); if (retval != null) { return(retval); } } try { return(this.FileSystem.GetService(this, serviceType)); } catch (NotSupportedException) { } return(base.GetService(serviceType)); }
public override bool Equals(object obj) { TrackedService other = obj as TrackedService; if (other == null) { return(false); } if (serviceAddress != other.serviceAddress && (serviceAddress == null || !serviceAddress.Equals(other.serviceAddress))) { return(false); } if (!serviceType.Equals(other.serviceType)) { return(false); } return(true); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write("/********************************************************************************" + "************************\r\n* Copyright @2004, RAMCO SYSTEMS, All rights reserved" + ".\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n* Application/Module Name :"); #line 5 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("_cr.cs\r\n* Code Generated on :"); #line 6 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now)); #line default #line hidden this.Write("\r\n* Code Generated From :"); #line 7 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(string.Format("{0}/{1}/{2}/{3}/{4}/{5}/{6}", ecrOptions.Customer, ecrOptions.Project, ecrOptions.Ecrno, ecrOptions.Model, ecrOptions.User, ecrOptions.DB, ecrOptions.CodegenClient))); #line default #line hidden this.Write(@" * Revision/Version # : * Purpose : * Modifications : * Modifier Name & Date : ********************************************************************************************************/ using System; using System.Diagnostics; using System.Reflection; using System.EnterpriseServices; using com.ramco.vw."); #line 17 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(".trans;\r\nusing com.ramco.vw.tp.CRUtil;\r\n\r\n[assembly: AssemblyDescription(\""); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Customer)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Project)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Ecrno)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Model.Replace('\\', '-'))); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.User)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.DB)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.CodegenClient)); #line default #line hidden this.Write("/"); #line 20 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(DateTime.Now.ToShortDateString())); #line default #line hidden this.Write("\")]\r\n[assembly:ApplicationActivation(ActivationOption.Server)]\r\n\r\n[assembly:Appli" + "cationAccessControlAttribute(false,AccessChecksLevel=AccessChecksLevelOption.App" + "licationComponent)]\r\n \r\nnamespace com.ramco.vw."); #line 25 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(".cr\r\n{\r\n [Transaction(TransactionOption.Supported, Isolation = TransactionIsol" + "ationLevel.ReadCommitted)]\r\n [EventTrackingEnabled(true)]\r\n\r\n public class" + " C"); #line 30 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr : ServicedComponent { public const int ATMA_SUCCESS = 0; public const int ATMA_FAILURE = 999; public const int ATMA_INVALID_SERVICE = 998; DefaultTraceListener output = new DefaultTraceListener(); public int ProcessDocument(string szInMtd, string szServiceName, string szSessionToken, ref string szOutMtd) { try { szOutMtd = """"; switch (szServiceName.ToLower().Trim()) { " ); #line 44 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" foreach (Service service in this.services) { ServiceType serviceType = (ServiceType)Enum.Parse(typeof(ServiceType), service.Type); string FetchOrUpdate = serviceType.Equals(ServiceType.Fetch) ? "0" : "1"; #line default #line hidden this.Write("case (\""); #line 48 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(service.Name.ToLower())); #line default #line hidden this.Write("\"):\r\n using (C"); #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FetchOrUpdate)); #line default #line hidden this.Write(" "); #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FetchOrUpdate)); #line default #line hidden this.Write(" = new C"); #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden #line 49 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FetchOrUpdate)); #line default #line hidden this.Write("())\r\n {\r\n if ("); #line 51 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden #line 51 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(FetchOrUpdate)); #line default #line hidden this.Write(".ProcessDocument(szInMtd, szServiceName, szSessionToken, out szOutMtd) == 0)\r\n " + " {\r\n output.WriteLine(\""); #line 53 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToUpper())); #line default #line hidden this.Write(".C"); #line 53 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("_cr.ProcessDocument - "); #line 53 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(service.Name.ToLower())); #line default #line hidden this.Write(" service executed successfully.\");\r\n return ATMA_S" + "UCCESS;\r\n }\r\n else\r\n " + " {\r\n output.WriteLine(\"C"); #line 58 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("_cr.ProcessDocument - "); #line 58 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(service.Name.ToLower())); #line default #line hidden this.Write(" service executed with a failure.\");\r\n return ATMA" + "_FAILURE;\r\n }\r\n }\r\n\t\t\t\t\t"); #line 62 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" } #line default #line hidden this.Write(@"default: int iType = -1; string szPSXmlPath = string.Empty; CRUtil.PassiveServiceCheck(szServiceName, ref iType, ref szPSXmlPath); switch (iType) { case 0: using (C"); #line 71 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("0 "); #line 71 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("0 = new C"); #line 71 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("0())\r\n {\r\n if (" + ""); #line 73 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("0.PassiveProcessDocument(szInMtd, szPSXmlPath, szSessionToken, out szOutMtd) == 0" + ")\r\n {\r\n " + " output.WriteLine(\""); #line 75 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(".C"); #line 75 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.PassiveProcessDocument - "" + szServiceName + "" service executed successfully.""); return ATMA_SUCCESS; } else { output.WriteLine(""C"); #line 80 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.PassiveProcessDocument - "" + szServiceName + "" service executed with a failure.""); return ATMA_FAILURE; } } case 1: using (C"); #line 85 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("1 "); #line 85 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("1 = new C"); #line 85 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("1())\r\n {\r\n if (" + ""); #line 87 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("1.PassiveProcessDocument(szInMtd, szPSXmlPath, szSessionToken, out szOutMtd) == 0" + ")\r\n {\r\n " + " output.WriteLine(\""); #line 89 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(".C"); #line 89 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.ProcessDocument - "" + szServiceName + "" service executed successfully.""); return ATMA_SUCCESS; } else { output.WriteLine(""C"); #line 94 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.PassiveProcessDocument - "" + szServiceName + "" service executed with a failure.""); return ATMA_FAILURE; } } default: output.WriteLine(""C"); #line 99 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.ProcessDocument - Service referred Is Not part of the runtime component-"" + szServiceName); return ATMA_INVALID_SERVICE; } } } catch (Exception e) { output.WriteLine(""C"); #line 106 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write(@"_cr.ProcessDocument - General Exception :""); output.WriteLine(e.Message); szOutMtd = """"; return ATMA_FAILURE; } finally { base.Dispose(true); } } public C"); #line 117 "E:\Workings\__Ramco.VwPlf.Developerconsole\Ramco.VwPlf.CodeGenerator\AppLayer\Template_cr.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ecrOptions.Component.ToLower())); #line default #line hidden this.Write("_cr()\r\n {\r\n }\r\n }\r\n}\r\n"); return(this.GenerationEnvironment.ToString()); }
public XElement BillPull(string guid, XElement billPullRequest) { MFEPMessage <BillsRecord> deserializedResponse = new MFEPMessage <BillsRecord>(); XElement serializedResponse = null; string fileGuid = Guid.NewGuid().ToString(); try { // Write the request to physical path WriteToPhysicalPath(billPullRequest, BillPullRequestPath, fileGuid); MFEPMessage <BillInquiryRequestEntity> deserializedRequest = billPullRequest.FromXElement <MFEPMessage <BillInquiryRequestEntity> >(); deserializedResponse.Header.TimeStamp = DateTime.Now.ToString("s"); deserializedResponse.Header.Guid = guid; deserializedResponse.Header.TransmitInfo = new TransmitInfo() { SenderCode = deserializedRequest.Header.TransmitInfo.ReceiverCode, ResponseType = ProcessesCodes.BILPULRS }; deserializedResponse.Header.Result = new Result(); bool isTestReponse = IsTestReponse; if (!isTestReponse) { // Verifying if (EnableSecuity) { if (deserializedRequest == null || deserializedRequest.Footer.Security == null || deserializedRequest.Footer.Security.Signature == null || string.IsNullOrWhiteSpace(deserializedRequest.Footer.Security.Signature.Trim())) { Result result_1 = new Result(); result_1.ErrorCode = (int)ServiceErrors.InvalidSignature; result_1.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result_1.Severity = Severity.Error; deserializedResponse.Header.Result = result_1; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } else { VerifyMode verifyMode = VerifyMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { verifyMode = VerifyMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; bool verifiedSuccessfully = CertificateManager.VerifyMessageSignature(deserializedRequest.ToXElement <MFEPMessage <BillInquiryRequestEntity> >(), xPath, deserializedRequest.Footer.Security.Signature, BillerCertificateSerialNumber, verifyMode); if (!verifiedSuccessfully) { Result result_2 = new Result(); result_2.ErrorCode = (int)ServiceErrors.InvalidSignature; result_2.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result_2.Severity = Severity.Error; deserializedResponse.Header.Result = result_2; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } } if (deserializedRequest.Header.TransmitInfo.SenderCode != MFEPCode) { Result result_3 = new Result(); result_3.ErrorCode = (int)ServiceErrors.InvalidSenderCode; result_3.ErrorDesc = ServiceErrors.InvalidSenderCode.ToString(); result_3.Severity = Severity.Error; deserializedResponse.Header.Result = result_3; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Validate Biller code if (deserializedRequest.Header.TransmitInfo.ReceiverCode != BillerCode) { Result result_4 = new Result(); result_4.ErrorCode = (int)ServiceErrors.UnsuccessfulBillPullRequest; result_4.ErrorDesc = ServiceErrors.UnsuccessfulBillPullRequest.ToString(); result_4.Severity = Severity.Error; deserializedResponse.Header.Result = result_4; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Validate Service Type if (!ServiceType.Equals(deserializedRequest.Body.ServiceType, StringComparison.CurrentCultureIgnoreCase)) { Result result_5 = new Result(); result_5.ErrorCode = (int)ServiceErrors.UnrecognizedServiceType; result_5.ErrorDesc = ServiceErrors.UnrecognizedServiceType.ToString(); result_5.Severity = Severity.Error; deserializedResponse.Header.Result = result_5; serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Get Bill and generate the response DAL dal = new DAL(); BillRecord billRecord = dal.GetBillInfo(deserializedRequest.Body.AccountInfo.BillNumber, deserializedRequest.Body.AccountInfo.BillingNumber, deserializedRequest.Body.ServiceType); if (billRecord != null) { billRecord.IssueDate = billRecord.IssueDate.Value.AddMinutes(TimeDifference); billRecord.DueDate = billRecord.DueDate.Value.AddMinutes(TimeDifference); deserializedResponse.Body = new BillsRecord() { RecCount = 1 }; deserializedResponse.Body.BillRecords.Add(billRecord); } else { deserializedResponse.Body = new BillsRecord() { RecCount = 0, BillRecords = null }; } // Sign the response if (EnableSecuity) { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(), xPath, BillerCertificateSerialNumber, signMode); } else { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(), xPath, BillerCertificateSerialNumber, signMode); } serializedResponse = deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >(); // Write the request to physical path WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); return(serializedResponse); } // Sign the response return(GenerateAutoResponse(guid, billPullRequest)); /* serializedResponse = deserializedResponse.ToXElement<MFEPMessage<BillsRecord>>(); * // Write the request to physical path * WriteToPhysicalPath(serializedResponse, BillPullResponsePath, fileGuid); * */ /*return serializedResponse;*/ } else { return(GenerateAutoResponse(guid, billPullRequest)); } } catch (Exception exception) { string ex = exception.Message + "\n" + exception.StackTrace; WriteException(ex, ExceptionPath); Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InternalError; result.ErrorDesc = ServiceErrors.InternalError.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; return(deserializedResponse.ToXElement <MFEPMessage <BillsRecord> >()); } }
public XElement ReceivePaymentNotification(string guid, XElement paymentNotification) { MFEPMessage <PaymentNotificationTransaction> deserializedResponse = new MFEPMessage <PaymentNotificationTransaction>(); XElement serializedResponse = null; string fileName = Guid.NewGuid().ToString(); try { MFEPMessage <PaymentNotificationTransaction> deserializedRequest = paymentNotification.FromXElement <MFEPMessage <PaymentNotificationTransaction> >(); deserializedResponse.Header.TimeStamp = DateTime.Now.ToString("s"); deserializedResponse.Header.Guid = guid; deserializedResponse.Header.TransmitInfo = new TransmitInfo() { SenderCode = deserializedRequest.Header.TransmitInfo.ReceiverCode, ResponseType = ProcessesCodes.BLRPMTNTFRS }; deserializedResponse.Header.Result = new Result(); fileName = deserializedRequest.Body.Transactions[0].ServiceType.SrvsTypValue.ToString() + fileName; if (!IsTestReponse) { // Verifying if (EnableSecuity) { if (deserializedRequest == null || deserializedRequest.Footer.Security == null || deserializedRequest.Footer.Security.Signature == null || string.IsNullOrWhiteSpace(deserializedRequest.Footer.Security.Signature.Trim())) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSignature; result.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } else { VerifyMode verifyMode = VerifyMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { verifyMode = VerifyMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; bool verifiedSuccessfully = CertificateManager.VerifyMessageSignature(paymentNotification, xPath, deserializedRequest.Footer.Security.Signature, BillerCertificateSerialNumber, verifyMode); if (!verifiedSuccessfully) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSignature; result.ErrorDesc = ServiceErrors.InvalidSignature.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } } } // Validation // Validate MFEP code if (deserializedRequest.Header.TransmitInfo.SenderCode != MFEPCode) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InvalidSenderCode; result.ErrorDesc = ServiceErrors.InvalidSenderCode.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } // Validate Biller code if (deserializedRequest.Header.TransmitInfo.ReceiverCode != BillerCode) { Result result = new Result(); result.ErrorCode = (int)ServiceErrors.UnsuccessfulPaymentNotification; result.ErrorDesc = ServiceErrors.UnsuccessfulPaymentNotification.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to failed notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } // if the serviceType is IndividualSecurity then insert it to database otherwise just write it ti physical directory if (ServiceType.Equals(deserializedRequest.Body.Transactions[0].ServiceType.SrvsTypValue.ToString(), StringComparison.CurrentCultureIgnoreCase)) { // Insert this payment DAL dal = new DAL(); dal.InsertPaymentNotification(deserializedRequest.Body.Transactions[0].AccountInfo.BillingNumber); } PaymentNotificationTransaction transaction = new PaymentNotificationTransaction { Transactions = new Collection <PaymentNotificationEntity>() }; foreach (PaymentNotificationEntity pne in deserializedRequest.Body.Transactions) { PaymentNotificationEntity notificationEntity = new PaymentNotificationEntity { JOEBPPSTrx = pne.JOEBPPSTrx, ProcessDate = pne.ProcessDate, STMTDate = pne.STMTDate, Result = new Result() }; transaction.Transactions.Add(notificationEntity); } deserializedResponse.Body = transaction; // Sign the response if (EnableSecuity) { SignMode signMode = SignMode.WithFormat; if (SecurityMode.Equals("WithOutFormat", StringComparison.CurrentCultureIgnoreCase)) { signMode = SignMode.WithOutFormat; } Collection <string> xPath = new Collection <string> { XPath }; deserializedResponse.Footer = new MFEPFooter(); deserializedResponse.Footer.Security.Signature = CertificateManager.SignMessage(deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(), xPath, BillerCertificateSerialNumber, signMode); } else { deserializedResponse.Footer = new MFEPFooter(); } WriteToPhysicalPath(paymentNotification, SuccessPMTNotiRequestPath, fileName); // Write to success notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, SuccessPMTNotiResponsePath, fileName); return(serializedResponse); } else { return(GenerateAutoResponse(guid, deserializedRequest, guid)); } } catch (Exception exception) { string ex = exception.Message + "\n" + exception.StackTrace; WriteException(ex, ExceptionPath); Result result = new Result(); result.ErrorCode = (int)ServiceErrors.InternalError; result.ErrorDesc = ServiceErrors.InternalError.ToString(); result.Severity = Severity.Error; deserializedResponse.Header.Result = result; WriteToPhysicalPath(paymentNotification, FailedPMTNotiRequestPath, fileName); // Write to success notifications serializedResponse = deserializedResponse.ToXElement <MFEPMessage <PaymentNotificationTransaction> >(); WriteToPhysicalPath(serializedResponse, FailedPMTNotiResponsePath, fileName); return(serializedResponse); } }
/// <summary> /// Determines if the service type of the current <see cref="LooselyNamedService" /> /// is the same as the service type of the specified <see cref="LooselyNamedService" />. /// </summary> /// <param name="other"> /// The <see cref="LooselyNamedService" /> whose service type is to be compared with /// the service type of the current <see cref="LooselyNamedService" />. /// </param> /// <returns> /// True if the service type of <paramref name="other" /> is the same as /// the service type of the current <see cref="LooselyNamedService" />, otherwise False. /// </returns> public bool Equals(LooselyNamedService other) { return(other != null && ServiceType.Equals(other.ServiceType)); }
/// <summary> /// Determines if the service type of the current <see cref="OpenGenericTypedService" /> /// is the same generic as the service type of the specified <see cref="OpenGenericTypedService" />. /// </summary> /// <param name="other"> /// The <see cref="OpenGenericTypedService" /> whose service type is to be compared with /// the service type of the current <see cref="OpenGenericTypedService" />. /// </param> /// <returns> /// True if the service type of <paramref name="other" /> is the same generic as /// the service type of the current <see cref="OpenGenericTypedService" />, otherwise False. /// </returns> public bool Equals(OpenGenericTypedService other) { return(other != null && (ServiceType.Equals(other.ServiceType) || openGenericType.Equals(other.openGenericType))); }