Exemplo n.º 1
0
        public bool SaveResults(DataTable dtResults, Guid timerjobguid)
        {
            var dtResultsFinal = new DataTable();

            dtResultsFinal.Columns.Add("RPTListId", Type.GetType("System.Guid"));
            dtResultsFinal.Columns.Add("ListName");
            dtResultsFinal.Columns.Add("ShortMessage");
            dtResultsFinal.Columns.Add("LongMessage");
            dtResultsFinal.Columns.Add("Level", Type.GetType("System.Int32"));
            dtResultsFinal.Columns.Add("Type", Type.GetType("System.Int32"));
            dtResultsFinal.Columns.Add("Timestamp", Type.GetType("System.DateTime"));
            dtResultsFinal.Columns.Add("timerjobguid", Type.GetType("System.Guid"));

            foreach (DataRow row in dtResults.Rows)
            {
                int    iLevel       = GetLevel((string)row["ResultText"]);
                string shortMessage = string.Empty;
                if (iLevel == 2)
                {
                    shortMessage = "Processed with errors.";
                }
                else
                {
                    shortMessage = "Processed successfully without errors.";
                }
                DataRow resultsFinalRow = dtResultsFinal.NewRow();
                resultsFinalRow["Level"] = iLevel;
                Guid guid = _DAO.GetListId(row["ListName"].ToString());
                if (guid != Guid.Empty)
                {
                    resultsFinalRow["RPTListId"] = guid;
                }
                resultsFinalRow["ListName"]     = row["ListName"];
                resultsFinalRow["ShortMessage"] = shortMessage;
                resultsFinalRow["LongMessage"]  = row["ResultText"];
                resultsFinalRow["Type"]         = 3;
                resultsFinalRow["Timestamp"]    = DateTime.Now;
                resultsFinalRow["timerjobguid"] = timerjobguid;
                dtResultsFinal.Rows.Add(resultsFinalRow);
            }

            var ds = new DataSet();

            dtResultsFinal.TableName = "RPTLog";
            ds.Tables.Add(dtResultsFinal);
            _DAO.BulkInsert(ds, timerjobguid);
            _DAO.Dispose();
            return(true);
        }