public int AddWish(long accountId, string content, string wallColor, string fontColor, int credit, int isFirstDay) { CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(accountId); CY.UME.Core.Business.Wishing wishtemp = new CY.UME.Core.Business.Wishing(); if (account == null) { return 1; } if (content.Trim().Length > 250 || wallColor.Trim().Length > 10 || fontColor.Length > 10) { return 3; } if (credit > account.Credit) { return 2; } if (credit > 0 && wishtemp.ValidateIsAdd() == 0) { return 4; } bool isTop = false; int days = 0; if (credit != 0) { switch (credit) { case 100: days = 1; break; default: days = -1; break; } if (days == -1) { return 0; } isTop = true; } try { CY.UME.Core.Business.Wishing wish = new CY.UME.Core.Business.Wishing(); DateTime dt = DateTime.Now; wish.AccountId = accountId; wish.WallColor = wallColor; wish.FontColor = fontColor; wish.Content = content.Trim(); wish.DateCreated = dt; wish.EndDate = dt.AddDays(days); wish.IsTop = isTop; wish.ReplyNum = 0; wish.Credit = credit; wish.Save(); /***********第一天活动****************/ if (isFirstDay.ToString() == "1") { CY.UME.Core.Business.WishingExtend we = new CY.UME.Core.Business.WishingExtend(); we.AccountId = wish.AccountId; we.ActivityId = "myfirstday"; we.Id = wish.Id; we.Save(); } /************第一天活动结束**************/ return 1; } catch { return 0; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; string content = context.Request.Form["content"].ToString().Trim(); string strCredit = context.Request.Form["credit"].ToString().Trim(); DateTime endDate=CY.UME.Core.Global.MinDateTime; DateTime dateCreated=DateTime.Now; bool isTop = false; int credit = 0; if (content.Length == 0 || content.Length>100) { context.Response.Write("{success:false,msg:'许愿内容为空或长度过长'}"); return; } if (strCredit.Length == 0) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } if (!int.TryParse(strCredit, out credit)) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } CY.UME.Core.Business.Account account = CY.UME.Core.Global.GetCurrentAccount(); if (account == null) { context.Response.Write("{success:false,msg:'用户登录超时'}"); return; } if (credit > account.Credit) { context.Response.Write("{success:false,msg:'您的积分不够'}"); return; } if (credit != 0) { //CY.UME.Core.Business.WishWallCreditPolicy cp = new CY.UME.Core.Business.WishWallCreditPolicy(); //int days = cp.GetDaysByCredit(credit); int days = 0; switch (credit) { case 100: days = 1; break; default: days = -1; break; } dateCreated = DateTime.Now; if (days == -1) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } else { endDate = dateCreated.AddDays(days); } isTop = true; } try { CY.UME.Core.Business.Wishing wish = new CY.UME.Core.Business.Wishing(); wish.AccountId = account.Id; wish.Content = content; wish.DateCreated = dateCreated; wish.EndDate = endDate; wish.ReplyNum = 0; wish.IsTop = isTop; wish.Save(); context.Response.Write("{success:true}"); } catch (Exception ex) { context.Response.Write("{success:false,msg:'"+ex.Message+"'}"); } }