Exemplo n.º 1
0
        public void Execute(Solution solution)
        {
            string solutionHeaderDefinitionFilePath = LicenseHeader.GetHeaderDefinitionFilePathForSolution(solution);

            if (File.Exists(solutionHeaderDefinitionFilePath))
            {
                solution.DTE.OpenFile(EnvDTE.Constants.vsViewKindTextView, solutionHeaderDefinitionFilePath).Activate();
            }
        }
Exemplo n.º 2
0
        public void Execute(Solution solution)
        {
            string solutionHeaderDefinitionFilePath = LicenseHeader.GetHeaderDefinitionFilePathForSolution(solution);

            // Add file
            string defaultLicenseHeaderFileText = this._defaultHeaderDefinitionFunc();

            File.WriteAllText(solutionHeaderDefinitionFilePath, defaultLicenseHeaderFileText, Encoding.UTF8);

            solution.DTE.OpenFile(EnvDTE.Constants.vsViewKindTextView, solutionHeaderDefinitionFilePath).Activate();
        }
        private void HandleAddLicenseHeaderToAllFilesReturn(object obj,
                                                            AddLicenseHeaderToAllFilesReturn addLicenseHeaderToAllFilesReturn)
        {
            var project     = obj as Project;
            var projectItem = obj as ProjectItem;

            if (project == null && projectItem == null)
            {
                return;
            }
            Project currentProject = project;

            if (projectItem != null)
            {
                currentProject = projectItem.ContainingProject;
            }

            if (addLicenseHeaderToAllFilesReturn.NoHeaderFound)
            {
                //No license header found...
                var page             = (DefaultLicenseHeaderPage)GetDialogPage(typeof(DefaultLicenseHeaderPage));
                var solutionSearcher = new AllSolutionProjectsSearcher();
                var projects         = solutionSearcher.GetAllProjects(_dte.Solution);

                //If there is a licenseheader in the Solution
                if (projects.Any(projectInSolution => LicenseHeaderFinder.GetHeader(projectInSolution) != null))
                {
                    if (MessageBoxHelper.DoYouWant(Resources.Question_AddExistingDefinitionFileToProject))
                    {
                        new AddExistingLicenseHeaderDefinitionFileCommand().AddDefinitionFileToOneProject(currentProject.FileName, currentProject.ProjectItems);

                        AddLicenseHeadersToAllFilesCallback((object)project ?? projectItem, null);
                    }
                }
                else
                {
                    if (MessageBoxHelper.DoYouWant(Resources.Question_AddNewLicenseHeaderDefinitionFileSingleProject))
                    {
                        var licenseHeader = LicenseHeader.AddLicenseHeaderDefinitionFile(currentProject, DefaultLicenseHeaderPage);

                        if (!MessageBoxHelper.DoYouWant(Resources.Question_StopForConfiguringDefinitionFilesSingleFile))
                        {
                            AddLicenseHeadersToAllFilesCallback((object)project ?? projectItem, null);
                        }
                        else if (licenseHeader != null)
                        {
                            licenseHeader.Open(Constants.vsViewKindCode).Activate();
                        }
                    }
                }
            }
        }
        private IEnumerable <ProjectItem> AddNewLicenseHeaderDefinitionFilesToProjects(List <Project> projectsWithoutLicenseHeader,
                                                                                       IDefaultLicenseHeaderPage page)
        {
            List <ProjectItem> newLicenseHeaders = new List <ProjectItem>();

            foreach (Project project in projectsWithoutLicenseHeader)
            {
                if (projectsWithoutLicenseHeader.Contains(project))
                {
                    newLicenseHeaders.Add(LicenseHeader.AddLicenseHeaderDefinitionFile(project, page));
                }
            }

            return(newLicenseHeaders);
        }
Exemplo n.º 5
0
        internal bool AddinIsValid(string addin, out DateTime dueDate)
        {
            string xmlKey;
            string licenseXml;

            dueDate = DateTime.MinValue;
            AddInAttribute addinAttribute = getAddinAttribute(addin);

            if (string.IsNullOrWhiteSpace(addinAttribute.LicenseFile))
            {
                dueDate = DateTime.MaxValue;
                return(true);
            }
            xmlKey = readKeyXML(addin, addinAttribute.LicenseFile);

            if (string.IsNullOrWhiteSpace(xmlKey) || string.IsNullOrWhiteSpace(addinAttribute.Namespace))
            {
                return(false);
            }

            licenseXml = licenseDAO.GetLicense(addinAttribute.Namespace);

            if (licenseXml == null || !CheckSignature(licenseXml, xmlKey))
            {
                return(false);
            }

            string sysNumber     = sapApp.Company.SystemId;
            string installNumber = sapApp.Company.InstallationId;

            LicenseHeader licenseFile = licenseXml.Deserialize <LicenseHeader>();

            if (!string.IsNullOrEmpty(licenseFile.SystemNumber) &&
                !string.IsNullOrEmpty(licenseFile.InstallNumber) &&
                licenseFile.SystemNumber == sysNumber && licenseFile.InstallNumber == installNumber)
            {
                List <LicenseModule> licenseModules = licenseFile.Items.Where(i => i.Name == addin).ToList();;
                if (licenseModules != null && licenseModules.Count() > 0)
                {
                    dueDate = licenseModules[0].ExpirationDate;
                }
            }

            return(GetDate() < dueDate);
        }
Exemplo n.º 6
0
        public void Present(
            SimpleInterfaceServerDispatcher interfaceServerDispatcher,
            FromProcessMeasurement <Interface.MemoryStruct.IMemoryMeasurement> measurement)
        {
            MeasurementLastHeader?.SetStatus(measurement.MemoryMeasurementLastStatusEnum());

            LicenseHeader?.SetStatus(interfaceServerDispatcher.LicenseStatusEnum());
            ProcessHeader?.SetStatus(ProcessChoice.ProcessStatusEnum());

            LicenseDataContext.Dispatcher = interfaceServerDispatcher;

            var sessionDurationRemainingTooShort = !(measurement?.Value).SessionDurationRemainingSufficientToStayExposed();

            SessionDurationRemainingTextBox.Text             = (measurement?.Value?.SessionDurationRemaining?.ToString() ?? "????");
            SessionDurationRemainingTooShortGroup.Visibility = (sessionDurationRemainingTooShort && null != measurement) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;

            Measurement?.Present(measurement);
        }
Exemplo n.º 7
0
        protected internal virtual void SaveLicense(string xmlPath)
        {
            string xml = null;

            if (File.Exists(xmlPath))
            {
                xml = File.ReadAllText(xmlPath);
            }
            else
            {
                throw new ArgumentException();
            }

            LicenseHeader licenseFile = xml.Deserialize <LicenseHeader>();
            string        licenseID   = licenseDAO.SaveLicense(xml, licenseFile.LicenseNamespace);

            UpdateAddinDueDateByNamespace(licenseFile.LicenseNamespace);
        }
Exemplo n.º 8
0
        public void Execute(Solution solution)
        {
            string solutionHeaderDefinitionFilePath = LicenseHeader.GetHeaderDefinitionFilePathForSolution(solution);

            // Look for and close the document if it exists
            foreach (EnvDTE.Document document in solution.DTE.Documents)
            {
                if (string.Equals(solutionHeaderDefinitionFilePath, document.FullName, StringComparison.OrdinalIgnoreCase))
                {
                    document.Close();
                }
            }

            // Delete the file
            if (File.Exists(solutionHeaderDefinitionFilePath))
            {
                File.Delete(solutionHeaderDefinitionFilePath);
            }
        }
Exemplo n.º 9
0
        private void AddNewLicenseHeaderDefinitionFileToProjectCallback(object sender, EventArgs e)
        {
            var page         = (DefaultLicenseHeaderPage)GetDialogPage(typeof(DefaultLicenseHeaderPage));
            var solutionItem = GetSolutionExplorerItem();
            var project      = solutionItem as Project;

            if (project == null)
            {
                var projectItem = solutionItem as ProjectItem;
                if (projectItem != null)
                {
                    LicenseHeader.AddLicenseHeaderDefinitionFile(projectItem, page);
                }
            }

            if (project != null)
            {
                var licenseHeaderDefinitionFile = LicenseHeader.AddHeaderDefinitionFile(project, page);
                licenseHeaderDefinitionFile.Open(Constants.vsViewKindCode).Activate();
            }
        }
Exemplo n.º 10
0
        private void AddLicenseHeaderToItem(ProjectItem item, bool calledByUser)
        {
            if (item == null || ProjectItemInspection.IsLicenseHeader(item))
            {
                return;
            }


            var headers = LicenseHeaderFinder.GetHeaderDefinitionForItem(item);

            if (headers != null)
            {
                _licenseReplacer.RemoveOrReplaceHeader(item, headers, calledByUser);
            }
            else
            {
                var page = (DefaultLicenseHeaderPage)GetDialogPage(typeof(DefaultLicenseHeaderPage));
                if (calledByUser && LicenseHeader.ShowQuestionForAddingLicenseHeaderFile(item.ContainingProject, page))
                {
                    AddLicenseHeaderToItem(item, true);
                }
            }
        }
Exemplo n.º 11
0
        public void InstallLicense()
        {
            LicenseHeader header = new LicenseHeader()
            {
                InstallNumber = b1App.Company.InstallationId,
                SystemNumber  = b1App.Company.SystemId,
                Items         = new List <LicenseModule>()
                {
                    new LicenseModule()
                    {
                        Description = "I18NExample", Name = "I18NExample", ExpirationDate = DateTime.Today.AddDays(3)
                    },
                    new LicenseModule()
                    {
                        Description = "Foo", Name = "Foo", ExpirationDate = DateTime.Today.AddDays(3)
                    },
                },
                LicenseNamespace = "DOVER_WL"
            };
            LicenseService service     = new LicenseService();
            var            privateKey  = CreateKeys.CreateKeyPair();
            string         xmlLicense  = service.GenerateLicense(header, privateKey);
            string         licensePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "license.xml");

            File.WriteAllText(licensePath, xmlLicense);

            Form     licenseForm         = UIHelper.GetFormAfterAction("Dover.license", b1App, () => b1App.Menus.Item("doverLicense").Activate());
            EditText licensePathEditText = (EditText)licenseForm.Items.Item("moduleEd").Specific;

            licensePathEditText.Value = licensePath;
            licenseForm.Items.Item("importBt").Click();
            AssertNoFrameworkError();
            BusinessOneDAO b1DAO = app.Resolve <BusinessOneDAO>();

            Assert.AreEqual(b1DAO.ExecuteSqlForObject <int>("select count(*) from \"@DOVER_LICENSE\""), 1);
            Assert.AreEqual(b1DAO.ExecuteSqlForObject <string>("select \"U_namespace\" from \"@DOVER_LICENSE\""), "DOVER_WL");
        }
Exemplo n.º 12
0
 public void NormalizeExtensions()
 {
     Extensions = Extensions.Where(e => !string.IsNullOrWhiteSpace(e)).Select(e => LicenseHeader.AddDot(e).ToLower()).ToArray();
 }
Exemplo n.º 13
0
        private bool SolutionHeaderDefinitionExists()
        {
            string solutionHeaderDefinitionFilePath = LicenseHeader.GetHeaderDefinitionFilePathForSolution(_dte.Solution);

            return(File.Exists(solutionHeaderDefinitionFilePath));
        }
        public void Execute(Solution solution)
        {
            if (solution == null)
            {
                return;
            }

            var allSolutionProjectsSearcher = new AllSolutionProjectsSearcher();
            var projectsInSolution          = allSolutionProjectsSearcher.GetAllProjects(solution);

            var projectsWithoutLicenseHeaderFile = CheckForLicenseHeaderFileInProjects(projectsInSolution);

            if (projectsInSolution.Count == 1 && projectsWithoutLicenseHeaderFile.Count == 1)
            {
                //There is exactly one Project in the Solution and it has no Definition File
                //--> Offer to add a new one and ask if they want to stop the update process to configure them
                if (MessageBoxHelper.DoYouWant(Resources.Question_AddNewLicenseHeaderDefinitionFileSingleProject))
                {
                    var licenseHeader = LicenseHeader.AddLicenseHeaderDefinitionFile(projectsInSolution.First(), _licenseHeaderPage);

                    if (!MessageBoxHelper.DoYouWant(Resources.Question_StopForConfiguringDefinitionFilesSingleFile))
                    {
                        AddLicenseHeaderToProjects(projectsInSolution);
                    }
                    else if (licenseHeader != null)
                    {
                        licenseHeader.Open(Constants.vsViewKindCode).Activate();
                    }
                }
            }
            else if (projectsWithoutLicenseHeaderFile.Count == projectsInSolution.Count)
            {
                //There are multiple Projects in the Solution but none of them has a Definition File
                //--> Offer to add new ones to everyone of them and ask if they want to stop the update process to configure them
                if (MessageBoxHelper.DoYouWant(Resources.Question_AddNewLicenseHeaderDefinitionFileMultipleProjects))
                {
                    var newLicenseHeaders = AddNewLicenseHeaderDefinitionFilesToProjects(projectsWithoutLicenseHeaderFile, _licenseHeaderPage);

                    if (!MessageBoxHelper.DoYouWant(Resources.Question_StopForConfiguringDefinitionFilesMultipleFiles))
                    {
                        AddLicenseHeaderToProjects(projectsInSolution);
                    }
                    else if (newLicenseHeaders.Count() <= Resources.Constant_MaxNumberOfProjectItemsWhereOpeningDefinitionFilesInEditor)
                    {
                        foreach (var licenseHeader in newLicenseHeaders)
                        {
                            licenseHeader.Open(Constants.vsViewKindCode).Activate();
                        }
                    }
                }
                else
                {
                    MessageBoxHelper.Information(Resources.Information_NoDefinitionFileStopUpdating);
                }
            }
            else if (projectsWithoutLicenseHeaderFile.Any())
            {
                //There are projects with and without Definition File --> Ask if we should add an existing License Header File to them and then add License Headers
                if (DefinitionFilesShouldBeAdded(projectsWithoutLicenseHeaderFile))
                {
                    new AddExistingLicenseHeaderDefinitionFileCommand().AddDefinitionFileToMultipleProjects(projectsWithoutLicenseHeaderFile);
                }

                AddLicenseHeaderToProjects(projectsInSolution);
            }
            else
            {
                //There are no Projects without Definition File --> Add License Headers
                AddLicenseHeaderToProjects(projectsInSolution);
            }
        }