コード例 #1
0
ファイル: MedWatchDAL.cs プロジェクト: rachid1805/str
        public static IEnumerable<IHospitalEvent> FindHospitalEventsAfter( int hospitalId, long afterEventId, int maxEventCount )
        {
            var events = new List<IHospitalEvent>();

            try
            {
                using ( var conn = new SqlConnection( ConnectionString ) )
                {
                    conn.Open();

                    using ( var cmd = new SqlCommand( "HospitalEventSelectCommand", conn ) )
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        var param = new SqlParameter
                        {
                            ParameterName = "@HospitalId",
                            Value = hospitalId,
                            SqlDbType = SqlDbType.Int
                        };
                        cmd.Parameters.Add( param );

                        param = new SqlParameter
                        {
                            ParameterName = "@AfterEventId",
                            Value = afterEventId,
                            SqlDbType = SqlDbType.BigInt
                        };
                        cmd.Parameters.Add( param );

                        param = new SqlParameter
                        {
                            ParameterName = "@MaxEventCount",
                            Value = maxEventCount,
                            SqlDbType = SqlDbType.Int
                        };
                        cmd.Parameters.Add(param);

                        var dr = cmd.ExecuteReader();

                        while ( dr.Read() )
                        {
                            var e = new HospitalEvent
                            {
                                EventId = dr.GetInt64( 0 ),
                                HospitalId = hospitalId,
                                PatiendId = dr.GetInt32( 1 ),
                                EventType = (HospitalEventType) dr.GetInt16( 2 ),
                                EventTime = dr.GetDateTime( 3 ),
                                DiseaseType = dr.IsDBNull( 4 ) ? (DiseaseType?) null : (DiseaseType) dr.GetInt16( 4 ),
                                DoctorId = dr.IsDBNull( 5 ) ? (int?) null : dr.GetInt32( 5 )
                            };

                            events.Add( e );
                        }
                    }

                    conn.Close();
                }
            }
            catch ( Exception ex )
            {
                s_logger.Error( "ERROR: {0}", ex.Message );
            }

            return events;
        }
コード例 #2
0
 private void Publish(HospitalEvent he)
 {
     foreach (var s in _subscriptions)
         s.Tell(he);
 }