GetValue() public method

public GetValue ( string key, Type type ) : object
key string
type System.Type
return object
コード例 #1
0
ファイル: Initializer.cs プロジェクト: virajs/monoscape
 public static void Initialize()
 {
     AppSettingsReader reader = new AppSettingsReader();
     Settings.MonoscapeAccessKey = (string)reader.GetValue("MonoscapeAccessKey", typeof(string));
     Settings.MonoscapeSecretKey = (string)reader.GetValue("MonoscapeSecretKey", typeof(string));
     Settings.LoadBalancerEndPointURL = (string)reader.GetValue("LoadBalancerEndPointURL", typeof(string));
 }
コード例 #2
0
        static ManagmentService()
        {
            ClientList = new List<IncomingClient>();

            AppSettingsReader _settingsReader = new AppSettingsReader();

            string value = _settingsReader.GetValue("ServerRunAtIP", type: typeof(string)) as string;

            if (!IPAddress.TryParse(value, out ServerIP))
                throw new Exception(message: "Appseting ServerRunAtIP Error");

            value = _settingsReader.GetValue("ServerRunAtPort", type: typeof(string)) as string;

            if (!int.TryParse(value, out ServerPort))
                throw new Exception(message: "Appseting ServerRunAtPort Error");

            value = _settingsReader.GetValue("MaxPoolClient", type: typeof(string)) as string;

            if (!int.TryParse(value, out MaxClient))
                throw new Exception(message: "Appseting MaxPoolClient Error");

            ServerEndPoint = new IPEndPoint(ServerIP, ServerPort);

            ServerLisenerSocket = new Socket(addressFamily: AddressFamily.InterNetwork, socketType: SocketType.Stream, protocolType: ProtocolType.Tcp);

            ServerLisenerSocket.Bind(ServerEndPoint);
        }
コード例 #3
0
ファイル: Configuration.cs プロジェクト: adambird/eaep
        static Configuration()
        {
            AppSettingsReader reader = new AppSettingsReader();

            try
            {
                MonitorURI = (string)reader.GetValue("EAEPMonitorURI", typeof(string));
            }
            catch
            {
                MonitorURI = null;
            }

            try
            {
                DefaultPollInterval = (int)reader.GetValue("DefaultPollInterval", typeof(int));
            }
            catch
            {
                DefaultPollInterval = 30;
            }

            try
            {
                DefaultEAEPClientTimeout = (int)reader.GetValue("DefaultEAEPClientTimeout", typeof(int)) * 1000;
            }
            catch
            {
                DefaultEAEPClientTimeout = 30000;
            }
        }
コード例 #4
0
ファイル: LoginPage.cs プロジェクト: AndriiChorniak/Task-C-
 public LoginPage(IWebDriver driver)
 {
     this.driver = driver;
     AppSettingsReader appSettingsReader = new AppSettingsReader();
     loginCred = (string)appSettingsReader.GetValue("login", typeof(string));
     passwordCred = (string)appSettingsReader.GetValue("password", typeof(string));
 }
コード例 #5
0
        public bool UpLoadFile(string voucherID, byte[] fileData, string fileType, string DocType, string PropertyName, out string filePathServer)
        {
            Console.WriteLine("DocService-UpLoadFile():" + fileData.Length.ToString() + "-" + DateTime.Now.ToString());
            string _FilePathQC = (string)(configurationAppSettings.GetValue("FilePathQC", typeof(string)));

            Console.WriteLine("configurationAppSettings.GetValue:" + _FilePathQC);
            filePathServer = "";
            try
            {
                filePathServer = string.Format("{0}-{1}.{2}", voucherID, DateTime.Now.ToString("yyMMddHHmmss"), fileType.ToLower());
                string filepath = string.Format("{0}{1}", _FilePathQC, filePathServer);
                Console.WriteLine("filepath:" + filepath);

                MemoryStream meoeryStream = new MemoryStream(fileData);
                FileStream   fileStream   = new FileStream(filepath, FileMode.Create);
                meoeryStream.WriteTo(fileStream);
                fileStream.Close();
                meoeryStream.Close();

                gate.DbHelper.ExecuteStoredProcedureNonQuery("QE31_UpLoadFilePath", new string[] { "filePath", "VoucherID", "DocType", "PropertyName" }
                                                             , new object[] { filePathServer, voucherID, DocType, PropertyName });

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
コード例 #6
0
        private void ValidateWithBriteVerify()
        {
            try
            {
                AppSettingsReader appsreader = new AppSettingsReader();
                string url = (string)appsreader.GetValue("briteverify_url", typeof(string)) + (string)appsreader.GetValue("briteverify_parameters", typeof(string));
                string apiKey = (string)appsreader.GetValue("briteverify_apikey", typeof(string));
                url = String.Format(url, eStatus.Email, apiKey);
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";

                request.Timeout = 10000;
                string output = string.Empty;
                using (var response = request.GetResponse())
                {
                    using (var stream = new StreamReader(response.GetResponseStream()))
                    {
                        string emailResponse = stream.ReadToEnd();
                        briteVerifyResult = JsonConvert.DeserializeObject<BriteVerifyResult>(emailResponse);
                        if (briteVerifyResult.status.Equals("valid"))
                        {
                            eStatus.Status = "Valid";
                        }
                    }
                }
            }
            catch(Exception e)
            {
                throw e;
            }
        }
コード例 #7
0
ファイル: Configuration.cs プロジェクト: adambird/eaep
        static Configuration()
        {
            AppSettingsReader reader = new AppSettingsReader();
            try
            {
                ApplicationName = (string)reader.GetValue("ApplicationName", typeof(string));
            }
            catch (Exception)
            {
                ApplicationName = Assembly.GetExecutingAssembly().FullName;
            }

            try
            {
                EAEPMonitorURI = (string)reader.GetValue("EAEPMonitorURI", typeof(string));
            }
            catch (Exception)
            {
                EAEPMonitorURI = null;
            }

            try
            {
                EAEPHttpClientTimeout = (int)reader.GetValue("EAEPHttpClientTimeout", typeof(int));
            }
            catch (Exception)
            {
                EAEPHttpClientTimeout = 100;
            }
        }
コード例 #8
0
        public static Boolean sendAlert()
        {
            System.Configuration.AppSettingsReader reader = new AppSettingsReader();
            string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string postData = File.ReadAllText(Path.Combine(path,reader.GetValue("alertfile", typeof(string)).ToString()));

            var uri = reader.GetValue("url", typeof(string)).ToString();

            var request = (HttpWebRequest)WebRequest.Create(uri);
            request.Credentials = new NetworkCredential(reader.GetValue("user", typeof(string)).ToString(), reader.GetValue("password", typeof(string)).ToString());

            request.Method = WebRequestMethods.Http.Post;
            request.ContentType = "application/xml";

            request.ContentLength = postData.Length;
            try
            {

                StreamWriter postStream = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
                postStream.Write(postData);
                postStream.Close();

                var response = (HttpWebResponse)request.GetResponse();

            }
            catch (Exception ex)
            {
                //use some logger to log this
                return false;
            }
            return true;
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: CharlesGeng/study-c
        public Form1()
        {
            InitializeComponent();

            AppSettingsReader appReader = new AppSettingsReader();
            _url = appReader.GetValue("URL", typeof(string)).ToString();
            _savePath = appReader.GetValue("SavePath", typeof(string)).ToString();
        }
コード例 #10
0
        private LogActivator getActivator(String assembly, String classname)
        {
            LogActivator activator = new LogActivator ();
            AppSettingsReader reader = new AppSettingsReader ();

            activator.Assembly = (String)reader.GetValue (assembly, typeof(String));
            activator.Classname = (String)reader.GetValue (classname, typeof(String));

            return activator;
        }
コード例 #11
0
ファイル: Helper.cs プロジェクト: yonglehou/SparkIODotNet
        public static CoreAPI GetCoreAPI()
        {
            CoreAPI core;

                AppSettingsReader reader = new AppSettingsReader();

                core = new CoreAPI(reader.GetValue("AccessToken", typeof(string)).ToString(),
                    reader.GetValue("CoreID", typeof(string)).ToString());

                return core;
        }
コード例 #12
0
        public ActionResult Index(string login, string senha)
        {
            try
            {
                string AD = "";
                AppSettingsReader reader = new AppSettingsReader();
                AD = (string)reader.GetValue("ACTIVE_DIRECTORY", typeof(string));
                var isValido = autenticacao.ValidarLogin(login, senha, AD);

                if (isValido)
                {
                    FormsAuthentication.SetAuthCookie(login, false);
                    Session["Usuario"] = login;
                    string dominio = (string)reader.GetValue("DOMINIO_ALIAS", typeof(string));
                    string bancoFrequencia = (string)reader.GetValue("BANCO_FREQUENCIA", typeof(string));

                    var pesquisa = autenticacao.isPesquisaValida(login, bancoFrequencia);

                    if (pesquisa)
                    {
                        ViewBag.Mensagem = "Usuário já preencheu o questionário";
                    }

                    var funcionarioDado = autenticacao.ObterDadosFuncionario(login, dominio, AD);//tipo funcionario qd dá ponto pega qq coisa dele

                    //Funcionario func = new Funcionario();
                    //var f = funcionario.ObterPesquisa(func);//qd é do tipo pega qq coisa dele

                    //foreach (var item in f)
                    //{
                    //    if (item.Funcao)
                    //    {

                    //    }

                    //}

                    if (funcionarioDado != null && funcionarioDado.Funcao.ToUpper().Contains("OPERADOR"))
                    {
                        return RedirectToAction("Cadastrar","Operador");
                    }
                    else
                    {
                        return RedirectToAction("Cadastrar","Supervisor");
                    }
                }
            }
            catch (Exception ex)
            {

                ViewBag.Mensagem = ex.Message;//pode ser uma msg no viewbag
            }
            return View();
        }
コード例 #13
0
 static void Main(string[] args)
 {
     Console.WriteLine("***** Reading <appSettings> Data *****\n");
     AppSettingsReader ar = new AppSettingsReader();
     int numbOfTimes = (int) ar.GetValue("RepeatCount", typeof (int));
     string textColor = (string) ar.GetValue("TextColor", typeof (string));
     Console.ForegroundColor = (ConsoleColor) Enum.Parse(typeof (ConsoleColor), textColor);
     for (int i = 0; i < numbOfTimes; i++)
     {
         Console.WriteLine("Howdy!");
     }
     Console.ReadLine();
 }
コード例 #14
0
        private void frmConfiguracaoBancoDeDados_Load(object sender, EventArgs e)
        {
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            string server = (string)settingsReader.GetValue("Servidor", typeof(String));
            string basedados = (string)settingsReader.GetValue("Base", typeof(String));
            string users = (string)settingsReader.GetValue("User", typeof(String));
            string passwd = Ferramentas.CryptoEngine.Decrypt((string)settingsReader.GetValue("Password", typeof(String)), true);
            txtServidor.Text = server;
            txtBancoDados.Text = basedados;
            txtUsuario.Text = users;
            txtSenha.Text = passwd;


        }
コード例 #15
0
ファイル: FrmCreateDataBase.cs プロジェクト: TMA-AQ/AlgoQuest
 private void btnAccept_Click(object sender, EventArgs e)
 {
     if (dataBaseList.Where(v => v.Name == txtDataBaseName.Text).Count() == 0)
     {
         AppSettingsReader _appReader = new AppSettingsReader();
         String dbPath = _appReader.GetValue("DataBasePath", typeof(System.String)).ToString();
         String cfgPath = _appReader.GetValue("ConfigPath", typeof(System.String)).ToString();
         DataBase.CreateDataBase(txtDataBaseName.Text, dbPath, cfgPath);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
     else
         MessageBox.Show((String.Format("La base {0} existe déjà.", txtDataBaseName.Text)), "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
 }
コード例 #16
0
 public AdAuthenticator()
 {
     var appSettings = new AppSettingsReader();
     try
     {
         LdapPath = appSettings.GetValue("LdapPath", typeof(string)).ToString();
     }
     catch { }
     try
     {
         LdapDomain = appSettings.GetValue("LdapDomain", typeof(string)).ToString();
     }
     catch { }
 }
コード例 #17
0
ファイル: SqlServerDB.cs プロジェクト: hanwest00/MYTestWeb
        protected SqlServerDB()
        {
            AppSettingsReader settingReader = new AppSettingsReader();
            dbMasterConnectString = settingReader.GetValue("MYORMConnectionString", typeof(string)) as string;
            dbExe = SqlDBEXE.GetInstance(dbMasterConnectString);
            DatabaseName = settingReader.GetValue("DatabaseName", typeof(string)) as string;

            DbFileDir = settingReader.GetValue("DatabaseDir", typeof(string)) as string;
            if (!DbFileDir.EndsWith("\\"))
                DbFileDir += "\\";
            if (!DBContians())
                this.CreateDatebase();
            dbExe.ConnectString = dbMasterConnectString.Replace("master", DatabaseName);
        }
コード例 #18
0
ファイル: Program.cs プロジェクト: ZLLselfRedeem/zllinmitu
        static void Main(string[] args)
        {
            AppSettingsReader ar = new AppSettingsReader();
            int numbOfTimes = (int)ar.GetValue("RepeatCount", typeof(int));
            string textColor = (string)ar.GetValue("TextColor", typeof(string));
            Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), textColor);

            ConsoleColor cs = Console.BackgroundColor;
            Console.BackgroundColor = ConsoleColor.Blue;
            for(int i = 0; i < numbOfTimes; i++)
                Console.WriteLine("Howdy!");

            Console.BackgroundColor = cs;
            Console.ReadLine();
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: 50minutos/VS2010
        static void Main(string[] args)
        {
            AppSettingsReader leitor = new AppSettingsReader();

            Console.WriteLine("nome: {0}", leitor.GetValue("nome", typeof(String)));
            Console.WriteLine("e-mail: {0}", leitor.GetValue("email", typeof(String)));

            System.Console.WriteLine(Properties.Settings.Default.varAplicacao);
            Properties.Settings.Default.varUsuario = "outro valor";
            System.Console.WriteLine(Properties.Settings.Default.varUsuario);

            Console.WriteLine();

            Console.ReadKey();
        }
コード例 #20
0
 public PersistenceMgr()
 {
     AppSettingsReader config = new AppSettingsReader();
     String connector = (String)config.GetValue("Connector", typeof(String));
     con = new OdbcConnection(connector);
     con.Open();
 }
コード例 #21
0
ファイル: EntryAl.cs プロジェクト: nezorepla/eksi_bahis
    public void PopulerBasliklariAl()
    {
        System.Configuration.AppSettingsReader asr = new System.Configuration.AppSettingsReader();
        string ConnStr = (string)asr.GetValue("eb", typeof(string));

        baglanti = new SqlConnection(ConnStr);


        WebClient wc = new WebClient();

        wc.Encoding = Encoding.UTF8;
        long tick = DateTime.Now.Ticks;

        string source = wc.DownloadString("https://eksisozluk.com/basliklar/populer?_=" + tick.ToString());


        string pattern = @"href=\""(.*?)a=popular\""";
        //   Match link = Regex.Match(parca, linkRx, RegexOptions.Singleline);
        Regex rgx = new Regex(pattern);

        foreach (Match match in rgx.Matches(source))
        {
            string rp   = "?day=" + DateTime.Now.ToString("yyyy-MM-dd") + "&a=nice";
            string link = match.Value.Replace("href=\"", "").Replace("\"", "").Replace("?a=popular", rp).ToString();
            // string link = "/24-mayis-2015-galatasaray-besiktas-maci--4470751?day=2015-05-24&a=nice";
            PopulerBasliktakiEntryleriAl(link);
        }
    }
コード例 #22
0
ファイル: Global.cs プロジェクト: saumyabrata/FinSoft2017
        public static string Encrypt_String(string plaintext)
        {
            string outstr = null;

            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(plaintext);
            System.Configuration.AppSettingsReader settingsReader = new System.Configuration.AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            //keyArray = UTF8Encoding.UTF8.GetBytes(key);

            MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();

            keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            hashmd5.Clear();

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

            tdes.Key     = keyArray;
            tdes.Mode    = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateEncryptor();

            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();

            outstr = Convert.ToBase64String(resultArray, 0, resultArray.Length);

            return(outstr);
        }
コード例 #23
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Jqgrid2_DataRequesting(object sender, Trirand.Web.UI.WebControls.JQGridDataRequestEventArgs e)
 {
     string ssd = (string)Session["sd_EnvExceptionDailyRpt "];
     string sed = (string)Session["ed_EnvExceptionDailyRpt "];
     if ((ssd == null) || (sed == null))
     {
         ssd = sd.Text;
         sed = ed.Text;
     }
     if ((ssd != null) && (sed != null)&&(ssd != "") && (sed != ""))
     {
         DataSet ds = new DataSet();
         try
         {
             AppSettingsReader asr = new AppSettingsReader();
             string dbconn = (string)asr.GetValue("dbconn", typeof(string));
             using (SqlConnection conn = new SqlConnection(dbconn))
             {
                 conn.Open();
                 SqlCommand sqlcomm = new SqlCommand("select * from V_EnvException_DayReport where timestamps<='" + sed + "' and timestamps>='" + ssd + "' order by timestamps desc", conn);
                 SqlDataAdapter sqladapter = new SqlDataAdapter(sqlcomm);
                 sqladapter.Fill(ds);
                 conn.Close();
             }
         }
         catch (Exception)
         {
         }
         Jqgrid2.DataSource = ds.Tables[0];
         Jqgrid2.DataBind();
     }
 }
コード例 #24
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var    MyReader = new System.Configuration.AppSettingsReader();
            string keyvalue = MyReader.GetValue("showopt", typeof(string)).ToString();

            if (keyvalue == "0")
            {
                dolasciToolStripMenuItem.Visible         = false;
                godišnjiToolStripMenuItem.Visible        = false;
                rasporedToolStripMenuItem.Visible        = false;
                prijavaToolStripMenuItem.Visible         = false;
                prijavaZaVikendToolStripMenuItem.Visible = false;
            }


            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState     = FormWindowState.Maximized;
            //this.ActiveControl = textBox1;
            label1.Text = LoginForm.lbltxt.Trim();     // text u naslovu
            pprezimer   = LoginForm.prezimer.Trim();   // prezime
            idradnika1  = LoginForm.idradnika.Trim();  // grupa
            idradnika0  = LoginForm.idradnika0.Trim(); // id radnika iz radnici_
            idfirme     = LoginForm.idfirme.Trim();    // id firme

            SqlConnection cn1 = new SqlConnection(connectionString);

            cn1.Open();
            SqlCommand    sqlCommand1 = new SqlCommand("select count(*) brojporuka from poruke  where rtrim(userid)='" + idradnika1 + "' and status is null", cn1);
            SqlDataReader reader21    = sqlCommand1.ExecuteReader();

            reader21.Read();
            int bp = (int.Parse)(reader21["brojporuka"].ToString());

            novostiToolStripMenuItem.Text = "Novosti (" + bp.ToString() + ")";
        }
コード例 #25
0
ファイル: db.cs プロジェクト: nezorepla/eksi_bahis
    private static string GetConnStr(String pConnKey)
    {
        System.Configuration.AppSettingsReader asr = new System.Configuration.AppSettingsReader();
        string ConnStr = (string)asr.GetValue(pConnKey, typeof(string));

        return(ConnStr);
    }
コード例 #26
0
        /// <summary>
        /// When implemented in a derived class, executes when a Start command is sent to the service by the Service Control Manager (SCM) or when the operating system starts (for a service that starts automatically). Specifies actions to take when the service starts.
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            System.Configuration.AppSettingsReader appReader = new System.Configuration.AppSettingsReader();
            this.timer1 = new System.Timers.Timer(Convert.ToDouble(appReader.GetValue("Interval", typeof(string))));

            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = System.AppDomain.CurrentDomain.BaseDirectory;
            /* Watch for changes in LastAccess and LastWrite times, and
               the renaming of files or directories. */
            watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
               | NotifyFilters.FileName | NotifyFilters.DirectoryName;

            // Only watch text files.
            watcher.Filter = "*.config";

            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(OnChanged);

            // Begin watching.
            watcher.EnableRaisingEvents = true;
            this.mutex = new Mutex(false);
            this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.Timer1_Elapsed);
            this.timer1.Start();

            string ipToAdd = appReader.GetValue("Host", typeof(string)).ToString();
            EventLog.WriteEntry("Firewall Updater monitoring host '" + ipToAdd + "'");
        }
コード例 #27
0
ファイル: LogToFile.cs プロジェクト: kartoshka7777/BFU
        public LogToFile(LoggerMode mode)
        {
            modOfException = mode;
            readAppConfig = new AppSettingsReader ();

            path = (string)readAppConfig.GetValue ("Path", typeof (string));
        }
コード例 #28
0
        public static string maHoa(string strMaHoa)
        {
            byte[] arrKey;
            byte[] arrMahoa = UTF8Encoding.UTF8.GetBytes(strMaHoa);

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            //Lấy giá trị key từ file Web.config
            string keyConfig = (string)settingsReader.GetValue("keyMD5", typeof(String));

            MD5CryptoServiceProvider serviceMD5 = new MD5CryptoServiceProvider();
            arrKey = serviceMD5.ComputeHash(UTF8Encoding.UTF8.GetBytes(keyConfig));
            serviceMD5.Clear();//Giải phóng tài nguyên
            TripleDESCryptoServiceProvider tdsp = new TripleDESCryptoServiceProvider();

            //Thiết lập 1 key cho thuật toán mã hóa
            tdsp.Key = arrKey;

            //Chọn phương thức mã hóa. Ở đây chúng ta chọn ECB(Electronic code Book ) [1]
            tdsp.Mode = CipherMode.ECB;

            //Thêm phương thức mã hóa IS010126 (random chuỗi kết quả)  [2]
            tdsp.Padding = PaddingMode.ISO10126;

            ICryptoTransform cTransform = tdsp.CreateEncryptor();
            byte[] arrKQ = cTransform.TransformFinalBlock(arrMahoa, 0, arrMahoa.Length);
            tdsp.Clear(); //Giải phóng tài nguyên của TripleDES Encryptor

            //Kết quả mã hóa được trả về 1 giá trị kiểu String
            return Convert.ToBase64String(arrKQ, 0, arrKQ.Length);
        }
コード例 #29
0
        protected void TextBox_mask_TextChanged(object sender, EventArgs e)
        {
            //do search...
            //string s1 = @"c:\users\cc\documents";


            Cerval_Configuration c1 = new Cerval_Configuration("StaffIntranet_StaffDocuments");
            string s1 = c1.Value;

            if (!c1.valid)//try revert to config file
            {
                System.Configuration.AppSettingsReader ar = new System.Configuration.AppSettingsReader();
                s1 = ar.GetValue("StaffDocuments", typeof(string)).ToString();
            }


            Table1.Rows.Clear();
            TableRow  r = new TableRow();
            TableCell c = new TableCell();

            c.Controls.Add(new LiteralControl("FileName"));
            r.Cells.Add(c);
            Table1.Rows.Add(r);
            c = new TableCell();
            c.Controls.Add(new LiteralControl("In Folder"));
            r.Cells.Add(c);
            SearchDirectory(s1, TextBox_mask.Text + "*");
        }
コード例 #30
0
ファイル: Configuration.cs プロジェクト: adambird/eaep
 static Configuration()
 {
     AppSettingsReader reader = new AppSettingsReader();
     try
     {
         MulticastSettings = new eaep.multicast.MulticastSettings(
             (string)reader.GetValue("MulticastGroupAddress", typeof(string)),
             (int)reader.GetValue("MulticastPortNumber", typeof(int)),
             (int)reader.GetValue("MulticastTTL", typeof(int))
             );
     }
     catch (Exception)
     {
         // if any errors reading the config file then leave settings as they are.
     }
 }
コード例 #31
0
ファイル: FrmIniProperties.cs プロジェクト: TMA-AQ/AlgoQuest
 public FrmIniProperties(string database)
 {
     InitializeComponent();
     tlpProperties.SuspendLayout();
     AppSettingsReader _appReader = new AppSettingsReader();
     String dbPath = _appReader.GetValue("DataBasePath", typeof(System.String)).ToString();
     _ip = new IniProperties(dbPath, database);
     _keys=_ip.Keys;
     int i = 0;
     foreach (DictionaryEntry de in _keys)
     {
         i = addTableRow();
         Label lbl = new Label();
         lbl.Name = "lbl" + i.ToString();
         lbl.Text = (string)de.Key;
         lbl.Dock = DockStyle.Fill;
         TextBox tb = new TextBox();
         tb.Name = "tb" + i.ToString();
         tb.Text = (string)de.Value;
         tb.Dock = DockStyle.Fill;
         tlpProperties.Controls.Add(lbl, 0, i);
         tlpProperties.Controls.Add(tb, 1, i);
     }
     i = addTableRow();
     btnCancel.Dock = DockStyle.Right;
     tlpProperties.Controls.Add(btnCancel, 0, i);
     tlpProperties.Controls.Add(btnSave, 1, i);
     tlpProperties.ResumeLayout();
 }
コード例 #32
0
 /// <summary>
 /// Devuelve una instancia del servicio web.
 /// Inicializa la conexión SQL con la cadena de conexión guardada en el fichero Web.config
 /// </summary>
 public Service1()
 {
     this.Log = LogManager.GetLogger("SOREWebServiceLog");
     AppSettingsReader appSettingsReader = new AppSettingsReader();
     this.connection = new SqlConnection();
     this.connection.ConnectionString = (string)appSettingsReader.GetValue("SqlConnection.ConnectionString", typeof(string));
 }
コード例 #33
0
        /// <summary>
        /// Processes the m59 message. If all goes OK, returns an ACK_PROCESSED with the current time
        /// </summary>
        /// <returns></returns>
        public StringCollection Process()
        {
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }

            string          sResponse         = "<t>" + OPS.Comm.Dtx.DtxToString(DateTime.Now.AddHours(nDifHour)) + "</t>";
            CmpParametersDB cmpParam          = new CmpParametersDB();
            string          strHourDifference = cmpParam.GetParameter("P_HOUR_DIFF");

            if (strHourDifference != "")
            {
                sResponse = sResponse + "<hd>" + strHourDifference + "</hd>";
            }

            AckMessage       ret = new AckMessage(_msgId, sResponse);
            StringCollection sc  = new StringCollection();

            sc.Add(ret.ToString());
            return(sc);
        }
コード例 #34
0
        /// <summary>
        /// Decrypts a cipher sting
        /// </summary>
        /// <param name="cipherString">String to decrypt</param>
        /// <returns>Decrypted string</returns>
        public string DecryptString(string cipherString)
        {
            try
            {
                byte[] keyArray;
                byte[] toEncryptArray = Convert.FromBase64String(cipherString);

                System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

                tdes.Clear();
                return UTF8Encoding.UTF8.GetString(resultArray);
            }
            catch (Exception e)
            {
                Console.WriteLine("DecryptString exception : " + e.ToString());
                return null;
            }
        }
コード例 #35
0
        public Pantalla_Cancelacion_Profesional(decimal idU)
        {
            InitializeComponent();

            idUser = idU;

            dateTimePicker1.Format       = DateTimePickerFormat.Custom;
            dateTimePicker1.CustomFormat = "dd/MM/yyyy";

            dateTimePicker2.Format       = DateTimePickerFormat.Custom;
            dateTimePicker2.CustomFormat = "dd/MM/yyyy";

            var MyReader = new System.Configuration.AppSettingsReader();

            fechaHoy = MyReader.GetValue("Datekey", typeof(string)).ToString();

            dateTimePicker1.MinDate = Convert.ToDateTime(fechaHoy);
            dateTimePicker2.MinDate = Convert.ToDateTime(fechaHoy);

            comboBox2.Items.Add("00");
            comboBox2.Items.Add(30);

            comboBox4.Items.Add("00");
            comboBox4.Items.Add(30);
        }
コード例 #36
0
        private void btRestore_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog d = new OpenFileDialog();
                d.Filter = "Backup Files|*.bak";
                d.ShowDialog();
                if (d.FileName != "")
                {
                    System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                    string basedados = (string)settingsReader.GetValue("Base", typeof(String));

                    String nomeBanco = basedados;
                    String localBackup = d.FileName;

                    String conexao = DadosDaConexao.srtConnMaster;
                
                    this.Cursor = Cursors.WaitCursor;
                    SQLServerBackup.RestauraDatabase(conexao, nomeBanco, d.FileName);
                    Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                    MessageBox.Show("Backup restaurado com sucesso!!!!", "Aviso", MessageBoxButtons.OK,MessageBoxIcon.Information);
               
                    this.Cursor = Cursors.Default;

                }
            }
            catch (Exception erro)
            {
                this.Cursor = Cursors.Default;
                Ferramentas.MessageBoxHelper.PrepToCenterMessageBoxOnForm(this);
                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #37
0
        public static string Decrypt(string cipherString, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = Convert.FromBase64String(cipherString);
            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            string key = (string)settingsReader.GetValue("SecurityKey",typeof(String));

            if (useHashing)
            {

                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
            {

                keyArray = UTF8Encoding.UTF8.GetBytes(key);
            }

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            tdes.Clear();

            return UTF8Encoding.UTF8.GetString(resultArray);
        }
コード例 #38
0
        /// <summary>
        /// Annotates a new retry to all pending messages
        /// </summary>
        private void UpdateMessageRetries()
        {
            lock (_msgStatus)
            {
                AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                double            nDifHour    = 0;
                try
                {
                    nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
                }
                catch
                {
                    nDifHour = 0;
                }

                DateTime    now = DateTime.Now.AddHours(nDifHour);
                IEnumerator en  = _msgStatus.Values.GetEnumerator();
                while (en.MoveNext())
                {
                    MessageData msg = (MessageData)en.Current;
                    if (msg.Status == MessageStatus.Sending)
                    {
                        msg.PendingRetries--;
                        FireRetryHandlers(msg);
                        //FailMessageIfExpired(msg, now);
                    }
                }
            }
        }
コード例 #39
0
        /// <summary>
        /// Encrypt a string using dual encryption method. Return a encrypted cipher Text
        /// </summary>
        /// <param name="toEncrypt">string to be encrypted</param>
        /// <param name="useHashing">use hashing? send to for extra secirity</param>
        /// <returns></returns>
        public static string Encrypt(string toEncrypt, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
            //System.Windows.Forms.MessageBox.Show(key);
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashmd5.Clear();
            }
            else
                keyArray = UTF8Encoding.UTF8.GetBytes(key);

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
            tdes.Key = keyArray;
            tdes.Mode = CipherMode.ECB;
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
コード例 #40
0
    public void al()
    {
        System.Configuration.AppSettingsReader asr = new System.Configuration.AppSettingsReader();
        string ConnStr = (string)asr.GetValue("eb", typeof(string));

        baglanti = new SqlConnection(ConnStr);

        WebClient wc = new WebClient();

        //wc.Headers.Add("Content-Type: text/html; charset=windows-1254");
        //wc.Headers.Add("Content-Type: text/html; charset=iso-8859-9;");

        //wc.Headers.Add("Content-Type: application/x-www-form-urlencoded");
        //wc.Headers.Add("User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5");
        //wc.Headers.Add("Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        //wc.Headers.Add("Accept-Encoding: identity");
        //wc.Headers.Add("Accept-Language: tr-TR");
        //wc.Headers.Add("Accept-Language: tr-TR,tr;q=0.8");
        wc.Encoding = Encoding.UTF8;
        long tick = DateTime.Now.Ticks;

        string source = wc.DownloadString("https://eksisozluk.com/istatistik/dunun-en-begenilen-entryleri?_=" + tick.ToString());

        //StreamWriter writer = new StreamWriter("c:\\DTS_PACKAGES\\sozluktest.txt");
        //writer.WriteLine(source);
        // writer.Close();

        source = source.vericek("topic-list\"", "</ol>");
        source = source.Replace("<li>", "|").ToString();
        string[] ayir = source.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

        int i = 1;

        foreach (string parca in ayir)
        {
            string linkRx  = @"href=\""(.*?)\""";
            string titleRx = @"(<span.*?>.*?</span>)"; // @"<span class=""caption"">";
            string autRx   = @"(<div.*?>.*?</div>)";
            Match  link    = Regex.Match(parca, linkRx, RegexOptions.Singleline);
            Match  title   = Regex.Match(parca, titleRx, RegexOptions.Singleline);
            Match  autor   = Regex.Match(parca, autRx, RegexOptions.Singleline);
            if (link.Success)
            {
                insert(
                    i.ToString(), link.Value.Replace("href=\"", "").Replace("\"", "").ToString(),
                    title.Value.Replace("<span class=\"caption\">", "").Replace("</span>", "").ToString(),
                    autor.Value.Replace("<div class=\"detail\">", "").Replace("</div>", "").ToString());


                //writer.WriteLine(i.ToString());
                //writer.WriteLine(link.Value.Replace("href=\"", "").Replace("\"", "").ToString());
                //writer.WriteLine(title.Value.Replace("<span class=\"caption\">", "").Replace("</span>", "").ToString());
                //writer.WriteLine(autor.Value.Replace("<div class=\"detail\">", "").Replace("</div>", "").ToString());
                //writer.WriteLine("");
                i++;
            }
        }
        //writer.Close();
    }
コード例 #41
0
ファイル: EntryAl.cs プロジェクト: nezorepla/eksi_bahis
    public EntryAl()
    {
        System.Configuration.AppSettingsReader asr = new System.Configuration.AppSettingsReader();
        string ConnStr = (string)asr.GetValue("eb", typeof(string));

        baglanti = new SqlConnection(ConnStr);
        //   baglanti = new SqlConnection("Data Source=.; Initial Catalog=eksi_bahis; Integrated Security=true");
    }
コード例 #42
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
     //
     // MultiXTpm
     //
     this.ServiceName = ((string)(configurationAppSettings.GetValue("MultiXTpmServiceInstaller.ServiceName", typeof(string))));
 }
コード例 #43
0
        private string GetStartingDirectory()
        {
            var startingDirectory = string.Empty;
            var appSettingsReader = new System.Configuration.AppSettingsReader();

            startingDirectory = (string)appSettingsReader.GetValue("startingFolder", typeof(string));
            _loggingController.Log(MessageType.information, " Initial directory loaded from config");
            return(startingDirectory);
        }
コード例 #44
0
        public ExternSystem()
        {
            m_Connection = new MySqlConnection();
            m_Adapter    = new MySqlDataAdapter();

            System.Configuration.AppSettingsReader confAppSettings = new System.Configuration.AppSettingsReader();

            m_ConnectionStr = (string)confAppSettings.GetValue("Processsoft.ConnectionString", typeof(string));
            m_Connection.ConnectionString = m_ConnectionStr;
        }
コード例 #45
0
        public static int GetAppSettingsID(string strKey)
        {
            AppSettingsReader asr        = new System.Configuration.AppSettingsReader();
            string            strTempVal = "";
            int intRetVal = 0;

            strTempVal = (string)asr.GetValue(strKey, typeof(string));

            int.TryParse(strTempVal, out intRetVal);
            return(intRetVal);
        }
コード例 #46
0
ファイル: Conf.cs プロジェクト: Hemanth1993/C-IN
 /// <summary>
 /// Gets a value in the configuratin file.
 /// </summary>
 /// <param name="key">Configuration to get.</param>
 /// <returns>The value of the configuration.</returns>
 protected static String GetSetting(String key)
 {
     System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
     try
     {
         return(((string)(configurationAppSettings.GetValue(key, typeof(string)))));
     }
     catch (InvalidOperationException)
     {
         return(null);
     }
 }
コード例 #47
0
        protected void SetupCombo()
        {
            DropDownList_Sets.Items.Clear();
            //get sets for this user..
            Utility u = new Utility();
            //string struser = Context.User.Identity.Name;
            //string staff_code = "";
            //Guid personID = u.GetPersonID(struser, out staff_code);
            Guid   personID   = u.GetPersonIdfromRequest(Request);
            string staff_code = u.GetsStaffCodefromRequest(Request);

#if DEBUG
            staff_code = "CC";
#endif

            Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Exam_Results_Years");
            string s = c.Value;
            if (!c.valid)//revert to config file
            {
                System.Configuration.AppSettingsReader ar = new System.Configuration.AppSettingsReader();
                s = ar.GetValue("Exam_Results_Years", typeof(string)).ToString();
            }
            //s contains the years we want to process as comma sep list
            string[] s1 = new string[1]; s1[0] = ",";
            string[] s2 = new string[10];
            s2 = s.Split(s1, StringSplitOptions.None);

            //staff_code = "JA";
            GroupList gl1 = new GroupList();
            gl1.LoadStaff(staff_code, DateTime.Now, GroupList.GroupListOrder.GroupName);
            foreach (Group g in gl1._groups)
            {
                foreach (string s3 in s2)
                {
                    if (g._GroupCode.StartsWith(s3))
                    {
                        ListItem i = new ListItem(g._GroupCode, g._GroupID.ToString());
                        DropDownList_Sets.Items.Add(i);
                    }
                }
                //if (g._GroupCode.StartsWith("12"))
                //if (g._GroupCode.StartsWith("10") || g._GroupCode.StartsWith("7") || g._GroupCode.StartsWith("8") || g._GroupCode.StartsWith("9"))
                //if (g._GroupCode.StartsWith("11"))
                //{
                //  ListItem i = new ListItem(g._GroupCode, g._GroupID.ToString());
                // DropDownList_Sets.Items.Add(i);
                //}
            }
            if (DropDownList_Sets.Items.Count > 0)
            {
                DropDownList_Sets.SelectedIndex = 0;
            }
        }
コード例 #48
0
        /// <summary>
        /// Adds a row to a message dataset using a row from the configuration
        /// dataset and the specific information for the new message
        /// </summary>
        /// <param name="cfgRow">A row from the message configuration dataset</param>
        /// <param name="msgId">The message identifier</param>
        /// <param name="msgBody">The text of the message</param>
        /// <param name="msgsDs">The dataset where the new row has to be added</param>
        private static void AddMessageRow(DataRow cfgRow, decimal msgId, string msgBody,
                                          decimal relatedId, DataSet msgsDs)
        {
            /// TODO: Obtain these values
            decimal           version     = decimal.One;
            decimal           valid       = decimal.One;
            decimal           deleted     = decimal.Zero;
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }

            MessageAccess msg = new MessageAccess(msgBody);

            msg.UpdateMessageHeader(msgId.ToString(),
                                    cfgRow[MessageConfiguration.DestUnitId].ToString(),
                                    cfgRow[MessageConfiguration.Priority].ToString());
            string xml = msg.ToString();

            msgsDs.Tables[0].Rows.Add(new object[] {
                msgId,
                cfgRow[MessageConfiguration.MsgId],
                cfgRow[MessageConfiguration.MediaId], DateTime.Now.AddHours(nDifHour),
                cfgRow[MessageConfiguration.Priority],
                cfgRow[MessageConfiguration.Mandatory],
                (relatedId != 0) ? (object)relatedId : (object)DBNull.Value,
                (relatedId != 0) ? (object)cfgRow[MessageConfiguration.Order] : (object)DBNull.Value,
                xml,
                cfgRow[MessageConfiguration.DestUnitId],
                cfgRow[MessageConfiguration.IPAdapter],
                (DBNull.Value.Equals(cfgRow[MessageConfiguration.IPAdapter])) ?
                cfgRow[MessageConfiguration.DestUnitPort] :
                cfgRow[MessageConfiguration.PortAdapter],
                decimal.Zero,
                DBNull.Value, DBNull.Value,
                cfgRow[MessageConfiguration.TotalRetries],
                cfgRow[MessageConfiguration.PartialRetries],
                cfgRow[MessageConfiguration.TotalInterval],
                cfgRow[MessageConfiguration.PartialInterval],
                cfgRow[MessageConfiguration.TotalTime],
                cfgRow[MessageConfiguration.HisMandatory],
                DBNull.Value, version, valid, deleted
            });
        }
コード例 #49
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //get the parameter....  the current directory level ..may be null

                string start_directory = Request.QueryString["Path"];
                string s = Table1.TemplateSourceDirectory;
                Cerval_Configuration c1 = new Cerval_Configuration("StaffIntranet_StaffDocuments");
                string s1 = c1.Value;
                if (!c1.valid)//try revert to config file
                {
                    System.Configuration.AppSettingsReader ar = new System.Configuration.AppSettingsReader();
                    s1 = ar.GetValue("StaffDocuments", typeof(string)).ToString();
                }
                //s1 = @"c:\users\cc\documents";
                if (start_directory != null)
                {
                    s1 = s1 + "\\" + start_directory;
                }
                s = s1;
                DirectoryInfo   di     = new DirectoryInfo(s);
                DirectoryInfo[] dilist = di.GetDirectories();
                foreach (DirectoryInfo di1 in dilist)
                {
                    if (!di1.Name.StartsWith("_"))
                    {
                        TableRow r = new TableRow();
                        s = di1.Name;
                        if (start_directory != null)
                        {
                            s = start_directory + "\\" + s;
                        }
                        TableCell c = new TableCell();
                        c.Controls.Add(new LiteralControl("FOLDER:- <A href=\"" + Table1.TemplateSourceDirectory + "/StaffDocuments.aspx?Path=" + s + "\">" + s + "</A>"));
                        r.Cells.Add(c);
                        Table1.Rows.Add(r);
                    }
                }
                FileInfo[] fi = di.GetFiles();
                foreach (FileInfo fiTemp in fi)
                {
                    AddFileToTable(fiTemp, false, start_directory);
                }

                Table1.Font.Name   = "Arial";
                Table1.CellPadding = 5;
                Table1.CellSpacing = 0;
                Table1.ToolTip     = "List of directories and files to downlaod";
            }
        }
コード例 #50
0
        public static string Decrypt(string cipherString, bool useHashing)
        {
            byte[] keyArray;
            //get the byte code of the string

            byte[] toEncryptArray = Convert.FromBase64String(cipherString);

            System.Configuration.AppSettingsReader settingsReader =
                new System.Configuration.AppSettingsReader();
            //Get your key from config file to open the lock!
            string key = (string)settingsReader.GetValue("SecurityKey",
                                                         typeof(String));

            if (useHashing)
            {
                //if hashing was used get the hash code with regards to your key
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                //release any resource held by the MD5CryptoServiceProvider

                hashmd5.Clear();
            }
            else
            {
                //if hashing was not implemented get the byte code of the key
                keyArray = UTF8Encoding.UTF8.GetBytes(key);
            }

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

            //set the secret key for the tripleDES algorithm
            tdes.Key = keyArray;
            //mode of operation. there are other 4 modes.
            //We choose ECB(Electronic code Book)

            tdes.Mode = CipherMode.ECB;
            //padding mode(if any extra byte added)
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();

            byte[] resultArray = cTransform.TransformFinalBlock(
                toEncryptArray, 0, toEncryptArray.Length);
            //Release resources held by TripleDes Encryptor
            tdes.Clear();
            //return the Clear decrypted TEXT
            return(UTF8Encoding.UTF8.GetString(resultArray));
        }
コード例 #51
0
        //Encrypt ID
        public static string Encrypt(string toEncrypt, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            System.Configuration.AppSettingsReader settingsReader = new System.Configuration.AppSettingsReader();
            // Get the key from config file
            string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));

            //System.Windows.Forms.MessageBox.Show(key);
            //If hashing use get hashcode regards to your key
            if (useHashing)
            {
                MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                //Always release the resources and flush data
                // of the Cryptographic service provide. Best Practice
                hashmd5.Clear();
            }
            else
            {
                keyArray = UTF8Encoding.UTF8.GetBytes(key);
            }

            TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();

            //set the secret key for the tripleDES algorithm
            tdes.Key = keyArray;
            //mode of operation. there are other 4 modes.
            //We choose ECB(Electronic code Book)
            tdes.Mode = CipherMode.ECB;
            //padding mode(if any extra byte added)

            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateEncryptor();

            //transform the specified region of bytes array to resultArray
            byte[] resultArray =
                cTransform.TransformFinalBlock(toEncryptArray, 0,
                                               toEncryptArray.Length);
            //Release resources held by TripleDes Encryptor
            tdes.Clear();
            //Return the encrypted data into unreadable string format
            return(Convert.ToBase64String(resultArray, 0, resultArray.Length));
        }
コード例 #52
0
        public DjLiveService()
        {
            var reader = new System.Configuration.AppSettingsReader();

            _host     = (string)reader.GetValue("host", typeof(string));
            _hostUrl  = (string)reader.GetValue("hostUrl", typeof(string));
            _apiUrl   = (string)reader.GetValue("apiUrl", typeof(string));
            _username = (string)reader.GetValue("userName", typeof(string));
            _password = (string)reader.GetValue("password", typeof(string));
            _port     = (int)reader.GetValue("port", typeof(int));
            _apiUrl   = string.IsNullOrEmpty(_apiUrl)?_hostUrl + $":{_apiPort}" : _apiUrl;
            ApiUrlManager.Init(_apiUrl);
        }
コード例 #53
0
        /// <summary>
        /// Updates the data on the DataRow containing info about the message
        /// Data updated includes but is not limited to, number of retries, date of last retry, status ...
        /// Data is updated in the internal DataRow (the same DataRow passed to ctor when the object was constructed)
        /// </summary>
        public void UpdateData()
        {
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }


            _dr["MSG_STATUS"]     = Convert.ToInt32(OPS.Components.Data.CmpMessagesDB.MsgsStatus.Sending);
            _dr["MSG_NUMRETRIES"] = Convert.ToInt32(_dr["MSG_NUMRETRIES"]) + 1;
            _dr["MSG_LASTRETRY"]  = DateTime.Now.AddHours(nDifHour);
        }
コード例 #54
0
        /// <summary>
        /// Insert a set of alarms of a unit.
        /// Do it inside a transaction
        /// </summary>
        /// <param name="alarms">Array of DALA_ID (alarms) to set</param>
        /// <param name="uniid">Unit which set that alarms</param>
        /// <param name="con">Connection object to use</param>
        /// <param name="tran">Transaction context to use</param>
        /// <returns></returns>
        protected void InsertAlarms(ArrayList alarms, int uniid, IDbConnection con, DateTime date)
        {
            Database d = DatabaseFactory.GetDatabase();

            //m.WaitOne();
            try
            {
                string ssql = "INSERT INTO ALARMS (ALA_ID, ALA_DALA_ID, ALA_UNI_ID, ALA_INIDATE) "
                              + "VALUES (@ALARMS.ALA_ID@, @ALARMS.ALA_DALA_ID@, @ALARMS.ALA_UNI_ID@, @ALARMS.ALA_INIDATE@)";
                object[] values = new object[5];
                values[2] = uniid;

                AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
                double            nDifHour    = 0;
                try
                {
                    nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
                }
                catch
                {
                    nDifHour = 0;
                }

                foreach (object alarm in alarms)
                {
                    values[0] = GetNewAlaPk();
                    values[1] = (int)alarm;
                    values[3] = date;
                    // cfe -- evito que el error en una alarma impida el funcionamiento del resto
                    try
                    {
                        d.ExecuteNonQuery(ssql, con, values);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            finally
            {
                //m.ReleaseMutex();
            }
        }
コード例 #55
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
     this.cnFriends  = new System.Data.SqlClient.SqlConnection();
     this.adApproved = new System.Data.SqlClient.SqlDataAdapter();
     this.cmApproved = new System.Data.SqlClient.SqlCommand();
     this.dsApproved = new FriendsReunion.ContactsData();
     ((System.ComponentModel.ISupportInitialize)(this.dsApproved)).BeginInit();
     //
     // cnFriends
     //
     this.cnFriends.ConnectionString = ((string)(configurationAppSettings.GetValue("cnFriends.ConnectionString", typeof(string))));
     //
     // adApproved
     //
     this.adApproved.SelectCommand = this.cmApproved;
     this.adApproved.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
         new System.Data.Common.DataTableMapping("Table", "User", new System.Data.Common.DataColumnMapping[] {
             new System.Data.Common.DataColumnMapping("FirstName", "FirstName"),
             new System.Data.Common.DataColumnMapping("LastName", "LastName"),
             new System.Data.Common.DataColumnMapping("PhoneNumber", "PhoneNumber"),
             new System.Data.Common.DataColumnMapping("Address", "Address"),
             new System.Data.Common.DataColumnMapping("Email", "Email"),
             new System.Data.Common.DataColumnMapping("UserID", "UserID")
         })
     });
     //
     // cmApproved
     //
     this.cmApproved.CommandText = "SELECT [User].FirstName, [User].LastName, [User].PhoneNumber, [User].Address, [Us" +
                                   "er].Email, [User].UserID FROM [User] INNER JOIN Contact ON [User].UserID = Conta" +
                                   "ct.RequestID WHERE (Contact.DestinationID = @ID) AND (Contact.IsApproved = 1)";
     this.cmApproved.Connection = this.cnFriends;
     this.cmApproved.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.VarChar, 36, "DestinationID"));
     //
     // dsApproved
     //
     this.dsApproved.DataSetName        = "ContactsData";
     this.dsApproved.Locale             = new System.Globalization.CultureInfo("en-US");
     this.grdApproved.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.grdApproved_PageIndexChanged);
     this.Load += new System.EventHandler(this.Page_Load);
     ((System.ComponentModel.ISupportInitialize)(this.dsApproved)).EndInit();
 }
コード例 #56
0
 /// <summary>
 /// GetConfigValue
 /// </summary>
 /// <typeparam name="T">passed type</typeparam>
 /// <param name="appSettingsReader">System.Configuration.AppSettingsReader</param>
 /// <param name="keyName">string</param>
 /// <param name="keyValue">ref T</param>
 /// <param name="defaultValue">T</param>
 private static void GetConfigValue <T>(System.Configuration.AppSettingsReader appSettingsReader,
                                        string keyName, ref T keyValue, T defaultValue)
 {
     keyValue = defaultValue; // provide a default
     try
     {
         string tempS = (string)appSettingsReader.GetValue(keyName, typeof(System.String));
         if ((tempS != null) && (tempS.Trim().Length > 0))
         {
             keyValue = (T)TypeDescriptor.GetConverter(keyValue.GetType()).ConvertFrom(tempS);
         }
         else
         {
             Debug.WriteLine("Registry failed to read value from " + keyName);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.ToString());  // if key does not exist, not a problem. Caller must pre-assign values anyway
     }
 }
コード例 #57
0
        protected void btnRechazar_Click(object sender, EventArgs e)
        {
            DBConn oConn = new DBConn();

            if (oConn.Open())
            {
                cAntPagos oPagos = new cAntPagos(ref oConn);
                oPagos.CodPagos             = hdd_cod_pago.Value;
                oPagos.ImporteTotalRecibido = hdd_importetotal_recibido.Value;
                oPagos.Discrepancia         = hdd_total_discrepancia.Value;
                oPagos.Estado = "A";
                oPagos.Accion = "EDITAR";
                oPagos.Put();
                oConn.Close();
            }

            StringBuilder sHmtl = new StringBuilder();

            sHmtl.Append("Se informa que la valija # ").Append(lblValija.Text).Append(" a sido rechazada.");

            AppSettingsReader appReader = new System.Configuration.AppSettingsReader();
            string            sEmlAddr  = appReader.GetValue("AntalisMail", typeof(string)).ToString();

            oEmailing.FromName = Application["NameSender"].ToString();
            oEmailing.From     = Application["EmailSender"].ToString();
            oEmailing.Address  = sEmlAddr;
            oEmailing.Subject  = "Valija # " + lblValija.Text + ", RECHAZADA";
            oEmailing.Body     = sHmtl;
            oEmailing.EmailSend();

            Log oLog = new Log();

            oLog.IdUsuario = oIsUsuario.CodUsuario;
            oLog.ObsLog    = "RECHAZO VALIJA #" + hdd_cod_pago.Value;
            oLog.CodEvtLog = "2";
            oLog.AppLog    = "ANTALIS";
            oLog.putLog();

            Response.Redirect("controllerpagos.aspx");
        }
コード例 #58
0
        /// <summary>
        /// Inserts a new Alarm into the alarms table
        /// </summary>
        /// <param name="iSrcId">Source Unit Id</param>
        /// <param name="iDstId">Destine Unit Id</param>
        /// <param name="sType">Message Type Name (m1, m2, ...)</param>
        /// <param name="sIn">Input message body</param>
        /// <param name="sOut">Answer message body</param>
        public void InsertMsg(int iSrcId, int iDstId, string sType, string sIn, string sOut)
        {
            Database          d           = DatabaseFactory.GetDatabase();
            long              id          = GetNewMsgsLogPk();
            AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
            double            nDifHour    = 0;

            try
            {
                nDifHour = (double)appSettings.GetValue("HOUR_DIFFERENCE", typeof(double));
            }
            catch
            {
                nDifHour = 0;
            }

            string ssql = "INSERT INTO MSGS_LOG (LMSG_ID, LMSG_SRC_UNI_ID, LMSG_DST_UNI_ID, LMSG_DATE, " +
                          "LMSG_TYPE, LMSG_XML_IN, LMSG_XML_OUT) VALUES (";

            ssql = ssql + "@MSGS_LOG.LMSG_ID@, @MSGS_LOG.LMSG_SRC_UNI_ID@, @MSGS_LOG.LMSG_DST_UNI_ID@, " +
                   "@MSGS_LOG.LMSG_DATE@, @MSGS_LOG.LMSG_TYPE@, @MSGS_LOG.LMSG_XML_IN@, @MSGS_LOG.LMSG_XML_OUT@)";
            d.ExecuteNonQuery(ssql, id, iSrcId, iDstId, DateTime.Now.AddHours(nDifHour), sType, sIn, sOut);
        }
コード例 #59
0
        public MainWindow()
        {
            this.ViewModel = new MainViewModel();
            this.ViewModel.PropertyChanged += ViewModel_PropertyChanged;
            InitializeComponent();

            string _initialFileName = ((App)Application.Current).FileName;

            if (!String.IsNullOrEmpty(_initialFileName))
            {
                this.ViewModel.FilesNames = new string[] { _initialFileName }
            }
            ;

            try
            {
                System.Configuration.AppSettingsReader _asr = new System.Configuration.AppSettingsReader();
                this.ViewModel.FolderName = (string)_asr.GetValue("FolderName", typeof(String));
            }
            catch (Exception _exc)
            {
            }
        }
コード例 #60
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
     this.cnFriends = new System.Data.SqlClient.SqlConnection();
     this.cmPlace   = new System.Data.SqlClient.SqlCommand();
     this.cmType    = new System.Data.SqlClient.SqlCommand();
     this.dsResults = new System.Data.DataSet();
     ((System.ComponentModel.ISupportInitialize)(this.dsResults)).BeginInit();
     this.grdResults.ItemCommand   += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.grdResults_ItemCommand);
     this.grdResults.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.grdResults_ItemDataBound);
     this.btnSearch.Click          += new System.EventHandler(this.btnSearch_Click);
     this.btnSearchResults.Click   += new System.EventHandler(this.btnSearchResults_Click);
     this.btnClearResults.Click    += new System.Web.UI.ImageClickEventHandler(this.btnClearResults_Click);
     this.btnClearSelection.Click  += new System.Web.UI.ImageClickEventHandler(this.btnClearSelection_Click);
     this.btnRequest.Click         += new System.Web.UI.ImageClickEventHandler(this.btnRequest_Click);
     //
     // cnFriends
     //
     this.cnFriends.ConnectionString = ((string)(configurationAppSettings.GetValue("cnFriends.ConnectionString", typeof(string))));
     //
     // cmPlace
     //
     this.cmPlace.CommandText = "SELECT PlaceID, Name FROM Place ORDER BY Name";
     this.cmPlace.Connection  = this.cnFriends;
     //
     // cmType
     //
     this.cmType.CommandText = "SELECT TypeID, Name FROM PlaceType ORDER BY Name";
     this.cmType.Connection  = this.cnFriends;
     //
     // dsResults
     //
     this.dsResults.DataSetName = "NewDataSet";
     this.dsResults.Locale      = new System.Globalization.CultureInfo("en-US");
     this.Load += new System.EventHandler(this.Page_Load);
     ((System.ComponentModel.ISupportInitialize)(this.dsResults)).EndInit();
 }