public void SendRequestLogin() { ResponsePacket metadata = new ResponsePacket(); string metatype = metadata.GetType().FullName; metadata.From = this.user; metadata.To = "SSocketServer"; metadata.Response = this.ip; SendCommand(ServerIp, OpcoDes.CMSG_REQUEST_USER_LOGIN, metatype, metadata); }
public bool SendJournalList() { lock (this) { try { var l1 = JournalData.OrderBy(st => st.ID).ToList(); ObservableCollection<JournalContentData> d = new ObservableCollection<JournalContentData>(l1); IEnumerator clientEnumerator = d.GetEnumerator(); StringBuilder str = new StringBuilder(); int count = 0; while (clientEnumerator.MoveNext()) { JournalContentData entry = (JournalContentData)clientEnumerator.Current; if (entry.ID > 0) { str.Append(entry.ID + "-" + entry.ModifyDate + "-" + entry.Date + ";"); count++; if (count == 10) { ResponsePacket pck = new OETS.Shared.ResponsePacket(Client.Instance.User, "SSocketServer", new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString())); Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL, pck.GetType().FullName, pck); count = 0; str.Remove(0, str.Length); } } } if (str.Length >= 0) { ResponsePacket pck = new ResponsePacket(Client.Instance.User, "SSocketServer", new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString())); Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL, pck.GetType().FullName, pck); count = 0; str.Remove(0, str.Length); } Trace.Write("[OETS.Client] [SendJournalList] All sended!"); return true; } catch (Exception ex) { Trace.WriteLine(ex.Message); return false; } } }
/// <summary> /// Using the ClientManager parameter send back a response to the client. /// </summary> private void SendResponse(ClientManager cm, OpcoDes command, string response) { SSocket sSocket = cm.SSocket; ResponsePacket pck = new ResponsePacket(); pck.From = "SSocketServer"; pck.To = cm.UserName; pck.Response = response; SendCommand(cm, command, pck); }
public bool SendJournalIds() { var l1 = JournalData.OrderBy(st => st.ID).ToList(); ObservableCollection<JournalContentData> d = new ObservableCollection<JournalContentData>(l1); IEnumerator clientEnumerator = d.GetEnumerator(); StringBuilder str = new StringBuilder(); while (clientEnumerator.MoveNext()) { //DictionaryEntry data = (DictionaryEntry)clientEnumerator.Current; JournalContentData entry = (JournalContentData)clientEnumerator.Current; if (entry.ID > 0) str.Append(entry.ID + ";"); } if (str.Length >= 0) { ResponsePacket pck = new ResponsePacket(Client.Instance.User, "SSocketServer", new Smc(Smc.ServiceProviderEnum.TripleDES).Encrypt(str.ToString())); Client.Instance.SendCommand(Client.Instance.ServerIp, OpcoDes.CMSG_GETTING_JOURNAL_2, pck.GetType().FullName, pck); } Trace.Write("[OETS.Client] [SendJournalIds] All sended!"); return true; }
private void HandleCMSG_GETTING_JOURNAL(ClientManager cm, TimedEventArgs ea) { try { SSocket sSocket = cm.SSocket; if (!sSocket.Connected) return; ResponsePacket d = (ResponsePacket)sSocket.Metadata; string news = new Smc(Smc.ServiceProviderEnum.TripleDES).Decrypt(d.Response); s_log.Debug("CMSG_GETTING_JOURNAL: {0} :: {1}:[{2}]", cm.ClientKey, ea.EventTime, news.Split(';').Length.ToString()/* + "::" + d.Response*/); string[] IdJournal = news.Split(';'); for (int i = 0; i < IdJournal.Length; ++i) { if (IdJournal[i] != "") { int _id = Convert.ToInt32(IdJournal[i].Split('-')[0]); if (JournalManager.Instance.Contains(_id)) { journal_contentData nct = JournalManager.Instance.FindByID(_id); if (nct.ID > 0) { string md = IdJournal[i].Split('-')[1]; string pd = IdJournal[i].Split('-')[2]; if (string.IsNullOrEmpty(md) || md != nct.ModifyDate || string.IsNullOrEmpty(pd) || pd != nct.Date) { JournalPacket pck = new JournalPacket(nct); SendCommand(cm, OpcoDes.SMSG_JOURNAL_MODIFY_SYNC, pck); s_log.Trace("У клиента {0} :: Изменены записи: [{1}]", cm.ClientKey, _id); } } } else { ResponsePacket pck = new ResponsePacket("SocketServer", cm.UserName, _id.ToString()); SendCommand(cm, OpcoDes.SMSG_JOURNAL_REMOVE_SYNC, pck); s_log.Trace("У клиента {0} :: Удалены записи: [{1}]", cm.ClientKey, _id); } } } SendResponse(cm, OpcoDes.SMSG_JOURNAL_SYNC_END, "SYNC_1"); } catch (Exception exc) { LogUtil.ErrorException(exc, false, "HandleCMSG_GETTING_JOURNAL"); } }