Beispiel #1
0
        public static void Update(long performId, int status, DateTime performOnDate, bool isNeedConfirm)
        {
            var perform = PerformServices.GetById(performId);

            if (perform != null)
            {
                perform.Status = status;

                if (status == 2 && perform.IsFinishedConfirm == true && isNeedConfirm)
                {
                    perform.Status         = 3;
                    perform.FinishedOnDate = performOnDate;
                    perform.IsSynced       = false;
                }
                else if (status == 2 && (!isNeedConfirm || !perform.IsFinishedConfirm))
                {
                    perform.Status         = 2;
                    perform.FinishedOnDate = performOnDate;
                    perform.IsSynced       = false;
                }

                PerformServices.Update(perform);
            }

            RequestServices.CapNhatTrangThaiYKCD(perform.RequestID);
        }
Beispiel #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
        }
Beispiel #3
0
        /// <summary>
        /// Cập nhật lại trạng thái request sau khi cập nhật trạng thái perform bất kì
        /// </summary>
        /// <param name="MaYKCD"></param>
        /// <param name="connectionName"></param>
        public static int CapNhatTrangThaiYKCD(long MaYKCD, string connectionName = "DatabaseConnection")
        {
            var request = GetById(MaYKCD);

            if (request == null)
            {
                return(-1);
            }

            //Nếu đây là ý kiến chỉ đạo của UBND tỉnh
            if (request.IsProvinceRequest)
            {
                //Nếu ykcd của UB tỉnh đã hoàn thành, cập nhật các nội dung giao việc trong đơn vị thành đã hoàn thành
                if (request.Status == 2)
                {
                    foreach (var perform in request.Performs)
                    {
                        perform.Status         = 2;
                        perform.FinishedOnDate = request.FinishedOnDate;
                        PerformServices.Update(perform);
                    }
                }
                //Nếu ykcd đã giao cho phòng ban thực hiện, cập nhật trạng thái ykcd thành đang thực hiện
                else if (request.Status == 0 && request.IsAssignPerform)
                {
                    request.Status = 1;
                }
                //Nếu các nội dung giao việc đã hoàn thành, cập nhật trạng thái ykcd thành chờ xác nhận
                else if (request.Performs != null && request.Performs?.Count > 0 && request.Performs.TrueForAll(item => item.Status == 2) && request.Status != 2)
                {
                    request.Status = 3;
                }
                else if (request.Performs != null && request.Performs?.Count > 0 && request.Performs.TrueForAll(item => item.Status == 2))
                {
                    request.Status = 2;
                }
                else
                {
                    request.Status = 1;
                }
            }
            //Nếu đây là ykcd nội bộ đơn vị
            else
            {
                if (request.Performs.TrueForAll(item => item.Status == 0))
                {
                    request.Status = 0;
                }
                else if (request.Performs.TrueForAll(item => item.Status == 2))
                {
                    request.Status = 2;
                }
                else
                {
                    request.Status = 1;
                }
            }

            Update(request);

            return(request.Status);
        }
Beispiel #4
0
        public static void Create(Report report, List <int> performIds, object fileContent, string fileName, string uploadFolder, bool isStaffReport = false, bool isSendToProvince = false, bool isSendFromProvince = false)
        {
            if (!string.IsNullOrEmpty(report.ReportContent))
            {
                Create(report);

                ReportFileServices.CreateReportFile(report, fileContent, fileName, uploadFolder);
            }

            Request request = RequestServices.GetById(report.RequestID);

            if (request.IsProvinceRequest)
            {
                if (request.Performs.Count > 0)
                {
                    if (isSendFromProvince)
                    {
                        if (request.Status == 2)
                        {
                            foreach (var perform in request.Performs)
                            {
                                PerformServices.Update(performId: perform.PerformID, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false);
                            }
                        }
                    }
                    else if (isStaffReport)
                    {
                        if (performIds != null)
                        {
                            foreach (var performId in performIds)
                            {
                                PerformServices.Update(performId: performId, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false);
                            }

                            report.Status = RequestServices.CapNhatTrangThaiYKCD(request.RequestID);
                        }
                    }
                    else
                    {
                        PerformServices.Update(performId: performIds.FirstOrDefault(), status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: true);
                        report.Status = RequestServices.CapNhatTrangThaiYKCD(request.RequestID);
                    }

                    if (isSendToProvince)
                    {
                        ProvinceServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Province_Service"], report);
                    }
                }
                else
                {
                    if (!isSendFromProvince)
                    {
                        request.Status = report.Status;

                        if (request.Status == 2)
                        {
                            request.FinishedOnDate = report.PerformOnDate;
                        }

                        RequestServices.Update(request);

                        if (isSendToProvince)
                        {
                            ProvinceServiceHelper.ReceiveReport(ConfigurationManager.AppSettings["Province_Service"], report);
                        }
                    }
                }
            }
            else if (isStaffReport)
            {
                foreach (var performId in performIds)
                {
                    PerformServices.Update(performId: performId, status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: false);
                }
            }
            else
            {
                PerformServices.Update(performId: performIds.FirstOrDefault(), status: report.Status, performOnDate: report.PerformOnDate, isNeedConfirm: true);
            }
        }