public void PutNameValue(NameValue name) { log.Info("{0} - PutNameValue({1})", Context.User.Identity.Name, name.Name); var session = excelSessionManager.GetSession(name.SessionId); if (session == null) throw new Exception("Session not found"); if (!session.Users.Contains(Context.User.Identity.Name)) throw new NotAuthorizedException(); session.UpdateName(name.Name, name.Values); }
public NameValue GetNameValue(NameValue name) { log.Info("{0} - GetNameValue({1})", Context.User.Identity.Name, name.Name); var session = excelSessionManager.GetSession(name.SessionId); if (session == null) throw new Exception("Session not found"); if (!session.Users.Contains(Context.User.Identity.Name)) throw new NotAuthorizedException(); name.Workbook = session.WorkbookName; name.Values = session.GetNameValue(name.Name); return name; }
public async Task SetNameValue() { if (_selectedSession == null) return; if (string.IsNullOrWhiteSpace(NameValue)) return; var values = NameValue.Split(',').Select(strValue => { double dvalue; return Convert.ToDouble(strValue, CultureInfo.InvariantCulture.NumberFormat); return double.NaN; }).Where(dValue => !double.IsNaN(dValue)).Cast<object>().ToArray(); switch (ConnectionType) { case ConnectionType.Rest: await _client.PutAsJsonAsync(string.Format("excel/sessions/{0}/names/{1}", _selectedSession.Id, Name), values); break; case ConnectionType.SignalR: var nameValue = new NameValue(_selectedSession.Id, null, Name, values); await _hubProxy.Invoke("PutNameValue", nameValue); break; } }
public async Task GetNameValue() { if (_selectedSession == null || string.IsNullOrWhiteSpace(_name)) return; object[] values = new object[0]; switch (ConnectionType) { case ConnectionType.Rest: var response = await _client.GetAsync(string.Format("excel/sessions/{0}/names/{1}", _selectedSession.Id, Name)); if (response.IsSuccessStatusCode) { values = await response.Content.ReadAsAsync<object[]>(); } break; case ConnectionType.SignalR: NameValue nameValue = null; var nameRequest = new NameValue(_selectedSession.Id, null, Name, null); nameValue = await _hubProxy.Invoke<NameValue>("GetNameValue", nameRequest); values = nameValue.Values; break; } this.NameValue = values != null ? string.Join(", ", values.Select(v=>Convert.ToString(v, CultureInfo.InvariantCulture))) : ""; }