Esempio n. 1
0
        public static object InvokeWebService(string url, string classname, string methodname, object[] args)
        {
            string @namespace = "EnterpriseServerBase.WebService.DynamicWebCalling";

            if ((classname == null) || (classname == ""))
            {
                classname = ServiceTest.GetWsClassName(url);
            }

            try
            {
                //获取WSDL
                WebClient                  wc     = new WebClient();
                Stream                     stream = wc.OpenRead(url + "?WSDL");
                ServiceDescription         sd     = ServiceDescription.Read(stream);
                ServiceDescriptionImporter sdi    = new ServiceDescriptionImporter();
                sdi.AddServiceDescription(sd, "", "");
                CodeNamespace cn = new CodeNamespace(@namespace);

                //生成客户端代理类代码
                CodeCompileUnit ccu = new CodeCompileUnit();
                ccu.Namespaces.Add(cn);
                sdi.Import(cn, ccu);

                #region csw 注释,因CreateCompiler已过期弃用
                //CSharpCodeProvider csc = new CSharpCodeProvider();
                //ICodeCompiler icc = csc.CreateCompiler();

                //设定编译参数
                //CompilerParameters cplist = new CompilerParameters();
                //cplist.GenerateExecutable = false;
                //cplist.GenerateInMemory = true;
                //cplist.ReferencedAssemblies.Add("System.dll");
                //cplist.ReferencedAssemblies.Add("System.XML.dll");
                //cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                //cplist.ReferencedAssemblies.Add("System.Data.dll");

                //编译代理类
                //CompilerResults cr = icc.CompileAssemblyFromDom(cplist, ccu);
                #endregion

                #region csw修改,因CreateCompiler已过期弃用
                if (!CodeDomProvider.IsDefinedLanguage("CSharp"))
                {
                    return("编译失败");
                }
                CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");

                //设定编译参数
                CompilerParameters cplist = new CompilerParameters();
                cplist.GenerateExecutable = false;
                cplist.GenerateInMemory   = true;
                cplist.ReferencedAssemblies.Add("System.dll");
                cplist.ReferencedAssemblies.Add("System.XML.dll");
                cplist.ReferencedAssemblies.Add("System.Web.Services.dll");
                cplist.ReferencedAssemblies.Add("System.Data.dll");

                CompilerResults cr = provider.CompileAssemblyFromDom(cplist, ccu);
                #endregion

                if (true == cr.Errors.HasErrors)
                {
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    foreach (System.CodeDom.Compiler.CompilerError ce in cr.Errors)
                    {
                        sb.Append(ce.ToString());
                        sb.Append(System.Environment.NewLine);
                    }
                    throw new Exception(sb.ToString());
                }

                //生成代理实例,并调用方法
                System.Reflection.Assembly assembly = cr.CompiledAssembly;
                Type   t   = assembly.GetType(@namespace + "." + classname, true, true);
                object obj = Activator.CreateInstance(t);
                System.Reflection.MethodInfo mi = t.GetMethod(methodname);

                return(mi.Invoke(obj, args));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.InnerException.Message, new Exception(ex.InnerException.StackTrace));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 计费接口(舱内扫描程序调用)
        /// 0 计费不成功
        /// 1 计费成功
        /// msg 失败原因
        /// </summary>
        /// <param name="labelno"></param>
        /// <param name="UserID"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override string Charge(string labelno, string UserID, out string msg)
        {
            msg = "计费出错";
            string begintime    = "";
            string endtime      = "";
            string reqMsgSerial = "";//发送方报文流水号

            try
            {
                StringBuilder selsql = new StringBuilder();

                String sql1 = "select * from V_drugCharge "
                              + " where LabelNo = '" + labelno + "'"
                              + " select * from DEmployee where DEmployeeID='" + UserID + "'"
                              + "select distinct  3 NUM from IVRecord "
                              + "inner join  Prescription on IVRecord.PrescriptionID = Prescription.PrescriptionID "
                              + "inner join PrescriptionDetail on Prescription.PrescriptionID=PrescriptionDetail.PrescriptionID "
                              + "where LabelNo ='" + labelno + "'";

                String sql2 = "select * from V_itemCharge"
                              + " where LabelNo = '" + labelno + "'"
                              + " select * from DEmployee where DEmployeeID='" + UserID + "'"
                              + "select distinct  3 NUM from IVRecord "
                              + "inner join  Prescription on IVRecord.PrescriptionID = Prescription.PrescriptionID "
                              + "inner join PrescriptionDetail on Prescription.PrescriptionID=PrescriptionDetail.PrescriptionID "
                              + "where LabelNo ='" + labelno + "'";

                using (DataSet ds = dbHelp.GetPIVAsDB(sql1))
                {
                    if (ds == null || ds.Tables[0].Rows.Count <= 0 || ds.Tables[1].Rows.Count <= 0)
                    {
                        msg = "数据为空,无法计费。未进入his接口";
                        string errsql = "INSERT INTO ToHisChargeLog(LabelNo,ChargeResult,HisReturn,Msg,Remark2) VALUES ('" + labelno + "','" + -1 + "','" + 0 + "','" + msg + "','" + UserID + "') ";
                        dbHelp.GetPIVAsDB(errsql);
                        dbHelp.SetPIVAsDB("update ivrecord set labelover='-3',labeloverid='" + UserID + "',labelovertime='" + DateTime.Now + "' where labelno='" + labelno + "'");

                        return("0");
                    }
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["PStatus"].ToString()) == 4)
                    {
                        msg = "医嘱已停。未进入his接口";
                        dbHelp.SetPIVAsDB("update ivrecord set labelover='-3',labeloverid='" + UserID + "',labelovertime='" + DateTime.Now + "' where labelno='" + labelno + "' and remark3<>15");
                        string errsql = "INSERT INTO ToHisChargeLog(LabelNo,ChargeResult,HisReturn,Msg,Remark2) VALUES ('" + labelno + "','" + -1 + "','" + 0 + "','" + msg + "','" + UserID + "') ";
                        dbHelp.GetPIVAsDB(errsql);
                        return("0");
                    }
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["result"].ToString()) == 15)
                    {
                        msg = "已计费";
                        return("1");
                    }
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["LabelOver"].ToString()) < 0)
                    {
                        msg = "配置取消";
                        return("0");
                    }
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["IVStatus"].ToString()) > 9)
                    {
                        msg = "已配置核对";
                        return("1");
                    }

                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["PackAdvance"].ToString()) == 1)
                    {
                        msg = "提前打包";
                        return("0");
                    }
                    DataSet ds2 = dbHelp.GetPIVAsDB(sql2);

                    for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
                    {
                        string drug = ds2.Tables[0].Rows[i]["drug_code"].ToString();
                        if (drug.Trim() == "" || drug.Trim().Equals("") || drug == null)
                        {
                            ds2.Tables[0].Rows[i].Delete();
                        }
                    }

                    ds2.AcceptChanges();
                    String XML;
                    if (ds.Tables[0].Rows[0]["Batch"].ToString().Contains("K"))
                    {
                        XML = WriteXml.SetXmlStr(ds);
                    }
                    else if (ds2 == null || ds2.Tables[0].Rows.Count <= 0 || ds2.Tables[1].Rows.Count <= 0)
                    {
                        XML = WriteXml.SetXmlStr(ds);
                    }
                    else
                    {
                        XML = WriteXml.set(ds, ds2);
                    }

                    string mystr          = XML.Replace("\"", "'");
                    string chargePayLoads = MakeHeader.makeRequestPayLoad("xmldata", mystr.Trim());

                    string chargeJSONs = MakeHeader.requestHeader("HIS06010", chargePayLoads);
                    //发送给HIS数据

                    //hisService his = new hisService();
                    string   url  = "http://192.168.200.23:8081/pivasGather/webservice/hisService";
                    string[] args = new string[1];
                    args[0] = chargeJSONs;

                    String result = ServiceTest.InvokeWebService(url, "invoke", args).ToString();

                    begintime = DateTime.Now.ToString();

                    //处理HIS数据
                    List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();
                    rows = MakeJson.JsonToDataTable(result, out reqMsgSerial);

                    string PZcode = ds.Tables[1].Rows[0]["DEmployeeCode"].ToString();//配置人

                    //药品计费返回信息和返回数值
                    msg = rows[0]["execTxt"].ToString();      //msg 全局变量
                    string s = rows[0]["execVal"].ToString(); //s发送信息后his返回值 0,-1,1

                    //更新瓶签信息sql语句
                    string sql = "update ivrecord set remark3='{0}' where labelno  ='" + labelno + "'";
                    sql    += " update IVRecordDetail set ReturnFromHis='{1}' where ivrecordid in (select ivrecordid from ivrecord where labelno='" + labelno + "')";
                    endtime = DateTime.Now.ToString();
                    if (s == "1")
                    {
                        dbHelp.GetPIVAsDB(string.Format(sql, "15", "1"));
                        String logsql = "INSERT INTO ToHisChargeLog VALUES ('" + begintime + "','" + endtime + "','" + labelno + "','" + "null" + "','" + 1 + "','" + s + "'," + "'" + msg + "'," + "null" + ",'" + UserID + "',null" + ",null) ";
                        dbHelp.GetPIVAsDB(logsql);
                        return("1");
                    }
                    else
                    {
                        if (msg.Contains("医嘱") || msg.Contains("病人"))
                        {
                            string updatesql = "update  Prescription  set PStatus  =4 "
                                               + " where  GroupNo  in("
                                               + " select distinct  GroupNo from IVRecord  "
                                               + "  where LabelNo ='{0}') ";
                            dbHelp.SetPIVAsDB(string.Format(updatesql, labelno));
                        }
                        dbHelp.SetPIVAsDB("update ivrecord set labelover='-3',labeloverid='" + UserID + "',labelovertime='" + DateTime.Now + "' where labelno='" + labelno + "'");
                        dbHelp.GetPIVAsDB(string.Format(sql, "12", "0"));
                        String logsql = "INSERT INTO ToHisChargeLog VALUES ('" + begintime + "','" + endtime + "','" + labelno + "','" + "null" + "','" + 0 + "','" + s + "'," + "'" + msg + "'," + "null" + ",'" + UserID + "',null" + ",null) ";
                        dbHelp.GetPIVAsDB(logsql);
                        return("0");
                    }
                }
            }
            catch (Exception ex)
            {
                //  msg = "计费出错,请确定是否连接到his接口,并确保传参是否正确";
                string errsql = "INSERT INTO ToHisChargeLog(LabelNo,ChargeResult,HisReturn,Msg,Remark2) VALUES ('" + labelno + "','" + -1 + "','" + 0 + "','" + ex.Message + "','" + UserID + "') ";
                dbHelp.GetPIVAsDB(errsql);
                return("0");
            }
        }
Esempio n. 3
0
 //动态调用web服务
 public static object InvokeWebService(string url, string methodname, object[] args)
 {
     return(ServiceTest.InvokeWebService(url, null, methodname, args));
 }