Exemple #1
0
        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;
            }
        }
        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;
        }
        private static GeoDataGlobals Load()
        {
            GeoDataGlobals retVal = null;  // Don't initialize here, it will be set up with a default in case all other methods fail!
            AppSettingsReader reader = new AppSettingsReader();

            retVal = new GeoDataGlobals();
            try
            {
                retVal.BingMapsKey = (String)reader.GetValue("BingMapsKey", typeof(String));
            }
            catch ( InvalidOperationException )
            {
            }

            try
            {
                retVal.DefaultLocation = new GeoPoint((String)reader.GetValue("DefaultLocation", typeof(String)));
            }
            catch ( InvalidOperationException )
            {
            }
            catch ( ArgumentException )
            {
            }

            return retVal;
        }
        /// <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);
                    }
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void JQGrid2_DataRequesting(object sender, JQGridDataRequestEventArgs e)
        {
            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_abnormal_NOXSO2_Relevant2 where id2 = '" + e.ParentRowKey.ToString() + "'", conn);
                    SqlDataAdapter sqladapter = new SqlDataAdapter(sqlcomm);
                    sqladapter.Fill(ds);
                    conn.Close();
                }
            }
            catch (Exception)
            {

            }
            Jqgrid2.DataSource = ds.Tables[0];
            Jqgrid2.DataBind();

            //
        }
Exemple #6
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);
        }
        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 + "*");
        }
Exemple #8
0
 private static void EnsureSettingsLoaded()
 {
     if (!settingsInitialized)
     {
         lock (appSettingsLock)
         {
             if (!settingsInitialized)
             {
                 try
                 {
                     AppSettingsReader reader = new AppSettingsReader();
                     object value = null;
                     if (TryGetValue(reader, AllowTransparentProxyMessageKeyName, typeof(bool), out value))
                     {
                         allowTransparentProxyMessageValue = (bool)value;
                     }
                     else
                     {
                         allowTransparentProxyMessageValue = AllowTransparentProxyMessageDefaultValue;
                     }
                 }
                 catch
                 {
                     // AppSettingsReader.ctor will throw if no appSettings section
                 }
                 finally
                 {
                     settingsInitialized = true;
                 }
             }
         }
     }
 }
 /// <summary>Instancia a DbFactory "setando a string de conexao"
 /// </summary>
 public DAOFactory(string connectionStringValue, string provider)
 {
     AppSettingsReader apps = new AppSettingsReader();
     objProvider = DbProviderFactories.GetFactory(provider);
     connectionString = connectionStringValue;
     objConn = objProvider.CreateConnection();
 }
        /// <summary>
        /// DeCrypt a string using dual encryption method. Return a DeCrypted clear string
        /// </summary>
        /// <param name="cipherString">encrypted string</param>
        /// <param name="useHashing">Did you use hashing to encrypt this data? pass true is yes</param>
        /// <returns></returns>
        public static string Decrypt(string cipherString, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = Convert.FromBase64String(cipherString);

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

            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);
        }
        /// <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 = SecurityKey;
            //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);
        }
Exemple #12
0
 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));
 }
        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);
        }
Exemple #14
0
        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);
        }
 /// <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();
     }
 }
Exemple #16
0
    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);
        }
    }
Exemple #17
0
 private void WorkTime_DoWork(object sender, DoWorkEventArgs e)
 {
     AppSettingsReader asr = new AppSettingsReader();
     int workTime = 60 * 1000 * (int)asr.GetValue("PomodoroPeriod", typeof(int));
     BackgroundWorker worker = (sender as BackgroundWorker);
     System.Threading.Thread.Sleep(workTime);
 }
 public SampleContext(string databasePassword)
 {
     var connectionString = new AppSettingsReader().GetValue("sampleDb", typeof (string)).ToString();
     connectionString = connectionString.Replace("{{password}}", databasePassword);
     var client = new MongoClient(connectionString);
     _db = client.GetDatabase(connectionString.Split('/').Last());
 }
Exemple #19
0
    private void InitializeComponent()
    {
        System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();

        this.qOrders = new System.Messaging.MessageQueue();

        //

        //qOrders

        //

        this.qOrders.Formatter = new System.Messaging.XmlMessageFormatter(new string[] { "Server.MSMQOrders,Server" });

        this.qOrders.Path = (string)configurationAppSettings.GetValue("msmqOrders.Path", typeof(System.String));

        //

        //WatchMSMQ

        //

        this.CanHandlePowerEvent = true;

        this.CanPauseAndContinue = true;

        this.CanShutdown = true;

        this.ServiceName = "WatchMSMQ";
    }
Exemple #20
0
        public string EncryptText(string toEncrypt, bool useHashing)
        {
            byte[] keyArray;
            byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

            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.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
            tdes.Clear();

            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }
        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;
            }
        }
 public PersistenceMgr()
 {
     AppSettingsReader config = new AppSettingsReader();
     String connector = (String)config.GetValue("Connector", typeof(String));
     con = new OdbcConnection(connector);
     con.Open();
 }
Exemple #23
0
    private static string GetConnStr(String pConnKey)
    {
        System.Configuration.AppSettingsReader asr = new System.Configuration.AppSettingsReader();
        string ConnStr = (string)asr.GetValue(pConnKey, typeof(string));

        return(ConnStr);
    }
Exemple #24
0
        private static ApplicationGridSettings ReadConfigSettings()
        {
            AppSettingsReader reader = new AppSettingsReader();

            ApplicationGridSettings settings = new ApplicationGridSettings();
            settings.MonoscapeAccessKey = (string)reader.GetValue("MonoscapeAccessKey", typeof(string));
            settings.MonoscapeSecretKey = (string)reader.GetValue("MonoscapeSecretKey", typeof(string));
            settings.DashboardServiceURL = (string)reader.GetValue("DashboardServiceURL", typeof(string));
            settings.NodeControllerServiceURL = (string)reader.GetValue("NodeControllerServiceURL", typeof(string));
            settings.FileServerServiceURL = (string)reader.GetValue("FileServerServiceURL", typeof(string));
            settings.FileServerServiceNetTcpURL = (string)reader.GetValue("FileServerServiceNetTcpURL", typeof(string));
            settings.FileServerServiceNetPipeURL = (string)reader.GetValue("FileServerServiceNetPipeURL", typeof(string));

            settings.ApplicationStoreFolder = (string)reader.GetValue("ApplicationStoreFolder", typeof(string));
            settings.ApplicationStorePath = Path.GetFullPath(settings.ApplicationStoreFolder);
            settings.SQLiteConnectionString = (string)reader.GetValue("SQLiteConnectionString", typeof(string));

            settings.LbApplicationGridEndPointUrl = (string)reader.GetValue("LbApplicationGridEndPointUrl", typeof(string));
            settings.NodeFileServerEndPointURL = (string)reader.GetValue("NodeFileServerEndPointURL", typeof(string));
            settings.NodeEndPointURL = (string)reader.GetValue("NodeEndPointURL", typeof(string));

            settings.ApFileReceiveSocketPort = (int)reader.GetValue("ApFileReceiveSocketPort", typeof(int));
            settings.NcFileTransferSocketPort = (int)reader.GetValue("NcFileTransferSocketPort", typeof(int));

            settings.IaasName = (string)reader.GetValue("IaasName", typeof(string));
            settings.IaasAccessKey = (string)reader.GetValue("IaasAccessKey", typeof(string));
            settings.IaasSecretKey = (string)reader.GetValue("IaasSecretKey", typeof(string));
            settings.IaasServiceURL = (string)reader.GetValue("IaasServiceURL", typeof(string));
            settings.IaasKeyName = (string)reader.GetValue("IaasKeyName", typeof(string));
            return settings;
        }
        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);
            }
        }
Exemple #26
0
 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));
 }
 /// <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));
 }
Exemple #28
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);
        }
        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);
        }
Exemple #30
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() + ")";
        }
        /// <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;
            }
        }
Exemple #32
0
 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();
 }
        public WebSiteConfigInfo(AppSettingsReader myAppReader)
            : base(myAppReader)
        {
            BaseConnectionString = ConfigurationManager.ConnectionStrings["EzLookerDB"].ConnectionString;
            DryTestDB = ConfigurationManager.ConnectionStrings["DryTestDB"].ConnectionString;

            try { EmailYak_Domain = readAppSetting("EmailYak_Domain", myAppReader).Value.ToString(); }
            catch { EmailYak_Domain = @"ezlooker.skunkdemo.com"; }

            try { EmailYak_BaseURL = readAppSetting("EmailYak_BaseURL", myAppReader).Value.ToString(); }
            catch { EmailYak_BaseURL = @"https://api.emailyak.com/v1/yausmoq46fjhvga/json"; }

            try { EmailYak_CallBackURL = readAppSetting("EmailYak_CallBackURL", myAppReader).Value.ToString(); }
            catch { EmailYak_CallBackURL = @""; }

            try { EmailYak_IsPushEmail = bool.Parse(readAppSetting("EmailYak_IsPushEmail", myAppReader).Value.ToString().ToLower()); }
            catch { EmailYak_IsPushEmail = string.IsNullOrEmpty(EmailYak_CallBackURL) ? false : true; }

            //make sure IsPushMail is true, only when requested and the CallBackURL is also provided.
            EmailYak_IsPushEmail = EmailYak_IsPushEmail && !string.IsNullOrEmpty(EmailYak_CallBackURL);

            try { EmailYak_MessageFooter = readAppSetting("EmailYak_MessageFooter", myAppReader).Value.ToString(); }
            catch { EmailYak_MessageFooter = string.Empty; }

        }
Exemple #34
0
        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;
            }
        }
Exemple #35
0
    public static string GetDecryptMD5(string input)
    {
        byte[] keyArray;

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

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

        MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();

        keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes("2150"));

        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));
    }
        /// <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 + "'");
        }
Exemple #37
0
        public LogToFile(LoggerMode mode)
        {
            modOfException = mode;
            readAppConfig = new AppSettingsReader ();

            path = (string)readAppConfig.GetValue ("Path", typeof (string));
        }
Exemple #38
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();
    }
Exemple #39
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))));
 }
        public void Init()
        {
            var connStr = new AppSettingsReader().GetValue("xmlconnection", typeof(string)).ToString();

            Configure.Component<DataStore>(DependencyLifecycle.SingleInstance)

            .ConfigureProperty(ds => ds.ConnectionString, connStr);
        }
Exemple #41
0
    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");
    }
Exemple #42
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);
        }
Exemple #43
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;
        }
Exemple #44
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);
        }
 /*******************************/
 public static string GetValue(string key, string defaultValue)
 {
     System.Configuration.AppSettingsReader tempSettings = new System.Configuration.AppSettingsReader();
     try
     {
         return((string)tempSettings.GetValue(key, System.Type.GetType("System.String")));
     }
     catch (System.Exception exception)
     {
         return(defaultValue);
     }
 }
        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;
            }
        }
Exemple #47
0
 /// <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);
     }
 }
Exemple #48
0
        public static void Main(string[] args)
        {
            // I have to check the args
            string userName = args[0];
            string userRemo = args[1];

            Key aliceKey = new Key("ABCDEFGH");

            #region Throw our server

            string confFile = Application.ExecutablePath + "." + userName.ToLower() + ".config";
            Console.WriteLine(confFile);
            RemotingConfiguration.Configure(confFile, false);

            #endregion

            #region Connection with server

            System.Configuration.AppSettingsReader configurationAppSettings =
                new System.Configuration.AppSettingsReader();
            //String url = (string)ConfigurationSettings.AppSettings["RemotingUrl"];
            String url =
                IKdc kdc = (IKdc)Activator.GetObject(typeof(ShareClasses.IKdc), url);

            #endregion

            #region AS_REQ

            User       alice = new User(userName);
            KRB_AS_REQ asReq = new KRB_AS_REQ(alice);
            KRB_AS_REP asRep = kdc.AS(asReq);

            #endregion

            #region TGS_REQ

            User          bob    = new User(userRemo);
            Authenticator auth   = new Authenticator(aliceKey);
            KRB_TGS_REQ   tgsReq = new KRB_TGS_REQ(asRep.GetTGT(aliceKey), auth, bob);
            KRB_TGS_REP   tgsRep = kdc.TGS(tgsReq);

            #endregion

            #region AP_REQ

            Ticket     ticket    = tgsRep.GetTicket(aliceKey);
            string     bobUrl    = (string)ConfigurationSettings.AppSettings["RemotingUser"];
            Server     bobServer = (Server)Activator.GetObject(typeof(Workstation.Server), bobUrl);
            KRB_AP_REQ apReq     = new KRB_AP_REQ(ticket, auth);
            KRB_AP_REP apRep     = bobServer.AP(apReq);

            #endregion
        }
Exemple #49
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);
        }
Exemple #50
0
        //*Conexion
        public AD_Conexion()
        {
            System.Configuration.AppSettingsReader config = new System.Configuration.AppSettingsReader();
            con = new SqlConnection();
            this.con.ConnectionString = ConfigurationManager.ConnectionStrings["Venta"].ConnectionString;
            //Sin web.config o app.config usar la cadena de conexion así:
            //this.con.ConnectionString ="Server=10.10.10.10; Database=Test_database; User ID=myuser; Password=mypassword;";

            //Con web.config o app.config usar la cadena de conexion así:
            //this.con.ConnectionString = ConfigurationManager.ConnectionStrings["theConexionStringName"].ConnectionString;

            strCadena = this.con.ConnectionString;
        }
Exemple #51
0
 public XMLBlogData()
 {
     try
     {
         System.Configuration.AppSettingsReader reader = new System.Configuration.AppSettingsReader();
         //dataPath = (string)reader.GetValue("dataPath", dataPath.GetType());
         dataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
     }
     catch
     {
         dataPath = "~/App_Data";
     }
 }
        /// <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
            });
        }
Exemple #53
0
        public bool LoginStatus()
        {
            bool   useHashing   = true;
            string cipherString = ConfigurationManager.AppSettings["AuthTocken"];

            byte[] keyArray;
            //get the byte code of the string

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

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

            string key = "workProgress";

            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;
            //padding mode(if any extra byte added)
            tdes.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdes.CreateDecryptor();

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

            tdes.Clear();

            if (DateTime.Now >= DateTime.Parse(UTF8Encoding.UTF8.GetString(resultArray)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        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";
            }
        }
        private void SaveMessages(
            string mgmtDbServer,
            string mgmtDbName,
            string outputFolder)
        {
            AppSettingsReader appSet       = new System.Configuration.AppSettingsReader();
            InstanceStatus    statusToFind = (InstanceStatus)Enum.Parse(typeof(InstanceStatus), (string)appSet.GetValue("State", typeof(string)));

            BizTalkOperations biztalkOps = new BizTalkOperations(mgmtDbServer, mgmtDbName);

            int  retryCount = 0;
            bool retryLoop  = true;

            while (retryLoop)
            {
                try
                {
                    SaveHelper(outputFolder, biztalkOps, statusToFind);
                    retryLoop = false;
                }
                catch (System.Exception ex)
                {
                    // For large numbers of messages, the connection occasionally breaks off...
                    if (ex.Message.IndexOf("Failed to connect") > -1)
                    {
                        bool connectSuccess = false;
                        while (!connectSuccess)
                        {
                            try
                            {
                                retryCount++;
                                Trace(string.Format("Connection failure {0} - trying again.", retryCount));
                                this.Refresh();
                                System.Threading.Thread.Sleep(500);
                                biztalkOps     = new BizTalkOperations(mgmtDbServer, mgmtDbName);
                                connectSuccess = true;
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }


            Trace("Done.");
        }
Exemple #56
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));
        }
    protected static SqlConnection criar_conexao(string Ptipo_conexao)
    {
        SqlConnection Fcnn = null;


        try {
            System.Configuration.AppSettingsReader app_reader = new System.Configuration.AppSettingsReader();
            string str_conexao = Convert.ToString(app_reader.GetValue(Ptipo_conexao, typeof(string)));

            Fcnn = new SqlConnection(str_conexao);
            Fcnn.Open();
            return(Fcnn);
        } catch (SqlException ex) {
            throw ex;
        }
    }
Exemple #58
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));
        }