コード例 #1
0
 public void SetLogger(ILoggable logger)
 {
     if (logger == null)
     {
         _log.Warn("Can't set logger. Logger instance equals null.");
         throw new ArgumentNullException();
     }
     _log = new LogAdapter(logger);
 }
コード例 #2
0
        static void Main(string[] args)
        {
            IClienteLog clienteLog = new LogAdapter();

            try
            {
                Console.Write("Digite el número a convertir...");
                var cadena = Console.ReadLine();
                var numero = Convert.ToInt16(cadena);
            }
            catch (Exception ex)
            {
                Console.Write(clienteLog.GuardarErrorLog(ex.Message, "2"));
                Console.ReadLine();
            }
        }
コード例 #3
0
        public static WriterDelegate ConnectionOpen(string vhost, string caps, bool insist)
        {
            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> ConnectionOpen");
                }

                writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, (w) =>
                {
                    w.WriteUShort(classId);
                    w.WriteUShort(methodId);

                    w.WriteShortstr(vhost);
                    w.WriteShortstr(caps);
                    w.WriteBit(insist);
                });
            });
        }
コード例 #4
0
        public static WriterDelegate ExchangeDelete(string exchange, bool waitConfirmation)
        {
            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> ExchangeDelete " + exchange);
                }

                writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, w =>
                {
                    w.WriteUShort(classId);
                    w.WriteUShort(methodId);

                    w.WriteUShort(0);                     // reserved
                    w.WriteShortstr(exchange);
                    w.WriteBits(false, !waitConfirmation);
                });
            });
        }
コード例 #5
0
        public static DataTable Query(string strSql)
        {
            SqlConnection conn  = ConnectionPool.BorrowConnection();
            DataTable     dtRet = null;

            try
            {
                dtRet = SqlHelper.ExecuteDataTable(conn, CommandType.Text, strSql);
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw ex;
            }
            finally
            {
                ConnectionPool.ReturnConnection(conn);
            }
            return(dtRet);
        }
コード例 #6
0
        internal static void InternalBasicAck(AmqpPrimitivesWriter writer, ushort channel, ushort classId, ushort methodId, object args)
        {
            var b_args = args as FrameParameters.BasicAckArgs;

            if (LogAdapter.ProtocolLevelLogEnabled)
            {
                LogAdapter.LogDebug(LogSource, "> BasicAck : " + b_args.deliveryTag);
            }

            {
                uint payloadSize = (uint)(8 + 5);

                writer.WriteFrameStart(AmqpConstants.FrameMethod, channel, payloadSize, classId, methodId);

                writer.WriteULong(b_args.deliveryTag);
                writer.WriteBit(b_args.multiple);

                writer.WriteOctet(AmqpConstants.FrameEnd);
            };
        }
コード例 #7
0
        public static WriterDelegate BasicQos(uint prefetchSize, ushort prefetchCount, bool global)
        {
            const int payloadSize = 11;

            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> BasicQos : prefetch " + prefetchCount);
                }

                writer.WriteFrameStart(AmqpConstants.FrameMethod, channel, payloadSize, classId, methodId);

                writer.WriteLong(prefetchSize);
                writer.WriteUShort(prefetchCount);
                writer.WriteBit(global);

                writer.WriteOctet(AmqpConstants.FrameEnd);
            });
        }
コード例 #8
0
        public static void ChannelClose(AmqpPrimitivesWriter writer, ushort channel, ushort classId, ushort methodId, object args)
        {
            var closeArgs = (FrameParameters.CloseParams)args;

            writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, (w) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> ChannelClose " + channel);
                }

                w.WriteUShort(classId);
                w.WriteUShort(methodId);

                w.WriteUShort(closeArgs.replyCode);
                w.WriteShortstr(closeArgs.replyText);
                w.WriteUShort(classId);
                w.WriteUShort(methodId);
            });
        }
コード例 #9
0
        public static WriterDelegate ConnectionTuneOk(ushort channelMax, uint frameMax, ushort heartbeat)
        {
            const int payloadSize = 12;             // 4 shorts + 1 int

            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> ConnectionTuneOk");
                }

                writer.WriteFrameStart(AmqpConstants.FrameMethod, 0, payloadSize, 10, 31);

                writer.WriteUShort(channelMax);
                writer.WriteLong(frameMax);
                writer.WriteUShort(heartbeat);

                writer.WriteOctet(AmqpConstants.FrameEnd);
            });
        }
コード例 #10
0
        public int AddInventory(OperLog operLog, Entity.Inventory inv)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    //inv.cndSDate = dtSysTime;
                    inv.cnvcCreatePerson = operLog.cnvcOperID;
                    inv.cndModifyDate    = dtSysTime;
                    EntityMapping.Create(inv, trans);
                    SyncGoods(inv, trans);
                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "存货编码:" + inv.cnvcInvCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
コード例 #11
0
ファイル: VCustInfoFacade.cs プロジェクト: zhenghua75/VIPCust
        public static void UpdateVisit(Visit newvisit, Oper oper)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    DateTime dtSysTime = Helper.GetSysTime(trans);
                    newvisit.cndOperDate = dtSysTime;
                    EntityMapping.Update(newvisit, trans);

                    BusiLog busiLog = new BusiLog();
                    busiLog.cndOperDate     = dtSysTime;
                    busiLog.cnnBusiSerialNo = Helper.GetSerialNo(trans);
                    busiLog.cnvcComments    = "修改拜访记录";
                    busiLog.cnvcFuncCode    = " 拜访跟踪";
                    busiLog.cnvcOperID      = oper.cnvcOperID;
                    busiLog.cnvcIPAddress   = "";
                    EntityMapping.Create(busiLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #12
0
        public static DataTable GetOneOperFuncList(string strOperID)
        {
            DataTable dtRet = null;

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                dtRet = auth.GetOneOperFuncList(strOperID);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }
            return(dtRet);
        }
コード例 #13
0
        public static Oper GetOper(Oper oper)
        {
            Oper OldOper = null;

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                OldOper = auth.GetOper(oper);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }
            return(OldOper);
        }
コード例 #14
0
        public async Task Apply(Channel channel, IDictionary <string, string> reservedNamesMapping)
        {
            var queueNameToUse =
                _queue.StartsWith(AmqpConstants.AmqpReservedPrefix, StringComparison.Ordinal) ? reservedNamesMapping[_queue] : _queue;

            if (LogAdapter.ExtendedLogEnabled)
            {
                LogAdapter.LogDebug("Recovery", "Recovering consumer " + _consumerTag + " for queue " + queueNameToUse);
            }

            if (_consumer2 != null)
            {
                await channel.BasicConsume(_mode, _consumer2, queueNameToUse, _consumerTag, _withoutAcks, _exclusive, _arguments, waitConfirmation : true).ConfigureAwait(false);

                _consumer2.Recovered();

                return;
            }

            await channel.BasicConsume(_mode, _consumer, queueNameToUse, _consumerTag, _withoutAcks, _exclusive, _arguments, waitConfirmation : true).ConfigureAwait(false);
        }
コード例 #15
0
        public static int DeleteOperFunc(OperFunc operFunc, BusiLog busiLog)
        {
            int ret = 0;

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                ret = auth.DeleteOperFunc(operFunc, busiLog);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }
            return(ret);
        }
コード例 #16
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }
            _disposed = true;

            if (LogAdapter.ExtendedLogEnabled)
            {
                LogAdapter.LogDebug(LogSource, "Dispose called");
            }

            _recoveryCancellationTokenSource.Cancel();

            _disableRecovery = true;

            _connection.Dispose();

            // not disposing _recoveryCancellationTokenSource. for now leaving for finalizer
        }
コード例 #17
0
        public static string GetDeptID(string strParentDeptID)
        {
            string strDeptID = "";

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                strDeptID = auth.GetDeptID(strParentDeptID);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }
            return(strDeptID);
        }
コード例 #18
0
        public static int AddOilPrice(OilPrice price, BusiLog busiLog)
        {
            int ret = 0;

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                ret = auth.AddOilPrice(price, busiLog);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }
            return(ret);
        }
コード例 #19
0
        public static Dept GetDept(Dept dept)
        {
            Dept retDept = null;

            try
            {
                BusinessRules.SysManage.Authorization auth = new BusinessRules.SysManage.Authorization();
                retDept = auth.GetDept(dept);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }

            return(retDept);
        }
コード例 #20
0
        //获取部门列表
        public static DataTable CommonQuery(string strSql)
        {
            DataTable dtRet = null;

            try
            {
                ReportQuery report = new ReportQuery();
                dtRet = report.CommonQuery(strSql);
            }
            catch (SqlException sex)
            {
                LogAdapter.WriteDatabaseException(sex);
                throw new Exception("数据库访问异常。");
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw new Exception("业务规则层异常。");
            }

            return(dtRet);
        }
コード例 #21
0
        internal RecoveryAction NotifyAbruptClose(Exception reason)
        {
            if (_disableRecovery)
            {
                if (LogAdapter.IsDebugEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "NotifyAbrupt skipping action since disconect was initiated by the user", reason);
                }
                return(RecoveryAction.NoAction);
            }

            // TODO: Block RecoveryChannels? So new operations are blocked. also should fire notifications to indicate recovery in progress

            if (LogAdapter.IsDebugEnabled)
            {
                LogAdapter.LogDebug(LogSource, "NotifyAbrupt", reason);
            }

            TryInitiateRecovery();

            return(RecoveryAction.WillReconnect);
        }
コード例 #22
0
        //		public DataTable GetMaterials(string strMaterialCode,string strMaterialName)
        //		{
        //			SqlConnection conn = ConnectionPool.BorrowConnection();
        //			DataTable dtRet = null;
        //			try
        //			{
        //				dtRet = MaterialAccess.GetAllMaterial(conn,strMaterialCode,strMaterialName);
        //			}
        //			catch(Exception ex)
        //			{
        //				LogAdapter.WriteFeaturesException(ex);
        //			}
        //			finally
        //			{
        //				ConnectionPool.ReturnConnection(conn);
        //			}
        //			return dtRet;
        //		}

        public void AddMaterial(Material material, OperLog operLog)//,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    material.IsUse = true;
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "原料材料编码:" + material.cnvcMaterialCode;
                    EntityMapping.Create(operLog, trans);

                    EntityMapping.Create(material, trans);
                    //EntityMapping.Create(busiLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #23
0
ファイル: BookFacade.cs プロジェクト: zhenghua75/AMSCenter
        public void AddBook(Book book, OperLog operLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    book.cndPublishDate = dtSysTime;
                    long ibook = EntityMapping.Create(book, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "留言本流水号:" + ibook.ToString();
                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #24
0
        public int AddWareHouse(OperLog operLog, Entity.Warehouse wh)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    EntityMapping.Create(wh, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "仓库编码:" + wh.cnvcWhCode;
                    EntityMapping.Create(operLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    return(-1);
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    return(-1);
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
                return(1);
            }
        }
コード例 #25
0
ファイル: OrderFacade.cs プロジェクト: zhenghua75/AMSCenter2
        //订单删除产品
        public void DeleteDetail(OrderBookDetail detail, OperLog operLog)       //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    EntityMapping.Delete(detail, trans);

                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "订单流水:" + detail.cnnOrderSerialNo.ToString() + ",产品编码:" + detail.cnvcInvCode;
                    EntityMapping.Create(operLog, trans);
                    //EntityMapping.Create(busiLog, trans);
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #26
0
        public void UpdateMaterial(Material mat, string strOldMaterialCode, OperLog operLog)//,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "原料材料编码:" + mat.cnvcMaterialCode;
                    EntityMapping.Create(operLog, trans);

                    MaterialAccess.UpdateMaterial(trans, mat, strOldMaterialCode);
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "Update tbProvider set cnvcProductName='" + mat.cnvcMaterialName + "' where cnvcProductCode='" + mat.cnvcMaterialCode + "' and cnvcProductName<>'" + mat.cnvcMaterialName + "'");
                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #27
0
        private Task __SendGreeting()
        {
            if (LogAdapter.ProtocolLevelLogEnabled)
            {
                LogAdapter.LogDebug("ConnectionIO", "__SendGreeting >");
            }

            var tcs = new TaskCompletionSource <bool>();

            SendCommand(0, 0, 0,
                        AmqpConnectionFrameWriter.Greeting(),
                        reply: (channel, classMethodId, _) =>
            {
                if (classMethodId == AmqpClassMethodConnectionLevelConstants.ConnectionStart)
                {
                    _frameReader.Read_ConnectionStart((versionMajor, versionMinor, serverProperties, mechanisms, locales) =>
                    {
                        this.ServerProperties = serverProperties;
                        this.AuthMechanisms   = mechanisms;

                        if (LogAdapter.ProtocolLevelLogEnabled)
                        {
                            LogAdapter.LogDebug("ConnectionIO", "__SendGreeting completed");
                        }

                        tcs.SetResult(true);
                    });
                }
                else
                {
                    // Unexpected
                    tcs.SetException(new Exception("Unexpected result. Got " + classMethodId));
                }
                return(Task.CompletedTask);
            }, expectsReply: true);

            return(tcs.Task);
        }
コード例 #28
0
ファイル: Helper.cs プロジェクト: zhenghua75/CMSM2
        public static DataTable QueryLongTrans(string strSql, bool IsCenter)
        {
            ConnectionPool.IsCenter = IsCenter;
            SqlConnection conn  = ConnectionPool.BorrowConnection();
            DataTable     dtRet = null;

            try
            {
                //conn.ConnectionTimeout = 300;
                //SqlHelper.
                dtRet = SqlHelper.ExecuteDataTableLongTrans(conn, CommandType.Text, strSql);
            }
            catch (Exception ex)
            {
                LogAdapter.WriteFeaturesException(ex);
                throw ex;
            }
            finally
            {
                ConnectionPool.ReturnConnection(conn);
            }
            return(dtRet);
        }
コード例 #29
0
        public static WriterDelegate BasicConsume(string queue, string consumerTag,
                                                  bool withoutAcks, bool exclusive, IDictionary <string, object> arguments, bool waitConfirmation)
        {
            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> BasicConsume " + queue);
                }

                writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, w =>
                {
                    w.WriteUShort(classId);
                    w.WriteUShort(methodId);

                    w.WriteUShort(0);
                    w.WriteShortstr(queue);
                    w.WriteShortstr(consumerTag);
                    w.WriteBits(false, withoutAcks, exclusive, !waitConfirmation);
                    w.WriteTable(arguments);
                });
            });
        }
コード例 #30
0
        public static WriterDelegate QueueDeclare(string queue, bool passive, bool durable, bool exclusive,
                                                  bool autoDelete, IDictionary <string, object> arguments, bool waitConfirmation)
        {
            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    var logQueueName = string.IsNullOrEmpty(queue) ? "*temp*" : queue;
                    LogAdapter.LogDebug(LogSource, "> QueueDeclare " + logQueueName);
                }

                writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, w =>
                {
                    w.WriteUShort(classId);
                    w.WriteUShort(methodId);

                    w.WriteUShort(0);
                    w.WriteShortstr(queue);
                    w.WriteBits(passive, durable, exclusive, autoDelete, !waitConfirmation);
                    w.WriteTable(arguments);
                });
            });
        }
コード例 #31
0
        public static WriterDelegate QueueUnbind(string queue, string exchange, string routingKey,
                                                 IDictionary <string, object> arguments)
        {
            return((writer, channel, classId, methodId, args) =>
            {
                if (LogAdapter.ProtocolLevelLogEnabled)
                {
                    LogAdapter.LogDebug(LogSource, "> QueueUnbind " + queue);
                }

                writer.WriteFrameWithPayloadFirst(AmqpConstants.FrameMethod, channel, w =>
                {
                    w.WriteUShort(classId);
                    w.WriteUShort(methodId);

                    w.WriteUShort(0);                     // reserved
                    w.WriteShortstr(queue);
                    w.WriteShortstr(exchange);
                    w.WriteShortstr(routingKey);
                    w.WriteTable(arguments);
                });
            });
        }
コード例 #32
0
        // Run on its own thread, and invokes user code from it
        private void ReadFramesLoop()
        {
            if (LogAdapter.IsDebugEnabled)
            {
                LogAdapter.LogDebug(LogSource, "ReadFramesLoop starting");
            }

            _readThreadRunning = true;

            try
            {
                var token = _threadCancelToken;

                while (!token.IsCancellationRequested)
                {
                    _frameReader.ReadAndDispatch();
                }

                LogAdapter.LogError(LogSource, "ReadFramesLoop exiting");
            }
            catch (ThreadAbortException)
            {
                // no-op
            }
            catch (Exception ex)
            {
                LogAdapter.LogError(LogSource, "ReadFramesLoop error", ex);

                this.InitiateAbruptClose(ex).IntentionallyNotAwaited();
            }
            finally
            {
                _readThreadRunning = false;

                TryTriggerClean();
            }
        }
コード例 #33
0
 public BookListService()
 {
     _books = new List<Book>();
     _log = new LogAdapter(new NLogger());
     _log.Initialize();
 }
コード例 #34
0
        public void SimpleCoverage()
        {
            var innerMessage = "";

            var inner = new TestLogger();
            var adapter = new LogAdapter(inner);
            inner.MethodCalled += (s, e) =>
            {
                innerMessage = e.Message;
            };
            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            Assert.AreEqual("Debug(object message)", innerMessage);



            // Debug Object, Exception
            adapter.Debug(obj, exception);
            Assert.AreEqual("Debug(object message, Exception exception)", innerMessage);





            // Error Object
            adapter.Error(obj);
            Assert.AreEqual("Error(object message)", innerMessage);

            // Error Object, Exception
            adapter.Error(obj, exception);
            Assert.AreEqual("Error(object message, Exception exception)", innerMessage);





            // Fatal Object
            adapter.Fatal(obj);
            Assert.AreEqual("Fatal(object message)", innerMessage);

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            Assert.AreEqual("Fatal(object message, Exception exception)", innerMessage);







            // Info Object
            adapter.Info(obj);
            Assert.AreEqual("Info(object message)", innerMessage);

            // Info Object, Exception
            adapter.Info(obj, exception);
            Assert.AreEqual("Info(object message, Exception exception)", innerMessage);



            // Trace Object
            adapter.Trace(obj);
            Assert.AreEqual("Trace(object message)", innerMessage);

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            Assert.AreEqual("Trace(object message, Exception exception)", innerMessage);


            



            // Warn Object
            adapter.Warn(obj);
            Assert.AreEqual("Warn(object message)", innerMessage);

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            Assert.AreEqual("Warn(object message, Exception exception)", innerMessage);



        }
コード例 #35
0
        public void MockedCoverage()
        {

            var inner = MockRepository.GenerateMock<TestLogger>();


            var adapter = new LogAdapter(inner);

            var obj = new object();
            const string format = "{0}";
            var formatProvider = CultureInfo.InvariantCulture;
            var exception = new Exception();

            // we are going to call methods on the adapter and verify that the
            // reciprocal methods are called on the inner logger instance


            // Debug Object
            adapter.Debug(obj);
            inner.AssertWasCalled(i => i.Debug(obj));


            // Debug Object, Exception
            adapter.Debug(obj, exception);
            inner.AssertWasCalled(i => i.Debug(obj, exception));


 
            // Error Object
            adapter.Error(obj);
            inner.AssertWasCalled(i => i.Error(obj));

            // Error Object, Exception
            adapter.Error(obj, exception);
            inner.AssertWasCalled(i => i.Error(obj, exception));

 


            // Fatal Object
            adapter.Fatal(obj);
            inner.AssertWasCalled(i => i.Fatal(obj));

            // Fatal Object, Exception
            adapter.Fatal(obj, exception);
            inner.AssertWasCalled(i => i.Fatal(obj, exception));

 




            // Info Object
            adapter.Info(obj);
            inner.AssertWasCalled(i => i.Info(obj));

            // Info Object, Exception
            adapter.Info(obj, exception);
            inner.AssertWasCalled(i => i.Info(obj, exception));

 


            // Trace Object
            adapter.Trace(obj);
            inner.AssertWasCalled(i => i.Trace(obj));

            // Trace Object, Exception
            adapter.Trace(obj, exception);
            inner.AssertWasCalled(i => i.Trace(obj, exception));

      



            // Warn Object
            adapter.Warn(obj);
            inner.AssertWasCalled(i => i.Warn(obj));

            // Warn Object, Exception
            adapter.Warn(obj, exception);
            inner.AssertWasCalled(i => i.Warn(obj, exception));

 
            
        }
コード例 #36
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Get employee
            EmployeeNumber= Intent.GetStringExtra("EmployeeNumber");
            selectedEmployee = EmployeeManagement.GetInstance().Employees.Where(L => L.Number == EmployeeNumber).FirstOrDefault();
            if (selectedEmployee == null) return;

            // Set up Listview
            SetContentView(Resource.Layout.CheckLogMaster);
            LogAdapter = new LogAdapter(this, selectedEmployee);
            listView = FindViewById<ListView>(Resource.Id.checklogs);
            listView.Adapter = LogAdapter;

            var LogName = this.FindViewById<TextView>(Resource.Id.NameForLog);
            LogName.Text = selectedEmployee.Name.ToString();

            var TotalHours = this.FindViewById<TextView>(Resource.Id.TotalHour);
            TotalHours.Text = "Total Hours: " + selectedEmployee.TotalHours;

            //editButton = this.FindViewById<Button>(Resource.Id.EditButton);
            addTimeButton = this.FindViewById<Button>(Resource.Id.AddTimeButton);

            //editButton.Click += EditButton_Click;
            addTimeButton.Click += AddTimeButton_Click;
            listView.SetOnTouchListener(this);

            // Gestures
            gestureDetector = new GestureDetector(this);
            listView.SetOnTouchListener(this);

            var _message = this.FindViewById<TextView>(Resource.Id.message);
            _message.Text = (selectedEmployee.Logs.Count == 0)?"There are no Transactions":"";
        }