//Json文件加载 private void JsonLoad(string path_name, CRSpline crSpline, ref bool is_right, Transform parent_trans) { string filePath = MotionPara.taskRootPath + MotionPara.taskName + "/PathControl.json"; if (File.Exists(filePath)) { JsonOperator jsonOp = new JsonOperator(); DataTable jsonTable = jsonOp.JsonReader(filePath, path_name); if (jsonTable == null) { Debug.LogError(path_name + ", 该路径名称不存在!"); return; } GameObject loadEmpty = new GameObject(); loadEmpty.name = "JsonLoad_empty"; loadEmpty.transform.parent = parent_trans; for (int i = 0; i < jsonTable.Rows.Count; i++) { loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString()); loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString()); crSpline.controlPoints.Add(loadEmpty.transform.position); crSpline.rotationList.Add(loadEmpty.transform.eulerAngles); crSpline.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString())); } GameObject.DestroyImmediate(loadEmpty); } else { Debug.LogError(filePath + ", 该文件不存在!"); } }
/// <summary> /// 挂号试算 /// </summary> /// <param name="transType"></param> /// <param name="transVersion"></param> /// <param name="verifyCode"></param> /// <param name="serNum"></param> /// <param name="transBody"></param> /// <returns></returns> public static T RegTrial <T>(string transType, string transVersion, string verifyCode, string serNum, object transBody) { var serialNumber = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + serNum; HealthMessage healthMessage = new HealthMessage() { transTime = DateTime.Now.ToString("yyyyMMddHHmmss:fff"), transType = transType, transReturnCode = "", transReturnMessage = "", transVersion = transVersion, serialNumber = serialNumber, cardArea = "440300", hospitalCode = "HZS10", operatorCode = "jeff", operatorName = "松下乘凉", operatorPass = "******", transBody = transBody, transChannel = "10", verifyCode = verifyCode, extendDeviceId = "", extendUserId = "", extendSerialNumber = "" }; var obj = PostData(JsonOperator.JsonSerialize(healthMessage)); return(JsonOperator.JsonDeserialize <T>(obj)); }
public void Buisnesslogic_SerializeExportFailed() { Exception ex_returnval = null; Tour Tour1 = new Tour(null, "Weite Runde", "abc", "Illmitz", "Podersdorf", 20); Tourlog TL1 = new Tourlog(-1, DateTime.Now, "Very Nice", 10, 120, 3, 3.34, 4, 200, 40, 3.5); Tour Tour2 = new Tour(null, "Weite Runde2", "abc", "Illmitz", "Podersdorf", 20); ObservableCollection <Tourlog> Tourloglist = new ObservableCollection <Tourlog>(); ObservableCollection <Tour> Tourlog = new ObservableCollection <Tour>(); Tourloglist.Add(TL1); Tour1.Tourlogs = Tourloglist; Tourlog.Add(Tour1); Tourlog.Add(Tour2); try { JsonOperator.Export(Tourlog, @"Z:\tmp"); } catch (Exception e) { ex_returnval = e; } Assert.AreEqual(typeof(DirectoryNotFoundException), ex_returnval.GetType()); Assert.Pass(); }
private static Task HandleExceptionAsync(HttpContext context, int statusCode, string message) { var data = new { code = statusCode.ToString(), is_success = false, msg = message }; var result = JsonOperator.JsonSerialize(new { data }); context.Response.ContentType = "application/json;charset=utf-8"; return(context.Response.WriteAsync(result)); }
public void SerializeShouldSuccess() { JsonSampleModel model = new JsonSampleModel { ID = 1, Name = "张三", RegTime = DateTimeOffset.Now, IsOnline = true, Status = JsonSampleStatus.Activated, TagId = null }; var json = JsonOperator.ToJson <JsonSampleModel>(model); Assert.NotNull(json); }
public void DeserializeShouldSuccess() { string json = "{\"ID\":1,\"Name\":\"\u5F20\u4E09\",\"RegTime\":\"2019-11-01T10:54:05.8940775+08:00\",\"IsOnline\":true,\"Status\":1,\"TagId\":null}"; var model = JsonOperator.ToObject <JsonSampleModel>(json); Assert.NotNull(model); Assert.True(model.ID == 0); Assert.Null(model.TagId); }
public void ParseShouldSuccess() { using (var stream = File.OpenRead("Files/Sample.json")) using (var result = JsonOperator.Parse(stream)) { var root = result.RootElement; Assert.NotNull(result); Assert.True(root.GetProperty("menu").GetProperty("id").GetString() == "file"); } }
public void Execute(object?parameter) { FolderBrowserDialog tmp = new FolderBrowserDialog(); if (tmp.ShowDialog() == DialogResult.OK) { MessageBox.Show(tmp.SelectedPath); JsonOperator.Export(__mainviewmodel.Tourlist, tmp.SelectedPath); } }
public void ToObject_WithExpectedParameters() { // arrange var fakeUser = GetFakeUser(); // act var result = JsonOperator.ToJson(fakeUser); // assert Assert.NotNull(result); }
public void Execute(object?parameter) { OpenFileDialog tmp = new OpenFileDialog(); if (tmp.ShowDialog() == DialogResult.OK) { string filePath = tmp.FileName; MessageBox.Show(filePath); JsonOperator.Import(filePath); __mainviewmodel.Tourlist = Mainlogic.UpdateTours(); } }
public void ToJson_WithExpectedParameters() { // arrange string fakeUserJson = "{\"Id\":1,\"Name\":\"Jack\",\"RegTime\":\"2019 - 03 - 20T16: 30:50\",\"IsDelete\":false}"; // act var result = JsonOperator.ToObject <User>(fakeUserJson); // assert Assert.NotNull(result); Assert.True(result.Id == 1); }
private void AnalysePathes(IList<string> filePathes) { foreach (var item in filePathes) { var jfi = new JsonFileItem(); jfi.Id = Guid.NewGuid().ToString(); jfi.Path = item; if (!FileHelper.ExistFile(item)) { jfi.HasError = true; jfi.ErrorMessage += "文件不存在\r\n"; this.JsonFileList.Add(jfi); continue; } if(Path.GetExtension(item)!=".json") { continue; } if (this.JsonFileList.FirstOrDefault(x => x.Path == item) != null) { jfi.HasError = true; jfi.ErrorMessage += "已经存在\r\n"; continue; //this.JsonFileList.Add(jfi); } jfi.Name = GetPathName(jfi.Path); GetInstaceInfo(jfi.Name, jfi); jfi.NameAsPara = jfi.Name; //jfi.Order = 0; try { jfi.Content = FileHelper.ReadFile(jfi.Path); JsonOperator jo = new JsonOperator(); jo.SetJsonToItemList(jfi.Content); jfi.JsonItems = jo.JsonItemList; } catch (Exception ex) { jfi.HasError = true; jfi.ErrorMessage = ex.Message; } this.JsonFileList.Add(jfi); } }
private void SaveUpdatedFiles(List<JsonFileItem> selected) { var jo = new JsonOperator(); foreach (JsonFileItem item in selected) { //jo.SetAsModel(model.JsonItems, item.JsonItems); jo.JsonItemList = item.JsonItems; var newJson = jo.SetToJson(); var x = JsonHelper.ConvertJsonString(newJson); var fileName = PathHelper.GetWholeFileName(item.Path); var path = $"{SavedFolder}\\{fileName}"; FileHelper.SaveFile(path, x); } }
private static Task CustomResponseWriter(HttpContext context, HealthReport healthReport) { context.Response.ContentType = "application/json"; var result = JsonOperator.ToJson(new { status = healthReport.Status.ToString(), errors = healthReport.Entries.Select(e => new { key = e.Key, value = e.Value.Status.ToString() }) }); return(context.Response.WriteAsync(result)); }
public void Buisnesslogic_SerializeExport() { Tour Tour1 = new Tour(null, "Weite Runde", "abc", "Illmitz", "Podersdorf", 20); Tourlog TL1 = new Tourlog(-1, DateTime.Now, "Very Nice", 10, 120, 3, 3.34, 4, 200, 40, 3.5); Tour Tour2 = new Tour(null, "Weite Runde2", "abc", "Illmitz", "Podersdorf", 20); ObservableCollection <Tourlog> Tourloglist = new ObservableCollection <Tourlog>(); ObservableCollection <Tour> Tourlog = new ObservableCollection <Tour>(); Tourloglist.Add(TL1); Tour1.Tourlogs = Tourloglist; Tourlog.Add(Tour1); Tourlog.Add(Tour2); JsonOperator.Export(Tourlog, @"E:\tmp"); Assert.IsTrue(File.Exists(@"E:\tmp\Tours.json")); }
public void Buisnesslogic_DeserializeTourJson() { Tour Tour1 = new Tour(null, "Weite Runde", "abc", "Illmitz", "Podersdorf", 20); Tourlog TL1 = new Tourlog(-1, DateTime.Now, "Very Nice", 10, 120, 3, 3.34, 4, 200, 40, 3.5); ObservableCollection <Tourlog> Tourloglist = new ObservableCollection <Tourlog>(); ObservableCollection <Tour> Tourlog = new ObservableCollection <Tour>(); Tourloglist.Add(TL1); Tour1.Tourlogs = Tourloglist; Tourlog.Add(Tour1); ObservableCollection <Tour> returnval = JsonOperator.DeserializeTours(@"E:\tmp\Tours.json"); Assert.AreEqual(returnval[0].Name, Tourlog[0].Name); }
private bool SetFragment(string str) { try { str = $"{{{str}}}"; Fragment = new List<JsonItem>(); JsonOperator jo = new JsonOperator(); jo.SetJsonToItemList(str); Fragment = jo.JsonItemList; return true; } catch { MessageBox.Show("转换失败"); } return false; }
public void Buisnesslogic_SerializeTourJson() { Tour Tour1 = new Tour(null, "Weite Runde", "abc", "Illmitz", "Podersdorf", 20); Tourlog TL1 = new Tourlog(-1, DateTime.Now, "Very Nice", 10, 120, 3, 3.34, 4, 200, 40, 3.5); ObservableCollection <Tourlog> Tourloglist = new ObservableCollection <Tourlog>(); ObservableCollection <Tour> Tourlog = new ObservableCollection <Tour>(); Tourloglist.Add(TL1); Tour1.Tourlogs = Tourloglist; Tourlog.Add(Tour1); string returnval = JsonOperator.SerializeTours(Tourlog); string expt = JsonSerializer.Serialize(Tourlog); Assert.AreEqual(expt, returnval); }
public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { if (commandId == CefMenuCommand.AddToDictionary) { Entry entry = new Entry(); try { var temp = File.ReadAllText(FilePaths.TemporaryFiles.LastWord); var index = temp.IndexOf('/'); entry.Word = temp.Substring(0, index); // "good/güzel" lenght == 9 , temp.IndexOf('/') == 5 entry.Meaning = temp.Substring(index + 1, temp.Length - 1 - index); } catch (DirectoryNotFoundException e) { MessageBox.Show("Eklenecek Dizin Bulunamadı \n" + "Hata Mesajı:" + e.Message); return(false); } catch (FileNotFoundException) { MessageBox.Show("Bu Sayfayı Ekleyemezsin"); return(false); } var userDictionary = new JsonOperator(FilePaths.PermanentFiles.UserDictionary); var words = userDictionary.LoadFile(); if (words.All(x => x.Word != entry.Word)) { entry.Date = DateTime.Now.ToString(); userDictionary.AppendFile(entry.ToString()); } else { MessageBox.Show("Kelime Zaten Sözlüğe Eklenmmiş!"); } return(true); } return(false); }
/// <summary> /// 写日志 /// </summary> /// <param name="invocation"></param> /// <param name="result"></param> public void WriteLogInfo(IInvocation invocation, object result) { try { //接口方法名称 string methodName = $"{invocation.MethodInvocationTarget.DeclaringType.FullName}.{invocation.Method.Name}"; StringBuilder builder = new StringBuilder(); var context = HttpContext.Current; builder.AppendFormat("【接口名】{0}", methodName); builder.AppendFormat("\r\n\r\n【IP地址】{0}", context == null ? string.Empty : context.Connection.RemoteIpAddress.ToString()); builder.AppendFormat("\r\n\r\n【参数】{0}", JsonOperator.JsonSerialize(invocation.Arguments)); builder.AppendFormat("\r\n\r\n【返回值】{0}", JsonOperator.JsonSerialize(result));//invocation.ReturnValue Logger.Error(builder.ToString()); } catch (Exception ex) { AbpLogHelper.Error(ex); } }
public string TradingRefund(request <Entity.SRequest.JY002> tradingrefund) { var ybsssno = commKeyBLL.GetYBNO(); var ybSno = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + ybsssno; var getVerifyCodeResult = JsonOperator.JsonDeserialize <Entity.SResponse.getVerifyCode>(HttpHelper.Post("http://192.168.88.134:8300/YBDLL/domain/getVerifyCode", JsonOperator.JsonSerialize(new getVerifyCode() { inParam = "JY002|" + ybSno + "|HZS10|" }), Encoding.UTF8, 1)); if (getVerifyCodeResult.resultCode != 0) { return(null); } var version = getVerifyCodeResult.outParam.Split("|")[2]; var verify = getVerifyCodeResult.outParam.Split("|")[0] + "|" + getVerifyCodeResult.outParam.Split("|")[1]; Entity.SRequest.JY002 jY002 = new JY002() { akc190 = tradingrefund.model.akc190, bke384 = tradingrefund.model.bke384 }; var result = HealthInsuranceHelper.RegTrial <BaseMedInsurance <Entity.SResponse.JY002> >("JY002", version, verify, ybsssno.ToString(), jY002); if (result.transReturnCode == "0" || result.transReturnCode == "00000000") { return(XMLHelper.XmlSerialize(new response <Entity.SResponse.JY002>() { model = new Entity.SResponse.JY002() { resultCode = 0, resultMessage = JsonOperator.JsonSerialize(result) } })); } else { return(RsXmlHelper.ResXml(-1, JsonOperator.JsonSerialize(result))); } }
/// <summary> /// 异常处理 /// </summary> /// <param name="context"></param> public void OnException(ExceptionContext context) { if (context.ExceptionHandled == false) { var result = new Result() { Code = ResponseStatus.HandleError, Time = DateTime.Now, Message = context.Exception.Message }; context.Result = new ContentResult { Content = JsonOperator.JsonSerialize(result), StatusCode = StatusCodes.Status200OK, ContentType = "application/json" }; } context.ExceptionHandled = true; //异常已处理了 }
private void CopyFromModelDele(object obj) { var paras = (List<object>)obj; var model = (JsonFileItem)paras[0]; var selected = (IList<JsonFileItem>)paras[1]; var jo = new JsonOperator(); foreach (var item in selected) { jo.SetAsModel(model.JsonItems, item.JsonItems); var newJson = jo.SetToJson(); var fileName = PathHelper.GetWholeFileName(item.Path); var path = $"{SavedFolder}\\{fileName}"; FileHelper.SaveFile(path, newJson); } this.BeginInvoke(new DeleParaNone(CopyFromModelAction)); base.EndExecute(null); }
private void SearchBox_TextChanged(object sender, EventArgs e) { var str = searchBox.Text; if (!isListing) { str = str.Replace("\n", String.Empty); str = str.Replace("\r", String.Empty); str = str.Replace("\t", String.Empty); searchBox.Text = str; BringToFront(); Show(); textBoxTimer.Stop(); textBoxTimer.Start(); } else { str = str.Replace("\n", String.Empty); str = str.Replace("\r", String.Empty); str = str.Replace("\t", String.Empty); var jsonOperator = new JsonOperator(FilePaths.PermanentFiles.UserDictionary); List <Entry> entries = jsonOperator.LoadFile(); var closeWords = new SortedDictionary <int, Entry>(); foreach (var entry in entries) { var word = entry.Word; var distance = WordsTable.LevenshteinDistance(word, str); if (distance < 3 && word.Contains(str)) { closeWords.Add(distance, entry); } } // TODO: burayı biraz daha geliştir. aranan kelimeyi bulsada listelememe ihtimali var wordsTable.LoadSearchedWord(closeWords); } }
private void SaveFilesDele(object obj) { var selected = (List<JsonFileItem>)obj; var jo = new JsonOperator(); foreach (JsonFileItem item in selected) { //jo.SetAsModel(model.JsonItems, item.JsonItems); jo.JsonItemList = item.JsonItems; var newJson = jo.SetToJson(); var x = JsonHelper.ConvertJsonString(newJson); var fileName = PathHelper.GetWholeFileName(item.Path); var path = $"{SavedFolder}\\{fileName}"; FileHelper.SaveFile(path, x); } this.BeginInvoke(new DeleParaNone(CopyFromModelAction)); base.EndExecute(null); }
//Json写入 private void JsonWirter() { string dirPath = MotionPara.taskRootPath + MotionPara.taskName; string filePath = dirPath + "/PathControl.json"; string tempDir = Application.dataPath + "/_TempExcel"; string tempPath = tempDir + "/TempPathInfo.json"; if (Directory.Exists(dirPath)) { //移动到起点 _target.transform.position = _target.nodes[0]; if (_target.camera != null) { _target.CameraView = _target.cameraViewList[0]; } if (_target.isCamera && _target.camera != null) { if (_target.isLookAt && _target.lookAt != null) { _target.transform.LookAt(_target.lookAt); } else { _target.transform.eulerAngles = _target.rotationList[0]; } } else { _target.transform.eulerAngles = _target.rotationList[0]; } JsonOperator jsonOp = new JsonOperator(); string[] nameArray = new string[] { "POSITION", "EULERANGLE", "VIEW" }; string[,] contentArray = new string[nameArray.Length, _target.nodeCount]; GameObject writerEmpty = new GameObject(); writerEmpty.name = "JsonWriter_empty"; writerEmpty.transform.parent = _target.transform; for (int i = 0; i < _target.nodeCount; i++) { //位置信息写入 writerEmpty.transform.position = _target.nodes[i]; writerEmpty.transform.eulerAngles = _target.rotationList[i]; contentArray[0, i] = writerEmpty.transform.localPosition.x + "," + writerEmpty.transform.localPosition.y + "," + writerEmpty.transform.localPosition.z; //角度信息写入 contentArray[1, i] = writerEmpty.transform.localEulerAngles.x + "," + writerEmpty.transform.localEulerAngles.y + "," + writerEmpty.transform.localEulerAngles.z; //视域信息写入 contentArray[2, i] = _target.cameraViewList[i].ToString(); } GameObject.DestroyImmediate(writerEmpty); jsonOp.JsonWriter(filePath, _target.pathName, nameArray, contentArray, false); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } jsonOp.JsonWriter(tempPath, _target.pathName, nameArray, contentArray, false); Debug.Log(_target.pathName + "---路径写入成功!"); } else { Debug.LogError(dirPath + ", 该路径不存在,请在运行模式下保存!"); } }
private void ExitButton_Click(object sender, EventArgs e) { ActiveControl = null; JsonOperator.DeleteTemporaryFiles(); Close(); }
private void FetchData() { var uri = new Uri("https://tureng.com/tr/turkce-ingilizce/"); var content = ""; var inputText = searchBox.Text; var meaning = ""; try { var html = ""; var css = ""; HtmlNode node; switch (_dictionary) { case WebDictionary.Tureng: uri = new Uri("https://tureng.com/tr/turkce-ingilizce/" + inputText); var turengBot = new Bot(uri, new WebClient()); node = turengBot.SelectNode("//*[@id='englishResultsTable']"); html = node.OuterHtml.Replace("href=", ""); meaning = turengBot.SelectNode("//*[@id='englishResultsTable']/tr[4]/td[4]/a").InnerHtml; css = "\n<style type=\"text/css\">\n" + Properties.Resources.css + "\n</style> "; content = html + css; break; case WebDictionary.MerriamWebster: uri = new Uri("https://www.merriam-webster.com/dictionary/" + inputText); var merriamBot = new Bot(uri, new WebClient()); merriamBot.ClearDocument("//div[@class='anchor-list']", "//div[@id='synonyms-anchor']", "//a[@class='widget-button thesaurus hoverable']", "//span[@id='in-sentences']", "//span[@id='on-web']", "//div[@class='on-web']", "//div[@class='widget learn_more']", "//div[@class='widget more-from']", "//div[@class='widget seen-and-heard-block']"); node = merriamBot.SelectNode("//div[@id='left-content']"); html = node.OuterHtml.Replace("href=", ""); css = "\n<style type=\"text/css\">\n" + Properties.Resources.merriamcss + "\n</style> "; content = html + css; break; case WebDictionary.Cambridge: //cambridge bot uri = new Uri("https://dictionary.cambridge.org/tr/sözlük/ingilizce-türkçe/" + inputText); var cambridgeBot = new Bot(uri, new WebClient()); cambridgeBot.ClearDocument("//div[@class='share rounded js-share']", "//h3[@class='h4 txt-block txt-block--alt']", "//div[@class='xref see_also margin-bottom']", "//div[@class='item']"); node = cambridgeBot.SelectNode( "//div[@class='di $ entry-body__el entry-body__el--smalltop clrd js-share-holder']"); html = node.OuterHtml.Replace("href=", ""); css = "\n<style type=\"text/css\">\n" + Properties.Resources.cambridgecss + "\n</style> "; content = html + css; break; } JsonOperator fileOperator; if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(css + html, uri.AbsoluteUri); fileOperator = new JsonOperator(FilePaths.TemporaryFiles.LastPage); fileOperator.SaveToFile(content); }); } meaning = WebUtility.HtmlDecode(meaning); fileOperator = new JsonOperator(FilePaths.TemporaryFiles.LastWord); fileOperator.SaveToFile(inputText + "/" + meaning); } catch (WebException exception) { content = Properties.Resources.errorpage; content = content.Replace("info", "Internet yok yada baglanti kurulamadi"); content = content.Replace("inserterrormessagehere", uri.AbsoluteUri + "bulunamadi"); content = content.Replace("insertexceptionhere", exception.ToString()); if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(content); }); } else { chromWebBrowser.LoadHtml(content); } } catch (NullReferenceException exception) { content = Properties.Resources.errorpage; content = content.Replace("info", "Aradidigin Kelimeyi Bulamadim"); content = content.Replace("inserterrormessagehere", "Loglar " + FilePaths.PermanentFiles.Logs + " 'a kaydedildi."); content = content.Replace("insertexceptionhere", "Bir Seferlik Arama Butonuna Basarak Ara"); LogOperator.Log(exception); if (chromWebBrowser.InvokeRequired) { chromWebBrowser.Invoke((MethodInvoker) delegate { chromWebBrowser.LoadHtml(content); }); } else { chromWebBrowser.LoadHtml(content); } } }
//Json数据提取 private void JsonLocationSet(string nodeName, string column_name) { nodeName = nodeName.ToUpper(); //检查是否存在以该数模命名的文件夹 string locationPath = MotionPara.taskRootPath + MotionPara.taskName + "/"; string subPath = ""; if (nodeName.StartsWith("C")) { subPath = "C/"; } else if (nodeName.StartsWith("Y")) { subPath = "Y/"; } else if (nodeName.StartsWith("Z")) { subPath = "Z/"; } else { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } //检查数字是否正确 int fileNum = 0; try { fileNum = int.Parse(nodeName.Substring(1)); } catch { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } string filePreName = nodeName.Substring(0, 1) + fileNum.ToString(); //Json处理类 JsonOperator jsonOp = new JsonOperator(); if (File.Exists(locationPath + subPath + filePreName + "Location.json")) { DataTable posTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "LOCATION" + column_name); Transform objTransform = null; bool isRight = true; BaseCompute baseCal = new BaseCompute(); for (int i = 0; i < posTable.Rows.Count; i++) { try { objTransform = GameObject.Find((string)posTable.Rows[i][0].ToString()).transform; } catch { UnityEngine.Debug.LogError((string)posTable.Rows[i][0].ToString() + ",该物体在当前场景中不存在,请确认!"); return; } objTransform.position = baseCal.Vector3Conversion((string)posTable.Rows[i][1].ToString(), ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)posTable.Rows[i][1].ToString() + ",位置向量转化错误,请检查!"); return; } objTransform.eulerAngles = baseCal.Vector3Conversion((string)posTable.Rows[i][2].ToString(), ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)posTable.Rows[i][2].ToString() + ",角度向量转化错误,请检查!"); return; } } if (File.Exists(locationPath + subPath + filePreName + "Location.json")) { DataTable speTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "SPECIAL" + column_name); string speName = ""; string speType = ""; string speValue = ""; for (int i = 0; i < speTable.Rows.Count; i++) { speName = (string)speTable.Rows[i][0].ToString(); speType = (string)speTable.Rows[i][1].ToString(); speValue = (string)speTable.Rows[i][2].ToString(); SetSpecialObjInfo(speName, speType, speValue, ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)speTable.Rows[i][0].ToString() + ",该处信息有误,请检查!"); return; } } } } else { UnityEngine.Debug.LogError(locationPath + subPath + filePreName + "Location.json,该文件不存在,请确认!"); return; } }
public string GetMZInsurance(request <getMZInsurance> getMZInsurance) { if (getMZInsurance == null) { return(RsXmlHelper.ResXml(-1, "XML格式错误")); } var ptInfo = ptInfoBLL.GetPtInfoByCardNo("", Convert.ToInt32(getMZInsurance.model.patCardType), getMZInsurance.model.patCardNo); if (ptInfo == null) { return(RsXmlHelper.ResXml(-1, "患者信息为空")); } var dept = sysDeptBLL.GetDeptByCode(getMZInsurance.model.deptCode); var doctor = sysUserinfoBLL.GetRDoctor(getMZInsurance.model.doctorCode); var regInfo = reginfoBLL.Get(x => x.regid == Convert.ToInt32(getMZInsurance.model.mzFeeId)); if (regInfo == null) { return(RsXmlHelper.ResXml(-1, "挂号信息为空")); } var orderInfoList = orderInfoBLL.Get(getMZInsurance.model.mzFeeId, getMZInsurance.model.mzBillId); var orderFeedetails = orderfeedetailBLL.GetOrder_Feedetails(orderInfoList.Select(x => x.billid).ToArray()); var ybsssno = commKeyBLL.GetYBNO(); var ybSno = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + ybsssno; FY001 fY001 = new FY001() { akc190 = "HZS10" + regInfo.mzno, bke384 = ybSno, listsize = orderFeedetails.Count, }; fY001.inputlist = new List <inputlistfy001>(); foreach (var order_Feedetail in orderFeedetails) { if (order_Feedetail.itemtype == "中草药" || order_Feedetail.itemtype == "中成药" || order_Feedetail.itemtype == "西药") { var commMed = commMedBLL.Get(x => x.itemid == order_Feedetail.itemid); fY001.inputlist.Add(new inputlistfy001() { aae072 = order_Feedetail.billid.ToString(), bkc369 = "1", bkf500 = order_Feedetail.bdfeeid.ToString(), ake001 = commMed.ybcode, ake002 = commMed.itemname, bkm017 = commMed.stdcode, ake005 = commMed.itemid, ake006 = commMed.itemname, akc225 = order_Feedetail.prices.ToString(), akc264 = order_Feedetail.totalprices.ToString(), aka067 = commMed.bscunit, aka070 = commYbCodeBLL.GetYbCodeByName("AKA070", commMed.dosage), aka074 = commMed.spec, akc226 = (Convert.ToInt32(order_Feedetail.total) * Convert.ToInt32(order_Feedetail.dppack)).ToString(), akc271 = Convert.ToDateTime(order_Feedetail.addtime).ToString("yyyyMMdd"), bkc320 = doctor.ybno }); } else { var commFee = new comm_fee(); var isPackage = commFeeBLL.IsPackage(x => x.itemid == order_Feedetail.itemid && x.costtype == "5"); if (isPackage) { commFee = commFeeBLL.Get(Convert.ToInt32(order_Feedetail.itemid)); } else { commFee = commFeeBLL.Get(x => x.itemid == order_Feedetail.itemid && x.costtype == "5"); } fY001.inputlist.Add(new inputlistfy001() { aae072 = order_Feedetail.billid.ToString(), bkc369 = "1", bkf500 = order_Feedetail.bdfeeid.ToString(), ake001 = commFee.scode, ake002 = commFee.itemname, bkm017 = commFee.scode, ake005 = commFee.itemid, ake006 = commFee.itemname, ala026 = "", aka070 = "", aka074 = order_Feedetail.spec, akc225 = decimal.Round(Convert.ToDecimal(order_Feedetail.prices), 2).ToString(), akc226 = Convert.ToInt32(order_Feedetail.total).ToString(), akc264 = decimal.Round(Convert.ToDecimal(order_Feedetail.totalprices), 2).ToString(), aka067 = order_Feedetail.dpunit, akc271 = Convert.ToDateTime(order_Feedetail.addtime).ToString("yyyyMMdd"), bkc320 = doctor.ybno, cke400 = "" }); } } FY004 fY004 = new FY004() { akc190 = "HZS10" + regInfo.mzno, aka130 = "11", bkc320 = doctor.ybno, ckc350 = doctor.username, aka030 = "12", akc264 = Math.Round(Convert.ToDecimal(orderInfoList.Sum(x => x.totprice)), 2).ToString(), ckc601 = "0", bke384 = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + ybsssno }; var getVerifyCodeResult = JsonOperator.JsonDeserialize <Entity.SResponse.getVerifyCode>(HttpHelper.Post("http://192.168.88.134:8300/YBDLL/domain/getVerifyCode", JsonOperator.JsonSerialize(new getVerifyCode() { inParam = "FY001|" + ybSno + "|HZS10|" }), Encoding.UTF8, 1)); if (getVerifyCodeResult.resultCode != 0 || getVerifyCodeResult.resultCode != 00000000) { return(RsXmlHelper.ResXml(-1, getVerifyCodeResult.resultMsg)); } var version = getVerifyCodeResult.outParam.Split("|")[2]; var verify = getVerifyCodeResult.outParam.Split("|")[0] + "|" + getVerifyCodeResult.outParam.Split("|")[1]; var resultFy001 = HealthInsuranceHelper.RegTrial <BaseMedInsurance <Entity.SResponse.FY001> >("FY001", version, verify, ybsssno.ToString(), fY001); if (resultFy001.transReturnCode != "0" && resultFy001.transReturnCode != "00000000") { return(RsXmlHelper.ResXml(-1, resultFy001.transReturnMessage + JsonOperator.JsonSerialize(fY001) + "出参:" + JsonOperator.JsonSerialize(resultFy001))); } getVerifyCodeResult = JsonOperator.JsonDeserialize <Entity.SResponse.getVerifyCode>(HttpHelper.Post("http://192.168.88.134:8300/YBDLL/domain/getVerifyCode", JsonOperator.JsonSerialize(new getVerifyCode() { inParam = "FY004|" + ybSno + "|HZS10|" }), Encoding.UTF8, 1)); var result = HealthInsuranceHelper.RegTrial <BaseMedInsurance <Entity.SResponse.FY004> >("FY004", version, verify, ybsssno.ToString(), fY004); if (result.transReturnCode == "0" || result.transReturnCode == "00000000") { feeTrialBLL.Add(new fee_trial() { akc190 = fY004.akc190, aka130 = fY004.aka130, bkc320 = fY004.bkc320, ckc350 = fY004.ckc350, aka030 = fY004.aka030, akc264 = Convert.ToDecimal(fY004.akc264), ckc601 = fY004.ckc601, bke384 = fY004.bke384 }); return(XMLHelper.XmlSerialize(new response <Entity.SResponse.getMZInsurance>() { model = new Entity.SResponse.getMZInsurance() { resultCode = 0, mzFeeId = regInfo.regid, mzBillId = string.Join(",", orderInfoList.Select(x => x.billid)), time = DateTime.Now, SSFeeNo = fY004.akc190, SSSerNum = fY004.bke384, recipeCount = orderInfoList.Count.ToString(), mzCategory = "普通", doctorCode = doctor.userno, doctorName = doctor.username, deptCode = dept.code, deptName = dept.name, payType = "医保", payAmount = result.transBody.akb067.ToString(), accountAmount = result.transBody.akb066.ToString(), medicareAmount = result.transBody.akb068.ToString(), insuranceAmout = (result.transBody.akb068 + result.transBody.akb066).ToString(), totalAmout = result.transBody.akc264.ToString(), akc190 = fY004.akc190, cardArea = result.cardArea, SSInfoNew = JsonOperator.JsonSerialize(result.transBody) } })); } else { return(RsXmlHelper.ResXml(-1, result.transReturnMessage)); } }
public string SettleMZInsurance(request <settleMZInsurance> settleMZInsurance) { if (settleMZInsurance == null) { return(RsXmlHelper.ResXml(-1, "XML格式错误")); } var ptInfo = ptInfoBLL.GetPtInfoByCardNo("", Convert.ToInt32(settleMZInsurance.model.patCardType), settleMZInsurance.model.patCardNo); if (ptInfo == null) { return(RsXmlHelper.ResXml(-1, "XML格式错误")); } var dept = sysDeptBLL.GetDeptByCode(settleMZInsurance.model.deptCode); var doctor = sysUserinfoBLL.GetRDoctor(settleMZInsurance.model.doctorCode); var pt_Info = ptInfoBLL.GetPtInfoByCardNo("", Convert.ToInt32(settleMZInsurance.model.patCardType), settleMZInsurance.model.patCardNo); if (pt_Info == null) { return(RsXmlHelper.ResXml(-1, "患者信息为空")); } var regInfo = reginfoBLL.GetReg_Info(Convert.ToInt32(settleMZInsurance.model.mzFeeId)); var orderInfoList = orderInfoBLL.GetMZOrderInfo(settleMZInsurance.model.mzFeeId, settleMZInsurance.model.mzBillId); if (regInfo == null) { return(RsXmlHelper.ResXml(-1, "挂号信息为空")); } var ybsssno = commKeyBLL.GetYBNO(); var FeeTrail = feeTrialBLL.Get(x => x.bke384 == settleMZInsurance.model.SSSerNo); if (FeeTrail == null && !string.IsNullOrWhiteSpace(FeeTrail.transBody)) { //return RsXmlHelper.ResXml(0, JsonOperator.JsonSerialize(FeeTrail.transBody)); return(XMLHelper.XmlSerialize(new response <FeeSettlement>() { model = new FeeSettlement() { resultCode = 0, resultMessage = FeeTrail.transBody, akc190 = FeeTrail.akc190 } })); } FY005 fY005 = new FY005() { aaz500 = settleMZInsurance.model.socialSecurityNo, bzz269 = string.IsNullOrWhiteSpace(settleMZInsurance.model.patCardPwd) ? "000000" : settleMZInsurance.model.patCardPwd, akc190 = FeeTrail.akc190, aka130 = FeeTrail.aka130, bkc320 = FeeTrail.bkc320, ckc350 = FeeTrail.ckc350, aka030 = FeeTrail.aka030, akc264 = FeeTrail.akc264.ToString(), ckc601 = FeeTrail.ckc601, bke384 = FeeTrail.bke384 }; var ybSno = "HZS10" + DateTime.Now.ToString("yyyyMMdd") + ybsssno; var getVerifyCodeResult = JsonOperator.JsonDeserialize <Entity.SResponse.getVerifyCode>(HttpHelper.Post("http://192.168.88.134:8300/YBDLL/domain/getVerifyCode", JsonOperator.JsonSerialize(new getVerifyCode() { inParam = "FY005|" + ybSno + "|HZS10|" }), Encoding.UTF8, 1)); if (getVerifyCodeResult.resultCode != 0) { return(null); } var version = getVerifyCodeResult.outParam.Split("|")[2]; var verify = getVerifyCodeResult.outParam.Split("|")[0] + "|" + getVerifyCodeResult.outParam.Split("|")[1]; var result = HealthInsuranceHelper.RegTrial <BaseMedInsurance <Entity.SResponse.FY005> >("FY005", version, verify, ybsssno.ToString(), fY005); if (result.transReturnCode == "0" || result.transReturnCode == "00000000") { var resultObj = new Entity.SResponse.getMZInsurance() { resultCode = 0, resultMessage = "", mzFeeId = regInfo.regid, mzBillId = string.Join(",", orderInfoList.Select(x => x.billid)), SSFeeNo = ybSno, SSBillNumber = null, time = DateTime.Now, recipeCount = orderInfoList.Count.ToString(), deptCode = dept.code, doctorCode = doctor.userno, doctorName = doctor.username, payType = "医保", payAmount = result.transBody.akb067.ToString(), totalAmout = orderInfoList.Sum(x => x.totprice).ToString(), akc190 = fY005.akc190, SSInfoNew = JsonOperator.JsonSerialize(result.transBody) }; return(XMLHelper.XmlSerialize(new response <FeeSettlement>() { model = new FeeSettlement() { resultCode = 0, resultMessage = JsonOperator.JsonSerialize(result.transBody), akc190 = fY005.akc190 } })); } else { return(RsXmlHelper.ResXml(-1, result.transReturnMessage + "{" + JsonOperator.JsonSerialize(fY005) + "}")); } }
//Json文件加载 private void JsonLoad(string path_name, CRSpline crSpline, ref bool is_right, Transform parent_trans) { string filePath = MotionPara.taskRootPath + MotionPara.taskName + "/PathControl.json"; if (File.Exists(filePath)) { JsonOperator jsonOp = new JsonOperator(); DataTable jsonTable = jsonOp.JsonReader(filePath, path_name); if (jsonTable == null) { Debug.LogError(path_name + ", 该路径名称不存在!"); return; } GameObject loadEmpty = new GameObject(); loadEmpty.name = "JsonLoad_empty"; loadEmpty.transform.parent = parent_trans; for (int i = 0; i < jsonTable.Rows.Count; i++) { loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString()); loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString()); crSpline.controlPoints.Add(loadEmpty.transform.position); crSpline.rotationList.Add(loadEmpty.transform.eulerAngles); crSpline.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString())); } GameObject.DestroyImmediate(loadEmpty); } else { Debug.LogError(filePath + ", 该文件不存在!"); } }
//Json数据提取 private void JsonLocationSet(string nodeName, string column_name) { nodeName = nodeName.ToUpper(); //检查是否存在以该数模命名的文件夹 string locationPath = MotionPara.taskRootPath + MotionPara.taskName + "/"; string subPath = ""; if (nodeName.StartsWith("C")) { subPath = "C/"; } else if (nodeName.StartsWith("Y")) { subPath = "Y/"; } else if (nodeName.StartsWith("Z")) { subPath = "Z/"; } else { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } //检查数字是否正确 int fileNum = 0; try { fileNum = int.Parse(nodeName.Substring(1)); } catch { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } string filePreName = nodeName.Substring(0, 1) + fileNum.ToString(); //Json处理类 JsonOperator jsonOp = new JsonOperator(); if (File.Exists(locationPath + subPath + filePreName + "Location.json")) { DataTable posTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "LOCATION" + column_name); Transform objTransform = null; bool isRight = true; BaseCompute baseCal = new BaseCompute(); for (int i = 0; i < posTable.Rows.Count; i++) { try { objTransform = GameObject.Find((string)posTable.Rows[i][0].ToString()).transform; } catch { UnityEngine.Debug.LogError((string)posTable.Rows[i][0].ToString() + ",该物体在当前场景中不存在,请确认!"); return; } objTransform.position = baseCal.Vector3Conversion((string)posTable.Rows[i][1].ToString(), ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)posTable.Rows[i][1].ToString() + ",位置向量转化错误,请检查!"); return; } objTransform.eulerAngles = baseCal.Vector3Conversion((string)posTable.Rows[i][2].ToString(), ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)posTable.Rows[i][2].ToString() + ",角度向量转化错误,请检查!"); return; } } if (File.Exists(locationPath + subPath + filePreName + "Location.json")) { DataTable speTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "SPECIAL" + column_name); string speName = ""; string speType = ""; string speValue = ""; for (int i = 0; i < speTable.Rows.Count; i++) { speName = (string)speTable.Rows[i][0].ToString(); speType = (string)speTable.Rows[i][1].ToString(); speValue = (string)speTable.Rows[i][2].ToString(); SetSpecialObjInfo(speName, speType, speValue, ref isRight); if (!isRight) { UnityEngine.Debug.LogError((string)speTable.Rows[i][0].ToString() + ",该处信息有误,请检查!"); return; } } } } else { UnityEngine.Debug.LogError(locationPath + subPath + filePreName + "Location.json,该文件不存在,请确认!"); return; } }
//JASON读取 private void JsonLocationCreate(string nodeName, string column_name, bool cover_flag) { nodeName = nodeName.ToUpper(); //检查是否存在以该数模命名的文件夹 string locationPath = MotionPara.taskRootPath + MotionPara.taskName + "/"; string subPath = ""; if (nodeName.StartsWith("C")) { subPath = "C/"; } else if (nodeName.StartsWith("Y")) { subPath = "Y/"; } else if (nodeName.StartsWith("Z")) { subPath = "Z/"; } else { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } //检查数字是否正确 int fileNum = 0; try { fileNum = int.Parse(nodeName.Substring(1)); } catch { UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!"); return; } string filePreName = nodeName.Substring(0, 1) + fileNum.ToString(); //检验根目录是否存在 if (Directory.Exists(locationPath)) { //Json处理类 JsonOperator jsonOp = new JsonOperator(); ExcelOperator excelOp = new ExcelOperator(); if (File.Exists(locationPath + "ObjectName.xls")) { //首先处理ObjectName文件 DataTable objNameTab = excelOp.ExcelReader(locationPath + "ObjectName.xls", "NAME", "A", "A"); //为Json写入做准备 string[] nameArray = new string[] { "NAME", "POSITION", "EULERANGLES" }; string[,] contentArray = new string[3, objNameTab.Rows.Count]; string objName = ""; string objPosition = ""; string objRotation = ""; Transform objTransform = null; for (int i = 0; i < objNameTab.Rows.Count; i++) { try { objTransform = GameObject.Find((string)objNameTab.Rows[i][0].ToString()).transform; } catch { UnityEngine.Debug.LogError((string)objNameTab.Rows[i][0].ToString() + ",该物体在当前场景中不存在,请确认!"); return; } objName = objTransform.name; objPosition = objTransform.position.x.ToString() + "," + objTransform.position.y.ToString() + "," + objTransform.position.z.ToString(); objRotation = objTransform.eulerAngles.x.ToString() + "," + objTransform.eulerAngles.y.ToString() + "," + objTransform.eulerAngles.z.ToString(); contentArray[0, i] = objName; contentArray[1, i] = objPosition; contentArray[2, i] = objRotation; } jsonOp.JsonWriter(locationPath + subPath + filePreName + "Location.json", "LOCATION" + column_name, nameArray, contentArray, cover_flag); UnityEngine.Debug.Log(filePreName + "Location.json表格LOCATION" + column_name + " sheet生成成功!"); //然后处理SpecialName文件 string speName = ""; string speType = ""; string speValue = ""; if (File.Exists(locationPath + "ObjectName.xls")) { DataTable specialNameTab = excelOp.ExcelReader(locationPath + "ObjectName.xls", "SPECIAL", "A", "B"); if (specialNameTab.Rows.Count > 0) { string[] nameArrayS = new string[] { "NAME", "TYPE", "CONTENT" }; string[,] contentArrayS = new string[3, specialNameTab.Rows.Count]; bool isRight = true; for (int i = 0; i < specialNameTab.Rows.Count; i++) { speName = (string)specialNameTab.Rows[i][0].ToString(); speType = (string)specialNameTab.Rows[i][1].ToString(); speValue = GetSpecialObjInfo(speName, speType, ref isRight); if (!isRight) { return; } else { contentArrayS[0, i] = speName; contentArrayS[1, i] = speType; contentArrayS[2, i] = speValue; } } jsonOp.JsonWriter(locationPath + subPath + filePreName + "Location.json", "SPECIAL" + column_name, nameArrayS, contentArrayS, false); UnityEngine.Debug.Log(filePreName + "Location.json表格SPECIAL" + column_name + " sheet生成成功!"); } } } else { UnityEngine.Debug.LogError(locationPath + "ObjectName.xls,该文件不存在,请确认!"); return; } } else { UnityEngine.Debug.LogError(locationPath + ",该路径不存在,请检查!"); return; } }
//Json文件加载 private void JsonLoad() { string filePath = Application.dataPath + "/_TempExcel/TempPathInfo.json"; if (File.Exists(filePath)) { JsonOperator jsonOp = new JsonOperator(); DataTable jsonTable = jsonOp.JsonReader(filePath, _target.pathName); if (jsonTable == null) { Debug.LogError(_target.pathName + ", 该路径名称不存在!"); return; } //移动到起点 _target.transform.position = _target.nodes[0]; if (_target.camera != null) { _target.CameraView = _target.cameraViewList[0]; } if (_target.isCamera && _target.camera != null) { if (_target.isLookAt && _target.lookAt != null) { _target.transform.LookAt(_target.lookAt); } else { _target.transform.eulerAngles = _target.rotationList[0]; } } else { _target.transform.eulerAngles = _target.rotationList[0]; } GameObject loadEmpty = new GameObject(); loadEmpty.name = "JsonLoad_empty"; loadEmpty.transform.parent = _target.transform; _target.nodes.Clear(); _target.rotationList.Clear(); _target.cameraViewList.Clear(); _target.displayInfoList.Clear(); _target.handleDisplay.Clear(); for (int i = 0; i < jsonTable.Rows.Count; i++) { loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString()); loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString()); _target.nodes.Add(loadEmpty.transform.position); _target.rotationList.Add(loadEmpty.transform.eulerAngles); _target.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString())); _target.displayInfoList.Add(false); _target.handleDisplay.Add(true); } _target.nodeCount = _target.nodes.Count; AngleOptimization(); GameObject.DestroyImmediate(loadEmpty); } else { Debug.LogError(filePath + ", 该文件不存在!"); } }