Example #1
0
        private static List <BuildLogMessage> CheckFileSrc(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages   = new List <BuildLogMessage>();
            List <TreeNode>        errorNodes = new List <TreeNode>();
            TreeNodeCollection     nodes      = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                ComponentNode componentNode = (ComponentNode)childNode.Tag;
                if (componentNode.Type == ComponentType.File)
                {
                    if (File.Exists(componentNode.Property.SourcePath) == false)
                    {
                        errorNodes.Add(childNode);
                    }
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(CheckFileSrc(tree, childNode, module));
                }
            }

            // add messages
            foreach (TreeNode errorNode in errorNodes)
            {
                BuildLogMessage message = new BuildLogMessage();
                message.Message = "Source file not found:" + errorNode.Text + ". (" + errorNode.FullPath + ")";
                message.Type    = LogType.ERROR;
                message.Module  = module;
                messages.Add(message);
            }
            return(messages);
        }
Example #2
0
        private static List <BuildLogMessage> CheckFeatureExists(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();
            TreeNodeCollection     nodes    = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                if (childNode.Tag != null && childNode.Tag is ComponentNode)
                {
                    ComponentNode componentNode = (ComponentNode)childNode.Tag;
                    if (componentNode.Property.Feature != null && Common.FeatureExists(componentNode.Property.Feature.Id) == false)
                    {
                        BuildLogMessage buildMessage = new BuildLogMessage();
                        buildMessage.Message = "Feature " + componentNode.Property.Feature.Name + " assigned to the file: " + childNode.FullPath + " is not found in the feature tree.";
                        buildMessage.Type    = LogType.ERROR;
                        buildMessage.Module  = Modules.Components;
                        messages.Add(buildMessage);
                    }
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(CheckFeatureExists(tree, childNode, module));
                }
            }

            return(messages);
        }
Example #3
0
        private static List <BuildLogMessage> CheckAcceptableChars(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages   = new List <BuildLogMessage>();
            List <TreeNode>        errorNodes = new List <TreeNode>();
            TreeNodeCollection     nodes      = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                if (ContainsInvalidChar(childNode.Text))
                {
                    errorNodes.Add(childNode);
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(CheckAcceptableChars(tree, childNode, module));
                }
            }

            foreach (TreeNode errorNode in errorNodes)
            {
                BuildLogMessage message = new BuildLogMessage();
                message.Message = "Node length is more than set limit:" + Common.MaxPropertyLength;
                message.Type    = LogType.ERROR;
                message.Module  = module;
                messages.Add(message);
            }
            return(messages);
        }
Example #4
0
        void Logger_MessageLogged(object sender, BuildLogMessage e)
        {
            try {
                int rowIndex = dgrOutputMessages.Rows.Add();
                dgrOutputMessages[indexColumn.Name, rowIndex].Value   = rowIndex;
                dgrOutputMessages[messageColumn.Name, rowIndex].Value = e.Message;
                dgrOutputMessages[moduleColumn.Name, rowIndex].Value  = e.Module.ToString();
                dgrOutputMessages.Rows[rowIndex].Tag = e;

                switch (e.Type)
                {
                case LogType.ERROR:
                    dgrOutputMessages.Rows[rowIndex].Visible = btnErrors.Checked;
                    ((DataGridViewImageCell)dgrOutputMessages[logTypeColumn.Name, rowIndex]).Value = errorImage;
                    break;

                case LogType.Warning:
                    dgrOutputMessages.Rows[rowIndex].Visible = btnWarnings.Checked;
                    ((DataGridViewImageCell)dgrOutputMessages[logTypeColumn.Name, rowIndex]).Value = warningImage;
                    break;

                case LogType.Information:
                    dgrOutputMessages.Rows[rowIndex].Visible = btnInformation.Checked;
                    ((DataGridViewImageCell)dgrOutputMessages[logTypeColumn.Name, rowIndex]).Value = infoImage;
                    break;
                }

                // update error count labels
                lblErrorCount.Text   = BuildLogger.ErrorCount.ToString();
                lblWarningCount.Text = BuildLogger.WarningCount.ToString();
            } catch (Exception exc) {
                Logger.ApplicationLog(new LogMessage(exc.Message, exc));
            }
        }
Example #5
0
        public static BuildLogMessage ValidateUrl(string name, string url, Modules module)
        {
            string strRegex = "^(https?://)"
                              + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //user@
                              + @"(([0-9]{1,3}\.){3}[0-9]{1,3}"                            // IP- 199.194.52.184
                              + "|"                                                        // allows either IP or domain
                              + @"([0-9a-z_!~*'()-]+\.)*"                                  // tertiary domain(s)- www.
                              + @"([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\."                    // second level domain
                              + "[a-z]{2,6})"                                              // first level domain- .com or .museum
                              + "(:[0-9]{1,4})?"                                           // port number- :80
                              + "((/?)|"                                                   // a slash isn't required if there is no file name
                              + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
            Regex re = new Regex(strRegex);

            if (re.IsMatch(url) == false)
            {
                BuildLogMessage logMessage = new BuildLogMessage();
                logMessage.Message = name + " [" + url + "]" + " is invalid Or empty.";
                logMessage.Type    = LogType.Warning;
                logMessage.Module  = module;

                return(logMessage);
            }
            return(null);
        }
Example #6
0
        public static List <BuildLogMessage> ValidateRepeatingItems(List <string> values, string text, LogType type, Modules module)
        {
            List <BuildLogMessage> logMessages = new List <BuildLogMessage>();

            foreach (string value in values)
            {
                int count = 0;
                foreach (string val in values)
                {
                    if (val == value)
                    {
                        count++;
                    }
                }
                if (count > 1)
                {
                    BuildLogMessage buildMessage = new BuildLogMessage();
                    buildMessage.Message = String.Format(text, value);
                    buildMessage.Type    = type;
                    buildMessage.Module  = module;
                    logMessages.Add(buildMessage);
                }
            }
            return(null);
        }
Example #7
0
 private static void NotifyLogMessage(BuildLogMessage message)
 {
     if (MessageLogged != null)
     {
         MessageLogged(null, message);
     }
 }
Example #8
0
        private static List <BuildLogMessage> CheckSystemFolderNames(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages   = new List <BuildLogMessage>();
            List <TreeNode>        errorNodes = new List <TreeNode>();
            TreeNodeCollection     nodes      = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                if (IsSystemFolderName(childNode.Text))
                {
                    errorNodes.Add(childNode);
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(CheckSystemFolderNames(tree, childNode, module));
                }
            }

            // add messages
            foreach (TreeNode errorNode in errorNodes)
            {
                BuildLogMessage message = new BuildLogMessage();
                message.Message = "System folder name used:" + errorNode.Text;
                message.Type    = LogType.ERROR;
                message.Module  = module;
                messages.Add(message);
            }
            return(messages);
        }
Example #9
0
        public void Validate()
        {
            BuildLogMessage buildMessage = new BuildLogMessage();

            if (type == CustomActionType.ExeCommand)
            {
                if (String.IsNullOrEmpty(sourcePath))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("No executable(exe) in target system is specified for the custom action: {0}.", name);
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
                if (String.IsNullOrEmpty(function))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("No argument specified for the custom action: {0}.", name);
                    buildMessage.Type    = LogType.Warning;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
            }
            else
            {
                if (this.browsable)
                {
                    if (scriptable)
                    {
                        if (String.IsNullOrEmpty(sourcePath) && String.IsNullOrEmpty(script))
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = String.Format("Neither {0} file specified nor any script found in the editor (Custom Action: {1}).", type.ToString(), name);
                            buildMessage.Type    = LogType.ERROR;
                            buildMessage.Module  = Modules.CustomActions;
                            BuildLogger.Add(buildMessage);
                        }
                    }
                    else if (String.IsNullOrEmpty(sourcePath))
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = String.Format("File path of the custom action :{0} is empty.", name);
                        buildMessage.Type    = LogType.ERROR;
                        buildMessage.Module  = Modules.CustomActions;
                        BuildLogger.Add(buildMessage);
                    }
                }
                if (browsable && String.IsNullOrEmpty(function))
                {
                    buildMessage         = new BuildLogMessage();
                    buildMessage.Message = String.Format("{0} of custom action: {1} is empty.", functionLabel, name);
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.CustomActions;
                    BuildLogger.Add(buildMessage);
                }
            }
        }
Example #10
0
        public static void Add(BuildLogMessage message)
        {
            switch (message.Type)
            {
            case LogType.ERROR: errorCount++; break;

            case LogType.Warning: warningCount++; break;
            }
            AddToLogDatabase(message);
            NotifyLogMessage(message);
        }
        void INvnControl.Validate()
        {
            #region Validate Product Key

            if (txtDllEntry.Text.Trim() == "" && txtFalseValue.Text.Trim() == "" && txtProperty.Text.Trim() == "" &&
                txtTrueValue.Text.Trim() == "" && txtValidationDll.Text.Trim() == "")
            {
                return;
            }
            else if (txtDllEntry.Text.Trim() != "" && txtFalseValue.Text.Trim() != "" && txtProperty.Text.Trim() != "" &&
                     txtTrueValue.Text.Trim() != "" && txtValidationDll.Text.Trim() != "")
            {
                return;
            }
            else
            {
                List <BuildLogMessage> logMessages = new List <BuildLogMessage>();
                BuildLogMessage        logMessage  = null;
                if (String.IsNullOrEmpty(txtValidationDll.Text))
                {
                    logMessage         = new BuildLogMessage();
                    logMessage.Message = "Sufficient information is not available for product key validation. Validation DLL path is empty.";
                    logMessage.Type    = LogType.ERROR;
                    logMessage.Module  = Modules.ProductKeyValidation;
                    logMessages.Add(logMessage);// add to the list
                }
                if (String.IsNullOrEmpty(txtProperty.Text))
                {
                    logMessage         = new BuildLogMessage();
                    logMessage.Message = "Sufficient information is not available for product key validation. Property name is missing.";
                    logMessage.Type    = LogType.ERROR;
                    logMessage.Module  = Modules.ProductKeyValidation;
                    logMessages.Add(logMessage);// add to the list
                }
                if (String.IsNullOrEmpty(txtDllEntry.Text))
                {
                    logMessage         = new BuildLogMessage();
                    logMessage.Message = "Sufficient information is not available for product key validation. DLL entry is missing.";
                    logMessage.Type    = LogType.ERROR;
                    logMessage.Module  = Modules.ProductKeyValidation;
                    logMessages.Add(logMessage);// add to the list
                }
                if (String.IsNullOrEmpty(txtTrueValue.Text) || String.IsNullOrEmpty(txtFalseValue.Text))
                {
                    logMessage         = new BuildLogMessage();
                    logMessage.Message = "Sufficient information is not available for product key validation. Either TRUE value or FALSE value is missing.";
                    logMessage.Type    = LogType.ERROR;
                    logMessage.Module  = Modules.ProductKeyValidation;
                    logMessages.Add(logMessage);// add to the list
                }
            }
            #endregion
        }
Example #12
0
        public static BuildLogMessage ValidateGuid(string candidate, string idName)
        {
            if (String.IsNullOrEmpty(candidate) || isGuid.IsMatch(candidate) == false)
            {
                BuildLogMessage logMessage = new BuildLogMessage();
                logMessage.Message = idName + " is not valid";
                logMessage.Type    = LogType.ERROR;

                return(logMessage);
            }
            return(null);
        }
Example #13
0
        public static BuildLogMessage ContainsInvalidChar(string value, string name, LogType errorType)
        {
            if (ContainsInvalidChar(value))
            {
                BuildLogMessage logMessage = new BuildLogMessage();
                logMessage.Message = name + " contains invalid character";
                logMessage.Type    = errorType;

                return(logMessage);
            }
            return(null);
        }
Example #14
0
        public static BuildLogMessage IsNullOrEmpty(string value, string name, LogType errorType, Modules module)
        {
            if (String.IsNullOrEmpty(value))
            {
                BuildLogMessage logMessage = new BuildLogMessage();
                logMessage.Message = name + " is empty";
                logMessage.Type    = errorType;
                logMessage.Module  = module;

                return(logMessage);
            }
            return(null);
        }
Example #15
0
        private static void AddToLogDatabase(BuildLogMessage log)
        {
            //if (File.Exists(Common.applicationLogsDb) == false && File.Exists("Logs.s3db")) {
            //    File.Copy("Logs.s3db", Common.applicationLogsDb, true);
            //}

            //string connectionString = String.Format(@"Data Source = {0}", Common.applicationLogsDb);
            //SQLiteConnection connection = new SQLiteConnection(connectionString);
            //connection.Open();
            //string sql = String.Format("INSERT INTO log VALUES('{0}','{1}','{2}','{3}','{4}')",
            //    log.LogTime.ToString("yyyy-MM-dd"), log.LogTime.ToString("HH:mm:ss"), log.Module + ":" + log.Type + ":" + log.Message, "", "N");
            //SQLiteCommand command = new SQLiteCommand(sql, connection);
            //command.ExecuteNonQuery();
            //connection.Close();
        }
Example #16
0
        private void UpdateGridItems()
        {
            foreach (DataGridViewRow row in dgrOutputMessages.Rows)
            {
                BuildLogMessage logMessage = (BuildLogMessage)row.Tag;
                switch (logMessage.Type)
                {
                case LogType.ERROR: row.Visible = btnErrors.Checked; break;

                case LogType.Warning: row.Visible = btnWarnings.Checked; break;

                case LogType.Information: row.Visible = btnInformation.Checked; break;
                }
            }
            UpdateIndexNumbers();
        }
Example #17
0
        void INvnControl.Validate()
        {
            List <string> extensions           = new List <string>();
            List <string> selectedApplications = new List <string>();

            foreach (DataGridViewRow row in dgrExtensions.Rows)
            {
                string application = (string)row.Cells[applicationColumn.Name].Value;
                string description = (string)row.Cells[DescriptionColumn.Name].Value;
                string extension   = (string)row.Cells[extensionColumn.Name].Value;
                // check for mandatory fields
                List <BuildLogMessage> logMessages = Validator.IsNullOrEmpty(
                    new string[] { application, extension }, new string[] { "Application Name", "File association extension" }, LogType.ERROR, Modules.FileAssociation);
                if (logMessages != null)
                {
                    BuildLogger.Add(logMessages);
                }
                // application name doesn't end with '.exe'
                if (application != null && application.EndsWith(".exe") == false)
                {
                    BuildLogMessage buildMessage = new BuildLogMessage();
                    buildMessage.Message = "Application selected for the file association:" + extension + " does not end with .exe. Are you sure it is an executable ?";
                    buildMessage.Type    = LogType.Warning;
                    buildMessage.Module  = Modules.FileAssociation;
                    BuildLogger.Add(buildMessage);// add to the list
                }
                //error if application selected for file association not in components tree
                if (row.Tag != null && ((TreeNode)row.Tag).TreeView == null)
                {
                    BuildLogMessage buildMessage = new BuildLogMessage();
                    buildMessage.Message = "Application selected for the file association:" + extension + " not found in components tree. Please check whether the application with name: " + application + " exists.";
                    buildMessage.Type    = LogType.ERROR;
                    buildMessage.Module  = Modules.FileAssociation;
                    BuildLogger.Add(buildMessage);// add to the list
                }
            }
            //check repeating names
            List <BuildLogMessage> messages = Validator.ValidateRepeatingItems(extensions, "Extension {0} found more than once. Are you sure you want to handle same extension by different applications.", LogType.Warning, Modules.FileAssociation);

            if (messages != null)
            {
                BuildLogger.Add(messages);
            }
        }
Example #18
0
 private void CheckComponentNodeExists(TreeNode node)
 {
     if (node.Tag != null) /*Normally NULL for root nodes*/
     {
         ComponentNode componentNode = (ComponentNode)node.Tag;
         if (componentNode.SecondaryTreeNode != null && componentNode.SecondaryTreeNode.TreeView == null)
         {
             BuildLogMessage buildMessage = new BuildLogMessage();
             buildMessage.Message = String.Format("Source file of shortcut file: {0} is not found in components tree. Please check whether the component tree structure is maintained.", node.FullPath);
             buildMessage.Type    = LogType.ERROR;
             buildMessage.Module  = Modules.Components;
             BuildLogger.Add(buildMessage);
         }
     }
     foreach (TreeNode childNode in node.Nodes)
     {
         CheckComponentNodeExists(childNode);
     }
 }
Example #19
0
        public static List <BuildLogMessage> ContainsInvalidChar(string[] values, string[] names, LogType errorType, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();

            for (int i = 0; i < values.Length; i++)
            {
                string value = values[i];
                string name  = names[i];
                if (ContainsInvalidChar(value))
                {
                    BuildLogMessage logMessage = new BuildLogMessage();
                    logMessage.Message = name + " contains invalid character";
                    logMessage.Type    = errorType;
                    logMessage.Module  = module;

                    messages.Add(logMessage);
                }
            }
            return(messages);
        }
Example #20
0
        private static List <BuildLogMessage> ValidateRepeatingNodes(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();
            Dictionary <string, List <TreeNode> > values = new Dictionary <string, List <TreeNode> >();
            TreeNodeCollection nodes = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                string key = childNode.Text;
                if (values.ContainsKey(key))
                {
                    List <TreeNode> value = values[key];
                    value.Add(childNode);
                }
                else
                {
                    List <TreeNode> valueNodes = new List <TreeNode>();
                    valueNodes.Add(childNode);
                    values.Add(key, valueNodes);
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(ValidateRepeatingNodes(tree, childNode, module));
                }
            }

            // check keys in dictionary with count more than 1
            foreach (string key in values.Keys)
            {
                List <TreeNode> listNodes = values[key];
                if (listNodes.Count > 1)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "Duplicate node found with name :" + key + ". Node path: " + node.FullPath;
                    message.Type    = LogType.ERROR;
                    message.Module  = module;
                    messages.Add(message);
                }
            }
            return(messages);
        }
Example #21
0
        public static List <BuildLogMessage> ValidateDescriptionLength(string[] values, string[] names, LogType errorType, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();

            for (int i = 0; i < values.Length; i++)
            {
                string name  = names[i];
                string value = values[i];
                if (value.Length > Common.MaxDescriptionLength)
                {
                    BuildLogMessage logMessage = new BuildLogMessage();
                    logMessage.Message = name + " length is more than the set limit: " + Common.MaxDescriptionLength;
                    logMessage.Type    = errorType;
                    logMessage.Module  = module;

                    messages.Add(logMessage);
                }
            }

            return(messages);
        }
Example #22
0
        public static List <BuildLogMessage> IsNullOrEmpty(string[] values, string[] names, LogType errorType, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();

            for (int i = 0; i < values.Length; i++)
            {
                string name  = names[i];
                string value = values[i];
                if (String.IsNullOrEmpty(value))
                {
                    BuildLogMessage logMessage = new BuildLogMessage();
                    logMessage.Message = name + " is empty";
                    logMessage.Type    = errorType;
                    logMessage.Module  = module;

                    messages.Add(logMessage);
                }
            }

            return(messages);
        }
Example #23
0
        public static BuildLogMessage ValidateVersionNumber(string version)
        {
            BuildLogMessage logMessage = new BuildLogMessage();

            logMessage.Message = String.Format("Version {0} number is not in valid format", version);
            logMessage.Type    = LogType.ERROR;
            logMessage.Module  = Modules.ProductInformation;
            string[] versionParts = version.Split(".".ToCharArray());
            if (versionParts.Length > 4)
            {
                return(logMessage);
            }
            foreach (string versionPart in versionParts)
            {
                int result = 0;
                if (Int32.TryParse(versionPart, out result) == false)
                {
                    return(logMessage);
                }
            }
            return(null);
        }
        //check for value limit - may be like string lentgh, max value of integer
        //check for valid value - like binary should not have a string value
        private List <BuildLogMessage> RegistryValueLimit(string value, TreeNode keyNode, RegistryValue regValue)
        {
            List <BuildLogMessage> logMessages = new List <BuildLogMessage>();

            if (value.Length > 1024 * 1024)
            {
                BuildLogMessage buildMessage = new BuildLogMessage();
                buildMessage.Message = "Value of registry :" + regValue.Name + " under " + keyNode.FullPath + " is not in valid limit. Value size should not be more than 1 MB.";
                buildMessage.Type    = LogType.ERROR;
                buildMessage.Module  = Modules.Registries;
                logMessages.Add(buildMessage);
            }
            if (regValue.Name.Length > 16383)
            {
                BuildLogMessage buildMessage = new BuildLogMessage();
                buildMessage.Message = "Name of a registry " + " under " + keyNode.FullPath + " is more than the valid limit. Name length should not be more than 16,383 characters.";
                buildMessage.Type    = LogType.ERROR;
                buildMessage.Module  = Modules.Registries;
                logMessages.Add(buildMessage);
            }
            return(logMessages);
        }
Example #25
0
        private static List <BuildLogMessage> CheckProperties(TreeView tree, TreeNode node, Modules module)
        {
            List <BuildLogMessage> messages = new List <BuildLogMessage>();
            TreeNodeCollection     nodes    = node == null ? tree.Nodes : node.Nodes;

            foreach (TreeNode childNode in nodes)
            {
                if (childNode.Tag != null && childNode.Tag.GetType() == typeof(ComponentNode))
                {
                    ComponentNode componentNode = (ComponentNode)childNode.Tag;
                    if (componentNode.Type == ComponentType.InternetShortcut)
                    {
                        if (String.IsNullOrEmpty(componentNode.Property.ShortcutProperty.URL))
                        {
                            BuildLogMessage message = new BuildLogMessage();
                            message.Message = "Internet shortcut URL is not set : " + childNode.FullPath;
                            message.Type    = LogType.ERROR;
                            message.Module  = module;
                            messages.Add(message);
                        }
                        else
                        {
                            BuildLogMessage message = ValidateUrl("Internet shortcut URL", componentNode.Property.ShortcutProperty.URL, module);
                            if (message != null)
                            {
                                messages.Add(message);
                            }
                        }
                    }
                }
                if (childNode.Nodes.Count > 0)
                {
                    messages.AddRange(CheckProperties(tree, childNode, module));
                }
            }

            return(messages);
        }
Example #26
0
        void INvnControl.Validate()
        {
            if (String.IsNullOrEmpty(txtUiAppPath.Text) == false && lstSelectedFiles.Items.Count != 0)
            {
                // Check whether files selected
                if (lstSelectedFiles.Items.Count == 0)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "Custom UI application and its supporting files are not selected.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
                // Check whether application with <MsiFileName>.exe exists
                bool   appExists = false, msiDllExits = false;
                string outputFilename = Path.GetFileNameWithoutExtension(ControlsManager.ProductInformation.Output.Text) + ".exe";
                foreach (NameValue nameValue in selectedItems)
                {
                    if (nameValue.Name == outputFilename)
                    {
                        appExists = true;
                    }
                    else if (nameValue.Name == "NvnInstaller.MsiDotNet.dll")
                    {
                        msiDllExits = true;
                    }
                }
                if (appExists == false)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "No application with name " + outputFilename + " found. Custom UI appliction with name " + outputFilename + " is expected.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }

                if (msiDllExits == false)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "NvnInstaller.MsiDotNet.dll is not found. It is needed for all custom UI application developed using NvnInstaller.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
                // check bootstrapper is downloaded
                if (cmbPrerequisites.Items.Count < 2)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "Nvn Installer needs at least .Net Framework 2.0 bootstrapper installed to build custom UI application. Please visit Nvn Installer website.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }

                // check bootstrapper is selected
                if (cmbPrerequisites.SelectedIndex < 1)
                {
                    BuildLogMessage message = new BuildLogMessage();
                    message.Message = "No prerequisite selected. Select relevent .Net Framework used for custom UI application.";
                    message.Type    = LogType.ERROR;
                    message.Module  = Modules.CustomUIApplication;
                    BuildLogger.Add(message);// add to the list
                }
            }
        }
        private void ValidateRegistryValues(TreeNode keyNode)
        {
            List <RegistryValue> values       = (List <RegistryValue>)keyNode.Tag;
            BuildLogMessage      buildMessage = new BuildLogMessage();

            if (values == null || values.Count == 0)
            {
                //warning - key exists but no value
                buildMessage         = new BuildLogMessage();
                buildMessage.Message = "Registry key node found with no values under it. " + keyNode.FullPath;
                buildMessage.Type    = LogType.Warning;
                buildMessage.Module  = Modules.Registries;
                BuildLogger.Add(buildMessage);
            }
            if (values != null)
            {
                //error: repeating value names
                foreach (RegistryValue value in values)
                {
                    foreach (RegistryValue val in values)
                    {
                        if (val.Id != value.Id && value.Name == val.Name)
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "Multiple registry values with same name found under " + keyNode.FullPath;
                            buildMessage.Type    = LogType.ERROR;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                    }
                }

                foreach (RegistryValue value in values)
                {
                    //feature assigned to each value it
                    if (value.Feature == null || String.IsNullOrEmpty(value.Feature.Name))
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = "No feature assigned to the registry value " + value.Name + " under " + keyNode.FullPath;
                        buildMessage.Type    = LogType.Warning;
                        buildMessage.Module  = Modules.Registries;
                        BuildLogger.Add(buildMessage);
                    }
                    //feature assigned but not available in feature tree (deleted somehow)
                    if (value.Feature != null && Common.FeatureExists(value.Feature.Id) == false)
                    {
                        buildMessage         = new BuildLogMessage();
                        buildMessage.Message = "Feature " + value.Feature.Name + " assigned  to the registry value: " + value.Name + " under " + keyNode.FullPath + " is not found in the feature tree.";
                        buildMessage.Type    = LogType.ERROR;
                        buildMessage.Module  = Modules.Registries;
                        BuildLogger.Add(buildMessage);
                    }

                    //warning - Registry value exists but no value assigned to it. default value used
                    if (value is RegistrySingleValue)
                    {
                        string singleValue = ((RegistrySingleValue)value).Value;
                        if (String.IsNullOrEmpty(singleValue))
                        {
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "No value assigned to the registry value: " + value.Name + " under " + keyNode.FullPath + ". Default value is assigned.";
                            buildMessage.Type    = LogType.Warning;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                        if (String.IsNullOrEmpty(singleValue) == false)
                        {
                            List <BuildLogMessage> logMessages = RegistryValueLimit(singleValue, keyNode, value);
                            if (logMessages.Count > 0)
                            {
                                BuildLogger.Add(logMessages);
                            }
                        }
                    }
                    else if (value is RegistryMultipleValue)
                    {
                        string[] multiValues = ((RegistryMultipleValue)value).Value;
                        if (multiValues.Length == 0)
                        {
                            string singleValue = ((RegistrySingleValue)value).Value;
                            buildMessage         = new BuildLogMessage();
                            buildMessage.Message = "No value assigned to the registry value: " + value.Name + " under " + keyNode.FullPath + ". Default value is assigned.";
                            buildMessage.Type    = LogType.Warning;
                            buildMessage.Module  = Modules.Registries;
                            BuildLogger.Add(buildMessage);
                        }
                        foreach (string singleValue in multiValues)
                        {
                            List <BuildLogMessage> logMessages = RegistryValueLimit(singleValue, keyNode, value);
                            if (logMessages.Count > 0)
                            {
                                BuildLogger.Add(logMessages);
                            }
                        }
                    }
                }
            }

            foreach (TreeNode childNode in keyNode.Nodes)
            {
                ValidateRegistryValues(childNode);
            }
        }
Example #28
0
        void INvnControl.Validate()
        {
            List <BuildLogMessage> tempMessages = new List <BuildLogMessage>();
            BuildLogMessage        logMessage   = null;

            // version number
            logMessage = Validator.ValidateVersionNumber(Version.Text);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            // check license file exists
            if (String.IsNullOrEmpty(LicenseFile.Text) || System.IO.File.Exists(LicenseFile.Text) == false)
            {
                BuildLogMessage licenseFileMessage = new BuildLogMessage();
                licenseFileMessage.Message = "License file not found";
                licenseFileMessage.Type    = LogType.ERROR;
                licenseFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(licenseFileMessage);// add to the list
            }
            // check Icon file
            if (String.IsNullOrEmpty(IconFile.Text) || System.IO.File.Exists(IconFile.Text) == false)
            {
                BuildLogMessage iconFileMessage = new BuildLogMessage();
                iconFileMessage.Message = "Icon file is not selected. Installer will set default icon for this product.";
                iconFileMessage.Type    = LogType.Warning;
                iconFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(iconFileMessage);// add to the list
            }
            logMessage = Validator.IsNullOrEmpty(Output.Text, "Output file(MSI)", LogType.ERROR, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            //check minimum installer version for empty, integer
            logMessage = Validator.IsNullOrEmpty(txtMajorVersion.Text, "Value 'Major' of minimum installer version", LogType.ERROR, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            if (Common.IsInteger(txtMajorVersion.Text) == false || Common.IsInteger(txtMinorVersion.Text) == false)
            {
                BuildLogMessage iconFileMessage = new BuildLogMessage();
                iconFileMessage.Message = "Value set for minimum installer version is not in valid format.";
                iconFileMessage.Type    = LogType.ERROR;
                iconFileMessage.Module  = Modules.ProductInformation;
                BuildLogger.Add(iconFileMessage);// add to the list
            }
            // validate URLs
            logMessage = Validator.ValidateUrl("Manufacturer Url", ManufacturerUrl.Text, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            logMessage = Validator.ValidateUrl("Support Url", SupportUrl.Text, Modules.ProductInformation);
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            // check for null or empty
            tempMessages = Validator.IsNullOrEmpty(
                new string[] { ProductCode.Text, UpgradeCode.Text, PackageId.Text, ProductName.Text, Title.Text, Version.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product code", "Upgrade code", "Package Id", "Product name", "Title", "Version", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for acceptible chars
            tempMessages = Validator.ContainsInvalidChar(
                new string[] { ProductName.Text, Title.Text, Version.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product name", "Title", "Version", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for property length
            tempMessages = Validator.ValidatePropertyLength(
                new string[] { ProductName.Text, Title.Text, Author.Text, Manufacturer.Text },
                new string[] { "Product name", "Title", "Author", "Manufacturer" },
                LogType.ERROR, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // check for description length
            tempMessages = Validator.ValidateDescriptionLength(
                new string[] { Description.Text, Comments.Text },
                new string[] { "Description", "Comments" },
                LogType.Warning, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);
            // validate IDs
            logMessage = Validator.ValidateGuid(ProductCode.Text, "Product code");
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }
            logMessage = Validator.ValidateGuid(UpgradeCode.Text, "Upgrade code");
            if (logMessage != null)
            {
                BuildLogger.Add(logMessage);
            }

            #region Features
            tempMessages = Validator.ValidateTree(tvFeatures, false, Modules.ProductInformation);
            BuildLogger.Add(tempMessages);

            if (tvFeatures.Nodes.Count == 0)
            {
                BuildLogMessage featureNotDefined = new BuildLogMessage();
                featureNotDefined.Message = "No Feature defined";
                featureNotDefined.Type    = LogType.ERROR;
                featureNotDefined.Module  = Modules.ProductInformation;
                BuildLogger.Add(featureNotDefined);
            }
            #endregion
        }