public DraftStatusObj(DraftStatus draftStatus) : this() { if (draftStatus != null) { Status = draftStatus.Status; Time = draftStatus.Time.ToUniversalTime(); } }
private DraftStatus GetCurrentDraftStatus() { DraftStatus toRet = null; var allCurrStatus = from t in db.DraftStatus where t.ID == 1 select t; if (allCurrStatus.Count() > 0) { toRet = allCurrStatus.First(); } return(toRet); }
public DraftStatusObj SetNextDraftStatusObj(DraftStatusObj toSet) { DraftStatusObj toRet = null; lock (_DraftLock) { var allNextStatus = from t in db.DraftStatus where t.ID == 2 select t; DraftStatus next = allNextStatus.First(); next.Status = toSet.Status; next.Time = DateTime.Now; // Commit all changes to the DB db.SubmitChanges(); toRet = new DraftStatusObj(next); } return(toRet); }
public void Load(string nodeName, LdmlDocument document, XmlReader reader, LdmlNode parent) { _document = document; _parent = parent; _code = nodeName; if (reader.MoveToFirstAttribute()) { List <LdmlAttributeValue> list = null; while (true) { string name = reader.Name; string value = reader.Value; LdmlAttribute attr = LdmlUtil.GetAttribute(name); if (attr == LdmlAttribute.Draft) { _draftStatus = CldrUtil.GetDraftStatus(value); } else if (!HandleAttribute(attr, value)) { if (list == null) { list = new List <LdmlAttributeValue>(); } list.Add(new LdmlAttributeValue(attr, value)); } if (!reader.MoveToNextAttribute()) { break; } } reader.MoveToElement(); if (list != null) { Attributes = list.ToArray(); } } //ReadChildren( reader ); if (reader.IsEmptyElement) { return; } while (reader.Read()) { var type = reader.NodeType; if (type == XmlNodeType.Element) { if (reader.Name == "alias") { _document.ReadAlias(reader, this); } else { _document.ReadNode(reader, this); //_nodes.Add( node ); } } else if (type == XmlNodeType.Text) { _value = reader.Value; } else if (type == XmlNodeType.EndElement) { break; } } }
public DraftStatus GetDraftStatus(IMediaWikiApi mediaWikiApi, string page) { var status = new DraftStatus(page); // retrieve the categories of the page var categorySet = mediaWikiApi.GetCategoriesOfPage(page); var speedyCategories = this.GetSpeedyCategories(categorySet); if (speedyCategories.Any()) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.SpeedyDeletion : status.StatusCode; status.SpeedyDeletionCategories = speedyCategories; } if (this.IsBeingReviewedNow(categorySet)) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.InReviewNow : status.StatusCode; } if (this.IsInArticleSpace(categorySet)) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.Pending : status.StatusCode; status.SubmissionInArticleSpace = true; } if (this.IsPendingReview(categorySet)) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.Pending : status.StatusCode; if (this.DuplicatesExisting(categorySet)) { status.DuplicatesExistingArticle = true; } } if (this.IsDraft(categorySet)) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.Draft : status.StatusCode; } var rejectCategories = this.GetRejectionCategories(categorySet); if (rejectCategories.Any()) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.Rejected : status.StatusCode; status.RejectionCategories = rejectCategories; } var declineCategories = this.GetDeclineCategories(categorySet); if (declineCategories.Any()) { status.StatusCode = status.StatusCode == DraftStatusCode.Unknown ? DraftStatusCode.Declined : status.StatusCode; status.DeclineCategories = declineCategories; } if (status.StatusCode == DraftStatusCode.Unknown) { this.logger.WarnFormat("Draft [[{0}]] reported status unknown - categories: {0}", string.Join("|", categorySet)); } status.SubmissionDate = this.GetSubmissionDate(categorySet); return(status); }
public DraftInfo(DateTime?lastUpdate, DraftStatus status, String file) { this.LastUpdate = lastUpdate; this.Status = status; this.File = file; }
public CmsPage() { this.Tags = new List <CmsTag>(); Status = new DraftStatus(); }
public List <DraftMoveObj> FindOnTheClock() { List <DraftMoveObj> onclock = new List <DraftMoveObj>(); List <DraftMove> toPause = new List <DraftMove>(); DraftMoveObj addedOnClock = null; // This entire operation MUST be atomic, so a Lock is required lock (_DraftLock) { DraftStatus oStatus = GetCurrentDraftStatus(); DraftStatusType currStatus = Converter.ToDraftStatusType(oStatus.Status); bool isPaused = (currStatus == DraftStatusType.Paused); var allNextStatus = from t in db.DraftStatus where t.ID == 2 select t; DraftActionType nextStatus = Converter.ToDraftActionType(allNextStatus.First().Status); List <DraftMove> currentOnClock = this.GetCurrentOnClock_Internal(); if (isPaused) { toPause = currentOnClock; } else { foreach (DraftMove mOnClock in currentOnClock) { onclock.Add(new DraftMoveObj(mOnClock)); } if (onclock.Count > 0) { onclock.Sort(new DraftMoveObjComparer()); } } // Determine if a new OnClock Move is needed bool addOnClock = (onclock.Count == 0 && toPause.Count == 0); // We attempt to minimize the time delay by waiting to calculate the current time // as far as possible. So if we don't need to calculate how much time is left // on the last OnClock Move, we'll wait longer. Otherwise, we have to re-use this one // to keep everything synchronized DateTime?currentTime = null; if (onclock.Count > 0) { currentTime = DateTime.Now; DraftMoveObj lastOnClock = onclock[onclock.Count - 1]; TimeSpan timeLeft = TimeSpan.FromSeconds(Settings.SecondsPerPick) - (currentTime.Value - lastOnClock.Time); // Check if the last OnClock Move is over the time limit if (timeLeft < TimeSpan.FromTicks(0)) { addOnClock = true; } } if (addOnClock && !isPaused) { // Find the next empty slot DraftMoveObj nextEmpty = FindNextEmptySlot(); // If no Empty Slots, the Draft is over, so make sure it gets paused if (nextEmpty == null) { nextStatus = DraftActionType.Pause; } else { if (!currentTime.HasValue) { currentTime = DateTime.Now; } DraftMove newOnClock = new DraftMove() { SeasonID = nextEmpty.SeasonID, Round = nextEmpty.Round, Pick = nextEmpty.Pick, PlayerID = null, MoveType = (int)DraftMoveType.OnClock, UserID = nextEmpty.UserID, Time = currentTime.Value }; db.DraftMoves.InsertOnSubmit(newOnClock); addedOnClock = new DraftMoveObj(newOnClock); } } // If the draft is paused, we need to update all the onClock Moves if (toPause.Count > 0) { if (!currentTime.HasValue) { currentTime = DateTime.Now; } foreach (DraftMove nextMove in toPause) { TimeSpan origGap = oStatus.Time - nextMove.Time; nextMove.Time = currentTime.Value - origGap; onclock.Add(new DraftMoveObj(nextMove)); } onclock.Sort(new DraftMoveObjComparer()); } // If we added a new OnClock Move, make sure it is at the end of the onclock list if (addedOnClock != null) { onclock.Add(addedOnClock); onclock.Sort(new DraftMoveObjComparer()); } // If the Draft is Paused or needs to change actions, update it int iCurr = (int)currStatus; int iNext = (int)nextStatus; if (isPaused || iCurr != iNext) { if (!currentTime.HasValue) { currentTime = DateTime.Now; } oStatus.Time = currentTime.Value; oStatus.Status = iNext; } // Commit all changes to the DB db.SubmitChanges(); } return(onclock); }