/// <summary> /// /// </summary> /// <param name="teamName">Team name</param> /// <param name="teamId">Team id</param> /// <param name="call">Remote service call</param> public ExecuteServiceRequest(string teamName, int teamId, RemoteServiceCall call) : base("EXEC-SERVICE", teamName, teamId.ToString()) { Contents.Add("SRV"); Contents.Add(""); Contents.Add(call.ServiceName); Contents.Add(""); Contents.Add(call.Args.Count.ToString()); Contents.Add(""); Contents.Add(""); Contents.Add(NewRow); for (int i = 0; i < call.Args.Count; i++) { var arg = call.Args[i]; Contents.Add("ARG"); Contents.Add(arg.Position.ToString()); Contents.Add(arg.Name); Contents.Add(ServiceArgument.TypeToString(arg.DataType)); Contents.Add(""); Contents.Add(arg.Value); Contents.Add(NewRow); } }
/// <summary> /// /// </summary> /// <param name="teamName">Team name</param> /// <param name="teamId">Team id</param> /// <param name="service">Service</param> public PublishServiceRequest(string teamName, int teamId, RemoteService service) : base("PUB-SERVICE", teamName, teamId.ToString()) { Contents.Add("SRV"); Contents.Add(service.Tag); Contents.Add(service.Name); Contents.Add(service.SecurityLevel.ToString()); Contents.Add(service.Args.Count.ToString()); Contents.Add(service.Returns.Count.ToString()); Contents.Add(service.Description); Contents.Add(NewRow); foreach (var arg in service.Args) { Contents.Add("ARG"); Contents.Add(arg.Position.ToString()); Contents.Add(arg.Name); Contents.Add(ServiceArgument.TypeToString(arg.DataType)); Contents.Add(arg.Mandatory ? "mandatory" : "optional"); Contents.Add(NewRow); } foreach (var ret in service.Returns) { Contents.Add("RSP"); Contents.Add(ret.Position.ToString()); Contents.Add(ret.Name); Contents.Add(ServiceArgument.TypeToString(ret.DataType)); Contents.Add(NewRow); } Contents.Add("MCH"); Contents.Add(service.Ip.ToString()); Contents.Add(service.Port.ToString()); Contents.Add(NewRow); }
/// <summary> /// Create HL7 from response /// </summary> /// <returns>HL7</returns> public string ToHl7() { var taxRate = (from t in taxRates where t.Code == provinceCode select t).FirstOrDefault(); if (taxRate == null) { throw new Exception("Unknown provinceCode == " + provinceCode); } // Perform the calculations var subtotal = purchaseAmount; var hst = (taxRate.Hst / 100) * subtotal; var gst = (taxRate.Gst / 100) * subtotal; var pst = 0.0; if (provinceCode == "QC" || provinceCode == "PE") { pst = (taxRate.Pst / 100) * (subtotal + gst); } else { pst = (taxRate.Pst / 100) * subtotal; } var total = subtotal + pst + hst + gst; // Create the return values var sr = SubTotalReturn; sr.Value = subtotal; var pr = PstReturn; pr.Value = pst; var hr = HstReturn; hr.Value = hst; var gr = GstReturn; gr.Value = gst; var tr = TotalReturn; tr.Value = total; // Create HL7 var sb = new StringBuilder(); sb.Append(String.Format("PUB|OK|||{0}|{1}", 5, Request.NewRow)); foreach (var ret in new ServiceReturn[] { sr, pr, hr, gr, tr }) { sb.Append(String.Format("RSP|{0}|{1}|{2}|{3}|{4}", ret.Position, ret.Name, ServiceArgument.TypeToString(ret.DataType), ret.Value, Request.NewRow)); } return(Request.BeginMarker + sb.ToString() + Request.EndOfMessage); }