コード例 #1
0
ファイル: HelperGeneral.cs プロジェクト: saijaroht/asocajas
        public static results exceptionError(Exception ex)
        {
            results result = new results();

            result.Message = ex.ToString();
            result.Ok      = false;
            using (BusinessBase <LTLogApp> objLTLogApp = new BusinessBase <LTLogApp>())
            {
                LTLogApp newLog = new LTLogApp();

                newLog.Type            = "Log";
                newLog.GUID            = Guid.NewGuid().ToString();
                newLog.AppName         = ex.Source;
                newLog.WebServiceName  = ((System.Reflection.MemberInfo)(((System.Reflection.MemberInfo)(ex.TargetSite)).DeclaringType)).Name;
                newLog.MethodName      = "First";
                newLog.MethodNameUI    = ((System.Reflection.MemberInfo)(ex.TargetSite)).Name;
                newLog.UserName        = null;
                newLog.UserMachineInfo = Utility.GetUserMachineInfo(MachineInfo);
                newLog.ServerIP        = Utility.GetServerIP();
                newLog.Data            = ex.ToString();
                newLog.ErrorMessage    = ex.Message;
                newLog.Source          = ex.Source;
                newLog.Method          = ((System.Reflection.MemberInfo)(ex.TargetSite)).Name;
                newLog.ErrorType       = null;
                newLog.Trace           = null;
                newLog.CreationDate    = DateTime.Now;
                objLTLogApp.Add(newLog);
            }
            return(result);
        }
コード例 #2
0
ファイル: HelperGeneral.cs プロジェクト: saijaroht/asocajas
        public static void SaveFile()
        {
            string filename = "C:\\ArchivosPlanos\\prueba1.csv";

            //int index = 1;
            //int process = 5;
            using (StreamWriter sw = new StreamWriter(new FileStream(filename, FileMode.Create), Encoding.UTF8))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("titulo1, Titulo2, Titulo3");
                sb.AppendLine("parametro11, parametro21, parametro31");
                sb.AppendLine("parametro12, parametro22, parametro32");
                sb.AppendLine("parametro13, parametro23, parametro33");
                sb.AppendLine("parametro14, parametro24, parametro34");


                sw.Write(sb.ToString());
            }
            byte[] file;
            using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                using (var reader = new BinaryReader(stream))
                {
                    file = reader.ReadBytes((int)stream.Length);
                }
            }
            TReporte NewReport = new TReporte();

            NewReport.Excel = file;
            using (BusinessBase <TReporte> objTReporte = new BusinessBase <TReporte>())
            {
                objTReporte.Add(NewReport);
            }
            HttpResponseMessage getFile = new HttpResponseMessage();

            getFile = GetFile(file);
        }