protected void Page_Load(object sender, EventArgs e) { var facebook = new FacebookGraphAPI(Facebook.Apps.MixmagGreatest); JObject user = facebook.GetObject("me", null); MixmagGreatestVoteSet vs = new MixmagGreatestVoteSet(new Query(new Q(MixmagGreatestVote.Columns.FacebookUid, facebook.Uid))); if (vs.Count > 0) { try { Update u = new Update(); u.Table = TablesEnum.MixmagGreatestDj; u.Changes.Add(new Assign.Subtraction(MixmagGreatestDj.Columns.TotalVotes, 1)); u.Where = new Q(MixmagGreatestDj.Columns.K, vs[0].MixmagGreatestDjK); u.Run(); } catch { } vs[0].Delete(); Response.Write("Done."); } else Response.Write("Nothing to delete!"); }
protected void Page_Load(object sender, EventArgs e) { string email = Request.QueryString["email"]; Update u = new Update(); u.Changes.Add(new Assign(MixmagEntry.Columns.SendDailyEmails, false)); u.Where = new Q(MixmagEntry.Columns.Email, email); u.Table = TablesEnum.MixmagEntry; u.Run(); }
public static void Increment(Items item, int count, DateTime date) { bool exists = false; try { Log l = new Log(item, date); exists = true; } catch (BobNotFound) { try { Log l = new Log(); l.ItemType = item; l.Date = date; l.Count = count; l.Update(); } catch { exists = true; } } if (exists) { try { Update u = new Update(); u.Table = TablesEnum.Log; u.Where = new And( new Q(Log.Columns.Item, item), new Q(Log.Columns.Date, date)); if (count == 1) u.Changes.Add(new Assign.Increment(Log.Columns.Count)); else u.Changes.Add(new Assign.Addition(Log.Columns.Count, count)); u.Run(); } catch { } } }
public void MergeAndDelete(Venue merge) { if (this.K == merge.K) throw new DsiUserFriendlyException("Can't merge a venue into itself!"); Cambro.Web.Helpers.WriteAlertHeader(); //throw new Exception("This function isn't finished yet!"); Cambro.Web.Helpers.WriteAlert("Starting merge...", true); #region Promoter Cambro.Web.Helpers.WriteAlert("Merging promoter...", true); if (merge.PromoterK > 0 && merge.PromoterStatus.Equals(Venue.PromoterStatusEnum.Confirmed) && merge.Promoter.IsEnabled) { this.PromoterK = merge.PromoterK; this.PromoterStatus = Venue.PromoterStatusEnum.Confirmed; } else if (this.PromoterK == 0 && merge.PromoterK > 0) { this.PromoterK = merge.PromoterK; this.PromoterStatus = merge.PromoterStatus; } Cambro.Web.Helpers.WriteAlert("Done merging promoter..."); #endregion #region Articles if (true) { Cambro.Web.Helpers.WriteAlert("Moving articles...", true); Query q = new Query(); q.QueryCondition = new And(new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),new Q(Article.Columns.ParentObjectK, merge.K)); ArticleSet ars = new ArticleSet(q); foreach (Article a in ars) { Cambro.Web.Helpers.WriteAlert("Moving article " + a.K + "..."); a.ParentObjectK = this.K; a.VenueK = this.K; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place) a.PlaceK = this.PlaceK; else a.PlaceK = 0; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country) a.CountryK = this.Place.CountryK; else a.CountryK = 0; a.UrlFragment = this.UrlFilterPart; a.Update(); #region Threads if (true) { Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new Q(Thread.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart)); u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K)); u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.PlaceK)); u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Place.CountryK)); u.Run(); } #endregion #region Galleries if (true) { Update u = new Update(); u.Table = TablesEnum.Gallery; u.Where = new Q(Gallery.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion #region Photos if (true) { Update u = new Update(); u.Table = TablesEnum.Photo; u.Where = new Q(Photo.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion } Cambro.Web.Helpers.WriteAlert("Done moving articles...", true); } #endregion #region Events if (true) { Cambro.Web.Helpers.WriteAlert("Moving events...", true); EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK, merge.K))); int count = 0; foreach (Event ev in es) { count++; Cambro.Web.Helpers.WriteAlert("Moving event "+ev.K+" ("+count+" / "+es.Count+")..."); ev.ChangeVenue(this.K, true); } Cambro.Web.Helpers.WriteAlert("Done moving events..."); } #endregion #region Thread ParentObjects if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", true); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK, merge.K)); u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)..."); } #endregion #region Thread if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", true); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.VenueK, merge.K), new Q(Thread.Columns.EventK, 0), new Q(Thread.Columns.ArticleK, 0)); u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K)); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPart)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)..."); } #endregion #region Pic if (!this.HasPic) { Cambro.Web.Helpers.WriteAlert("Merging picture...", true); this.Pic = merge.Pic; this.PicMiscK = merge.PicMiscK; this.PicPhotoK = merge.PicPhotoK; this.PicState = merge.PicState; merge.Pic = Guid.Empty; merge.PicMiscK = 0; merge.PicPhotoK = 0; merge.PicState = ""; merge.Update(); Cambro.Web.Helpers.WriteAlert("Done merging picture..."); } #endregion this.AdminNote += "Venue " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from venue " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n"; this.Update(); int mergePlaceK = merge.PlaceK; Cambro.Web.Helpers.WriteAlert("Deleting old venue...", true); merge.DeleteAll(null); Cambro.Web.Helpers.WriteAlert("Done deleting old venue..."); if (mergePlaceK != this.PlaceK) { Place mergePlace = new Place(mergePlaceK); Cambro.Web.Helpers.WriteAlert("Updating stats for old place...", true); mergePlace.UpdateTotalComments(null); mergePlace.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for old place..."); } Cambro.Web.Helpers.WriteAlert("Updating stats for new venue...", true); this.UpdateTotalComments(null); this.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for new venue..."); this.Update(); Cambro.Web.Helpers.WriteAlert("Done merging venues!", true); }
public void UpdateChildUrlFragments(bool Cascade) { Update uEvents = new Update(); uEvents.Table=TablesEnum.Event; uEvents.Changes.Add(new Assign(Event.Columns.UrlFragment,UrlFilterPart)); uEvents.Where=new Q(Event.Columns.VenueK,this.K); uEvents.Run(); if (Cascade) { Query q = new Query(); q.NoLock=true; q.QueryCondition=new Q(Event.Columns.VenueK,this.K); q.Columns=new ColumnSet( Event.Columns.K, Event.Columns.UrlFragment, Event.Columns.VenueK, Event.Columns.DateTime); EventSet es = new EventSet(q); foreach (Event e in es) { try { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, e.K, true); job.ExecuteAsynchronously(); } catch(Exception ex) { if (Vars.DevEnv) throw ex; } } } Update uThreads = new Update(); uThreads.Table=TablesEnum.Thread; uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart)); uThreads.Where=new And( new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK,this.K)); uThreads.Run(); Update uArticles = new Update(); uArticles.Table=TablesEnum.Article; uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart)); uArticles.Where=new And( new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Article.Columns.ParentObjectK,this.K)); uArticles.Run(); if (Cascade) { Query q = new Query(); q.NoLock=true; q.QueryCondition=new And( new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Article.Columns.ParentObjectK,this.K)); q.Columns=new ColumnSet( Article.Columns.K, Article.Columns.UrlFragment, Article.Columns.ParentObjectK, Article.Columns.ParentObjectType); ArticleSet aSet = new ArticleSet(q); foreach (Article a in aSet) { try { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true); job.ExecuteAsynchronously(); } catch(Exception ex) { if (Vars.DevEnv) throw ex; } } } }
public void ChangePlace(int NewPlaceK, bool UpdateChildUrlFragments) { if (this.PlaceK!=NewPlaceK) { Place OldPlace = this.Place; Place NewPlace = new Place(NewPlaceK); Update uThreads = new Update(); uThreads.Table = TablesEnum.Thread; uThreads.Where = new Q(Thread.Columns.VenueK,this.K); uThreads.Changes.Add(new Assign(Thread.Columns.PlaceK,NewPlace.K)); uThreads.Changes.Add(new Assign(Thread.Columns.CountryK,NewPlace.CountryK)); uThreads.Run(); Update uArticle = new Update(); uArticle.Table = TablesEnum.Article; uArticle.Where = new Q(Article.Columns.VenueK,this.K); uArticle.Changes.Add(new Assign(Article.Columns.PlaceK,NewPlace.K)); uArticle.Changes.Add(new Assign(Article.Columns.CountryK, NewPlace.CountryK)); uArticle.Run(); this.PlaceK = NewPlace.K; this.Update(); OldPlace.UpdateTotalComments(null); OldPlace.UpdateTotalEvents(null); this.Place=null; this.UpdateTotalComments(null); Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, this.K, UpdateChildUrlFragments); job.ExecuteAsynchronously(); this.Place.UpdateTotalEvents(null); } }
public static void UpdateTicketHeatOfEvents() { //UPDATE [Event] set [Event].[TicketHeat] = sumBookingFee FROM //(SELECT [Ticket].[EventK], SUM([Ticket].[BookingFee]) AS sumBookingFee FROM [Ticket] WHERE [Ticket].[BuyDateTime]>DATEADD(day, -2, GETDATE()) AND [Ticket].[Enabled] = 1 GROUP BY [Ticket].[EventK]) t1 //INNER JOIN [Event] on t1.[EventK] = [Event].[K] Transaction t = new Transaction(); try { Update clear = new Update(); clear.Changes.Add(new Assign(Event.Columns.TicketHeat, 0.0)); clear.Table = TablesEnum.Event; clear.Where = new Q(Event.Columns.TicketHeat, QueryOperator.GreaterThan, 0.0); Console.WriteLine("Cleared {0} row(s)", clear.Run(t)); Update up = new Update(); up.Table = TablesEnum.Event; up.Changes.Add(new Assign.Override(Event.Columns.TicketHeat, "sumBookingFee")); up.Where = new Q(true); up.From = new Join( new Join.StringOverride( "(SELECT [Ticket].[EventK], SUM([Ticket].[BookingFee]) AS sumBookingFee FROM [Ticket] WHERE [Ticket].[BuyDateTime]>DATEADD(day, -7, GETDATE()) AND [Ticket].[Enabled] = 1 GROUP BY [Ticket].[EventK]) t1"), new TableElement(TablesEnum.Event), QueryJoinType.Inner, new StringQueryCondition("t1.[EventK] = [Event].[K]")); Console.WriteLine("Updated {0} row(s)", up.Run(t)); t.Commit(); } catch (Exception ex) { t.Rollback(); Utilities.AdminEmailAlert("Exception updating TicketHeat flag on all events", "Exception updating TicketHeat flag on all events", ex); } finally { t.Close(); } try { Event ev1 = new Event(159336); ev1.TicketHeat = 1001; ev1.Update(); } catch(Exception ex) { Utilities.AdminEmailAlert("Exception updating TicketHeat flag on CreamFields 159336", "Exception updating TicketHeat flag on CreamFields 159336", ex); } try { Event ev2 = new Event(166002); ev2.TicketHeat = 1000; ev2.Update(); } catch (Exception ex) { Utilities.AdminEmailAlert("Exception updating TicketHeat flag on CreamFields 166002", "Exception updating TicketHeat flag on CreamFields 166002", ex); } }
public static void UpdateTicketsStatusOfEvents() { Transaction t = new Transaction(); try { Update clear = new Update(); clear.Changes.Add(new Assign(Event.Columns.IsTicketsAvailable, false)); clear.Table = TablesEnum.Event; clear.Where = new Q(Event.Columns.IsTicketsAvailable, true); Console.WriteLine("Cleared {0} row(s)", clear.Run(t)); Update up = new Update(); up.Table = TablesEnum.Event; up.Changes.Add(new Assign(Event.Columns.IsTicketsAvailable, true)); up.Where = new Q(true); up.From = new Join( new TableElement(TablesEnum.Event), new TableElement(TablesEnum.TicketRun), QueryJoinType.Inner, new And( new Q(TicketRun.Columns.EndDateTime, QueryOperator.GreaterThan, DateTime.Now), new Q(TicketRun.Columns.StartDateTime, QueryOperator.LessThanOrEqualTo, DateTime.Now), new Q(TicketRun.Columns.SoldTickets, QueryOperator.LessThan, TicketRun.Columns.MaxTickets, true), new Q(TicketRun.Columns.Paused, false), new Q(Event.Columns.K, TicketRun.Columns.EventK, true) ) ); Console.WriteLine("Updated {0} row(s)", up.Run(t)); t.Commit(); } catch (Exception ex) { t.Rollback(); Utilities.AdminEmailAlert("Exception updating TicketsAvailable flag on all events", "Exception updating TicketsAvailable flag on all events", ex); } finally { t.Close(); } Update clearHilight = new Update(); clearHilight.Changes.Add(new Assign(Event.Columns.HasHilight, false)); clearHilight.Table = TablesEnum.Event; clearHilight.Where = new And( new Q(Event.Columns.IsTicketsAvailable, false), new Q(Event.Columns.Donated, false), new Q(Event.Columns.HasHilight, true)); Console.WriteLine("Cleared hilight on {0} row(s)", clearHilight.Run()); Update setHilight = new Update(); setHilight.Changes.Add(new Assign(Event.Columns.HasHilight, true)); setHilight.Table = TablesEnum.Event; setHilight.Where = new And( new Or(new Q(Event.Columns.IsTicketsAvailable, true), new Q(Event.Columns.Donated, true)), new Q(Event.Columns.HasHilight, false)); Console.WriteLine("Set hilight on {0} row(s)", setHilight.Run()); }
private static void SetEmailBroken(string emailAddress) { if (emailAddress.Length == 0) return; { int changes = 0; Update u = new Update(); u.Table = TablesEnum.Usr; u.Changes.Add(new Assign(Usr.Columns.IsEmailBroken, true)); u.Where = new And(new Q(Usr.Columns.Email, emailAddress), new Or(new Q(Usr.Columns.IsEmailBroken, false), new Q(Usr.Columns.IsEmailBroken, QueryOperator.IsNull, null))); changes = u.Run(); Log.Increment(Model.Entities.Log.Items.EmailBouncesDisabled, changes); } { int changes = 0; Update u = new Update(); u.Table = TablesEnum.MixmagSubscription; u.Changes.Add(new Assign(MixmagSubscription.Columns.IsEmailBroken, true)); u.Changes.Add(new Assign(MixmagSubscription.Columns.EmailBrokenDateTime, DateTime.Now)); u.Where = new And(new Q(MixmagSubscription.Columns.Email, emailAddress), new Or(new Q(MixmagSubscription.Columns.IsEmailBroken, false), new Q(MixmagSubscription.Columns.IsEmailBroken, QueryOperator.IsNull, null))); changes = u.Run(); Log.Increment(Model.Entities.Log.Items.MixmagBouncesDisabled, changes); } }
protected override void Execute() { if (!IsAlreadyRunning.Value) { Caching.Instances.Main.Store(MemcachedKey.Value, Job.JobStatus.Running, new TimeSpan(0, 15, 0)); Update uThreadUsr = new Update(); try { if (StatusChangeObjectType.Value == null && StatusChangeObjectK.Value != null) throw new Exception("Usr.UpdateThreadUsrJob(): Invalid StatusChangeObject."); uThreadUsr.Table = TablesEnum.ThreadUsr; uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.Status, ChangeStatus.Value)); uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.StatusChangeDateTime, Common.Time.Now)); uThreadUsr.Where = new Q(ThreadUsr.Columns.UsrK, UsrK.Value); if (ThreadStatusesToChange.Value != null && ThreadStatusesToChange.Value.Count > 0) { Or statusOr = new Or(); foreach (ThreadUsr.StatusEnum statusEnum in ThreadStatusesToChange.Value) { statusOr = new Or(statusOr, new Q(ThreadUsr.Columns.Status, statusEnum)); } uThreadUsr.Where = new And(uThreadUsr.Where, statusOr); } else throw new Exception("Usr.UpdateThreadUsrs(): Invalid list of ThreadUsr.StatusEnum to change."); if (StatusChangeObjectType.Value != null) { if (StatusChangeObjectType.Value == Model.Entities.ObjectType.Usr) { // do nothing here } else { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.StatusChangeObjectType, StatusChangeObjectType.Value)); } if (StatusChangeObjectK.Value != null) { if (StatusChangeObjectType.Value == Model.Entities.ObjectType.Usr) { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.InvitingUsrK, StatusChangeObjectK.Value)); } else { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.StatusChangeObjectK, StatusChangeObjectK.Value)); } } } uThreadUsr.CommandTimeout = 300; uThreadUsr.Run(); // Update memcached Caching.Instances.Main.Store(MemcachedKey.Value, Job.JobStatus.Completed, new TimeSpan(0, 15, 0)); } catch (Exception ex) { Caching.Instances.Main.Store(MemcachedKey.Value, Job.JobStatus.Failed, new TimeSpan(0, 15, 0)); throw ex; } } }
public static Hashtable VoteNow(int mixmagGreatestDjK, string facebookSource, bool facebookMessage) { try { var facebook = new FacebookGraphAPI(Facebook.Apps.MixmagGreatest); JObject user = facebook.GetObject("me", null); //string email = user.Value<string>("email"); string firstName = user.Value<string>("first_name"); string lastName = user.Value<string>("last_name"); Hashtable ret = new Hashtable(); if (DateTime.Now > new DateTime(2011, 12, 24)) { ret["Done"] = false; ret["Message"] = "Sorry, voting closed at midnight on 23rd December 2011."; return ret; } MixmagGreatestDj dj = new MixmagGreatestDj(mixmagGreatestDjK); MixmagGreatestVote mgv = new MixmagGreatestVote(); mgv.DateTime = DateTime.Now; mgv.DidWallPost = false; mgv.EmailPermission = true; //mgv.FacebookEmail = email; mgv.FacebookUid = facebook.Uid; mgv.MixmagGreatestDjK = dj.K; mgv.WallPostPermission = true; mgv.FacebookSource = facebookSource == "1"; try { if (!Vars.DevEnv && DateTime.Now > new DateTime(2011, 09, 15, 11, 0, 0)) mgv.Update(); } catch (Exception ex) { MixmagGreatestVoteSet voteSet = new MixmagGreatestVoteSet(new Query(new Q(MixmagGreatestVote.Columns.FacebookUid, facebook.Uid))); if (voteSet.Count > 0) { MixmagGreatestDj votedFor = new MixmagGreatestDj(voteSet[0].MixmagGreatestDjK); ret["Done"] = false; ret["Message"] = "You already voted for " + votedFor.Name + ". Sorry - you can only vote once."; return ret; } else { ret["Done"] = false; ret["Message"] = "There's a problem voting: " + ex.ToString(); return ret; } } try { Update u = new Update(); u.Table = TablesEnum.MixmagGreatestDj; u.Changes.Add(new Assign.Increment(MixmagGreatestDj.Columns.TotalVotes)); u.Where = new Q(MixmagGreatestDj.Columns.K, dj.K); u.Run(); } catch { } //FacebookHttpContext.Current.Status.Set(dj.Name + " is my greatest DJ of all time. Click to vote for yours in the Mixmag poll: http://greatest.dj/"); if (facebookMessage) { try { //send facebook message //http://developers.facebook.com/docs/reference/api/post Dictionary<string, object> par = new Dictionary<string, object>(); par["picture"] = dj.Image90Url; par["link"] = "http://mixmag-greatest.com/?fb=1"; par["name"] = "Mixmag Greatest Dance Act"; if (dj.IsHidden) { par["description"] = "I voted for my greatest dance act of all time. Vote for yours now in the Mixmag poll..."; } else { par["caption"] = dj.Name; par["description"] = "I voted " + dj.ShortName + " the greatest dance act of all time. Vote for yours now in the Mixmag poll..."; } facebook.PutWallPost("", par); mgv.DidWallPost = true; mgv.Update(); } catch { } } ret["Done"] = true; return ret; } catch (Exception ex) { Hashtable ret = new Hashtable(); ret["Done"] = false; ret["Message"] = ex.ToString(); return ret; } }
public void SendMail(UsrSet us, bool liveSend, int startUsrK) { Console.WriteLine("Flyer.SendMail v3 - with IsEmailBroken flag..."); if (liveSend && this.IsReadyToSend && !this.IsSending) { if (this.Sends == 0) this.SendDateTime = DateTime.Now; this.IsSending = true; this.Update(); } string body = ""; if (!IsHtml) { body = string.Format(@" <div style=""padding-top:10px;padding-bottom:10px;{0}""><center> <a href=""{1}"">Click here if you can't see the e-flyer below</a><br> <a href=""{2}""><img src=""{3}"" border=""0"" width=""{4}"" height=""{5}"" vspace=""10""></a><br>", (this.BackgroundColor == "") ? "" : @"background-color:#" + this.BackgroundColor + ";", this.PopupUrl, this.LinkTargetUrlTrackingClicks, this.ImgSrcTrackingViews, this.Misc.Width, this.Misc.Height); } //string unsubscribeLink = "/popup/unsubscribeeflyers/usrk-" "/flyerk-" + this.K; Random r = new Random(); const int intervalToUpdateSends = 100; //int startIndex = usrList.FindIndex(u => u.K >= startUsrK); int skipped = 0; for (int i = 0; i < us.Count; i++) { try { Usr u = us[i]; //string unsubscribeLinkNoDomain = "http://" + Vars.DomainName + "/popup/unsubscribeeflyers/usrk-" + u.K.ToString() + "/loginstring-" + u.LoginString.ToLower() + "/flyerk-" + this.K; //string unsubscribeLinkWithDomain = "http://" + Vars.DomainName + "/popup/unsubscribeeflyers/usrk-" + u.K.ToString() + "/loginstring-" + u.LoginString.ToLower() + "/flyerk-" + this.K; string unsubscribeLinkWithDomain = u.LoginAndTransfer("/popup/unsubscribeeflyers/flyerk-" + this.K); if (u.K > startUsrK) { if (liveSend && i % intervalToUpdateSends == 0) { //this.Update(); // check that we're still good to send, not been paused // this'll be cached until anything changes if (new Flyer(this.K).IsReadyToSend == false) { this.IsSending = false; this.Update(); return; } } System.Net.Mail.SmtpClient c = new System.Net.Mail.SmtpClient(); c.Host = Common.Properties.GetDefaultSmtpServer(r); System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage(); m.IsBodyHtml = true; if (!IsHtml) { m.Body = body + @" <a href=""" + unsubscribeLinkWithDomain + @""">Click here to unsubscribe from DontStayIn e-flyers</a> </center></div> "; } else { if (this.TextAlternative.Length > 0) { System.Net.Mail.AlternateView alt = System.Net.Mail.AlternateView.CreateAlternateViewFromString(this.TextAlternative + @" Click here to unsubscribe from DontStayIn e-flyers: " + unsubscribeLinkWithDomain, null, "text/plain"); m.AlternateViews.Add(alt); System.Net.Mail.AlternateView html = System.Net.Mail.AlternateView.CreateAlternateViewFromString( @"<p style=""margin:5px;padding:5px;background-color:#ffffff;""><center><a href=""" + unsubscribeLinkWithDomain + @""">Click here to unsubscribe from DontStayIn e-flyers</a><img src=""" + this.ImgSrcTrackingViews + @""" width=""1"" height=""1"" border=""0"" /></center></p>" + this.Html, null, "text/html"); m.AlternateViews.Add(html); } else { m.Body = @"<p style=""margin:5px;padding:5px;background-color:#ffffff;""><center><a href=""" + unsubscribeLinkWithDomain + @""">Click here to unsubscribe from DontStayIn e-flyers</a><img src=""" + this.ImgSrcTrackingViews + @""" width=""1"" height=""1"" border=""0"" /></center></p>" + this.Html; } } m.Subject = this.Subject; string To = u.Email; m.From = (this.MailFromDisplayName.Trim().Length > 0) ? new System.Net.Mail.MailAddress(Vars.AdminReplyAddress, this.MailFromDisplayName.Trim()) : new System.Net.Mail.MailAddress(Vars.AdminReplyAddress); //System.Threading.Thread.Sleep(50); if (!u.IsEmailBroken) { if (Vars.DevEnv) { m.Subject += " (to:" + To + ") (" + DateTime.Now.ToString() + ")"; m.To.Add("*****@*****.**"); if (u.K == 8) m.To.Add(To); } else { m.To.Add(To); } bool done = false; do { try { c.Send(m); done = true; u.RegisterMailSentForBounceTracking(); } catch (Exception ex) { if (ex.Message.Contains("Insufficient system storage")) { Update up = new Update(); up.Changes.Add(new Assign.Increment(Flyer.Columns.MailServerRetries)); up.Changes.Add(new Assign(Flyer.Columns.MailServerLastRetry, DateTime.Now)); up.Changes.Add(new Assign(Flyer.Columns.DateTimeLastMessageSent, DateTime.Now)); up.Table = TablesEnum.Flyer; up.Where = new Q(Flyer.Columns.K, this.K); up.Run(); Console.Error.WriteLine("UsrK: {0}, eFlyerK: {1}, retrying after 5 sec.", us[i].K, this.K); System.Threading.Thread.Sleep(5000); } else throw ex; } } while (!done); if (liveSend) { Update up = new Update(); up.Changes.Add(new Assign.Increment(Flyer.Columns.Sends)); up.Changes.Add(new Assign(Flyer.Columns.PausedAtUsrK, u.K)); up.Changes.Add(new Assign(Flyer.Columns.DateTimeLastMessageSent, DateTime.Now)); up.Table = TablesEnum.Flyer; up.Where = new Q(Flyer.Columns.K, this.K); up.Run(); } } else { if (liveSend) { Update up = new Update(); up.Changes.Add(new Assign.Increment(Flyer.Columns.Broken)); up.Changes.Add(new Assign(Flyer.Columns.DateTimeLastMessageSent, DateTime.Now)); up.Table = TablesEnum.Flyer; up.Where = new Q(Flyer.Columns.K, this.K); up.Run(); } } } if (i % 10 == 0) Console.Out.WriteLine("Done " + i + "/" + us.Count); us.Kill(i); } catch (Exception ex) { Console.Error.WriteLine("UsrK: {0}, eFlyerK: {1}, Exception: {2}", us[i].K, this.K, ex.Message); if (liveSend) { Update up = new Update(); up.Changes.Add(new Assign.Increment(Flyer.Columns.Exceptions)); up.Changes.Add(new Assign(Flyer.Columns.DateTimeLastMessageSent, DateTime.Now)); up.Table = TablesEnum.Flyer; up.Where = new Q(Flyer.Columns.K, this.K); up.Run(); } } } if (liveSend) { //this.Sends += (us.Count - skipped) % intervalToUpdateSends; this.IsSending = false; this.HasFinishedSending = true; this.Update(); } }
public void MergeAndDelete(Event merge) { if (this.K == merge.K) throw new DsiUserFriendlyException("Can't merge event into itself!"); Cambro.Web.Helpers.WriteAlertHeader(); //throw new Exception("This function isn't finished yet!"); Cambro.Web.Helpers.WriteAlert("Starting merge...", 1); #region Articles if (true) { Query q = new Query(); q.QueryCondition = new Q(Article.Columns.EventK, merge.K); ArticleSet ars = new ArticleSet(q); foreach (Article a in ars) { Cambro.Web.Helpers.WriteAlert("Merging article " + a.K + "...", 2); a.ParentObjectK = this.K; a.EventK = this.K; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Venue) a.VenueK = this.VenueK; else a.VenueK = 0; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place) a.PlaceK = this.Venue.PlaceK; else a.PlaceK = 0; if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country) a.CountryK = this.Venue.Place.CountryK; else a.CountryK = 0; a.UrlFragment = this.UrlFilterPartVenueDate; a.Update(); #region Threads if (true) { Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new Q(Thread.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart)); u.Changes.Add(new Assign(Thread.Columns.EventK, this.K)); u.Changes.Add(new Assign(Thread.Columns.VenueK, this.VenueK)); u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.Venue.PlaceK)); u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Venue.Place.CountryK)); u.Run(); } #endregion #region Galleries if (true) { Update u = new Update(); u.Table = TablesEnum.Gallery; u.Where = new Q(Gallery.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion #region Photos if (true) { Update u = new Update(); u.Table = TablesEnum.Photo; u.Where = new Q(Photo.Columns.ArticleK, a.K); u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart)); u.Run(); } #endregion } Cambro.Web.Helpers.WriteAlert("Done merging articles...", 2); } #endregion #region Banners if (true) { Cambro.Web.Helpers.WriteAlert("Merging banners...", 4); Update u = new Update(); u.Table = TablesEnum.Banner; u.Where = new Q(Banner.Columns.EventK, merge.K); u.Changes.Add(new Assign(Banner.Columns.EventK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging banners...", 4); } #endregion #region Comp if (true) { Cambro.Web.Helpers.WriteAlert("Merging competitions...", 5); Update u = new Update(); u.Table = TablesEnum.Comp; u.Where = new Q(Comp.Columns.EventK, merge.K); u.Changes.Add(new Assign(Comp.Columns.EventK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging competitions...", 5); } #endregion #region EventMusicType if (true) { Cambro.Web.Helpers.WriteAlert("Merging music types...", 6); Query q1 = new Query(); q1.TableElement = MusicType.EventJoin; q1.QueryCondition = new Q(Event.Columns.K, merge.K); MusicTypeSet ems1 = new MusicTypeSet(q1); Query q2 = new Query(); q2.TableElement = MusicType.EventJoin; q2.QueryCondition = new Q(Event.Columns.K, this.K); MusicTypeSet ems2 = new MusicTypeSet(q2); bool hasAllMuisc = false; ArrayList majorTypes = new ArrayList(); ArrayList relevantTypes = new ArrayList(); #region find major types foreach (MusicType mt in ems1) { if (mt.K == 1) { hasAllMuisc = true; break; } if (mt.ParentK == 1 && !majorTypes.Contains(mt.K)) majorTypes.Add(mt.K); } if (!hasAllMuisc) { foreach (MusicType mt in ems2) { if (mt.K == 1) { hasAllMuisc = true; break; } if (mt.ParentK == 1 && !majorTypes.Contains(mt.K)) majorTypes.Add(mt.K); } } #endregion if (!hasAllMuisc) { foreach (MusicType mt in ems1) { if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K)) relevantTypes.Add(mt.K); } foreach (MusicType mt in ems2) { if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K)) relevantTypes.Add(mt.K); } } if (hasAllMuisc || relevantTypes.Count == 0) { Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K)); d.Run(); EventMusicType emt = new EventMusicType(); emt.EventK = this.K; emt.MusicTypeK = 1; emt.Update(); } else { Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K)); d.Run(); foreach (int mtK in relevantTypes) { EventMusicType emt = new EventMusicType(); emt.EventK = this.K; emt.MusicTypeK = mtK; emt.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging music types...", 6); } #endregion #region EventBrand if (true) { Cambro.Web.Helpers.WriteAlert("Merging brands...", 7); EventBrandSet ebs = new EventBrandSet(new Query(new Q(EventBrand.Columns.EventK, merge.K))); foreach (EventBrand eb in ebs) { try { EventBrand ebThis = new EventBrand(this.K, eb.BrandK); } catch { EventBrand ebThis = new EventBrand(); ebThis.EventK = this.K; ebThis.BrandK = eb.BrandK; ebThis.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging brands...", 7); } #endregion #region Gallery if (true) { Cambro.Web.Helpers.WriteAlert("Merging galleries...", 9); Update u = new Update(); u.Table = TablesEnum.Gallery; u.Where = new Q(Gallery.Columns.EventK, merge.K); u.Changes.Add(new Assign(Gallery.Columns.EventK, this.K)); u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, this.UrlFilterPartVenueDate)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging galleries...", 9); } #endregion #region Photo if (true) { Cambro.Web.Helpers.WriteAlert("Merging photos...", 10); Update u = new Update(); u.Table = TablesEnum.Photo; u.Where = new Q(Photo.Columns.EventK, merge.K); u.Changes.Add(new Assign(Photo.Columns.EventK, this.K)); u.Changes.Add(new Assign(Photo.Columns.UrlFragment, this.UrlFilterPartVenueDate)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging photos...", 10); } #endregion #region GroupEvent if (true) { Cambro.Web.Helpers.WriteAlert("Merging group-event links...", 11); GroupEventSet ges = new GroupEventSet(new Query(new Q(GroupEvent.Columns.EventK, merge.K))); foreach (GroupEvent ge in ges) { try { GroupEvent geThis = new GroupEvent(ge.GroupK, this.K); } catch { GroupEvent geThis = new GroupEvent(); geThis.EventK = this.K; geThis.GroupK = ge.GroupK; geThis.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging group-event links...", 11); } #endregion #region Thread ParentObjects if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", 12); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Thread.Columns.ParentObjectK, merge.K)); u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)...", 12); } #endregion #region Thread if (true) { Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", 13); Update u = new Update(); u.Table = TablesEnum.Thread; u.Where = new And( new Q(Thread.Columns.EventK, merge.K), new Q(Thread.Columns.ArticleK, 0)); u.Changes.Add(new Assign(Thread.Columns.EventK, this.K)); u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPartVenueDate)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)...", 13); } #endregion #region UsrEventAttended if (true) { Cambro.Web.Helpers.WriteAlert("Merging members...", 14); UsrEventAttendedSet ueas = new UsrEventAttendedSet(new Query(new Q(UsrEventAttended.Columns.EventK, merge.K))); foreach (UsrEventAttended uea in ueas) { try { UsrEventAttended ueaThis = new UsrEventAttended(uea.UsrK, this.K); bool changed = false; if (!uea.SendUpdate && ueaThis.SendUpdate) { ueaThis.SendUpdate = false; changed = true; } if (uea.Spotter && !ueaThis.Spotter) { ueaThis.Spotter = true; changed = true; } if (changed) ueaThis.Update(); } catch { UsrEventAttended ueaThis = new UsrEventAttended(); ueaThis.EventK = this.K; ueaThis.UsrK = uea.UsrK; ueaThis.SendUpdate = uea.SendUpdate; ueaThis.Spotter = uea.Spotter; ueaThis.Update(); } } Cambro.Web.Helpers.WriteAlert("Done merging members...", 14); } #endregion if (!this.HasPic) { Cambro.Web.Helpers.WriteAlert("Merging picture...", 15); this.Pic = merge.Pic; this.PicMiscK = merge.PicMiscK; this.PicPhotoK = merge.PicPhotoK; this.PicState = merge.PicState; merge.Pic = Guid.Empty; merge.PicMiscK = 0; merge.PicPhotoK = 0; merge.PicState = ""; merge.Update(); Cambro.Web.Helpers.WriteAlert("Done merging picture...", 15); } this.AdminNote += "Event " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from event " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n"; if (!this.HasGuestlist && merge.HasGuestlist) { Cambro.Web.Helpers.WriteAlert("Merging guestlist...", 16); this.HasGuestlist = true; this.GuestlistOpen = merge.GuestlistOpen; this.GuestlistFinished = merge.GuestlistOpen; this.GuestlistLimit = merge.GuestlistLimit; this.GuestlistCount = merge.GuestlistCount; this.GuestlistDetails = merge.GuestlistDetails; this.GuestlistPromoterK = merge.GuestlistPromoterK; this.GuestlistRegularPrice = merge.GuestlistRegularPrice; this.GuestlistPrice = merge.GuestlistPrice; this.GuestlistPromotion = merge.GuestlistPromotion; Delete d = new Delete(TablesEnum.UsrEventGuestlist, new Q(UsrEventGuestlist.Columns.EventK, this.K)); d.Run(); Update u = new Update(); u.Table = TablesEnum.UsrEventGuestlist; u.Where = new Q(UsrEventGuestlist.Columns.EventK, merge.K); u.Changes.Add(new Assign(UsrEventGuestlist.Columns.EventK, this.K)); u.Run(); Cambro.Web.Helpers.WriteAlert("Done merging guestlist...", 16); } if (merge.Donated) this.Donated = true; if (merge.HasHilight) this.HasHilight = true; this.UpdateUsrAttendCount(false); this.Update(); int mergeVenueK = merge.VenueK; Cambro.Web.Helpers.WriteAlert("Deleting old event...", 17); merge.DeleteAll(null); Cambro.Web.Helpers.WriteAlert("Done deleting old event...", 17); if (mergeVenueK != this.VenueK) { Venue mergeVenue = new Venue(mergeVenueK); Cambro.Web.Helpers.WriteAlert("Updating stats for old venue...", 18); mergeVenue.UpdateTotalComments(null); mergeVenue.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for old venue...", 18); } Cambro.Web.Helpers.WriteAlert("Updating stats for new event...", 19); this.UpdateMusicTypesStringNoUpdate(); this.UpdateTotalComments(null); this.UpdateHasSpotter(null); this.UpdateTotalPhotos(null); this.Venue.UpdateTotalEvents(null); Cambro.Web.Helpers.WriteAlert("Done updating stats for new event...", 19); this.Update(); Cambro.Web.Helpers.WriteAlert("Done merging events!", 20); }
public void UpdateChildUrlFragments(bool Cascade) { Update uGalleries = new Update(); uGalleries.Table = TablesEnum.Gallery; uGalleries.Changes.Add(new Assign(Gallery.Columns.UrlFragment, UrlFilterPartVenueDate)); uGalleries.Where = new Q(Gallery.Columns.EventK, this.K); uGalleries.Run(); Update uPhotos = new Update(); uPhotos.Table = TablesEnum.Photo; uPhotos.Changes.Add(new Assign(Photo.Columns.UrlFragment, UrlFilterPartVenueDate)); uPhotos.Where = new Q(Photo.Columns.EventK, this.K); uPhotos.Run(); Update uThreads = new Update(); uThreads.Table = TablesEnum.Thread; uThreads.From = new Join( new TableElement(TablesEnum.Thread), new TableElement(TablesEnum.Photo), QueryJoinType.Left, Thread.Columns.PhotoK, Photo.Columns.K ); uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment, UrlFilterPart)); uThreads.Where = new Or( new Q(Photo.Columns.EventK, this.K), new And( new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Thread.Columns.ParentObjectK, this.K) ) ); uThreads.Run(); Update uArticles = new Update(); uArticles.Table = TablesEnum.Article; uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment, UrlFilterPartVenueDate)); uArticles.Where = new And( new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Article.Columns.ParentObjectK, this.K)); uArticles.Run(); if (Cascade) { Query q = new Query(); q.NoLock = true; q.QueryCondition = new And( new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Article.Columns.ParentObjectK, this.K)); q.Columns = new ColumnSet( Article.Columns.K, Article.Columns.UrlFragment, Article.Columns.ParentObjectK, Article.Columns.ParentObjectType); ArticleSet aSet = new ArticleSet(q); foreach (Article a in aSet) { try { Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true); job.ExecuteAsynchronously(); } catch (Exception ex) { if (Vars.DevEnv) throw ex; } } } }
public static void UpdateUsrAttendCountStatic(int EventK) { Update u = new Update(); u.Changes.Add(new Assign.Override(Event.Columns.UsrAttendCount, "( SELECT COUNT(*) FROM [UsrEventAttended] WHERE [UsrEventAttended].[EventK] = [Event].[K] )")); u.Table = TablesEnum.Event; u.Where = new Q(Event.Columns.K, EventK); u.Run(); }
public void SetBlockedAndUpdate(bool blocked) { if (!Usr.Current.IsAdmin) { throw new Exception("You need to be an admin to block or unblock a tag"); } Transaction t = new Transaction(); Query q = new Query(new Q(TagPhoto.Columns.TagK, this.K)); List<int> tagPhotoKs = (new TagPhotoSet(q)).ToList().ConvertAll(tagPhoto => tagPhoto.K); List<Assign> changes = new List<Assign>() { new Assign(TagPhoto.Columns.Disabled, blocked) }; Q condition = new And( new Q(TagPhoto.Columns.TagK, this.K), new Q(TagPhoto.Columns.Disabled, !blocked) ); Update u = new Update(TablesEnum.TagPhoto, changes, condition); u.Run(t); foreach (int tagPhotoK in tagPhotoKs) { TagPhotoHistory historyItem = new TagPhotoHistory() { Action = blocked ? TagPhotoHistory.TagPhotoHistoryAction.Blocked : TagPhotoHistory.TagPhotoHistoryAction.Unblocked, DateTime = DateTime.Now, TagPhotoK = tagPhotoK, UsrK = Usr.Current.K }; historyItem.Update(t); } this.Blocked = blocked; this.BlockedDateTime = DateTime.Now; this.BlockedByUsrK = Usr.Current.K; this.Update(t); t.Commit(); (new Caching.CacheKeys.NamespaceCacheKey(CacheKeyPrefix.TagCloudVersion)).Invalidate(); }
private void RunUpdate(bool isArchive) { if (StatusChangeObjectType.Value == null && StatusChangeObjectK.Value != null) throw new Exception("Usr.SmartDeleteThreadUsrJob(): Invalid StatusChangeObject."); if(ThreadStatusesToChange.Value.Count == 0) throw new Exception("Usr.SmartDeleteThreadUsrJob(): Invalid ThreadStatusesToChange."); Update uThreadUsr = new Update(); uThreadUsr.Table = TablesEnum.ThreadUsr; uThreadUsr.From = new Join(ThreadUsr.Columns.ThreadK, Thread.Columns.K); uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.StatusChangeDateTime, Common.Time.Now)); uThreadUsr.Where = new Q(ThreadUsr.Columns.UsrK, UsrK.Value); if (isArchive) { uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.Archived)); uThreadUsr.Where = new And(uThreadUsr.Where, new Q(Thread.Columns.TotalWatching, QueryOperator.LessThanOrEqualTo, SMART_DELETE_CUT_OFF_NUMBER_OF_PEOPLE_WATCHING)); } else { uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.Status, ThreadUsr.StatusEnum.Ignore)); uThreadUsr.Where = new And(uThreadUsr.Where, new Q(Thread.Columns.TotalWatching, QueryOperator.GreaterThan, SMART_DELETE_CUT_OFF_NUMBER_OF_PEOPLE_WATCHING)); } if (ThreadStatusesToChange.Value != null && ThreadStatusesToChange.Value.Count > 0) { Or statusOr = new Or(); foreach (ThreadUsr.StatusEnum statusEnum in ThreadStatusesToChange.Value) { statusOr = new Or(statusOr, new Q(ThreadUsr.Columns.Status, statusEnum)); } uThreadUsr.Where = new And(uThreadUsr.Where, statusOr); } else throw new Exception("Usr.SmartDeleteThreadUsrJob(): Invalid list of ThreadUsr.StatusEnum to change."); if (StatusChangeObjectType.Value != null) { if (StatusChangeObjectType.Value == Model.Entities.ObjectType.Usr) { // do nothing here } else { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.StatusChangeObjectType, StatusChangeObjectType.Value)); } if (StatusChangeObjectK.Value != null) { if (StatusChangeObjectType.Value == Model.Entities.ObjectType.Usr) { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.InvitingUsrK, StatusChangeObjectK.Value)); } else { uThreadUsr.Where = new And(uThreadUsr.Where, new Q(ThreadUsr.Columns.StatusChangeObjectK, StatusChangeObjectK.Value)); } } } uThreadUsr.CommandTimeout = 300; uThreadUsr.Run(); }