public BackData requestData(string[] data) { PBase _pBase = PFactory.instance.stringToClass(data); if (_pBase != null) { switch (_pBase.act) { case "1": return(DBCtrl.instance.doSQLAdd(_pBase)); case "2": return(DBCtrl.instance.doSQLDel(_pBase)); case "3": return(DBCtrl.instance.doSQLEdit(_pBase)); case "4": return(DBCtrl.instance.doSQLFind(_pBase)); } } BackData backData = new BackData(); _pBase = new PBase(); _pBase.result = "0"; //backData.data.Add(_pBase); return(backData); }
private PBase?ParseMorphoBase(XElement addonElement) { PBase baseModel = new PBase(); XAttribute urlAttribute = addonElement.Attribute("url"); if (urlAttribute == null) { return(null); } Uri baseUri = new Uri(urlAttribute.Value); baseModel.Id = System.IO.Path.GetFileNameWithoutExtension(baseUri.LocalPath); baseModel.Url = string.Format(Config.CatalogBaseFileFormat, baseModel.Id); baseModel.Size = long.Parse(addonElement.Attribute("size").Value); baseModel.Type = addonElement.Attribute("type").Value; XAttribute langAttribute = addonElement.Attribute("lang"); if (langAttribute != null) { baseModel.LanguageTo = langAttribute.Value; baseModel.LanguageFrom = langAttribute.Value; } DownloadBase(baseModel.Id, baseUri.OriginalString); return(baseModel); }
public BackData doSQLEdit(PBase _pBase) { PBase _tempTool = new PBase(); _tempTool.result = "0"; _tempTool.tabName = _pBase.tabName; BackData backData = new BackData(); backData.data.Add(_tempTool); string tabName = _pBase.tabName; string strCom = "update " + tabName + " set "; //try //{ OleDbConnection conn = getConn(); conn.Open(); Dictionary <string, string> param = classToDic(_pBase); int numUpData = 0; OleDbCommand myCommand; foreach (string field in param.Keys) { if (field != "ID" && field != "userid") { strCom += field + "='" + param[field] + "',"; numUpData++; } if (numUpData == 5) { strCom = strCom.Substring(0, strCom.Length - 1); strCom += " where id=" + param["ID"] + " and userid='" + param["userid"] + "'"; myCommand = new OleDbCommand(strCom, conn); myCommand.ExecuteNonQuery(); strCom = "update " + tabName + " set "; numUpData = 0; } } if (numUpData > 0) { strCom = strCom.Substring(0, strCom.Length - 1); strCom += " where id=" + param["ID"] + " and userid='" + param["userid"] + "'"; myCommand = new OleDbCommand(strCom, conn); myCommand.ExecuteNonQuery(); } conn.Close(); _tempTool.result = "1"; //} //catch (Exception e) //{ // throw (new Exception("数据库更新出错:" + strCom + "\r" + e.Message)); //} return(backData); }
public BackData doSQLFind(PBase _pBase = null) { BackData backData = new BackData(); string tabName = _pBase.tabName; string strCom = "Select * from " + tabName; //try //{ OleDbConnection conn = getConn(); conn.Open(); if (_pBase != null) { Dictionary <string, string> param = classToDic(_pBase); strCom += " where "; foreach (string field in param.Keys) { if (field != "tabName" && field != "act" && field != "result") { strCom += field + "='" + param[field] + "' and "; } } } strCom = strCom.Substring(0, strCom.Length - 5); OleDbCommand myCommand = new OleDbCommand(strCom, conn); OleDbDataReader reader = myCommand.ExecuteReader(); PBase _tempTool; while (reader.Read()) { _tempTool = PFactory.instance.stringToClass(new string[] { "tabName", tabName }); for (int i = 0; i < reader.FieldCount; i++) { if (_tempTool.GetType().GetProperty(reader.GetName(i)) != null) { _tempTool.GetType().GetProperty(reader.GetName(i)).SetValue(_tempTool, reader.GetValue(i).ToString()); } } _tempTool.tabName = tabName; backData.data.Add(_tempTool); } conn.Close(); //} //catch (Exception e) //{ // throw (new Exception("数据库更新出错:" + strCom + "\r" + e.Message)); //} return(backData); }
private Dictionary <string, string> classToDic(PBase _pBase) { Dictionary <string, string> _dic = new Dictionary <string, string>(); PropertyInfo[] _property = _pBase.GetType().GetProperties(); for (int i = 0; i < _property.Length; i++) { if (_property[i].GetValue(_pBase, null) != null) { _dic[_property[i].Name] = _property[i].GetValue(_pBase, null).ToString(); } } return(_dic); }
public BackData doSQLAdd(PBase _pBase) { string tabName = _pBase.tabName; PBase _tempTool = new PBase(); _tempTool.result = "0"; _tempTool.tabName = _pBase.tabName; BackData backData = new BackData(); backData.data.Add(_tempTool); string strCom = "insert into " + tabName; //try //{ OleDbConnection conn = getConn(); conn.Open(); string strField = "("; string strValue = "("; Dictionary <string, string> param = classToDic(_pBase); foreach (string field in param.Keys) { if (field != "ID") { strField += field + ","; strValue += "'" + param[field] + "',"; } } strField = strField.Substring(0, strField.Length - 1) + ")"; strValue = strValue.Substring(0, strValue.Length - 1) + ")"; strCom += strField + " values " + strValue; OleDbCommand insertcmd = new OleDbCommand(strCom, conn); insertcmd.ExecuteNonQuery(); conn.Close(); _tempTool.result = "1"; //} //catch (Exception e) //{ // throw (new Exception("数据库更新出错:" + strCom + "\r" + e.Message)); //} return(backData); }
public BackData doSQLDel(PBase _pBase) { PBase _tempTool = new PBase(); _tempTool.result = "0"; _tempTool.tabName = _pBase.tabName; BackData backData = new BackData(); backData.data.Add(_tempTool); string tabName = _pBase.tabName; string strCom = "delete * from " + tabName; try { OleDbConnection conn = getConn(); conn.Open(); strCom += " where "; Dictionary <string, string> param = classToDic(_pBase); foreach (string field in param.Keys) { if (param[field] != "" && field != "tabName" && field != "act") { strCom += field + "='" + param[field] + "' and "; } } strCom = strCom.Substring(0, strCom.Length - 5); OleDbCommand myCommand = new OleDbCommand(strCom, conn); myCommand.ExecuteNonQuery(); conn.Close(); _tempTool.result = "1"; } catch (Exception e) { throw (new Exception("数据库更新出错:" + strCom + "\r" + e.Message)); } return(backData); }
public override void exchangePBase_async(AMD_TestIntf_exchangePBase cb, PBase pb, Ice.Current current) { cb.ice_response(pb); }
exchangePBaseAsync(PBase pb, Ice.Current current) => Task.FromResult(pb);
public void response_exchangePBase1(PBase r) { PDerived p2 = (PDerived)r; AllTests.test(p2.pi == 3); AllTests.test(p2.ps.Equals("preserved")); AllTests.test(p2.pb == p2); callback.called(); }
private PBase?ParseBase(XElement baseElement) { PBase baseModel = new PBase(); XAttribute prcIdAttribute = baseElement.Attribute("prc_id"); if (prcIdAttribute == null) { return(null); } baseModel.Id = prcIdAttribute.Value; baseModel.Size = long.Parse(baseElement.Attribute("size").Value); baseModel.Type = baseElement.Attribute("type").Value; XAttribute amazonUrlAttribute = baseElement.Attribute("amazon_url"); if (amazonUrlAttribute != null) { baseModel.Url = amazonUrlAttribute.Value; } XAttribute langFromAttribute = baseElement.Attribute("from_lang"); if (langFromAttribute != null) { baseModel.LanguageFrom = langFromAttribute.Value; } XAttribute langToAttribute = baseElement.Attribute("to_lang"); if (langToAttribute != null) { baseModel.LanguageTo = langToAttribute.Value; } XAttribute langAttribute = baseElement.Attribute("lang"); if (langAttribute != null) { baseModel.LanguageTo = langAttribute.Value; baseModel.LanguageFrom = langAttribute.Value; } XAttribute majorVerAttribute = baseElement.Attribute("major_ver"); if (majorVerAttribute != null) { baseModel.MajorVersion = int.Parse(majorVerAttribute.Value); } XAttribute minorVerAttribute = baseElement.Attribute("minor_ver"); if (minorVerAttribute != null) { baseModel.MinorVersion = int.Parse(minorVerAttribute.Value); } if (baseModel.Type == "demo_dict") { XAttribute urlAttribute = baseElement.Attribute("url"); if (urlAttribute == null) { return(null); } DownloadBase(baseModel.Id, urlAttribute.Value); baseModel.Url = string.Format(Config.CatalogBaseFileFormat, baseModel.Id); } return(baseModel); }
public override PBase exchangePBase(PBase pb, Ice.Current current) { return pb; }
exchangePBaseAsync(PBase pb, Ice.Current current) { return(Task.FromResult <PBase>(pb)); }
public override Task<PBase> exchangePBaseAsync(PBase pb, Ice.Current current) { return Task.FromResult<PBase>(pb); }
public void response_exchangePBase2(PBase r) { AllTests.test(!(r is PCUnknown)); AllTests.test(r.pi == 3); callback.called(); }
public void response_exchangePBaseCompact1(PBase r) { AllTests.test(!(r is CompactPCDerived)); AllTests.test(r.pi == 3); callback.called(); }
public void response_exchangePBase6(PBase r) { PCDerived3 p3 = r as PCDerived3; AllTests.test(p3.pi == 3); for(int i = 0; i < 300; ++i) { PCDerived2 p2 = p3.pbs[i] as PCDerived2; test(p2.pi == i); test(p2.pbs.Length == 1); test(p2.pbs[0] == null); test(p2.pcd2 == i); } test(p3.pcd2 == p3.pi); test(p3.pcd3 == p3.pbs[10]); callback.called(); }
public void response_exchangePBase5(PBase r) { AllTests.test(!(r is PCDerived3)); AllTests.test(r is Preserved); AllTests.test(r.pi == 3); callback.called(); }
public void response_exchangePBaseCompact2(PBase r) { CompactPCDerived p2 = r as CompactPCDerived; AllTests.test(p2.pi == 3); AllTests.test(p2.pbs[0] == p2); callback.called(); }
public PBase exchangePBase(PBase pb, Ice.Current current) { return(pb); }
exchangePBaseAsync(PBase pb, Action <PBase> response, Action <Exception> exception, Ice.Current current) { response(pb); }