Beispiel #1
0
        //public static int getrightnumber()
        //{
        //    string username = Utils.getusername();
        //    string connection_string = Utils.getConnectionstr();
        //    LinqtoSQLDataContext dc = new LinqtoSQLDataContext(connection_string);

        //    var rs = (from tbl_Temp in dc.tbl_Temps
        //              where tbl_Temp.username == username

        //              select tbl_Temp.userright).FirstOrDefault();
        //    if (rs == null)
        //    {
        //        return 0;
        //    }
        //    else
        //    {

        //        return rs.Value;
        //    }

        //}


        public static string getConnectionstr()
        {
            String current = System.IO.Directory.GetCurrentDirectory();

            string      fileName          = current + "\\Connectstring.txt";
            string      connection_string = "";
            const Int32 BufferSize        = 128;



            string line;



            Model.SercurityFucntion bm2 = new Model.SercurityFucntion();
            line = bm2.Readtextfromfile(fileName);
            string line2 = bm2.Decryption(line);



            string[] parts = line2.Split(';');

            string st1 = parts[0].Trim();
            string st2 = parts[1].Trim();
            string st3 = parts[2].Trim();
            string st4 = parts[3].Trim();

            connection_string = ("Data Source =" + st1 + "; Initial Catalog = " + st4 + "; User Id =" + st2 + "; Password ="******"Data Source =" + st1 + "; Initial Catalog = ARconfirmationletter; User Id =" + st2 + "; Password =" + st3).Trim();
            return(connection_string);
        }
Beispiel #2
0
        public static string getDatalocate()
        {
            String current = System.IO.Directory.GetCurrentDirectory();

            string      fileName   = current + "\\Connectstring.txt";
            const Int32 BufferSize = 128;

            using (var fileStream = File.OpenRead(fileName))
                using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize))
                {
                    string line;
                    string st5;
                    while ((line = streamReader.ReadLine()) != null)
                    {
                        Model.SercurityFucntion bm2 = new Model.SercurityFucntion();
                        //  line = bm2.Readtextfromfile(fileName);
                        string line2 = bm2.Decryption(line);

                        //    string s1 = st1 + ";" + st2 + ";" + st3 + ";" + st4 + ";" + txtusername.Text;



                        string[] parts = line2.Split(';');


                        if (parts.Count() >= 5)
                        {
                            st5 = parts[3].Trim();
                        }
                        else
                        {
                            st5 = "";
                        }
                        //       string st1 = parts[0].Trim();
                        //       string st2 = parts[1].Trim();
                        //  string st3 = parts[2].Trim();


                        string datalocate = st5.ToUpper();
                        return(datalocate);
                    }

                    return("");
                }
        }