using NKC_SDK; using SteamWare; using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Web; namespace AppData { public class utils { #region Public Methods /// /// /// /// /// public static string getPath(string filePath) { string answ = ""; try { answ = HttpContext.Current.Server.MapPath(filePath); } catch (Exception exc) { Log.Instance.Error($"{ComLib.traduci("UtilsErrorMapPath")}:{Environment.NewLine}{exc}"); } return answ; } public static void SaveToCsv(List reportData, string path) { var lines = new List(); IEnumerable props = TypeDescriptor.GetProperties(typeof(T)).OfType(); var header = string.Join(";", props.ToList().Select(x => x.Name)); lines.Add(header); var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null)))); lines.AddRange(valueLines); File.WriteAllLines(path, lines.ToArray()); } #endregion Public Methods } }