private static void assertFormatsTo(String expected, double input) { IWorkbook wb = new HSSFWorkbook(); try { ISheet s1 = wb.CreateSheet(); IRow row = s1.CreateRow(0); ICell rawValue = row.CreateCell(0); rawValue.SetCellValue(input); ICellStyle newStyle = wb.CreateCellStyle(); IDataFormat dataFormat = wb.CreateDataFormat(); newStyle.DataFormat = (dataFormat.GetFormat("General")); String actual = new DataFormatter().FormatCellValue(rawValue); Assert.AreEqual(expected, actual); } finally { wb.Close(); } }
public void TestBoolean() { DataFormatter formatter = new DataFormatter(); // Create a spreadsheet with some TRUE/FALSE boolean values in1 it IWorkbook wb = new HSSFWorkbook(); try { ISheet s = wb.CreateSheet(); IRow r = s.CreateRow(0); ICell c = r.CreateCell(0); c.SetCellValue(true); Assert.AreEqual("TRUE", formatter.FormatCellValue(c)); c.SetCellValue(false); Assert.AreEqual("FALSE", formatter.FormatCellValue(c)); } finally { wb.Close(); } }
public async Task <ThemePublish> GetThemeAndThemePagesAsync(string token, ObjectId themeId, Guid projectId) { var uri = BuildQueryUri("Api/DiyService/GetTheme"); IDictionary <string, string> parameters = new Dictionary <string, string> { { "token", token }, { "themeId", themeId.ToString() }, { "projectId", projectId.ToString() } }; var result = await Connector.GetAsync(uri, parameters); var apiResult = DataFormatter.ToObject <ApiResult <ThemePublish> >(result); if (apiResult.Status == ResultStatus.Success) { return(apiResult.Result); } return(null); }
public Table GetDataTable(ImportFile importFile, IImportFileStructure importFileStructure) { var result = new Table(); try { HSSFWorkbook workbook; using (var stream = importFile.FileStream) { workbook = new HSSFWorkbook(stream); } _formulaEvaluator = new HSSFFormulaEvaluator(workbook); _dataFormatter = new HSSFDataFormatter(); var rows = GetRows(workbook, importFileStructure); if (!rows.Any()) { return(result); } foreach (var row in rows) { result.AddRow(row); } return(result); } catch (FileFormatException) { result.MarkAsInValid(ErrorMessage.IncorrectXlsFileFormat); } catch (Exception ex) { result.MarkAsInValid(ErrorMessage.UnexpectedError); Logs.Logger.Error(ex); } return(result); }
//map table欄位 - CommunRecord public CommunRecord CommunMapper(CommunRecord rec, IRow row) { DataFormatter Formatter = new DataFormatter(CultureInfo.CurrentCulture); string[] conArray = { "受話", "發話", "簡訊", "轉接" }; string firstCell = Formatter.FormatCellValue(row.GetCell(0)); //判斷是否通聯記錄內容 if (conArray.Where(c => firstCell.Contains(c)).Any() && firstCell != "") { rec.CType = Formatter.FormatCellValue(row.GetCell(0)); rec.CPhoneNum = Formatter.FormatCellValue(row.GetCell(1)); rec.CCorrePhoneNum = Formatter.FormatCellValue(row.GetCell(2)); //將字串轉換成時間 rec.CStartTime = ParseHelper.ParseDateTime(Formatter.FormatCellValue(row.GetCell(3))); rec.CEndTime = ((DateTime)rec.CStartTime).AddSeconds(row.GetCell(4).NumericCellValue); rec.CIMEI = Formatter.FormatCellValue(row.GetCell(5)); rec.CThroughPhoneNum = Formatter.FormatCellValue(row.GetCell(6)); //基地台編號和地址分離 string station = Formatter.FormatCellValue(row.GetCell(7)); string[] stationDetail = station.Split('/'); if (stationDetail.Length >= 2) { rec.CStationNum = stationDetail[0]; rec.CStationAddress = stationDetail[1]; } rec.isDeleted = false; return(rec); } else { return(null); } }
public byte[] SearchDataByPage(string TableName, string Select, string OrderBy, int Size, int Index, bool ASC, string Where, out int Count) { object[] outParameters; DataSet ds = new DataSet(); try { ds = acQC.ExecuteStoredProcedure("_PagerSql2016_out_count", new string[] { "tblName", "fldCow", "fldName", "PageSize", "PageIndex", "OrderType", "strWhere" }, new object[] { TableName, Select, OrderBy, Size, Index, ASC, Where }, new string[] { "count" }, new DbType[] { DbType.Int32 }, out outParameters ); Count = (int)outParameters.ElementAt(0); } catch (Exception ex) { throw ex; } return(DataFormatter.GetBinaryFormatDataCompress(ds)); }
/// <summary> /// Converts a WatchListEntity to WatchListModel. /// </summary> /// <param name="watchListEntity">WatchListEntity to be converted to WatchListModel.</param> /// <returns>WatchListModel corresponding to WatchListEntity.</returns> public static WatchListModel ConvertWatchListEntityToModel(WatchListEntity watchListEntity) { return(new WatchListModel { AlertRequired = watchListEntity.AlertRequired, AltNameOne = watchListEntity.AltNameOne, AltNameThree = watchListEntity.AltNameThree, AltNameTwo = watchListEntity.AltNameTwo, BseSymbol = watchListEntity.BseSymbol, CreatedOn = (watchListEntity.CreatedOn != null) ? DataFormatter.FormatDateToString(DataFormatter.GetDateTimeInLocalFormat(watchListEntity.CreatedOn)) : null, IsActive = watchListEntity.IsActive, ModifiedOn = (watchListEntity.ModifiedOn != null) ? DataFormatter.FormatDateToString(DataFormatter.GetDateTimeInLocalFormat(watchListEntity.ModifiedOn)) : null, Name = watchListEntity.Name, NseSymbol = watchListEntity.NseSymbol, TempName = watchListEntity.TempName, WatchListID = watchListEntity.WatchListID }); }
private SrezTableLight prevDateHourTable; // таблица часовых данных за предыдущую дату /// <summary> /// Конструктор /// </summary> public HourDataRepBuilder(DataAccess dataAccess) : base() { if (dataAccess == null) { throw new ArgumentNullException("dataAccess"); } this.dataAccess = dataAccess; dataFormatter = new DataFormatter(); tableView = null; date = DateTime.MinValue; startHour = 0; endHour = 23; genDT = DateTime.MinValue; itemRowTemplate = null; viewItem = null; reqDateHourTable = null; prevDateHourTable = null; }
string scaleAndFormatData() { if (DataScaler != null) { DataScaler.ScaleData(this); } if (DataFormatter != null) { return(DataFormatter.FormatData(this, false)); } else { if (ScaledFloatData != null) { return(ScaledFloatData.GetValueOrDefault().ToString()); } else { return(ScaledIntData.ToString()); } } }
public void TestFormatDistance() { // set up double distance1 = 42.0; double distance2 = 4200.0; double distance3 = 0.0; // run string text1 = DataFormatter.FormatDistance(distance1); string text2 = DataFormatter.FormatDistance(distance2); string text3 = DataFormatter.FormatDistance(distance3); // check Assert.AreEqual("42 m", text1, "formatted text must match"); string separator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; string expectedText2 = $"4{separator}2 km"; Assert.AreEqual(expectedText2, text2, "formatted text must match"); Assert.AreEqual("-", text3, "formatted text must match"); }
public void DoTest49928Core(IWorkbook wb) { DataFormatter df = new DataFormatter(); ISheet sheet = wb.GetSheetAt(0); ICell cell = sheet.GetRow(0).GetCell(0); ICellStyle style = cell.CellStyle; // not expected normally, id of a custom format should be greater // than BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX short poundFmtIdx = 6; Assert.AreEqual(poundFmt, style.GetDataFormatString()); Assert.AreEqual(poundFmtIdx, style.DataFormat); Assert.AreEqual("\u00a31", df.FormatCellValue(cell)); IDataFormat dataFormat = wb.CreateDataFormat(); Assert.AreEqual(poundFmtIdx, dataFormat.GetFormat(poundFmt)); Assert.AreEqual(poundFmt, dataFormat.GetFormat(poundFmtIdx)); }
public void Test55265() { IWorkbook wb = _testDataProvider.CreateWorkbook(); try { DataFormatter formatter = new DataFormatter(); IDataFormat fmt = wb.CreateDataFormat(); ISheet sheet = wb.CreateSheet(); IRow r = sheet.CreateRow(0); ICellStyle cs = wb.CreateCellStyle(); cs.DataFormat = (fmt.GetFormat("#'##0")); ICell zero = r.CreateCell(0); zero.SetCellValue(0); zero.CellStyle = (cs); ICell sml = r.CreateCell(1); sml.SetCellValue(12); sml.CellStyle = (cs); ICell med = r.CreateCell(2); med.SetCellValue(1234); med.CellStyle = (cs); ICell lge = r.CreateCell(3); lge.SetCellValue(12345678); lge.CellStyle = (cs); Assert.AreEqual("0", formatter.FormatCellValue(zero)); Assert.AreEqual("12", formatter.FormatCellValue(sml)); Assert.AreEqual("1'234", formatter.FormatCellValue(med)); Assert.AreEqual("12'345'678", formatter.FormatCellValue(lge)); } finally { wb.Close(); } }
private void ExtractValueAndStatus(PXModel model, out double?[] value, out Dictionary <int, string> status) { int matrixSize = model.Data.MatrixColumnCount * model.Data.MatrixRowCount; value = new double?[matrixSize]; var buffer = new double[model.Data.MatrixColumnCount]; var dataSymbolMap = BuildDataSymbolMap(model.Meta); var formatter = new DataFormatter(model); string note = string.Empty; string dataNote = string.Empty; status = new Dictionary <int, string>(); int n = 0; var numberFormatInfo = new System.Globalization.NumberFormatInfo(); for (int i = 0; i < model.Data.MatrixRowCount; i++) { model.Data.ReadLine(i, buffer); for (int j = 0; j < model.Data.MatrixColumnCount; j++) { string symbol = null; if (dataSymbolMap.TryGetValue(buffer[j], out symbol)) { value[n] = null; status.Add(n, symbol); } else { value[n] = Convert.ToDouble(formatter.ReadElement(i, j, ref note, ref dataNote, ref numberFormatInfo), numberFormatInfo); if (!string.IsNullOrEmpty(dataNote)) { status.Add(n, dataNote); } } n++; } } }
public void TestTruthFile() { Stream truthFile = HSSFTestDataSamples.OpenSampleFileStream("54686_fraction_formats.txt"); TextReader reader = new StreamReader(truthFile); IWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("54686_fraction_formats.xls"); ISheet sheet = wb.GetSheetAt(0); DataFormatter formatter = new DataFormatter(); IFormulaEvaluator Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator(); // Skip over the header row String truthLine = reader.ReadLine(); String[] headers = truthLine.Split("\t".ToCharArray()); truthLine = reader.ReadLine(); for (int i = 1; i < sheet.LastRowNum && truthLine != null; i++) { IRow r = sheet.GetRow(i); String[] truths = truthLine.Split("\t".ToCharArray()); // Intentionally ignore the last column (tika-1132), for now for (short j = 3; j < 12; j++) { ICell cell = r.GetCell(j, MissingCellPolicy.CREATE_NULL_AS_BLANK); String truth = Clean(truths[j]); String testKey = truths[0] + ":" + truths[1] + ":" + headers[j]; String formatted = Clean(formatter.FormatCellValue(cell, Evaluator)); if (truths.Length <= j) { continue; } Assert.AreEqual(truth, formatted, testKey); } truthLine = reader.ReadLine(); } wb.Close(); reader.Close(); }
public void TestDatesWithLocales() { DataFormatter dfUS = new DataFormatter(CultureInfo.GetCultureInfo("en-US"), true); String dateFormatEnglish = "[$-409]mmmm dd yyyy h:mm AM/PM"; String dateFormatChinese = "[$-804]mmmm dd yyyy h:mm AM/PM"; // Check we format the English one correctly double date = 26995.477777777778; Assert.AreEqual( "November 27 1973 11:28 AM", dfUS.FormatRawCellContents(date, -1, dateFormatEnglish) ); // Check that, in the absence of locale support, we handle // the Chinese one the same as the English one Assert.AreEqual( "November 27 1973 11:28 AM", dfUS.FormatRawCellContents(date, -1, dateFormatChinese) ); }
private string getCellValue(ICell cell) { var dataFormatter = new DataFormatter(CultureInfo.CurrentCulture); // If this is not part of a merge cell, // just get this cell's value like normal. if (!cell.IsMergedCell) { return(dataFormatter.FormatCellValue(cell)); } // Otherwise, we need to find the value of this merged cell. else { // Get current sheet. var currentSheet = cell.Sheet; // Loop through all merge regions in this sheet. for (int i = 0; i < currentSheet.NumMergedRegions; i++) { var mergeRegion = currentSheet.GetMergedRegion(i); // If this merged region contains this cell. if (mergeRegion.FirstRow <= cell.RowIndex && cell.RowIndex <= mergeRegion.LastRow && mergeRegion.FirstColumn <= cell.ColumnIndex && cell.ColumnIndex <= mergeRegion.LastColumn) { // Find the top-most and left-most cell in this region. var firstRegionCell = currentSheet.GetRow(mergeRegion.FirstRow) .GetCell(mergeRegion.FirstColumn); // And return its value. return(dataFormatter.FormatCellValue(firstRegionCell)); } } // This should never happen. throw new Exception("Cannot find this cell in any merged region"); } }
public async Task <List <ArkTradingRecord> > Parse(string fileName) { var skipRows = 4; var records = new List <ArkTradingRecord>(); HSSFWorkbook hssfwb; using (FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { hssfwb = new HSSFWorkbook(file); } DataFormatter formatter = new DataFormatter(); ISheet sheet = hssfwb.GetSheet("Sheet1"); var startRow = skipRows; for (int i = startRow; i <= sheet.LastRowNum; i++) { var row = sheet.GetRow(i); if (row == null) { continue; } var record = new ArkTradingRecord { Fund = formatter.FormatCellValue(row.GetCell(0)), Date = DateTime.Parse(formatter.FormatCellValue(row.GetCell(1))), Direction = Enum.Parse <TradingDirection>(formatter.FormatCellValue(row.GetCell(2))), Ticker = formatter.FormatCellValue(row.GetCell(3)), CusIP = formatter.FormatCellValue(row.GetCell(4)), Name = formatter.FormatCellValue(row.GetCell(5)), Shares = (int)row.GetCell(6).NumericCellValue, PercentOfEtf = row.GetCell(7).NumericCellValue, }; records.Add(record); } return(await Task.FromResult(records)); }
//匯入 public void Import(Attachment attach) { FileStream fs = null; //NPOI IWorkbook workbook = null; ISheet sheet = null; DataFormatter dataFormatter = new DataFormatter(CultureInfo.CurrentCulture); //path var physicalPath = HttpContext.Current.Server.MapPath(attach.AttachmentPath); var path = Path.Combine(physicalPath, attach.AttachmentName); try { //開啟現有檔案來讀取,存到資料串流 using (fs = File.OpenRead(path)) { //資料串流存到NPOI物件 //新excel workbook = GetWorkbook(attach, fs); if (workbook != null) { sheet = workbook.GetSheetAt(0); //SMS訊息 SMSCreate(sheet, attach); //sheet = workbook.GetSheetAt(1); //聯絡人 //ContaCreate(sheet, attach); } } } catch (Exception e) { if (fs != null) { fs.Close(); } } }
//map table欄位 - ForensicSMS public ForensicSMS SMSMapper(ForensicSMS sms, IRow row) { DataFormatter Formatter = new DataFormatter(CultureInfo.CurrentCulture); string firstCell = Formatter.FormatCellValue(row.GetCell(0)); //判斷是否通聯記錄內容 if (int.TryParse(firstCell, out int result) && firstCell != "") { sms.FSheetNum = 0; sms.FSheetName = row.Sheet.SheetName; sms.FNum = result; sms.FCorrespond = Formatter.FormatCellValue(row.GetCell(1)); //將字串轉換成時間 sms.FDatetime = ParseHelper.ParseDateTime(Formatter.FormatCellValue(row.GetCell(2))); return(sms); } else { return(null); } }
public void BnlsVersionCheckRequest(VersionCheckRequestToken requestToken) { if (!IsConnected) { Connect(); } BnlsPacket versionCheckEx2 = new BnlsPacket(); versionCheckEx2.InsertInt32(requestToken.Product); // Product versionCheckEx2.InsertInt32(0); // Flags versionCheckEx2.InsertInt32(Environment.TickCount); // Cookie - unused versionCheckEx2.InsertInt64(requestToken.FileTime); // Filetime versionCheckEx2.InsertString(requestToken.VersionName); // Version file name versionCheckEx2.InsertBytes(requestToken.ChecksumFormula); // Checksum Formula versionCheckEx2.InsertByte(0x00); System.Diagnostics.Debug.WriteLine("Checksum Form"); DataFormatter.WriteToTrace(requestToken.ChecksumFormula); SendPacket(0x1A, versionCheckEx2); // BNLS_VERSIONCHECK Receive(3, requestToken); }
public void check() { new Task(() => { Dispatcher.Invoke(() => { originalString = NoticeLabel.Content.ToString(); formattedText = new FormattedText(originalString, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface(NoticeLabel.FontFamily.ToString()), NoticeLabel.FontSize + 2, Brushes.Black); //글자 오버를 체크하기 위해 생성한 Formatted 텍스트 if (General.ActualWidth < formattedText.WidthIncludingTrailingWhitespace) //글자가 화면을 초과함을 확인 { int idx = 0; while ((new FormattedText(originalString.Substring(0, idx++), CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface(NoticeLabel.FontFamily.ToString()), NoticeLabel.FontSize + 2, Brushes.Black).WidthIncludingTrailingWhitespace < this.ActualWidth)) { ; //글자 오버를 체크하기 위해 생성한 Formatted 텍스트 } newText = originalString.Substring(0, idx > 3 ? idx - 3 : idx); NoticeLabel.Content = newText + "..."; } DateLabel.Content = DataFormatter.toDate(notice.when); }); }).Start(); }
public void Test58536() { IWorkbook wb = _testDataProvider.CreateWorkbook(); DataFormatter formatter = new DataFormatter(); IDataFormat fmt = wb.CreateDataFormat(); ISheet sheet = wb.CreateSheet(); IRow r = sheet.CreateRow(0); char pound = '\u00A3'; String formatUK = "_-[$" + pound + "-809]* #,##0_-;\\-[$" + pound + "-809]* #,##0_-;_-[$" + pound + "-809]* \"-\"??_-;_-@_-"; ICellStyle cs = wb.CreateCellStyle(); cs.DataFormat = (fmt.GetFormat(formatUK)); ICell pve = r.CreateCell(0); pve.SetCellValue(12345); pve.CellStyle = (cs); ICell nve = r.CreateCell(1); nve.SetCellValue(-12345); nve.CellStyle = (cs); ICell zero = r.CreateCell(2); zero.SetCellValue(0); zero.CellStyle = (cs); Assert.AreEqual(pound + " 12,345", formatter.FormatCellValue(pve)); Assert.AreEqual("-" + pound + " 12,345", formatter.FormatCellValue(nve)); // TODO Fix this to not have an extra 0 at the end //assertEquals(pound+" - ", formatter.formatCellValue(zero)); wb.Close(); }
/** * Compute width of a column based on a subset of the rows and return the result * * @param sheet the sheet to calculate * @param column 0-based index of the column * @param useMergedCells whether to use merged cells * @param firstRow 0-based index of the first row to consider (inclusive) * @param lastRow 0-based index of the last row to consider (inclusive) * @param maxRows limit the scope to maxRows rows to speed up the function, or leave 0 (optional) * @return the width in pixels or -1 if cell is empty */ public static double GetColumnWidth(ISheet sheet, int column, bool useMergedCells, int firstRow, int lastRow, int maxRows = 0) { DataFormatter formatter = new DataFormatter(); int defaultCharWidth = GetDefaultCharWidth(sheet.Workbook); // No need to explore the whole sheet: explore only the first maxRows lines if (maxRows > 0 && lastRow - firstRow > maxRows) { lastRow = firstRow + maxRows; } double width = -1; for (int rowIdx = firstRow; rowIdx <= lastRow; ++rowIdx) { IRow row = sheet.GetRow(rowIdx); if (row != null) { double cellWidth = GetColumnWidthForRow(row, column, defaultCharWidth, formatter, useMergedCells); width = Math.Max(width, cellWidth); } } return(width); }
public void TestFormatsWithPadding() { DataFormatter dfUS = new DataFormatter(CultureInfo.GetCultureInfo("en-US"), true); // These request space-padding, based on the cell width // There should always be one space after, variable (non-zero) amount before // Because the Cell Width isn't available, this gets emulated with // 4 leading spaces, or a minus then 3 leading spaces // This isn't all that consistent, but it's the best we can really manage... Assert.AreEqual(" 1,234.56 ", dfUS.FormatRawCellContents(1234.56, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual("- 1,234.56 ", dfUS.FormatRawCellContents(-1234.56, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual(" 12.34 ", dfUS.FormatRawCellContents(12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual("- 12.34 ", dfUS.FormatRawCellContents(-12.34, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual(" 0.10 ", dfUS.FormatRawCellContents(0.1, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual("- 0.10 ", dfUS.FormatRawCellContents(-0.1, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); // TODO Fix this, we are randomly adding a 0 at the end that souldn't be there //Assert.AreEqual(" - ", dfUS.FormatRawCellContents(0.0, -1, "_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-")); Assert.AreEqual(" $ 1.10 ", dfUS.FormatRawCellContents(1.1, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-")); Assert.AreEqual("-$ 1.10 ", dfUS.FormatRawCellContents(-1.1, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-")); // TODO Fix this, we are randomly adding a 0 at the end that souldn't be there //Assert.AreEqual(" $ - ", dfUS.FormatRawCellContents( 0.0, -1, "_-$* #,##0.00_-;-$* #,##0.00_-;_-$* \"-\"??_-;_-@_-")); }
public async Task <ApiResult> SendTemplateAsync(string token, string mobile, long templateId, string userIpAddress, IDictionary <string, string> parameter = null) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } var url = BuildQueryUri(_sendTemplateUrl); IDictionary <string, string> parameters = new Dictionary <string, string> { { "token", token }, { "ipaddress", userIpAddress } }; var data = DataFormatter.FromObject(new { templateid = templateId, mobile, parameters = DataFormatter.FromObject(parameter), IpAddress = userIpAddress }); var result = await Connector.PostAsync(url, parameters, data); return(DataFormatter.ToObject <ApiResult <SecretKeyAuthentication> >(result)); }
public async Task <ServiceResult> InitOpenSite(string token, Guid proejctId) { var uri = BuildQueryUri(_getInitOpenSite); IDictionary <string, string> parameters = new Dictionary <string, string> { { "token", token }, { "projectId", proejctId.ToString() } }; var result = await Connector.GetAsync(uri, parameters); var apiResult = DataFormatter.ToObject <ApiResult <List <Theme> > >(result); if (apiResult.Status != ResultStatus.Success) { return(ServiceResult.Failure(apiResult.Message)); } var themeList = Ioc.Resolve <IThemeService>().GetList(); var addList = new List <Theme>(); foreach (var item in apiResult.Result) { var find = themeList.FirstOrDefault(r => r.Id == item.Id); if (find == null) { addList.Add(item); } } if (addList.Count > 0) { Ioc.Resolve <IThemeService>().AddMany(addList); } return(ServiceResult.Success); }
/// <summary> /// Get the index value of the last row with actual data in it from the specified sheet. /// </summary> /// <param name="sheet"> the sheet containing the data. </param> /// <returns> index of the last row with actual data in it.</returns> public static int GetLastRowWithData(ISheet sheet) { IFormulaEvaluator evaluator = sheet.Workbook.GetCreationHelper().CreateFormulaEvaluator(); DataFormatter formatter = new DataFormatter(true); int lastRowIndex = -1; if (sheet.PhysicalNumberOfRows > 0) { // getLastRowNum() actually returns an index, not a row number lastRowIndex = sheet.LastRowNum; // now, start at end of spreadsheet and work our way backwards until we find a row having data for ( ; lastRowIndex >= 0; lastRowIndex--) { IRow row = sheet.GetRow(lastRowIndex); if (!IsRowEmpty(row, evaluator, formatter)) { break; } } } return(lastRowIndex); }
public byte[] GetQCReport(string procdureName, string[] paramenters, object[] values) { try { Console.WriteLine("procedureName:" + procdureName); List <string> ps = paramenters.ToList(); ps.Add("UserID"); paramenters = ps.ToArray(); List <object> vs = values.ToList(); //vs.Add(Shawoo.GenuineChannels.GenuineUtility.CurrentSession["UID"].ToString()); vs.Add(Shawoo.GenuineChannels.GenuineUtility.CurrentSession["UID"].ToString()); values = vs.ToArray(); Console.WriteLine("paramenters:" + JsonConvert.SerializeObject(paramenters)); Console.WriteLine("values:" + JsonConvert.SerializeObject(values)); DataSet ds = acQC.DbHelper.ExecuteStoredProcedure(procdureName, paramenters, values); return(DataFormatter.GetBinaryFormatDataCompress(ds)); } catch (Exception e) { Console.WriteLine(e.ToString()); throw e; } }
public void HandleIncomingMessage(string data, NetPeer peer) { var dataArray = DataFormatter.StringToArray(data, "@"); //Data[0] è sempre il comando ricevuto dal client //Debug.Log(data); switch (dataArray[0]) { case "PlayerMapLoaded": _networkManager.networkPlayer.SpawnPlayer(dataArray, peer); break; case "PlayerConnected": _networkManager.networkPlayer.StartPlayer(dataArray, peer); break; case "PlayerPosition": _networkManager.networkPlayer.MovePlayer(dataArray, peer); break; case "ChatMessage": _networkManager.SendChatMessage(data); break; case "GunShoot": _networkManager.networkFps.ParseShootingData(dataArray, peer); break; case "GunEntityShoot": _networkManager.networkFps.ParseEntityShootData(dataArray); break; case "GunChange": _networkManager.networkPlayer.ChangePlayerGunIndex(dataArray[1], peer); break; } }
/// <summary> /// Gets a hex representation of this buffer. /// </summary> /// <returns>A string representing this buffer's contents in hexadecimal notation.</returns> public override string ToString() { return(DataFormatter.Format(_data, _baseIndex, _baseSize)); }
public void SetUp() { theFormatter = new DataFormatter(); theOutput = theFormatter.DataFor(new Output("test")); }