Beispiel #1
0
		protected override int InsertMaster (IDbConnection cnc, State state)
		{
			IDbCommand cmd = cnc.CreateCommand ();
			cmd.CommandText = "insert_master";
			cmd.CommandType = CommandType.StoredProcedure;
			AddParameter (cmd, "reference", state.Reference);
			AddParameter (cmd, "profile", state.Profile);
			AddParameter (cmd, "assembly", state.Assembly);
			AddParameter (cmd, "detail_level", state.DetailLevel);
			AddParameter (cmd, "last_updated", state.AssemblyLastWrite);
			IDataParameter p = AddOutputParameter (cmd, "id");
			cmd.ExecuteNonQuery ();
			return Convert.ToInt32 (p.Value);
		}
 public void InsertRoot(State state)
 {
     using (IDbConnection cnc = GetConnection ()) {
         state.MasterId = InsertMaster (cnc, state);
         using (state.NodesWriter = new StreamWriter (state.NodesFileName)) {
             using (state.MessagesWriter = new StreamWriter (state.MessagesFileName)) {
                 InsertTree (cnc, state, state.Root, null, 0);
             }
         }
         LoadFile (cnc, "nodes", state.NodesFileName);
         LoadFile (cnc, "messages", state.MessagesFileName);
         File.Delete (state.NodesFileName);
         File.Delete (state.MessagesFileName);
         EnableNewMaster (cnc, state.MasterId);
     }
     DeleteInactive (state);
 }
        protected virtual void InsertTree(IDbConnection cnc, State state, ComparisonNode node, string base_name, int node_id)
        {
            StringBuilder sb = new StringBuilder ();
            string node_name = GetNodeName (base_name, node_id);
            AppendValue (sb, node_name); // node_name
            AppendValue (sb, state.MasterId); // master_id
            AppendValue (sb, node_id); // child_id
            AppendValue (sb, base_name == null ? "-" : base_name); // parent_name
            AppendValue (sb, (int) node.Type); // comparison_type
            AppendValue (sb, (int) node.Status); // status
            AppendValue (sb, node.Extra); // extras
            AppendValue (sb, node.Missing); // missing
            AppendValue (sb, node.Present); // present
            AppendValue (sb, node.Warning); // warning
            AppendValue (sb, node.Todo); // todo
            AppendValue (sb, node.Niex); // niex
            AppendValue (sb, node.ThrowsNIE); // throwsnie
            AppendValue (sb, node.Children.Count > 0); // has_children
            AppendValue (sb, node.Messages.Count > 0 || node.Todos.Count > 0); // has_messages
            AppendValue (sb, node.Name); // name
            AppendValue (sb, node.TypeName); // typename
            sb.Length--; // remove trailing \t
            state.NodesWriter.WriteLine (sb);

            InsertMessages (state, node_name, node.Messages, false);
            InsertMessages (state, node_name, node.Todos, true);
            int counter = 0;
            foreach (ComparisonNode n in node.Children) {
                InsertTree (cnc, state, n, node_name, counter);
                counter++;
            }
        }
        protected virtual void InsertMessages(State state, string node_name, List<string> strs, bool is_todo)
        {
            if (strs == null || strs.Count == 0)
                return;

            StringBuilder sb = new StringBuilder ();
            foreach (string s in strs) {
                sb.AppendFormat ("\\N\t{0}\t{1}\t{2}\t{3}", node_name, state.MasterId, (is_todo) ? (char) 1 : (char) 0, FormatString (s));
                state.MessagesWriter.WriteLine (sb);
                sb.Length = 0;
            }
        }
 protected abstract int InsertMaster(IDbConnection cnc, State state);
 protected virtual void DeleteInactive(State state)
 {
     using (IDbConnection cnc = GetConnection ()) {
         IDbCommand cmd = cnc.CreateCommand ();
         cmd.CommandText = String.Format (
             "SELECT id FROM master WHERE active = FALSE AND reference = {0} AND profile = {1} AND assembly = {2}",
                 GetParameterNameForQuery ("reference"),
                 GetParameterNameForQuery ("profile"),
                 GetParameterNameForQuery ("assembly"));
         AddParameter (cmd, "reference", state.Reference);
         AddParameter (cmd, "profile", state.Profile);
         AddParameter (cmd, "assembly", state.Assembly);
         List<int> ids = new List<int> ();
         using (IDataReader reader = cmd.ExecuteReader ()) {
             while (reader.Read ()) {
                 ids.Add (Convert.ToInt32 (reader [0]));
             }
         }
         CleanupTables (cnc, ids);
     }
 }
Beispiel #7
0
		static void CreateWorkItems (string [] compares, List<string> include_list)
		{
			foreach (string str in compares) {
				string [] s = str.Split ();
				string reference = s [0];
				string profile = s [1];
				string mpath = "../masterinfos/" + reference;
				string bpath = "../binary/" + profile;
				if (!Directory.Exists (mpath))
					continue;

				if (!Directory.Exists (bpath))
					continue;
			
				var infos = from p in Directory.GetFiles (mpath)
					select Path.GetFileNameWithoutExtension (p);

				var dlls  = from p in Directory.GetFiles (bpath)
					select Path.GetFileNameWithoutExtension (p);

				foreach (var assembly in (from p in infos.Intersect (dlls) orderby p select p)) {
					if (include_list.Count > 0 && include_list.IndexOf (assembly) == -1)
						continue;
					string info_file = Path.Combine (mpath, assembly + ".xml");
					string dll_file = Path.Combine (bpath, assembly + ".dll");
					State state = new State (reference, profile, assembly, info_file, dll_file);
					work_items.Add (state);
				}
			}
		}