private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create Application object MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project1.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Project project = projectApplication.ActiveProject; // Enumerate the tasks foreach (Task task in project.Tasks) { //Get critical tasks if (task != null) if ((bool)task.Critical) { Console.WriteLine(task.ID + " " + task.Name); Console.WriteLine(task.Start); Console.WriteLine(task.Finish + "\n"); } } // Make sure to clean up and close the file projectApplication.FileCloseAll(PjSaveType.pjDoNotSave); }
private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { Microsoft.Office.Interop.MSProject.Application msApplication = null; try { msApplication = new Microsoft.Office.Interop.MSProject.Application(); } catch (COMException) { MessageBox.Show("You need to have MSProject installed on your computer in order to use the export functionality of the example.", "No Installation"); return; } try { msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType<IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType<Task>(), this.radGanttView1.TasksSource.OfType<IGanttTask>()); msApplication.Visible = true; } catch (COMException) { try { msApplication.Quit(PjSaveType.pjDoNotSave); } catch (COMException) { return; } MessageBox.Show("You should not interact with MSProject while Exporting is performed! Please, export again.", "Interaction exception"); } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create an Application object Microsoft.Office.Interop.MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project1.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); Microsoft.Office.Interop.MSProject.Project project = projectApplication.ActiveProject; int iRecourceId = 1; foreach (Task tsk in project.Tasks) { string developer = "Developer0" + iRecourceId; project.Resources.Add(developer, iRecourceId); tsk.Assignments.Add(tsk.ID, iRecourceId, missingValue); iRecourceId++; } projectApplication.FileCloseAll(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create an Application object Microsoft.Office.Interop.MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project2.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Microsoft.Office.Interop.MSProject.Project project = projectApplication.ActiveProject; //Create and add new task Microsoft.Office.Interop.MSProject.Task task; task = project.Tasks.Add("Task1", 1); task.Start = "8/23/2012"; task.Duration = 3 * 8 * 60; task.Text1 = "Task1"; //Save project and close application projectApplication.FileCloseAll(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create Application object MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project1.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Project project = projectApplication.ActiveProject; //Loop through each task and read information related to tasks foreach (Task task in project.Tasks) { Console.WriteLine("Reading Task " + task.Name); Console.WriteLine("\nID: " + task.ID); Console.WriteLine("Start: " + task.Start); Console.WriteLine("Finish: " + task.Finish); Console.WriteLine("\n===========================\n"); //Read any other information you need } //Loop through each resource and read information related to resources foreach (Resource resource in project.Resources) { string resourceType = null; switch (resource.Type) { case PjResourceTypes.pjResourceTypeCost: resourceType = "Cost"; break; case PjResourceTypes.pjResourceTypeMaterial: resourceType = "Material"; break; case PjResourceTypes.pjResourceTypeWork: resourceType = "Work"; break; } Console.WriteLine("Reading Resource " + resource.Name); Console.WriteLine("\nID: " + resource.ID); Console.WriteLine("Type: " + resourceType); Console.WriteLine("\n===========================\n"); //Read any other information you need } Console.ReadLine(); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create Application object MSProject. Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project1.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Project project = projectApplication.ActiveProject; //Loop through each task and read information related to tasks foreach (Task task in project.Tasks) { Console.WriteLine("Reading Task " + task.Name); Console.WriteLine("\nID: " + task.ID); Console.WriteLine("Start: " + task.Start); Console.WriteLine("Finish: " + task.Finish); Console.WriteLine("\n===========================\n"); //Read any other information you need } //Loop through each resource and read information related to resources foreach (Resource resource in project.Resources) { string resourceType = null; switch (resource.Type) { case PjResourceTypes.pjResourceTypeCost: resourceType = "Cost"; break; case PjResourceTypes.pjResourceTypeMaterial: resourceType = "Material"; break; case PjResourceTypes.pjResourceTypeWork: resourceType = "Work"; break; } Console.WriteLine("Reading Resource " + resource.Name); Console.WriteLine("\nID: " + resource.ID); Console.WriteLine("Type: " + resourceType); Console.WriteLine("\n===========================\n"); //Read any other information you need } Console.ReadLine(); }
//public frmProjectSelection(ref MSProject.Application oApplication, ref CSAPInterface oSAPInterface) public frmProjectSelection(ref MSProject.Application oApplication, ref CSAPInterface oSAPInterface) { InitializeComponent(); // Set reference to MS Project Application object rApplication = oApplication; //Used to set status bar from this form // Set reference to the CSAPInterface rSAPInterface = oSAPInterface; // Get the collection of SAP Project IDs to display oSAPInterface.GetProjDefList(ref oProjDefs); dataGridPrjDefs.DataSource = oProjDefs; }
private void CcmRibbon_Load(object sender, RibbonUIEventArgs e) { application = CmmAddIn.thisApp; CmmAddIn.OnProjectLoaded += (project) => { this.project = project; // Update ribbon display var isBuffersHidden = CcmData.GetIsBuffersHidden(); HideUnhideBuffers(isBuffersHidden); }; }
private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { var msApplication = new Microsoft.Office.Interop.MSProject.Application(); msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType<IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType<Task>(), this.radGanttView1.TasksSource.OfType<IGanttTask>()); msApplication.Visible = true; }
public static void DisplayCommandBars(object objApp, string appName) { // Show all the command bars // Will need to cast objApp if Option Strict string s = ""; Office.CommandBars cbars = null; switch (appName) { case "Microsoft Excel": MsoExcel.Application appExcel = (MsoExcel.Application)objApp; cbars = appExcel.CommandBars; break; case "Microsoft PowerPoint": MsoPowerPoint.Application appPowerPoint = (MsoPowerPoint.Application)objApp; cbars = appPowerPoint.CommandBars; break; case "Microsoft Project": MsoProject.Application appProject = (MsoProject.Application)objApp; cbars = appProject.CommandBars; break; case "Microsoft Visio": MsoVisio.Application appVisio = (MsoVisio.Application)objApp; cbars = (Office.CommandBars)appVisio.CommandBars; break; case "Microsoft Word": MsoWord.Application appWord = (MsoWord.Application)objApp; cbars = appWord.CommandBars; break; case "Outlook": MsoOutlook.Application appOutlook = (MsoOutlook.Application)objApp; MsoOutlook.Explorer explorer = appOutlook.ActiveExplorer(); cbars = explorer.CommandBars; break; default: MessageBox.Show("DisplayCommandBars:Unknown appName->" + appName + "<"); return; } foreach (Office.CommandBar bar in cbars) { s = s + String.Format("{0}\n", bar.Name); } MessageBox.Show(s); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; oApplication = Application; // Set oProject as the current ActiveProject oProject = new CProject(ref Application); // Pass the project in for use in CSAPInterface oSAPInterface = new CSAPInterface(ref oProject); oApplication.StatusBar = "SAP AddIn loaded successfully."; Cursor.Current = Cursors.Default; }
private void ExportToMSProjectButtonClick(object sender, RoutedEventArgs e) { MessageBox.Show("MSProject will start exporting RadGanttView soon. While the process in running we do not recommend interacting with MS Project because the export might break.", "Start Exporting", MessageBoxButton.OK, MessageBoxImage.Information); try { msApplication = new Microsoft.Office.Interop.MSProject.Application(); } catch (COMException) { MessageBox.Show("You need to have MSProject installed on your computer in order to use the export functionality of the example.", "No Installation"); return; } System.Windows.Application.Current.MainWindow.WindowState = WindowState.Minimized; try { msApplication.AppMaximize(); msApplication.FileNew(Missing.Value, Missing.Value, Missing.Value, Missing.Value); var msProject = msApplication.ActiveProject; msProject.ManuallyScheduledTasksAutoRespectLinks = false; FillProjectWithTasks(msProject, this.radGanttView1.TasksSource.OfType <IGanttTask>(), null, false); FillTasksWithDependencies(msProject.Tasks.OfType <Task>(), this.radGanttView1.TasksSource.OfType <IGanttTask>()); msApplication.Visible = true; } catch (COMException) { try { msApplication.Quit(PjSaveType.pjDoNotSave); } catch (COMException) { return; } System.Windows.Application.Current.MainWindow.WindowState = WindowState.Normal; MessageBox.Show("Export has failed. Please, do not interact with MSProject while Exporting is performed.", "Interaction exception"); } }
// Constructor public CProject(ref MSProject.Application Application) { // sGlobalTemplate is our global MS Project objects string sGlobalTemplate = Properties.Settings.Default.TestDir + "SAPProject.mpt"; rApplication = Application; try { //Load our GlobalTemplate //rApplication.FileNew(false, @sGlobalTemplate, false, false); rApplication.FileNew(false, @sGlobalTemplate, false, false); } catch (IOException e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } //Assign reference from standard MSProject to our own rProject = rApplication.ActiveProject; rTasks = rProject.Tasks; }
public BuildSchedule(MSProject.Application projectApp, ProjectServerConnection psc) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.projectApp = projectApp; this.psc = psc; Project[] userProjects = psc.getProjectManager().getAllProjectsForAccount(psc.getAccount().id); foreach (Project project in userProjects) { ProjectListItem pli = new ProjectListItem(); pli.Name = project.name; pli.Project = project; cbSelectProject.Items.Add(pli); } }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create an Application object Microsoft.Office.Interop.MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Microsoft.Office.Interop.MSProject.Project project = projectApplication.ActiveProject; //Add dependencies among the tasks project.Tasks.get_UniqueID(2).TaskDependencies.Add(project.Tasks.get_UniqueID(1), PjTaskLinkType.pjFinishToStart); project.Tasks.get_UniqueID(3).TaskDependencies.Add(project.Tasks.get_UniqueID(2), PjTaskLinkType.pjFinishToStart); project.Tasks.get_UniqueID(4).TaskDependencies.Add(project.Tasks.get_UniqueID(3), PjTaskLinkType.pjFinishToStart); project.Tasks.get_UniqueID(5).TaskDependencies.Add(project.Tasks.get_UniqueID(4), PjTaskLinkType.pjFinishToStart); project.Tasks.get_UniqueID(5).TaskDependencies.Add(project.Tasks.get_UniqueID(2), PjTaskLinkType.pjFinishToStart); //Display the dependencies foreach (Task tsk in project.Tasks) { foreach (TaskDependency dep in project.Tasks.get_UniqueID(tsk.ID).TaskDependencies) { Console.WriteLine("From ID = " + dep.From.ID + "=>To ID = " + dep.To.ID); } Console.WriteLine("____________________________________________________________"); } //Save the project projectApplication.FileCloseAll(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { //Create Application object MSProject.Application projectApplication = new MSProject.Application(); object missingValue = System.Reflection.Missing.Value; //Open an MPP file projectApplication.FileOpenEx("Project1.mpp", missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, PjPoolOpen.pjPoolReadOnly, missingValue, missingValue, missingValue, missingValue, missingValue); //Create a Project object by assigning active project Project project = projectApplication.ActiveProject; // Enumerate the tasks foreach (Task task in project.Tasks) { //Get critical tasks if (task != null) { if ((bool)task.Critical) { Console.WriteLine(task.ID + " " + task.Name); Console.WriteLine(task.Start); Console.WriteLine(task.Finish + "\n"); } } } // Make sure to clean up and close the file projectApplication.FileCloseAll(PjSaveType.pjDoNotSave); }
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { // Clean up if (frmSAP != null) { frmSAP.Close(); frmSAP = null; } //Disconnect from our SAP DB if (oSAPInterface != null) { oSAPInterface.Logout(); oSAPInterface = null; } oApplication = null; // Release the AddIn reference if (objAddIn != null) { objAddIn.Dispose(); objAddIn = null; } }
public CcmData() { application = CmmAddIn.thisApp; project = CmmAddIn.thisApp.ActiveProject; }
public static new int Convert(String inputFile, String outputFile, Hashtable options) { Boolean running = (Boolean)options["noquit"]; MSProject.Application app = null; object missing = System.Reflection.Missing.Value; try { try { app = (MSProject.Application)Marshal.GetActiveObject("MSProject.Application"); } catch (System.Exception) { app = new MSProject.Application(); running = false; } System.Type type = app.GetType(); if (type.GetMethod("DocumentExport") == null || System.Convert.ToDouble(app.Version.ToString()) < 14) { Console.WriteLine("Not implemented with Office version {0}", app.Version); return((int)ExitCode.UnsupportedFileFormat); } app.ShowWelcome = false; app.DisplayAlerts = false; app.DisplayPlanningWizard = false; app.DisplayWizardErrors = false; Boolean includeProps = !(Boolean)options["excludeprops"]; Boolean markup = (Boolean)options["markup"]; FileInfo fi = new FileInfo(inputFile); switch (fi.Extension) { case ".mpp": MSProject.Project project = null; if (app.FileOpenEx(inputFile, false, MSProject.PjMergeType.pjDoNotMerge, missing, missing, missing, missing, missing, missing, missing, missing, MSProject.PjPoolOpen.pjDoNotOpenPool, missing, missing, false, missing)) { project = app.ActiveProject; } if (project == null) { return((int)ExitCode.UnknownError); } app.DocumentExport(outputFile, MSProject.PjDocExportType.pjPDF, includeProps, markup, false, missing, missing); app.FileCloseEx(MSProject.PjSaveType.pjDoNotSave, missing, missing); break; } return(File.Exists(outputFile) ? (int)ExitCode.Success : (int)ExitCode.UnknownError); } catch (System.Exception e) { Console.WriteLine(e.Message); return((int)ExitCode.UnknownError); } finally { if (app != null && !running) { ((MSProject.Application)app).Quit(); } Converter.ReleaseCOMObject(app); } }
private void button2_Click(object sender, EventArgs e) { //inicializar //try //{ MySqlConnection conn = new MySqlConnection(connStr); //} //catch (Exception errosql) //{ // MessageBox.Show("Error en conexion a la base de datos\n\n" + errosql.Message); //} double[] request_id = new double[50]; double[] act_request_id = new double[50]; string[] ms_project = new string[3]; string act_trello_name; string act_init_date; string act_mail; string act_end_date; string act_trello_user; double act_estimated_hours; double act_time_loaded; int contador = 0; int contador1 = 0; try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM (SELECT request.req_id, request.req_ms_project, COUNT(activities.req_id) AS act_count FROM request LEFT JOIN activities ON activities.req_id = request.req_id GROUP BY 1) AS src WHERE src.act_count = 0;"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); if (!reader.HasRows) { MessageBox.Show("Error no hay solicitudes para cargar.\nVerifique que las solicitudes a cargar no tegan tareas ya inicializadas"); } while (reader.Read()) { //MessageBox.Show("aqui\n\n"); request_id[contador1] = reader.GetDouble(0); //MessageBox.Show(request_id[contador1].ToString()); ms_project[contador1] = reader.GetString(1); contador1++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { MessageBox.Show("Error en la consulta\n\n" + errosql.Message); } try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM activities;"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); //act_trello_name[contador] = reader.GetString(2); act_request_id[contador1] = reader.GetDouble(1); //MessageBox.Show(act_request_id[contador1].ToString()); contador++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { MessageBox.Show("Error en la consulta1\n\n" + errosql.Message); } ArrayList tasks = new ArrayList(); // se declara array de las tareas // creamos un objeto de tipo aplicacion MSProject int contTask = 0; int contTitle = 0; int cont1 = 0; int contTaskT = 0; int contTitleT = 0; string[] task_names = new string[50]; MSProject.Application app = null; app = new MSProject.Application(); foreach (String project in ms_project) { if (project != null) { try { contTask = 0; contTitle = 0; // Si no hay problemas para abrir el project entrará en la condición // Fijense en la info que da FileOpen pues aqui indicarás especificas como lo quieres abrir (escritura/lectura) y la ruta, como está aqui es de la forma que se pueda escribir y leer en él if (app.FileOpen("C:/Home/Intelix/Mayoreo/00-Control-Solicitudes/" + project + "", false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSProject.PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing, Type.Missing, Type.Missing)) { foreach (MSProject.Project proj in app.Projects) { //Se recorre las tareas foreach (MSProject.Task task in proj.Tasks) { if (task.Rollup.ToString() == "False") { act_trello_name = task.Name; act_time_loaded = task.ActualWork / 60; act_estimated_hours = task.Work / 60; act_init_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Start); act_end_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Finish); act_trello_user = task.ResourceNames; act_mail = task.Text10; try { //MessageBox.Show("INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'false', '" + act_trello_user + "', '" + act_mail + "')"); conn.Open(); MySqlDataReader reader; MySqlCommand command1; string commandStr1 = "INSERT INTO activities (req_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",LTRIM(RTRIM('" + act_trello_name + "')),'" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + 0 + ", 'false', '" + act_trello_user + "', '" + act_mail + "')"; command1 = new MySqlCommand(commandStr1, conn); reader = command1.ExecuteReader(); reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); contTask++; contTaskT++; } catch (Exception errosql) { MessageBox.Show("Error en la consulta1\n\n" + errosql.Message); } //continue; } else { act_trello_name = task.Name; act_time_loaded = task.Number11 / 60; act_estimated_hours = task.Work / 60; act_init_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Start); act_end_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Finish); try { //MessageBox.Show("INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'true', '', '')"); conn.Open(); MySqlDataReader reader; MySqlCommand command1; string commandStr1 = "INSERT INTO activities (req_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",LTRIM(RTRIM('" + act_trello_name + "')),'" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + 0 + ", 'true', '', '')"; command1 = new MySqlCommand(commandStr1, conn); reader = command1.ExecuteReader(); reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); contTitle++; contTitleT++; } catch (Exception errosql) { MessageBox.Show("Error en la consulta1\n\n" + errosql.Message); } } } } MessageBox.Show(contTask + " tareas agregadas a la base de datos.\n\n" + contTitle + " titulos agregados a la base de datos.\n\nCargadas desde: " + project); app.FileClose(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave, false); //cerramos el fichero } //} } catch (Exception err) { MessageBox.Show("Error en el proyecto\n\n" + err.Message, "Error"); } cont1++; } } MessageBox.Show("Se agrego un total de:\n\n\t- " + contTaskT + " tareas a la base de datos.\n\n\t- " + contTitleT + " titulos a la base de datos."); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { thisApp = Application; this.Application.NewProject += Application_NewProject; }
//"Server=127.0.0.1;Database=dbgestionocupacion;Uid=root;Pwd="; //"Server=10.48.13.154;Database=dbgestionocupacion;Uid=userInt;Pwd=userInt123456"; private void button1_Click(object sender, EventArgs e) { /* try * {*/ MySqlConnection conn = new MySqlConnection(connStr); /*} * catch (Exception errosql) * { * MessageBox.Show("Error en conexion a la base de datos\n\n" + errosql.Message); * }*/ //tabla Request List <int> req_id = new List <int>(); List <String> ms_project = new List <String>(); //Tabla activities List <String> act_trello_name = new List <String>(); List <DateTime> act_init_date = new List <DateTime>(); List <DateTime> act_init_real_date = new List <DateTime>(); List <DateTime> act_end_date = new List <DateTime>(); List <DateTime> act_real_end_date = new List <DateTime>(); List <String> act_title = new List <String>(); List <String> mails = new List <String>(); List <double> act_estimated_hours = new List <double>(); List <double> act_time_loaded = new List <double>(); List <double> act_porcent = new List <double>(); List <bool> used = new List <bool>(); //Llaves List <int> for_req_id = new List <int>(); try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM request WHERE req_cargar='false' AND sta_id = 'open';"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); req_id.Add(reader.GetInt32(0)); ms_project.Add(reader.GetString(4)); } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { MessageBox.Show("Error en la consulta\n\n" + errosql.Message); } try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM activities ORDER BY act_id asc;"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { for_req_id.Add(getintNotNull(reader, 1)); act_trello_name.Add(getStringNotNull(reader, 2)); act_init_date.Add(getDateTimeNotNull(reader, 5)); act_init_real_date.Add(getDateTimeNotNull(reader, 6)); act_end_date.Add(getDateTimeNotNull(reader, 7)); act_real_end_date.Add(getDateTimeNotNull(reader, 8)); act_estimated_hours.Add(getdoubleNotNull(reader, 9)); act_time_loaded.Add(getdoubleNotNull(reader, 17)); act_porcent.Add(getdoubleNotNull(reader, 19)); act_title.Add(getStringNotNull(reader, 20)); mails.Add(getStringNotNull(reader, 21)); used.Add(false); } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { MessageBox.Show("Error en la consulta\n\n" + errosql.Message); } ArrayList tasks = new ArrayList(); // se declara array de las tareas // creamos un objeto de tipo aplicacion MSProject MSProject.Application app = null; app = new MSProject.Application(); int cont = 0; int filteredListCount; bool test; for (int i = 0; i < ms_project.Count; i++) { if (ms_project[i] != null) { MessageBox.Show("Nombre del Project: " + ms_project[i]); try { // Si no hay problemas para abrir el project entrará en la condición // Fijense en la info que da FileOpen pues aqui indicarás especificas como lo quieres abrir (escritura/lectura) y la ruta, como está aqui es de la forma que se pueda escribir y leer en él if (app.FileOpen("C:/Home/Intelix/Mayoreo/00-Control-Solicitudes/" + ms_project[i] + "", false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSProject.PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing, Type.Missing, Type.Missing)) { //Se recorren los proyectos activos foreach (MSProject.Project proj in app.Projects) { //MessageBox.Show(string.Join(",", for_req_id.ToArray())); filteredListCount = for_req_id.Where(x => x == req_id[i]).ToList().Count; if (proj.Tasks.Count < filteredListCount) { MessageBox.Show("Para esta solicitud se añadieron cartas desde trello"); //proj.Tasks.Add(act_trello_name[i], i + 1); for (int k = proj.Tasks.Count; k < filteredListCount; k++) { proj.Tasks.Add("", k + 1); } } //Se recorre las tareas foreach (MSProject.Task task in proj.Tasks) { //proj.Tasks.Add(act_trello_name[i], i + 1); for (int j = 0; j < act_trello_name.Count; j++) { test = ((act_trello_name[j] == task.Name || "" == task.Name) && task.Rollup.ToString() == "False" && act_title[j] == "false" && req_id[i] == for_req_id[j] && used[j] == false); if (test) { used[j] = true; task.Name = act_trello_name[j]; task.Text10 = mails[j]; task.Number11 = act_time_loaded[j]; task.Start10 = act_init_real_date[j]; task.Finish10 = act_real_end_date[j]; task.Number10 = act_porcent[j]; cont++; continue; } if (act_title[j] == "true" && used[j] == false) { used[j] = true; } if (task.Rollup.ToString() == "True") { continue; } } } MessageBox.Show(cont + " tareas actualizadas"); app.FileClose(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave, false); //cerramos el fichero } } } catch (Exception err) { MessageBox.Show("Error en el proyecto\n\n" + err.Message, "Error"); } } } }
public static void RemoveMenu(object objApp, string appName, Office.CommandBar cbar, string menuName, string Name) { Office.CommandBars cbars = null; try { switch (appName) { case "Microsoft Excel": MsoExcel.Application appExcel = (MsoExcel.Application)objApp; cbars = appExcel.CommandBars; break; case "Microsoft PowerPoint": MsoPowerPoint.Application appPowerPoint = (MsoPowerPoint.Application)objApp; cbars = appPowerPoint.CommandBars; break; case "Microsoft Project": MsoProject.Application appProject = (MsoProject.Application)objApp; cbars = appProject.CommandBars; break; case "Microsoft Visio": MsoVisio.Application appVisio = (MsoVisio.Application)objApp; cbars = (Office.CommandBars)appVisio.CommandBars; break; case "Microsoft Word": MsoWord.Application appWord = (MsoWord.Application)objApp; cbars = appWord.CommandBars; break; // TODO: There is no ActiveExplorer when we exit app. How to handle? //case "Outlook": // Outlook.Application appOutlook = (Outlook.Application)objApp; // Outlook.Explorer explorer = appOutlook.ActiveExplorer(); // cbars = explorer.CommandBars; // break; default: MessageBox.Show("RemoveMenu:Unknown appName->" + appName + "<"); return; } cbar = cbars[menuName]; foreach (Office.CommandBarControl cbc in cbar.Controls) { if (cbc.Caption == Name) { cbc.Delete(Missing.Value); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw; } }
public IEnumerable <Prueba> GetAllPruebas() { /* try * {*/ //cadenas de construcción de conexión a servidor string connStr = "Server=10.48.13.154;Database=integracion;Uid=userInt;Pwd=userInt123456"; MySqlConnection conn = new MySqlConnection(connStr); /*} * catch (Exception errosql) * { * MessageBox.Show("Error en conexion a la base de datos\n\n" + errosql.Message); * }*/ double[] request_id = new double[50]; string[] ms_project = new string[50]; string[] act_trello_name = new string[50]; DateTime[] act_init_date = new DateTime[50]; DateTime[] act_init_real_date = new DateTime[50]; DateTime[] act_end_date = new DateTime[50]; DateTime[] act_real_end_date = new DateTime[50]; double[] act_estimated_hours = new double[50]; double[] act_time_loaded = new double[50]; double[] act_porcent = new double[50]; int contador = 0; int contador1 = 0; try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM request WHERE req_cargar='true';"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); request_id[contador1] = reader.GetDouble(0); ms_project[contador1] = reader.GetString(4); contador1++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { Pruebas[0] = new Prueba { Resultados = "Error en la consulta\n\n" + errosql.Message }; } try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM activities WHERE act_title = 'false';"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); act_trello_name[contador] = reader.GetString(2); //MessageBox.Show(act_trello_name[contador]); act_init_date[contador] = reader.GetDateTime(5); act_init_real_date[contador] = reader.GetDateTime(6); act_end_date[contador] = reader.GetDateTime(7); act_real_end_date[contador] = reader.GetDateTime(8); act_estimated_hours[contador] = reader.GetDouble(9); act_time_loaded[contador] = reader.GetDouble(17); //MessageBox.Show(act_time_loaded[contador].ToString()); act_porcent[contador] = reader.GetDouble(19); //MessageBox.Show(act_porcent[contador].ToString()); contador++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { Pruebas[1] = new Prueba { Resultados = "Error en la consulta\n\n" + errosql.Message }; } ArrayList tasks = new ArrayList(); // se declara array de las tareas // creamos un objeto de tipo aplicacion MSProject MSProject.Application app = null; app = new MSProject.Application(); int cont = 0; foreach (String project in ms_project) { if (project != null) { try { // Si no hay problemas para abrir el project entrará en la condición // Fijense en la info que da FileOpen pues aqui indicarás especificas como lo quieres abrir (escritura/lectura) y la ruta, como está aqui es de la forma que se pueda escribir y leer en él if (app.FileOpen("C:/Home/Intelix/Mayoreo/00-Control-Solicitudes/" + project + "", false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSProject.PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing, Type.Missing, Type.Missing)) { //Se recorren los proyectos activos foreach (MSProject.Project proj in app.Projects) { //Se recorre las tareas foreach (MSProject.Task task in proj.Tasks) { for (int i = 0; i < act_trello_name.Length; i++) { if (act_trello_name[i] == task.Name && task.Rollup.ToString() == "False") { task.Number11 = act_time_loaded[i]; task.Start10 = act_init_real_date[i]; task.Finish10 = act_real_end_date[i]; task.Number10 = act_porcent[i]; //actualizamos en el project el porcentaje if (cont % 10 == 0 && cont != 0) { } cont++; continue; } } } app.FileClose(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave, false); //cerramos el fichero } } } catch (Exception err) { Pruebas[2] = new Prueba { Resultados = "Error en el proyecto\n\n" + err.Message }; } } } return(Pruebas); }
private void LaunchMSProject() { try { this.application = new MSProject.Application(); application.Visible = true; System.Threading.Thread.Sleep(5000); application.Projects.Add(System.Type.Missing, System.Type.Missing, System.Type.Missing); this.project = this.application.ActiveProject; this.SetCalendarNoHolidays(); this.launched = true; #region Example code from http://social.technet.microsoft.com/Forums/ru-RU/project2010custprog/thread/0d4b2b34-3051-4b27-bb51-e3cae64ac9f9 //bool launched = false; //for (int timerSec = 0; timerSec < 20 && !launched; timerSec++) //{ // try // { // this.application.WorkOffline(false); // launched = true; // break; // } // catch // { // } //} //if (!launched) //{ // application.DocClose(); // System.Threading.Thread.Sleep(1500); // application.Quit(MSProject.PjSaveType.pjDoNotSave); // throw new ApplicationException("Unable to start an instance of MS Project"); //} #endregion } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public static new int Convert(String inputFile, String outputFile, Hashtable options) { Boolean running = (Boolean)options["noquit"]; MSProject.Application app = null; object missing = System.Reflection.Missing.Value; try { try { app = (MSProject.Application)Marshal.GetActiveObject("MSProject.Application"); } catch (System.Exception) { app = new MSProject.Application(); running = false; } System.Type type = app.GetType(); if (type.GetMethod("DocumentExport") == null || System.Convert.ToDouble(app.Version.ToString()) < 14) { Console.WriteLine("Not implemented with Office version {0}", app.Version); return (int)ExitCode.UnsupportedFileFormat; } app.ShowWelcome = false; app.DisplayAlerts = false; app.DisplayPlanningWizard = false; app.DisplayWizardErrors = false; Boolean includeProps = !(Boolean)options["excludeprops"]; Boolean markup = (Boolean)options["markup"]; FileInfo fi = new FileInfo(inputFile); switch(fi.Extension) { case ".mpp": MSProject.Project project = null; if (app.FileOpenEx(inputFile, false, MSProject.PjMergeType.pjDoNotMerge,missing, missing, missing, missing, missing, missing, missing, missing, MSProject.PjPoolOpen.pjDoNotOpenPool, missing, missing, false, missing)) { project = app.ActiveProject; } if (project == null) { return (int)ExitCode.UnknownError; } app.DocumentExport(outputFile, MSProject.PjDocExportType.pjPDF, includeProps, markup, false, missing, missing); app.FileCloseEx(MSProject.PjSaveType.pjDoNotSave, missing, missing); break; } return File.Exists(outputFile) ? (int)ExitCode.Success : (int)ExitCode.UnknownError; } catch (System.Exception e) { Console.WriteLine(e.Message); return (int)ExitCode.UnknownError; } finally { if (app != null && !running) { ((MSProject.Application)app).Quit(); } Converter.releaseCOMObject(app); } }
public IEnumerable <Prueba> GetAllPruebas() { string connStr = "Server=10.48.13.154;Database=integracion;Uid=userInt;Pwd=userInt123456"; MySqlConnection conn = new MySqlConnection(connStr); Pruebas[0] = new Prueba { Resultados = "Todo bien\n\n" }; //} //catch (Exception errosql) //{ // MessageBox.Show("Error en conexion a la base de datos\n\n" + errosql.Message); //} double[] request_id = new double[50]; double[] act_request_id = new double[50]; string[] ms_project = new string[3]; string act_trello_name; string act_init_date; string act_mail; string act_end_date; string act_trello_user; double act_estimated_hours; double act_time_loaded; double act_porcent; int contador = 0; int contador1 = 0; try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM request WHERE req_cargar='true';"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); request_id[contador1] = reader.GetDouble(0); //MessageBox.Show(request_id[contador1].ToString()); ms_project[contador1] = reader.GetString(4); contador1++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { Pruebas[1] = new Prueba { Resultados = "Error en la consulta\n\n" + errosql.Message }; } try { conn.Open(); MySqlDataReader reader; MySqlCommand command; string commandStr = "SELECT * FROM activities;"; command = new MySqlCommand(commandStr, conn); reader = command.ExecuteReader(); while (reader.Read()) { //MessageBox.Show("aqui\n\n"); //act_trello_name[contador] = reader.GetString(2); act_request_id[contador1] = reader.GetDouble(1); //MessageBox.Show(act_request_id[contador1].ToString()); contador++; } reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); } catch (Exception errosql) { Pruebas[2] = new Prueba { Resultados = "Error en la consulta1\n\n" + errosql.Message }; } ArrayList tasks = new ArrayList(); // se declara array de las tareas // creamos un objeto de tipo aplicacion MSProject int cont = 0; int cont1 = 0; string[] task_names = new string[50]; MSProject.Application app = null; app = new MSProject.Application(); Pruebas[3] = new Prueba { arr = ms_project }; foreach (String project in ms_project) { if (project != null) { try { // Si no hay problemas para abrir el project entrará en la condición // Fijense en la info que da FileOpen pues aqui indicarás especificas como lo quieres abrir (escritura/lectura) y la ruta, como está aqui es de la forma que se pueda escribir y leer en él if (app.FileOpen("C:/Home/Intelix/Mayoreo/00-Control-Solicitudes/" + project + "", false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, MSProject.PjPoolOpen.pjPoolReadWrite, Type.Missing, Type.Missing, Type.Missing, Type.Missing)) { foreach (MSProject.Project proj in app.Projects) { //Se recorre las tareas foreach (MSProject.Task task in proj.Tasks) { if (task.Rollup.ToString() == "False") { act_trello_name = task.Name; act_time_loaded = task.ActualWork / 60; act_estimated_hours = task.Work / 60; act_init_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Start); act_end_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Finish); act_trello_user = task.ResourceNames; act_mail = task.Text10; act_porcent = task.Number10; if (cont % 10 == 0 && cont != 0) { } try { //MessageBox.Show("INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'false', '" + act_trello_user + "', '" + act_mail + "')"); conn.Open(); MySqlDataReader reader; MySqlCommand command1; string commandStr1 = "INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'false', '" + act_trello_user + "', '" + act_mail + "')"; command1 = new MySqlCommand(commandStr1, conn); reader = command1.ExecuteReader(); reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); cont++; } catch (Exception errosql) { Pruebas[4] = new Prueba { Resultados = "Error en la consulta\n\n" + errosql.Message }; } //continue; } else { act_trello_name = task.Name; act_time_loaded = task.Number11 / 60; act_estimated_hours = task.Work / 60; act_init_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Start); act_end_date = String.Format("{0:yyyy-MM-dd HH:mm:ss}", task.Finish); act_porcent = task.Number10; if (cont % 10 == 0 && cont != 0) { } try { //MessageBox.Show("INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'true', '', '')"); conn.Open(); MySqlDataReader reader; MySqlCommand command1; string commandStr1 = "INSERT INTO activities (act_request_id, act_trello_name, act_init_date, act_end_date, act_estimated_hours, act_time_loaded ,act_porcent, act_title, act_trello_user, act_mail) VALUES (" + request_id[cont1] + ",'" + act_trello_name + "','" + act_init_date + "', '" + act_end_date + "', " + act_estimated_hours + "," + act_time_loaded + ", " + act_porcent + ", 'true', '', '')"; command1 = new MySqlCommand(commandStr1, conn); reader = command1.ExecuteReader(); reader.Close(); //importante cerrar el reader pues solo se puede tener uno abierto a la vez conn.Close(); cont++; } catch (Exception errosql) { Pruebas[5] = new Prueba { Resultados = "Error en la consulta\n\n" + errosql.Message }; } } } } app.FileClose(Microsoft.Office.Interop.MSProject.PjSaveType.pjSave, false); //cerramos el fichero } //} } catch (Exception err) { Pruebas[6] = new Prueba { Resultados = "Error en la consulta\n\n" + err.Message }; } cont1++; } } return(Pruebas); }
private void btImport_Click(object sender, EventArgs e) { var address = tbAddress.Text.Trim(); var userName = tbUserName.Text.Trim(); var password = tbPassword.Text.Trim(); Properties.Settings.Default["Address"] = address; Properties.Settings.Default["UserName"] = userName; Properties.Settings.Default["Password"] = JonGallowaySecuriyString.EncryptString(JonGallowaySecuriyString.ToSecureString(password)); using (var client = new WebClient()) { var protocol = "http"; var urlprefix = $"{protocol}://{address}/api/2.0/"; client.Encoding = System.Text.Encoding.UTF8; client.Headers["Accept"] = "text/xml"; client.Headers["Content-type"] = "application/x-www-form-urlencoded"; string res = ""; string token; XDocument xdoc; try { res = client.UploadString(urlprefix + "authentication.xml", $"userName={userName}&password={password}"); xdoc = XDocument.Parse(res); token = xdoc.XPathSelectElement("//token").Value; } catch (WebException ex) { SLog.Append(SLog.Type.Error, ex.Message); return; } catch (XmlSyntaxException ex) { SLog.Append(SLog.Type.Error, ex.Message); return; } SLog.Append($"Token: {token}"); client.Headers["Authorization"] = token; res = client.DownloadString($"{urlprefix}project/@self.xml"); xdoc = XDocument.Parse(res); var selectProject = new SelectProject() { Projects = xdoc.XPathSelectElements("//response") .ToDictionary(node => node.XPathSelectElement("./id").Value, node => node.XPathSelectElement("./title").Value) }; if (selectProject.ShowDialog() != DialogResult.OK) { SLog.Append(SLog.Type.Warning, "User cancel"); return; } var projectId = selectProject.SelectedProjectId; SLog.Append($"ProjectID: {projectId}"); res = client.DownloadString($"{urlprefix}project/{projectId}/task.xml"); xdoc = XDocument.Parse(res); // Resource list var persons = new Dictionary <string, string>(); foreach (var xperson in xdoc.XPathSelectElements("/result/response/responsibles")) { var id = xperson.XPathSelectElement("id").Value; if (persons.ContainsKey(id)) { continue; } var displayName = xperson.XPathSelectElement("displayName").Value; persons[id] = displayName; } // Task list var msapp = new MSProject.Application { Visible = true }; var msproject = msapp.Projects.Add(); foreach (var person in persons) { var msresource = msproject.Resources.Add(person.Value); msresource.Code = person.Key; msresource.EnterpriseText40 = person.Key; } foreach (var xtask in xdoc.XPathSelectElements("/result/response")) { var title = xtask.XPathSelectElement("title").Value; var mstask = msproject.Tasks.Add(title); mstask.EnterpriseText40 = xtask.XPathSelectElement("id").Value; var xresource = xtask.XPathSelectElement("responsibles"); if (xresource != null) { mstask.ResourceNames = xresource.XPathSelectElement("displayName").Value; } var xstart = xtask.XPathSelectElement("startDate"); if (xstart != null) { mstask.Start = DateTime.Parse(xstart.Value); } var xfinish = xtask.XPathSelectElement("deadline"); if (xfinish != null) { mstask.Finish = DateTime.Parse(xfinish.Value); } var xnotes = xtask.XPathSelectElement("description"); if (xnotes != null) { mstask.Notes = xnotes.Value; } } } SaveSettings(); }