Fixed this issue: http://npanday.codeplex.com/WorkItem/View.aspx?WorkItemId=10315. should execute re-sync artifacts prior to re-import


git-svn-id: https://svn.apache.org/repos/asf/incubator/npanday/trunk@994065 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
index 222046c..b7bdf23 100644
--- a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
+++ b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
@@ -855,6 +855,7 @@
 

         void resetReferenceButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)

         {

+            outputWindowPane.OutputString("\nRe-syncing artifacts...");

             try

             {

                 IReferenceManager refmanager = new ReferenceManager();

@@ -862,10 +863,11 @@
                 refmanager.Initialize((VSProject2)CurrentSelectedProject.Object);

                 

                 refmanager.ResyncArtifacts();

-

+                outputWindowPane.OutputString(string.Format("done [{0}]", DateTime.Now.ToString("hh:mm tt")));

             }

             catch (Exception ex)

             {

+                outputWindowPane.OutputString(string.Format("ERROR! [{0}]", DateTime.Now.ToString("hh:mm tt")));

                 MessageBox.Show(ex.Message, "Reset References", MessageBoxButtons.OK, MessageBoxIcon.Error);

             }

         }

@@ -989,20 +991,36 @@
 

         void resetAllButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)

         {

-            if (_applicationObject.Solution != null)

+            outputWindowPane.OutputString("\nRe-syncing artifacts...");

+            try

             {

-                Solution2 solution = (Solution2)_applicationObject.Solution;

-                foreach (Project project in solution.Projects)

+                if (_applicationObject.Solution != null)

                 {

-                    if (!IsWebProject(project))

+                    Solution2 solution = (Solution2)_applicationObject.Solution;

+                    foreach (Project project in solution.Projects)

                     {

-                        IReferenceManager mgr = new ReferenceManager();

-                        mgr.OnError += new EventHandler<ReferenceErrorEventArgs>(mgr_OnError);

-                        mgr.Initialize((VSProject2)project.Object);

-                        mgr.ResyncArtifacts();

-                        mgr = null;

+                        if (!IsWebProject(project))

+                        {

+                            IReferenceManager mgr = new ReferenceManager();

+                            mgr.OnError += new EventHandler<ReferenceErrorEventArgs>(mgr_OnError);

+                            mgr.Initialize((VSProject2)project.Object);

+                            mgr.ResyncArtifacts();

+                            mgr = null;

+                        }

                     }

                 }

+                outputWindowPane.OutputString(string.Format("done [{0}]", DateTime.Now.ToString("hh:mm tt")));

+            }

+            catch (Exception ex)

+            {

+                if (ex.Message.Contains("no valid pom file."))

+                {

+                    outputWindowPane.OutputString(string.Format("done [{0}]", DateTime.Now.ToString("hh:mm tt")));

+                }

+                else

+                {

+                    outputWindowPane.OutputString(string.Format("ERROR! [{0}]\n\n{1}\n\n", ex.Message, ex.StackTrace));

+                }

             }

         }

 

@@ -1695,24 +1713,7 @@
         private void cbChangeProjectImportForm_Click(CommandBarButton btn, ref bool Cancel)

         {

             SaveAllDocuments();

-            outputWindowPane.OutputString("\nRe-syncing artifacts...");

-            try

-            {

-                resetAllButton_Click(btn, ref Cancel);

-                outputWindowPane.OutputString(string.Format("done [{0}]", DateTime.Now.ToString("hh:mm tt")));

-            }

-            catch (Exception ex)

-            {

-                if (ex.Message.Contains("no valid pom file."))

-                {

-                    outputWindowPane.OutputString(string.Format("done [{0}]", DateTime.Now.ToString("hh:mm tt")));

-                }

-                else

-                {

-                    outputWindowPane.OutputString(string.Format("ERROR! [{0}]", DateTime.Now.ToString("hh:mm tt")));

-                    throw;

-                }

-            }

+            resetAllButton_Click(btn, ref Cancel);

             NPandayImportProjectForm frm = new NPandayImportProjectForm(_applicationObject);

             frm.ShowDialog();

         }

diff --git a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
index 7dbff01..d3233bf 100644
--- a/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
+++ b/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
@@ -141,13 +141,16 @@
         {

             Artifact.ArtifactRepository repository = new NPanday.Artifact.ArtifactContext().GetArtifactRepository();

             NPanday.Model.Pom.Model m = NPanday.Utils.PomHelperUtility.ReadPomAsModel(new FileInfo(pomFile));

-            

-            foreach (Dependency d in m.dependencies)

+

+            if (m.dependencies != null)

             {

-                // artifacts from remote repository only

-                if (d.systemPath == null)

+                foreach (Dependency d in m.dependencies)

                 {

-                    CopyArtifact(repository.GetArtifact(d));

+                    // artifacts from remote repository only

+                    if (d.systemPath == null)

+                    {

+                        CopyArtifact(repository.GetArtifact(d));

+                    }

                 }

             }

         }