public static void Propose(string Email, string SessionTitle, string SessionAbstract) { var ctx = new ICCData(); int eId = Event.GetNextEvent().Id; var session = new Session() { Title = SessionTitle, Abstract = SessionAbstract, EventId = eId }; ctx.Sessions.InsertOnSubmit(session); ctx.SubmitChanges(); var user = ctx.Users.Where(u => string.Compare(u.Email, Email, true) == 0).FirstOrDefault(); Speaker speak = new Speaker() { SessionId = session.Id, UserId = user.Id }; ctx.Speakers.InsertOnSubmit(speak); ctx.SubmitChanges(); }
partial void DeleteSession(Session instance);
partial void UpdateSession(Session instance);
partial void InsertSession(Session instance);
private void detach_Sessions(Session entity) { this.SendPropertyChanging(); entity.Event = null; }
private void attach_Sessions(Session entity) { this.SendPropertyChanging(); entity.Event = this; }
private void UpdateSessionInfo(Session session) { Invoke((MethodInvoker)( () => { if (!session.status.Equals("disconnected")) { txtSessionID.Text = session.sessionId.ToString(CultureInfo.InvariantCulture); txtIvrID.Text = session.callId; txtNetworkType.Text = session.networkType; txtStatus.Text = session.status; txtQuality.Text = session.networkQuality; txtCallerID.Text = session.callerId; if (SessionPropertiesUri == null || !SessionPropertiesUri.AbsolutePath.StartsWith( SessionUri.AbsolutePath)) { var link = session.links.Find(l => l.rel.EndsWith(Link.PayloadRel)); if (link != null) SessionPropertiesUri = new Uri(link.href); else MessageBox.Show("Cannot find the properties uri!"); } toolStripStatusLabel1.Text = String.Format("Last update: {0}", DateTime.Now); } else { timer1.Enabled = false; UpdateUI(false); txtSessionID.Text = "Not Connected"; txtIvrID.Text = string.Empty; txtNetworkType.Text = string.Empty; txtStatus.Text = string.Empty; txtQuality.Text = string.Empty; txtCallerID.Text = string.Empty; SessionPropertiesUri = null; } })); }
private void UpdateSession() { Client.GetAsync(SessionUri).ContinueWith( responseTask => { var errId = String.Format("GET {0} failed!", SessionUri.AbsoluteUri); if (responseTask.Exception != null) { displayHttpRequestError(responseTask.Exception, errId); } else if (responseTask.Result.IsSuccessStatusCode) { responseTask.Result.Content.ReadAsAsync<Session>( new List<MediaTypeFormatter> { jsonFormatter }).ContinueWith( contentTask => { cvSession = contentTask.Result; if (cvSession != null) { UpdateSessionInfo(cvSession); } else { MessageBox.Show(String.Format("GET {0} did not return recognizable content!", SessionUri.AbsoluteUri)); } }); } else { switch (responseTask.Result.StatusCode) { case HttpStatusCode.NotFound: cvSession.status = "disconnected"; UpdateSessionInfo(cvSession); break; case HttpStatusCode.NotModified: break; default: displayHttpResponseError(responseTask.Result, errId); break; } } }); }
private void btnStartEndSession_Click(object sender, EventArgs e) { if (cvSession == null || cvSession.status.Equals("disconnected")) { if (!string.IsNullOrWhiteSpace(txtClientID.Text)) { var newSession = new NewSession { callerId = txtClientID.Text, callId = txtCallID.Text, newMessageUri = string.Empty, stateChangeUri = string.Empty }; Invoke((MethodInvoker)(() => { toolStripStatusLabel1.Text = "Waiting for server at " + Settings.Default.ApiAddress + "..."; btnStartEndSession.Text = "Waiting"; btnStartEndSession.Enabled = false; })); Client.PostAsJsonAsync(SessionsUri.AbsoluteUri, newSession).ContinueWith( responseTask => { var errId = String.Format("POST {0} failed!", SessionsUri.AbsoluteUri); if (responseTask.Exception != null) { UpdateUI(false); displayHttpRequestError(responseTask.Exception, errId); } else if (responseTask.Result.StatusCode == HttpStatusCode.Created) { SessionUri = responseTask.Result.Headers.Location; responseTask.Result.Content.ReadAsAsync<Session>( new List<MediaTypeFormatter> { jsonFormatter }).ContinueWith( contentTask => { if (contentTask.Exception == null) { cvSession = contentTask.Result; if (cvSession != null) { UpdateSessionInfo(cvSession); } else { MessageBox.Show( String.Format( "POST {0} did not return recognizable content!", SessionsUri.AbsoluteUri)); } UpdateUI(cvSession != null && !cvSession.status.Equals("disconnected")); } else { UpdateUI(false); MessageBox.Show( String.Format( "Cannot read the content from POST {0}\nError: {1}", SessionsUri.AbsoluteUri, contentTask.Exception.InnerException.Message)); } } ); } else { UpdateUI(false); displayHttpResponseError(responseTask.Result, errId); } }); } else { MessageBox.Show("No Client ID!"); } } else { Client.DeleteAsync(SessionUri).ContinueWith( task => { var errId = String.Format("DELETE {0} failed!", SessionUri.AbsoluteUri); if (task.Exception != null) { displayHttpRequestError(task.Exception, errId); } else if (task.Result.IsSuccessStatusCode) { cvSession.status = "disconnected"; UpdateSessionInfo(cvSession); } else displayHttpResponseError(task.Result, errId); }); } }