//监听客户端发来的请求
        private static void WatchConnecting()
        {
            while (true)
            {
                Socket connection = null;
                try
                {
                    connection = socketwatch.Accept();
                }
                catch (Exception ex)
                {
                    LW.E(ex.Message);
                    continue;
                }

                string remoteEndPoint = connection.RemoteEndPoint.ToString();
                LW.D("Estalished a connection with " + remoteEndPoint);

                Thread thread = new Thread(new ParameterizedThreadStart(Recv))
                {
                    IsBackground = true,
                    Name         = remoteEndPoint + " Worker Thread"
                };
                thread.Start(connection);
            }
        }
        static void Main()
        {
            LW.InitLog();
            if (!XConfig.LoadConfig("XConfig.conf"))
            {
                LW.E("Config File Not Loaded!");
                return;
            }
            DatabaseCore.InitialiseDBConnection();
            DatabaseSocketsServer.InitialiseSockets();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            mainForm = new MainForm();
            try
            {
                Application.Run(mainForm);
            }
            catch (Exception ex)
            {
                LW.E(ex.Message);
                LW.E("MainForm disappeared caused by exception!");
                Thread.Sleep(1000);
                LW.E("DBServer is to be restarted to keep stability!");
            }
            Application.Restart();
        }
 public IActionResult UserManage(string mode, string from, string uid, string msg)
 {
     ViewData["where"] = ControllerName;
     if (ValidateSession())
     {
         if (!CurrentUser.UserGroup.IsAdmin)
         {
             LW.E("Someone trying access illegal page!, Page: UserManage, user:"******", possible referer:" + Request.Headers["Referer"]);
             return(NotFound());
         }
         ViewData["mode"] = mode;
         if (mode == "edit")
         {
             ViewData["from"] = from;
             string targetId = uid;
             string message  = (string)PublicTools.DecodeObject(Encoding.UTF8.GetString(Convert.FromBase64String(msg ?? "")));
             ViewData["registerMsg"] = message;
             return(DataBaseOperation.QuerySingleData(new DBQuery().WhereEqualTo("objectId", uid), out UserObject _user) == DBQueryStatus.ONE_RESULT
                 ? View(_user)
                 : NotFoundError(ServerAction.INTERNAL_ERROR, XConfig.Messages["NoUserFoundByGivenID"]));
         }
         else if (mode == "query")
         {
             return(View());
         }
         else
         {
             throw new NotSupportedException("mode not supported!");
         }
     }
     else
     {
         return(LoginFailed($"/Manage/UserManage?mode={mode}&from={from}&uid={uid}&msg={msg}"));
     }
 }
 public static void StartProcessThreads()
 {
     ProcessorSENTThread.Start();
     LW.D("\tWeChatSendThread Started!");
     ProcessorRCVDThread.Start();
     LW.D("\tWeChatRcvdThread Started!");
 }
示例#5
0
 public static bool ChangePassWord(UserObject NowUser, string OriPasswrd, string NewPasswrd)
 {
     if (OriPasswrd.SHA256Encrypt() != CurrentUser.Password)
     {
         LW.E("ChangePassword Request Failed, Reason: Original Password Incorrect....");
         return(false);
     }
     else
     {
         NowUser.Password = NewPasswrd.SHA256Encrypt();
         if (DataBaseOperation.UpdateData(ref NowUser, new DBQuery()
                                          .WhereEqualTo("objectId", CurrentUser.ObjectId)
                                          .WhereEqualTo("Password", OriPasswrd.SHA256Encrypt())
                                          .WhereEqualTo("Username", CurrentUser.UserName)) == DBQueryStatus.ONE_RESULT)
         {
             LW.I("Change Password Success!");
             return(true);
         }
         else
         {
             LW.I("Change Password Failed!");
             return(false);
         }
     }
 }
 private static void Maintain()
 {
     while (true)
     {
         try
         {
             string _mid   = Cryptography.RandomString(5, false);
             byte[] packet = PublicTools.EncodeMessage(_mid, "HeartBeat");
             if (CoreSend(packet, _mid, out string reply))
             {
                 LW.D("HeartBeat Succeed! " + reply);
             }
             else
             {
                 throw new Exception("CoreSend Error: Timeout");
             }
             Thread.Sleep(5000);
         }
         catch (Exception ex)
         {
             if (ex is ThreadAbortException)
             {
                 return;
             }
             LW.E("Heartbeat Error! " + ex.Message);
             socketclient.CloseAndDispose();
             stream.CloseAndDispose();
             Initialise(remoteEndpoint.Address, remoteEndpoint.Port);
             Thread.Sleep(5000);
         }
     }
 }
示例#7
0
        public static bool Login(string xUserName, string xPassword, out UserObject user)
        {
            xUserName = xUserName.ToLower();
            string  HashedPs      = xPassword.SHA256Encrypt();
            DBQuery UserNameQuery = new DBQuery();

            UserNameQuery.WhereEqualTo("Username", xUserName);
            UserNameQuery.WhereEqualTo("Password", HashedPs);
            switch (DataBaseOperation.QuerySingleData(UserNameQuery, out user))
            {
            case DBQueryStatus.INTERNAL_ERROR:
                LW.E("Internal DataBase Error");
                break;

            case DBQueryStatus.NO_RESULTS:
                LW.E("No User Found");
                break;

            case DBQueryStatus.ONE_RESULT:
                LW.E("User Found");
                return(true);

            case DBQueryStatus.MORE_RESULTS:
                LW.E("WTF Exception....");
                break;

            default:
                break;
            }
            return(false);
        }
        public static bool Initialise(IPAddress ServerIP, int Port)
        {
            socketclient   = new TcpClient();
            remoteEndpoint = new IPEndPoint(ServerIP, Port);
            int FailedRetry = XConfig.Current.Database.FailedRetryTime;

            for (int i = 0; i < FailedRetry; i++)
            {
                try
                {
                    socketclient.Connect(remoteEndpoint);
                    stream = socketclient.GetStream();
                    LW.D("\tDatabase Connection Estabilished!");
                    if (IsFirstTimeInit)
                    {
                        ReceiverThread.Start();
                        DataBaseConnectionMaintainer.Start();
                        IsFirstTimeInit = false;
                    }
                    SendData("openConnection", "00000", out string token);
                    LW.D("\tDatabase Connected! Identity: " + token);
                    return(true);
                }
                catch (Exception ex)
                {
                    LW.E("\t\tDatabase connection to server: " + ServerIP + " failed. " + ex.Message);
                    Thread.Sleep(1000);
                }
            }
            return(false);
        }
示例#9
0
 private void UsrLoginWindow_FormClosed(object sender, FormClosedEventArgs e)
 {
     void ApplicationExit()
     {
         LW.I("Terminating Application.....");
         Application.Exit();
     }
 }
        static void Main(string[] args)
        {
            LW.InitLog();
            LW.SetLogLevel(LogLevel.Dbg);
            DataBaseOperation.InitialiseClient();

            LW.D(DataBaseOperation.QuerySingleData(new DBQuery().WhereEqualTo("realname", "刘浩宇"), out UserObject me));
            LW.D(me);
            ClassObject co = new ClassObject()
            {
                CDepartment = "学部",
                CGrade      = "1年级",
                CNumber     = "5班",
                TeacherID   = me.ObjectId
            };

            LW.D(DataBaseOperation.CreateData(ref co));
            me.ClassList.Add(co.ObjectId);
            LW.D(co);


            SchoolBusObject bo = new SchoolBusObject()
            {
                BusName   = "校车方向1",
                TeacherID = me.ObjectId
            };

            LW.D(DataBaseOperation.CreateData(ref bo));

            LW.D(bo);

            for (int cn = 1; cn < 40; cn++)
            {
                StudentObject stu = new StudentObject()
                {
                    BusID       = bo.ObjectId,
                    ClassID     = co.ObjectId,
                    Sex         = "M",
                    StudentName = "学生-" + cn.ToString("000"),
                    AHChecked   = false,
                    CSChecked   = false,
                    LSChecked   = false
                };
                LW.D(DataBaseOperation.CreateData(ref stu));

                LW.D(stu);
                if (cn < 21)
                {
                    me.ChildList.Add(stu.ObjectId);
                }
            }

            me.HeadImagePath = "liuhaoyu.gif";
            LW.D(DataBaseOperation.UpdateData(ref me));
            LW.D(me);
        }
示例#11
0
        public static void InitialiseClient()
        {
            LW.D("Started Initialise Database Server Connection....");
            bool conn = DatabaseSocketsClient.Initialise(IPAddress.Parse(XConfig.Current.Database.DBServerIP), XConfig.Current.Database.DBServerPort);

            while (!conn)
            {
                LW.E("DBServer Initial Connection Failed!");
                conn = DatabaseSocketsClient.Initialise(IPAddress.Parse(XConfig.Current.Database.DBServerIP), XConfig.Current.Database.DBServerPort);
            }
        }
 //发送字符信息到服务端的方法
 public static bool SendData(string sendMsg, string MessageId, out string rcvdMessage)
 {
     rcvdMessage = "";
     byte[] mergedPackage = PublicTools.EncodeMessage(MessageId, sendMsg);
     while (!Connected)
     {
         LW.E("Message Sent Waiting for connection....");
         Thread.Sleep(500);
     }
     return(CoreSend(mergedPackage, MessageId, out rcvdMessage));
 }
示例#13
0
        public static IWebHost BuildWebHost(string instrumentationKey, string[] args)
        {
            LW.D("Building WebHost....");
            var host = WebHost.CreateDefaultBuilder(args)
                       .UseIISIntegration()
                       .UseKestrel()
                       .UseApplicationInsights(instrumentationKey)
                       .UseStartup <Startup>()
                       .Build();

            return(host);
        }
        public IActionResult RequestChange()
        {
            ViewData["where"] = ControllerName;
            if (ValidateSession())
            {
                if (Request.HasFormContentType)
                {
                    Microsoft.AspNetCore.Http.IFormCollection form = Request.Form;
                    UserChangeRequestTypes types = (UserChangeRequestTypes)Enum.Parse(typeof(UserChangeRequestTypes), form[nameof(UserChangeRequest.RequestTypes)][0]);
                    string            reason     = form[nameof(UserChangeRequest.DetailTexts)][0];
                    string            newVal     = form[nameof(UserChangeRequest.NewContent)][0];
                    UserChangeRequest request    = new UserChangeRequest()
                    {
                        DetailTexts  = reason,
                        SolverID     = "",
                        NewContent   = newVal,
                        Status       = UCRProcessStatus.NotSolved,
                        RequestTypes = types,
                        UserID       = CurrentUser.ObjectId
                    };

                    if (DataBaseOperation.CreateData(ref request) != DBQueryStatus.ONE_RESULT)
                    {
                        LW.E("AccountController->ProcessNewUCR: Create UCR Failed!");
                        return(DatabaseError(ServerAction.MyAccount_CreateChangeRequest, XConfig.Messages["CreateUCR_Failed"]));
                    }

                    InternalMessage messageAdmin = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created_TO_ADMIN, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    InternalMessage message_User = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created__TO_User, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    MessagingSystem.AddMessageProcesses(messageAdmin, message_User);

                    return(Redirect($"/{HomeController.ControllerName}/{nameof(HomeController.RequestResult)}?req=changereq&status=ok&callback=/Account/"));
                }
                else
                {
                    ViewData["cUser"] = CurrentUser.ToString();
                    return(View(new UserChangeRequest()
                    {
                        UserID = CurrentUser.ObjectId
                    }));
                }
            }
            else
            {
                return(LoginFailed("/" + ControllerName + "/" + nameof(RequestChange)));
            }
        }
        public static void InitialiseDBConnection()
        {
            SqlConnectionStringBuilder conn = new SqlConnectionStringBuilder();

            LW.D("Start Initiallising Database Connections.....");
            conn.DataSource             = XConfig.Current.Database.SQLServerIP + "," + XConfig.Current.Database.SQLServerPort;
            conn.UserID                 = XConfig.Current.Database.DatabaseUserName;
            conn.Password               = XConfig.Current.Database.DatabasePassword;
            conn.TrustServerCertificate = true;
            LW.D("DB Connection String Loaded!");
            sqlConnection = new SqlConnection(conn.ConnectionString);
            sqlConnection.Open();
            LW.D("DB Connection Opened!");
        }
        public static void Main()
        {
            LW.SetLogLevel(LogLevel.Dbg);
            LW.InitLog();
            LW.D("========= = Start WoodenBench for Schoolbus Windows Client = =========");
            if (!XConfig.LoadConfig("XConfig.conf"))
            {
                LW.E("Config Loading Failed! Check file...");
                return;
            }

            DataBaseOperation.InitialiseClient();
            Application.EnableVisualStyles();
            Application.Run(LoginWindow.Default);
        }
示例#17
0
        public static void Main(string[] args)
        {
            LW.SetLogLevel(LogLevel.Dbg);
            LW.InitLog();

            var v = XConfig.LoadAll();

            if (!(v.Item1 && v.Item2))
            {
                return;
            }

            new Thread(new ThreadStart(GetStateString)).Start();
            BuildWebHost(args).Run();
        }
 // 接收服务端发来信息的方法
 static void Recv()
 {
     while (true)
     {
         while (Connected)
         {
             string requestString = PublicTools.DecodeMessage(stream);
             _messages.Add(requestString.Substring(0, 5), requestString.Substring(5));
         }
         while (!Connected)
         {
             LW.E("Message Recieve waiting for connection......");
             Thread.Sleep(500);
         }
     }
 }
示例#19
0
 private void DoLogin(object sender, EventArgs e)
 {
     //Login the user
     UserNameTxt.Enabled  = false;
     PswdTxt.Enabled      = false;
     NewUserLabel.Visible = false;
     LoginResult.Text     = "";
     DoLoginBtn.Enabled   = false;
     CancelBtn.Enabled    = false;
     DoLoginBtn.Text      = "登录中...";
     Application.DoEvents();
     if (UserActivity.Login(UserNameTxt.Text, PswdTxt.Text, out UserObject user))
     {
         LW.D($"Login succeed using username {UserNameTxt.Text}");
         if (user.UserGroup.IsAdmin || user.UserGroup.IsBusManager || user.UserGroup.IsClassTeacher)
         {
             DoLoginBtn.Enabled  = true;
             CancelBtn.Enabled   = true;
             UserNameTxt.Enabled = true;
             PswdTxt.Enabled     = true;
             DoLoginBtn.Text     = "登录(&L)";
             CurrentUser         = user;
             MainForm.Default.Show();
             Hide();
         }
         else if (user.UserGroup.IsParent)
         {
             MessageBox.Show("暂时不支持家长使用小板凳 Windows 客户端哦!");
         }
         else
         {
             MessageBox.Show("用户组配置无效,请联系管理员。");
         }
     }
     else
     {
         LW.E($"Login failed using username {UserNameTxt.Text} and password {PswdTxt.Text}.");
         LoginResult.Text    = "用户名或密码不正确";
         LoginResult.Visible = true;
         DoLoginBtn.Enabled  = true;
         CancelBtn.Enabled   = true;
         UserNameTxt.Enabled = true;
         PswdTxt.Enabled     = true;
         DoLoginBtn.Text     = "登录(&L)";
     }
 }
示例#20
0
        public static int Main(string[] args)
        {
            LW.SetLogLevel(LogLevel.D);
            LW.InitLog();
            LW.I("========= = Start WoodenBench for Schoolbus Windows Client = =========");
            if (!XConfig.LoadConfig("XConfig.conf"))
            {
                LW.E("Config Loading Failed! Check file...");
                return(0);
            }

            DataBaseOperation.InitialiseClient();
            Application.EnableVisualStyles();
            Application.Run(LoginWindow.Default);

            DatabaseSocketsClient.KillConnection();
            return(0);
        }
示例#21
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     foreach (StudentObject item in studentDataObjectBindingSource)
     {
         var _item = item;
         if (Database.DataBaseOperation.UpdateData(ref _item) == DBQueryStatus.ONE_RESULT)
         {
             ExDescription.Text = "成功更新项:" + _item.StudentName;
             LW.I("BusCheck: Succeed Updated Record: " + item.ObjectId);
         }
         else
         {
             ExDescription.Text = "出现问题:" + _item.StudentName;
             LW.E("BusCheck: Failed to Update Record: " + item.ObjectId);
         }
         Application.DoEvents();
     }
 }
        public override IActionResult Index()
        {
            ViewData["where"] = HomeController.ControllerName;
            if (ValidateSession())
            {
                if (!CurrentUser.UserGroup.IsAdmin)
                {
                    LW.E("Someone trying access illegal page!, Page: index, user:"******", possible referer:" + Request.Headers["Referer"]);
                    return(NotFound());
                }

                ViewData["cUser"] = CurrentUser.ToString();
                return(View(CurrentUser));
            }
            else
            {
                return(LoginFailed("/" + ControllerName));
            }
        }
        public void POST(string msg_signature, string timestamp, string nonce)
        {
            MemoryStream ms = new MemoryStream();

            Request.Body.CopyTo(ms);
            string XML_Message = "";
            string _message    = Encoding.UTF8.GetString(ms.ToArray());
            int    ret         = WeChatHelper.WeChatEncryptor.DecryptMsg(msg_signature, timestamp, nonce, _message, ref XML_Message);

            if (ret != 0)
            {
                Response.StatusCode = 200;
                LW.E("WeChat Message Decrypt Failed!! " + _message);
                Response.WriteAsync("");
                return;
            }
            WeChatMessageSystem.AddToRecvList(new WeChatRcvdMessage(XML_Message, DateTime.Now));
            Response.StatusCode = 200;
            Response.WriteAsync("");
        }
 public void Put(string column, object data)
 {
     if (data == null)
     {
         LW.E("DBOutput: Put " + column + " as null, drop it..."); return;
     }
     if (data is ICollection)
     {
         data = string.Join(",", (IEnumerable <string>)data);
     }
     if (Data.ContainsKey(column))
     {
         Data.Remove(column);
         Data.Add(column, data);
     }
     else
     {
         Data.Add(column, data);
     }
 }
示例#25
0
        public static void GetStateString()
        {
            NamedPipeClientStream client = new NamedPipeClientStream("localhost", XConfig.Current.StatusReportNamedPipe, PipeDirection.In);

            while (true)
            {
                client.Connect();
                while (client.IsConnected)
                {
                    var data  = new byte[65535];
                    var count = client.Read(data, 0, data.Length);
                    if (count > 0)
                    {
                        HomeController.ServerStatus = Encoding.UTF8.GetString(data, 0, count);
                    }
                }
                LW.E("GetStateString: DisConnected from the WBWebServer....");
                Thread.Sleep(1000);
            }
        }
示例#26
0
        private static Dictionary <string, string> SendMessageString(WeChatSMsg MessageType, string users, string Title, string Content, string URL = null)
        {
            WeChatMessageBackupService.AddToSendList(users, Title, Content);
            WeChatHelper.ReNewWCCodes();
            string Message = "{\"touser\":\"" + users + "\",\"msgtype\":\"" + MessageType.ToString() + "\",\"agentid\":" + XConfig.Current.WeChat.AgentId + ",\"" + MessageType.ToString() + "\":";

            switch (MessageType)
            {
            case WeChatSMsg.text:
                Message = Message + $"{{\"content\":\"{Content}\r\n\r\n MST: {DateTime.Now.ToNormalString()}\"}}";
                break;

            case WeChatSMsg.textcard:
                Message = Message + $"{{\"title\":\"{Title}\",\"description\":\"{Content}\",\"url\":\"{URL}\"}}";
                break;
            }
            Message = Message + "}";
            LW.D("WeChat Message Sent: " + Message);
            return(PublicTools.HTTPPost("https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + WeChatHelper.AccessToken, Message));
        }
示例#27
0
        public static DBQueryStatus UpdateData <T>(ref T item, DBQuery query) where T : DataTableObject, new()
        {
            if (query == null)
            {
                query = new DBQuery().WhereEqualTo("objectId", item.ObjectId);
            }
            query.Limit(1);
            DataBaseIO output = new DataBaseIO();

            item.WriteObject(output, false);
            var _result = _DBRequestInternal(item.Table, DBVerbs.Update, query, output, out DataBaseIO[] inputs);

            if (_result != DBQueryStatus.ONE_RESULT)
            {
                LW.E("DBInternalLog: UpdateData Process Failed!");
                return(DBQueryStatus.INTERNAL_ERROR);
            }
            item = new T();
            item.ReadFields(inputs[0]);
            return(_result);
        }
        public IActionResult WeChatLogin(string state, string code)
        {
            ViewData["where"] = ControllerName;
            if (string.IsNullOrEmpty(Request.Cookies["WB_WXLoginOption"]) || string.IsNullOrEmpty(state) || string.IsNullOrEmpty(code))
            {
                return(RequestIllegal(ServerAction.WeChatLogin_PreExecute, XConfig.Messages["WeChatRequestStatusUnexcepted"]));
            }
            else
            {
                WeChatHelper.ReNewWCCodes();
                //object LogonUser = null;
                Dictionary <string, string> JSON = PublicTools.HTTPGet("https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=" + WeChatHelper.AccessToken + "&code=" + code);
                if (!JSON.ContainsKey("UserId"))
                {
                    LW.E("WeChat JSON doesnot Contain: UserID, " + JSON.ToParsedString());
                    return(null);
                }
                string WeiXinID = JSON["UserId"];
                switch (DataBaseOperation.QuerySingleData(new DBQuery().WhereEqualTo("Username", WeiXinID), out UserObject User))
                {
                case DBQueryStatus.INTERNAL_ERROR:
                    LW.E("SessionManager: Failed to get User by its UserName --> DataBase Inernal Error....");
                    return(DatabaseError(ServerAction.WeChatLogin_PostExecute, XConfig.Messages["InternalDataBaseError"]));

                case DBQueryStatus.NO_RESULTS:
                    string token = OnePassTicket.CreateTicket();
                    OnePassTicket.TryAdd(token, new TicketInfo(TicketUsage.UserRegister, Request.Headers["User-Agent"], WeiXinID));
                    return(Redirect($"/Account/Register?token={token}&user={WeiXinID}&_action=register"));

                case DBQueryStatus.ONE_RESULT:
                    UpdateUser(User);
                    Response.Cookies.Delete("WB_WXLoginOption");
                    return(Redirect("/Home/Index/"));

                default:
                    LW.E("HomeController: Unexpected Database Query Result for WeChatLogin...");
                    return(DatabaseError(ServerAction.WeChatLogin_PostExecute, XConfig.Messages["WrongDataReturnedFromDatabase"]));
                }
            }
        }
示例#29
0
        public static void Main(string[] args)
        {
            LW.SetLogLevel(LogLevel.Dbg);
            LW.InitLog();
            StartUpTime = DateTime.Now;
            LW.D("WoodenBench WebServer Starting....");
            LW.D($"\t Startup Time {StartUpTime.ToString()}.");
            Version = new FileInfo(new string(Assembly.GetExecutingAssembly().CodeBase.Skip(8).ToArray())).LastWriteTime.ToString();
            LW.D($"\t Version {Version}");

            var v = XConfig.LoadAll();

            if (!(v.Item1 && v.Item2))
            {
                return;
            }

            StatusMonitor.StartMonitorThread();
            WeChatHelper.ReNewWCCodes();

            DataBaseOperation.InitialiseClient();
            //DataBaseOperation.InitialiseClient(IPAddress.Loopback);

            WeChatHelper.InitialiseExcryptor();

            LW.D("Initialising Core Messaging Systems.....");
            WeChatMessageSystem.StartProcessThreads();
            WeChatMessageBackupService.StartBackupThread();
            MessagingSystem.StartProcessThread();

            var webHost = BuildWebHost(XConfig.Current.ApplicationInsightInstrumentationKey, args);

            LW.D("Starting WebHost....");

            WebServerTask = webHost.RunAsync(ServerStopToken.Token);
            WebServerTask.Wait();
            LW.E("WebServer Stoped! Cancellation Token = " + ServerStopToken.IsCancellationRequested);
        }
示例#30
0
        private void clientEnumTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Dictionary <string, string> clientConncetionQueryStrings;
                lock (DatabaseSocketsServer.QueryStrings)
                {
                    clientConncetionQueryStrings = DatabaseSocketsServer.QueryStrings;
                }

                listView1.Items.Clear();
                foreach (KeyValuePair <string, string> item in clientConncetionQueryStrings)
                {
                    listView1.Items.Add(new ListViewItem(new string[] { item.Key, item.Value }));
                }
                dbConnections.Text  = "1";
                currentClients.Text = listView1.Items.Count.ToString();
            }
            catch (Exception ex)
            {
                LW.E("TIMER ERROR: " + ex.Message);
            }
        }