Beispiel #1
0
        public void PutCellValue(CellValue cell)
        {
            log.Info("{0} - PutCellValue({1}!{2})", Context.User.Identity.Name, cell.Worksheet, cell.CellName);
            var session = excelSessionManager.GetSession(cell.SessionId);

            if (session == null) throw new Exception("Session not found");
            if (!session.Users.Contains(Context.User.Identity.Name)) throw new NotAuthorizedException();

            session.UpdateCell(cell.Worksheet, cell.CellName, cell.Value);
        }
Beispiel #2
0
        public CellValue GetCellValue(CellValue cell)
        {
            log.Info("{0} - GetCellValue({1}!{2})", Context.User.Identity.Name, cell.Worksheet, cell.CellName);

            var session = excelSessionManager.GetSession(cell.SessionId);
            if (session == null) throw new Exception("Session not found");
            if (string.IsNullOrWhiteSpace(cell.CellName)) throw new ArgumentException();

            if (!session.Users.Contains(Context.User.Identity.Name)) throw new NotAuthorizedException();

            cell.Workbook = session.WorkbookName;
            cell.Value = session.GetCellValue(cell.Worksheet, cell.CellName);
            return cell;
        }
Beispiel #3
0
        public async Task GetCellValue()
        {
            if (_selectedSession == null) return;

            string strValue = null;
            switch (ConnectionType)
            {
                case ConnectionType.Rest:
                    var response = await _client.GetAsync(string.Format("excel/sessions/{0}/{1}/{2}", _selectedSession.Id, Worksheet, Cell));
                    if (response.IsSuccessStatusCode)
                    {
                        var value = await response.Content.ReadAsAsync<object>();
                        strValue = Convert.ToString(value, CultureInfo.InvariantCulture);
                    }
                    break;
                case ConnectionType.SignalR:
                    var cellValue = new CellValue(_selectedSession.Id, null, Worksheet, Cell, null);
                    cellValue = await _hubProxy.Invoke<CellValue>("GetCellValue", cellValue);
                    strValue = Convert.ToString(cellValue.Value, CultureInfo.InvariantCulture);
                    break;
            }

            CellValue = strValue;
        }