Esempio n. 1
0
        private bool sendNotificationCode()
        {
            System.Configuration.Configuration webConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/docbox/web.config");
            System.Configuration.KeyValueConfigurationElement hostEmailId =
                webConfig.AppSettings.Settings["adminEmail"];
            var allusers = from usertabel in database.DX_USER
                           where usertabel.userid == SessionKeyMgmt.UserId
                           select usertabel;

            if (allusers == null && allusers.ToList().Count != 1)
            {
                return(false);
            }
            try
            {
                string activationcode = generateActivationCode();
                allusers.ToList().First().actcodehash = generateHash(activationcode);
                EmailMessaging.sendMessage(allusers.ToList().First().userid, "Activation code is:" + activationcode, "Activation Code");
                database.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
        static string getConfig(string key)
        {
            var configFileName = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                Environment.MachineName + ".config");

            if (File.Exists(configFileName))
            {
                foreach (var line in File.ReadAllLines(configFileName))
                {
                    if (line.StartsWith(key + "="))
                    {
                        return(line.Substring(line.IndexOf("=") + 1));
                    }
                }
            }

            System.Configuration.Configuration rootWebConfig1 =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");
            if (rootWebConfig1.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement customSetting =
                    rootWebConfig1.AppSettings.Settings[key];
                if (customSetting != null)
                {
                    return(customSetting.Value);
                }
            }
            return(null);
        }
Esempio n. 3
0
        public bool GetXMLFileLoc()
        {
            bool bReturn = false;

            if (Session["XMLFileLoc"] != null)
            {
                XMLFileLoc = Session["XMLFileLoc"].ToString();
            }
            else
            {
                System.Configuration.Configuration rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");
                if (rootWebConfig1.AppSettings.Settings.Count > 0)
                {
                    System.Configuration.KeyValueConfigurationElement customSetting2 = rootWebConfig1.AppSettings.Settings["53FilterXMLFile"];
                    if (customSetting2 != null)
                    {
                        XMLFileLoc = HttpContext.Current.Server.MapPath(customSetting2.Value);
                        bReturn    = true;
                    }
                }
                else
                {
                    myLogging.LogError("No Filter file loaded, setting to default filter file.", "Warning");
                    XMLFileLoc = HttpContext.Current.Server.MapPath("/CSharp/My53Finan/Uploads/Filter.xml");
                }

                //saving it to session
                Session["XMLFileLoc"] = XMLFileLoc;
            }

            return(bReturn);
        }
Esempio n. 4
0
        private void IntialValue()
        {
            //// initialize our UploadDir
            if (Session["UploadDir"] != null)
            {
                UploadDir = Session["UploadDir"].ToString();
            }
            else
            {
                System.Configuration.Configuration rootWebConfig1 = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");
                if (rootWebConfig1.AppSettings.Settings.Count > 0)
                {
                    System.Configuration.KeyValueConfigurationElement customSetting = rootWebConfig1.AppSettings.Settings["53UploadDir"];
                    if (customSetting != null)
                    {
                        UploadDir = HttpContext.Current.Server.MapPath(customSetting.Value);
                    }
                }
                else
                {
                    errLog.LogError("No Upload directory loaded, setting to default directory.", "Warning");
                    UploadDir = HttpContext.Current.Server.MapPath("/CSharp/My53Finan/Uploads/");
                }

                //saving it to session
                Session["UploadDir"] = UploadDir;
            }
        }
Esempio n. 5
0
        public static void RegisterAuth()
        {
            // To let users of this site log in using their accounts from other sites such as Microsoft, Facebook, and Twitter,
            // you must update this site. For more information visit http://go.microsoft.com/fwlink/?LinkID=252166

            //OAuthWebSecurity.RegisterMicrosoftClient(
            //    clientId: "",
            //    clientSecret: "");

            //OAuthWebSecurity.RegisterTwitterClient(
            //    consumerKey: "",
            //    consumerSecret: "");

            string appid     = "";
            string appsecret = "";

            //appid = WebConfigurationManager.AppSettings["FacebookAppId"].ToString();
            //appsecret = WebConfigurationManager.AppSettings["FacebookAppSecret"].ToString();

            System.Configuration.Configuration rootWebConfig1 =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
            if (rootWebConfig1.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement FacebookAppSetting =
                    rootWebConfig1.AppSettings.Settings["FacebookAppId"];
                if (FacebookAppSetting != null)
                {
                    appid = FacebookAppSetting.Value;
                }

                else
                {
                    Console.WriteLine("No FacebookAppId application string");
                }

                FacebookAppSetting =
                    rootWebConfig1.AppSettings.Settings["FacebookAppSecret"];
                if (FacebookAppSetting != null)
                {
                    appsecret = FacebookAppSetting.Value;
                }

                else
                {
                    Console.WriteLine("No FacebookAppSecret application string");
                }
            }


            OAuthWebSecurity.RegisterFacebookClient(
                appId: appid,
                appSecret: appsecret);

            //OAuthWebSecurity.RegisterGoogleClient();
        }
Esempio n. 6
0
            public static SelectList GetDepts(string branchcode)
            {
                //branchcode  = "001";

                System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
                System.Configuration.KeyValueConfigurationElement HeadOfficeDepartments = rootWebConfig.AppSettings.Settings["HeadOfficeDepartments"];

                //string deptcodes   = "118,225,224,117,180,474,1473,166,658";
                string deptcodes = HeadOfficeDepartments.Value.ToString();

                return(LINQCalls.getHODepts(branchcode, deptcodes));
            }
Esempio n. 7
0
        private void RegisterTypes()
        {
            try
            {
                LogToVSOutputWindow("Registering types...\n");
                //kludge
                if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    LogToVSOutputWindow("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;
                try
                {
                    ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                    helperAssembly = config.AppSettings["QfHelperAssembly"];
                }
                catch (Exception ex)
                {//nobody cares
                }
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    IEnumerable <Assembly> assemblies = new Assembly[]
                    { Assembly.LoadFrom(helperAssembly.Value), Assembly.GetExecutingAssembly() };
                    //IEnumerable<Assembly> assemblies = new Assembly[] { Assembly.GetExecutingAssembly(), Assembly.LoadFrom(helperAssembly.Value) };

                    // Don't use AutoRegister(), it registers thousands of types and we only use four.
                    //TinyIoCContainer.Current.AutoRegister(assemblies);
                    TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IQueryParamInfo), typeof(QueryParamInfo)).AsMultiInstance();
                }
                else
                {
                    // Don't use AutoRegister(), it registers thousands of types and we only use four.
                    //TinyIoCContainer.Current.AutoRegister();
                    TinyIoCContainer.Current.Register <IProvider, Providers.SqlServer>("System.Data.SqlClient");
                    TinyIoCContainer.Current.Register <IProvider, Providers.Postgres>("Npgsql");
                    TinyIoCContainer.Current.Register <IProvider, Providers.MySql>("MySql.Data.MySqlClient");
                    TinyIoCContainer.Current.Register(typeof(IWrapperClassMaker), typeof(WrapperClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(ISignatureMaker), typeof(SignatureMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IResultClassMaker), typeof(ResultClassMaker)).AsMultiInstance();
                    TinyIoCContainer.Current.Register(typeof(IQueryParamInfo), typeof(QueryParamInfo)).AsMultiInstance();
                }
                LogToVSOutputWindow("Registered types...\n");
            }
            catch (Exception ex)
            {
                LogToVSOutputWindow(ex.Message + '\n' + ex.StackTrace);
            }
        }
Esempio n. 8
0
 public static bool Get(string name, bool value)
 {
     System.Configuration.KeyValueConfigurationElement element =
         instance.config.AppSettings.Settings[name];
     if (element == null)
     {
         return(value);
     }
     else
     {
         return(element.Value == "true");
     }
 }
Esempio n. 9
0
        public ActionResult ViewAppraisalApprovers(string FilterBy = "")
        {
            System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
            System.Configuration.KeyValueConfigurationElement CurrentAppraisalPeriod = rootWebConfig.AppSettings.Settings["CurrentAppraisalPeriod"];

            List <AppraisalApproverModel> appraisalApproverModel = LINQCalls.getApproverSetupList();

            if (!String.IsNullOrEmpty(FilterBy))
            {
                appraisalApproverModel = FilterAppraisalApproverList(appraisalApproverModel, FilterBy.ToUpper());
            }
            return(View(appraisalApproverModel));
        }
Esempio n. 10
0
 protected Logger()
 {
     System.Configuration.Configuration rootWebConfig =
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
     if (rootWebConfig.AppSettings.Settings.Count > 0)
     {
         System.Configuration.KeyValueConfigurationElement customSetting =
             rootWebConfig.AppSettings.Settings["EnableLogging"];
         if (customSetting != null)
         {
             this.enableLogging = bool.Parse(customSetting.Value);
         }
     }
 }
Esempio n. 11
0
            public static SelectList GetNumberCountries()
            {
                System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
                System.Configuration.KeyValueConfigurationElement maxCountries = rootWebConfig.AppSettings.Settings["maxCountries"];

                var list = new List <SelectListItem>();

                for (var i = 1; i < int.Parse(maxCountries.Value.ToString()); i++)
                {
                    list.Add(new SelectListItem {
                        Text = i.ToString(), Value = i.ToString()
                    });
                }

                return(new SelectList(list, "Text", "Value"));
            }
Esempio n. 12
0
        public static string GetAppSetting(string key)
        {
            string settingValue = string.Empty;

            System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
            if (rootWebConfig.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement customSetting =
                    rootWebConfig.AppSettings.Settings[key];
                if (customSetting != null)
                {
                    settingValue = customSetting.Value;
                }
            }
            return(settingValue);
        }
Esempio n. 13
0
        public Log4NetLoggerService()
        {
            this.logger = LogManager.GetLogger(
                System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
            if (rootWebConfig.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement customSetting =
                    rootWebConfig.AppSettings.Settings["EnableLogging"];
                if (customSetting != null)
                {
                    this.enableLogging = bool.Parse(customSetting.Value);
                }
            }
        }
Esempio n. 14
0
            public static SelectList GetSexes()
            {
                System.Configuration.Configuration rootWebConfig        = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
                System.Configuration.KeyValueConfigurationElement sexes = rootWebConfig.AppSettings.Settings["sexes"];

                var sexList = sexes.Value.ToString().Split(',').ToList();

                SelectList list = new SelectList(sexList);

                /*var list = new List<SelectListItem>();
                 * for (var i = 1; i <= sexList.Count; i++) {
                 *  list.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() });
                 * }
                 *
                 * list = sexList.Select((r,index) => new SelectListItem{Text = r, Value = index.ToString()}).ToList<SelectList>();*/
                return(list);
            }
Esempio n. 15
0
 public string this[string name] {
     get {
         System.Configuration.KeyValueConfigurationElement element =
             config.AppSettings.Settings[name];
         if (element != null)
         {
             return(element.Value);
         }
         else
         {
             return(null);
         }
     }
     set {
         config.AppSettings.Settings.Remove(name);
         config.AppSettings.Settings.Add(name, value);
     }
 }
Esempio n. 16
0
        public LinqLogger(string fileName)
        {
#if DEBUG
            this.sw           = new StreamWriter(fileName, true);
            this.sw.AutoFlush = true;
#endif
            System.Configuration.Configuration rootWebConfig =
                System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
            if (rootWebConfig.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement customSetting =
                    rootWebConfig.AppSettings.Settings["EnableLogging"];
                if (customSetting != null)
                {
                    this.enableLogging = bool.Parse(customSetting.Value);
                }
            }
        }
Esempio n. 17
0
        public ActionResult ViewBranchInitiators(string FilterBy = "")
        {
            System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
            System.Configuration.KeyValueConfigurationElement CurrentAppraisalPeriod = rootWebConfig.AppSettings.Settings["CurrentAppraisalPeriod"];

            List <BHSingleSetupModel> bHSingleSetupModel = new LINQCalls().getBranchInitiators(CurrentAppraisalPeriod.Value.ToString());

            if (!String.IsNullOrEmpty(FilterBy))
            {
                /*bHSingleSetupModel = bHSingleSetupModel.Where(  c => c.SetupBranch.ToUpper().Contains(FilterBy)   ||
                 *                                              c.StaffNumber.ToUpper().Contains(FilterBy)        ||
                 *                                              c.StaffName.ToUpper().Contains(FilterBy)          ||
                 *                                              c.SetupAppPeriod.ToUpper().Contains(FilterBy)     ||
                 *                                              c.SelectedAppraisalPeriod.ToUpper().Contains(FilterBy))
                 *                                     .ToList();*/
                bHSingleSetupModel = FilterBranchInitiatorList(bHSingleSetupModel, FilterBy.ToUpper());
            }
            return(View(bHSingleSetupModel));
        }
Esempio n. 18
0
        /// <summary>
        /// This method reads app settings the local app.config file for the calling assembly/dll"/>
        /// </summary>
        /// <param name="section"></param>
        /// <param name="setting"></param>
        /// <param name="obj">valid return value if returned true</param>
        /// <returns>true if value exists</returns>
        public static bool GetDllConfigAppSetting(string setting, out object obj)
        {
            try
            {
                // The dllPath can't just use Assembly.GetExecutingAssembly().Location as ASP.NET doesn't copy the config to shadow copy path
                var dllPath   = new Uri(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase).LocalPath;
                var dllConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(dllPath);

                // Get the appSettings section
                var appSettings = (System.Configuration.AppSettingsSection)dllConfig.GetSection("appSettings");
                System.Configuration.KeyValueConfigurationElement element = appSettings.Settings[setting];
                obj = element.Value;
                return(true);
            }
            catch (Exception ex)
            {
                throw new ArgumentNullException(string.Format("ConfigurationManager.GetDllConfigAppSetting(...) - error attempting to get value from dll 'appSettings' section , param:{0} - {1}", setting, ex.Message), ex);
            }
        }
Esempio n. 19
0
        private string GetLogFilePath()
        {
            if (logFilePath != null)
            {
                return(logFilePath);
            }
            else
            {
                string logPath = "";
                try
                {
                    // Get log file path from web.config
                    System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
                    if (rootWebConfig.AppSettings.Settings.Count > 0)
                    {
                        System.Configuration.KeyValueConfigurationElement logPathElem = rootWebConfig.AppSettings.Settings["LogPath"];
                        if (logPathElem != null)
                        {
                            logPath = logPathElem.Value;
                        }
                    }

                    // create default log file path and store in web.config
                    if (logPath == "")
                    {
                        logPath = @"C:\Inetpub\Log";
                        rootWebConfig.AppSettings.Settings.Add("LogPath", logPath);
                        rootWebConfig.Save();
                    }

                    // create directory if not exists
                    if (!Directory.Exists(logPath))
                    {
                        Directory.CreateDirectory(logPath);
                    }
                }
                catch { }

                logFilePath = Path.Combine(logPath, string.Format("{0}.log", this.GetType().ToString()));

                return(logFilePath);
            }
        }
Esempio n. 20
0
        private void BuildEvents_OnBuildBegin(vsBuildScope Scope, vsBuildAction Action)
        {
            // Determine whether require extension setting includes debug commenting
            bool commentInDebug = false;

            System.Configuration.KeyValueConfigurationElement requireExtension = null;
            try
            {
                ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                requireExtension = config.AppSettings["QfRequireExtension"];
            }
            catch (Exception)
            {            //nobody cares
            }
            if (requireExtension != null)
            {
                try
                {
                    if (!Convert.ToBoolean(requireExtension.Value))
                    {
                        commentInDebug = true;
                    }
                }
                catch (Exception)
                {                //still, nobody cares
                }
            }


            if (!_dte.Solution.SolutionBuild.ActiveConfiguration.Name.Contains("Debug") || commentInDebug)
            {
                foreach (Project proj in _dte.Solution.Projects)
                {
                    // Comments !
                    // On opening a query to edit, we "open" the design time comments.
                    // In debug builds, the comment may be compiled "open", and closed by the generated code prior to running the query.
                    // In production builds, to save this step, we verify and "close" all comments section before the build, and
                    // the generated code runs the query as found.
                    SetCommentsForProd(proj.ProjectItems);
                }
            }
        }
Esempio n. 21
0
        private void RegisterTypes(bool force = false)
        {
            try
            {
                var ctr = TinyIoCContainer.Current;
                LogToVSOutputWindow("Registering types...\n");
                //kludge
                if (force == true)
                {
                    ctr.Dispose();
                }
                else if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    LogToVSOutputWindow("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;
                try
                {
                    ConfigurationAccessor config = new ConfigurationAccessor(_dte, null);
                    helperAssembly = config.AppSettings["QfHelperAssembly"];
                }
                catch (Exception ex)
                {//nobody cares
                }
                List <Assembly> assemblies = new List <Assembly>();
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    assemblies.Add(Assembly.LoadFrom(helperAssembly.Value));
                }
                assemblies.Add(Assembly.GetExecutingAssembly());
                TinyIoCContainer.Current.AutoRegister(assemblies, DuplicateImplementationActions.RegisterSingle);
                // IProvider, for instance, has multiple implementations. To resolve we use the provider name on the connection string,
                // which must correspond to the fully qualified name of the implementation. ie. QueryFirst.Providers.SqlClient for SqlServer

                LogToVSOutputWindow("Registered types...\n");
            }
            catch (Exception ex)
            {
                LogToVSOutputWindow(ex.Message + '\n' + ex.StackTrace);
            }
        }
Esempio n. 22
0
 public static int Get(string name, int value)
 {
     System.Configuration.KeyValueConfigurationElement element =
         instance.config.AppSettings.Settings[name];
     if (element == null)
     {
         return(value);
     }
     else
     {
         int parsedValue;
         if (int.TryParse(element.Value, out parsedValue))
         {
             return(parsedValue);
         }
         else
         {
             return(value);
         }
     }
 }
Esempio n. 23
0
        internal string GetUserName()
        {
            logWriter.WriteTolog(string.Format("Entered GetUserName"));
            string username = null;

            try
            {
                System.Configuration.Configuration rootWebConfig              = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
                System.Configuration.KeyValueConfigurationElement sADUser     = null;
                System.Configuration.KeyValueConfigurationElement sADPassword = null;
                System.Configuration.KeyValueConfigurationElement sDomain     = null;

                if (rootWebConfig.AppSettings.Settings.Count > 0)
                {
                    sADUser     = rootWebConfig.AppSettings.Settings["sADUser"];
                    sADPassword = rootWebConfig.AppSettings.Settings["sADPassword"];
                    sDomain     = rootWebConfig.AppSettings.Settings["sDomain"];
                    if (sADUser == null)
                    {
                        username = null;
                        logWriter.WriteTolog(string.Format("No ad admin profile application string"));
                    }
                    else
                    {
                        username = SearchUserName(sADUser.Value.ToString(), sADPassword.Value.ToString(), sDomain.Value.ToString());
                    }
                }
                else
                {
                    username = null;
                }
            }
            catch (Exception ex)
            {
                username = null;
                logWriter.WriteTolog(string.Format(" GetStaffProfile : Exception / {0} / {1}", staffADProfile.employee_number, ex.Message));
            }
            return(username);
        }
Esempio n. 24
0
 protected void Page_Load(object sender, EventArgs e)
 {
     System.Configuration.Configuration rootWebConfig1 =
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/");
     if (rootWebConfig1.AppSettings.Settings.Count > 0)
     {
         System.Configuration.KeyValueConfigurationElement accountSidSetting =
             rootWebConfig1.AppSettings.Settings["myAccountSid"];
         System.Configuration.KeyValueConfigurationElement authTokenSetting =
             rootWebConfig1.AppSettings.Settings["myAuthToken"];
         if (accountSidSetting != null && authTokenSetting != null)
         {
             System.Diagnostics.Debug.Print("accountSidSetting application string = \"{0}\"",
                                            accountSidSetting.Value);
             TwilioClient.Init(accountSidSetting.Value, authTokenSetting.Value);
         }
         else
         {
             System.Diagnostics.Debug.Print("Account sid or auth token not found");
         }
     }
 }
Esempio n. 25
0
 /// <summary>
 /// 获取写在Web.config里面的appsetting节的内容,如果没有对应节返回null
 /// </summary>
 /// <param name="KeyName">要读取节的KeyName</param>
 /// <returns>对应节的值,没有则返回null </returns>
 public static String GetAppSettingValue(String KeyName)
 {
     //注意!这里的值是从网站根目录WebConfig读取的
     System.Configuration.Configuration rootWebConfig1 =
         System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/web.config");
     if (rootWebConfig1.AppSettings.Settings.Count > 0)
     {
         System.Configuration.KeyValueConfigurationElement customSetting =
             rootWebConfig1.AppSettings.Settings[KeyName];
         if (customSetting != null)
         {
             return(customSetting.Value);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }
Esempio n. 26
0
 public static float Get(string name, float value)
 {
     System.Configuration.KeyValueConfigurationElement element =
         instance.config.AppSettings.Settings[name];
     if (element == null)
     {
         return(value);
     }
     else
     {
         float parsedValue;
         if (float.TryParse(element.Value,
                            System.Globalization.NumberStyles.Float,
                            System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
         {
             return(parsedValue);
         }
         else
         {
             return(value);
         }
     }
 }
Esempio n. 27
0
 public static Color Get(string name, Color value)
 {
     System.Configuration.KeyValueConfigurationElement element =
         instance.config.AppSettings.Settings[name];
     if (element == null)
     {
         return(value);
     }
     else
     {
         int parsedValue;
         if (int.TryParse(element.Value,
                          System.Globalization.NumberStyles.HexNumber,
                          System.Globalization.CultureInfo.InvariantCulture, out parsedValue))
         {
             return(Color.FromArgb(parsedValue));
         }
         else
         {
             return(value);
         }
     }
 }
Esempio n. 28
0
        /// <summary>
        /// Retorna um valor de uma chave da seção AppSettins do arquivo xml de configuração do Assembly está executando
        /// </summary>
        /// <param name="KeyCustomSetting"></param>
        /// <returns></returns>
        private string GetValeuOfSectionAppSettingsOfFileOfConfigCurrentAssemblyRunning(string KeyCustomSetting)
        {
            System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/");

            // cria um elemento chave valor para App
            System.Configuration.KeyValueConfigurationElement customSetting = new System.Configuration.KeyValueConfigurationElement(KeyCustomSetting, "");

            if (rootWebConfig.AppSettings.Settings.Count > 0)
            {
                customSetting = rootWebConfig.AppSettings.Settings[KeyCustomSetting];
            }
            else
            {
                throw new Exception(String.Format("A chave {0} não foi encontrada no arquivo de configuração da aplicação", KeyCustomSetting));
            }

            if (customSetting == null)
            {
                throw new Exception(String.Format("A chave {0} não possui valor.", KeyCustomSetting));
            }

            return(customSetting.Value);
        }
        private void RegisterTypes(bool force = false)
        {
            try
            {
                var ctr = TinyIoCContainer.Current;
                _VSOutputWindow.Write(@"If you're using and enjoying QueryFirst, please leave a review!
https://marketplace.visualstudio.com/items?itemName=bbsimonbb.QueryFirst#review-details
");
                //kludge
                if (force == true)
                {
                    ctr.Dispose();
                }
                else if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    _VSOutputWindow.Write("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;

                List <Assembly> assemblies = new List <Assembly>();
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    assemblies.Add(Assembly.LoadFrom(helperAssembly.Value));
                }
                assemblies.Add(Assembly.GetExecutingAssembly());
                TinyIoCContainer.Current.AutoRegister(assemblies, DuplicateImplementationActions.RegisterSingle);
                // IProvider, for instance, has multiple implementations. To resolve we use the provider name on the connection string,
                // which must correspond to the fully qualified name of the implementation. ie. QueryFirst.Providers.SqlClient for SqlServer

                //_VSOutputWindow.Write("Registered types...\n");
            }
            catch (Exception ex)
            {
                _VSOutputWindow.Write(ex.Message + '\n' + ex.StackTrace);
            }
        }
Esempio n. 30
0
        public void Register(VSOutputWindow outputWindow, bool force = false)
        {
            try
            {
                var ctr = TinyIoCContainer.Current;


                //kludge
                if (force == true)
                {
                    ctr.Dispose();
                }
                else if (TinyIoCContainer.Current.CanResolve <IWrapperClassMaker>())
                {
                    //_VSOutputWindow.Write("Already registered\n");
                    return;
                }
                System.Configuration.KeyValueConfigurationElement helperAssembly = null;

                List <Assembly> assemblies = new List <Assembly>();
                if (helperAssembly != null && !string.IsNullOrEmpty(helperAssembly.Value))
                {
                    assemblies.Add(Assembly.LoadFrom(helperAssembly.Value));
                }
                assemblies.Add(Assembly.GetExecutingAssembly());
                TinyIoCContainer.Current.AutoRegister(assemblies, DuplicateImplementationActions.RegisterSingle);
                // IProvider, for instance, has multiple implementations. To resolve we use the provider name on the connection string,
                // which must correspond to the fully qualified name of the implementation. ie. QueryFirst.Providers.SqlClient for SqlServer

                //_VSOutputWindow.Write("Registered types...\n");
            }
            catch
            {
                //outputWindow.Write(ex.Message + '\n' + ex.StackTrace);
            }
        }