public static void addToDownloadList(GroupDocsComponent component, string urlStr, string outputFile)
 {
     AsyncDownload asyncDownload = new AsyncDownload();
     asyncDownload.Url = urlStr;
     asyncDownload.LocalPath = getLibaryDownloadPath() + outputFile;
     asyncDownload.Component = component;
     AsyncDownloadList.list.Add(asyncDownload);
 }
        public static string readVersion(GroupDocsComponent component)
        {
            string localPath = getLibaryDownloadPath() + component.get_name() + ".ver";
            string line = string.Empty;

            try
            {
                return System.IO.File.ReadAllText(localPath);
            }
            catch (Exception) { }
            return line;
        }
        public static void storeVersion(GroupDocsComponent component)
        {
            string localPath = getLibaryDownloadPath() + component.get_name() + ".ver";

            try
            {
                System.IO.File.WriteAllText(localPath, component.get_latestVersion());
            }
            catch (FileNotFoundException e)
            {
            }
            catch (Exception e)
            {
            }
        }
        public void storeReleaseNotes(GroupDocsComponent component)
        {
            string localPath = getLibaryDownloadPath() + component.get_name() + ".htm";

            try
            {
                System.IO.File.WriteAllText(localPath, component.get_changeLog());
            }
            catch (FileNotFoundException e)
            {
            }
            catch (Exception e)
            {
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>
        public static string CloneOrCheckOutRepo(GroupDocsComponent component)
        {
            string repUrl = component.get_remoteExamplesRepository();
            string localFolder = getLocalRepositoryPath(component);
            string error = string.Empty;

            checkAndCreateFolder(getLocalRepositoryPath(component));

            try
            {
                CloneCommand clone = Git.CloneRepository();
                clone.SetURI(repUrl);
                clone.SetDirectory(localFolder);

                Git repo = clone.Call();
                //writer.Close();
                repo.GetRepository().Close();
               }
            catch (Exception ex)
            {

                try
                {
                    var git = Git.Open(localFolder);
                    //var repository = git.GetRepository();
                    //PullCommand pullCommand = git.Pull();
                    //pullCommand.Call();
                    //repository.Close();

                    var reset = git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef("origin/master").Call();

                }
                catch (Exception ex2)
                {

                    error = ex2.Message;
                }

                error = ex.Message;
            }

            return error;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>

        public static string CloneOrCheckOutRepo(GroupDocsComponent component)
        {
            string repUrl      = component.get_remoteExamplesRepository();
            string localFolder = getLocalRepositoryPath(component);
            string error       = string.Empty;

            checkAndCreateFolder(getLocalRepositoryPath(component));

            try
            {
                CloneCommand clone = Git.CloneRepository();
                clone.SetURI(repUrl);
                clone.SetDirectory(localFolder);

                Git repo = clone.Call();
                //writer.Close();
                repo.GetRepository().Close();
            }
            catch (Exception ex)
            {
                try
                {
                    var git = Git.Open(localFolder);
                    //var repository = git.GetRepository();
                    //PullCommand pullCommand = git.Pull();
                    //pullCommand.Call();
                    //repository.Close();

                    var reset = git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef("origin/master").Call();
                }
                catch (Exception ex2)
                {
                    error = ex2.Message;
                }

                error = ex.Message;
            }

            return(error);
        }
        public void storeReleaseNotes(GroupDocsComponent component)
        {
            string localPath = getLibaryDownloadPath() + component.get_name() + ".htm";
            try
            {
                System.IO.File.WriteAllText(localPath, component.get_changeLog());
            }
            catch (FileNotFoundException e)
            {

            }
            catch (Exception e)
            {

            }
        }
        public static void storeVersion(GroupDocsComponent component)
        {
            string localPath = getLibaryDownloadPath() + component.get_name() + ".ver";
            try
            {
                System.IO.File.WriteAllText(localPath, component.get_latestVersion());
            }
            catch (FileNotFoundException e)
            {

            }
            catch (Exception e)
            {

            }
        }
        private void UpdatePrjReferenceHintPath(string projectFilePath, GroupDocsComponent component)
        {
            if (!File.Exists(projectFilePath))
                return;

            XmlDocument xdDoc = new XmlDocument();
            xdDoc.Load(projectFilePath);

            XmlNamespaceManager xnManager =
             new XmlNamespaceManager(xdDoc.NameTable);
            xnManager.AddNamespace("tu",
             "http://schemas.microsoft.com/developer/msbuild/2003");

            XmlNode xnRoot = xdDoc.DocumentElement;
            XmlNodeList xnlPages = xnRoot.SelectNodes("//tu:ItemGroup", xnManager);
            foreach (XmlNode node in xnlPages)
            {
                XmlNodeList nodelist = node.SelectNodes("//tu:HintPath", xnManager);
                foreach (XmlNode nd in nodelist)
                {
                    string innter = nd.InnerText;
                    nd.InnerText = "..\\Bin\\Debug\\" + component.Name + ".dll";
                }
            }

            xdDoc.Save(projectFilePath);
        }
 private void CloneOrCheckOutRepoWorker(GroupDocsComponent component)
 {
     GitHelper.CloneOrCheckOutRepo(component);
     downloadTaskCompleted = true;
 }
 private void CloneOrCheckOutRepo(GroupDocsComponent component)
 {
     downloadTaskCompleted = false;
     timer1.Start();
     Task repoUpdateWorker = new Task(delegate { CloneOrCheckOutRepoWorker(component); });
     repoUpdateWorker.Start();
     progressTask = new Task(delegate { progressDisplayTask(); });
     progressBar1.Enabled = true;
     progressTask.Start();
     ContinueButton.Enabled = false;
     toolStripStatusMessage.Text = "Please wait while the Examples are being downloaded...";
 }
        private void checkAndUpdateRepo(GroupDocsComponent component)
        {
            if (null == component)
                return;
            if (null == component.get_remoteExamplesRepository() || component.RemoteExamplesRepository == string.Empty)
            {
                showMessage("Examples not available", component.get_name() + " - " + Constants.EXAMPLES_NOT_AVAILABLE_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                examplesNotAvailable = true;
                return;
            }
            else
            {
                examplesNotAvailable = false;
            }

            if (GroupDocsComponentsManager.isIneternetConnected())
            {
                CloneOrCheckOutRepo(component);
            }
            else
            {
                showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, component.get_name() + " - " + Constants.EXAMPLES_INTERNET_CONNECTION_REQUIRED_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 public static string getLocalRepositoryPath(GroupDocsComponent component)
 {
     return GroupDocsComponentsManager.getAsposeHomePath() + "gitrepos" + "/" + component.get_name();
 }
 void processComponents()
 {
     GroupDocsComponent component = new GroupDocsComponent();
     GroupDocsComponents.list.TryGetValue(Constants.GROUPDOCS_COMPONENT, out component);
     component.Selected = true;
 }
 public static string getLocalRepositoryPath(GroupDocsComponent component)
 {
     return(GroupDocsComponentsManager.getAsposeHomePath() + "gitrepos" + "/" + component.get_name());
 }