Пример #1
0
        public void Commit(Photo [] items)
        {
            uint timer = Log.DebugTimerStart();
            // Only use a transaction for multiple saves. Avoids recursive transactions.

            // TODO.
            bool use_transactions = true;             //!Database.InTransaction && items.Length > 1;

            //if (use_transactions)
            //      Database.BeginTransaction ();

            // FIXME: this hack is used, because HyenaSqliteConnection does not support
            // the InTransaction propery
            try {
                Database.BeginTransaction();
            } catch {
                use_transactions = false;
            }

            var changes = new PhotosChanges();

            foreach (DbItem item in items)
            {
                changes |= Update((Photo)item);
            }

            if (use_transactions)
            {
                Database.CommitTransaction();
            }

            EmitChanged(items, new PhotoEventArgs(items, changes));
            Log.DebugTimerPrint(timer, "Commit took {0}");
        }
Пример #2
0
        public static PhotosChanges operator |(PhotosChanges c1, PhotosChanges c2)
        {
            PhotosChanges changes = new PhotosChanges();

            changes.changes         = c1.changes | c2.changes;
            changes.VersionsChanged = c1.VersionsChanged || c2.VersionsChanged;
            changes.TagsChanged     = c1.TagsChanged || c2.TagsChanged;
            return(changes);
        }
	public void Commit (Photo [] items)
	{
		uint timer = Log.DebugTimerStart ();
		// Only use a transaction for multiple saves. Avoids recursive transactions.
		bool use_transactions = !Database.InTransaction && items.Length > 1;

		if (use_transactions)
			Database.BeginTransaction ();

		PhotosChanges changes = new PhotosChanges ();
		foreach (DbItem item in items)
			changes |= Update ((Photo)item);

		if (use_transactions)
			Database.CommitTransaction ();

		EmitChanged (items, new PhotoEventArgs (items, changes));
		Log.DebugTimerPrint (timer, "Commit took {0}");
	}
		public static PhotosChanges operator | (PhotosChanges c1, PhotosChanges c2)
		{
			PhotosChanges changes = new PhotosChanges ();
			changes.changes = c1.changes | c2.changes;
			changes.VersionsChanged = c1.VersionsChanged || c2.VersionsChanged;
			changes.TagsChanged = c1.TagsChanged || c2.TagsChanged;
			return changes;
		}
Пример #5
0
        public static PhotosChanges operator |(PhotosChanges c1, PhotosChanges c2)
        {
            if (c1 == null)
                throw new ArgumentNullException ("c1");
            if (c2 == null)
                throw new ArgumentNullException ("c2");

            PhotosChanges changes = new PhotosChanges ();
            changes.changes = c1.changes | c2.changes;
            changes.VersionsChanged = c1.VersionsChanged || c2.VersionsChanged;
            changes.TagsChanged = c1.TagsChanged || c2.TagsChanged;
            return changes;
        }
Пример #6
0
 public PhotoEventArgs(Photo[] photos, PhotosChanges changes) : base(photos)
 {
     Changes = changes;
 }
Пример #7
0
 public PhotoEventArgs(Photo photo, PhotosChanges changes) : this(new[] { photo }, changes)
 {
 }