예제 #1
0
 public object DeleteDp(string dpId, string userid)
 {
     var tran = Utility.Database.BeginDbTransaction();
     try
     {
         bool b = FindExist(dpId, tran);
         if (b == true)
         {
             return Utility.JsonResult(false, "还有部分员工被归类在此部门中,不能删除此数据");
         }
         else
         {
             FX_Department dp = new FX_Department();
             dp.Condition.Add("DPID = " + dpId);
             Utility.Database.Delete(dp, tran);
         }
         Utility.Database.Commit(tran);
         return Utility.JsonResult(true, "删除成功!");
     }
     catch (Exception ex)
     {
         Utility.Database.Rollback(tran);
         throw (new Exception("保存数据失败!错误:" + ex.Message, ex));
     }
 }
예제 #2
0
        public string CreateDepartment(string DPName, string FullName)
        {
            IDbTransaction tran = Utility.Database.BeginDbTransaction();
            try
            {

                string NEW_DPID = MaxValue("D", 6, tran);
                FX_Department insert_obj = new FX_Department();
                insert_obj.DPID = NEW_DPID;
                insert_obj.DPName = DPName;
                insert_obj.FullName = FullName;
                insert_obj.createDate = DateTime.Now.ToString();
                Utility.Database.Insert<FX_Department>(insert_obj, tran);
                Utility.Database.Commit(tran);
                return Utility.JsonResult(true, "添加成功!");
            }
            catch (Exception e)
            {
                Utility.Database.Rollback(tran);
                return PackResult.JsonMsg(false, "CreateDepartment失败!" + e.Message);
            }
        }
예제 #3
0
        /// <summary>
        /// 保存到文档中心和文档中心审核意见表和文章关系表中
        /// </summary>
        /// <param name="tran"></param>
        /// <param name="caseid"></param>
        /// <param name="userid"></param>
        public void SaveToNotice(IDbTransaction tran, string caseid, string userid)
        {
            StringBuilder strSql = new StringBuilder();
            string DPName = "";//部门名称
            string DPID = "";//部门ID
            string CnName = "";//归档人姓名
            string saveFileName = "";//需要存档的文件夹名称
            string dir = "";
            string UserID = "";
            dir = AppDomain.CurrentDomain.BaseDirectory;//获取应用程序跟目录
            dir = dir.Replace("\\", "/");
            strSql.Clear();
            strSql.AppendFormat(@"select * from FX_AttachMent where CaseID='{0}'", caseid);
            DataSet ds = Utility.Database.ExcuteDataSet(strSql.ToString(), tran);
            if (ds.Tables[0].Rows.Count > 0)
            {
                string jsonData = JsonConvert.SerializeObject(ds.Tables[0]);
                List<FX_AttachMent> list_fx = (List<FX_AttachMent>)JsonConvert.DeserializeObject(jsonData, typeof(List<FX_AttachMent>));
                //将文件复制文档中心下的相应目录
                string path = dir + "attachment/documentCenter/";
                if (Directory.Exists(path) == false)//如果不存在就创建文件夹
                {
                    Directory.CreateDirectory(path);
                }

                for (int f = 0; f < list_fx.Count(); f++)
                {
                    string path1 = "";
                    string path2 = "";
                    path1 = dir + "附件目录/" + list_fx[f].FilePath;
                    string fileName = DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_" + list_fx[f].FileName;
                    path2 = path + fileName;
                    //取出文件并保存到相应目录中
                    File.Copy(path1, path2, true);
                    saveFileName += "attachment/documentCenter/" + fileName;
                    if (f != (list_fx.Count() - 1))
                    {
                        saveFileName += "|";
                    }
                }
            }

            //取出用户相关信息
            var userInfo = ComClass.GetUserInfo(userid);
            DPID = userInfo.DPID;
            CnName = userInfo.CnName;
            UserID = userInfo.UserID;
            //查找部门ID
            FX_Department department = new FX_Department();
            department.Condition.Add("DPID=" + userInfo.DPID);
            FX_Department department_ad = Utility.Database.QueryList<FX_Department>(department, tran)[0];
            DPName = department_ad.DPName;
            //放入的文件类型ID
            B_OA_SendDoc sendDoc = new B_OA_SendDoc();
            sendDoc.Condition.Add("caseid=" + caseid);
            sendDoc = Utility.Database.QueryObject<B_OA_SendDoc>(sendDoc);

            //保存文档
            B_OA_Notice newNotice = new B_OA_Notice();
            //newNotice.NewsTitle = sendDoc.;//文档标题
            newNotice.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//现在时间
            newNotice.NewsTitle = sendDoc.wjbt;
            newNotice.documentTypeId = sendDoc.fwlxId;//文档类型id
            string documentTypeName = getFileTypeNameByFileTypeId(sendDoc.fwlxId, tran);
            newNotice.documentTypeName = documentTypeName;//所选树状图名称,从根节点到子节点
            newNotice.CreateMan = CnName;//创建人
            newNotice.CreaterId = userid;//创建人
            newNotice.AttachmentName = saveFileName;//保存文件路径
            newNotice.ShareAttachment = "0";//是否共享文件
            newNotice.isSeeInDoor = false;//是否在门户中查看
            newNotice.status = "checkThrough";//审核状态
            newNotice.caseid = sendDoc.caseid;
            newNotice.publicRange = 0;//非指定人查看
            newNotice.NewsId = ComClass.GetGuid();
            newNotice.publicRange = 0;//所有人查看
            newNotice.isReadRecord = true;//查看记录
            newNotice.isTextSuggetion = true;//可以发表意见
            newNotice.ChkMId = UserID + ";";
            newNotice.ChkM = CnName + ";";
            newNotice.Chkdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//审核时间

            Utility.Database.Insert<B_OA_Notice>(newNotice, tran);

            //插入审核记录
            //取出审核人ID数组
            string[] checkManId = newNotice.ChkMId.Split(';');
            //插入审核表,用于文章修改后,或者新生成的文章审核
            for (int i = 0; i < checkManId.Length - 1; i++)
            {
                B_OA_Notice_Addvice addvice = new B_OA_Notice_Addvice();
                var user_check = ComClass.GetUserInfo(checkManId[i]);
                //审核人ID
                addvice.chkId = checkManId[i];
                //审核人姓名
                addvice.chkName = user_check.CnName;
                //审核状态为未审核
                addvice.statuType = "checkThrough";
                //审核状态名称
                addvice.statusName = "审核通过";
                //文章表外键
                addvice.noticeId = newNotice.NewsId;
                Utility.Database.Insert(addvice, tran);
            }

            //插入文章关系表
            B_OA_Notice_FileType_R fileType_r = new B_OA_Notice_FileType_R();
            fileType_r.noticeId = newNotice.NewsId;
            fileType_r.fileTypeId = sendDoc.fwlxId;
            Utility.Database.Insert(fileType_r, tran);
            //sendDoc.fwlxId;
        }
예제 #4
0
        public object GetAllList(string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            try
            {
                FX_Department dp = new FX_Department();
                List<FX_Department> list = new List<FX_Department>();
                List<FX_Department> listDp = Utility.Database.QueryList(dp, tran);
                //直接返回数据,而不需要打包一层了
                return new
                {
                    list = listDp,
                    dp
                };

            }
            catch (Exception ex)
            {
                Utility.Database.Rollback(tran);
                throw (new Exception("数据获取失败!错误:" + ex.Message, ex));
            }
        }
예제 #5
0
        public string FilePlaceS(string caseid, string title, string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            string DPName = "";//部门名称
            string DPID = "";//部门ID
            string CnName = "";//归档人姓名
            string AttachmentType = "";//归档文件夹ID
            string saveFileName = "";//需要存档的文件夹名称
            string dir = "";
            string UserID = "";
            try
            {
                dir = AppDomain.CurrentDomain.BaseDirectory;//获取应用程序跟目录
                StringBuilder strSql = new StringBuilder();
                strSql.AppendFormat("select * from FX_AttachMent where CaseID='{0}' and FileName like '归档_%'", caseid);
                DataSet ds = Utility.Database.ExcuteDataSet(strSql.ToString(), tran);
                string jsonData = JsonConvert.SerializeObject(ds.Tables[0]);
                List<FX_AttachMent> list_fx = (List<FX_AttachMent>)JsonConvert.DeserializeObject(jsonData, typeof(List<FX_AttachMent>));
                if (list_fx.Count == 0)
                {
                    return Utility.JsonResult(false, "没有归档文件,请上传归档文件");
                }
                if (list_fx.Count > 1)
                {
                    return Utility.JsonResult(false, "该文有两份归档文件,无法归档");
                }
                saveFileName = DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒") + list_fx[0].FileName;
                //取出部门id
                var userInfo = ComClass.GetUserInfo(userid);
                DPID = userInfo.DPID;
                CnName = userInfo.CnName;
                UserID = userInfo.UserID;
                //查找部门ID
                FX_Department department = new FX_Department();
                department.Condition.Add("DPID=" + userInfo.DPID);
                FX_Department department_ad = Utility.Database.QueryList<FX_Department>(department, tran)[0];
                DPName = department_ad.DPName;

                //归档文件夹ID
                B_OA_FileType fileType = new B_OA_FileType();
                fileType.Condition.Add("FileTypeName=" + "发文归档");
                List<B_OA_FileType> listFileType = Utility.Database.QueryList<B_OA_FileType>(fileType, tran);
                if (listFileType.Count <= 0)
                {
                    return Utility.JsonResult(false, "文档中心分类中未有“发文归档”文档,请联系管理员添加");
                }
                B_OA_FileType fileType_ad = listFileType[0];
                AttachmentType = fileType_ad.FileTypeId;

                //保存文档
                B_OA_Notice newNotice = new B_OA_Notice();
                newNotice.NewsTitle = title;//文档标题
                newNotice.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//现在时间
                newNotice.documentTypeId = AttachmentType;//文档类型id
                newNotice.CreateMan = CnName; //创建人
                newNotice.CreaterId = userid;//创建人ID
                newNotice.AttachmentName = "attachment/documentCenter/" + saveFileName;//保存文件路径
                newNotice.ShareAttachment = "0";//是否共享文件
                newNotice.Chk = "0";//是否已经审核
                newNotice.ChkM = CnName + ";";//审核人
                newNotice.Chkdate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//审核时间
                newNotice.documentTypeName = "办公室;收发文归档;发文归档;";//文件文档分类名
                newNotice.NewsId = ComClass.GetGuid();
                newNotice.publicRange = 0;//所有人查看
                newNotice.isReadRecord = true;//查看记录
                newNotice.isTextSuggetion = true;//可以发表意见
                newNotice.status = "waitCheck";//审核状态待审核
                newNotice.ChkMId = UserID + ";";

                string path = dir + "attachment\\documentCenter\\";
                if (Directory.Exists(path) == false)//如果不存在就创建文件夹
                {
                    Directory.CreateDirectory(path);
                }
                //取出文件并保存到相应目录中
                File.Copy(dir + "附件目录\\" + list_fx[0].FilePath, path + saveFileName, true);

                Utility.Database.Insert<B_OA_Notice>(newNotice, tran);

                //插入审核记录
                //取出审核人ID数组
                string[] checkManId = newNotice.ChkMId.Split(';');
                //插入审核表,用于文章修改后,或者新生成的文章审核
                for (int i = 0; i < checkManId.Length - 1; i++)
                {
                    B_OA_Notice_Addvice addvice = new B_OA_Notice_Addvice();
                    var user_check = ComClass.GetUserInfo(checkManId[i]);
                    //审核人ID
                    addvice.chkId = checkManId[i];
                    //审核人姓名
                    addvice.chkName = user_check.CnName;
                    //审核状态为未审核
                    addvice.statuType = "waitcheck";
                    //审核状态名称
                    addvice.statusName = "待审核";
                    //文章表外键
                    addvice.noticeId = newNotice.NewsId;
                    Utility.Database.Insert(addvice, tran);
                }

                //插入文件夹附件表
                //B_OA_FileList newFileList = new B_OA_FileList();
                //newFileList.NewsId = ComClass.GetGuid();
                //newFileList.FileName = saveFileName;
                //newFileList.RelativePath = "attachment/fileDocument/" + saveFileName;
                //string a = dir.Replace("\\", "/");
                //newFileList.AbsolutePath = a + saveFileName;
                //newFileList.Extension = saveFileName.Split('.')[1];
                //newFileList.FileSize = 0;
                //newFileList.BeforeFileName = list_fx[0].FileName;
                //newFileList.Dept = DPID;
                //Utility.Database.Insert<B_OA_FileList>(newFileList, tran);

                //修改收文的归档状态
                B_OA_SendDoc sendDoc = new B_OA_SendDoc();
                sendDoc.Condition.Add("caseid=" + caseid);
                B_OA_SendDoc sendDoc_ad = Utility.Database.QueryList<B_OA_SendDoc>(sendDoc, tran)[0];
                sendDoc_ad.sfgd = 1;//修改归档状态为已归档
                Utility.Database.Update(sendDoc_ad, tran);

                Utility.Database.Commit(tran);
                return Utility.JsonResult(true, "归档成功,此文档上传的归档附件可在文档中心的“办公室》收发文归档》发文归档”文件夹中看到");
            }
            catch (Exception e)
            {
                Utility.Database.Rollback(tran);
                return Utility.JsonResult(false, "数据加载失败!异常信息: " + e.Message);
            }
        }
예제 #6
0
파일: ComClass.cs 프로젝트: hehaiquan/OA
        public static FX_Department GetDeptByUserId(string userId)
        {
            //// Department deptEnt = new Department();
            //var sql = @"select UserID, EnName, CnName, DPName from FX_UserInfo a, FX_Department b where a.DPID = b.DPID and a.UserID = " + userId;
            //DataSet ds = Utility.Database.ExcuteDataSet(sql);
            //return ds;
            UserInfo uient = new UserInfo();
            uient.Condition.Add("UserID=" + userId);
            uient = Utility.Database.QueryObject<UserInfo>(uient);

            FX_Department dptent = new FX_Department();
            dptent.Condition.Add("DPID=" + uient.DPID);
            dptent = Utility.Database.QueryObject<FX_Department>(dptent);
            return dptent;
        }
예제 #7
0
파일: ComClass.cs 프로젝트: hehaiquan/OA
        // 获取部门和用户信息
        public static DeptInfoAndUserInfo GetDeptAndUserByUserId(string userId)
        {
            try
            {
                var data = new DeptInfoAndUserInfo();
                UserInfo uient = new UserInfo();
                uient.Condition.Add("UserID=" + userId);
                uient = Utility.Database.QueryObject<UserInfo>(uient);
                data.userinfo = uient;

                FX_Department dptent = new FX_Department();
                dptent.Condition.Add("DPID=" + uient.DPID);
                dptent = Utility.Database.QueryObject<FX_Department>(dptent);
                data.deptinfo = dptent;
                return data;

            }
            catch (Exception ex)
            {
                ComBase.Logger(ex.Message);
                return null;
            }
        }
예제 #8
0
 private bool FindSonExist(string dpid, IDbTransaction tran)
 {
     FX_Department dp = new FX_Department();
     dp.Condition.Add("PDPID =" + dpid);
     List<FX_Department> listDp = Utility.Database.QueryList<FX_Department>(dp, tran);
     if (listDp.Count > 0)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #9
0
        public object DeleteDp(string dpId, string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            try
            {
                bool b = FindExist(dpId, tran);
                bool c = FindSonExist(dpId, tran);

                if (b == true)
                {
                    return Utility.JsonMsg(false, "删除部门前先保证部门下没有任何用户");
                }
                else if (c == true)
                {
                    return Utility.JsonMsg(false, "删除部门前先保证部门下没有任何子部门");
                }
                else
                {
                    FX_Department dp = new FX_Department();
                    dp.Condition.Add("DPID = " + dpId);
                    Utility.Database.Delete(dp, tran);
                }
                Utility.Database.Commit(tran);
                return Utility.JsonMsg(true, "删除成功!");
            }
            catch (Exception ex)
            {
                Utility.Database.Rollback(tran);
                throw (new Exception("删除失败!错误:" + ex.Message, ex));
            }
        }