/// <summary>
        /// This method will add the URL in the xml directly from a bulk add using the Enterprise Mode Site List Manager.
        /// </summary>
        /// <param name="tickets">Array of Tickets model objects</param>
        /// <returns>bool</returns>
        public bool AddToV2XMLBulk(Tickets[] tickets)
        {
            Configuration config = null;

            if (LoginController.config == null)
            {
                using (ConfigurationController configController = new ConfigurationController())
                {
                    config = configController.GetConfiguration();
                }
            }
            else
            {
                config = LoginController.config;
            }

            bool saved = false;

            foreach (Tickets ticket in tickets)
            {
                xmlHelper.AddToV2XMLBulk(ticket, config, !saved);

                if (!saved)
                {
                    saved = true;
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// get values from config setting files by key
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        private static string GetValueLFromConfigSettings(string Key)
        {
            ConfigurationController config     = new ConfigurationController();
            Configuration           configdata = null;

            if (LoginController.config == null)
            {
                configdata = config.GetConfiguration();
            }
            else
            {
                configdata = LoginController.config;
            }
            if (configdata != null)
            {
                var configkey = configdata.ConfigSettings.Find(x => x.key.Equals(Key));
                if (configkey != null)
                {
                    string loginURL = configdata.ConfigSettings.Find(x => x.key.Equals(Key)).value.ToString();
                    return(loginURL);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
 /// <summary>
 /// Get configuration settings at the start and store it to global variable
 /// </summary>
 public JsonResult GetConfigurationAtStart()
 {
     using (ConfigurationController configController = new ConfigurationController())
     {
         config = configController.GetConfiguration();
         if (config.ConfigSettings.Count > 2)
         {
             return(Json(false, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(true, JsonRequestBehavior.AllowGet));
         }
     }
 }
        /// <summary>
        /// Change EMIE admin password
        /// </summary>
        /// <param name="Newpassword">new password</param>
        /// <returns>1-if saved successfully,0 -if failed</returns>
        public JsonResult ChangeEMIEAdminCredentials(string newpassword)
        {
            var configItem = DbEntity.EMIEConfigurationSettings.Where(config => config.ConfigItem.Equals(ConfigConstants.EMIEAdminPassword)).FirstOrDefault();

            if (configItem != null)
            {
                ConfigurationController controller = new ConfigurationController();
                string encryptedPassword           = controller.Encrypt(newpassword);
                configItem.ConfiguredValue = encryptedPassword;
                int result = DbEntity.SaveChanges();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// This method check URL entered in the XML list, the method will check if the loaded XML file is
        /// v1 or v2 version, and will check if the particular file contains the URL, and accordingly gives the result
        /// </summary>
        /// <param name="findString"></param>
        /// <returns>bool</returns>
        public bool CheckUrl(Uri findString)
        {
            Configuration config = null;

            if (LoginController.config == null)
            {
                using (ConfigurationController configController = new ConfigurationController())
                {
                    config = configController.GetConfiguration();
                }
            }
            else
            {
                config = LoginController.config;
            }
            return(xmlHelper.CheckUrl(findString, config));
        }
        /// <summary>
        /// This method will decide which method to call based on the version of XML
        /// </summary>
        /// <param name="ticket">ticket object has to be passed as first parameter</param>
        /// <param name="operation">Operation enumeration parameter</param>
        /// <example>OperationOnXML(ticketObject, Operation.ProductionRollBack)</example>
        public void OperationOnXML(Tickets ticket, Operation operation)
        {
            Configuration config = null;

            if (LoginController.config == null)
            {
                using (ConfigurationController configController = new ConfigurationController())
                {
                    config = configController.GetConfiguration();
                }
            }
            else
            {
                config = LoginController.config;
            }
            xmlHelper.OperationOnXML(ticket, operation, config);
        }
        /// <summary>
        /// this method will get all the websites from the production and sent to the tool to be diaplyed
        /// and it also reads all the comments to extract the application information
        /// </summary>
        /// <returns>this function returns the application info and the xml string</returns>
        public JsonResult getSitesFromProduction()
        {
            Configuration config = null;

            if (LoginController.config == null)
            {
                using (ConfigurationController configController = new ConfigurationController())
                {
                    config = configController.GetConfiguration();
                }
            }
            else
            {
                config = LoginController.config;
            }
            string xmlData = xmlHelper.getProductionSites(config);

            //XDocument prodXml = XDocument.Parse(xmlData);
            //var comments = (from node in prodXml.Elements().DescendantNodesAndSelf()
            //                where node.NodeType == XmlNodeType.Comment
            //                select node.ToString()).ToList();
            //List<Dictionary<string,string>> sitesInformation = new List<Dictionary<string,string>>();
            //foreach (var comment in comments)
            //{
            //    Dictionary<string,string> name = new Dictionary<string,string>();
            //    string[] check = { Constants.spacing.ToString(), System.Environment.NewLine };
            //    var info = comment.Split(check, StringSplitOptions.None);
            //    foreach (var site in info)
            //    {
            //        if (site.IndexOf(Constants.Owner) != -1)
            //            name["Owner"] = site.Substring(site.IndexOf(Constants.Owner) + Constants.Owner.Length);
            //        if (site.IndexOf(Constants.Name) != -1)
            //            name["Name"] = site.Substring(site.IndexOf(Constants.Name) + Constants.Name.Length);
            //        if (site.IndexOf(Constants.TicketId) != -1)
            //            name["TicketId"] = site.Substring(site.IndexOf(Constants.TicketId) + Constants.TicketId.Length);
            //    }
            //    sitesInformation.Add(name);
            //}
            //var data = new { comments = sitesInformation,xmlData };
            return(Json(xmlData, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Validate EMIE admin
        /// </summary>
        /// <param name="EMIEUserName">username</param>
        /// <param name="EMIEPassword">password</param>
        /// <returns>true-if validated successfully</returns>
        public JsonResult ValidateEMIEAdmin(string emieUserName, string emiePassword)
        {
            try
            {
                var EMIEAdminUserNameConfigItem = DbEntity.EMIEConfigurationSettings.Where(config => config.ConfigItem.Equals(ConfigConstants.EMIEAdminUserName)).FirstOrDefault();
                var EMIEAdminPasswordConfigItem = DbEntity.EMIEConfigurationSettings.Where(config => config.ConfigItem.Equals(ConfigConstants.EMIEAdminPassword)).FirstOrDefault();

                ConfigurationController controller = new ConfigurationController();
                string EMIEUserNameCred            = EMIEAdminUserNameConfigItem.ConfiguredValue;
                string EMIEUSerPAsswordCred        = controller.Decrypt(EMIEAdminPasswordConfigItem.ConfiguredValue);
                if (EMIEUserNameCred.Equals(emieUserName, StringComparison.OrdinalIgnoreCase) && EMIEUSerPAsswordCred.Equals(emiePassword))
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }