/// <summary> /// Converter a string em número inteiro /// </summary> /// <param colName="o"></param> /// <returns></returns> public static int ToInt(object stringValue) { if (IsValidText(stringValue)) { try { if (stringValue.ToString().Contains(",")) { stringValue = stringValue.ToString().Split(',')[0]; } return(Convert.ToInt32(stringValue)); } catch (OverflowException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } catch (FormatException ex) { LoggerUtilIts.ShowExceptionMessage(ex); return(-1); } catch (Exception ex) { LoggerUtilIts.ShowExceptionLogs(ex); } } return(0); }
public static byte[] GetBytesFromImage(Image image, ImageFormat imfFormart) { try { if (imfFormart == null) { imfFormart = System.Drawing.Imaging.ImageFormat.Jpeg; } using (var ms = new MemoryStream()) { image.Save(ms, imfFormart); return(ms.ToArray()); } } catch (Exception ex) { LoggerUtilIts.ShowExceptionMessage(ex); return(null); } }