public AppConfig(string filename) { System.Configuration.ExeConfigurationFileMap _cfgMap = new System.Configuration.ExeConfigurationFileMap(); _cfgMap.ExeConfigFilename = filename; _config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration (_cfgMap, System.Configuration.ConfigurationUserLevel.None); _app_settings = new config.Internals.AppSettingsClass(ref _config); }
public Mixture() { InitializeComponent(); Checker.cEmpty = Color.Yellow; //Checker.cOutOfRange = Color.MediumOrchid; Checker.cErr = Color.DeepPink; mainConf = System.Configuration.ConfigurationManager.OpenExeConfiguration(""); GetValueByKey("IronTask", txbIronTask); GetValueByKey("IronTemp", txbIronTemp); GetValueByKey("ScrapTemp", txbScrapTemp); GetValueByKey("SteelTemp", txbSteelTemp); GetValueByKey("Basiticy", txbBasiticy); GetValueByKey("LimeTask", txbLimeIn); GetValueByKey("DolomSTask", txbLimeStoneIn); GetValueByKey("FomTask", txbFomIn); GetValueByKey("DolmaxTask", txbDolomIn); GetValueByKey("CokeTask", txbCokeIn); GetValueByKey("PercentMgO", txbMgO); GetValueByKey("PercentFeO", txbFeO); ch_Iron = new ChemTable("Химия чугуна", "IRON"); ch_Iron.LoadCSVData(); ch_Scrap = new ChemTable("Химия лома", "SCRAP"); ch_Scrap.LoadCSVData(); ch_Lime = new ChemTable("Химия извести", "LIME"); ch_Lime.LoadCSVData(); ch_Dolmax = new ChemTable("Химия доломита сушеного (ДОЛОМС)", "DOLOMS"); ch_Dolmax.LoadCSVData(); ch_Fom = new ChemTable("Химия ФОМа", "FOM"); ch_Fom.LoadCSVData(); if (Program.slagFormerIsMaxG) { lblLimeStoneIn.Text = "Магнезит"; lblLimeStoneOut.Text = "Магнезит"; ch_Doloms = new ChemTable("Химия магнезита (МАХГ)", "MAXG"); } else { lblLimeStoneIn.Text = "Доломит"; lblLimeStoneOut.Text = "Доломит"; ch_Doloms = new ChemTable("Химия доломита (ДОЛМИТ)", "DOLMIT"); } ch_Doloms.LoadCSVData(); ch_Coke = new ChemTable("Химия кокса", "COKE"); ch_Coke.LoadCSVData(); ch_Dust = new ChemTable("Химия отходящих пылей", "OFFDUST"); ch_Dust.LoadCSVData(); scrapTable = new ScrapTable(); ironTable = new IronTable(); btnCalculate.Select(); }
public static void RegisterDataAccessAgents(string serviceDirectory, string serviceName) { System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(serviceDirectory); if (!DataAccessServices.IsDataAccessServiceRegistered <IWorklistDataAccessAgent2>()) { IWorklistDataAccessAgent2 worklistDataAccess = DataAccessFactory.GetInstance(new WorklistDataAccessConfigurationView(configuration, null, serviceName)).CreateDataAccessAgent <IWorklistDataAccessAgent2>(); DataAccessServices.RegisterDataAccessService <IWorklistDataAccessAgent2>(worklistDataAccess); DataAccess = worklistDataAccess; } else { DataAccess = DataAccessServices.GetDataAccessService <IWorklistDataAccessAgent2>(); } }
/// <summary> /// Hàm này lấy connection string từ file web.config theo tên của connection string /// Nếu lưu chuỗi kết nối cùng với mã nguồn C# thì sau này không thể dùng chương trình đã biên dịch với các cấu hình khác, cần phải điều chỉnh /// chuỗi kết nối trong mã nguồn C# và biên dịch lại... /// Nếu lưu trong web.config và các kiểu cấu hình khác, chỉ cần thay đổi cấu hình trong các tệp đó... /// </summary> /// <param name="connectionStringName"></param> - xem web.config để thấy tên và nội dung của chuỗi kết nối có tên connectionStringName /// <returns></returns> public static string getConnectionStringByName(string connectionStringName) { System.Configuration.Configuration rootWebConfig = //Dung System.Reflection.Assembly.GetExecutingAssembly().FullName de lay namespace=websiate thay vi moi lan phai dieu chinh cho moi du an System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(String.Format("\\{0}", System.Reflection.Assembly.GetExecutingAssembly().FullName)); // /VD9 ten website = project System.Configuration.ConnectionStringSettings connString; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings[connectionStringName]; if (connString != null) { return(connString.ConnectionString); } } return(""); }
//get constring from xml config public string getConnectionStringByName(string connectionStringName) { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/SalesFood"); System.Configuration.ConnectionStringSettings connString; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings[connectionStringName]; if (connString != null) { return(connString.ConnectionString); } } return(""); }
public static bool SetNgaySaoLuuTatCaGanDay(string NgaySaoLuuTatCaGanDay) { try { System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); config.AppSettings.Settings["NgaySaoLuuTatCaGanDay"].Value = NgaySaoLuuTatCaGanDay; config.Save(System.Configuration.ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); return(true); } catch (Exception ex) { return(false); } }
private bool CheckPermissions() { try { System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(Module.ServiceDirectory); IPermissionManagementDataAccessAgent agent = DataAccessFactory.GetInstance(new AePermissionManagementDataAccessConfigurationView(configuration, null, Module.ServiceName)).CreateDataAccessAgent <IPermissionManagementDataAccessAgent>(); string[] permissions = agent.GetUserPermissions(_Client.AETitle); return(permissions.Contains(UpdatePermission)); } catch (Exception e) { Logger.Global.Exception("Patient Updater", e); } return(false); }
public override void Configure(IServiceCollection services, System.Configuration.Configuration moduleConfiguration) { IAuthorizationRulesService authorizationRuleService = services.Get <IAuthorizationRulesService>(); if (authorizationRuleService != null) { AuthorizationConfigurationSection authorizationSection = moduleConfiguration.GetSection(AuthorizationSection) as AuthorizationConfigurationSection; if (authorizationSection != null) { foreach (AuthorizationRuleElement ruleElement in authorizationSection.ModuleRules) { authorizationRuleService.RegisterAuthorizationRule(ruleElement.AbsolutePath, ruleElement.RuleName); } } } }
private ClientSettingsSection GetConfigSection(System.Configuration.Configuration config, string sectionName, bool declare) { string str = "userSettings/" + sectionName; ClientSettingsSection section = null; if (config != null) { section = config.GetSection(str) as ClientSettingsSection; if ((section == null) && declare) { this.DeclareSection(config, sectionName); section = config.GetSection(str) as ClientSettingsSection; } } return(section); }
/// <summary> /// Gets the app settings section entry. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="sectionName">Name of the section.</param> /// <param name="keyName">Name of the key.</param> /// <returns></returns> public static string GetAppSettingsSectionEntry(System.Configuration.Configuration configuration, string sectionName, string keyName) { string result = string.Empty; System.Configuration.ConfigurationSection configSection = configuration.GetSection(sectionName); if (configSection != null) { System.Configuration.AppSettingsSection section = (System.Configuration.AppSettingsSection)configuration.GetSection(sectionName); if (section?.Settings?[keyName] != null) { var item = section.Settings[keyName]; result = item.Value; } } return(result); }
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")); }
/// <summary> /// Sets the value to web configuration. /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> public static void SetValueToWebConfig(string key, string value) { try { if (System.Configuration.ConfigurationManager.AppSettings[key] != null) { System.Configuration.Configuration rockWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~"); rockWebConfig.AppSettings.Settings[key].Value = value; rockWebConfig.Save(); } } catch (Exception ex) { ExceptionLogService.LogException(ex, null); } }
public static string getConnectionStringByName(string connectionStringName) { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/PracticeEx6");//ten website = project System.Configuration.ConnectionStringSettings connString; if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0) { connString = rootWebConfig.ConnectionStrings.ConnectionStrings[connectionStringName]; if (connString != null) { return(connString.ConnectionString); } } return(""); }
protected void btnRestart_Click(object sender, EventArgs e) { try { System.Configuration.Configuration cfg = WebConfigurationManager.OpenWebConfiguration("~"); EditSection edit = (EditSection)cfg.GetSection("n2/edit"); edit.Installer.AllowInstallation = AllowInstallationOption.No; cfg.Save(); Response.Redirect(Engine.ManagementPaths.GetManagementInterfaceUrl()); } catch { ltDisableFailed.Text = "Failed writing to web.config, please change this manually in web.config:"; } }
public static ControlAtraso.Result <string> Enrolar(ControlAtraso.Entity.Persona persona) { string startupPath = System.Environment.GetCommandLineArgs()[0]; System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(startupPath); string url = configuration.AppSettings.Settings["targetUrl"].Value; url = string.Format("{0}/Enrolar", url); ControlAtraso.Helper h = new Helper(); ControlAtraso.Result <string> result = h.Call <string>(CallType.CallTypePost, url, persona); return(result); }
public void InsertComShopID() { System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); string strConn = config.AppSettings.Settings["connectionstring"].Value; //this.txtUrl.Text.Trim(); this.comboBox1.Items.Clear(); //清空ComBox IDataReader dr = SqlHelper.ExecuteReader(strConn, CommandType.StoredProcedure, "pr_xc_getWorkShop"); while (dr.Read()) { this.comboBox1.Items.Add(dr[0].ToString());//循环读取数据 }//end block while dr.Close();// 关闭数据集 // DB.GetColse();//关闭数据库连接 }
/// <summary> /// Opens the Host configuration file for edit /// </summary> /// <returns>Returns true if the file is opened else false.</returns> internal bool OpenHostConfigurationFile() { try { string collectionCreatorExePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "Zentity.Pivot.CollectionCreator.exe"); this.hostConfiguration = System.Configuration.ConfigurationManager.OpenExeConfiguration(collectionCreatorExePath); HostConfigurationHelper.pivotConfigSection = (PivotConfigurationSection)this.hostConfiguration.GetSection(PivotConfigurationSection.Instance.SectionInformation.Name); PivotConfigurationSection.Instance = HostConfigurationHelper.pivotConfigSection; return(true); } catch (System.Exception exception) { throw new FaultException(exception.ToString()); //throw new FaultException<Exception>(exception, exception.Message); } }
public static void configOnOff(string _key) { System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); if (conf.AppSettings.Settings[_key].Value == "true") { conf.AppSettings.Settings.Remove(_key); conf.AppSettings.Settings.Add(_key, "false"); } else { conf.AppSettings.Settings.Remove(_key); conf.AppSettings.Settings.Add(_key, "true"); } conf.Save(System.Configuration.ConfigurationSaveMode.Modified); }
// ------------------------------------------------------------------------- public static ProjectSection GetSection(string filename) { if (string.IsNullOrWhiteSpace(filename)) { return(null); } System.Configuration.ExeConfigurationFileMap configMap = new System.Configuration.ExeConfigurationFileMap( ); configMap.ExeConfigFilename = filename; System.Configuration.Configuration config = System.Configuration.ConfigurationManager .OpenMappedExeConfiguration(configMap, System.Configuration.ConfigurationUserLevel.None); ProjectSetting.ProjectSection ps = config.GetSection(nameof(ProjectSetting.ProjectSection)) as ProjectSetting.ProjectSection; // System.Data.DataTable dt = ConfigurationSetting.DataStore.LoadDataStoreConfigurationSetting( ); ps.LinkDataStores(dt); ps.VerifySnapshots( ); return(ps); }
public WmiConnector() { // Initialize our WMI information and connection System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~/"); if (rootWebConfig.AppSettings.Settings.Count > 0) { SiteServer = rootWebConfig.AppSettings.Settings["SiteServer"].Value.ToString(); SiteCode = rootWebConfig.AppSettings.Settings["SiteCode"].Value.ToString(); NameSpace = "root\\SMS\\site_" + rootWebConfig.AppSettings.Settings["SiteCode"].Value.ToString(); FQWmiPath = "\\\\" + SiteServer + "\\" + NameSpace; } CmAppScope = new ManagementScope(FQWmiPath, new ConnectionOptions { Impersonation = ImpersonationLevel.Impersonate }); }
public static void RemoveKey(string key) { try { if (!string.IsNullOrEmpty(key)) { System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); if (config.AppSettings.Settings[key] != null) { config.AppSettings.Settings.Remove(key); config.Save(System.Configuration.ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); } } } catch { } }
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); } } }
public void Excluir(int cod) { System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot"); System.Configuration.ConnectionStringSettings connString; connString = rootWebConfig.ConnectionStrings.ConnectionStrings["mymoneyConnectionString"]; //cria um objeto de conexão SqlConnection con = new SqlConnection(); con.ConnectionString = connString.ToString(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "delete from financas where id = " + cod.ToString(); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
protected void btLogar_Click(object sender, EventArgs e) { String email = txbEmail.Text; String senha = txbSenha.Text; // Acessando Web.config System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MyWebSiteRoot"); System.Configuration.ConnectionStringSettings connString; // Pegando a string de conexão no do web.config connString = rootWebConfig.ConnectionStrings.ConnectionStrings["ConnectionString"]; SqlConnection con = new SqlConnection(); con.ConnectionString = connString.ToString(); // Procurando usuario SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "SELECT * FROM usuario WHERE email = @email AND senha = @senha"; cmd.Parameters.AddWithValue("email", txbEmail.Text); cmd.Parameters.AddWithValue("senha", txbSenha.Text); // Pegando dados retornados do Select con.Open(); SqlDataReader registro = cmd.ExecuteReader(); if (registro.HasRows) { // Para efetuar a leitura dos registros retornados // registro.Read(); // Trabalhando com Coockies // Esta sendo feito a validação da autenticação em MasterPagePrincipal HttpCookie login = new HttpCookie("login", txbEmail.Text); Response.Cookies.Add(login); // Direcionar para pagina principal Response.Redirect("~/index.aspx"); } else { // Escrevendo script na pagina Response.Write("<script> alert('Error', 'Email ou senha incorretos!!'); </script>"); } con.Close(); }
public ActionResult Create(utblGenEnquiry model) { System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings"); System.Net.NetworkCredential credential = new System.Net.NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password); //Create the SMTP Client SmtpClient client = new SmtpClient(); client.Host = settings.Smtp.Network.Host; client.Credentials = credential; client.Timeout = 300000; client.EnableSsl = false; if (ModelState.IsValid) { MailMessage mail = new MailMessage(); StringBuilder mailbody = new StringBuilder(); mail.From = new MailAddress(settings.Smtp.Network.UserName, "Brothers Tours & Travel"); mail.To.Add(model.GuestEmailID); mail.To.Add("*****@*****.**"); mail.Priority = MailPriority.High; mail.ReplyToList.Add("*****@*****.**"); mail.Subject = "Enquiry Details"; mailbody.Append("<b>Thank You for submitting your enquiry. Our Travel Agents with get in touch with you soon with answers to your enquiry.</b>"); mailbody.Append("<h4>Enquiry Details</h4>"); mailbody.Append("Email Address: " + model.GuestEmailID + "<br/>Contact No.: " + model.GuestMobileNo + "<br/>Enquiry : " + model.EnquiryDetails); mail.Body = mailbody.ToString(); mail.IsBodyHtml = true; DateTime Currdate = DateTime.Today; string tempdate = Currdate.ToString("dd MMM yyyy"); DateTime NewCurrDate = DateTime.ParseExact(tempdate, "dd MMM yyyy", CultureInfo.InvariantCulture); model.EnquiryDate = NewCurrDate; model.EnquiryStatus = "Not Replied"; try { client.Send(mail); var a = obj.Save(model); return(Json(new { success = true, Message = 1 })); } catch (Exception) { return(Json(new { success = true, Message = 0 })); } } return(PartialView("_pvEnquiry", model)); }
private void UserLogin() { try { tblError.Visibility = Visibility.Collapsed; if (c_LoadCommonDataStatus != 2) { return; } User_Controller _User_Controller = new User_Controller(); User_Info _User_Info = _User_Controller.User_Login(txtUsername.Text, txtPassword.Text); if (_User_Info == null) { NoteBox.Show("Sai tên đăng nhập hoặc mật khẩu", "", NoteBoxLevel.Error); txtPassword.Focus(); return; } _User_Controller.User_Update_Last_Login(_User_Info.User_Id, DateTime.Now); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("LastestUser"); config.AppSettings.Settings.Add("LastestUser", _User_Info.User_Name); config.AppSettings.Settings.Remove("Password"); config.AppSettings.Settings.Add("Password", txtPassword.Text); config.Save(System.Configuration.ConfigurationSaveMode.Modified); System.Configuration.ConfigurationManager.RefreshSection("appSettings"); CommonData.c_Urser_Info = _User_Info; DBMemory.LoadFunctionUsers(); this.DialogResult = true; this.Close(); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); NoteBox.Show("Đăng nhập thất bại", "Thông báo"); } }
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); }
private void DeclareSection(System.Configuration.Configuration config, string sectionName) { if (config.GetSectionGroup("userSettings") == null) { ConfigurationSectionGroup group2 = new UserSettingsGroup(); config.SectionGroups.Add("userSettings", group2); } ConfigurationSectionGroup sectionGroup = config.GetSectionGroup("userSettings"); if ((sectionGroup != null) && (sectionGroup.Sections[sectionName] == null)) { ConfigurationSection section = new ClientSettingsSection { SectionInformation = { AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToLocalUser, RequirePermission = false } }; sectionGroup.Sections.Add(sectionName, section); } }
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); }
private void DoWork_handle(object sender, DoWorkEventArgs e) { //1. Query Data object using (PIPusingWPFModel.PIPEntities conn = new PIPusingWPFModel.PIPEntities()) { var prescriptionResult = conn.Prescriptions.Where(a => a.PrescriptionId.Equals(PrescriptionID)).First(); prescriptionTable = DAO.ToDataTable.ToDataTableMethodForObject(prescriptionResult); var patientResult = conn.Patients.Where(a => a.PatientId.Equals(prescriptionResult.PatientId)).First(); patientTable = DAO.ToDataTable.ToDataTableMethodForObject(patientResult); var doctorResult = conn.Doctors.Where(a => a.Did.Equals(prescriptionResult.Did)).First(); doctorTable = DAO.ToDataTable.ToDataTableMethodForObject(doctorResult); var result = conn.Drugs.Where(a => a.PrescriptionId.Equals(PrescriptionID)).ToList(); drugTable = DAO.ToDataTable.ToDataTableMethodForList(result); } Microsoft.Reporting.WinForms.ReportDataSource reportDataSource = new Microsoft.Reporting.WinForms.ReportDataSource(); reportDataSource.Name = "DrugsDataSet"; reportDataSource.Value = drugTable; //2. Load Data into report System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); _reportViewer.LocalReport.ReportPath = config.AppSettings.Settings["reportPath"].Value; //增加资源 _reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource() { Name = "PatientDataSet", Value = patientTable }); _reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource() { Name = "DoctorDataSet", Value = doctorTable }); _reportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource() { Name = "PrescriptionDataSet", Value = prescriptionTable }); _reportViewer.LocalReport.DataSources.Add(reportDataSource); _reportViewer.RefreshReport(); //3. show report }
public ActionResult Reply(MstBookingReplyModel paramdata) { System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings"); System.Net.NetworkCredential credential = new System.Net.NetworkCredential(settings.Smtp.Network.UserName, settings.Smtp.Network.Password); //Create the SMTP Client SmtpClient client = new SmtpClient(); client.Host = settings.Smtp.Network.Host; client.Credentials = credential; client.Timeout = 300000; client.EnableSsl = false; if (ModelState.IsValid) { MailMessage mail = new MailMessage(); mail.From = new MailAddress(settings.Smtp.Network.UserName, "Brothers Tours & Travel"); mail.To.Add(paramdata.MstTourBook.ClientEmailID); mail.Priority = MailPriority.High; mail.Subject = paramdata.MstMail.Subject; mail.Body = paramdata.MstMail.MessageBody; mail.ReplyToList.Add("*****@*****.**"); try { client.Send(mail); paramdata.MstTourBook.Status = "Replied"; dbBook.Save(paramdata.MstTourBook); TempData["ErrMsg"] = 1; return(RedirectToAction("list")); } catch (Exception ex) { TempData["ErrMsg"] = 0; return(RedirectToAction("list")); } } paramdata.MstTourBook = dbBook.GetBookingByID(paramdata.MstTourBook.BookingID); MstTourPackageDetailsModel pack = new MstTourPackageDetailsModel(); dalMstTourPackage dbPack = new dalMstTourPackage(); pack = dbPack.GetTourPackageDetailsByID(paramdata.MstTourBook.PackageID); ViewBag.PackageName = pack.PackageName; return(View(paramdata)); }
public static ScriptingJsonSerializationSection GetScriptingJsonSerializationSection() { if (scriptJsonSerializationSection == null) { lock (syncLock) { if (scriptJsonSerializationSection == null) { System.Configuration.Configuration webConfiguration = WebConfigurationManager.OpenWebConfiguration("/"); // Get the object related to the <system.web.extensions> section scriptJsonSerializationSection = (ScriptingJsonSerializationSection)webConfiguration.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); } } } return(scriptJsonSerializationSection); }
static ComBoostAuthentication() { _Config = WebConfigurationManager.OpenWebConfiguration("~"); SystemWebSectionGroup system = (SystemWebSectionGroup)_Config.GetSectionGroup("system.web"); IsEnabled = system.Authentication.Mode == AuthenticationMode.Forms; if (!IsEnabled) return; if (!_Config.AppSettings.Settings.AllKeys.Contains("ComBoostAuthenticationKey")) { _Key = Guid.NewGuid().ToByteArray(); _Config.AppSettings.Settings.Add("ComBoostAuthenticationKey", Convert.ToBase64String(_Key)); _Config.Save(); } else { _Key = Convert.FromBase64String(_Config.AppSettings.Settings["ComBoostAuthenticationKey"].Value); } CookieDomain = system.Authentication.Forms.Domain; CookieName = system.Authentication.Forms.Name ?? "comboostauth"; CookiePath = system.Authentication.Forms.Path; LoginUrl = system.Authentication.Forms.LoginUrl; Timeout = system.Authentication.Forms.Timeout; }
/*private PushBulletAPI.DeviceCollection GetDevices() { if (conf == null) conf = PushBulletAPI.GetSharedConfiguration("pushbullet"); if (!PushBulletAPI.HasConfigurationOption(conf, "apikey")) throw new Exception("No device cache available"); //var serializer = new System.Xml.Serialization.XmlSerializer(typeof(PushBulletAPI.DevicesResponse)); //return serializer.Deserialize(new System.IO.StringReader(PushBulletAPI.GetNonNullConfigurationOption(conf, "cachedDevices"))) as PushBulletAPI.DevicesResponse; }*/ private void TryExecute(string devId) { if (conf == null) conf = PushBulletAPI.GetSharedConfiguration("pushbullet"); if (!PushBulletAPI.HasConfigurationOption(conf, "mainPath")) throw new Exception("No executable path available"); try { Process.Start(PushBulletAPI.GetNonNullConfigurationOption(this.conf, "mainPath"), "/upload " + devId + " " + MergePaths(this.SelectedItemPaths)); } catch (Exception exa) { MessageBox.Show("An error occurred while opening the upload helper: " + exa.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private bool InitDevices() { if (devices != null) return true; try { if (conf == null) conf = PushBulletAPI.GetSharedConfiguration("pushbullet"); var data = PushBulletAPI.GetResponseSection(this.conf); if (data == null) throw new Exception("Empty ResponseSection"); this.devices = data; // avoid NPEs //if (this.devices.Devices.Count == null) this.devices.devices = new PushBulletAPI.DevicesResponse.Device[] { }; //if (this.devices.shared_devices == null) this.devices.shared_devices = new PushBulletAPI.DevicesResponse.SharedDevice[] { }; if (devices.SharedDevices.Count == 0) MessageBox.Show("Kaboom"); return true; } catch (Exception e) { err("Got an Exception while retrieving the devices: " + e.ToString()); return false; } }
private System.Configuration.Configuration GetConfiguration() { if (cachedConfiguration == null) { lock (cachedConfigurationLock) { if (cachedConfiguration == null) { cachedConfiguration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, System.Configuration.ConfigurationUserLevel.None); } } } return cachedConfiguration; }
public SettingController() { _configuration = ConfigManager.GetConfig(); _config = ConfigManager.GetSection(_configuration); }
/// <summary> /// 构造函数 /// </summary> /// <param name="Config"></param> public ConfigurationHelper(System.Configuration.Configuration Config) { this.Config = Config; }
public AppSettingsClass(ref System.Configuration.Configuration config) { _config = config; }
public override ProblemCollection Check(System.Configuration.Configuration configuration) { this.Configuration = configuration; return base.Problems; }
public override void Configure(Funq.Container container) { JsConfig.ExcludeTypeInfo = true; Logger.Info("Reading global configuration"); //register any dependencies your services use, e.g: //container.Register<ICacheClient>(new MemoryCacheClient()); WebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null); Logger.Info("Configure ServiceStack EndpointHostConfig"); base.SetConfig(new EndpointHostConfig { GlobalResponseHeaders = { { "Access-Control-Allow-Origin", "*" }, { "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" }, { "Cache-Control", "no-cache, no-store, must-revalidate" }, { "Pragma", "no-cache" }, { "Expires", "0" } }, EnableAccessRestrictions = true, DebugMode = true, //Enable StackTraces in development WebHostUrl = WebConfig.AppSettings.Settings["baseUrl"].Value, WriteErrorsToResponse = true, DefaultContentType = ServiceStack.Common.Web.ContentType.Json, MapExceptionToStatusCode = { { typeof(NotFoundException), 404 }, } }); Logger.Info("Load Plugins"); LoadPlugins(); Logger.Info("Configure Service Exception Handler"); this.ServiceExceptionHandler = (httpReq, request, ex) => { if (EndpointHost.Config != null && EndpointHost.Config.ReturnsInnerException && ex.InnerException != null && !(ex is IHttpError)) { ex = ex.InnerException; } ResponseStatus responseStatus = ex.ToResponseStatus(); if (EndpointHost.DebugMode) { responseStatus.StackTrace = DtoUtils.GetRequestErrorBody(request) + "\n" + ex; } return DtoUtils.CreateErrorResponse(request, ex, responseStatus); }; Logger.Info("Register ContentType Filters"); this.ContentTypeFilters.Register("application/opensearchdescription+xml", OpenSearchDescriptionService.OpenSearchDescriptionSerializer, OpenSearchDescriptionService.OpenSearchDescriptionDeserializer); this.PreRequestFilters.Insert(0, (httpReq, httpRes) => { httpReq.UseBufferedStream = true; }); }
public AppConfig(System.Configuration.Configuration configuration, ILogger logger) { _configuration = configuration; _logger = logger; Language = GetLanguageType(); }
/// <summary> /// protected constructor to block creating instance directly. /// </summary> /// <param name="importErrors"></param> /// <param name="targetCompileUnit"></param> /// <param name="targetConfiguration">May be null</param> /// <param name="bindingCollection"></param> /// <param name="contractCollection"></param> /// <param name="serviceEndpointList"></param> /// <param name="serviceEndpointToChannelEndpointElementMap"></param> /// <param name="proxyGeneratedContractTypes"></param> /// <param name="proxyGenerationErrors"></param> protected VSWCFServiceContractGenerator( List<ProxyGenerationError> importErrors, CodeCompileUnit targetCompileUnit, System.Configuration.Configuration targetConfiguration, IEnumerable<System.ServiceModel.Channels.Binding> bindingCollection, IEnumerable<ContractDescription> contractCollection, List<ServiceEndpoint> serviceEndpointList, Dictionary<ServiceEndpoint, ChannelEndpointElement> serviceEndpointToChannelEndpointElementMap, List<GeneratedContractType> proxyGeneratedContractTypes, IEnumerable<ProxyGenerationError> proxyGenerationErrors) { if (importErrors == null) throw new ArgumentNullException("importErrors"); if (targetCompileUnit == null) throw new ArgumentNullException("targetCompileUnit"); // Please note - target configuration may be NULL if (bindingCollection == null) throw new ArgumentNullException("bindingCollection"); if (contractCollection == null) throw new ArgumentNullException("contractCollection"); if (serviceEndpointList == null) throw new ArgumentNullException("serviceEndpointList"); if (serviceEndpointToChannelEndpointElementMap == null) throw new ArgumentNullException("serviceEndpointToChannelEndpointElementMap"); if (proxyGeneratedContractTypes == null) throw new ArgumentNullException("proxyGeneratedContractTypes"); if (proxyGenerationErrors == null) throw new ArgumentNullException("proxyGenerationErrors"); this.importErrors = importErrors; this.targetCompileUnit = targetCompileUnit; this.targetConfiguration = targetConfiguration; this.bindingCollection = bindingCollection; this.contractCollection = contractCollection; this.serviceEndpointList = serviceEndpointList; this.serviceEndpointToChannelEndpointElementMap = serviceEndpointToChannelEndpointElementMap; this.proxyGeneratedContractTypes = proxyGeneratedContractTypes; this.proxyGenerationErrors = proxyGenerationErrors; }
internal void UpdateCache() { System.Configuration.Configuration newConfiguration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, System.Configuration.ConfigurationUserLevel.None); lock (cachedConfigurationLock) { cachedConfiguration = newConfiguration; } }