Beispiel #1
0
        private string GetMainPage(string workID, string flow, string node, string name)
        {
            string jsonData = "{";

            Flow myFlow = new Flow(flow);

            string pTable = myFlow.PTable;

            if (string.IsNullOrEmpty(pTable))
            {
                pTable = "ND" + int.Parse(flow) + "Rpt";
            }

            Node nd = new Node(node);
            Work wk = nd.HisWork;

            wk.OID = int.Parse(workID);
            wk.Retrieve();
            wk.ResetDefaultVal();

            GEEntity ndxxRpt = new GEEntity(pTable);

            ndxxRpt.PKVal = workID;
            ndxxRpt.Retrieve();
            ndxxRpt.Copy(wk);


            //执行序列化
            // string jsonData = JsonConvert.SerializeObject(wk.Row);

            // jsonData = jsonData.Substring(1, jsonData.Length - 2);
            //加入他的明细表.
            List <Entities> al = wk.GetDtlsDatasOfList();

            if (!name.Equals("MainPage"))
            {
                foreach (Entities singlEntities in al)
                {
                    if (singlEntities.GetNewEntity.ToString() == name)
                    {
                        jsonData += "\"jsonDtl\":" + JsonConvert.SerializeObject(singlEntities.ToDataTableField()) + "}";
                        break;
                    }
                }
            }
            else
            {
                //把数据赋值给wk.
                wk.Row = ndxxRpt.Row;
                string tempJson = JsonConvert.SerializeObject(wk.Row);
                jsonData = tempJson;
            }
            return(jsonData);
        }
Beispiel #2
0
        /// <summary>
        /// 打印单据
        /// </summary>
        /// <param name="func"></param>
        public void PrintDocV2(BillTemplate func)
        {
            string billInfo = "";
            Node   nd       = new Node(this.FK_Node);
            Work   wk       = nd.HisWork;

            wk.OID = this.WorkID;
            wk.Retrieve();
            wk.ResetDefaultVal();

            string file = DateTime.Now.Year + "_" + WebUser.FK_Dept + "_" + func.No + "_" + WorkID + ".doc";

            BP.Pub.RTFEngine rtf = new BP.Pub.RTFEngine();

            string[] paths;
            string   path;

            try
            {
                #region 生成单据
                rtf.HisEns.Clear();
                rtf.EnsDataDtls.Clear();
                if (func.NodeID == 0)
                {
                }
                else
                {
                    //WorkNodes wns = new WorkNodes();
                    //if (nd.HisRunModel == RunModel.FL
                    //    || nd.HisRunModel == RunModel.FHL
                    //    || nd.HisRunModel == RunModel.HL)
                    //    wns.GenerByFID(nd.HisFlow, this.WorkID);
                    //else
                    //    wns.GenerByWorkID(nd.HisFlow, this.WorkID);

                    //把流程主表数据放入里面去.
                    GEEntity ndxxRpt = new GEEntity("ND" + int.Parse(nd.FK_Flow) + "Rpt");
                    ndxxRpt.PKVal = this.WorkID;
                    ndxxRpt.Retrieve();
                    ndxxRpt.Copy(wk);

                    //把数据赋值给wk.
                    wk.Row          = ndxxRpt.Row;
                    rtf.HisGEEntity = wk;

                    //加入他的明细表.
                    List <Entities> al = wk.GetDtlsDatasOfList();
                    foreach (Entities ens in al)
                    {
                        rtf.AddDtlEns(ens);
                    }

                    //rtf.AddEn(wk);
                    ////if (wns.Count == 0)
                    ////    works = nd.HisWorks;
                    ////else
                    ////    works = wns.GetWorks;
                    //foreach (Work mywk in works)
                    //{
                    //    if (mywk.OID == 0)
                    //        continue;
                    //    rtf.AddEn(mywk);
                    //    rtf.ensStrs += ".ND" + mywk.NodeID;
                    //}
                }

                paths = file.Split('_');
                path  = paths[0] + "/" + paths[1] + "/" + paths[2] + "/";

                string billUrl = BP.WF.Glo.CCFlowAppPath + "DataUser/Bill/" + path + file;

                if (func.HisBillFileType == BillFileType.PDF)
                {
                    billUrl   = billUrl.Replace(".doc", ".pdf");
                    billInfo += "<img src='/WF/Img/FileType/PDF.gif' /><a href='" + billUrl + "' target=_blank >" + func.Name + "</a>";
                }
                else
                {
                    billInfo += "<img src='/WF/Img/FileType/doc.gif' /><a href='" + billUrl + "' target=_blank >" + func.Name + "</a>";
                }

                path = BP.WF.Glo.FlowFileBill + DateTime.Now.Year + "\\" + WebUser.FK_Dept + "\\" + func.No + "\\";
                //  path = Server.MapPath(path);
                if (System.IO.Directory.Exists(path) == false)
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                rtf.MakeDoc(func.Url + ".rtf",
                            path, file, func.ReplaceVal, false);
                #endregion

                #region 转化成pdf.
                if (func.HisBillFileType == BillFileType.PDF)
                {
                    string rtfPath = path + file;
                    string pdfPath = rtfPath.Replace(".doc", ".pdf");
                    try
                    {
                        BP.WF.Glo.Rtf2PDF(rtfPath, pdfPath);
                    }
                    catch (Exception ex)
                    {
                        billInfo = ex.Message;
                        //this.addMsg("RptError", "产生报表数据错误:" + ex.Message);
                    }
                }
                #endregion

                #region 保存单据
                Bill bill = new Bill();
                bill.MyPK        = wk.FID + "_" + wk.OID + "_" + nd.NodeID + "_" + func.No;
                bill.FID         = wk.FID;
                bill.WorkID      = wk.OID;
                bill.FK_Node     = wk.NodeID;
                bill.FK_Dept     = WebUser.FK_Dept;
                bill.FK_Emp      = WebUser.No;
                bill.Url         = billUrl;
                bill.RDT         = DataType.CurrentDataTime;
                bill.FullPath    = path + file;
                bill.FK_NY       = DataType.CurrentYearMonth;
                bill.FK_Flow     = nd.FK_Flow;
                bill.FK_BillType = func.FK_BillType;
                bill.Emps        = rtf.HisGEEntity.GetValStrByKey("Emps");
                bill.FK_Starter  = rtf.HisGEEntity.GetValStrByKey("Rec");
                bill.StartDT     = rtf.HisGEEntity.GetValStrByKey("RDT");
                bill.Title       = rtf.HisGEEntity.GetValStrByKey("Title");
                bill.FK_Dept     = rtf.HisGEEntity.GetValStrByKey("FK_Dept");
                try
                {
                    bill.Save();
                }
                catch
                {
                    bill.Update();
                }
                #endregion
            }
            catch (Exception ex)
            {
                BP.WF.DTS.InitBillDir dir = new BP.WF.DTS.InitBillDir();
                dir.Do();
                path = BP.WF.Glo.FlowFileBill + DateTime.Now.Year + "\\" + WebUser.FK_Dept + "\\" + func.No + "\\";
                string msgErr = "@" + string.Format("生成单据失败,请让管理员检查目录设置") + "[" + BP.WF.Glo.FlowFileBill + "]。@Err:" + ex.Message + " @File=" + file + " @Path:" + path;
                billInfo += "@<font color=red>" + msgErr + "</font>";
                throw new Exception(msgErr + "@其它信息:" + ex.Message);
            }

            this.Pub1.AddFieldSet("打印单据");
            this.Pub1.AddUL();
            this.Pub1.AddLi(billInfo);
            this.Pub1.AddULEnd();
            this.Pub1.AddFieldSetEnd();
            return;
        }
Beispiel #3
0
        private string GetDtlCount(string workID, string flow, string node)
        {
            Flow myFlow = new Flow(flow);

            string pTable = myFlow.PTable;

            if (string.IsNullOrEmpty(pTable))
            {
                pTable = "ND" + int.Parse(flow) + "Rpt";
            }

            Node nd = new Node(node);
            Work wk = nd.HisWork;

            wk.OID = int.Parse(workID);
            wk.Retrieve();
            wk.ResetDefaultVal();

            GEEntity ndxxRpt = new GEEntity(pTable);

            ndxxRpt.PKVal = workID;
            ndxxRpt.Retrieve();
            ndxxRpt.Copy(wk);

            //把数据赋值给wk.
            wk.Row = ndxxRpt.Row;

            //string jsonData = null;

            //执行序列化
            // string jsonData = JsonConvert.SerializeObject(wk.Row);

            // jsonData = jsonData.Substring(1, jsonData.Length - 2);
            //加入他的明细表.
            List <Entities> al = wk.GetDtlsDatasOfList();

            List <TempEntity> tempName = new List <TempEntity>();

            foreach (Entities singleEntities in al)
            {
                tempName.Add(new TempEntity()
                {
                    Name = singleEntities.GetNewEntity.ToString()
                });
            }

            return(JsonConvert.SerializeObject(tempName));
            //if (al.Count > 1)
            //{
            //    foreach (Entities ens in al)
            //    {
            //        string dtlJson = JsonConvert.SerializeObject(ens.ToDataTableField());

            //        var index = al.IndexOf(ens);
            //        jsonData += ",\"jsonDtl" + index + "\":" + dtlJson;
            //    }
            //}
            //else
            //{
            //    jsonData = JsonConvert.SerializeObject(wk.Row);

            //    jsonData = jsonData.Substring(0, jsonData.Length - 1);

            //    jsonData += ",\"jsonDtl\":" + JsonConvert.SerializeObject(al[0].ToDataTableField());

            //    jsonData += "}";
            //}
        }