public static async Task <ResponseMessage> Process2(RequestRawMessageModel requestRawMessageModel) { ResponseMessage responseMessage = new ResponseMessage(); responseMessage.Error = ""; await DataBaseFunctions.InsertDBRunningLog2("Process2: New RawMessage " + requestRawMessageModel.REQUEST_MESSAGE); return(responseMessage); }
private void SettingsBasketball_FormClosing(object sender, FormClosingEventArgs e) { if (!_dbfunc.CheckIfPeriodsComplete(_gamekind_id, (int)nudMaxPeriods.Value)) { int num = (int)MessageBox.Show("Missing period(s) in saved settings!"); } _dbfunc.DeleteUndesiredPeriods(_gamekind_id, (int)nudMaxPeriods.Value); Settings.Default.Save(); _settings_functions.saveParameters((Form)this, _dbfunc, _gamekind_id, _act_period); _dbfunc = (DataBaseFunctions)null; }
private void MaterialFlatButton1_Click(object sender, EventArgs e) { string login = materialSingleLineTextField1.Text; string password = materialSingleLineTextField2.Text; var user = DataBaseFunctions.Auth(login, password); if (user != null) { MainForm form = new MainForm(user); form.Show(); this.Visible = false; } else { MessageBox.Show("Неправильный логин или пароль"); } }
private void _open_form( string Servername, string Databasename, string UserID, string Password, int KindOfgameID, Team Team) { if (Directory.Exists(Settings.Default.LastLogoFolder)) { openFileDialogTeamLogo.InitialDirectory = Settings.Default.LastLogoFolder; } else { Settings.Default.LastLogoFolder = "c:\\"; Settings.Default.Save(); } _servername = Servername; _databasename = Databasename; _password = Password; _user_id = UserID; _dbfunc = new DataBaseFunctions(_servername, _databasename, _user_id, _password); _dbfunc.ConnectDatabase(); _team = Team; if (_team != null) { txtTeamName.Text = _team.TeamName.Trim(); if (_team.TeamLogo != null && _team.TeamLogo.Length > 0) { MemoryStream memoryStream = new MemoryStream(_team.TeamLogo, 0, _team.TeamLogo.Length); pbTeamLogo.Image = (Image) new Bitmap((Stream)memoryStream); memoryStream.Close(); } _players = _dbfunc.ReadPlayersWithImage(_team.TeamID); } else { _team = new Team(); _players = new List <Player>(); } _team.TeamGameKindID = KindOfgameID; ShowPlayers(); btnImportPlayerList.Visible = _show_import_button; }
public BasketballGameData(DataBaseFunctions DbFunctions) { this.DbFunctions = DbFunctions; _game_timer = (ITimeCounter) new DownCounter(nameof(GameTimer)); _game_timer.TimeChanged += new TimeChangedDelegate(_game_timer_TimeChanged); _game_timer.EndTimeReached += new EndTimeReachedDelegate(_game_timer_EndTimeReached); _shot_timer = new DownCounter(nameof(ShotTimer)); _shot_timer.TimeChanged += new TimeChangedDelegate(_shot_timer_TimeChanged); _shot_timer.EndTimeReached += new EndTimeReachedDelegate(_shot_timer_EndTimeReached); _timeout_timer_home = new DownCounter("TimeOutTimerHome"); _timeout_timer_home.TimeChanged += new TimeChangedDelegate(_timeout_timer_home_TimeChanged); _timeout_timer_home.EndTimeReached += new EndTimeReachedDelegate(_timeout_timer_home_EndTimeReached); _timeout_timer_guest = new DownCounter("TimeOutTimerGuest"); _timeout_timer_guest.TimeChanged += new TimeChangedDelegate(_timeout_timer_guest_TimeChanged); _timeout_timer_guest.EndTimeReached += new EndTimeReachedDelegate(_timeout_timer_guest_EndTimeReached); _break_timer = new DownCounter(nameof(BreakTimer)); _break_timer.TimeChanged += new TimeChangedDelegate(_break_timer_TimeChanged); _break_timer.EndTimeReached += new EndTimeReachedDelegate(_break_timer_EndTimeReached); }
public SettingsBasketball( string Servername, string Databasename, string UserID, string Password, int GameKindID) { InitializeComponent(); Settings.Default.Reload(); _servername = Servername; _databasename = Databasename; _user_id = UserID; _password = Password; _gamekind_id = GameKindID; _dbfunc = new DataBaseFunctions(_servername, _databasename, _user_id, _password); _dbfunc.ConnectDatabase(); _act_period = 1; _settings_functions.showParameters((Form)this, _dbfunc, _gamekind_id, _act_period); }
public void saveParameters(Form Source, DataBaseFunctions DbFunc, int GameKindID, int Period) { GameParameter Parameter = (GameParameter)null; foreach (Control control in (ArrangedElementCollection)Source.Controls) { if (control.GetType() != typeof(Label) && control.GetType() != typeof(Button) && control.Name != nameof(Period)) { if (control.GetType() == typeof(NumericUpDown)) { if (control.Tag != null) { try { long int64 = Convert.ToInt64(control.Tag); Parameter = new GameParameter(GameKindID, Period, control.Name, int64); } catch { } } } if (control.GetType() == typeof(CheckBox)) { Parameter = !((CheckBox)control).Checked ? new GameParameter(GameKindID, Period, control.Name, 0L) : new GameParameter(GameKindID, Period, control.Name, 1L); } if (control.GetType() == typeof(RadioButton)) { Parameter = !((RadioButton)control).Checked ? new GameParameter(GameKindID, Period, control.Name, 0L) : new GameParameter(GameKindID, Period, control.Name, 1L); } if (control.GetType() == typeof(ComboBox)) { long selectedIndex = (long)((ListControl)control).SelectedIndex; Parameter = new GameParameter(GameKindID, Period, control.Name, selectedIndex); } if (Parameter != null) { DbFunc.WriteGameParameter(Parameter); } } } }
public static async Task Run([EventHubTrigger("MyAzureFunctionCallSP", Connection = "AzureEventHubConnectionString")] EventData[] events, ILogger log) { var exceptions = new List <Exception>(); /////////////////////Loop thru messages as is////////////////////////////////////////////////// foreach (EventData eventData in events) { var MainMessage = string.Empty; try { string ErrorsInObject = string.Empty; //Get the message from event hub///////////////////////////// string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count); MainMessage = messageBody; /////Temp Logging log to DB as is: await DataBaseFunctions.InsertDBSTRIIMMessages(log, messageBody); //JSON message object collection schema List <RootObject> rootObjectCollection = new List <RootObject>(); // Deserilize to object collection. rootObjectCollection = ConvertMessageToObject(messageBody, ref ErrorsInObject); if (rootObjectCollection != null) { foreach (RootObject rootObject in rootObjectCollection) { // Start the logging collection for every loop as the the logging happens in TPMessageLog ErrorResponseMessages errorResponseMessage = new ErrorResponseMessages(); // serilize the object string JsonString = JsonConvert.SerializeObject(rootObject.data, Formatting.None); ////////////////////////////Alter input message: This is from ProcessTest Test data //////////////////////////// ///////////////THere is a reason to do this, this is helps in proper logging. ///For now this is hardcoded for a specific tagnumber. For message type 1 RequestRawMessageModel requestRawMessageModel = JsonConvert.DeserializeObject <RequestRawMessageModel>(JsonString); RequestMessageModel requestMessageModel = JsonConvert.DeserializeObject <RequestMessageModel>(requestRawMessageModel.REQUEST_MESSAGE); requestMessageModel.TagNumber = "015015018"; requestRawMessageModel.RequestMesssage = requestMessageModel; string ConvertMessage = JsonConvert.SerializeObject(requestRawMessageModel, Formatting.None); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // This does not mean there is error, error object is same as logging. errorResponseMessage.RequestMessage = JsonString; if (ConvertMessage.Length > 0) { // Validate the message string ValidateMessage = StaticClasses.Validate.ValidateRequest(ConvertMessage); if (ValidateMessage == StaticClasses.StaticVars.SUCCESS) { errorResponseMessage.MessageValidation = "True"; //ALL MAIN PROCESS HAPPENS HERE/////////////////////////////////////////////////////////// ResponseMessage ResponseJSON = await TranscoreProcess.Process(requestRawMessageModel);/// //////////////////////////////////////////////////////////////////////////////////////// errorResponseMessage.ResponseMessage = ResponseJSON.JSONMessage; if (ResponseJSON.Error.Length > 0) { errorResponseMessage.MessageProcessStatus = false; errorResponseMessage.ErrorResponseMessage = errorResponseMessage.ErrorResponseMessage + " | " + ResponseJSON.Error; } else { //SEND TO RABBITMQ SendToQueue(ResponseJSON.JSONMessage, errorResponseMessage); } } else { errorResponseMessage.MessageValidation = "False"; log.LogInformation($"Invalid Message"); } } else { log.LogInformation($"Message Length is ZERO: {ConvertMessage}"); } string jsonMessageError = JsonConvert.SerializeObject(errorResponseMessage, Formatting.None); await DataBaseFunctions.InsertDB(requestRawMessageModel.CRM_REQUEST_ID, requestRawMessageModel.REQUEST_TYPE, jsonMessageError, errorResponseMessage.ResponseMessage, errorResponseMessage.RequestMessage, errorResponseMessage.ErrorResponseMessage); } // await InsertDB(log,0,jsonMessageError, "Success", "OutMessage"); log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}"); await Task.Yield(); } else { } } catch (Exception e) { await DataBaseFunctions.InsertDB(9999, 0, MainMessage, "", "", "Invalid Message"); // We need to keep processing the rest of the batch - capture this exception and continue. // Also, consider capturing details of the message that failed processing so it can be processed again later. exceptions.Add(e); } } // Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure. if (exceptions.Count > 1) { throw new AggregateException(exceptions); } if (exceptions.Count == 1) { throw exceptions.Single(); } }
public void showParameters(Form Target, DataBaseFunctions DbFunc, int GameKindID, int Period) { GameParameter[] gameParameterArray = DbFunc.GameParameter(GameKindID, Period); if (gameParameterArray == null) { return; } Hashtable hashtable = new Hashtable(); for (int index = 0; index < gameParameterArray.Length; ++index) { hashtable.Add((object)gameParameterArray[index].ParameterName.Trim(), (object)gameParameterArray[index]); } foreach (Control control in (ArrangedElementCollection)Target.Controls) { if (hashtable.Contains((object)control.Name)) { if (control.GetType() == typeof(ComboBox)) { ((ListControl)control).SelectedIndex = Convert.ToInt32(((GameParameter)hashtable[(object)control.Name]).ParameterIntValue); } if (control.GetType() == typeof(CheckBox)) { ((CheckBox)control).Checked = ((GameParameter)hashtable[(object)control.Name]).ParameterIntValue > 0L; } if (control.GetType() == typeof(RadioButton)) { ((RadioButton)control).Checked = ((GameParameter)hashtable[(object)control.Name]).ParameterIntValue > 0L; } if (control.GetType() == typeof(NumericUpDown)) { if (((NumericUpDown)control).Minimum < new Decimal(1)) { ((NumericUpDown)control).Value = new Decimal(0); } else { ((NumericUpDown)control).Value = new Decimal(1); } Decimal num = Convert.ToDecimal(((GameParameter)hashtable[(object)control.Name]).ParameterIntValue); string upper = control.Name.ToUpper(); if (upper.Contains("TIME") && !upper.Contains("TIMEOUTS") && (!upper.Contains("SCORE") && !upper.Contains("BREAKTIME"))) { num /= new Decimal(1000); if ((!upper.Contains("PENALTY") || GameKindID != 4) && num > new Decimal(90)) { num /= new Decimal(60); } } else if (upper.Contains("BREAKTIME")) { if (GameKindID == 1) { num /= new Decimal(1000); } else { num /= new Decimal(1000); if (num > new Decimal(59)) { num /= new Decimal(60); } } } ((NumericUpDown)control).Value = num; } } } }