コード例 #1
0
        public ActionResult SaveVanBanDen(HSCV_VANBANDEN entity, FormCollection fc, IEnumerable <HttpPostedFileBase> filebase, string[] filename, string[] FOLDER_ID)
        {
            try
            {
                AssignUserInfo();

                UploadFileTool uploadFileTool = new UploadFileTool();
                hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>();
                wfProcessBusiness     = Get <WF_PROCESSBusiness>();
                dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();

                entity.SOHIEU            = fc["SOHIEU"].Trim();
                entity.TRICHYEU          = fc["TRICHYEU"].Trim();
                entity.SOTRANG           = fc["SOTRANG"].ToIntOrZero();
                entity.LOAIVANBAN_ID     = fc["LOAIVANBAN_ID"].ToIntOrZero();
                entity.DONVI_ID          = fc["DONVI_ID"].ToIntOrZero();
                entity.LINHVUCVANBAN_ID  = fc["LINHVUCVANBAN_ID"].ToIntOrZero();
                entity.DOKHAN_ID         = fc["DOKHAN_ID"].ToIntOrZero();
                entity.NGAY_HIEULUC      = fc["NGAY_HIEULUC"].ToDateTime();
                entity.NGAYHET_HIEULUC   = fc["NGAYHET_HIEULUC"].ToDateTime();
                entity.NGAY_VANBAN       = fc["NGAY_VANBAN"].ToDateTime();
                entity.NGAY_BANHANH      = fc["NGAY_BANHANH"].ToDateTime();
                entity.NGUOIKY           = !string.IsNullOrEmpty(fc["NGUOIKY"]) ? fc["NGUOIKY"].Trim() : string.Empty;
                entity.CHUCVU            = !string.IsNullOrEmpty(fc["CHUCVU"]) ? fc["CHUCVU"].Trim() : string.Empty;
                entity.NOIDUNG           = !string.IsNullOrEmpty(fc["NOIDUNGVANBAN"]) ? fc["NOIDUNGVANBAN"].Trim() : string.Empty;
                entity.DOMAT_ID          = fc["DOMAT_ID"].ToIntOrZero();
                entity.SOVANBANDEN_ID    = fc["SOVANBANDEN_ID"].ToIntOrZero();
                entity.SODITHEOSO        = fc["SODITHEOSO"].Trim();
                entity.NGAYCONGTAC       = fc["NGAYCONGTAC"].ToDateTime();
                entity.GIO_CONGTAC       = fc["GIO_CONGTAC"].ToIntOrNULL();
                entity.PHUT_CONGTAC      = fc["PHUT_CONGTAC"].ToIntOrNULL();
                entity.SODITHEOSO_NUMBER = int.Parse(entity.SODITHEOSO);
                entity.MA_DANGKY         = fc["MA_DANGKY"];
                entity.LOAI_COQUAN_ID    = fc["LOAI_COQUAN_ID"].ToIntOrNULL();
                entity.SO_BAN            = fc["SO_BAN"].ToIntOrNULL();
                entity.THONGTIN_LOAI_ID  = fc["THONGTIN_LOAI_ID"].ToIntOrNULL();
                entity.TACGIA            = fc["TACGIA"];
                entity.CONGVAN_DEN_ID    = fc["CONGVAN_DEN_ID"].ToIntOrNULL();
                entity.THOIHAN_GIAIQUYET = fc["THOIHAN_GIAIQUYET"].ToDateTime();
                List <long> ListUser = new List <long>();
                ListUser.Add(currentUser.ID);
                if (entity.ID == 0)
                {
                    entity.NGAYTAO  = DateTime.Now;
                    entity.NGUOITAO = currentUser.ID;
                    entity.NGAYSUA  = DateTime.Now;
                    entity.NGUOISUA = currentUser.ID;
                    hscvVanBanDenBusiness.Save(entity);
                    #region insert elastic search
                    ElasticModel model = ElasticModel.ConvertVanBanDen(entity, ListUser);
                    ElasticSearch.insertDocument(model, model.Id.ToString(), ElasticType.VanBanDen);
                    #endregion
                    JsonResultBO processResult = wfProcessBusiness.AddFlow(entity.ID, MODULE_CONSTANT.VANBANDEN, currentUser);
                    if (processResult.Status)
                    {
                        uploadFileTool.UploadFiles(filebase, extensionOfVanBanDen.Split(',').ToList(), uploadFolder, filename, entity.ID, LOAITAILIEU.VANBANDEN, maxSizeOfVanBanDen, currentUser);
                    }
                    //cập nhật số đi theo sổ
                    dmDanhMucDataBusiness.UpdateSoVanBan(entity.SOVANBANDEN_ID.GetValueOrDefault(), entity.SODITHEOSO.ToIntOrZero());
                }
                else
                {
                    HSCV_VANBANDEN dbEntity = hscvVanBanDenBusiness.Find(entity.ID);

                    dbEntity.SOHIEU           = entity.SOHIEU;
                    dbEntity.TRICHYEU         = entity.TRICHYEU;
                    dbEntity.SOTRANG          = entity.SOTRANG;
                    dbEntity.DONVI_ID         = entity.DONVI_ID;
                    dbEntity.LOAIVANBAN_ID    = entity.LOAIVANBAN_ID;
                    dbEntity.LINHVUCVANBAN_ID = entity.LINHVUCVANBAN_ID;
                    dbEntity.DOKHAN_ID        = entity.DOKHAN_ID;
                    dbEntity.NGAY_HIEULUC     = entity.NGAY_HIEULUC;
                    dbEntity.NGAYHET_HIEULUC  = entity.NGAYHET_HIEULUC;
                    dbEntity.NGAY_VANBAN      = entity.NGAY_VANBAN;
                    dbEntity.NGAY_BANHANH     = entity.NGAY_BANHANH;
                    dbEntity.NGUOIKY          = entity.NGUOIKY;
                    dbEntity.CHUCVU           = entity.CHUCVU;
                    dbEntity.NOIDUNG          = entity.NOIDUNG;
                    dbEntity.DOMAT_ID         = entity.DOMAT_ID;

                    dbEntity.NGAYCONGTAC       = entity.NGAYCONGTAC;
                    dbEntity.SOVANBANDEN_ID    = entity.SOVANBANDEN_ID;
                    dbEntity.SODITHEOSO        = entity.SODITHEOSO;
                    dbEntity.SODITHEOSO_NUMBER = entity.SODITHEOSO_NUMBER;

                    dbEntity.GIO_CONGTAC  = entity.GIO_CONGTAC;
                    dbEntity.PHUT_CONGTAC = entity.PHUT_CONGTAC;

                    dbEntity.MA_DANGKY              = entity.MA_DANGKY;
                    dbEntity.LOAI_COQUAN_ID         = entity.LOAI_COQUAN_ID;
                    dbEntity.SO_BAN                 = entity.SO_BAN;
                    dbEntity.THONGTIN_LOAI_ID       = entity.THONGTIN_LOAI_ID;
                    dbEntity.TACGIA                 = entity.TACGIA;
                    dbEntity.CONGVAN_DEN_ID         = entity.CONGVAN_DEN_ID;
                    dbEntity.THOIHAN_GIAIQUYET      = entity.THOIHAN_GIAIQUYET;
                    dbEntity.NGUOINHAN_TRUCTIEP_IDS = entity.NGUOINHAN_TRUCTIEP_IDS;
                    dbEntity.NGAYSUA                = DateTime.Now;
                    dbEntity.NGUOISUA               = currentUser.ID;
                    hscvVanBanDenBusiness.Save(dbEntity);

                    uploadFileTool.UploadFiles(filebase, extensionOfVanBanDen.Split(',').ToList(), uploadFolder, filename, dbEntity.ID, LOAITAILIEU.VANBANDEN, maxSizeOfVanBanDen, currentUser);

                    #region update elastic
                    ElasticModel model = ElasticModel.ConvertVanBanDen(dbEntity, ListUser);
                    ElasticSearch.updateDocument(model, model.Id.ToString(), ElasticType.VanBanDen);
                    #endregion
                }
                return(RedirectToAction("DetailVanBanDen", new { id = entity.ID }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index"));
            }
        }
コード例 #2
0
        public JsonResult SaveCongViec(HSCV_CONGVIEC CongViec, FormCollection col, IEnumerable <HttpPostedFileBase> filebase, string[] filename, string[] FOLDER_ID)
        {
            AssignUserInfo();
            #region gán dữ liệu
            string NGAYBATDAU       = col["NGAYBATDAU"];
            string NGAYKETTHUC      = col["NGAYKETTHUC"];
            string MUCTIEU_CONGVIEC = col["MUCTIEU_CONGVIEC"];
            string CACBUOC_THUCHIEN = col["CACBUOC_THUCHIEN"];
            if (!string.IsNullOrEmpty(NGAYBATDAU))
            {
                NGAYBATDAU = NGAYBATDAU.Trim();
            }
            if (!string.IsNullOrEmpty(NGAYKETTHUC))
            {
                NGAYKETTHUC = NGAYKETTHUC.Trim();
            }
            if (!string.IsNullOrEmpty(col["NOIDUNGCONGVIEC"]))
            {
                CongViec.NOIDUNGCONGVIEC = col["NOIDUNGCONGVIEC"].Trim();
            }
            if (!string.IsNullOrEmpty(col["TENCONGVIEC"]))
            {
                CongViec.TENCONGVIEC = col["TENCONGVIEC"].Trim();
            }
            if (!string.IsNullOrEmpty(MUCTIEU_CONGVIEC))
            {
                CongViec.MUCTIEU_CONGVIEC = MUCTIEU_CONGVIEC.Trim();
            }
            if (!string.IsNullOrEmpty(CACBUOC_THUCHIEN))
            {
                CongViec.CACBUOC_THUCHIEN = CACBUOC_THUCHIEN.Trim();
            }
            CongViec.NGAY_NHANVIEC = NGAYBATDAU.ToDateTime();
            CongViec.NGAYHOANTHANH_THEOMONGMUON = NGAYKETTHUC.ToDateTime();
            CongViec.IS_BATDAU = false;
            #endregion
            List <CommonError> ListError = IsValid(CongViec, NGAYBATDAU, NGAYKETTHUC);
            if (ListError.Any())
            {
                return(Json(new { Type = "INVALID", Message = ListError }, JsonRequestBehavior.AllowGet));
            }
            HSCV_CONGVIECBusiness = Get <HSCV_CONGVIECBusiness>();
            UploadFileTool tool = new UploadFileTool();
            if (CongViec.ID > 0)
            {
                #region Cập nhật công việc cá nhân
                var result = HSCV_CONGVIECBusiness.Find(CongViec.ID);
                if (result == null || currentUser.ID != result.NGUOIGIAOVIEC_ID)
                {
                    return(Json(new { Type = "ERROR", Message = "Không tìm thấy công việc cần cập nhật" }, JsonRequestBehavior.AllowGet));
                }
                result.DOKHAN                     = CongViec.DOKHAN;
                result.DOUU_TIEN                  = CongViec.DOUU_TIEN;
                result.HAS_FILE                   = filebase.Any() ? 1 : 0;
                result.HAS_NHACVIECDENHAN         = CongViec.HAS_NHACVIECDENHAN;
                result.IS_EMAIL                   = CongViec.IS_EMAIL;
                result.IS_HASPLAN                 = CongViec.IS_HASPLAN;
                result.IS_MESG                    = CongViec.IS_MESG;
                result.IS_POPUP                   = CongViec.IS_POPUP;
                result.IS_SMS                     = CongViec.IS_SMS;
                result.IS_SUBTASK                 = CongViec.IS_SUBTASK;
                result.ITEMTYPE                   = CongViec.ITEMTYPE;
                result.ITEM_ID                    = CongViec.ITEM_ID;
                result.NGAY_NHANVIEC              = CongViec.NGAY_NHANVIEC;
                result.NGAYHOANTHANH_THEOMONGMUON = CongViec.NGAYHOANTHANH_THEOMONGMUON;
                result.NGAYSUA                    = DateTime.Now;
                result.NGUOIGIAOVIECDANHGIA       = CongViec.NGUOIGIAOVIECDANHGIA;
                result.NGUOIGIAOVIECDAPHANHOI     = CongViec.NGUOIGIAOVIECDAPHANHOI;
                result.NOIDUNGCONGVIEC            = CongViec.NOIDUNGCONGVIEC;
                result.PHANTRAMHOANTHANH          = CongViec.PHANTRAMHOANTHANH;
                result.SONGAYNHACTRUOCHAN         = CongViec.SONGAYNHACTRUOCHAN;
                result.SUBTASK_ID                 = CongViec.SUBTASK_ID;
                result.TENCONGVIEC                = CongViec.TENCONGVIEC;
                result.TRANGTHAI_ID               = CongViec.TRANGTHAI_ID;
                result.IS_BATDAU                  = CongViec.IS_BATDAU;
                result.CACBUOC_THUCHIEN           = CongViec.CACBUOC_THUCHIEN;
                result.MUCTIEU_CONGVIEC           = CongViec.MUCTIEU_CONGVIEC;
                HSCV_CONGVIECBusiness.Save(result);
                tool.UploadCustomFileVer3(filebase, true, CongViecExtension, URL_FOLDER, CongViecSize, FOLDER_ID, filename, result.ID, LOAITAILIEU.CONGVIEC, "Công việc", currentUser);
                #endregion
                #region Elastic search
                List <long> ListUser = new List <long>();
                ListUser.Add(currentUser.ID);
                ListUser.Add(result.NGUOITAO.HasValue ? result.NGUOITAO.Value : 0);
                ElasticModel model = ElasticModel.ConvertJob(result, ListUser, currentUser.HOTEN);
                ElasticSearch.updateDocument(model, model.Id.ToString(), ElasticType.CongViec);
                #endregion

                return(Json(new { Type = "SUCCESS", Message = "Cập nhật công việc đã giao thành công" }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Type = "ERROR", Message = "Không thể thực hiện thao tác này" }, JsonRequestBehavior.AllowGet));
        }