Exemple #1
0
        public void IniData()
        {
            FrmPrintWait frmPrintWait = new FrmPrintWait();

            Dictionary <string, string> dicnameIndex = new Dictionary <string, string>();
            List <string> keys      = new List <string>();
            int           indexpage = 0;

            isRpCreateComplate = false;
            if (rpFirst != null)
            {
                rpFirst.Pages.Clear();
            }
            tdPrint = new Thread(new ThreadStart(delegate
            {
                #region loop
                Index index = new Index();
                for (int i = 0; i < 6; i++)
                {
                    try
                    {
                        string txt = "正在打印\\糖尿病评估-";
                        switch (i)
                        {
                        case 0:
                            txt     = txt + "首页.....";
                            rpFirst = new titlepage();
                            rpFirst.Indata(personDr);
                            rpFirst.CreateDocument();
                            rpFirst.SetWatermark();
                            dicnameIndex.Add("首页", "1");
                            keys.Add("首页");
                            indexpage = 1;
                            break;

                        case 1:
                            txt = txt + "目录.....";

                            keys.Add("目录");
                            dicnameIndex.Add("目录", "2");
                            indexpage = 2;
                            break;

                        case 2:
                            if (ConfigHelper.GetConfigString("repglycuresis") == "1")
                            {
                                txt            = txt + "糖尿病评估.....";
                                glycuresis gly = new glycuresis();
                                gly.Pages.Clear();
                                gly.indata(personDr);
                                gly.CreateDocument();
                                dicnameIndex.Add("糖尿病评估", "3");
                                keys.Add("糖尿病评估");
                                indexpage = 3;
                                rpFirst.Pages.AddRange(gly.Pages);
                                indexpage = indexpage + gly.Pages.Count();
                            }
                            break;

                        case 3:
                            if (ConfigHelper.GetConfigString("repFrist") == "1")
                            {
                                txt      = txt + "历次体检对比.....";
                                Frist fi = new Frist();
                                fi.indata(personDr);
                                fi.CreateDocument();
                                dicnameIndex.Add("历次体检对比", indexpage.ToString());
                                keys.Add("历次体检对比");
                                rpFirst.Pages.AddRange(fi.Pages);
                                indexpage = indexpage + fi.Pages.Count();
                            }
                            break;

                        case 4:
                            if (ConfigHelper.GetConfigString("repTargetcomparison") == "1")
                            {
                                txt = txt + "历次体检趋势图.....";
                                keys.Add("历次体检趋势图");
                                Targetcomparison ttc = new Targetcomparison();
                                ttc.indata(personDr);
                                ttc.CreateDocument();
                                dicnameIndex.Add("历次体检趋势图", indexpage.ToString());
                                rpFirst.Pages.AddRange(ttc.Pages);
                                indexpage = indexpage + ttc.Pages.Count();
                            }
                            break;

                        case 5:
                            if (ConfigHelper.GetConfigString("repdiabetes") == "1")
                            {
                                txt = txt + "糖尿病简介.....";
                                diabetes diabete = new diabetes();
                                diabete.indata(personDr);
                                diabete.CreateDocument();
                                dicnameIndex.Add("糖尿病简介", indexpage.ToString());
                                keys.Add("糖尿病简介");
                                rpFirst.Pages.AddRange(diabete.Pages);
                                indexpage = indexpage + diabete.Pages.Count();
                            }
                            break;
                        }

                        nowIndex++;
                        double rate = (double)nowIndex * 100 / (double)6;
                        showPrintdlg(txt, rate);
                    }
                    catch (Exception)
                    {
                    }
                }
                index.Indata(dicnameIndex, keys);
                index.CreateDocument();
                index.SetWatermark();
                if (index.Pages.Count == 1)
                {
                    rpFirst.Pages.Insert(1, index.Pages[0]);
                }
                else if (index.Pages.Count > 1)
                {
                    for (int i = index.Pages.Count - 1; i > 0; i--)
                    {
                        rpFirst.Pages.Insert(1, index.Pages[i]);
                    }
                }



                colsePrintdlg();
                #endregion

                isRpCreateComplate = true;
            }));

            #region 进度条委托展示
            showPrintdlg = new showPrintHandler(delegate(string txt, double rate)
            {
                try
                {
                    if (frmPrintWait.InvokeRequired)
                    {
                        frmPrintWait.Invoke(showPrintdlg, txt, rate);
                    }
                    else
                    {
                        frmPrintWait.Rate = rate;
                        frmPrintWait.Txt  = txt;
                    }
                }
                catch
                {
                    frmPrintWait.Close();
                }
            });
            #endregion

            tdPrint.IsBackground = true;
            tdPrint.Start();

            colsePrintdlg = new colsePrintHandler(delegate
            {
                try
                {
                    frmPrintWait.CrossThreadCalls(() =>
                    {
                        frmPrintWait.Close();
                        frmPrintWait.Dispose();
                    });
                }
                catch
                { }
            });
            frmPrintWait.ShowDialog();
        }
        public void IniData()
        {
            string ids = personDr["qc_ids"] == null ? "" : personDr["qc_ids"].ToString();
            Dictionary <string, string[]> idcs = new Dictionary <string, string[]>();

            if (!string.IsNullOrEmpty(ids))
            {
                idcs = JsonConvert.DeserializeObject <Dictionary <string, string[]> >(ids);
            }


            List <string> qc_ids = new List <string>();

            qc_ids = idcs["value"].ToList();
            FrmPrintWait frmPrintWait = new FrmPrintWait();
            int          nums         = 18;
            Dictionary <string, string> dicnameIndex = new Dictionary <string, string>();
            List <string> keys      = new List <string>();
            int           indexpage = 0;

            isRpCreateComplate = false;
            if (rpFirst != null)
            {
                rpFirst.Pages.Clear();
            }
            tdPrint = new Thread(new ThreadStart(delegate
            {
                #region loop
                Index index       = new Index();
                string userID     = personDr["user_id"].ToString();
                string user_times = personDr["user_times"].ToString();
                DataSet advicDs   = TmoShare.getDataSetFromXML(TmoLinkServer.TmoServiceClient.InvokeServerMethodT <string>(TmoCommon.funCode.GetMainData, new object[] { userID, user_times }));
                string XXX        = "";
                for (int i = 0; i < nums; i++)
                {
                    try
                    {
                        string txt = "正在打印\\糖尿病评估-";
                        switch (i)
                        {
                        case 0:
                            txt     = txt + "首页.....";
                            rpFirst = new titlepage();
                            rpFirst.Indata(personDr);
                            rpFirst.CreateDocument();
                            rpFirst.SetWatermark();
                            dicnameIndex.Add("首页", "1");
                            keys.Add("首页");
                            indexpage = 1;
                            break;

                        case 1:
                            txt = txt + "目录.....";

                            keys.Add("目录");
                            dicnameIndex.Add("目录", "2");
                            indexpage = 2;
                            break;

                        case 2:
                            indexpage = 3;
                            txt       = txt + "历次指标对比.....";
                            Each each = new Each(advicDs);

                            each.Pages.Clear();
                            each.indata(personDr);
                            each.CreateDocument();
                            dicnameIndex.Add("历次指标对比", indexpage.ToString());
                            keys.Add("历次指标对比");
                            rpFirst.Pages.AddRange(each.Pages);
                            indexpage = indexpage + each.Pages.Count();
                            break;

                        case 16:

                            txt             = txt + "指标检测推荐.....";
                            TuiEach tuieach = new TuiEach();
                            tuieach.indata(personDr);
                            tuieach.CreateDocument();
                            dicnameIndex.Add("指标检测推荐", indexpage.ToString());
                            keys.Add("指标检测推荐");
                            rpFirst.Pages.AddRange(tuieach.Pages);
                            indexpage = indexpage + tuieach.Pages.Count();
                            break;

                        case 3:
                            txt         = txt + "重点指标趋势.....";
                            Qushi qushi = new Qushi();
                            qushi.indata(personDr);
                            qushi.CreateDocument();
                            dicnameIndex.Add("重点指标趋势", indexpage.ToString());
                            keys.Add("重点指标趋势");
                            rpFirst.Pages.AddRange(qushi.Pages);
                            indexpage = indexpage + qushi.Pages.Count();
                            break;

                        case 17:
                            txt       = txt + "个人健康信息汇总报告.....";
                            Zong zong = new Zong(advicDs);
                            zong.indata(personDr, dis);
                            zong.CreateDocument();
                            dicnameIndex.Add("个人健康信息汇总报告", indexpage.ToString());
                            keys.Add("个人健康信息汇总报告");
                            rpFirst.Pages.AddRange(zong.Pages);
                            indexpage = indexpage + zong.Pages.Count();
                            break;

                        case 4:
                            //if (qc_ids.Contains("D3CAD02F2C9742B4ACD44ED9FE2C8616") )
                            //{
                            txt             = txt + "肥胖风险评估报告.....";
                            Feipang feipang = new Feipang();
                            feipang.indata(personDr, qctypes["D3CAD02F2C9742B4ACD44ED9FE2C8616"]);
                            feipang.CreateDocument();
                            dicnameIndex.Add("肥胖风险评估报告", indexpage.ToString());
                            dis.Add("fp", feipang.ResultVale);
                            keys.Add("肥胖风险评估报告");
                            rpFirst.Pages.AddRange(feipang.Pages);
                            indexpage = indexpage + feipang.Pages.Count();
                            //}
                            break;

                        case 5:
                            //if (qc_ids.Contains("72525CFEDA6846F5B0651FA48C60381A"))
                            //{
                            txt           = txt + "血脂异常风险评估报告.....";
                            Xuezhi xuezhi = new Xuezhi();
                            xuezhi.indata(personDr);
                            xuezhi.CreateDocument();
                            dicnameIndex.Add("血脂异常风险评估报告", indexpage.ToString());
                            dis.Add("xz", xuezhi.ResultVale);
                            XXX = xuezhi.ResultVale;
                            keys.Add("血脂异常风险评估报告");
                            rpFirst.Pages.AddRange(xuezhi.Pages);
                            indexpage = indexpage + xuezhi.Pages.Count();
                            //}
                            break;

                        case 6:
                            //if (qc_ids.Contains("ea1df0536c9f4adeacd61eee1e3e7aba"))
                            //{
                            txt = txt + "高血压的风险评估.....";
                            TangNiao tangniao = new TangNiao();
                            tangniao.indata(personDr, qctypes["ea1df0536c9f4adeacd61eee1e3e7aba"], XXX);
                            tangniao.CreateDocument();
                            dicnameIndex.Add("高血压的风险评估", indexpage.ToString());
                            keys.Add("高血压的风险评估");
                            rpFirst.Pages.AddRange(tangniao.Pages);
                            dis.Add("gxy", tangniao.ResultVale);
                            indexpage = indexpage + tangniao.Pages.Count();
                            //}
                            break;

                        case 7:
                            if (qc_ids.Contains("487C157853DD4E1CB7A13BF7D95EE0F3"))
                            {
                                txt           = txt + "糖尿病风险评估报告.....";
                                Dengji dengji = new Dengji();
                                dengji.indata(personDr, qctypes["487C157853DD4E1CB7A13BF7D95EE0F3"]);
                                dengji.CreateDocument();
                                dicnameIndex.Add("糖尿病风险评估报告", indexpage.ToString());
                                dis.Add("tnb", dengji.ResultVale);
                                keys.Add("糖尿病风险评估报告");
                                rpFirst.Pages.AddRange(dengji.Pages);
                                indexpage = indexpage + dengji.Pages.Count();
                            }
                            break;

                        case 8:
                            if (qc_ids.Contains("13A86E7E5EE842C08CE3C33A1931BC51"))
                            {
                                txt       = txt + "糖尿病并发眼病风险评估报告.....";
                                Hbyj hbyj = new Hbyj();
                                hbyj.indata(personDr);
                                hbyj.CreateDocument();
                                dicnameIndex.Add("糖尿病并发眼病风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发眼病风险评估报告");
                                dis.Add("yb", hbyj.ResultVale);
                                rpFirst.Pages.AddRange(hbyj.Pages);
                                indexpage = indexpage + hbyj.Pages.Count();
                            }
                            break;

                        case 9:
                            if (qc_ids.Contains("7BFA351E8482429988CAEA459CAD9302"))
                            {
                                txt           = txt + "糖尿病并发神经病变风险评估报告.....";
                                Hbsjbb hbsjbb = new Hbsjbb();
                                hbsjbb.indata(personDr);
                                hbsjbb.CreateDocument();
                                dicnameIndex.Add("糖尿病并发神经病变风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发神经病变风险评估报告");
                                dis.Add("shenjing", hbsjbb.ResultVale);
                                rpFirst.Pages.AddRange(hbsjbb.Pages);
                                indexpage = indexpage + hbsjbb.Pages.Count();
                            }
                            break;

                        case 10:
                            if (qc_ids.Contains("1B6CD1BD99954EAA84DBADDA1FEFC1CF"))
                            {
                                txt       = txt + "糖尿病并发足病风险评估报告.....";
                                Hbzb hbzb = new Hbzb();
                                hbzb.indata(personDr);
                                hbzb.CreateDocument();
                                dicnameIndex.Add("糖尿病并发足病风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发足病风险评估报告");
                                dis["zb"] = hbzb.ResultVale;
                                rpFirst.Pages.AddRange(hbzb.Pages);
                                indexpage = indexpage + hbzb.Pages.Count();
                            }
                            break;

                        case 11:
                            if (qc_ids.Contains("F014863B9E2F4769976A25979819A9D6"))
                            {
                                txt       = txt + "糖尿病并发肾病风险评估报告.....";
                                Hbsb hbsb = new Hbsb();
                                hbsb.indata(personDr);
                                hbsb.CreateDocument();
                                dicnameIndex.Add("糖尿病并发肾病风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发肾病风险评估报告");
                                dis.Add("shenbing", hbsb.ResultVale);
                                rpFirst.Pages.AddRange(hbsb.Pages);
                                indexpage = indexpage + hbsb.Pages.Count();
                            }
                            break;

                        case 12:
                            if (qc_ids.Contains("01C109EBE334495BBBB4792AAE191ACF"))
                            {
                                txt         = txt + "糖尿病并发心血管病风险评估报告.....";
                                Hbxxg hbxxg = new Hbxxg();
                                hbxxg.indata(personDr);
                                hbxxg.CreateDocument();
                                dicnameIndex.Add("糖尿病并发心血管病风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发心血管病风险评估报告");
                                dis.Add("xxue", hbxxg.ResultVale);
                                rpFirst.Pages.AddRange(hbxxg.Pages);
                                indexpage = indexpage + hbxxg.Pages.Count();
                            }
                            break;

                        case 13:
                            if (qc_ids.Contains("FF2D4BD3203449898CFB327D4F8E8751"))
                            {
                                txt         = txt + "糖尿病并发脑血管病风险评估报告.....";
                                Hbnxb hbnxg = new Hbnxb();
                                hbnxg.indata(personDr);
                                hbnxg.CreateDocument();
                                dicnameIndex.Add("糖尿病并发脑血管病风险评估报告", indexpage.ToString());
                                keys.Add("糖尿病并发脑血管病风险评估报告");
                                dis.Add("naoxue", hbnxg.ResultVale);
                                rpFirst.Pages.AddRange(hbnxg.Pages);
                                indexpage = indexpage + hbnxg.Pages.Count();
                            }
                            break;

                        case 14:
                            txt       = txt + "膳食评估报告.....";
                            SsBg ssbg = new SsBg(advicDs);
                            ssbg.indata(personDr);
                            ssbg.CreateDocument();
                            dicnameIndex.Add("膳食评估报告", indexpage.ToString());
                            keys.Add("膳食评估报告");
                            rpFirst.Pages.AddRange(ssbg.Pages);
                            indexpage = indexpage + ssbg.Pages.Count();
                            break;

                        case 15:
                            txt        = txt + "运动评估报告.....";
                            YDBG ydobg = new YDBG(advicDs);
                            ydobg.indata(personDr);
                            ydobg.CreateDocument();
                            dicnameIndex.Add("运动评估报告", indexpage.ToString());
                            keys.Add("运动评估报告");
                            rpFirst.Pages.AddRange(ydobg.Pages);
                            indexpage = indexpage + ydobg.Pages.Count();
                            break;
                        }

                        nowIndex++;
                        double rate = (double)nowIndex * 100 / (double)nums;
                        showPrintdlg(txt, rate);
                    }
                    catch (Exception)
                    {
                    }
                }
                index.Indata(dicnameIndex, keys);
                index.CreateDocument();
                index.SetWatermark();
                if (index.Pages.Count == 1)
                {
                    rpFirst.Pages.Insert(1, index.Pages[0]);
                }
                else if (index.Pages.Count == 2)
                {
                    rpFirst.Pages.Insert(1, index.Pages[0]);
                    rpFirst.Pages.Insert(2, index.Pages[1]);
                }



                colsePrintdlg();
                #endregion

                isRpCreateComplate = true;
            }));

            #region 进度条委托展示
            showPrintdlg = new showPrintHandler(delegate(string txt, double rate)
            {
                try
                {
                    if (frmPrintWait.InvokeRequired)
                    {
                        frmPrintWait.Invoke(showPrintdlg, txt, rate);
                    }
                    else
                    {
                        frmPrintWait.Rate = rate;
                        frmPrintWait.Txt  = txt;
                    }
                }
                catch
                {
                    frmPrintWait.Close();
                }
            });
            #endregion

            tdPrint.IsBackground = true;
            tdPrint.Start();

            colsePrintdlg = new colsePrintHandler(delegate
            {
                try
                {
                    frmPrintWait.CrossThreadCalls(() =>
                    {
                        frmPrintWait.Close();
                        frmPrintWait.Dispose();
                    });
                }
                catch
                { }
            });
            frmPrintWait.ShowDialog();
        }