protected override void OnInitialize() { base.OnInitialize(); DisplayName = Strings.RevisionsViewModel_DisplayName; var loadingTask = Task.Run(async delegate { try { var revisions = await _productServiceModel.GetProducts(new ProductQuery { Identifier = Product.Identifier, RevisionFilter = RevisionFilter.All }).ConfigureAwait(false); var vms = revisions.Select(r => new ProductInfoViewModel(r)).ToArray(); await Execute.OnUIThreadAsync(() => Revisions.AddRange(vms)); } catch (Exception e) { await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message); } finally { await Execute.OnUIThreadAsync(CommandManager.InvalidateRequerySuggested); } }); TaskNotifier = new TaskNotifier(loadingTask); }
/// <summary> /// Handles the disposal of resources. Derived from abstract class <see cref="DisposableObject"/> which handles common required locking logic. /// </summary> protected override void DisposeResources() { Helper.IfNotNull(x => x.Dispose()); Schemas.Dispose(); Revisions.Dispose(); Transaction.Dispose(); }
public void Validate(ValidationResult result) { if (Revisions.GroupBy(rev => new { rev.VersionNumber, rev.MinorVersionNumber }).Count() != Revisions.Count) { result.AddUserError("Revision Indexes must be unique."); } }
protected override void PerformAddOrUpdate(TypedEntity entity) { Mandate.ParameterNotNull(entity, "persistedEntity"); using (NhProfilerLogging.Start(Helper.NhSession, "PerformAddOrUpdate", new OdbcParameter("entity", entity))) { // Note that it should be the caller's responsibility to add to revisions but the Cms backoffice code needs to change // to do that, so this is included to avoid breaking assumptions about auto-created versions until then if (Revisions.CanWrite) { var newRevision = new Revision <TypedEntity>(entity); Revisions.AddOrUpdate(newRevision); return; } else { if (TryUpdateExisting(entity)) { return; } Helper.MapAndMerge(entity, FrameworkContext.TypeMappers); } } }
/// <summary> /// Update revisions /// </summary> /// <param name="Revisions">Revisions to update</param> public void UpdateRevisions(Revisions revisions) { AutoRentEntities context = new AutoRentEntities(); DbTransaction transaction = null; try { context.Connection.Open(); transaction = context.Connection.BeginTransaction(); context.Revisions.Attach(context.Revisions.Single(c => c.Id == revisions.Id)); context.Revisions.ApplyCurrentValues(revisions); context.SaveChanges(); transaction.Commit(); } catch { transaction.Rollback(); } finally { context.Connection.Close(); } }
public void Save(cmSite site, SiteAccessRule rule, bool logChanges = true) { string filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteAccessRule", site.DistinctName)); SiteAccessRule cached = HttpRuntime.Cache[filePath] as SiteAccessRule; string relativePath = "/.config/site_access_rule.setting"; string name = "Access Control"; cached = rule; HttpRuntime.Cache.Insert(filePath , cached , new CacheDependencyEx(new string[] { filePath }, false) , Cache.NoAbsoluteExpiration , Cache.NoSlidingExpiration , CacheItemPriority.NotRemovable , null ); if (logChanges) { Revisions.BackupIfNotExists(site, filePath, relativePath, name); } ObjectHelper.BinarySerialize <SiteAccessRule>(rule, filePath); if (logChanges) { Revisions.Backup(site, filePath, relativePath, name); } }
public void AddOrUpdate(TypedEntity entity) { Transaction.EnsureBegun(); // First, call Schemas.AddOrUpdate for the schema if (Schemas != null && Schemas.CanWrite && entity.EntitySchema != null) { Schemas.AddOrUpdate(entity.EntitySchema); } entity.Id = new HiveId((Uri)null, entity.Id.ProviderId, entity.Id.Value); if (Revisions.CanWrite) { var newRevision = new Revision <TypedEntity>(entity); Revisions.AddOrUpdate(newRevision); OnAddOrUpdateComplete(entity); return; } else { PerformAddOrUpdate(entity); OnAddOrUpdateComplete(entity); } AddCacheFlushesToTransaction(entity.Id); }
public ActionResult DeleteConfirmed(int id) { Revisions revisions = db.RevisionsSet.Find(id); db.RevisionsSet.Remove(revisions); db.SaveChanges(); return(RedirectToAction("Index")); }
public void RefreshData(XmlDocument doc) { Revisions.Clear(); foreach (XmlElement elem in doc.FirstChild.ChildNodes) { Revisions.Add(Revision.CreateFromXml(elem)); } }
public override void NotifyDeleting() { base.NotifyDeleting(); if (OnNotifyDeleting_Document != null) { OnNotifyDeleting_Document(this); } Revisions.Clear(); }
internal void RemoveRevision(int id) { var revision = Revisions.Find(r => r.ID == id); if (revision != null) { Revisions.Remove(revision); } }
public Revisions GetRevision() { Revisions revisionData = new Revisions(); revisionData.AccelID = ReadRegister(BNO055_ACCEL_REV_ID_ADDR); revisionData.MagID = ReadRegister(BNO055_MAG_REV_ID_ADDR); revisionData.GyroID = ReadRegister(BNO055_GYRO_REV_ID_ADDR); revisionData.Bootloader = ReadRegister(BNO055_BL_REV_ID_ADDR); revisionData.Software = (ReadRegister(BNO055_SW_REV_ID_MSB_ADDR) << 8) | ReadRegister(BNO055_SW_REV_ID_MSB_ADDR); return(revisionData); }
async Task ISessionAdapter.Save(ReviewRevision revision) { if (Revisions.Contains(revision)) { return; } Assert.That(revision.RevisionNumber, Is.EqualTo(Revisions.Count + 1)); Revisions.Add(revision); }
ReviewRevision ISessionAdapter.GetPreviousRevision(ReviewRevision revision) { Assert.That(revision, Is.AnyOf(Revisions.OfType <object>().ToArray())); if (revision.RevisionNumber == 1) { return(null); } return(Revisions.Single(x => x.RevisionNumber == revision.RevisionNumber - 1)); }
public ActionResult Edit([Bind(Include = "Id,Date,UserName,TriggerScript,ProcessScript,RulesId,Revision,Operation")] Revisions revisions) { if (ModelState.IsValid) { db.Entry(revisions).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RulesId = new SelectList(db.RulesSet, "Id", "Title", revisions.RulesId); return(View(revisions)); }
public void InsertRevisions(Revisions revisions) { if ((revisions.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(revisions, EntityState.Added); } else { this.ObjectContext.Revisions.AddObject(revisions); } }
public ModelSummary CreateSummary() { return(new ModelSummary() { Id = Id, Description = Description, IsPublic = IsPublic, Key = Key, Name = Name, Revisions = new List <ModelRevisionSummary>(Revisions.Select(rev => rev.ToSummary())) }); }
public void DeleteRevisions(Revisions revisions) { if ((revisions.EntityState != EntityState.Detached)) { this.ObjectContext.ObjectStateManager.ChangeObjectState(revisions, EntityState.Deleted); } else { this.ObjectContext.Revisions.Attach(revisions); this.ObjectContext.Revisions.DeleteObject(revisions); } }
public void Save(cmSite site, SiteRestrictDomainRule rule) { string filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteDomainRule", site.DistinctName)); string relativePath = "/.config/site_domain_access_rule.setting"; string name = "Domain Access Control"; Revisions.BackupIfNotExists(site, filePath, relativePath, name); ObjectHelper.BinarySerialize <SiteRestrictDomainRule>(rule, filePath); Revisions.Backup(site, filePath, relativePath, name); }
public static void Save(cmSite site, Dictionary <string, string> hostMapping) { string filePath = HostingEnvironment.MapPath(string.Format("~/Views/{0}/.config/SiteHostMapping", site.DistinctName)); string relativePath = "/.config/site_host_mapping.setting"; string name = "Host Mapping"; Revisions.BackupIfNotExists(site, filePath, relativePath, name); ObjectHelper.BinarySerialize <Dictionary <string, string> >(hostMapping, filePath); Revisions.Backup(site, filePath, relativePath, name); }
private void AddRevision(Rules pRule, string pOperation) { Revisions _rev = new Revisions(); _rev.Date = DateTime.Now; _rev.Revision = pRule.Revision; _rev.TriggerScript = pRule.TriggerScript; _rev.ProcessScript = pRule.ProcessScript; _rev.Rules = pRule; _rev.UserName = this.User.Identity.Name; _rev.Operation = pOperation; db.RevisionsSet.Add(_rev); db.SaveChanges(); }
// GET: Revisions/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Revisions revisions = db.RevisionsSet.Find(id); if (revisions == null) { return(HttpNotFound()); } return(View(revisions)); }
// GET: Revisions/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Revisions revisions = db.RevisionsSet.Find(id); if (revisions == null) { return(HttpNotFound()); } ViewBag.RulesId = new SelectList(db.RulesSet, "Id", "Title", revisions.RulesId); return(View(revisions)); }
public ReviewRevision MarkRevision(PublishReview.RevisionCommits commits) { var revision = new ReviewRevision { BaseCommit = commits.Base, HeadCommit = commits.Head, ReviewId = ReviewId, RevisionNumber = Revisions.Count + 1, Id = Guid.NewGuid() }; Revisions.Add(revision); return(revision); }
protected override void PerformAddOrUpdate(TypedEntity entity) { // Note that it should be the caller's responsibility to add to revisions but the Cms backoffice code needs to change // to do that, so this is included to avoid breaking assumptions about auto-created versions until then if (Revisions.CanWrite) { var newRevision = new Revision <TypedEntity>(entity); Revisions.AddOrUpdate(newRevision); return; } else { Helper.PerformAddOrUpdate(entity, ExamineTransaction); } }
// Save the item, this will create a new revision. public virtual void Save() { if (!IsDirty) { return; } // Create a new revision _fieldData.CreateNewRevision(); // Store the data, this should create a new identifier _store.SaveItem(this); // Refresh the revision list Revisions.PrepareRevisions(); }
void ISessionAdapter.Save(Review review) { Assert.That(review.RevisionId, Is.AnyOf(Revisions.Select(x => (object)x.Id).ToArray()), "Review must be linked to valid revision"); Assert.That(review.UserId, Is.AnyOf(Users.Select(x => (object)x.Id).ToArray()), "Review must be linked to valid user"); var user = Users.Single(x => x.Id == review.UserId); var revision = Revisions.Single(x => x.Id == review.RevisionId); if (Reviews.TryGetValue(user, revision, out var original)) { Assert.That(review, Is.SameAs(original), "Do not overwrite review"); } else { Reviews[user, revision] = review; } }
public virtual Revision Revise() { var original = LatestRevision; var revision = new Revision(); if (original != null) { revision.Body = original.Body; revision.Reason = original.Reason; } revision.Entry = this; revision.Revised = DateTime.UtcNow; revision.RevisionNumber = Revisions.Count + 1; LatestRevision = revision; Revisions.Add(revision); return(revision); }
public int CompareTo(EventProviderTransaction other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } var thisMin = Revisions.Min(x => x.Version); Contract.Assume(thisMin != null); var otherMin = other.Revisions.Min(x => x.Version); Contract.Assume(otherMin != null); return(thisMin.CompareTo(otherMin)); }
// // Gets the revision lists for a list of files // public static Revisions[] Request(string[] pathList, Logging logger) { // Spin through and get them all List <Revisions> results = new List <Revisions>(); foreach (string thisPath in pathList) { logger.Log(@"Finding revisions for {0}", thisPath); Revisions thisResult = Request(thisPath, logger); if (thisResult != null) { results.Add(thisResult); } } // Return our list return(results.Count == 0 ? null : results.ToArray()); }