public ActionResult sendDataXmlToSSO(F_SSO_SendDataForm formModelMethod) { formModelMethod.server_path_xml = Server.MapPath("~/Uploads/TestFileXml"); //return model.sendDataXmlToSSO(formModelMethod); if (model.sendDataXmlToSSO(formModelMethod)) { return(Json(SystemClass.returnResultJsonSuccess())); } else { return(Json(SystemClass.returnResultJsonFailure())); } }
public ActionResult convertDataUploadXml(F_SSO_SendDataForm formModelMethod) { var pathDecode = Path.Combine(Server.MapPath("~/Uploads/TestFileDecode"), formModelMethod.server_file_name); formModelMethod.server_path_decode = pathDecode; formModelMethod.server_path_send_exe = Path.Combine(Server.MapPath("~/Plugins/SSO_SendData"), "SSO_Subsidy_SendData.exe"); formModelMethod.server_path_plugins = Server.MapPath("~/Plugins/SSO_SendData");; formModelMethod.server_path_xml = Server.MapPath("~/Uploads/TestFileXml"); if (model.convertDataToXml(formModelMethod)) { return(Json(SystemClass.returnResultJsonSuccess())); } else { return(Json(SystemClass.returnResultJsonFailure())); } }
public ActionResult transferDataXmlToSSO(F_SSO_SendDataForm formModelMethod) { formModelMethod.server_path_xml = Server.MapPath("~/Uploads/TestFileXml"); var pathXml = Path.Combine(Server.MapPath("~/Uploads/TestFileXml"), "SSOSENA_ANSI_TEST_2.xml"); formModelMethod.server_path_xml = pathXml; //return model.sendDataXmlToSSO(formModelMethod); if (model.transferDataXmlToSSO(formModelMethod)) { return(Json(SystemClass.returnResultJsonSuccess())); } else { return(Json(SystemClass.returnResultJsonFailure())); } }
public Object getDecodeString(F_SSO_SendDataForm formModel) { Dictionary <string, object> jsonReturn = new Dictionary <string, object>(); // string path = @"D:\TestFiles\test_text_007.DATII"; string path = formModel.server_path; // This text is added only once to the file. if (File.Exists(path)) { string readTextEncode = File.ReadAllText(path); var base64EncodedBytes = System.Convert.FromBase64String(readTextEncode); string textDecode = System.Text.Encoding.UTF8.GetString(base64EncodedBytes); string pathSaveDecode = formModel.server_path_decode; try { File.WriteAllText(pathSaveDecode, textDecode, Encoding.UTF8); Debug.WriteLine(readTextEncode); Debug.WriteLine(textDecode); jsonReturn.Add("textEncode", readTextEncode); jsonReturn.Add("textDecode", textDecode); jsonReturn.Add("pathSaveDecode", pathSaveDecode); jsonReturn.Add("textXmlFileName", formModel.server_file_name); jsonReturn.Add("progressStatus", "1"); } catch (Exception ex) { Debug.WriteLine(ex); jsonReturn.Add("Failure", ex); } } return(jsonReturn); }
public bool convertDataToXml(F_SSO_SendDataForm formModel) { try { XmlDocument xmlDoc = new XmlDocument(); XmlDeclaration xmlDeclaration = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement root = xmlDoc.DocumentElement; xmlDoc.InsertBefore(xmlDeclaration, root); XmlElement elementBody = xmlDoc.CreateElement(string.Empty, "SSOMessageSubsidy", string.Empty); xmlDoc.AppendChild(elementBody); elementBody.SetAttribute("xmlns", "urn:th:sso:xsd:subsidy:1"); elementBody.SetAttribute("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#"); string[] lines = File.ReadAllLines(formModel.server_path_decode); string firstLine = lines[0]; // gets the first line from file. //##### FOR CONTROL. string secondLine = lines[1]; // gets the second line from file. //##### FOR ACCOUNT BRANCH CONTROL. lines = lines.Skip(2).ToArray(); //######################################################## SET Control. SubsidyControl subsidyControl = new SubsidyControl(); subsidyControl.setSubsidyControl(firstLine); SubsidySsoAccountBranchControl accountBranchControl = new SubsidySsoAccountBranchControl(); accountBranchControl.setSubsidySsoAccountBranchControl(secondLine); XmlElement documentHeader = this.createDocumentHeader(xmlDoc, subsidyControl); // SET HEADER. XmlElement documentDetail = xmlDoc.CreateElement(string.Empty, "DocumentDetail", string.Empty); XmlElement documentPartyInformation = this.createDocumentPartyInformation(xmlDoc, subsidyControl); // SET PartyInformation. XmlElement documentEmployerInformation = this.createDocumentEmployerInformation(subsidyControl); // SET EmployerInformation. XmlElement documentSubsidyInformation = this.createDocumentSubsidyInformation(subsidyControl, accountBranchControl, lines); // SET SubsidyInformation. XmlElement documentPaymentInformation = this.createDocumentPaymentInformation(subsidyControl); // SET PaymentInformation. documentDetail.AppendChild(documentPartyInformation); documentDetail.AppendChild(documentDetail.OwnerDocument.ImportNode(documentEmployerInformation, true)); documentDetail.AppendChild(documentDetail.OwnerDocument.ImportNode(documentSubsidyInformation, true)); documentDetail.AppendChild(documentDetail.OwnerDocument.ImportNode(documentPaymentInformation, true)); elementBody.AppendChild(documentHeader); elementBody.AppendChild(documentDetail); //######################################################## END SET Control. string pathSaveXml = formModel.server_path_xml; try { //string xmlFileName = pathSaveXml + "/" + formModel.server_file_name.Split('.')[0] + ".xml"; //string xmlFileName = formModel.server_file_name.Split('.')[0] + ".xml"; //###################################### SET SsoClass. ssoClass.SEND_STATUS = "0"; ssoClass.SEND_RESPONSE = ""; string inv_no = ssoClass.getSsoInvNo(); ssoClass.XML_PATH = "XML_SEND/1/" + DateTime.Now.ToString("yyyy_MM"); ssoClass.XML_NAME = ssoClass.generateXmlFileName(); ssoClass.insertDataSsoDataSend(); //ssoClass.XML_NAME = xmlFileName; string xmlFilePathToSso = formModel.server_path_plugins + "/" + ssoClass.XML_PATH; if (!Directory.Exists(xmlFilePathToSso)) { Directory.CreateDirectory(xmlFilePathToSso); } xmlDoc.Save(formModel.server_path_xml + "/" + ssoClass.XML_NAME); xmlDoc.Save(xmlFilePathToSso + "/" + ssoClass.XML_NAME); string appPath = formModel.server_path_send_exe; //ProcessStartInfo processInfo = new ProcessStartInfo(appPath); //Process process = Process.Start(processInfo); string arr = ssoClass.REF_NO_TEXT + "| " + inv_no + "| " + ssoClass.XML_PATH + "/" + ssoClass.XML_NAME; const string argsSeparator = "|"; string args = string.Join(argsSeparator, arr); Process.Start(appPath, args.Replace(" | ", " ")); //string url = WebConfigurationManager.AppSettings["GENiusWebServiceCoreData"]; //HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url+ "/sendDataToSSO_Subsidy_1_10"); //Debug.WriteLine("xxxxxxxxxx"); } catch (Exception ex) { Debug.WriteLine(ex); return(false); } return(true); } catch (Exception ex) { Debug.WriteLine(ex); return(false); } }
public bool sendDataXmlToSSO(F_SSO_SendDataForm formModel) { //XmlDocument xmlDoc = new XmlDocument(); //xmlDoc.LoadXml(formModel.server_path_xml); string url = System.Configuration.ConfigurationManager.AppSettings.Get("GENiusWebServiceCoreData"); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); webRequest.ContentType = "text/xml; charset=utf-8"; webRequest.Method = "POST"; XmlDocument soapEnvelopeXml = CreateSoapEnvelope(); using (Stream stream = webRequest.GetRequestStream()) { soapEnvelopeXml.Save(stream); } HttpWebResponse webResponse = null; webResponse = (HttpWebResponse)webRequest.GetResponse(); Stream reader = null; reader = webResponse.GetResponseStream(); StreamReader sreader = new StreamReader(reader); string result = sreader.ReadToEnd(); XmlDocument xml = new XmlDocument(); xml.LoadXml(result); // suppose that myXmlString contains "<Names>...</Names>" //XmlNodeList xmlList = root.SelectNodes("//getReturnFromSSo/GetReturnFromSSo"); XmlNodeList xmlList = xml.GetElementsByTagName("GetReturnFromSSo"); Debug.WriteLine(xmlList[0]["DATETIME"].InnerText); //Debug.WriteLine(root.GetElementsByTagName("getReturnFromSSo").Count); //Debug.WriteLine(xnList.Count); /* * foreach (XmlNode xmlNode in xmlList) { * Debug.WriteLine(xmlNode["DATETIME"].InnerText); * } */ return(true); //XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable); //nsmgr.AddNamespace("tempuri", "http://tempuri.org/"); //XmlNodeList xmlNodeList = xml.SelectNodes("GetReturnFromSSo"); //var unwrappedResponse = xml.Descendants((XNamespace)"http://schemas.xmlsoap.org/soap/envelope/" + "Body").First().FirstNode(); //Debug.WriteLine( "----->"+xml.SelectSingleNode("getService_SSO_1_10Response", nsmgr) ); //Debug.WriteLine(xmlNodeList.Count); //XmlDocument xmlTest = new XmlDocument(); //xmlTest.LoadXml(result); // suppose that myXmlString contains "<Names>...</Names>" //XmlElement root = xmlTest.DocumentElement; //XmlNamespaceManager nameSpace = new XmlNamespaceManager(xmlTest.NameTable); //nameSpace.AddNamespace("", "http://tempuri.org/"); //xml.SelectSingleNode(); //XmlNode xmlNodeList = xml.SelectSingleNode("/STATUS"); /* * foreach (XmlNode node in xmlNodeList) { * Debug.WriteLine(node["STATUS"].InnerText); * } * Debug.WriteLine(xmlNodeList); * * XmlNodeList xnList = xml.SelectNodes("/Names/Name"); * foreach (XmlNode xn in xnList) { * string firstName = xn["FirstName"].InnerText; * string lastName = xn["LastName"].InnerText; * Console.WriteLine("Name: {0} {1}", firstName, lastName); * } */ //return result; // return ""; /* * string url = System.Configuration.ConfigurationManager.AppSettings.Get("GENiusWebServiceCoreData"); * HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); * * try { * WebResponse response = request.GetResponse(); * using (Stream responseStream = response.GetResponseStream()) { * StreamReader reader = new StreamReader(responseStream, Encoding.UTF8); * return reader.ReadToEnd(); * } * } * catch (Exception ex) { * Debug.WriteLine(ex); * return "{error:false}"; * } */ }
public bool transferDataXmlToSSO(F_SSO_SendDataForm formModel) { return(false); }