Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     progressBar.Value = 100;
     asyncActiveDownload.Component.Downloaded = true;
     GroupDocsComponentsManager.storeVersion(asyncActiveDownload.Component);
     UnZipDownloadedFile(asyncActiveDownload);
     AbortButton.Enabled = true;
     processDownloadList();
 }
Ejemplo n.º 3
0
        private bool performFinish()
        {
            ContinueButton.Enabled = false;
            processComponents();

            if (!GroupDocsComponentsManager.isIneternetConnected())
            {
                this.showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return(false);
            }

            GlobalData.backgroundWorker = new BackgroundWorker();
            GlobalData.backgroundWorker.WorkerReportsProgress      = true;
            GlobalData.backgroundWorker.WorkerSupportsCancellation = true;

            GlobalData.backgroundWorker.DoWork             += new DoWorkEventHandler(backgroundWorker_DoWork);
            GlobalData.backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            GlobalData.backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            GlobalData.backgroundWorker.RunWorkerAsync();

            return(true);
        }
Ejemplo n.º 4
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                UpdateProgress(1);
                int total = 10;
                int index = 0;

                GroupDocsComponentsManager comManager = new GroupDocsComponentsManager(this);
                foreach (GroupDocsComponent component in GroupDocsComponents.list.Values)
                {
                    if (component.is_selected())
                    {
                        GlobalData.SelectedComponent = component.get_name();

                        if (GroupDocsComponentsManager.libraryAlreadyExists(component.get_downloadFileName()))
                        {
                            component.set_downloaded(true);
                        }
                        else
                        {
                            GroupDocsComponentsManager.addToDownloadList(component, component.get_downloadUrl(), component.get_downloadFileName());
                        }
                    }

                    decimal percentage = ((decimal)(index + 1) / (decimal)total) * 100;
                    UpdateProgress(Convert.ToInt32(percentage));

                    index++;
                }

                UpdateProgress(100);
                UpdateText("All operations completed");
            }
            catch (Exception) { }
        }
Ejemplo n.º 5
0
 private void UnZipDownloadedFile(AsyncDownload download)
 {
     GroupDocsComponentsManager.unZipFile(download.LocalPath, Path.Combine(Path.GetDirectoryName(download.LocalPath), download.Component.Name));
 }
        bool CopyAndCreateProject()
        {
            progressBar1.Visible           = true;
            progressBar1.Value             = 10;
            toolStripStatusMessage.Visible = true;
            toolStripStatusMessage.Text    = "Fetching Examples: - Please wait while we configure you preferences";
            GroupDocsComponent component;

            GroupDocsComponents.list.TryGetValue(Constants.GROUPDOCS_COMPONENT, out component);
            //TreeNodeData nodeData = (TreeNodeData)selectedNode.Tag;
            //string sampleSourcePath = "GroupDocs.Annotation";
            string sampleSourcePath = "Examples";
            string repoPath         = GitHelper.getLocalRepositoryPath(component);
            string destinationPath  = GetDestinationPath(textBoxLocation.Text + "\\" + Constants.GROUPDOCS_COMPONENT, sampleSourcePath);

            progressBar1.Value = 30;

            bool isSuccessfull = false;

            try
            {
                CopyFolderContents(Path.Combine(repoPath, sampleSourcePath), destinationPath);
                progressBar1.Value = 40;

                string   dllsRootPath = GroupDocsComponentsManager.getLibaryDownloadPath();
                string[] dllsPaths    = Directory.GetFiles(Path.Combine(dllsRootPath, component.Name + "/lib/"), "*.dll");
                for (int i = 0; i < dllsPaths.Length; i++)
                {
                    //For CSharp Project...
                    if (!Directory.Exists(Path.Combine(destinationPath, "CSharp", "Bin", "Debug")))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationPath, "CSharp", "Bin", "Debug"));
                    }
                    File.Copy(dllsPaths[i], Path.Combine(destinationPath, "CSharp", "Bin", "Debug", Path.GetFileName(dllsPaths[i])), true);

                    //For VBasic Project...
                    if (!Directory.Exists(Path.Combine(destinationPath, "VisualBasic", "Bin", "Debug")))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationPath, "VisualBasic", "Bin", "Debug"));
                    }
                    File.Copy(dllsPaths[i], Path.Combine(destinationPath, "VisualBasic", "Bin", "Debug", Path.GetFileName(dllsPaths[i])), true);
                }

                progressBar1.Value = 50;

                string[] projectFiles = Directory.GetFiles(Path.Combine(destinationPath, (rdbCSharp.Checked ? "CSharp" : "VisualBasic")), (rdbCSharp.Checked ? "*.csproj" : "*.vbproj"));
                for (int i = 0; i < projectFiles.Length; i++)
                {
                    UpdatePrjReferenceHintPath(projectFiles[i], component);
                }
                progressBar1.Value = 70;

                int vsVersion = GetVSVersion();

                if (vsVersion >= 2010)
                {
                    vsVersion = 2010;                    // Since our examples mostly have 2010 solution files
                }
                string[] solutionFiles = Directory.GetFiles(destinationPath, (rdbCSharp.Checked ? "*.sln" : "*.sln"));
                progressBar1.Value = 80;

                string language = rdbCSharp.Checked == true ? "csharp" : "visualbasic";
                try
                {
                    if (solutionFiles.Length > 0)
                    {
                        foreach (string sFile in solutionFiles)
                        {
                            //if (sFile.Contains(vsVersion.ToString()))
                            {
                                if (sFile.ToLower().Contains(language))
                                {
                                    _application.Solution.Open(sFile);
                                    isSuccessfull = true;
                                    break;
                                }
                            }
                            //else
                            //{

                            //}
                        }

                        if (!isSuccessfull)
                        {
                            System.Diagnostics.Process.Start(solutionFiles[solutionFiles.Count() - 1]);
                            isSuccessfull = true;
                        }
                    }
                    else if (projectFiles.Length > 0)
                    {
                        foreach (string pFile in solutionFiles)
                        {
                            if (pFile.ToLower().Contains(language))
                            {
                                System.Diagnostics.Process.Start(pFile);
                                isSuccessfull = true;
                            }
                        }
                    }
                    progressBar1.Value = 90;
                }
                catch (Exception exp)
                {
                    //MessageBox.Show(exp.Message);
                    //if (solutionFiles.Length > 0)
                    //{
                    //    System.Diagnostics.Process.Start(solutionFiles[0]);
                    //    isSuccessfull = true;
                    //}
                    //else if (projectFiles.Length > 0)
                    //{
                    //    System.Diagnostics.Process.Start(projectFiles[0]);
                    //    isSuccessfull = true;
                    //}
                    //progressBar1.Value = 90;
                }
            }
            catch (Exception exp)
            {
                //MessageBox.Show("Exception occured: " + exp.Message);
            }

            if (!isSuccessfull)
            {
                MessageBox.Show("Oops! We are unable to open the example project. Please open it manually from " + destinationPath);
                return(false);
            }
            progressBar1.Value = 100;

            return(true);
        }