本文整理汇总了C#中Member.getProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Member.getProperty方法的具体用法?C# Member.getProperty怎么用?C# Member.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member.getProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Member_AfterSave
void Member_AfterSave(Member sender, umbraco.cms.businesslogic.SaveEventArgs e)
{
Document[] documents = Document.GetChildrenForTree(int.Parse(UmbracoCustom.GetParameterValue(UmbracoType.GymnastNode)));
Document documentMember = documents.SingleOrDefault(d => d.Text == sender.Text);
Property gymnast = sender.getProperty("gymnast");
if (documentMember == null && Roles.GetRolesForUser(sender.LoginName).Any())
{
DocumentType documentType = DocumentType.GetByAlias("Gymnast");
Document document = Document.MakeNew(sender.Text, documentType, new User("admin"), int.Parse(UmbracoCustom.GetParameterValue(UmbracoType.GymnastNode)));
document.getProperty("member").Value = sender.Id;
document.Save();
gymnast.Value = document.Id;
sender.Save();
//Log.Add(LogTypes.New, int.Parse(UmbracoCustom.GetParameterValue(UmbracoType.GymnastNode)), string.Format("Create new user {0} in Member_AfterSave event", sender.Text));
}
else if (gymnast.Value == null && Roles.GetRolesForUser(sender.LoginName).Any())
{
gymnast.Value = documentMember.Id;
sender.Save();
}
//sender.Save();
//if (sender.LoginName != sender.Text && documentMember == null)
}
示例2: SendNotification
public override bool SendNotification(System.Xml.XmlNode details, params object[] args)
{
SmtpClient c = new SmtpClient(details.SelectSingleNode("//smtp").InnerText);
c.Credentials = new System.Net.NetworkCredential(details.SelectSingleNode("//username").InnerText, details.SelectSingleNode("//password").InnerText);
MailAddress from = new MailAddress(
details.SelectSingleNode("//from/email").InnerText,
details.SelectSingleNode("//from/name").InnerText);
string subject = details.SelectSingleNode("//subject").InnerText;
string body = details.SelectSingleNode("//body").InnerText;
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["umbracoDbDSN"]);
string select = @"select id, memberId from forumTopics where answer = 0
and created < getdate() - 7
and created > '2010-06-10 00:00:00'
and id not in (select topicId from notificationMarkAsSolution)
order by created desc;";
SqlCommand comm = new SqlCommand(
select, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
string domain = details.SelectSingleNode("//domain").InnerText;
while (dr.Read())
{
int topicId = dr.GetInt32(0);
string mbody = string.Format(body,
t.Title,
"http://" + domain + args[1].ToString());
Member m = new Member(dr.GetInt32(1));
if (m.getProperty("bugMeNot") != null || m.getProperty("bugMeNot").Value.ToString() != "1")
{
MailMessage mm = new MailMessage();
mm.Subject = subject;
mm.Body = mbody;
mm.To.Add(m.Email);
mm.From = from;
c.Send(mm);
}
string insert =
"Insert into notificationMarkAsSolution(topicId, memberID, timestamp) values(@topicId, @memberID, getdate())";
SqlCommand icomm = new SqlCommand(insert, conn);
icomm.Parameters.AddWithValue("@topicId", topicId);
icomm.Parameters.AddWithValue("@memberID", m.Id);
icomm.ExecuteNonQuery();
}
conn.Close();
return true;
}
示例3: HandleCreateDiscussion
public ActionResult HandleCreateDiscussion(UMFCreateDiscussionModel model)
{
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
var cs = Services.ContentService;
var helper = new UmbracoHelper(UmbracoContext);
int userId = 0;
try
{
int.TryParse(Membership.GetUser().ProviderUserKey.ToString(), out userId);
}
catch { }
//Check if its a new discussion or one gets updated
if (model.id == 0)
{
//Create a new Discussion
var newDiscusssion = cs.CreateContent(model.name, cs.GetById(model.parent), "UMF_Discussion");
newDiscusssion.SetValue("bodyText", model.text);
newDiscusssion.SetValue("userId", userId);
newDiscusssion.SetValue("sticky", false);
cs.SaveAndPublish(newDiscusssion);
//Insert new count of posts to the member and update karma
if (0 != userId)
{
var settings = this.GetSettings(newDiscusssion.Id);
var member = new Member(userId);
int noPosts = 0, karma = 0;
try
{
if (int.TryParse(member.getProperty("numberOfPosts").Value.ToString(), out noPosts))
{
//Managed to parse it to a number
//Don't need to do anything as we have default value of 0
}
member.getProperty("numberOfPosts").Value = noPosts + 1;
}
catch { }
try
{
if (settings.useKarma)
{
int.TryParse(member.getProperty("karma").Value.ToString(), out karma);
member.getProperty("karma").Value = karma + settings.KarmaForAnswer;
}
}
catch { }
member.Save();
}
}
else
{
//Update discussion
var discussion = cs.GetById(model.id);
discussion.Name = model.name;
discussion.SetValue("bodyText", model.text);
cs.SaveAndPublish(discussion);
}
return Redirect(helper.TypedContent(model.parent).Url);
}
示例4: MarkAsAnswer
public ActionResult MarkAsAnswer(int answer, int discussion)
{
var cs = Services.ContentService;
var helper = new UmbracoHelper(UmbracoContext);
//Update Answer
var current = cs.GetById(answer);
current.SetValue("isAnswer", true);
cs.SaveAndPublish(current);
//Uopdate Karma
var settings = this.GetSettings(answer);
if (settings.useKarma)
{
int userId = Convert.ToInt32(current.GetValue("userId").ToString());
var member = new Member(userId);
int karma = 0;
int.TryParse(member.getProperty("karma").Value.ToString(),out karma);
member.getProperty("karma").Value = karma + settings.KarmaForMarkedAnswer;
member.Save();
}
return Redirect(helper.TypedContent(discussion).Url);
}
示例5: HandleCreateAnswer
public ActionResult HandleCreateAnswer(UMFCreateAnswerModel model)
{
if (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
var cs = Services.ContentService;
var helper = new UmbracoHelper(UmbracoContext);
int userId = 0;
try
{
int.TryParse(Membership.GetUser().ProviderUserKey.ToString().Trim(), out userId);
}
catch { }
//Check if its a new one or it gets updated
if (model.id == 0)
{
//Create new answer
var newDiscusssion = cs.CreateContent("Comment-" + helper.TypedContent(model.parent).Children.Count().ToString(), cs.GetById(model.parent), "UMF_Answer");
newDiscusssion.SetValue("bodyText", model.text);
newDiscusssion.SetValue("userId", userId);
cs.SaveAndPublish(newDiscusssion);
if (userId != 0)
{
//Insert new count of posts to the member and update karma
var settings = this.GetSettings(newDiscusssion.Id);
var member = new Member(userId);
int noPosts = 0, karma = 0;
if (int.TryParse(member.getProperty("numberOfPosts").Value.ToString(), out noPosts))
{
//Managed to parse it to a number
//Don't need to do anything as we have default value of 0
}
member.getProperty("numberOfPosts").Value = noPosts + 1;
if (settings.useKarma)
{
int.TryParse(member.getProperty("karma").Value.ToString(), out karma);
member.getProperty("karma").Value = karma + settings.KarmaForAnswer;
}
member.Save();
}
//Send Notification email
var node = Umbraco.AssignedContentItem;
//Loop through each relation to get member wich want to get notified
var rs = Services.RelationService;
foreach (var rel in rs.GetByParentOrChildId(Umbraco.AssignedContentItem.Id).Where(x => x.RelationType.Alias == "UMF_EmailNotification"))
{
try
{
var member = new Member(rel.ParentId);
new MailController()
.SendNotificationEmail(
member.Email,
Umbraco.AssignedContentItem.GetPropertyValue<string>("notificationSubject", true, "New Notification on Forum"),
Umbraco.AssignedContentItem.GetPropertyValue<string>("fromEmail", true, "[email protected]" + Request.Url.Host),
Umbraco.TypedContent(model.parent),
CultureInfo.CurrentCulture.TwoLetterISOLanguageName.ToUpper()
).Deliver();
}
catch (Exception ex) { LogHelper.Error<UMFSurfaceController>("Failed to send notification email", ex); }
}
}
else
{
//Update answer
var discussion = cs.GetById(model.id);
discussion.SetValue("bodyText", model.text);
cs.SaveAndPublish(discussion);
}
return Redirect(helper.TypedContent(model.parent).Url);
}