Example #1
0
        ///// <summary>
        ///// 站内分享
        ///// </summary>
        ///// <param name="objectId">课程Id</param>
        ///// <param name="objectType">
        /////   0:课程
        /////   1:知识
        /////   2:计划
        /////   3:讲师
        /////   10:外部资源
        /////  </param>
        ///// <param name="shareFlag">
        ///// 分享类型
        ///// <para>0:个人</para>
        ///// <para>1:同岗位</para>
        ///// <para>2:同部门</para>
        ///// <para>3:好友</para>
        ///// </param>
        ///// <param name="userIds"></param>
        ///// <returns></returns>
        //public JsonResult StationShareResource(int objectId, int objectType, string shareFlag, int sourceId, string userIds)
        //{
        //    try
        //    {
        //        var list = new List<ShareTarget>();
        //        if (!string.IsNullOrWhiteSpace(shareFlag))
        //        {
        //            if (shareFlag.Contains("0"))
        //            {
        //                var user = userIds.GetArray();
        //                for (int i = 0; i < user.Length; i++)
        //                {
        //                    list.Add(new ShareTarget
        //                    {
        //                        TargetId = user[i],
        //                        TargetType = 0
        //                    });
        //                }
        //            }
        //            if (shareFlag.Contains("1") && CurrentUser.PostId > 0)
        //            {
        //                list.Add(new ShareTarget
        //                {
        //                    TargetId = CurrentUser.PostId,
        //                    TargetType = 1
        //                });
        //            }
        //            if (shareFlag.Contains("2") && CurrentUser.DeptId > 0)
        //            {
        //                list.Add(new ShareTarget
        //                {
        //                    TargetId = CurrentUser.DeptId,
        //                    TargetType = 2
        //                });
        //            }
        //            if (shareFlag.Contains("3"))
        //            {
        //                var relationshipService = new RelationshipService();
        //                var user = relationshipService.GetFriends(CurrentUser.UserId);
        //                if (user.Count() > 0)
        //                {
        //                    foreach (var item in user)
        //                    {
        //                        list.Add(new ShareTarget
        //                        {
        //                            TargetId = item,
        //                            TargetType = 3
        //                        });
        //                    }
        //                }
        //            }
        //        }

        //        IntSharedManager.AddStationiShare(CurrentTenant.TenantId, CurrentUser.UserId, objectId, objectType, sourceId, list);

        //        #region 积分

        //        if (objectType == 0)
        //        {
        //            IntegrationManager.FireIntegrationEvent(IntegrationEvents.ShareCourse, CurrentUser.UserId, CurrentTenant.TenantId);
        //        }
        //        else if (objectType == 1)
        //        {
        //            IntegrationManager.FireIntegrationEvent(IntegrationEvents.ShareKnowledge, CurrentUser.UserId, CurrentTenant.TenantId);
        //        }

        //        #endregion

        //        return Json(new
        //        {
        //            result = 1,
        //            content = RetechWing.LanguageResources.Learning.fenxiangchenggong
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //    catch
        //    {
        //        return Json(new
        //        {
        //            result = 0,
        //            content = RetechWing.LanguageResources.Learning.fenxiangshibai
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //}

        #endregion

        /// <summary>
        /// 站内分享
        /// </summary>
        /// <param name="objectId">课程Id</param>
        /// <param name="objectType">
        ///   0:课程
        ///   1:知识
        ///   2:计划
        ///   3:讲师
        ///   10:外部资源
        ///  </param>
        /// <param name="shareFlag">
        /// 分享类型
        /// <para>0:个人</para>
        /// <para>1:同岗位</para>
        /// <para>2:同部门</para>
        /// <para>3:好友</para>
        /// </param>
        /// <param name="userIds"></param>
        /// <returns></returns>
        public JsonResult StationShareResource(int objectId, int objectType, int sourceId, string recommend)
        {
            try
            {
                IntSharedManager.AddStationiShare(CurrentTenant.TenantId, CurrentUser.UserId, objectId, objectType, sourceId, new List <ShareTarget>(), recommend);

                //添加到动态
                if (objectType == 0)
                {
                    activityService.AddActivity(CurrentUser.UserId, objectId, ActionType.CourseShared, recommend);
                }
                else if (objectType == 1)
                {
                    activityService.AddActivity(CurrentUser.UserId, objectId, ActionType.KnowledgeShared, recommend);
                }
                else if (objectType == 2)
                {
                    activityService.AddActivity(CurrentUser.UserId, objectId, ActionType.StudyPlanShared, recommend);
                }


                #region 积分

                if (objectType == 0)
                {
                    IntegrationManager.Instence.FireIntegrationEvent(IntegrationEvents.ShareCourse, CurrentUser.UserId, CurrentTenant.TenantId);
                }
                else if (objectType == 1)
                {
                    IntegrationManager.Instence.FireIntegrationEvent(IntegrationEvents.ShareKnowledge, CurrentUser.UserId, CurrentTenant.TenantId);
                }

                #endregion

                return(Json(new
                {
                    result = 1,
                    content = RetechWing.LanguageResources.Learning.fenxiangchenggong
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new
                {
                    result = 0,
                    content = RetechWing.LanguageResources.Learning.fenxiangshibai
                }, JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public JsonResult Create(Activity activity)
        {
            try
            {
                if (LoginOrganize != null)
                {
                    string[] EnrollTime   = Request["EnrollTime"].Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                    string[] ActivtiyTime = Request["ActivityTime"].Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                    activity.ActivityEnrollStart = DateTime.Parse(EnrollTime[0]);
                    activity.ActivityEnrollEnd   = DateTime.Parse(EnrollTime[1]);
                    activity.ActivityStart       = DateTime.Parse(ActivtiyTime[0]);
                    activity.ActivityEnd         = DateTime.Parse(ActivtiyTime[1]);
                }
                if (activity.ActivityEnrollEnd > activity.ActivityStart)
                {
                    return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
                }
                if (UserInfoService.GetEntities(u => u.UserInfoID == activity.ActivityManagerID).FirstOrDefault() == null)
                {
                    return(Json(new { msg = "noexist" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch
            {
                return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
            }

            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(activity.ActivityIcon))
                {
                    activity.ActivityIcon = System.Configuration.ConfigurationManager.AppSettings["DefaultActivityIconPath"];
                }
                if (LoginOrganize != null)//组织注册
                {
                    activity.ActivityApplyOrganizeID = LoginOrganize.OrganizeInfoID;
                    //activity.Status = LoginOrganize.OrganizeInfoManageId == null ? delUndone : delAuditing;
                    activity.Status = activity.ActivityTypeID == 1 ? (LoginOrganize.OrganizeInfoManageId == null? delUndone:delAuditing) : delUndone;
                }
                else//
                {
                    activity.ActivityApplyUserInfoID = LoginUser.UserInfoID;
                    activity.ActivityApplyOrganizeID = LoginUser.OrganizeInfoID;
                    activity.Status             = delAuditing;
                    activity.ActivityDepartment = ",";
                    activity.ActivityMajor      = ",";
                    activity.ActivityPolitical  = ",";
                }
                activity.ActivityClicks = 0;
                activity.CreateTime     = DateTime.Now;
                activity.ModfiedOn      = activity.CreateTime;

                if (ActivityService.AddActivity(activity))
                {
                    return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        private void btnAddActivity_Click(object sender, EventArgs e)
        {
            Activity activities = new Activity();

            activities.Description = txtDescription.Text;
            activities.StartDate   = DateTime.Parse(txtStart.Text);
            activities.EndDate     = DateTime.Parse(txtEnd.Text);

            activityService.AddActivity(activities);
        }
Example #4
0
        public IActionResult AddActivity([FromBody] ActivityDTO activityDTO)
        {
            ActivityDTO addedActivity = null;

            if (!activityDTO.isAssay)
            {
                addedActivity = _activityService.AddActivity(activityDTO);
            }

            if (addedActivity != null)
            {
                return(new CreatedAtRouteResult("GetActivityById", new { activityId = addedActivity.Id }, addedActivity));
            }

            return(new StatusCodeResult(StatusCodes.Status409Conflict));
        }
        public void AddActivity_WhenActivityDescriptionIsMissing()
        {
            //Arrange
            var newActivity = new Activity {
                Description = string.Empty
            };

            var activityService = new ActivityService();

            //Act

            var result = activityService.AddActivity(newActivity);

            //Asserts
            Assert.AreEqual(StatusCode.Error, result.StatusCode);
            Assert.AreEqual("The Description field is required.", result.StatusMessage);
        }
Example #6
0
        private void btn_activity_create_Click(object sender, EventArgs e)
        {
            ActivityService activityService = new ActivityService();

            btn_activity_create.Enabled = false;

            try
            {
                activityService.AddActivity(tb_activity_create_omschrijving.Text, tb_activity_create_student_count.Text, tb_activity_create_begeleider_count.Text);
                showPanel("activity");
            }
            catch (Exception f)
            {
                lbl_activity_create_status.Text = $"Error: {f.Message}";
            }
            finally
            {
                btn_activity_create.Enabled = true;
            }
        }
Example #7
0
        /// <summary>
        /// 保存说说
        /// </summary>
        /// <param name="content"></param>
        /// <param name="isprivate"></param>
        /// <returns></returns>
        public JsonResult SaveTalk(string content, int isprivate)
        {
            //var talk = new Talk();
            //talk.CreateTime = DateTime.Now;
            //talk.IsPrivate = isprivate;
            //talk.TalkContent = content;
            //talk.UserId = CurrentUser.UserId;
            //talkService.Add(talk);
            //动态
            int actid = activityService.AddActivity(CurrentUser.UserId, 0, ActionType.Talk, content, isprivate);

            #region 积分
            //公开的说说才加积分
            if (isprivate == 0)
            {
                BusinessCommon.Integration.IntegrationManager.Instence.FireIntegrationEvent(IntegrationEvents.Talk,
                                                                                            CurrentUser.UserId, CurrentTenant.TenantId);
            }
            #endregion

            return(Json(new { result = 1, msg = RetechWing.LanguageResources.Common.SaveSuccess, dataId = actid, pubtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm") }, JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> AddActivity([FromBody] Activity model)
        {
            var activity = await _activitiesService.AddActivity(model);

            return(CreatedAtAction(nameof(GetActivityById), new { id = activity.Id }, activity));
        }