public HttpResponseMessage Get(string Method, string Ver = null, string Device = null, string Sid = null, string Md5 = null, int channel_id = 0, int start = 0, int end = 0, string group_id = null, string filter = null, int recording_id = 0, string name = null, int channel = 0, int time_t = 0, int duration = 0) { Logger.ServiceILog("Service Request: {0}, {1}", Method, Request.RequestUri.ToString()); object response = new Response() { ErrorCode = 0, ErrorMessage = "Unknown method." }; try { switch ((Method ?? "").ToLower()) { case "session.initiate": response = Session_Initiate(Ver, Device); break; case "session.login": response = Session_Login(Sid, Md5); break; case "channel.icon": response = Channel_Icon(channel_id); break; default: { var config = new Models.Configuration(); int userOid = 0; if (config.EnableUserSupport) /* ensure a user is found if users are enabled */ { if (!String.IsNullOrWhiteSpace(Sid) && SessionUserOids.ContainsKey(Sid)) userOid = SessionUserOids[Sid]; else throw new UnauthorizedAccessException(); } switch ((Method ?? "").ToLower()) { case "setting.list": response = Setting_List(); break; case "channel.listings": response = Channel_Listings(userOid, channel_id, start, end); break; case "channel.list": response = Channel_List(userOid, group_id); break; case "channel.groups": response = Channel_Groups(userOid); break; case "recording.list": response = Recording_List(userOid, filter); break; case "recording.delete": response = Recording_Delete(userOid, recording_id); break; case "recording.save": response = Recording_Save(userOid, name, channel, time_t, duration); break; } } break; } } catch (InvalidSessionException) { response = new Response() { ErrorCode = 8, ErrorMessage = "Invalid Session", Stat = Response.ResponseStat.fail /* NOTE: this is a "fail" response */ }; } catch (ChannelNotFoundException) { response = new Response() { ErrorCode = 5, ErrorMessage = "Channel not found", Stat = Response.ResponseStat.failed /* NOTE: this is a "fail" response */ }; } if (response is Response) return new HttpResponseMessage() { Content = new StringContent(response.ToString(), System.Text.Encoding.UTF8, "application/xml") }; else if (response == null) return new HttpResponseMessage(HttpStatusCode.NotFound); return response as HttpResponseMessage; }