Example #1
0
        public void ChangeAlarmAsync(StaticValuesDll.AlarmList alarm, Action <bool, Exception> continueWith)
        {
            var asyncAction = new Action(() =>
            {
                try
                {
                    using (var serviceChannel = new ChannelFactory <IWaterGateService>(CreateBinding(), new EndpointAddress(_address)))
                    {
                        var channel = serviceChannel.CreateChannel();

                        bool result;
                        using (var contextScope = new OperationContextScope((IContextChannel)channel))
                        {
                            OperationContext.Current.OutgoingMessageHeaders.Add(_userHeader);
                            result = channel.ChangeAlarm(alarm);
                        }

                        continueWith(result, null);
                    }
                }
                catch (Exception e)
                {
                    LogConnectionFailed();
                    continueWith(false, e);
                }
            });

            asyncAction.BeginInvoke(null, null);
        }
Example #2
0
        public bool ChangeAlarm(StaticValuesDll.AlarmList alarm)
        {
            LockSlim.TryEnterWriteLock(-1);

            try
            {
                using (var connection = new SQLiteConnection(_connectionString))
                {
                    connection.Open();



                    using (var command = new SQLiteCommand("UPDATE AlarmList SET Execute=@Execute WHERE Id=@id AND Name=@name", connection))
                    {
                        command.Parameters.Add("@Execute", DbType.Int32).Value = alarm.Execute;
                        command.Parameters.Add("@id", DbType.Int32).Value      = alarm.Id;
                        command.Parameters.Add("@name", DbType.String).Value   = alarm.Name;

                        command.ExecuteNonQuery();
                    }


                    return(true);
                }
            }
            catch

            {
                return(false);
            }
            finally
            {
                LockSlim.ExitWriteLock();
            }
        }
Example #3
0
        public bool ChangeAlarm(StaticValuesDll.AlarmList alarm)
        {
            var result = _repository.ChangeAlarm(alarm);

            ClientLogService.Write(CurrentUser, "Обновление списка аварий", "Авария" + alarm.Name + "добавлена в список на блокировку канала");

            return(result);
        }