/* here goes everything that's * connected to the interaction * with the user, e.g. through a Console */ public static void Run(string[] args) { Console.WriteLine("This is an example of Console App"); string path; if (args.Length == 0) { Console.WriteLine("Please, write the name/path of/to the file: "); path = (string)Console.In.ReadLine(); } else { path = args[0]; } string s2 = "fox"; //a word to find BllClass bl = new BllClass(path); bool b = bl.Contains(s2); Console.WriteLine("'{0}' is in the file '{1}': {2}", s2, path, b); if (b) { int index = bl.IndexOf(s2); if (index >= 0) { Console.WriteLine("'{0} begins at character position {1}", s2, index + 1); } } }
/// <summary> /// 同步的取得DataSet的方法 /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> /// <returns></returns> public DataSet GetDataSet_Syn(string sql, string cuser) { BllClass bc = WC.CallWebAPI_Syn(sql, cuser, "GetDataSet_Log"); this.Core2Framework(bc); byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut); return(IoRyClass.RetrieveXmlDataSet(mbs)); }
/// <summary> /// 异步的执行事务的方法. /// </summary> /// <param name="sql"></param> public async Task <DataSet> ExcutSP_Async(string SPname, List <DbParameter> DbParameterS) { BllClass bc = await WC.CallWebAPI_Async(SPname, DbParameterS, "ExcutSP"); this.Core2Framework(bc); byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut); return(IoRyClass.RetrieveXmlDataSet(mbs)); }
/// <summary> /// 异步的得到DataSet的方法,可以和按钮与进度条相关联用 /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> /// <param name="myobj">可以传送到事件里面的东西</param> public async Task <DataSet> GetDataSet_Async(string sql, string cuser) { BllClass bc = await WC.CallWebAPI_Async(sql, cuser, "GetDataSet"); this.Core2Framework(bc); byte[] mbs = IoRyClass.StringToBytes(bc.JsonOut); return(IoRyClass.RetrieveXmlDataSet(mbs)); }
/// <summary> /// 同步的取得DataSet的方法 /// </summary> /// <param name="sql"></param> /// <returns></returns> public DataSet GetDataSet_Syn(string sql) { BllClass bc = WC.CallWebAPI_Syn(sql, "GetDataSet"); //bc.JsonOut = bc.JsonOut.Replace("System.Guid, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); //byte[] mbs = Convert.FromBase64String(bc.JsonOut); //byte[] mbs = YezhanbafangCore.StringToBytes(bc.JsonOut); //DataSet ds = YezhanbafangCore.RetrieveXmlDataSet(mbs); DataSet ds = JsonConvert.DeserializeObject <DataSet>(bc.JsonOut, new Newtonsoft.Json.Converters.DataSetConverter()); return(ds); }
void ImyService.ClientSendMessage(string methodName, string xmlParam, string callOperator, string certificate) { ConsoleMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam, myTransport.ClientToService)); //验证验证码 if (certificate != LoadBalanceService.GetConfigValue("MyCheck")) { mCB.ServerSendMessage(methodName, mywrong("certificate is wrong!")); return; } try { XElement xmdata = XElement.Parse(xmlParam); string fname = xmdata.Element("Function").Value; string fpath = xmdata.Element("xmlPath").Value; string fparam = xmdata.Element("Param").Value; switch (methodName) { case "CallBLL": BllClass bc = JsonConvert.DeserializeObject <BllClass>(fparam); Assembly assembly = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + bc.DLLName); object obj = assembly.CreateInstance(bc.ClassName); object ret = obj.GetType().InvokeMember(bc.Function, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, obj, new object[] { fparam }); byte[] bts = IoRyClass.StringToBytes(mycorrect(ret.ToString(), methodName)); System.ComponentModel.BackgroundWorker bw1 = new System.ComponentModel.BackgroundWorker(); bw1.DoWork += new System.ComponentModel.DoWorkEventHandler(Bytes_DoWork); bw1.RunWorkerAsync(bts); ConsoleMsg(AddMsgClient(mycorrect(ret.ToString(), methodName), myTransport.ServiceToClient)); break; default: ConsoleErrorMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + "服务不提供此方法!", myTransport.ServiceToClient)); mCB.ServerSendMessage(methodName, mywrong("服务不提供此方法!")); break; } } catch (Exception me) { string exmsg = ""; while (me.InnerException != null) { exmsg += me.Message + "\r\n------>\r\n"; me = me.InnerException; } exmsg += me.Message; ConsoleErrorMsg(AddMsgClient("用户调用ClientSendMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + exmsg, myTransport.ServiceToClient)); mCB.ServerSendMessage(methodName, mywrong(exmsg)); } }
string ImyService.SynMessage(string methodName, string xmlParam, string callOperator, string certificate) { ConsoleMsg(AddMsgClient("用户调用SynMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam, myTransport.ClientToService)); //验证验证码 if (certificate != LoadBalanceService.GetConfigValue("MyCheck")) { return(mywrong("certificate is wrong!")); } try { XElement xmdata = XElement.Parse(xmlParam); string XmlFunction = xmdata.Element("Function").Value; string fpath = xmdata.Element("xmlPath").Value; string fparam = xmdata.Element("Param").Value; switch (methodName) { case "GetServerStatus": string msgxml = this.mycorrect(LoadBalanceService.CPULoad.ToString(), methodName); ConsoleMsg(AddMsgClient(msgxml, myTransport.ServiceToClient)); return(msgxml); case "CallBLL": BllClass bc = JsonConvert.DeserializeObject <BllClass>(fparam); Assembly assembly = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + bc.DLLName); object obj = assembly.CreateInstance(bc.ClassName); object ret = obj.GetType().InvokeMember(bc.Function, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, obj, new object[] { fparam }); string cbreturn = mycorrect(ret.ToString(), methodName); ConsoleMsg(AddMsgClient(mycorrect(ret.ToString(), methodName), myTransport.ServiceToClient)); return(cbreturn); default: ConsoleErrorMsg(AddMsgClient("用户调用SynMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + "服务不提供此方法!", myTransport.ServiceToClient)); return(mywrong("服务不提供此方法!")); } } catch (Exception me) { string exmsg = ""; while (me.InnerException != null) { exmsg += me.Message + "\r\n------>\r\n"; me = me.InnerException; } exmsg += me.Message; ConsoleErrorMsg(AddMsgClient("用户调用SynMessage,发送命令:" + methodName + " 用户:" + callOperator + "\r\n" + xmlParam + "\r\n" + "Error报错:" + exmsg, myTransport.ServiceToClient)); return(mywrong(exmsg)); } }
private void Wc_eAsnyCallBll(string json, object csobj) { if (this.eAsnyCallBll != null) { XElement xmdata = XElement.Parse(json); if (xmdata.Element("correct").Value == "false") { throw new Exception(xmdata.Element("Exception").FirstNode.ToString()); } string jsonr = xmdata.Element("return").FirstNode.ToString(); BllClass bc = JsonConvert.DeserializeObject <BllClass>(jsonr); double timecost = DateTime.Now.Subtract(this.TimeStart_Async).TotalMilliseconds; bc.TimeCost = timecost; this.eAsnyCallBll(JsonConvert.SerializeObject(bc), csobj); } }
/// <summary> /// 同步调用方法 /// </summary> /// <param name="FName"></param> /// <param name="json"></param> /// <param name="callOperator"></param> /// <param name="certificate"></param> /// <returns></returns> public string CallWCF_Syn(string json) { DateTime TimeStart = DateTime.Now; string wcfxml = this.BestWCFClient.CallWCF_Syn("CallBLL", json, "LoadBalanceClient", "ydh"); XElement xmdata = XElement.Parse(wcfxml); if (xmdata.Element("correct").Value == "false") { throw new Exception(xmdata.Element("Exception").FirstNode.ToString()); } string jsonr = xmdata.Element("return").FirstNode.ToString(); BllClass bc = JsonConvert.DeserializeObject <BllClass>(jsonr); double timecost = DateTime.Now.Subtract(TimeStart).TotalMilliseconds; bc.TimeCost = timecost; return(JsonConvert.SerializeObject(bc)); }
public BllClass Post(BllClass bcin) { try { string sin = JsonConvert.SerializeObject(bcin); if (bcin.IsLog) { Ydhlog.Info("入参:"); Ydhlog.Info(sin); } Assembly assembly = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + bcin.DLLName); // 获取当前程序集 object obj = assembly.CreateInstance(bcin.ClassName); object obse = obj.GetType().GetMethod(bcin.Function, new Type[] { typeof(string) }).Invoke(obj, new object[] { sin }); if (bcin.IsLog) { Ydhlog.Info("出参:"); Ydhlog.Info(obse.ToString()); } BllClass bcout = JsonConvert.DeserializeObject <BllClass>(obse.ToString()); if (!bcout.IsNormal) { Ydhlog.Error("可预期的错误:"); Ydhlog.Error(bcout.ErrorMsg); } return(bcout); } catch (Exception me) { string exmsg = ""; while (me.InnerException != null) { exmsg += me.Message + " ------> "; me = me.InnerException; } exmsg += me.Message; Ydhlog.Error(exmsg); BllClass bc = new BllClass(); bc.IsNormal = false; bc.ErrorMsg = exmsg; return(bc); } }
/// <summary> /// 异步的执行事务的方法. /// </summary> /// <param name="sql"></param> public async Task <DataSet> ExcutSP_Async(string SPname, List <DbParameter> DbParameterS) { BllClass bc = await WC.CallWebAPI_Async(SPname, DbParameterS, "ExcutSP"); return(JsonConvert.DeserializeObject <DataSet>(bc.JsonOut, new Newtonsoft.Json.Converters.DataSetConverter())); }
/// <summary> /// 异步的执行事务的方法. /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> public async Task <string> ExcutSqlTran_Async(string sql, string cuser) { BllClass bc = await WC.CallWebAPI_Async(sql, cuser, "ExcutSqlTran_Log"); return(bc.JsonOut); }
/// <summary> /// 异步的得到DataSet的方法,可以和按钮与进度条相关联用 /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> /// <param name="myobj">可以传送到事件里面的东西</param> public async Task <DataSet> GetDataSet_Async(string sql, string cuser) { BllClass bc = await WC.CallWebAPI_Async(sql, cuser, "GetDataSet"); return(JsonConvert.DeserializeObject <DataSet>(bc.JsonOut, new Newtonsoft.Json.Converters.DataSetConverter())); }
/// <summary> /// 同步的执行事务的方法 /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> /// <returns></returns> public string ExcutSqlTran_Syn(string sql, string cuser) { BllClass bc = WC.CallWebAPI_Syn(sql, cuser, "ExcutSqlTran_Log"); return(bc.JsonOut); }
/// <summary> /// 同步的执行事务的方法 /// </summary> /// <param name="sql"></param> /// <returns></returns> public string ExcutSqlTran_Syn(string sql) { BllClass bc = WC.CallWebAPI_Syn(sql, "ExcutSqlTran"); return(bc.JsonOut); }
/// <summary> /// 同步的取得DataSet的方法 /// </summary> /// <param name="sql"></param> /// <param name="cuser">执行者</param> /// <returns></returns> public DataSet GetDataSet_Syn(string sql, string cuser) { BllClass bc = WC.CallWebAPI_Syn(sql, cuser, "GetDataSet_Log"); return(JsonConvert.DeserializeObject <DataSet>(bc.JsonOut, new Newtonsoft.Json.Converters.DataSetConverter())); }
public BllClass Post(BllClass bcin) { try { string sin = JsonConvert.SerializeObject(bcin); if (bcin.IsLog) { Ydhlog.Info("入参:"); Ydhlog.Info(sin); } DLLjson dj = JsonConvert.DeserializeObject <DLLjson>(bcin.JsonIn); IoRyClass ic = new IoRyClass(dj.ConfigPath); DataSet ds = null; byte[] mbs = null; string StringDataSet = null; switch (bcin.RouteName) { case "GetDataSet": ds = ic.GetDataSet(dj.SQL_string); //StringDataSet = JsonConvert.SerializeObject(ds, new Newtonsoft.Json.Converters.DataSetConverter()); mbs = IoRyClass.GetXmlFormatDataSet(ds); StringDataSet = IoRyClass.BytesToString(mbs); //StringDataSet = Convert.ToBase64String(mbs); //byte[] mbs1 = IoRyClass.StringToBytes(StringDataSet); //DataSet ds1 = IoRyClass.RetrieveXmlDataSet(mbs1); //DataSet ds1 = JsonConvert.DeserializeObject<DataSet>(StringDataSet, new Newtonsoft.Json.Converters.DataSetConverter()); bcin.JsonOut = StringDataSet; break; case "GetDataSet_Log": ds = ic.Log_GetDataSet(dj.SQL_string, dj.Operater); mbs = IoRyClass.GetXmlFormatDataSet(ds); StringDataSet = IoRyClass.BytesToString(mbs); bcin.JsonOut = StringDataSet; break; case "ExcutSqlTran": StringDataSet = ic.ExecuteSqlTran(dj.SQL_string); bcin.JsonOut = StringDataSet; break; case "ExcutSqlTran_Log": StringDataSet = ic.Log_ExecuteSqlTran(dj.SQL_string, dj.Operater); bcin.JsonOut = StringDataSet; break; case "ExcutSP": List <DbParameter> LD = new List <DbParameter>(); foreach (var item in dj.DbParaList) { //这里就先只写SqlServer的吧,其他的数据库类型,用到了再说 SqlParameter sp = new SqlParameter(); sp.Value = item.Value; sp.ParameterName = item.Name; LD.Add(sp); } ds = ic.ExecuteSP(dj.SQL_string, LD); mbs = IoRyClass.GetXmlFormatDataSet(ds); StringDataSet = IoRyClass.BytesToString(mbs); bcin.JsonOut = StringDataSet; break; default: bcin.IsNormal = false; bcin.ErrorMsg = "找不到此RouteName"; break; } string sout = JsonConvert.SerializeObject(bcin); if (bcin.IsLog) { Ydhlog.Info("出参:"); Ydhlog.Info(sout); } if (!bcin.IsNormal) { Ydhlog.Error("可预期的错误:"); Ydhlog.Error(sout); } return(bcin); } catch (Exception me) { string exmsg = ""; while (me.InnerException != null) { exmsg += me.Message + "\r\n------>\r\n"; me = me.InnerException; } exmsg += me.Message; Ydhlog.Error(exmsg); bcin.IsNormal = false; bcin.ErrorMsg = exmsg; return(bcin); } }
void Core2Framework(BllClass bc) { bc.JsonOut = bc.JsonOut.Replace("System.Guid, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", "System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); }