Exemple #1
0
        public static string UploadFile(string fileBase64, ConfiguracaoGeral diretorioMedia, int idRegistro, string extensao)
        {
            string newFileName = string.Empty;

            try
            {
                byte[] tempBytes = Convert.FromBase64String(fileBase64);
                if (tempBytes.Length > 0)
                {
                    newFileName = Guid.NewGuid().ToString() + extensao;

                    string diretorioSalvar = ConfiguracaoAppUtil.GetPath(diretorioMedia);

                    diretorioSalvar = string.Format("{0}/{1}/", diretorioSalvar, idRegistro);
                    if (!Directory.Exists(diretorioSalvar))
                    {
                        try
                        {
                            Directory.CreateDirectory(diretorioSalvar);
                        }
                        catch { }
                    }

                    string filePath = diretorioSalvar + @"/" + newFileName;
                    File.WriteAllBytes(filePath, tempBytes);
                }
            }
            catch (Exception ex)
            {
                LogUtil.Error(ex);
                return(string.Empty);
            }
            return(newFileName);
        }
 public static List <string> GetAsList <T>(T nome, char separator = ',')
 {
     if (String.IsNullOrEmpty(ConfiguracaoAppUtil.Get(nome)))
     {
         return(new List <string>());
     }
     else
     {
         return(ConfiguracaoAppUtil.Get(nome).Split(separator).Select(t => t.Trim()).ToList());
     }
 }
        public static Dictionary <string, int> GetAsDictionaryInt <T>(T nome, char separator = ',', char separatorValue = '=')
        {
            var list = ConfiguracaoAppUtil.Get(nome).Split(separator);

            if ((list.Length > 0) && (list[0].Trim().Contains(separatorValue)))
            {
                return(list.ToDictionary <string, string, int>(t => t.Split(separatorValue)[0].Trim(), t => Convert.ToInt32(t.Split(separatorValue)[1].Trim())));
            }
            else
            {
                return(new Dictionary <string, int>());
            }
        }
 public static List <decimal> GetAsListDecimal <T>(T nome, char separator = ',')
 {
     return(ConfiguracaoAppUtil.GetAsList(nome, separator).Select(t => Convert.ToDecimal(t.Trim())).ToList());
 }
 public static decimal GetAsDecimal <T>(T nome)
 {
     return(Convert.ToDecimal(ConfiguracaoAppUtil.Get(nome)));
 }
 public static List <int> GetAsListInt <T>(T nome, char separator = ',')
 {
     return(ConfiguracaoAppUtil.GetAsList(nome, separator).Select(t => Convert.ToInt32(t.Trim())).ToList());
 }
 public static int GetAsInt <T>(T nome)
 {
     return(Convert.ToInt32(ConfiguracaoAppUtil.Get(nome)));
 }
 public static List <DateTime> GetAsListDateTime <T>(T nome, char separator = ',')
 {
     return(ConfiguracaoAppUtil.GetAsList(nome, separator).Select(t => t.ToDateTime()).ToList());
 }
 public static DateTime GetAsDateTime <T>(T nome)
 {
     return(ConfiguracaoAppUtil.Get(nome).ToDateTime());
 }
 public static List <bool> GetAsListBool <T>(T nome, char separator = ',')
 {
     return(ConfiguracaoAppUtil.GetAsList(nome, separator).Select(t => Convert.ToBoolean(t.Trim())).ToList());
 }
 public static bool GetAsBool <T>(T nome)
 {
     return(Convert.ToBoolean(ConfiguracaoAppUtil.Get(nome)));
 }
 public static double GetAsDouble <T>(T nome)
 {
     return(Convert.ToDouble(ConfiguracaoAppUtil.Get(nome)));
 }