/// <summary> /// Converter uma string em Double /// </summary> /// <param colName="o"></param> /// <returns></returns> public static Double ToDouble(object stringValue) { if (IsValidText(stringValue)) { try { stringValue = stringValue.ToString().Replace(".", ","); return(Convert.ToDouble(stringValue)); } catch (OverflowException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } catch (FormatException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } } return(0.0d); }
/// <summary> /// Converter uma string em Float /// </summary> /// <param colName="o"></param> /// <returns></returns> public static Single ToFloat(object stringValue) { if (IsValidText(stringValue)) { try { //stringValue = stringValue.ToString().Replace(".", ","); stringValue = prepareStringToConvertDecimal(stringValue); return(Convert.ToSingle(stringValue)); } catch (OverflowException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } catch (FormatException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } } return(0.0f); }
/// <summary> /// Cria uma imagem a partir do arquivo informado. /// </summary> /// <param name="file"></param> /// <returns></returns> public static Image CreateImage(string file) { try { using (var ms = new MemoryStream()) { var imfFormart = System.Drawing.Imaging.ImageFormat.Jpeg; var bmp = new Bitmap(file); return(bmp); } } // The System.Drawing.Image this method creates. //T: System.OutOfMemoryException: //T: System.IO.FileNotFoundException: //T: System.ArgumentException: catch (Exception ex) { LoggerUtilIts.ShowExceptionLogs(ex); return(null); } }
/// <summary> /// Converter a string em número inteiro (long) /// </summary> /// <param colName="o"></param> /// <returns></returns> public static long ToLong(object stringValue) { if (IsValidText(stringValue)) { try { return(Convert.ToInt64(stringValue)); } catch (OverflowException ex) { LoggerUtilIts.ShowExceptionLogs(ex); } catch (FormatException ex) { LoggerUtilIts.ShowExceptionLogs(ex); return(-1); } catch (Exception ex) { LoggerUtilIts.ShowExceptionLogs(ex); } } return(0); }