public static TwitterLifecycle Factory(TwitterIssue twitterIssue) { if (twitterIssue.Type.HasValue) { switch (twitterIssue.Type.Value) { case TwitterIssueType.BTP: return new BTPLifeCycle(twitterIssue); break; case TwitterIssueType.TEFOP: return new TEFOPLifeCycle(twitterIssue); break; case TwitterIssueType.BTPH: return new BTPHLifeCycle(twitterIssue); break; case TwitterIssueType.VBTPX: return new VBTPXLifeCycle(twitterIssue); break; case TwitterIssueType.VBTPE: return new VBTPELifeCycle(twitterIssue); break; case TwitterIssueType.VBTPD: return new VBTPDLifeCycle(twitterIssue); break; case TwitterIssueType.VBTPC: return new VBTPCLifeCycle(twitterIssue); break; case TwitterIssueType.TEFCL: return new TEFCLLifeCycle(twitterIssue); break; case TwitterIssueType.BTPC: return new BTPCLifeCycle(twitterIssue); break; case TwitterIssueType.BTPD: return new BTPDLifeCycle(twitterIssue); break; default: log.Error(string.Format("TwitterLifecyle cannot deal with {0}",twitterIssue.TypeString)); return null; break; } } else { log.Error(string.Format("TwitterLifecyle cannot deal with {0}",twitterIssue.TypeString)); return null; } }
public override TwitterIssue Parse() { Match m = Match(nakedTwittToParse.Text); Func<String, String> all = (x) => x.Equals("*") ? "ALL" : x; string twitterKeyToken = m.Groups["TwitterKeyToken"].Value; string commentToken = m.Groups["CommentToken"].Value; string serviceToken = m.Groups["ServiceToken"].Value; string countryToken = m.Groups["CountryToken"].Value; countryToken =all(countryToken); string startingDateToken = m.Groups["StartingDateToken"].Value; string idToken = m.Groups["IDToken"].Value; string estimatedMinutesToken = m.Groups["EstimatedMinutesToken"].Value; int estimatedMinutes = 0; bool areMinutes = int.TryParse(estimatedMinutesToken, out estimatedMinutes); DateTime? startingDate = ParseDate(startingDateToken); //if (!areMinutes || startingDate ==null) //{ // //TODO: Log error to trace // return null; //} TwitterIssue result = new TwitterIssue(); result.IntenalId = AssembleId(idToken, serviceToken, countryToken); result.Finished = false; result.CountryKey = countryToken; result.ProductKey = serviceToken; result.TypeString = twitterKeyToken.ToUpper(); result.Description = commentToken; result.OriginalMessage = nakedTwittToParse.Text; result.TwitterDate = nakedTwittToParse.CreatedDate; result.TwitterId = nakedTwittToParse.StringId; result.PreviousTwittId = null; result.EstimatedMinutes = estimatedMinutes; result.StartingDate = startingDate; result.EndingDate = null; result.EffectiveDate = startingDate; result.ProductId = -1; return result; }
public override TwitterIssue Parse() { Match m = Match(nakedTwittToParse.Text); if (m == null) { //TODO:Log Error return null; } Func<String, String> all = (x) => x.Equals("*") ? "ALL" : x; string twitterKeyToken = m.Groups["TwitterKeyToken"].Value; string commentToken = m.Groups["CommentToken"].Value; string serviceToken = m.Groups["ServiceToken"].Value; string countryToken = m.Groups["CountryToken"].Value; countryToken =all(countryToken); string idToken = m.Groups["IDToken"].Value; TwitterIssue result = new TwitterIssue(); result.IntenalId = AssembleId(idToken,serviceToken,countryToken); result.Finished = false; result.CountryKey = countryToken; result.ProductKey = serviceToken; result.TypeString = twitterKeyToken.ToUpper(); result.Description = commentToken; result.OriginalMessage = nakedTwittToParse.Text; result.TwitterDate = nakedTwittToParse.CreatedDate; result.TwitterId = nakedTwittToParse.StringId; result.PreviousTwittId = null; result.EstimatedMinutes = null; result.StartingDate = null; result.EndingDate = null; //TODO: Effective Date will be set whenever the parent twitt is setted result.EffectiveDate = null; result.ProductId = -1; return result; }
public TwitterLifecycle(TwitterIssue twitterIssue) { this.twitterIssue = twitterIssue; }
private void ProcessTwitterIssue(TwitterIssue twitterIssue) { log.Info(string.Format("Processing twitter, with TwitterInternalID ={0}",twitterIssue.TwitterId)); try { TwitterIssue twitterInDB = null; twitterInDB = twitterIssueRepository.FindByTweeterId(twitterIssue.TwitterId); if (twitterInDB == null) { Product product = FindProduct(twitterIssue.ProductKey); TwitterLifecycle.TwitterLifecycle lifecycle = TwitterLifecycle.TwitterLifecycle.Factory(twitterIssue); TwitterIssue parent = lifecycle.FindParent(); bool isLeaf = lifecycle.IsLeaf; if (product != null && product.Id.HasValue) { twitterIssue.ProductId = product.Id.Value; if (parent != null && parent.Id.HasValue) { twitterIssue.PreviousTwittId = parent.Id.Value; twitterIssue.Finished = isLeaf; //In case of #BTPC,#VBTPC get parent effective date if ((twitterIssue.Type.Equals(TwitterIssueType.BTPC) || twitterIssue.Type.Equals(TwitterIssueType.VBTPC)) && !twitterIssue.EffectiveDate.HasValue) twitterIssue.EffectiveDate = parent.EffectiveDate; } twitterIssueRepository.SaveEntity(twitterIssue); } else { log.Error(string.Format("The product with with ProductKey = {0} cannot be found", twitterIssue.ProductKey)); } } else //(twitterInDB != null) { TwitterLifecycle.TwitterLifecycle lifecycle = TwitterLifecycle.TwitterLifecycle.Factory(twitterInDB); TwitterIssue parent = lifecycle.FindParent(); bool isLeaf = lifecycle.IsLeaf; if (parent != null && parent.Id.HasValue) { twitterInDB.PreviousTwittId = parent.Id.Value; twitterInDB.Finished = isLeaf; twitterIssueRepository.UpdateEntity(twitterInDB); } } } catch (Exception ex) { log.Error(string.Format("Error processing twitter, with TwitterInternalID ={0}",twitterIssue.TwitterId),ex); } }
public TEFCLLifeCycle(TwitterIssue twitterIssue) : base(twitterIssue) { }
public BTPHLifeCycle(TwitterIssue twitterIssue) : base(twitterIssue) { }
public VBTPXLifeCycle(TwitterIssue twitterIssue) : base(twitterIssue) { }