当前位置: 首页>>代码示例>>C#>>正文


C# DB.UploadString方法代码示例

本文整理汇总了C#中DB.UploadString方法的典型用法代码示例。如果您正苦于以下问题:C# DB.UploadString方法的具体用法?C# DB.UploadString怎么用?C# DB.UploadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB.UploadString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateRevisionsInDBInternal

		protected override bool UpdateRevisionsInDBInternal (DB db, DBLane lane, string repository,Dictionary<string, DBRevision> revisions, List<DBHost> hosts, List<DBHostLane> hostlanes, string min_revision)
		{
			string revision;
			XmlDocument svn_log;
			bool update_steps = false;
			DBRevision r;
			int min_revision_int = string.IsNullOrEmpty (min_revision) ? 0 : int.Parse (min_revision);
			int max_revision_int = int.MaxValue;
			int current_revision;
			string log;
			XmlNode n;
			XmlAttribute attrib;

			Log ("Updating '{0}'", lane.lane);

			if (min_revision_int == 0 && !string.IsNullOrEmpty (lane.min_revision))
				min_revision_int = int.Parse (lane.min_revision);
			if (!string.IsNullOrEmpty (lane.max_revision))
				max_revision_int = int.Parse (lane.max_revision);

			log = GetSVNLog (lane, repository, min_revision_int, max_revision_int);

			if (string.IsNullOrEmpty (log)) {
				Log ("Didn't get a svn log for '{0}'", repository);
				return false;
			}

			svn_log = new XmlDocument ();
			svn_log.PreserveWhitespace = true;
			svn_log.Load (new StringReader (log));

			foreach (XmlNode node in svn_log.SelectNodes ("/log/logentry")) {
				revision = node.Attributes ["revision"].Value;

				if (revisions.ContainsKey (revision))
					continue;

				try {
					current_revision = int.Parse (revision);
					if (current_revision < min_revision_int || current_revision > max_revision_int)
						continue;
				} catch {
					continue;
				}

				r = new DBRevision ();
				attrib = node.Attributes ["revision"];
				if (attrib == null || string.IsNullOrEmpty (attrib.Value)) {
					Log ("An entry without revision in {0}, skipping entry", repository);
					continue;
				}
				r.revision = attrib.Value;
				r.lane_id = lane.id;

				n = node.SelectSingleNode ("author");
				if (n != null) {
					r.author = n.InnerText;
				} else {
					Log ("No author specified in r{0} in {1}", r.revision, repository);
					r.author = "?";
				}
				n = node.SelectSingleNode ("date");
				if (n != null) {
					DateTime dt;
					if (DateTime.TryParse (n.InnerText, out dt)) {
						r.date = dt;
					} else {
						Log ("Could not parse the date '{0}' in r{1} in {2}", n.InnerText, r.revision, repository);
						r.date = DateTime.MinValue;
					}
				} else {
					Log ("No date specified in r{0} in {1}", r.revision, repository);
					r.date = DateTime.MinValue;
				}
				n = node.SelectSingleNode ("msg");
				if (n != null) {
					r.log_file_id = db.UploadString (n.InnerText, ".log", false).id;
				} else {
					Log ("No msg specified in r{0} in {1}", r.revision, repository);
					r.log_file_id = null;
				}

				r.Save (db);

				update_steps = true;
				Log ("Saved revision '{0}' for lane '{1}'", r.revision, lane.lane);
			}

			return update_steps;
		}
开发者ID:rolfbjarne,项目名称:monkeywrench,代码行数:90,代码来源:SchedulerSVN.cs

示例2: UpdateRevisionsInDBInternal

		protected override bool UpdateRevisionsInDBInternal (DB db, DBLane lane, string repository, Dictionary<string, DBRevision> revisions, List<DBHost> hosts, List<DBHostLane> hostlanes, string min_revision, string max_revision)
		{
			string revision;
			bool update_steps = false;
			List<DateTime> used_dates;
			DBRevision r;
			List<GitEntry> log;

			if (string.IsNullOrEmpty (max_revision))
				max_revision = "remotes/origin/master";

			Log ("Updating lane: '{0}', repository: '{1}' min revision: '{2}' max revision: '{3}'", lane.lane, repository, min_revision, max_revision);

			log = GetGITLog (lane, repository, min_revision, max_revision);

			if (log == null || log.Count == 0) {
				Log ("Didn't get a git log for '{0}'", repository);
				return false;
			}

			Log ("Got {0} log records", log.Count);

			used_dates = new List<DateTime> ();

			foreach (GitEntry entry in log) {
				string hash = entry.revision;
				string unix_timestamp_str = entry.timestamp;
				long unix_timestamp;
				string author = entry.author;
				string msg = entry.message;
				DateTime date;

				if (!long.TryParse (unix_timestamp_str, out unix_timestamp)) {
					/* here something is wrong, this way the commit shows up as the first one so that it's easy to spot and start investigating */
					date = DateTime.Now.AddYears (20);
					Log ("Could not parse timestamp '{0}' for revision '{1}' in lane '{2}' in repository {3}", unix_timestamp_str, entry.revision, lane.lane, repository);
				} else {
					const long EPOCH_DIFF = 0x019DB1DED53E8000; /* 116444736000000000 nsecs */
					const long RATE_DIFF = 10000000; /* 100 nsecs */
					date = DateTime.FromFileTimeUtc ((unix_timestamp * RATE_DIFF) + EPOCH_DIFF);
				}

				/* 
				 * The timestamp resolution on my machine seems to be 1 second,
				 * which means that if you commit fast enough you'll get
				 * commits with the same date. This is a very bad thing since
				 * the commits are order by the commit date, and if two commits
				 * have the same date the order they're build / shown is random
				 * (the db decides whatever it feels like). Work around this by
				 * keeping a list of used dates and if the date has already
				 * used, add a millisecond to it (and try again). Note that
				 * there is still a possibility of duplicate dates: if there
				 * already is a revision in the database with this date (from
				 * a previous run of the scheduler).
				 * 
				 * It may seem like there is a very small possibility of having
				 * two commits within a second, but this happens all the time
				 * for our test suite.
				 */
				while (used_dates.Contains (date)) {
					date = date.AddMilliseconds (1);
				}
				used_dates.Add (date);

				revision = hash;

				if (revision == null)
					continue;

				if (revisions.ContainsKey (revision)) {
					/* Check if we've saved the wrong date earlier and fix it */
					if (revisions [revision].date > new DateTime (2030, 1, 1)) {
						/* Hopefully this code will not stay here for 20 years */
						revisions [revision].date = date;
						revisions [revision].Save (db);
						Log ("Detected wrong date in revision '{0}' in lane '{1}' in repository {2}, fixing it", revision, lane.lane, repository);
				}
					// Log (2, "Already got {0}", revision);
					continue;
				}

				if (!string.IsNullOrEmpty (lane.commit_filter)) {
					FetchFiles (entry, repository);
					if (DoesFilterExclude (entry, lane.commit_filter))
						continue;
				}

				r = new DBRevision ();
				r.revision = revision;
				r.lane_id = lane.id;

				r.author = author;
				if (string.IsNullOrEmpty (r.author)) {
					Log ("No author specified in r{0} in {1}", r.revision, repository);
					r.author = "?";
				}
				r.date = date;
				if (!string.IsNullOrEmpty (msg)) {
					r.log_file_id = db.UploadString (msg, ".log", false).id;
				} else {
//.........这里部分代码省略.........
开发者ID:vargaz,项目名称:monkeywrench,代码行数:101,代码来源:SchedulerGIT.cs

示例3: UpdateSVNDiff

		private static void UpdateSVNDiff (object dummy)
		{
			try {
				Logger.Log ("SVNDiff: Thread started.");
				using (DB db = new DB (true)) {
					using (DB db_save = new DB (true)) {
						using (IDbCommand cmd = db.CreateCommand ()) {
							cmd.CommandText = @"
SELECT Revision.*, Lane.repository, Lane.lane
FROM Revision 
INNER JOIN Lane ON Lane.id = Revision.lane_id 
WHERE (Revision.diff IS NULL OR Revision.diff = '') AND Revision.diff_file_id IS NULL;";
							using (IDataReader reader = cmd.ExecuteReader ()) {
								while (!quit_svn_diff && reader.Read ()) {
									DBRevision revision = new DBRevision (reader);
									string repositories = reader.GetString (reader.GetOrdinal ("repository"));
									string lane = reader.GetString (reader.GetOrdinal ("lane"));
									string diff = null;

									foreach (string repository in repositories.Split (',')) {
										diff = GetSVNDiff (lane, repository, revision.revision);
										if (!string.IsNullOrEmpty (diff))
											break;
									}

									if (string.IsNullOrEmpty (diff))
										diff = "No diff";

									revision.diff_file_id = db_save.UploadString (diff, ".log", false).id;
									revision.Save (db_save);
									Logger.Log ("SVNDiff: Got diff for lane '{0}', revision '{1}'", lane, revision.revision);
								}
							}
						}
					}
				}
				Logger.Log ("SVNDiff: Thread stopping. Done: {0}", !quit_svn_diff);
			} catch (Exception ex) {
				Logger.Log ("SVNDiff: Exception: {0} \n{1}", ex.Message, ex.StackTrace);
			}
		}
开发者ID:rolfbjarne,项目名称:monkeywrench,代码行数:41,代码来源:SchedulerSVN.cs


注:本文中的DB.UploadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。