Пример #1
0
        //同意签订!! 2015-12-26
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(Globals.ConnectionString))
            {
                string id = Functions.ParseStr(ViewState["id"]);

                HRContractBLL hrcb = new HRContractBLL(conn);
                hrcb.ConfirmHRContract(id);
                //copy video from userdata/tempvideos to contract
                //hrid.mp4 --> .pdf.mp4
                //hrid.wmv --> .pdf.wmv
                HRContractDAL hrcd = new HRContractDAL(conn);
                DataRow hrc = hrcd.GetAHRContract(id);
                string docpath = Functions.CleanDBString(hrc["docpath"]);//pdf fullfilename

                string contractdatapath = Functions.GetAppConfigString("ContractFileRootPath", "");
                string userdatapath = Functions.GetAppConfigString("UserDataPath", "");

                string srcfile = userdatapath + "\\tempvideos\\"+id+".wmv";
                string destfile = contractdatapath + "\\"+docpath+".wmv";

                File.Copy(srcfile, destfile, true);
                File.Delete(srcfile);

                GetSuccessMsg("签约成功!\\n合同内容已不可修改!", "list.aspx");

            }
        }
Пример #2
0
        private void BindData(SqlConnection conn)
        {
            try
            {
                string id = Functions.ParseStr(ViewState["id"]);

                HRContractDAL hrcd = new HRContractDAL(conn);
                DataRow hrc = hrcd.GetAHRContract(id);
                if (null == hrc) return;

                int status = Functions.CleanDBInt(hrc["status"]);
                ViewState["status"] = status;
                string jsonpath = Functions.CleanDBString(hrc["jsonpath"]);
                ViewState["jsonpath"] = jsonpath;

                ContractLog.ContractID = id;
                ContractLog.XmlGridFile = "../person/lists.xml";
                ContractLog.XmlGridName = "contractlog";
                ContractLog.BindGrid();

                PDFImageViewer.PDFID = id;
                PDFImageViewer.PDFType = "hrc";
                PDFImageViewer.PageNo = 1;
                PDFImageViewer.From = "p";
            }
            catch (Exception e) {
                Response.Write(e.ToString());
                GetErrMsg(e.Message);

            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string _corpid = "";
            string _personid = "";

            string from = Functions.ParseStr(Request["from"], "c");//来源:c:corp;p:person

            if (from.Equals("c"))
            {
                CorpAdminBLL.CheckSession(Session, Request, Response);
                _corpid = Functions.ParseStr(Session["corp.id"]);
            }
            else
            {
                PersonBLL.CheckSession(Session, Request, Response);
                _personid = Functions.ParseStr(Session["person.id"]);

            }

            //request
            string hrcontractid = Functions.ParseStr(Request["id"]);
            using (SqlConnection conn = new SqlConnection(Globals.ConnectionString))
            {
                HRContractBLL hrcb = new HRContractBLL(conn);

                HRContractDAL hrcd = new HRContractDAL(conn);
                DataRow hrc = hrcd.GetAHRContract(hrcontractid);

                string personid = Functions.CleanDBGuid(hrc["person_id"]);
                string corpid = Functions.CleanDBGuid(hrc["corp_id"]);
                if (!_corpid.Equals(corpid) && !_personid.Equals(personid))
                {
                    //非本人或者本企业无权利查看该合同
                    Response.Write("您没有该合同的访问权.");
                    CloseOrBack("您没有该合同的访问权.");
                    return;
                }

                string contractbase = Functions.GetAppConfigString("ContractFileRootPath", "");

                #region v1 (v2版本换为HRContractBLL中的GetContractFilePathByID,会增加一次数据库访问,但会让程序漂亮)
                //int status = Functions.CleanDBInt(hrc["status"]);

                //最终的合同直接读取docpath
                string docpath = Functions.CleanDBString(hrc["docpath"]);
                string docfile = contractbase + "\\" + docpath+".wmv";

                if (File.Exists(docfile))
                {
                    Response.ContentType = "application/octet-stream";
                    CommonBLL.GetStreamFromFile(docfile, Response);
                }
                else
                {
                    Response.Write("视频不存在.");
                    CloseOrBack("视频不存在.");
                }

                #endregion

            }
        }
Пример #4
0
        private void BindData(SqlConnection conn)
        {
            string id = Functions.ParseStr(ViewState["id"]);

            HRContractDAL hrcd = new HRContractDAL(conn);
            DataRow hrc = hrcd.GetAHRContract(id);
            if (null == hrc) return;

            int status = Functions.CleanDBInt(hrc["status"]);
            ViewState["status"] = status;
            string jsonpath = Functions.CleanDBString(hrc["jsonpath"]);
            ViewState["jsonpath"] = jsonpath;

            PersonInfo.Conn = conn;
            PersonInfo.PersonID = Functions.CleanDBGuid(hrc["person_id"]);

            ContractLog.ContractID = id;
            ContractLog.XmlGridFile = "../corp/lists.xml";
            ContractLog.XmlGridName = "contractlog";
            ContractLog.BindGrid();

            //PDFImageViewer.Conn = conn;
            PDFImageViewer.PDFID = id;
            PDFImageViewer.PDFType = "hrc";
            PDFImageViewer.PageNo = 1;
            //PDFImageViewer.BindData();
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string _corpid = "";
            string _personid = "";

            string from = Functions.ParseStr(Request["from"], "c");//来源:c:corp;p:person
            string type = Functions.ParseStr(Request["type"], "pdf").ToLower();//pdf/img

            if (from.Equals("c"))
            {
                CorpAdminBLL.CheckSession(Session, Request, Response);
                _corpid = Functions.ParseStr(Session["corp.id"]);
            }else
            {
                PersonBLL.CheckSession(Session, Request, Response);
                _personid = Functions.ParseStr(Session["person.id"]);

            }

            //request
            string hrcontractid = Functions.ParseStr(Request["id"]);
            using (SqlConnection conn = new SqlConnection(Globals.ConnectionString))
            {
                HRContractBLL hrcb = new HRContractBLL(conn);

                HRContractDAL hrcd = new HRContractDAL(conn);
                DataRow hrc = hrcd.GetAHRContract(hrcontractid);

                string personid = Functions.CleanDBGuid(hrc["person_id"]);
                string corpid = Functions.CleanDBGuid(hrc["corp_id"]);
                if (!_corpid.Equals(corpid) && !_personid.Equals(personid)) {
                    //非本人或者本企业无权利查看该合同
                    Response.Write("您没有该合同的访问权.");
                    CloseOrBack("您没有该合同的访问权.");
                    return;
                }

                string contractbase = Functions.GetAppConfigString("ContractFileRootPath", "");

                #region v1 (v2版本换为HRContractBLL中的GetContractFilePathByID,会增加一次数据库访问,但会让程序漂亮)
                int status = Functions.CleanDBInt(hrc["status"]);
                if (status == (int)HRContractStatus.PersonAccepted)
                {
                    //最终的合同直接读取docpath
                    string docpath = Functions.CleanDBString(hrc["docpath"]);
                    string docfile = contractbase + "\\" + docpath;
                    if (!File.Exists(docfile))
                    {
                        Response.Write("未发现合同文件.");
                        CloseOrBack("未发现合同文件.");
                        return;
                    }

                    Response.ContentType = "application/pdf";
                    CommonBLL.GetStreamFromFile(docfile, Response);

                }
                else
                {
                    //其他状态的合同根据jsonfile临时生成,之后清除掉
                    string jsonpath = Functions.CleanDBString(hrc["jsonpath"]);

                    string jsonfile = contractbase + "\\" + jsonpath;
                    string outputfile = contractbase + "\\temp\\" + hrcontractid + ".pdf";

                    if (!File.Exists(jsonfile))
                    {
                        Response.Write("未发现数据文件[J].");
                        CloseOrBack("未发现数据文件[J].");
                        return;
                    }

                    hrcb.CreatePDFInstance(jsonfile, outputfile);

                    if (!File.Exists(outputfile))
                    {
                        Response.Write("未发现合同文件.");
                        CloseOrBack("未发现合同文件.");
                        return;
                    }

                    Response.ContentType = "application/pdf";
                    CommonBLL.GetStreamFromFile(outputfile, Response);

                    File.Delete(outputfile);
                }
                #endregion

            }
        }
Пример #6
0
        //确认合同生成;
        //生成pdf,记录hrcontract状态,记录日志;
        //2015-9-3 记录人员状态为 已签约
        public void ConfirmHRContract(string hrcid)
        {
            HRContractDAL hrcd = new HRContractDAL(conn);
            DataRow hrc = hrcd.GetAHRContract(hrcid);
            if (null == hrc) return;
            string corp_person_id = Functions.CleanDBGuid(hrc["corp_person_id"]);

            //生成pdf实例;only jsondata
            string jsonpath = Functions.CleanDBString(hrc["jsonpath"]);
            string contractbase = Functions.GetAppConfigString("ContractFileRootPath", "");
            string jsonfile = contractbase + "\\" + jsonpath;

            //在json中插入signtime信息
            PDFInstanceData pdfJsonData0 = PDFInstanceData.LoadFromJSONFile(jsonfile);
            //PDFInstanceFieldItem fi_signtime = new PDFInstanceFieldItem();
            //fi_signtime.FieldKey = "signtime";
            //fi_signtime.FeildValue = DateTime.Now.ToShortDateString();
            //pdfJsonData0.Items.Add(fi_signtime);
            pdfJsonData0.AddItem("signtime", DateTime.Now.ToShortDateString());

            pdfJsonData0.SaveToJSONFile(jsonfile);

            string datepath = DateTime.Now.ToString("yyyy/MM/dd").Replace('/', '\\').Replace('-','\\') ;
            string dir = contractbase + "\\" + datepath;
            if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
            string filename = Guid.NewGuid().ToString() + ".pdf";
            string newFile = dir + "\\" + filename; //contracts下YYYY/MM/DD/GUID.json命名

            //create pdf instance file
            this.CreatePDFInstance(jsonfile, newFile);

            #region CreatePDFInstance old srcode
            ////------------------------------------
            //PDFInstanceData data = PDFInstanceData.LoadFromJSONFile(jsonfile);
            //string corpid = data.CorpID;
            //string personid = data.PersonID;
            //string templetid = data.TempletID;
            //string templetdocpath = data.TempletDocPath;

            //string templetbase = Functions.GetAppConfigString("TempletFileRootPath", "");
            //string pdfTemplate = templetbase + "\\" + corpid + "\\" + templetdocpath;

            //PdfReader pdfReader = new PdfReader(pdfTemplate);
            //PdfStamper pdfStamper = null;
            //try
            //{
            //    pdfStamper = new PdfStamper(pdfReader, new FileStream(newFile, FileMode.Create));
            //    //设置字体解决中文问题
            //    BaseFont font = BaseFont.CreateFont(fontpath+ ",1",/*@"C:\windows\fonts\simsun.ttc,1", */
            //        BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            //    pdfStamper.AcroFields.AddSubstitutionFont(font);

            //    AcroFields pdfFormFields = pdfStamper.AcroFields;

            //    // set form pdfFormFields
            //    // The first worksheet and W-4 form
            //    for (int x = 0; x < data.Items.Count; x++)
            //    {
            //        string fieldName = data.Items[x].FieldKey;
            //        string fieldValue = data.Items[x].FeildValue;
            //        pdfFormFields.SetField(fieldName, fieldValue);

            //    }

            //    // close the pdf
            //    pdfStamper.Close();

            //}
            //catch (Exception e)
            //{
            //    e.ToString();
            //    pdfStamper.Close();
            //}
            ////--------------------------------------
            #endregion

            //写hrcontract
            //extract infos from json
            PDFInstanceData pdfJsonData = PDFInstanceData.LoadFromJSONFile(jsonfile);
            foreach (PDFTempletFieldItem fi in this._fieldsInfo.FeildsNeedExtract)
            {
                string fieldKey = fi.FieldKey;
                string fieldValue = pdfJsonData.GetItem(fieldKey).FeildValue;

                try
                {
                    hrc[fieldKey] = fieldValue;
                }
                catch { }

            }
            //set db docpath
            string docpath = datepath + "\\" + filename;
            hrc["docpath"] = docpath;

            hrcd.Update(hrc);

            //写企业人员状态corp_person
            //因为此过程由person发起,所以没有admin_id
            CorpPersonDAL cpd = new CorpPersonDAL(conn);
            cpd.ProcAndLog(corp_person_id, "", (int)CorpPersonProcType.ContractAssgin, (int)CorpPersonStatus.ContractAssigned);

            //reclog
            hrcd.ProcAndLog(hrcid, "", (int)HRContractProcType.PersonAccept, (int)HRContractStatus.PersonAccepted);
        }
Пример #7
0
        //通过id获取Instance实例文件路径,若还没有实例则返回空字符
        //return:1:存在的实例文件;0:通过json生成的临时文件(json里含有templetid)。
        //若返回0,则需要调用方注意,用完之后删掉!!!否则造成空间浪费
        //out参数filename,在调用完之后需检查一下该文件是否存在(可能因为未知原因造成文件不存在,比如在多处开发时,测试数据不一致
        public int GetContractFilePathByID(string hrcontractid,out string filename )
        {
            int res = 0;
            string contractbase = Functions.GetAppConfigString("ContractFileRootPath", "");

            HRContractDAL hrcd = new HRContractDAL(conn);
            DataRow r = hrcd.GetAHRContract(hrcontractid);

            string docpath = Functions.CleanDBString(r["docpath"]);

            if(docpath.Equals(""))
            {
                res = 0;
                string jsonpath = Functions.CleanDBString(r["jsonpath"]);
                string jsonfile = contractbase + "\\" + jsonpath;
                filename = contractbase + "\\temp\\" + hrcontractid + ".pdf";
                CreatePDFInstance(jsonfile, filename);
            }
            else
            {
                res = 1;
                filename = contractbase + "\\" + docpath;
            }
            return res;
        }