public DataBus GetDataBus() { bool isTimeOut = IsTimeOut; if (isTimeOut) { if (dataBus != null) { try { //Send stop mession first StopAction stopAction = new StopAction(dataBus); HttpResponseMessage response = stopAction.DoAction(); string str = response.GetContent(); } catch { //Nothing to do. } } } if (dataBus == null || isTimeOut) { sessionStart = System.DateTime.Now; dataBus = LoadBalanceUtil.GetDataBus(connectionInfo); //Start action. StartAction startAction = new StartAction(dataBus); HttpResponseMessage response = startAction.DoAction(); string str = response.GetContent(); try { Start startEntity = startAction.ResponseData as Start; dataBus.ThreadId = startEntity.Threads[0].ThreadId; } catch (Exception ex) { throw new Exception("Start:" + str); } ActionUtil.GetFormAndData(dataBus, string.Empty); //Login LoginAction loginAction = new LoginAction(dataBus); loginAction.UserName = dataBus.UserName; loginAction.Password = dataBus.EncryptedPassword; response = loginAction.DoAction(); string loginMessage = response.GetContent(); GetMessageAction fetchMessageAction = new GetMessageAction(dataBus); fetchMessageAction.DoAction(); Execute execute = fetchMessageAction.ResponseData as Execute; while (execute != null && execute.ClientRequestEntity != null) { ActionUtil.StoreMessages(execute.ClientRequestEntity); fetchMessageAction = new GetMessageAction(dataBus); fetchMessageAction.DoAction(); execute = fetchMessageAction.ResponseData as Execute; } //fetchMessageAction = new GetMessageAction(dataBus); //fetchMessageAction. DoAction(); ActionUtil.GetFormAndData(dataBus, string.Empty); SetPreferencesAction setPreferencesAction = new SetPreferencesAction(dataBus); response = setPreferencesAction.DoAction(); string setPreferencesMessage = response.GetContent(); SetPreferences setPreferences = setPreferencesAction.ResponseData as SetPreferences; } else { dataBus.Refresh(); dataBus.ThreadId++; } return(dataBus); }