Exemplo n.º 1
0
        public void WriteToExcel_IntegerArray_Test()
        {
            var writtenInput = new List <int> {
                2, 3, 4, 5
            };

            _excelWriter.WriteToExcel <int>(writtenInput, 1);
            var readOutput = ExcelReader.ReadSheet(1, maintainOrder: true).
                             Select(int.Parse).ToList();

            CollectionAssert.AreEqual(writtenInput, readOutput);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load data from SharpCloud and save it to an Excel file. Only needed when
        /// SharpCloud is a data source, so the upload process can work on local data.
        /// </summary>
        public async Task InitialiseDatabase(
            SharpCloudConfiguration config,
            string connectionString,
            DatabaseType dbType)
        {
            if (dbType == DatabaseType.SharpCloudExcel)
            {
                var filename = _connectionStringHelper.GetVariable(connectionString, DatabaseStrings.DataSourceKey);
                var sourceId = _connectionStringHelper.GetVariable(connectionString, "SourceId");

                var csUsername = _connectionStringHelper.GetVariable(connectionString, "SourceUserName");
                var csPassword = _connectionStringHelper.GetVariable(connectionString, "SourcePassword");
                var csServer   = _connectionStringHelper.GetVariable(connectionString, "SourceServer");

                var username = string.IsNullOrWhiteSpace(csUsername)
                    ? config.Username
                    : csUsername;

                var password = string.IsNullOrWhiteSpace(csPassword)
                    ? config.Password
                    : Encoding.Default.GetString(Convert.FromBase64String(csPassword));

                var server = string.IsNullOrWhiteSpace(csServer)
                    ? config.Url
                    : csServer;

                await _logger.Log("Initialising data source...");

                var sc = _sharpCloudApiFactory.CreateSharpCloudApi(
                    username,
                    password,
                    server,
                    config.ProxyUrl,
                    config.UseDefaultProxyCredentials,
                    config.ProxyUserName,
                    config.ProxyPassword);

                if (sc == null)
                {
                    throw new InvalidCredentialsException();
                }

                var story         = sc.LoadStory(sourceId);
                var items         = story.GetItemsData();
                var relationships = story.GetRelationshipsData();

                await _logger.Log($"Writing story to {filename}");

                _excelWriter.WriteToExcel(filename, items, relationships);
                await _logger.Log("Data source ready");
            }
        }
Exemplo n.º 3
0
 public void writeToExcel()
 {
     logger.Info("Excel Hander - Write to Excel: Started");
     try
     {
         excelWriter.WriteToExcel();
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         logger.Error(ex.StackTrace);
     }
 }
Exemplo n.º 4
0
 public void writeToExcel(DataTable dt, DateTime dateFrom, DateTime dateTo)
 {
     logger.Info("Excel Hander - Write to Excel: Started");
     try
     {
         excelWriter.WriteToExcel(dt, dateFrom, dateTo);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         logger.Error(ex.StackTrace);
     }
 }
Exemplo n.º 5
0
        public async Task <Byte[]> DownloadStudyDataAsync()
        {
            var data = _userService.GetUserQueryable();

            return(await _excelWriter.WriteToExcel <LVIStudyUser>(data));
        }