Example #1
0
 public void ChangeGuidToCaseId(string guid, string caseid, IDbTransaction tran)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.AppendFormat("select * from B_Common_CreateDoc where caseid = '{0}'", guid);
     DataSet ds = Utility.Database.ExcuteDataSet(strSql.ToString());
     if (ds.Tables[0].Rows.Count > 0)
     {
         string jsonData = JsonConvert.SerializeObject(ds.Tables[0]);
         List<B_Common_CreateDoc> list = (List<B_Common_CreateDoc>)JsonConvert.DeserializeObject(jsonData, typeof(List<B_Common_CreateDoc>));
         for (int i = 0; i < list.Count; i++)
         {
             B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
             createDoc = list[i];
             createDoc.caseid = caseid;
             createDoc.Condition.Add("id = " + createDoc.id);
             Utility.Database.Update(createDoc, tran);
         }
     }
 }
Example #2
0
        public object AutoTypesetting(string caseid, string userid)
        {
            IDbTransaction tran = Utility.Database.BeginDbTransaction();
            try
            {
                //查找是否有排版过的路径
                B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
                createDoc.Condition.Add("caseid = " + caseid);
                createDoc = Utility.Database.QueryObject<B_Common_CreateDoc>(createDoc, tran);
                string targetpath;
                targetpath = CommonFunctional.GetDocumentPathByName("SendDocContent", "FileDir");
                //判断文件是否存在,若不存在就生成一个文件
                if (createDoc == null)
                {
                    targetpath = CombindTitleAndBody(caseid, userid, targetpath, tran);
                }
                else
                {
                    targetpath = targetpath + createDoc.filename;
                    //如果文件不存在删除原先的数据后再生成
                    if (!File.Exists(targetpath))
                    {
                        createDoc.Condition.Add("caseid = " + caseid);
                        Utility.Database.Delete(createDoc, tran);
                        targetpath = CommonFunctional.GetDocumentPathByName("SendDocContent", "FileDir");
                        targetpath = CombindTitleAndBody(caseid, userid, targetpath, tran);
                    }
                }
                Utility.Database.Commit(tran);
                return new
                {
                    targetpath = targetpath
                };
            }
            catch (Exception ex)
            {
                ComBase.Logger(ex);
                throw (new Exception("排版失败!", ex));

            }
        }
Example #3
0
 public object GetDocName(string caseid, string type, string doctype)
 {
     ////SkyLandDeveloper developer = SkyLandDeveloper.FromJson("{}");
     try
     {
         B_Common_CreateDoc doc = new B_Common_CreateDoc();
         doc.Condition.Add("caseid = " + caseid);
         doc.Condition.Add("type = " + type);
         doc.Condition.Add("docType = " + doctype);
         doc = Utility.Database.QueryObject<B_Common_CreateDoc>(doc);
         if (doc != null && !string.IsNullOrEmpty(doc.filename))
         {
             string savePath = Utility.RootPath.Replace("\\", "/") + doc.filename.Replace("#", "/");
             return Utility.JsonResult(true, "ok", "{wordPath:\"" + savePath + "\"}");
         }
         return Utility.JsonResult(true, "nodoc");
     }
     catch (Exception ex)
     {
         ComBase.Logger(ex.Message);
         return Utility.JsonResult(false, "获取文件失败:" + ex.Message.Replace(":", " "));
     }
 }
Example #4
0
        public string PrintSendDocContent(string content, string userid)
        {
            IDbTransaction tran = Utility.Database.BeginDbTransaction();
            SkyLandDeveloper developer = new SkyLandDeveloper("{}", userid, tran);
            try
            {
                dynamic jdata = JValue.Parse(content);
                string fwrqString = jdata["fwrqString"];//fwrqString
                string printType = jdata["printType"];//printType
                string caseid = jdata["caseid"];
                string strFileName = "发文正文_";
                strFileName += DateTime.Now.ToString("yyyyMMddHHmmss") + "_temporary";
                strFileName += ".docx";
                string sendContentPath = CommonFunctional.GetDocumentPathByName("SendDocContent", "FileDir");
                string targetPath = sendContentPath + strFileName;
                string savePath = "SendDocContent#" + strFileName;

                string realFileName = "";
                switch (printType)
                {
                    case "1":
                        realFileName = "南宁市“美丽南宁 清洁水源”专项活动领导小组文件中红头.docx";
                        break;
                    case "2":
                        realFileName = "南宁市“美丽南宁 清洁水源”专项活动领导小组小红头.docx";
                        break;
                    case "3":
                        realFileName = "南宁市规划环境影响评价工作领导小组办公室文件红头.docx";
                        break;
                    case "4":
                        realFileName = "南宁市环保专项行动领导小组办公室上报红头文件.docx";
                        break;
                    case "5":
                        realFileName = "南宁市环保专项行动领导小组办公室文件红头.docx";
                        break;
                    case "6":
                        realFileName = "南宁市环保专项行动领导小组办公室小红头.docx";
                        break;
                    case "7":
                        realFileName = "南宁市环境保护局上报红头文件.docx";
                        break;
                    case "8":
                        realFileName = "南宁市环境保护局小红头.docx";
                        break;
                    case "9":
                        realFileName = "南宁市环境保护局中红头.docx";
                        break;
                    case "10":
                        realFileName = "南宁市环境保护委员会办公室文件红头(新).docx";
                        break;
                    case "11":
                        realFileName = "南宁市环境保护委员会办公室文件上报红头.docx";
                        break;
                    case "12":
                        realFileName = "南宁市环境保护委员会办公室小红头.docx";
                        break;
                    case "14":
                        realFileName = "中共南宁市环境保护局党组上报红头.docx";
                        break;
                }
                string modelPath = CommonFunctional.GetDocumentPathByName("Send", "FileModelDir");

                //选择模版,将模版复制出一份
                //通过caseid查找发文,并将字号贴上
                B_OA_SendDoc sendDoc = new B_OA_SendDoc();
                sendDoc.Condition.Add("caseid=" + caseid);
                sendDoc = Utility.Database.QueryObject(sendDoc, tran);
                string fwzh = sendDoc.fwzh;
                Dictionary<string, Object> dict = new Dictionary<string, Object>();
                dict.Add("fwzh", fwzh == "" ? "" : fwzh);//发文字号
                realFileName = modelPath + realFileName;
                //将字号赋到文档的相应位置
                IWorkFlow.OfficeService.IWorkFlowOfficeHandler.ProduceWord2007UP(realFileName,targetPath, dict);

                //获取正文的路径
                B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
                createDoc.Condition.Add("caseid=" + caseid);
                createDoc.Condition.Add("docType=" + "mainBody");
                createDoc = Utility.Database.QueryObject(createDoc, tran);
                if (createDoc == null)
                {
                    throw (new Exception("选择模版失败:此发文未生成过正文,请编辑正文后再选择模版!"));
                }

                string fileName = createDoc.filename.Replace("#", "/");
                string filePath = CommonFunctional.GetDocumentPathByName("", "") + fileName;
                if (!File.Exists(filePath))
                {
                    developer.RollBack();
                    return Utility.JsonResult(false, "此正文路径不存在,无法套红");
                }
                //删除旧的套红过的源数据
                B_Common_CreateDoc delDoc = new B_Common_CreateDoc();
                delDoc.Condition.Add("caseid = " + caseid);
                delDoc.Condition.Add("type = " + "SendDoc");
                delDoc.Condition.Add("docType = " + "redCover");
                delDoc = Utility.Database.QueryObject<B_Common_CreateDoc>(delDoc);
                if (delDoc != null)
                {
                    delDoc.Condition.Add("id =" + delDoc.id);
                    Utility.Database.Delete(delDoc, tran);
                }
                //存入新的套红模版路径
                B_Common_CreateDoc redCover = new B_Common_CreateDoc();
                redCover.caseid = caseid;
                redCover.type = "SendDoc";
                redCover.filename = savePath;
                redCover.createdate = DateTime.Now;
                redCover.createman = userid;
                redCover.docType = "redCover";
                Utility.Database.Insert(redCover, tran);
                //将发文的正文路径
                GetDataModel dataModel = new GetDataModel();
                dataModel.mainBodyPath = filePath;
                dataModel.redCoverPath = targetPath;
                Utility.Database.Commit(tran);
                return Utility.JsonResult(true, "发送成功!", dataModel);
            }
            catch (Exception ex)
            {
                developer.RollBack();
                ComBase.Logger(ex);
                return Utility.JsonResult(false, "选择模版失败:" + ex.Message.Replace(":", " "));
            }
        }
Example #5
0
        /// <summary>
        /// 获取正文路径
        /// </summary>
        /// <param name="docType"></param>
        /// <param name="caseId"></param>
        /// <param name="userid"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string GetFilePath(string docType, string caseId, string userid, IDbTransaction tran, string type,string actId)
        {
            B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
            StringBuilder strSql = new StringBuilder();
            string returnPath = "";//返回路径
            string filePath = "";//数据库要记录的的路径
            string documentName = "SendDocContent";//文件加路径
            string documentPath = CommonFunctional.GetDocumentPathByName(documentName,"FileDir");//文件夹全路径

            string modelName = "Send";
            string modelPath = CommonFunctional.GetDocumentPathByName(modelName, "FileModelDir");
            string modelFileName = "发文正文模板.docx";
            modelPath = modelPath + modelFileName;

            if (!File.Exists(modelPath))
            {
                throw (new Exception("发文正文模版路径不存在!"));
            }

            //优先查找套红模版,若已套红则优先选择套红模版,若没有套红则查询是否存入过正文,如果存入过返回存入过的正文路径,如果没有则新生成
            strSql.AppendFormat("select * from B_Common_CreateDoc where caseid = '{0}' and type = '{1}' and docType = '{2}'", caseId, type, "redCover");
            DataSet ds_Cover = Utility.Database.ExcuteDataSet(strSql.ToString(), tran);
            if (ds_Cover.Tables[0].Rows.Count > 0)
            {
                string jsonData_Cover = JsonConvert.SerializeObject(ds_Cover.Tables[0]);
                List<B_Common_CreateDoc> list_Cover = (List<B_Common_CreateDoc>)JsonConvert.DeserializeObject(jsonData_Cover, typeof(List<B_Common_CreateDoc>));
                filePath = list_Cover[0].filename;
                filePath = filePath.Replace("#", @"/");
                string path = CommonFunctional.GetDocumentPathByName("", "");
                returnPath = path + filePath;
            }
            else
            {
                strSql.Clear();
                strSql.AppendFormat("select * from B_Common_CreateDoc where caseid = '{0}' and type = '{1}' and docType = '{2}'", caseId, type, docType);
                DataSet ds = Utility.Database.ExcuteDataSet(strSql.ToString(), tran);
                string jsonData = JsonConvert.SerializeObject(ds.Tables[0]);
                List<B_Common_CreateDoc> list = (List<B_Common_CreateDoc>)JsonConvert.DeserializeObject(jsonData, typeof(List<B_Common_CreateDoc>));
                if (list.Count == 0)
                {
                    DateTime dataTimeNow = DateTime.Now;
                    string strFileName = "发文正文_" + dataTimeNow.ToString("yyyyMMddHHmmss") + "_" + caseId + ".docx";
                    documentPath =documentPath + strFileName;
                    string savePath = documentName + "#" + strFileName;
                    returnPath = documentPath;

                    if (!File.Exists(documentPath))
                    {
                        File.Copy(modelPath, documentPath);
                    }
                    createDoc.caseid = caseId;
                    createDoc.createman = userid;
                    createDoc.type = type;
                    createDoc.createdate = dataTimeNow;
                    createDoc.filename = savePath;
                    createDoc.docType = "mainbody";
                    Utility.Database.Insert(createDoc, tran);
                }
                else
                {
                    filePath = list[0].filename;
                    filePath = filePath.Replace("#", @"/");
                    string path = CommonFunctional.GetDocumentPathByName("", "");
                    returnPath = path + filePath;
                    if (!File.Exists(returnPath))
                    {
                        if (actId == "A001")
                        {
                            File.Copy(modelPath, documentPath);
                        }
                        else {
                            throw (new Exception("此发文的正文路径不存在,请联系统管理员 或 回退到发文拟稿时的步骤!"));
                        }
                    }

                    returnPath =returnPath.Replace("\\", "/");
                }
            }

            return returnPath;
        }
Example #6
0
        /// <summary>
        /// 将
        /// </summary>
        /// <param name="caseid"></param>
        /// <param name="userid"></param>
        /// <param name="targetpath"></param>
        /// <param name="tran"></param>
        /// <returns></returns>
        public string CombindTitleAndBody(string caseid, string userid, string targetpath, IDbTransaction tran)
        {
            B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
            createDoc.caseid = caseid;
            createDoc.type = "SendDoc_QuZhan";
            createDoc.filename = "发文模板_" + caseid + ".docx";
            createDoc.createman = userid;
            createDoc.createdate = DateTime.Now;
            createDoc.docType = "mainBody";
            Utility.Database.Insert(createDoc, tran);

            string wordPath = CommonFunctional.GetDocumentPathByName("Send", "FileModelDir");
            wordPath = wordPath + "发文正文模板.docx";
            targetpath = targetpath + createDoc.filename;
            var dic = CombindMainBody(caseid, tran);
            IWorkFlow.OfficeService.IWorkFlowOfficeHandler.ProduceWord2007UP(wordPath, targetpath, dic);
            return targetpath;
        }
Example #7
0
        public bool DeleteCase(string caseid, string userid, Object obj)
        {
            IDbTransaction tran = (IDbTransaction)obj;
            //加入针对不同的业务的删除前处理
            FX_WorkFlowCase workFlow = new FX_WorkFlowCase();
            workFlow.Condition.Add("ID =" + caseid);
            workFlow = Utility.Database.QueryObject<FX_WorkFlowCase>(workFlow, tran);
            if (workFlow != null)
            {
                string flowId = workFlow.FlowID;
                switch (flowId)
                {
                    case "W000098": //发文
                        B_OA_SendDoc_QuZhan sendDoc = new B_OA_SendDoc_QuZhan();
                        sendDoc.Condition.Add("caseid=" + caseid);
                        Utility.Database.Delete(sendDoc, tran);
                        break;
                    case "W000099": //收文
                        B_OA_ReceiveDoc_QuZhan receiveDoc = new B_OA_ReceiveDoc_QuZhan();
                        receiveDoc.Condition.Add("caseid=" + caseid);
                        Utility.Database.Delete(receiveDoc, tran);
                        break;
                    case "W000100": //内部事项
                        B_OA_SendDoc_Inner_QuZhan innderDoc = new B_OA_SendDoc_Inner_QuZhan();
                        innderDoc.Condition.Add("caseId=" + caseid);
                        Utility.Database.Delete(innderDoc, tran);
                        break;
                    case "W000070": //车辆申请
                        B_OA_Car car = new B_OA_Car();
                        car.Condition.Add("workflowcaseid=" + caseid);
                        Utility.Database.Delete(car, tran);
                        break;
                    case "W000071": //会议申请
                        B_OA_Meeting data = new B_OA_Meeting();
                        data.Condition.Add("CaseID=" + caseid);
                        Utility.Database.Delete(data, tran);
                        break;
                    case "W000079": //请假申请
                        B_OA_LeaveList leave = new B_OA_LeaveList();
                        leave.Condition.Add("caseId=" + caseid);
                        Utility.Database.Delete(leave, tran);
                        break;
                    case "W000080": //出差申请
                        B_OA_TravelList travel = new B_OA_TravelList();
                        travel.Condition.Add("caseId=" + caseid);
                        Utility.Database.Delete(travel, tran);
                        break;
                    case "W000089": //通知公告
                        B_OA_Notice notice = new B_OA_Notice();
                        notice.Condition.Add("caseid=" + caseid);
                        Utility.Database.Delete(notice, tran);
                        break;
                }
                if (!string.IsNullOrEmpty(caseid))
                {
                    //删除正文路径
                    B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
                    createDoc.Condition.Add("caseid=" + caseid);
                    Utility.Database.Delete(createDoc, tran);
                    //删除附件
                    FX_AttachMent attach  = new FX_AttachMent();
                    attach.Condition.Add("CaseID="+caseid);
                    Utility.Database.Delete(attach, tran);

                }
            }
            return true;
        }
Example #8
0
 public string PrintSendDocContent(string content, string userid)
 {
     IDbTransaction tran = Utility.Database.BeginDbTransaction();
     SkyLandDeveloper developer = new SkyLandDeveloper("{}", userid, tran);
     try
     {
         string rootPath = HttpContext.Current.Server.MapPath("/");
         rootPath = rootPath.Replace("\\", "/");
         dynamic jdata = JValue.Parse(content);
         string fwrqString = jdata["fwrqString"];//fwrqString
         string printType = jdata["printType"];//printType
         string caseid = jdata["caseid"];
         string fwzh = jdata["fwzh"];
         string strFileName = "发文正文_";
         strFileName += DateTime.Now.ToString("yyyyMMddHHmmss") + "_temporary";
         strFileName += ".docx";
         string targetpath = rootPath + "officeFile/SendDocContent/" + strFileName;
         string savePath = "officeFile/SendDocContent/" + strFileName;
         string realFileName = "";
         switch (printType)
         {
             case "1":
                 realFileName = "officeFileModel/SendZhiDui/南宁市环境监察支队文件中红头.docx";
                 break;
             case "2":
                 realFileName = "officeFileModel/SendZhiDui/南宁市环境监察支队小红头.docx";
                 break;
         }
         //选择模版,将模版复制出一份
         //通过caseid查找发文,并将字号贴上
         B_OA_SendDoc_ZhiDui sendDoc = new B_OA_SendDoc_ZhiDui();
         sendDoc.Condition.Add("caseid=" + caseid);
         sendDoc = Utility.Database.QueryObject(sendDoc, tran);
         Dictionary<string, Object> dict = new Dictionary<string, Object>();
         dict.Add("fwzh", fwzh == "" ? "" : fwzh);//发文字号
         realFileName = rootPath + realFileName;
         //将字号赋到文档的相应位置
         IWorkFlow.OfficeService.IWorkFlowOfficeHandler.ProduceWord2007UP(realFileName, targetpath, dict);
         //获取正文的路径
         B_Common_CreateDoc createDoc = new B_Common_CreateDoc();
         createDoc.Condition.Add("caseid=" + caseid);
         createDoc.Condition.Add("docType=" + "mainBody");
         createDoc = Utility.Database.QueryObject(createDoc, tran);
         if (createDoc == null)
         {
             return Utility.JsonMsg(false, "选择模版失败:此发文未生成过正文,请编辑正文后再选择模版!");
         }
         string fileName = createDoc.filename.Replace("#", "/");
         string filePath = rootPath + fileName;
         if (!File.Exists(filePath))
         {
             developer.RollBack();
             return Utility.JsonMsg(false, "此模版路径不存在,无法套红");
         }
         //删除旧的套红过的源数据
         B_Common_CreateDoc delDoc = new B_Common_CreateDoc();
         delDoc.Condition.Add("caseid = " + caseid);
         delDoc.Condition.Add("type = " + "SendDocZhiDui");
         delDoc.Condition.Add("docType = " + "redCover");
         delDoc = Utility.Database.QueryObject<B_Common_CreateDoc>(delDoc);
         if (delDoc != null)
         {
             delDoc.Condition.Add("id =" + delDoc.id);
             Utility.Database.Delete(delDoc, tran);
         }
         //存入新的套红模版路径
         B_Common_CreateDoc redCover = new B_Common_CreateDoc();
         redCover.caseid = caseid;
         redCover.type = "SendDocZhiDui";
         redCover.filename = savePath.Replace("/", "#");
         redCover.createdate = DateTime.Now;
         redCover.createman = userid;
         redCover.docType = "redCover";
         Utility.Database.Insert(redCover, tran);
         //将发文的正文路径
         GetDataModel dataModel = new GetDataModel();
         dataModel.mainBodyPath = rootPath + createDoc.filename.Replace("#", "/");
         dataModel.redCoverPath = rootPath + redCover.filename.Replace("#", "/");
         Utility.Database.Commit(tran);
         return JsonConvert.SerializeObject( dataModel);
     }
     catch (Exception ex)
     {
         developer.RollBack();
         ComBase.Logger(ex);
         return Utility.JsonMsg(false, "选择模版失败:" + ex.Message.Replace(":", " "));
     }
 }
Example #9
0
 /// <summary>
 /// 删除业务文件和业务数据
 /// </summary>
 /// <param name="caseid">业务ID</param>
 /// <param name="type">类别(表名)</param>
 /// <param name="docType">文件类别</param>
 /// <returns></returns>
 public static void isExistCreateRecordAndDeleteDoc(string caseid, string type, string docType, IDbTransaction tran)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.AppendFormat("select * from B_Common_CreateDoc where caseid='{0}' and type='{1}'",caseid,type);
     if (docType != "")
     {
         strSql.AppendFormat("and docType='{0}'", docType);
     }
        DataSet ds = Utility.Database.ExcuteDataSet(strSql.ToString(), tran);
        DataTable dt = ds.Tables[0];
        string jsonData = JsonConvert.SerializeObject(ds.Tables[0]);
        List < B_Common_CreateDoc> list = (List<B_Common_CreateDoc>)JsonConvert.DeserializeObject(jsonData, typeof(List<B_Common_CreateDoc>));
        for (int i = 0; i < list.Count; i++)
     {
         //删除对应文件
         string filePath = list[i].filename.Replace("#", "\\");
         ComFileOperate.DeleteAttachment(filePath);
         B_Common_CreateDoc dl = new B_Common_CreateDoc();
         dl.Condition.Add("id = " + list[i].id);
         Utility.Database.Delete(dl, tran);
     }
 }