Skip to content

Instantly share code, notes, and snippets.

@erkantaylan
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save erkantaylan/5b9a83483db5225fe46d to your computer and use it in GitHub Desktop.

Select an option

Save erkantaylan/5b9a83483db5225fe46d to your computer and use it in GitHub Desktop.
-----------------------------------------------
[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