public static void NewLiveBroadcast() { try { SqlCommand command; SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); SqlDataAdapter dataAdapter = new SqlDataAdapter(command); DataSet ds = new DataSet(); dataAdapter.Fill(ds); //Populate data from the inserted row DataRow insertedRow = ds.Tables[0].Rows[0]; DataColumnCollection insertedColumns = ds.Tables[0].Columns; int MemberIDTo = (int)insertedRow["MemberIDTo"]; int MemberIDFrom = (int)insertedRow["MemberIDFrom"]; Member targetMember = Member.GetMemberByMemberID(MemberIDTo, connection); Member sendingMember = Member.GetMemberByMemberID(MemberIDFrom, connection); string TargetEmailAddress = targetMember.Email; string subject = Templates.NewLiveBroadcastSubject; string body = Templates.NewLiveBroadcastBody; subject = MergeHelper.GenericMerge(subject, insertedColumns, insertedRow); body = MergeHelper.GenericMerge(body, insertedColumns, insertedRow); subject = MergeHelper.MergeMemberInfo(subject, targetMember); body = MergeHelper.MergeMemberInfo(body, targetMember); subject = MergeHelper.MergeOtherMemberInfo(subject, sendingMember); body = MergeHelper.MergeOtherMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } }
private static void TriggerHandler(SqlConnection connection, ContentType contentType, DataSet ds) { //Populate data from the inserted row DataRow insertedRow = ds.Tables[0].Rows[0]; DataColumnCollection insertedColumns = ds.Tables[0].Columns; int OwnerMemberID = (int)insertedRow["MemberID"]; string WebPhotoID = (string)insertedRow["WebPhotoID"]; DataSet PhotoDS = GetPhotoByWebPhotoIDWithJoin(WebPhotoID, connection); DataRow PhotoDSRow = PhotoDS.Tables[0].Rows[0]; DataColumnCollection PhotoDSColumns = PhotoDS.Tables[0].Columns; Member ownerMember = Member.GetMemberByMemberID(OwnerMemberID, connection); MemberSettings ms = Member.GetMemberSettingsByMemberID(OwnerMemberID, connection); // In case we don't find any settings if (ms == null) { return; } string TargetEmailAddress = ownerMember.Email; string subject = Templates.NewPhotoSelfSubject; string body = Templates.NewPhotoSelfBody; subject = MergeHelper.GenericMerge(subject, insertedColumns, insertedRow); body = MergeHelper.GenericMerge(body, insertedColumns, insertedRow); subject = MergeHelper.GenericMerge(subject, PhotoDSColumns, PhotoDSRow); body = MergeHelper.GenericMerge(body, PhotoDSColumns, PhotoDSRow); subject = MergeHelper.MergeMemberInfo(subject, ownerMember); body = MergeHelper.MergeMemberInfo(body, ownerMember); try { MailHelper.SendEmail(TargetEmailAddress, subject, body, @"\\www\Live\user\" + ownerMember.NickName + @"\pmed\" + PhotoDSRow["PhotoResourceFileFileName"]); } catch { } }
public static void NewAAFComment() { SqlCommand command; SqlTriggerContext triggContext = SqlContext.TriggerContext; SqlDataAdapter dataAdapter = null; DataSet ds = new DataSet(); try { switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); //Populate data from the inserted row DataRow insertedRow = ds.Tables[0].Rows[0]; DataColumnCollection insertedColumns = ds.Tables[0].Columns; // In AskAFriend comment the MemberID is actually the from member id int MemberIDFrom = (int)insertedRow["MemberID"]; // Get the AskAFriendID against the inserted Row int AskAFriendID = (int)insertedRow["AskAFriendID"]; // Get AskAFriend Information against the inserted AskAFriend Comment ds = AskAFriend.GetAskAFriendInformation(AskAFriendID, connection); // If there is no AskAFriend row found if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { return; } DataRow AAFRow = ds.Tables[0].Rows[0]; DataColumnCollection AAFColumns = ds.Tables[0].Columns; int MemberID = (int)AAFRow["MemberID"]; MemberSettings ms = Member.GetMemberSettingsByMemberID(MemberID, connection); // In case we don't find any settings if (ms == null) { return; } // If the user doesn't want to be notified return if (!ms.NotifyOnAAFComment) { return; } Member targetMember = Member.GetMemberByMemberID(MemberID, connection); Member sendingMember = Member.GetMemberByMemberID(MemberIDFrom, connection); string TargetEmailAddress = targetMember.Email; string subject = Templates.NewAAFCommentSubject; string body = Templates.NewAAFCommentBody; subject = MergeHelper.GenericMerge(subject, insertedColumns, insertedRow); body = MergeHelper.GenericMerge(body, insertedColumns, insertedRow); subject = MergeHelper.GenericMerge(subject, AAFColumns, AAFRow); body = MergeHelper.GenericMerge(body, AAFColumns, AAFRow); subject = MergeHelper.MergeMemberInfo(subject, targetMember); body = MergeHelper.MergeMemberInfo(body, targetMember); subject = MergeHelper.MergeOtherMemberInfo(subject, sendingMember); body = MergeHelper.MergeOtherMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } }
public static void NewProfileInvite() { SqlCommand command = null; DataSet ds = null; SqlDataAdapter dataAdapter = null; try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); DataTable table = ds.Tables[0]; DataRow row = table.Rows[0]; DataColumnCollection columns = table.Columns; int InvitingMemberID = (int)row["MemberID"]; string EmailAddress = (string)row["EmailAddress"]; Member sendingMember = null; sendingMember = Member.GetMemberByMemberID(InvitingMemberID, connection); string TargetEmailAddress = EmailAddress; string subject = Templates.ProfileInviteSubject; string body = Templates.ProfileInviteBody; subject = MergeHelper.GenericMerge(subject, columns, row); body = MergeHelper.GenericMerge(body, columns, row); subject = MergeHelper.MergeMemberInfo(subject, sendingMember); body = MergeHelper.MergeMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } finally { try { if (command != null) { command.Dispose(); } if (ds != null) { ds.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } } catch { } } }
public static void NewContentInvite() { SqlCommand command = null; DataSet ds = null; SqlDataAdapter dataAdapter = null; try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); DataTable table = ds.Tables[0]; DataRow insertedRow = table.Rows[0]; DataColumnCollection columns = table.Columns; int MemberID = (int)insertedRow["MemberID"]; int ObjectID = (int)insertedRow["ObjectID"]; string EmailAddress = (string)insertedRow["EmailAddress"]; ContentType contentType = (ContentType)((int)insertedRow["ObjectType"]); // The object on which the invite was made along with the owner information // Can be a Video, Photo, Nspot, Member etc... DataSet objectDS = Utility.GetObjectByObjectIDWithJoin(ObjectID, contentType, connection); Member sendingMember = null; if (MemberID != 0) { sendingMember = Member.GetMemberByMemberID(MemberID, connection); } else { sendingMember = new Member(); sendingMember.FirstName = "Your friend"; } string TargetEmailAddress = EmailAddress; string subject = MergeHelper.MergeContentType(Templates.ContentInviteSubject, contentType); string body = MergeHelper.MergeContentType(Templates.ContentInviteBody, contentType); subject = Utility.PopulateLink(subject, contentType, objectDS.Tables[0].Rows[0]); body = Utility.PopulateLink(body, contentType, objectDS.Tables[0].Rows[0]); subject = MergeHelper.GenericMerge(subject, columns, insertedRow); body = MergeHelper.GenericMerge(body, columns, insertedRow); subject = MergeHelper.MergeMemberInfo(subject, sendingMember); body = MergeHelper.MergeMemberInfo(body, sendingMember); //body = MergeHelper.MergeBanner(body, "New " + contentType.ToString() + " Invite", connection); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } finally { try { if (command != null) { command.Dispose(); } if (ds != null) { ds.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } } catch { } } }
public static void NewMessage() { SqlCommand command = null; DataSet ds = null; SqlDataAdapter dataAdapter = null; try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); //Populate data from the inserted row DataRow insertedRow = ds.Tables[0].Rows[0]; DataColumnCollection insertedColumns = ds.Tables[0].Columns; int MemberIDTo = (int)insertedRow["MemberIDTo"]; int MemberIDFrom = (int)insertedRow["MemberIDFrom"]; string ExternalEmailTo = (string)insertedRow["ExternalEmailTo"]; if (MemberIDTo != -1) { MemberSettings ms = Member.GetMemberSettingsByMemberID(MemberIDTo, connection); // In case we don't find any settings if (ms == null) { return; } // If the user doesn't want to be notified return if (!ms.NotifyOnNewMessage) { return; } } Member targetMember = null; if (MemberIDTo != -1) { targetMember = Member.GetMemberByMemberID(MemberIDTo, connection); } else { targetMember = new Member(); targetMember.Email = ExternalEmailTo; } Member sendingMember = Member.GetMemberByMemberID(MemberIDFrom, connection); string TargetEmailAddress = targetMember.Email; string subject = string.Empty; string body = string.Empty; if (MemberIDTo == -1) { subject = Templates.NewExternalMessageSubject; body = Templates.NewExternalMessageBody; } else { subject = Templates.NewMessageSubject; body = Templates.NewMessageBody; } subject = MergeHelper.GenericMerge(subject, insertedColumns, insertedRow); body = MergeHelper.GenericMerge(body, insertedColumns, insertedRow); subject = MergeHelper.MergeMemberInfo(subject, targetMember); body = MergeHelper.MergeMemberInfo(body, targetMember); subject = MergeHelper.MergeOtherMemberInfo(subject, sendingMember); body = MergeHelper.MergeOtherMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } finally { try { if (command != null) { command.Dispose(); } if (ds != null) { ds.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } } catch { } } }
public static void NewMemberComment() { SqlCommand command = null; DataSet ds = null; SqlDataAdapter dataAdapter = null; try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Insert: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); DataTable table = ds.Tables[0]; DataRow row = table.Rows[0]; DataColumnCollection columns = table.Columns; int MemberID = (int)row["MemberID"]; int MemberIDFrom = (int)row["MemberIDFrom"]; MemberSettings ms = null; ms = Member.GetMemberSettingsByMemberID(MemberID, connection); // In case we don't find any settings if (ms == null) { return; } if (!ms.NotifyNewProfileComment) { return; } Member targetMember = Member.GetMemberByMemberID(MemberID, connection); Member sendingMember = Member.GetMemberByMemberID(MemberIDFrom, connection); string TargetEmailAddress = targetMember.Email; string subject = Templates.NewMemberCommentSubject; string body = Templates.NewMemberCommentBody; subject = MergeHelper.GenericMerge(subject, columns, row); body = MergeHelper.GenericMerge(body, columns, row); subject = MergeHelper.MergeMemberInfo(subject, targetMember); body = MergeHelper.MergeMemberInfo(body, targetMember); subject = MergeHelper.MergeOtherMemberInfo(subject, sendingMember); body = MergeHelper.MergeOtherMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } finally { try { if (command != null) { command.Dispose(); } if (ds != null) { ds.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } } catch { } } }
public static void NewImportInvite() { SqlCommand command = null; SqlCommand command2 = null; SqlDataAdapter dataAdapter = null; SqlDataAdapter dataAdapter2 = null; DataSet ds = null; DataSet dsDel = null; //try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Update: using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); //Populate data from the inserted row DataRow updatedRow = ds.Tables[0].Rows[0]; DataColumnCollection updatedColumns = ds.Tables[0].Columns; command2 = new SqlCommand(@"SELECT * FROM DELETED;", connection); dataAdapter2 = new SqlDataAdapter(command2); dsDel = new DataSet(); dataAdapter2.Fill(dsDel); //Populate data from the inserted row DataRow deletedRow = dsDel.Tables[0].Rows[0]; DataColumnCollection deletedColumns = dsDel.Tables[0].Columns; if (((int)deletedRow["InviteState"] == (int)updatedRow["InviteState"]) || ((int)updatedRow["InviteState"] != 2)) { return; } int MemberID = (int)updatedRow["ImporterMemberID"]; string TargetEmailAddress = (string)updatedRow["Email"]; Member sendingMember = Member.GetMemberByMemberID(MemberID, connection); string ReferralString1 = InsertInviteClick(updatedRow, sendingMember, "/signup", connection); //Referral.Encrypt(ReferrerType.ContactImportID, (int)updatedRow["ContactImportID"], "/signup"); string ReferralString2 = InsertInviteClick(updatedRow, sendingMember, "/users/" + sendingMember.NickName, connection); //Referral.Encrypt(ReferrerType.ContactImportID, (int)updatedRow["ContactImportID"], "/users/" + sendingMember.NickName); //ReferralString1 = ReferralString1.Replace(@"/", "xxyyxx12345"); //ReferralString1 = ReferralString1.Replace(@"\", "12345xxyyxx"); //ReferralString2 = ReferralString2.Replace(@"/", "xxyyxx12345"); //ReferralString2 = ReferralString2.Replace(@"\", "12345xxyyxx"); string subject = Templates.NewImportInviteSubject; string body = Templates.NewImportInviteBody; subject = MergeHelper.GenericMerge(subject, updatedRow.Table.Columns, updatedRow); body = MergeHelper.GenericMerge(body, updatedRow.Table.Columns, updatedRow); subject = MergeHelper.MergeMemberInfo(subject, sendingMember); body = MergeHelper.MergeMemberInfo(body, sendingMember); body = MergeHelper.MergeReferral(body, 1, Utility.UrlEncode(ReferralString1)); body = MergeHelper.MergeReferral(body, 2, Utility.UrlEncode(ReferralString2)); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } //catch { } //finally { try { if (command != null) { command.Dispose(); } if (ds != null) { ds.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } } catch { } } }
public static void AcceptedFriendRequest() { SqlCommand command = null; SqlCommand command2 = null; SqlDataAdapter dataAdapter = null; SqlDataAdapter dataAdapter2 = null; DataSet ds = null; DataSet dsDel = null; try { SqlTriggerContext triggContext = SqlContext.TriggerContext; switch (triggContext.TriggerAction) { case TriggerAction.Update: // Retrieve the connection that the trigger is using using (SqlConnection connection = new SqlConnection(@"context connection=true")) { connection.Open(); command = new SqlCommand(@"SELECT * FROM INSERTED;", connection); dataAdapter = new SqlDataAdapter(command); ds = new DataSet(); dataAdapter.Fill(ds); //Populate data from the inserted row DataRow updatedRow = ds.Tables[0].Rows[0]; DataColumnCollection updatedColumns = ds.Tables[0].Columns; command2 = new SqlCommand(@"SELECT * FROM DELETED;", connection); dataAdapter2 = new SqlDataAdapter(command2); dsDel = new DataSet(); dataAdapter2.Fill(dsDel); //Populate data from the inserted row DataRow deletedRow = dsDel.Tables[0].Rows[0]; DataColumnCollection deletedColumns = dsDel.Tables[0].Columns; // If the old response value was zero and the new response value is ONE // only then its a request accept // Other wise return if (!((int)deletedRow["Status"] == 0 && (int)updatedRow["Status"] == 1)) { return; } // If the status has been updated to ONE but // response is still ZERO // means the friend request was rejected // Don't need to send the email on friend request reject if (((int)updatedRow["Response"] == 0 && (int)updatedRow["Status"] == 1)) { return; } int MemberIDTo = (int)updatedRow["FriendMemberID"]; int MemberIDFrom = (int)updatedRow["MemberID"]; MemberSettings ms = Member.GetMemberSettingsByMemberID(MemberIDTo, connection); // In case we don't find any settings if (ms == null) { return; } // If the user doesn't want to be notified return if (!ms.NotifyOnFriendRequest) { return; } Member targetMember = Member.GetMemberByMemberID(MemberIDTo, connection); Member sendingMember = Member.GetMemberByMemberID(MemberIDFrom, connection); string TargetEmailAddress = targetMember.Email; string subject = Templates.AcceptedFriendRequestSubject; string body = Templates.AcceptedFriendRequestBody; subject = MergeHelper.GenericMerge(subject, updatedColumns, updatedRow); body = MergeHelper.GenericMerge(body, updatedColumns, updatedRow); subject = MergeHelper.MergeMemberInfo(subject, targetMember); body = MergeHelper.MergeMemberInfo(body, targetMember); subject = MergeHelper.MergeOtherMemberInfo(subject, sendingMember); body = MergeHelper.MergeOtherMemberInfo(body, sendingMember); MailHelper.SendEmail(TargetEmailAddress, subject, body); } break; } } catch { } finally { try { if (command != null) { command.Dispose(); } if (command2 != null) { command2.Dispose(); } if (ds != null) { ds.Dispose(); } if (dsDel != null) { dsDel.Dispose(); } if (dataAdapter != null) { dataAdapter.Dispose(); } if (dataAdapter2 != null) { dataAdapter2.Dispose(); } } catch { } } }