/// <summary> ///检查新版本的打印接口的打印配置 /// </summary> /// <param name="labelFilePath">标签模板路径</param> /// <param name="lang">语言</param> /// <param name="obj">反射类型</param> /// <param name="errorCode">错误码</param> /// <param name="errorMessage">错误消息</param> private void CheckPrintConfig9(string labelFilePath, string lang, Type obj, ref int errorCode, ref String errorMessage) { if (!File.Exists(labelFilePath)) { string message; if (lang == "cn") { message = string.Format(new ResourceManager(obj).GetString("NotFountLabTemplate1"), labelFilePath); } else { message = string.Format(new ResourceManager(obj).GetString("NotFountLabTemplate2"), labelFilePath); } errorCode = -1; errorMessage = message; throw new ApplicationException(message); } if (!Deserialization.ComIsRegistered(this.TLB_CLASS_ID)) { string @string; if (lang == "cn") { @string = new ResourceManager(obj).GetString("NotFountCodeSoft1"); } else { @string = new ResourceManager(obj).GetString("NotFountCodeSoft2"); } errorCode = -1; errorMessage = @string; throw new ApplicationException(@string); } }
private void button4_Click(object sender, EventArgs e) { var list1 = new Deserialization().Deserialize <Product>(@"D:\serial.json"); if (list1 != null) { controlTreeView1.SetList(list1, (x) => x.Category); } }
public CsvOutput(File targetDirectory, Header nodeHeader, Header relationshipHeader, Configuration config) { this._targetDirectory = targetDirectory; Debug.Assert(targetDirectory.Directory); this._nodeHeader = nodeHeader; this._relationshipHeader = relationshipHeader; this._config = config; this._deserialization = new StringDeserialization(config); targetDirectory.mkdirs(); }
public async Task <IReadOnlyCollection <T> > Get <T>() where T : ICalendarioDTO { var entities = await _context.Get <T>(); if (entities != null) { return(entities); } var json = await _server.GetJsonEnities <T>(); return(Deserialization.DeserializeObject <List <T> >(json, this)); }
// Skips fields until finds MsgType. Throws if MsgType can't be found. static MsgType FindMsgType(IEnumerator <Field> fields) { MsgType msgType = new MsgType(); while (fields.MoveNext()) { int tag = Deserialization.ParseInt(fields.Current.Tag); if (msgType.AcceptField(tag, fields.Current.Value) == FieldAcceptance.Accepted) { return(msgType); } } throw new MsgTypeNotFoundException(); }
public static void WriteLyrics(string singer, string title, TagLib.File audioFile) { string result = SearchLyrics.FindLyrics(singer, title); if (result.Length <= 0) { return; } else { audioFile.Tag.Lyrics = Deserialization.DeserializeLyrics(result); } audioFile.Save(); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { //管理类单例 m_manage = UIManage.Instance; m_SceneManage = SceneStateController.Instance; //系统 uiEvent = new UIEventSystem(this); stageSystem = new StageSystem(this); cardManage = new CardManageSystem(this); attackSystem = new AttackSystem(this); //其他 serialize = new Serialize(this); deserialization = Deserialization.Instance; }
private void OnElapsedTime(object source, ElapsedEventArgs e) { WriteToFile("Service is recall at " + DateTime.Now, "sportService"); WriteToFile(updateData("https://www.polsatsport.pl/rss/pilkanozna.xml"), "pilkanozna"); WriteToFile(updateData("https://www.polsatsport.pl/rss/siatkowka.xml"), "siatkowka"); WriteToFile(updateData("https://www.polsatsport.pl/rss/sportywalki.xml"), "sportywalki"); WriteToFile(updateData("https://www.polsatsport.pl/rss/pilkareczna.xml"), "pilkareczna"); WriteToFile(updateData("https://www.polsatsport.pl/rss/moto.xml"), "moto"); WriteToFile(updateData("https://www.polsatsport.pl/rss/tenis.xml"), "tenis"); WriteToFile(updateData("https://www.polsatsport.pl/rss/koszykowka.xml"), "koszykowka"); WriteToFile(updateData("https://www.polsatsport.pl/rss/wszystkie.xml"), "wszystkie"); LineRemover.RemoveLine(id_of_rss); Deserialization.Run(id_of_rss); }
private void Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Reader read = new Reader(); read.ReadFile(openFileDialog.FileName); Deserialization d = new Deserialization(); Drawer dr = new Drawer(d.Deserialize(read.ReadFile(openFileDialog.FileName)), Graph_image.DesiredSize.Width, Graph_image.DesiredSize.Height); Graph_image.Source = Converter.ToBitmapImage(dr.Draw()); } }
// Throws if the message is malformed. // Returns null if message type isn't recognized. // If the result is not null, it's guaranteed to inherit from Fix44.Message // and implement IClientMessage, IServerMessage, or both. public Mantle.IMessage CreateMessage(IEnumerator <Field> fields) { MsgType msgType = FindMsgType(fields); IMessage msg = NewMessage(msgType); if (msg != null) { while (fields.MoveNext()) { int tag = Deserialization.ParseInt(fields.Current.Tag); msg.AcceptField(tag, fields.Current.Value); } } return(msg); }
public static string ReturnId(string format, IRestResponse apiResponse) { string idValue = GoRestAPISteps.idValue; if (format.Equals("json")) { string response = apiResponse.Content; var jObject = JObject.Parse(response); idValue = JObject.Parse(apiResponse.Content)["result"][0]["user_id"].Value <string>(); } else if (format.Equals("xml")) { idValue = Deserialization.AlbumIdDeserialization(apiResponse); } return(idValue); }
protected override void OnStart(string[] args) { WriteToFile("Service is started at " + DateTime.Now, "sportService"); timer.Elapsed += new ElapsedEventHandler(OnElapsedTime); timer.Interval = 600000; //co jaki czas aktualizujemy dane timer.Enabled = true; // Pierwsze pobieranie danych po uruchomieniu WriteToFile(updateData("https://www.polsatsport.pl/rss/pilkanozna.xml"), "pilkanozna"); WriteToFile(updateData("https://www.polsatsport.pl/rss/siatkowka.xml"), "siatkowka"); WriteToFile(updateData("https://www.polsatsport.pl/rss/sportywalki.xml"), "sportywalki"); WriteToFile(updateData("https://www.polsatsport.pl/rss/pilkareczna.xml"), "pilkareczna"); WriteToFile(updateData("https://www.polsatsport.pl/rss/moto.xml"), "moto"); WriteToFile(updateData("https://www.polsatsport.pl/rss/tenis.xml"), "tenis"); WriteToFile(updateData("https://www.polsatsport.pl/rss/koszykowka.xml"), "koszykowka"); WriteToFile(updateData("https://www.polsatsport.pl/rss/wszystkie.xml"), "wszystkie"); LineRemover.RemoveLine(id_of_rss); Deserialization.Run(id_of_rss); }
/// <summary> /// 老式接口,迭代每个LabelContent并且在激活的当前文档下打印 /// </summary> /// <param name="labelValue"></param> /// <param name="document"></param> private static void ItereatePerLabelContentPrintOld(string labelValue, Document document) { List <LabelData> list = new List <LabelData>(); List <LabelInfo> list2 = new List <LabelInfo>(); list = Deserialization.JSONStringToList <LabelData>(labelValue); for (int i = 0; i < list.Count; i++) { list2 = Deserialization.JSONStringToList <LabelInfo>(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(list[i].LabelContent)); AssignValueToFormVariables(document, list2); document.PrintDocument(Copys); } }
public static int ReturnCount(string format, IRestResponse apiResponse) { string responseString = apiResponse.Content; int intValue = 0; if (format.Equals("json")) { var jObject = JObject.Parse(responseString); string value = jObject["_meta"]["totalCount"].Value <string>(); intValue = int.Parse(value); } else if (format.Equals("xml")) { var responseObject = Deserialization.ResponseDeserialization(apiResponse); string value = responseObject.TotalCount; intValue = int.Parse(value); } return(intValue); }
// Throws if the protocol can't be recognized. IMessageFactory GetFactory(IEnumerator <Field> fields) { if (!fields.MoveNext()) { throw new MissingBeginStringException(); } int tag = Deserialization.ParseInt(fields.Current.Tag); BeginString version = new BeginString(); if (version.AcceptField(tag, fields.Current.Value) != FieldAcceptance.Accepted) { throw new MissingBeginStringException(); } if (!_protocols.ContainsKey(version.Value)) { throw new UnsupportedProtocolException(String.Format("Unrecognized protocol: {0}", version.Value)); } return(_protocols[version.Value]); }
/// <summary> /// 新版接口迭代每个LabelContent并且打印 /// </summary> /// <param name="labelValue"></param> /// <param name="copies"></param> /// <param name="errorCode"></param> /// <param name="errorMessage"></param> /// <param name="document"></param> private static void ItereatePerLabelContentAndPrint(string labelValue, int copies, ref int errorCode, ref String errorMessage, Document document) { List <LabelData> list = new List <LabelData>(); List <LabelInfo> list2 = new List <LabelInfo>(); list = Deserialization.JSONStringToList <LabelData>(labelValue); for (int i = 0; i < list.Count; i++) { list2 = Deserialization.JSONStringToList <LabelInfo>(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(list[i].LabelContent)); //清空脏数据 //ClearOldFormVariables(document); AssignValueToFormVariables(document, list2); for (int m = 0; m < copies; m++) { document.PrintDocument(1); } } //到这里可以确认打印成功了,默认是失败的 errorCode = 0; errorMessage = "打印成功"; }
public async Task SerilizeDates_Success() { var json = await data.GetJsonEntities <Date>(); var objects = Deserialization.DeserializeObject <Date[]>(json, data); }
public void ProcessPrintJob(string e, ref int errorCode, ref String errorMessage) { Tool.Tools.PubMessage("收到打印请求"); LabelPrintX.LabelPrint print = new LabelPrintX.LabelPrint(); HashMap map = JsonConvert.DeserializeObject <HashMap>(e); if (!map.ContainsKey("labelJsonData")) { errorCode = -1; errorMessage = "没有传递labelJsonData字段"; Tool.Tools.PubMessage(errorMessage); return; } String LabelContent = map["labelJsonData"].ToString(); String printer = map.GetValue <String>("printName"); if (!map.ContainsKey("tempatePath")) { errorCode = -1; errorMessage = "没有传递tempatePath字段"; Tool.Tools.PubMessage(errorMessage); return; } String tempatePath = map.GetValue <String>("tempatePath"); int copys = map.GetValue <int>("copys"); int linkFlag = map.GetValue <int>("linkFlag"); Tools.PubMessage("是否连板--------" + linkFlag); if (linkFlag < 1) { //连扳标记 linkFlag = 0; } PrintX.LeanMES.Plugin.LabelPrint.PrintHlper.linkFlag = linkFlag; if (copys < 1) { //打印份数 PrintX.LeanMES.Plugin.LabelPrint.PrintHlper.Copys = 1; copys = 1; } Tools.PubMessage("打印份数--------" + copys); string snString = ""; List <LabelData> list = new List <LabelData>(); List <LabelInfo> list2 = new List <LabelInfo>(); list = Deserialization.JSONStringToList <LabelData>(LabelContent); try { //加速赋值 Parallel.For(0, list.Count, i => { list2 = Deserialization.JSONStringToList <LabelInfo>(JsonConvert.SerializeObject(list[i].LabelContent)); for (int j = 0; j < list2.Count; j++) { snString = list2[j].Value; } }); } catch (Exception err) { errorMessage = "解析打印内容的json失败,请校验格式是否正确,您传递的格式为:" + e + "触发的异常信息为:\n" + err.Message; errorCode = -1; } try { Tools.PubMessage("准备打印--------"); Tools.PubMessage("打印模板--------" + tempatePath); Tools.PubMessage("打印机--------" + printer); print.PrintLabelUseCodeSoft9(tempatePath, LabelContent, copys, "cn", printer, ref errorCode, ref errorMessage, linkFlag); } catch (Exception er) { errorMessage = er.Message; errorCode = -1; } //组装返回结果 HashMap responseBean = new HashMap(); if (errorCode == 0) { errorMessage = "打印成功"; } Tool.Tools.PubMessage(errorMessage); }
protected override DateTime Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseTimestamp(bytes)); }
protected override int Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseInt(bytes)); }
protected override TimeSpan Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseTimeOnly(bytes)); }
protected override char Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseChar(bytes)); }
public static string ProcPrintJob(string e, ref int errorCode, ref String errorMessage) { LabelPrint print = new LabelPrint(); HashMap map = JsonConvert.DeserializeObject <HashMap>(e); String LabelContent = map["labelJsonData"].ToString(); String printer = map.GetValue <String>("printName"); //如果设置了全局当前打印机,就用当前打印机打印 //提供web修改接口 if (Setting.globalPrinter != null && Setting.globalPrinter != "") { printer = Setting.globalPrinter; } String tempatePath = map.GetValue <String>("tempatePath"); int copys = map.GetValue <int>("copys"); try { PrintX.LeanMES.Plugin.LabelPrint.PrintHlper.Copys = copys; } catch (Exception err) { Console.WriteLine(err.Message); copys = 1; } int linkFlag = 0; try { map.GetValue <int>("linkFlag"); } catch (Exception err) { Console.WriteLine(err.Message); linkFlag = 1; } Tools.PubMessage("是否连板--------" + linkFlag); if (linkFlag < 1) { //连扳标记 linkFlag = 0; } if (copys < 1) { //打印份数 PrintX.LeanMES.Plugin.LabelPrint.PrintHlper.Copys = 1; copys = 1; } Tools.PubMessage("打印份数--------" + copys); string snString = ""; List <LabelData> list = new List <LabelData>(); List <LabelInfo> list2 = new List <LabelInfo>(); list = Deserialization.JSONStringToList <LabelData>(LabelContent); try { //加速赋值 Parallel.For(0, list.Count, i => { list2 = Deserialization.JSONStringToList <LabelInfo>(JsonConvert.SerializeObject(list[i].LabelContent)); for (int j = 0; j < list2.Count; j++) { snString = list2[j].Value; } }); } catch (Exception err) { errorMessage = "解析打印内容的json失败,请校验格式是否正确,您传递的格式为:" + e + "触发的异常信息为:\n" + err.Message; errorCode = -1; } try { Tools.PubMessage("准备打印--------"); Tools.PubMessage("打印模板--------" + tempatePath); Tools.PubMessage("打印机--------" + printer); print.PrintLabelUseCodeSoft9(tempatePath, LabelContent, copys, "cn", printer, ref errorCode, ref errorMessage, linkFlag); } catch (Exception er) { Tools.PubMessage("发生异常咯--------" + er.Message); errorMessage = er.Message; errorCode = -1; } //重置打印份数 PrintX.LeanMES.Plugin.LabelPrint.PrintHlper.Copys = 1; //组装返回结果 HashMap responseBean = new HashMap(); if (errorCode == 0) { errorMessage = "打印成功"; } responseBean.Add("errorMessage", errorMessage); responseBean.Add("errorCode", errorCode); responseBean.Add("key", "PrintJob"); return(JsonConvert.SerializeObject(responseBean)); }
public static string ReturnXmlId(IRestResponse apiResponse) { var responseObject = Deserialization.IdDeserialization(apiResponse); return(responseObject); }
protected override decimal Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseDecimal(bytes)); }
protected override long Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseLong(bytes)); }
public async Task SerilizeandDeserializeEvents_Success() { var json = await data.GetJsonEntities <Event>(); var objects = Deserialization.DeserializeObject <Event[]>(json, data); }
protected override bool Deserialize(ArraySegment <byte> bytes) { return(Deserialization.ParseBool(bytes)); }