public HttpService(HttpServiceConfig _config, Tnxlog _rdaLog) { config = _config; tnxlog = _rdaLog; unsentFilePath = Path.Combine(tnxlog.dataPath, "unsent"); List <QSO> unsentQSOs = QSOFactory.ReadList <List <QSO> >(unsentFilePath + ".qso"); if (unsentQSOs != null && unsentQSOs.Count > 0) { Task.Run(async() => { await postQso(unsentQSOs.ToArray()); }); } List <QsoDeleteData> unsentDels = ProtoBufSerialization.Read <List <QsoDeleteData> >(unsentFilePath + ".del"); if (unsentDels != null && unsentDels.Count > 0) { Task.Run(async() => { foreach (QsoDeleteData del in unsentDels) { if (!await _postDeleteQso(del)) { addToQueue(del); } } }); } }
private void saveUnsent() { List <QSO> qsoList = new List <QSO>(); foreach (QSO[] qsoBatch in logQueue.Where(item => item.qso != null).Select(item => item.qso).ToList()) { qsoList.AddRange(qsoBatch); } ProtoBufSerialization.Write <List <QSO> >(unsentFilePath + ".qso", qsoList); ProtoBufSerialization.Write <List <QsoDeleteData> >(unsentFilePath + ".del", logQueue.Where(item => item.delete != null).Select(item => item.delete).ToList()); }
private async void UDPDataReceived(object sender, DataReceivedArgs e) { string data = Encoding.UTF8.GetString(e.data); System.Diagnostics.Trace.TraceInformation(data); QSO qso = qsoFactory.create(data); if (qso == null) { return; } //System.Diagnostics.Trace.TraceInformation(qso.toJSON()); dgvQSOInsert(qso); ProtoBufSerialization.Write <QSO>(qsoFilePath, qso, true); await http.postQso(qso); }
public HTTPService(GPSReader _gpsReader) { gpsReader = _gpsReader; schedulePingTimer(); List <QSO> unsentQSOs = ProtoBufSerialization.Read <List <QSO> >(unsentFilePath); if (unsentQSOs != null && unsentQSOs.Count > 0) { Task.Run(() => { foreach (QSO qso in unsentQSOs) { postQso(qso); } saveUnsent(); }); } }
public HTTPService(GPSReader _gpsReader, DXpConfig _config) { gpsReader = _gpsReader; config = _config; userColumnsData = new UserColumnsData(config); schedulePingTimer(); List <QSO> unsentQSOs = ProtoBufSerialization.Read <List <QSO> >(unsentFilePath); if (unsentQSOs != null && unsentQSOs.Count > 0) { Task.Run(() => { foreach (QSO qso in unsentQSOs) { postQso(qso); } saveUnsent(); }); } }
public static T ReadList <T>(string filePath) where T : IList <QSO> { T r = ProtoBufSerialization.Read <T>(filePath); if (r != null) { foreach (QSO qso in r) { if (qso.qth == null || qso.qth.Length < TnxlogConfig.QthFieldCount) { string[] src = qso.qth == null ? new string[] { } : qso.qth; qso.qth = new string[TnxlogConfig.QthFieldCount]; for (int field = 0; field < src.Length; field++) { qso.qth[field] = src[field]; } } } } return(r); }
private void saveUnsent() { ProtoBufSerialization.Write <List <QSO> >(unsentFilePath, qsoQueue.ToList()); }
public void writeQsoList() { ProtoBufSerialization.Write <BindingList <QSO> >(qsoFilePath, qsoList); }
public FMain() { #if DEBUG TextWriterTraceListener[] listeners = new TextWriterTraceListener[] { new TextWriterTraceListener("debug." + Guid.NewGuid() + ".log"), new TextWriterTraceListener(Console.Out) }; foreach (TextWriterTraceListener listener in listeners) { listener.TraceOutputOptions |= TraceOptions.DateTime; } Trace.Listeners.AddRange(listeners); Trace.AutoFlush = true; Trace.TraceInformation("-----------------------START---------------------------------"); #endif config = new XmlConfigNS.XmlConfig <DXpConfig>(); config.data.initialize(); qsoFactory = new QSOFactory(config.data); InitializeComponent(); udpListener.DataReceived += UDPDataReceived; udpListener.StartListener(12060); bsQSO = new BindingSource(blQSO, null); dgvQSO.AutoGenerateColumns = false; dgvQSO.DataSource = bsQSO; for (int c = 0; c < DXpConfig.UserColumnsCount; c++) { UserColumnSettings cs = config.data.userColumns != null && config.data.userColumns.Count > c ? config.data.userColumns[c] : null; DataGridViewColumn col = new DataGridViewTextBoxColumn(); col.Name = "userFieldColumn" + c.ToString(); col.DataPropertyName = "userField" + c.ToString(); col.Visible = cs != null ? cs.show : false; col.HeaderText = cs != null ? cs.name : ""; dgvQSO.Columns.Add(col); } if (config.data.dgvQSOColumnsWidth != null) { for (int co = 0; co < dgvQSO.ColumnCount && co < config.data.dgvQSOColumnsWidth.Count(); co++) { dgvQSO.Columns[co].Width = config.data.dgvQSOColumnsWidth[co]; } } else { config.data.dgvQSOColumnsWidth = new List <int>(); } if (config.data.dgvQSOColumnsWidth.Count < dgvQSO.ColumnCount) { for (int co = config.data.dgvQSOColumnsWidth.Count; co < dgvQSO.ColumnCount; co++) { config.data.dgvQSOColumnsWidth.Add(dgvQSO.Columns[co].Width); } writeConfig(); } bool qsoEr; List <QSO> storedQSOs = ProtoBufSerialization.ReadListItems <QSO>(qsoFilePath, out qsoEr); if (storedQSOs.Count > 0) { Regex reComaNoSpace = new Regex(",(\\S)"); string comaNoSpaceRepl = ", $1"; Regex reNoRegion = new Regex("(\\w\\w)-(\\d\\d),\\s?(\\d\\d)"); string noRegionRepl = "$1-$2, $1-$3"; Regex reRDA = new Regex("[A-Z][A-Z]-\\d\\d"); foreach (QSO qso in storedQSOs) { if (qso.freq.IndexOf('.') == -1) { qso.freq = QSO.formatFreq(qso.freq); qsoEr = true; } if (qso.rda != null) { MatchCollection rdaMatches = reRDA.Matches(qso.rda); string rda = ""; if (rdaMatches.Count > 1) { qsoEr = true; } foreach (Match rdaMatch in rdaMatches) { if (rda != "") { rda += ", "; } rda += rdaMatch.Value; } qso.rda = rda; } /* * if (qso.rda != null && reComaNoSpace.IsMatch(qso.rda)) * { * qso.rda = reComaNoSpace.Replace(qso.rda, comaNoSpaceRepl); * qsoEr = true; * } * if (qso.rda != null && reNoRegion.IsMatch(qso.rda)) * { * qso.rda = reNoRegion.Replace(qso.rda, noRegionRepl); * qsoEr = true; * }*/ blQSO.Insert(0, qso); updateQsoIndex(qso); } QSO lastQSO = storedQSOs.Last(); if (lastQSO.rda == config.data.getOptionalColumnValue("RDA")) { qsoFactory.no = lastQSO.no + 1; } } if (qsoEr) { ProtoBufSerialization.WriteList(qsoFilePath, storedQSOs, false); } config.data.optionalColumnValueChanged += optionalColumnValueChanged; gpsReader.locationChanged += locationChanged; gpsReader.gpsConnectionChanged += gpsConnectionChanged; config.data.logIO += onLoggedIO; onLoggedIO(null, null); startGPSReader(); http = new HTTPService(gpsReader, config.data); http.connectionStateChanged += onHTTPConnection; http.locationChanged += locationChanged; }
public static VendorInfo ReceiveVendorInfo(Socket Sock) { return((VendorInfo)ProtoBufSerialization.ObjectDeserializing(ReceiveData(Sock), ProtoBufSerialization.ObjectType.VendorObject)); }
public static OrderInfo ReceiveOrderInfo(Socket Sock) { return((OrderInfo)ProtoBufSerialization.ObjectDeserializing(ReceiveData(Sock), ProtoBufSerialization.ObjectType.OrderObject)); }
public static DataTable ReceiveDataTable(Socket Sock) { return(ProtoBufSerialization.DataDeserializing(ReceiveData(Sock))); }
public static void SendVendorInfo(Socket Sock, VendorInfo BussinessInfo) { SendData(Sock, ProtoBufSerialization.ObjectSerialization(BussinessInfo)); }
/// <summary> /// Serializes UserInfo Object and Uses SendData To Send it over the network /// </summary> /// <param name="UserInformation">Object That Needs to be Serialized</param> public static void SendUserInfo(Socket Sock, UserInfo UserInformation) { SendData(Sock, ProtoBufSerialization.ObjectSerialization(UserInformation)); }
public static void SendOrderDetails(Socket Sock, OrderInfo OrderInformation) { SendData(Sock, ProtoBufSerialization.ObjectSerialization(OrderInformation)); }
public static void SendDataTable(Socket Sock, DataTable dataTable) { SendData(Sock, ProtoBufSerialization.DataSerialization(dataTable)); }