In my program that calls certain web services, I would like that in the final result different CSV files will be created depending on whether the ProjectID
is different
In the following code, in the array filter of projectIDs
, it calls all the project numbers, and sends it to the final service call.
At this moment the final file is only one containing the 2 different projects.
What I want to do is that for every projectID that exists, a CSV file is created differently and therefore downloaded.
How can I do this?
Here is the code:
Thank you very much.
string ExportTasksForAllProjects = "ExportTasksForAllProjects";
string outCsvFile = string.Format(@"C:\ExportTasksForAllProjects\{0}.csv", ExportTasksForAllProjects + DateTime.Now.ToString("_yyyyMMdd HHmms")); //+ DateTime.Now.ToString("_yyyyMMdd HHmms") + "_" + Guid.NewGuid() + );
String newLine = "";
var stream = File.CreateText(outCsvFile);
WS.UserData[] userDataId = client.GetUserData(DataSourceId);
List<string> multiUserIDs = new List<string>();
foreach (var userdata in userDataId)
{
multiUserIDs.Add(userdata.List[0].ToString());
}
foreach (WS.ProjectMetaData proj in pr)
{
string temp = "";
var AllProjectIds = proj.ProjectID;
string[] projectIDs = new string[] { AllProjectIds }; // all projects
WS.TaskEntry[] resultGT3 = client.GetTasks3(projectIDs, multiUserIDs.ToArray());
foreach (var item in resultGT3)
{
newLine = item.ProjectID + "," +
item.UserID + "," +
item.ProjectTitle + "," +
item.StartDate;
stream.WriteLine(newLine);
}
stream.Close();
}