Beispiel #1
0
 public void Publish(List <Occurrence> occurrences)
 {
     using (TextWriter writer = new StreamWriter(@"d:\temp\integri\index.txt"))
     {
         foreach (Occurrence o in occurrences)
         {
             if (o.PublicObject.Type == ObjectType.Event)
             {
                 EventOccurence e = o as EventOccurence;
                 writer.WriteLine(@"""{0}"",""{1}"",""{2}"",""{3}"",""{4}""", o.PublicObject.MciFile, o.PublicObject.Type, o.PublicObject.Name, e.ProgramName, e.IsRaised ? "Raised" : "Handled");
             }
         }
     }
 }
Beispiel #2
0
        private void PublishIndex(IEnumerable <Occurrence> occurrences)
        {
            int           rowCount = 0;
            StringBuilder sql      = new StringBuilder("");

            foreach (Occurrence o in occurrences)
            {
                if (o.PublicObject.Type == ObjectType.Event)
                {
                    if (rowCount == 1000)
                    {
                        Log.InfoFormat("Publishing {0} rows ...", rowCount);
                        sql.Insert(0, @"INSERT INTO Public_Object_Index VALUES ");
                        SqlCommand command = new SqlCommand(sql.ToString(0, sql.Length - 1), Connection);
                        command.ExecuteNonQuery();
                        sql.Clear();
                        rowCount = 0;
                    }

                    EventOccurence e = (EventOccurence)o;
                    sql.AppendFormat("('{0}','{1}','{2}','{3}','{4}'),",
                                     o.PublicObject.MciFile,
                                     o.PublicObject.Type,
                                     o.PublicObject.Name,
                                     e.Project.Name,
                                     e.ProgramName + " - " + (e.IsRaised ? "Raised" : "Handled"));

                    rowCount++;
                }
            }

            if (rowCount > 0)
            {
                Log.InfoFormat("Publishing last {0} remaining rows ...", rowCount);
                sql.Insert(0, @"INSERT INTO Public_Object_Index VALUES ");
                SqlCommand command = new SqlCommand(sql.ToString(0, sql.Length - 1), Connection);
                command.ExecuteNonQuery();
            }
        }