Пример #1
0
        public static void WriteCSV(List <CSVOutputExternalUser> list)
        {
            string filepath = ConfigurationManager.AppSettings["csvOutputPath"] == null ? string.Empty : ConfigurationManager.AppSettings["csvOutputPath"];

            if (!string.IsNullOrEmpty(filepath))
            {
                var fileName = filepath + "GrantAccessReport " + DateTime.Now.ToString("dd-MMM-yyyy hh-mm tt") + ".csv";
                using (CsvFileWriter writer = new CsvFileWriter(fileName))
                {
                    // Write sample data to CSV file
                    string[] str = { "Name", "Email", "Site", "Permission Group", "isAdded" };
                    CsvRow   row = new CsvRow();
                    row.AddRange(str);
                    writer.WriteRow(row);
                    foreach (CSVOutputExternalUser item in list)
                    {
                        row = new CsvRow();
                        row.Add(item.Name);
                        row.Add(item.Email);
                        row.Add(item.Site);
                        row.Add(item.PermissionGroup);
                        row.Add(item.Message);
                        writer.WriteRow(row);
                    }
                }
            }
        }
Пример #2
0
        static void WriteCSV(List <CSVOutput> list)
        {
            string filepath = ConfigurationManager.AppSettings["csvOutputPath"] == null?string.Empty:ConfigurationManager.AppSettings["csvOutputPath"];

            if (!string.IsNullOrEmpty(filepath))
            {
                var fileName = filepath + "WorkflowReport " + DateTime.Now.ToString("dd-MMM-yyyy hh-mm tt") + ".csv";
                using (CsvFileWriter writer = new CsvFileWriter(fileName))
                {
                    // Write sample data to CSV file
                    string[] str = { "ItemId",          "ItemTitle",        "ItemUrl", "Workflow Name",
                                     "Workflow Status", "Workflow Message", "Workflow URL" };
                    CsvRow   row = new CsvRow();
                    row.AddRange(str);
                    writer.WriteRow(row);
                    foreach (CSVOutput item in list)
                    {
                        row = new CsvRow {
                        };
                        row.Add(item.ItemId);
                        row.Add(item.ItemTitle);
                        row.Add(item.ItemUrl);
                        row.Add(item.WorkflowName);
                        row.Add(item.WorkflowStatus);
                        row.Add(item.WorkflowMessage);
                        row.Add(item.WorkflowURL);
                        writer.WriteRow(row);
                    }
                }
            }
        }