public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; string result = string.Empty; if (context.Request.Params["activeID"] == null) { result = "{success:false,msg:'活动不能为空'}"; } else if (context.Request.Params["accountID"] == null) { result = "{success:false,msg:'用户不能为空'}"; } else if (context.Request.Params["type"] == null) { result = "{success:false,msg:'类型不能为空'}"; } else { int activeID = CY.Utility.Common.ConvertUtility.ConvertToInt(context.Request.Params["activeID"], 0);//活动ID long accountID = CY.Utility.Common.ConvertUtility.ConvertToLong(context.Request.Params["accountID"], 0);//用户ID string TYPE = context.Request.Params["type"].ToString(); try { if (TYPE == "1" || TYPE == "2") { CY.UME.Core.Business.ActivitieParticipants ap = new CY.UME.Core.Business.ActivitieParticipants(); ap.AccountId = accountID; ap.ActivitieId = activeID; ap.JionTime = DateTime.Now; int type = int.Parse(TYPE); ap.Type = type; ap.Save(); result = "{success:true}"; } else if (TYPE == "3" || TYPE == "4")//我不参加了|我不感兴趣了 { int Type = int.Parse(TYPE); int instrID = 0; if (Type == 3) { instrID = 1; } else if (Type == 4) { instrID = 2; } List<CY.UME.Core.Business.ActivitieParticipants> appList = CY.UME.Core.Business.ActivitieParticipants.GetByActiveIDandAccountID(activeID, accountID, instrID).ToList(); if (appList != null && appList.Count > 0) { CY.UME.Core.Business.ActivitieParticipants app = CY.UME.Core.Business.ActivitieParticipants.Load(appList[0].Id); if (app != null) { app.DeleteOnSave(); app.Save(); if (instrID == 1) { List<CY.UME.Core.Business.ActivitieParticipants> appListInterset = CY.UME.Core.Business.ActivitieParticipants.GetByActiveIDandAccountID(activeID, accountID, 2).ToList(); if (appListInterset != null && appListInterset.Count > 0) { CY.UME.Core.Business.ActivitieParticipants appI = CY.UME.Core.Business.ActivitieParticipants.Load(appListInterset[0].Id); if (appI != null) { appI.DeleteOnSave(); appI.Save(); } } } result = "{success:true}"; } else { result = "{success:false,msg:'服务器忙,请稍候再试'}"; } } else { result = "{success:false,msg:'你没有参加,不能退出'}"; } } } catch (Exception ex) { result = "{success:false,msg:'" + ex.Message + "'}"; } } context.Response.Write(result); }
protected void bunSumbit_Click(object sender, EventArgs e) { #region Valid if (string.IsNullOrEmpty(tbName.Text.Trim())) { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '活动名称不能为空'});</script>"); base.ExecuteClientScript("$('#add_msg').html('活动名称不能为空。').fadeOut(10000, function () { $(this).html('').show(); });"); tbName.Focus(); return; } if (tbName.Text.Trim().Length > 20) { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '活动名称不能超过20字符'});</script>"); base.ExecuteClientScript("$('#add_msg').html('活动名称不能为空。').fadeOut(10000, function () { $(this).html('').show(); });"); tbName.Focus(); return; } if (string.IsNullOrEmpty(tbStartTime.Text.Trim())) { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '活动起始时间不能为空'});</script>"); base.ExecuteClientScript("$('#add_msg').html('活动起始时间不能为空。').fadeOut(10000, function () { $(this).html('').show(); });"); tbStartTime.Focus(); return; } if (string.IsNullOrEmpty(tbEndTime.Text.Trim())) { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '活动结束时间不能为空'});</script>"); base.ExecuteClientScript("$('#add_msg').html('活动结束时间不能为空。').fadeOut(10000, function () { $(this).html('').show(); });"); tbEndTime.Focus(); return; } HttpPostedFile files = Request.Files["file"]; if (files.ContentLength > 0 && !string.IsNullOrEmpty(files.FileName)) { string fileExtension = CY.Utility.Common.FileUtility.GetFileExtension(files.FileName).ToLower(); if (fileExtension != ".jpg" && fileExtension != ".jpeg" && fileExtension != ".gif" && fileExtension != ".png" && fileExtension != ".bmp") { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '图片格式不正确,请上传图片格式'});</script>"); base.ExecuteClientScript("$('#add_msg').html('图片格式不正确,请重新选择图片上传。').fadeOut(10000, function () { $(this).html('').show(); });"); return; } } #endregion try { if (Request.QueryString["ActiveID"] == null) { CY.UME.Core.Business.Activities activ = new CY.UME.Core.Business.Activities(); activ.Name = tbName.Text.Trim();//活动名称 if (!string.IsNullOrEmpty(tbStartTime.Text.Trim())) { string startH = tbStartTime.Text.Trim(); string startM = ddlHour.SelectedValue; string startS = ddlM.SelectedValue; string Time = startH + " " + startM + ":" + startS; activ.StartTime = DateTime.Parse(Time);//起始时间 } if (!string.IsNullOrEmpty(tbEndTime.Text.Trim())) { string endH = tbEndTime.Text.Trim(); string endM = ddlH2.SelectedValue; string endS = ddlM2.SelectedValue; string endTime = endH + " " + endM + ":" + endS; activ.EndTime = DateTime.Parse(endTime);//结束时间 } activ.Sponsor = CurrentAccount.Id;//发起人 activ.Overview = tbOverView.Text.Trim();//活动简介 //activ.Slogans = tbSlogans.Text.Trim();//活动广告语 activ.Type = int.Parse(ddlType.SelectedValue);//活动类型 activ.Address = tbAddress.Text.Trim();//活动地址 if (Request.QueryString["groupId"] != null) { activ.Organizer = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["groupId"], 0); } activ.Save(); if (files != null && files.ContentLength > 0 && !string.IsNullOrEmpty(files.FileName)) { SaveFiles(activ.Id, activ.Name, files); } else { activ.CreateActiveAlbum(); } /*****************************************************************************/ //存入参加人表 CY.UME.Core.Business.ActivitieParticipants ap = new CY.UME.Core.Business.ActivitieParticipants(); ap.ActivitieId = activ.Id; ap.AccountId = CurrentAccount.Id; ap.JionTime = DateTime.Now; ap.Type = 1;//参加 ap.Save(); //存入感兴趣表 CY.UME.Core.Business.ActivitieParticipants apInterest = new CY.UME.Core.Business.ActivitieParticipants(); apInterest.ActivitieId = activ.Id; apInterest.AccountId = CurrentAccount.Id; apInterest.JionTime = DateTime.Now; apInterest.Type = 2;//感兴趣 apInterest.Save(); /******************************************************************************************************/ //添加通知 //CurrentAccount.SendNoticeToAllFriend("activites", CurrentAccount.Name + "创建了新活动:" + activ.Name, activ.Id.ToString());后台加 //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '发起活动成功,等待管理员审核,跳转到活动首页'});window.location.href='ActiveDefault.aspx'</script>"); base.ShowAlert("提示", "发起活动成功,等待管理员审核。<span>3</span>秒后自动跳转。", true, pageName, true); } else { int aID = CY.Utility.Common.ConvertUtility.ConvertToInt(Request.QueryString["ActiveID"], 0); CY.UME.Core.Business.Activities at = CY.UME.Core.Business.Activities.Load(aID); if (at != null) { at.Name = tbName.Text.Trim();//活动名称 if (!string.IsNullOrEmpty(tbStartTime.Text.Trim())) { string startH = tbStartTime.Text.Trim(); string startM = ddlHour.SelectedValue; string startS = ddlM.SelectedValue; string Time = startH + " " + startM + ":" + startS; at.StartTime = DateTime.Parse(Time);//起始时间 } if (!string.IsNullOrEmpty(tbEndTime.Text.Trim())) { string endH = tbEndTime.Text.Trim(); string endM = ddlH2.SelectedValue; string endS = ddlM2.SelectedValue; string endTime = endH + " " + endM + ":" + endS; at.EndTime = DateTime.Parse(endTime);//结束时间 } //at.Sponsor = CurrentAccount.Id;//发起人 at.Overview = tbOverView.Text.Trim();//活动简介 //at.Slogans = tbSlogans.Text.Trim();//活动广告语 at.Type = int.Parse(ddlType.SelectedValue);//活动类型 at.Address = tbAddress.Text.Trim();//活动地址 at.Save(); if (files != null && files.ContentLength > 0 && !string.IsNullOrEmpty(files.FileName)) { if (File.Exists(Server.MapPath(at.Pic))) { File.Delete(Server.MapPath(at.Pic)); } SaveFiles(at.Id, at.Name, files); } if (at.IsCheck) { //添加通知 //CurrentAccount.SendNoticeToAllFriend("activites", CurrentAccount.Name + "创建了新活动:" + at.Name, aID.ToString());后台加 //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '编辑活动成功,跳转到活动首页'});window.location.href='ActiveDetail2.aspx?aid=" + aID + "'</script>"); base.ShowAlert("提示", "编辑活动成功。<span>3</span>秒后自动跳转。请稍后。。。", true, pageName, true); } else { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '修改活动成功,等待管理员审核,跳转到活动首页'});window.location.href='ActiveDefault.aspx'</script>"); base.ShowAlert("提示", "修改活动成功,等待管理员审核。<span>3</span>秒后自动跳转。<br/>请稍后。。。", true, pageName, true); } } } } catch (Exception ex) { //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '" + ex.Message + "'});</script>"); base.ShowAlert("提示", ex.Message, false, "", true); return; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; int ActiveID = 0; CY.UME.Core.Business.Account currentAccount; #region validate if (context.Request.Params["ActiveID"] == null) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } if (!int.TryParse(context.Request.Params["ActiveID"].ToString(), out ActiveID)) { context.Response.Write("{success:false,msg:'参数错误'}"); return; } currentAccount = CY.UME.Core.Global.GetCurrentAccount(); if (currentAccount == null) { context.Response.Write("{success:false,msg:'用户登录超时失败,请重新登录'}"); return; } #endregion try { CY.UME.Core.Business.Activities act = CY.UME.Core.Business.Activities.Load(ActiveID); if (act == null) { context.Response.Write("{success:false,msg:'该活动不存在或已被删除'}"); return; } //标识活动邀请通知已读 IList<CY.UME.Core.Business.Notice> noticeList = CY.UME.Core.Business.Notice.GetNoticeByTypeAndInstanceId(currentAccount, false, "activeInviteFriend", ActiveID.ToString(), new CY.UME.Core.PagingInfo { CurrentPage = 1, PageSize = int.MaxValue }); foreach (CY.UME.Core.Business.Notice notice in noticeList) { CY.UME.Core.Business.Notice noticeTemp = CY.UME.Core.Business.Notice.Load(notice.Id); noticeTemp.IsReaded = true; noticeTemp.Save(); } if (noticeList.Count > 0) { //查看被邀请人是否自己参与些活动 List<CY.UME.Core.Business.ActivitieParticipants> listJion = CY.UME.Core.Business.ActivitieParticipants.GetByActiveIDandAccountID(ActiveID, currentAccount.Id, 1).ToList(); if (listJion != null && listJion.Count > 0) { //do nothing } else { //若已参加,则忽略此条邀请 CY.UME.Core.Business.ActivitieParticipants ap = new CY.UME.Core.Business.ActivitieParticipants(); ap.AccountId = currentAccount.Id; ap.ActivitieId = ActiveID; ap.JionTime = DateTime.Now; ap.Type = 1;//接受邀请,参加 ap.Save(); } //删除ActivitiesInvite中数据,以便下一次邀请能够读出来 List<CY.UME.Core.Business.ActivitiesInvite> acInvitelist= CY.UME.Core.Business.ActivitiesInvite.Get(noticeList[0].AuthorId,currentAccount.Id, ActiveID).ToList(); if (acInvitelist != null && acInvitelist.Count > 0) { CY.UME.Core.Business.ActivitiesInvite ai = CY.UME.Core.Business.ActivitiesInvite.Load(acInvitelist[0].Id); if (ai != null) { ai.DeleteOnSave(); ai.Save(); } } } context.Response.Write("{success:true,ActiveName:'" +act.Name+ "'}"); } catch { context.Response.Write("{success:false,msg:'请稍后,系统忙'}"); } }