示例#1
0
        /// <summary>
        /// Giao việc một ý kiến chỉ đạo cho cá nhân, đơn vị thực hiện
        /// </summary>
        /// <param name="request">Thông tin ý kiến chỉ đạo</param>
        /// <param name="requesterId">Mã người giao việc</param>
        /// <param name="trackerIds">Mã người theo dõi</param>
        /// <param name="departmentIds">Mã đơn vị thực hiện</param>
        /// <param name="isFinishedConfirm">Có cần xác nhận</param>
        public static void Assign(Request request, int requesterId, List <int> trackerIds, List <int> departmentIds, bool isFinishedConfirm)
        {
            foreach (var trackerId in trackerIds)
            {
                Tracking tracking = new Tracking(request.RequestID, trackerId);
                TrackingServices.Create(tracking);
            }

            foreach (var departmentId in departmentIds)
            {
                Perform perform = new Perform(requestId: request.RequestID, departmentId: departmentId, requiredDate: request.RequiredDate);
                perform.IsFinishedConfirm = isFinishedConfirm;
                PerformServices.CreatePerform(perform);
            }

            var orgRequest = GetById(request.RequestID);

            orgRequest.Status          = 1;
            orgRequest.IsAssignPerform = true;
            orgRequest.RequesterID     = requesterId;

            Update(orgRequest);

            if (request.IsAgencyRequest)
            {
                orgRequest.CreatedBy = CommonSessions.UserID;
                Update(orgRequest);

                Report report = new Report()
                {
                    ReportContent = $"Đã giao cho {request.Departments?.Select(i => i.DepartmentName)?.ToList()?.DisplayInline()} thực hiện",
                    PerformOnDate = DateTime.Now,
                    RequestID     = request.RequestID,
                    Status        = 1
                };

                AgencyServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Agency_Service"], report);
            }
        }
示例#2
0
        /// <summary>
        /// Cập nhật thông tin ý kiến chỉ đạo
        /// </summary>
        /// <param name="request"></param>
        /// <param name="trackerIds"></param>
        /// <param name="departmentIds"></param>
        /// <param name="userIds"></param>
        public static void Update(Request request, List <int> trackerIds, List <int> departmentIds = null, List <int> userIds = null, bool isFinishedConfirm = false)
        {
            Update(request);

            #region Lưu thông tin chuyên viên theo dõi
            var oldTrackers = TrackingServices.GetList(request.RequestID);

            foreach (var oldTracker in oldTrackers)
            {
                if (!trackerIds.Contains(oldTracker.UserID))
                {
                    TrackingServices.Delete(oldTracker.TrackingID);
                }
            }

            foreach (var trackerId in trackerIds)
            {
                if (!oldTrackers.Select(t => t.UserID).Contains(trackerId))
                {
                    TrackingServices.Create(new Tracking(request.RequestID, trackerId));
                }
            }
            #endregion

            #region Lưu thông tin đơn vị thực hiện
            if (departmentIds != null)
            {
                var oldDepartmentPerforms = request.Performs.Where(p => p.DepartmentID > 0);

                foreach (var oldPerform in oldDepartmentPerforms)
                {
                    if (!departmentIds.Contains(oldPerform.DepartmentID))
                    {
                        PerformServices.Delete(oldPerform.PerformID);
                    }
                }

                foreach (var departmentId in departmentIds)
                {
                    if (!oldDepartmentPerforms.Select(t => t.DepartmentID).Contains(departmentId))
                    {
                        Perform perform = new Perform(requestId: request.RequestID, departmentId: departmentId, requiredDate: request.RequiredDate);
                        perform.IsFinishedConfirm = isFinishedConfirm;
                        PerformServices.CreatePerform(perform);
                    }
                    else
                    {
                        var perform = PerformServices.GetList(request.RequestID, departmentId: departmentId).FirstOrDefault();

                        if (perform != null)
                        {
                            perform.RequiredDate      = request.RequiredDate;
                            perform.IsFinishedConfirm = isFinishedConfirm;
                            PerformServices.Update(perform);
                        }
                    }
                }
            }
            #endregion

            #region Lưu thông tin người thực hiện
            if (userIds != null)
            {
                var oldUserPerforms = request.Performs.Where(p => p.UserID > 0);

                foreach (var oldPerform in oldUserPerforms)
                {
                    if (!userIds.Contains(oldPerform.UserID))
                    {
                        PerformServices.Delete(oldPerform.PerformID);
                    }
                }

                foreach (var userId in userIds)
                {
                    if (!oldUserPerforms.Select(t => t.UserID).Contains(userId))
                    {
                        Perform perform = new Perform(requestId: request.RequestID, userId: userId, requiredDate: request.RequiredDate);
                        PerformServices.CreatePerform(perform);
                    }
                    else
                    {
                        var perform = PerformServices.GetList(request.RequestID, userId: userId).FirstOrDefault();

                        if (perform != null)
                        {
                            perform.RequiredDate = request.RequiredDate;
                            PerformServices.Update(perform);
                        }
                    }
                }
            }

            #endregion
        }