Last active
August 29, 2015 14:24
-
-
Save erkantaylan/5b9a83483db5225fe46d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ----------------------------------------------- | |
| [ScsService(Version = "1.0.0.0")] | |
| public interface IMessageService | |
| { | |
| void AddMessage(MessageRecord record); | |
| bool DeleteMessage(MessageRecord record); | |
| MessageRecord FindMessage(string index); | |
| void SendMessages(); | |
| } | |
| ======== SERVER ================ | |
| var server = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(2000)); | |
| server.AddService<IMessageService, MessageService>(new essageService()); | |
| server.Start(); | |
| -- | |
| public class MessageRecord { | |
| private string Index { get; set; } | |
| public Log MessageLog { get; set; } | |
| public MessageRecord(Log messageLog) { | |
| this.MessageLog = messageLog; | |
| switch(messageLog.LogType) { | |
| case Log.LogTypes.PrintLog: | |
| this.Index = string.Format("Print:{0}", messageLog.SessionNumer); | |
| break; | |
| case Log.LogTypes.ProgramLog: | |
| this.Index = string.Format("Program:{0}", messageLog.SessionNumer); | |
| break; | |
| case Log.LogTypes.UserLog: | |
| this.Index = string.Format("User:{0}", messageLog.SessionNumer); | |
| break; | |
| } | |
| } | |
| public override string ToString() { | |
| return this.Index; | |
| } | |
| } | |
| -- | |
| public class MessageService : ScsService, IMessageService { | |
| private readonly SortedList<string, MessageRecord> _records; | |
| public MessageService() { | |
| _records = new SortedList<string, MessageRecord>(); | |
| } | |
| public void AddMessage(MessageRecord record) { | |
| if (record.Equals(null)) { | |
| throw new ArgumentNullException("record"); | |
| } | |
| _records.Add(record.ToString(), record); | |
| } | |
| public bool DeleteMessage(MessageRecord record) { | |
| return _records.Remove(record.ToString()); | |
| } | |
| public MessageRecord FindMessage(string index) { | |
| //TODO | |
| return null; | |
| } | |
| public void SendMessages() { | |
| //TODO | |
| //throw new NotImplementedException(); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment