public static string drop(string strEventTypeID) { DataStorage storage = new DataStorage(); // 删除角色权限 string strSQL = "DELETE FROM ROLEPOWER WHERE EVENTTYPEID='" + strEventTypeID + "'"; storage.addSQL(strSQL); // 删除对应的事件 strSQL = "DELETE FROM EVENTTYPE WHERE EVENTTYPEID='" + strEventTypeID + "'"; storage.addSQL(strSQL); // 执行 string strReturn = storage.runSQL(); ReturnDoc returndoc = new ReturnDoc(); if (!General.empty(strReturn)) { returndoc.addErrorResult(Common.RT_FUNCERROR); returndoc.setFuncErrorInfo(strReturn); } else { returndoc.addErrorResult(Common.RT_SUCCESS); } return returndoc.getXml(); }
public static string addNew(string strXml) { DataDoc doc = new DataDoc(strXml); // 创建执行对象 DataStorage storage = new DataStorage(); int size = doc.getDataNum(Table.USERLIST); // 解析sql语句 for (int i = 0; i < size; i++) { XmlElement ele = (XmlElement)doc.getDataNode(Table.USERLIST, i); string a = ele.InnerXml; XmlNode node = XmlFun.getNode(ele, Field.USERID); string strId = NumAssign.assignID_A("000002"); XmlFun.setNodeValue(node,strId); storage.addSQL(SQLAnalyse.analyseXMLSQL(ele)); } // 执行 string strReturn = storage.runSQL(); ReturnDoc returndoc = new ReturnDoc(); if (!General.empty(strReturn)) { returndoc.addErrorResult(Common.RT_FUNCERROR); returndoc.setFuncErrorInfo(strReturn); } else { returndoc.addErrorResult(Common.RT_SUCCESS); } return returndoc.getXml(); }
/// <summary> /// 删除角色 /// </summary> /// <param name="strRoleID"></param> /// <returns></returns> public static string DropRole(string strRoleID) { DataStorage storage = new DataStorage(); string str_SQL = "DELETE FROM ROLEBASIC WHERE ROLEID='" + strRoleID + "'"; storage.addSQL(str_SQL); str_SQL = "DELETE FROM ROLEPOWER WHERE ROLEID='" + strRoleID + "'"; storage.addSQL(str_SQL); str_SQL = "DELETE FROM ROLEUSER WHERE ROLEID='" + strRoleID + "'"; storage.addSQL(str_SQL); // 执行 string strReturn = storage.runSQL(); ReturnDoc returndoc = new ReturnDoc(); if (!General.empty(strReturn)) { returndoc.addErrorResult(Common.RT_FUNCERROR); returndoc.setFuncErrorInfo(strReturn); } else { returndoc.addErrorResult(Common.RT_SUCCESS); } return returndoc.getXml(); }
protected void Page_Load(object sender, EventArgs e) { try { string sMothod = Request["method"]; if (!General.empty(sMothod)) { Type ts = typeof(baseRef); object obj = Activator.CreateInstance(ts, null); //获得一个实例 object[] methodParamArgs = new object[] { Request, Response }; MethodInfo mi = ts.GetMethod(sMothod); //获得执行方法 string sXml = (string)mi.Invoke(obj, methodParamArgs); //带参数方法的调用并返回值 Response.ContentType = "text/xml;charset=utf-8"; Response.Charset = "UTF-8"; Response.Write(sXml); } } catch (Exception ex) { ReturnDoc obj_ReturnDoc = new ReturnDoc(); obj_ReturnDoc.addErrorResult(ex.Message); obj_ReturnDoc.setFuncErrorInfo(Common.SRT_FUNCERROR); Response.Write(obj_ReturnDoc.getXml()); } }
public static string ExpExcel(string path) { ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks; Microsoft.Office.Interop.Excel.Workbook workbook = workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];//取得sheet1 worksheet.Cells[1, 1] = "管道名称"; // 数据查询 OleDbDataReader rst = null; string ret = CommonQuery.qryRst("select * from PIPELINE", ref rst); Int16 i = 2; DicCache dic = DicCache.getInstance(); if (ret.Equals("0")) { while (rst.Read()) { worksheet.Cells[i, 1] = rst["DATA1"].ToString(); i++; } rst.Close(); } string sPath = path; string filename = "海底管道数据导出.xls"; workbook.Saved = true; workbook.SaveCopyAs(sPath + filename); xlApp.Quit(); obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS); obj_ReturnDoc.setFuncErrorInfo(filename); } catch (Exception e) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(e.Message); } return obj_ReturnDoc.getXml(); }
public static string addNew(string strXml) { /// 创建执行对象 DataStorage obj_Storage = new DataStorage(); ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { XmlDocument obj_Doc = XmlFun.CreateNewDoc(strXml); XmlNodeList nodeLst = obj_Doc.SelectNodes("//*[@operation][@operation!='']"); for (int i = 0; i < nodeLst.Count; i++ ) { XmlElement ele_Temp = (XmlElement)nodeLst.Item(i); // 分配学生编码 string strpersonid = NumAssign.assignID_B("100001", "1007"); XmlFun.setNodeValue(ele_Temp.SelectSingleNode("//PERSONID"), strpersonid); string stT = ele_Temp.InnerXml; // 创建插入数据的XML string str_SQL = SQLAnalyse.analyseXMLSQL(ele_Temp); obj_Storage.addSQL(str_SQL); } /// 执行 string str_Return = obj_Storage.runSQL(); if (!General.empty(str_Return)) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(str_Return); } else { obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS); } } catch(Exception e) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(e.Message); } return obj_ReturnDoc.getXml(); }
/// <summary> /// 生成字典文件 /// </summary> /// <param name="Request"></param> /// <param name="Response"></param> /// <returns></returns> public string CreateDicFile(HttpRequest Request, HttpResponse Response) { string strDicName = Request["txtXML"]; ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { General.CreateDicFile(strDicName); obj_ReturnDoc.setErrorResult(Common.SRT_SUCCESS); } catch (Exception ep) { obj_ReturnDoc.addErrorResult(ep.Message); obj_ReturnDoc.setFuncErrorInfo(Common.SRT_FUNCERROR); } return obj_ReturnDoc.getXml(); }
/// <summary> /// 生成字典文件 /// </summary> /// <param name="Request"></param> /// <param name="Response"></param> /// <returns></returns> public string CreateDicFile(HttpRequest Request, HttpResponse Response) { string strDicName = Request["txtXML"]; ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { General.CreateDicFile(strDicName); obj_ReturnDoc.setErrorResult(Common.SRT_SUCCESS); } catch (Exception ep) { obj_ReturnDoc.addErrorResult(ep.Message); obj_ReturnDoc.setFuncErrorInfo(Common.SRT_FUNCERROR); } return(obj_ReturnDoc.getXml()); }
/// <summary> /// 统一处理标准的业务操作型XML文档,将文档分析称T-SQL封装到DataStorage类中作为一个事务执行 /// </summary> /// <param name="strXML">标准业务操作型XML文档</param> /// <returns>标准 XML 返回文档字符串</returns> public static string dealWithXml(string strXML) { /// 创建执行对象 DataStorage obj_Storage = new DataStorage(); ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { XmlDocument obj_Doc = XmlFun.CreateNewDoc(strXML); XmlNodeList nodeLst = obj_Doc.SelectNodes("//*[@operation][@operation!='']"); for (int i = 0; i < nodeLst.Count; i++) { XmlElement ele_Temp = (XmlElement)nodeLst.Item(i); // 创建插入数据的XML string str_SQL = SQLAnalyse.analyseXMLSQL(ele_Temp); obj_Storage.addSQL(str_SQL); } /// 执行 string str_Return = obj_Storage.runSQL(); if (!General.empty(str_Return)) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(str_Return); } else { obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS); } } catch (Exception e) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(e.Message); } return(obj_ReturnDoc.getXml()); }
protected void Page_Load(object sender, EventArgs e) { Response.ContentType = "text/xml;charset=utf-8"; Response.Charset = "UTF-8"; string strDicName = Request["txtDicName"]; ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { General.CreateDicFile(strDicName); obj_ReturnDoc.setErrorResult(Common.SRT_SUCCESS); } catch (Exception ep) { obj_ReturnDoc.addErrorResult(ep.Message); obj_ReturnDoc.setFuncErrorInfo(Common.SRT_FUNCERROR); } Response.Write(obj_ReturnDoc.getXml()); }
/// <summary> /// 统一处理标准的业务操作型XML文档,将文档分析称T-SQL封装到DataStorage类中作为一个事务执行 /// </summary> /// <param name="strXML">标准业务操作型XML文档</param> /// <returns>标准 XML 返回文档字符串</returns> public static string dealWithXml(string strXML) { /// 创建执行对象 DataStorage obj_Storage = new DataStorage(); ReturnDoc obj_ReturnDoc = new ReturnDoc(); try { XmlDocument obj_Doc = XmlFun.CreateNewDoc(strXML); XmlNodeList nodeLst = obj_Doc.SelectNodes("//*[@operation][@operation!='']"); for (int i = 0; i < nodeLst.Count; i++ ) { XmlElement ele_Temp = (XmlElement)nodeLst.Item(i); // 创建插入数据的XML string str_SQL = SQLAnalyse.analyseXMLSQL(ele_Temp); obj_Storage.addSQL(str_SQL); } /// 执行 string str_Return = obj_Storage.runSQL(); if (!General.empty(str_Return)) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(str_Return); } else { obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS); } } catch(Exception e) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(e.Message); } return obj_ReturnDoc.getXml(); }
public static string psnDel(string strPersonID) { /// 创建执行对象 DataStorage obj_Storage = new DataStorage(); ReturnDoc obj_ReturnDoc = new ReturnDoc(); // 手工构造sql语句 string str_SQL = "DELETE FROM PERSON WHERE PERSONID='" + strPersonID + "'"; obj_Storage.addSQL(str_SQL); /// 执行sql string str_Return = obj_Storage.runSQL(); if (!General.empty(str_Return)) { obj_ReturnDoc.addErrorResult(Common.RT_FUNCERROR); obj_ReturnDoc.setFuncErrorInfo(str_Return); } else { obj_ReturnDoc.addErrorResult(Common.RT_SUCCESS); } return obj_ReturnDoc.getXml(); }
public static string getQueryXml(OleDbDataReader rst, string[] strDicFieldList, string[] strDicNameList, string[] strDateFieldList, int int_TotalRecords, int int_TotalPages, Boolean blnDicInSv, string strListName) { strListName = strListName==null ? Common.XDOC_ROW : strListName; ReturnDoc docReturn = new ReturnDoc(); try { if (docReturn.getQueryInfo(rst, strListName)) { XmlDocument doc = docReturn.getDocument(); XmlNodeList nodeList = doc.SelectNodes(Common.BAR2 + strListName); for (int k = 0; k < nodeList.Count;k++ ) { XmlNode node = (XmlElement)nodeList.Item(k); XmlElement node_Temp; /// 处理字典的翻译 DicCache obj_DicCache = DicCache.getInstance(); if (strDicFieldList != null) { for (int i = 0; i < strDicFieldList.Length; i++) { node_Temp = (XmlElement)node.SelectSingleNode(strDicFieldList[i]); string str_Text = node_Temp.InnerText; if (General.empty(str_Text)) continue; string str_SV = obj_DicCache.getText(strDicNameList[i], str_Text); if (!blnDicInSv) { if (str_SV != null) node_Temp.InnerText = str_SV; } else { if (str_SV != null) node_Temp.SetAttribute(Common.XML_PROP_SV, str_SV); } } } /// 处理日期类型的字段 if (strDateFieldList != null) { for (int i = 0; i < strDateFieldList.Length; i++) { node_Temp = (XmlElement)node.SelectSingleNode(strDateFieldList[i]); string str_Text = node_Temp.InnerText; if (General.empty(str_Text)) continue; string str_SV = General.cDateStr(str_Text); str_Text = General.strToDate(str_SV); node_Temp.InnerText = str_Text; if (blnDicInSv) { if (str_SV != null) node_Temp.SetAttribute(Common.XML_PROP_SV, str_SV); } } } } docReturn.addErrorResult(Common.RT_QUERY_SUCCESS); } else { docReturn.addErrorResult(Common.RT_QUERY_NOTHING); } docReturn.addPropToQueryInfo(Common.XML_PROP_TOTALPAGES, int_TotalPages.ToString()); docReturn.addPropToQueryInfo(Common.XML_PROP_RECORDS, int_TotalRecords.ToString()); } catch(Exception e) { } return docReturn.getXml(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { try{ string strXml = Request["txtXML"]; // strXml = XmlFun.addXDocHead(strXml); XmlDocument doc = XmlFun.CreateNewDoc(strXml); string strUsertitle = XmlFun.getNodeValue(doc,Common.BAR2 + Common.XDOC_LOGININFO + Common.BAR + Field.USERTITLE); string strPassWord = XmlFun.getNodeValue(doc, Common.BAR2 + Common.XDOC_LOGININFO + Common.BAR + Field.USERPASSWORD); string strIP = XmlFun.getNodeValue(doc, Common.BAR2 + Common.XDOC_LOGININFO + Common.BAR + Field.LOGINIP); string strMac = XmlFun.getNodeValue(doc, Common.BAR2 + Common.XDOC_LOGININFO + Common.BAR + Field.MAC); string str_SQL = "SELECT * FROM VW_USERLIST WHERE USERTITLE='" + strUsertitle + "'"; string strErr = ""; ReturnDoc Rtdoc = new ReturnDoc(); OleDbDataReader rst = null; string strRet = CommonQuery.qryRst(str_SQL, ref rst); if (strRet == "0") { Rtdoc.getQueryInfo(rst); if (strPassWord != Rtdoc.getNodeValue(Common.BAR2 + Field.USERPASSWORD)) { strErr = "密码错误"; } } else { strErr = "查询用户信息为空"; } rst.Close(); if(strErr == "") { UserSession user = new UserSession(Rtdoc.getXml()); string[] arrSys = { user.getUserID(), user.getUserTitle(), user.getUserName(), "", user.getUnitID(), user.getUnitName(), strIP, strMac }; string logid = SystemLog.addSysLog(arrSys); user.setLogID(logid); Session.Add("RoleUser", user); Response.Redirect("Login.aspx"); Response.End(); } else { Response.Write("<script language=\"javascript\">"); Response.Write("alert('" + strErr + "');"); Response.Write("history.back();"); Response.Write("</script>"); } } catch(Exception ex) { } } }
public string getUserRightsByUserID() { /// 查询出该用户的权限信息 string str_SQL = Common.SELECT + Common.DISTINCT + Common.ALL + Common.S_FROM + Table.VW_USERRIGHTTREE + Common.S_WHERE + Field.USERID + Common.EQUAL + General.addQuotes(this.getUserID()) + Common.S_ORDER + Field.AFFAIRTYPEID + Common.COMMA + Field.EVENTTYPEID; OleDbDataReader rst_UserRight = null; try { string strRet = CommonQuery.qryRst(str_SQL,ref rst_UserRight); if (strRet != "0") { throw new Exception("获得用户权限失败"); } string str_PreAffairTypeID = ""; string str_PreEventTypeID = ""; ReturnDoc doc_RightTree = new ReturnDoc(); XmlDocument doc_tmp = doc_RightTree.getDocument(); XmlElement ele_Root = null; XmlElement ele_Query = null; XmlElement ele_AffairType = null; /// 对结果集进行遍历,用来生成功能树 while (rst_UserRight.Read()) { /// 创建查询返回节点 if (!doc_RightTree.createQueryInfoNode()) { throw new Exception("UserCache.setUserRightsByUserID.创建查询返回节点时发生错误"); } /// if (!doc_RightTree.createQueryInfoNode()) ele_Root = ele_Root == null ? (XmlElement)doc_RightTree.getQueryInfoNode() : ele_Root; string str_AffairTypeID = rst_UserRight[Field.AFFAIRTYPEID].ToString(); string str_AffairTypeName = rst_UserRight[Field.AFFAIRTYPENAME].ToString(); string str_EventTypeID = rst_UserRight[Field.EVENTTYPEID].ToString(); string str_EventTypeName = rst_UserRight[Field.EVENTTYPENAME].ToString(); string str_OpURL = rst_UserRight[Field.OPURL].ToString(); int int_AffairTypeID = Convert.ToInt32(str_AffairTypeID); XmlElement ele_EventType = null; /// 查询事务 if (int_AffairTypeID == 4) { ele_AffairType = doc_tmp.CreateElement(Common.XDOC_OPERATION); ele_AffairType.SetAttribute(Common.XML_PROP_AFFAIRTYPEID, str_AffairTypeID); ele_AffairType.SetAttribute(Common.XML_PROP_NAME, str_AffairTypeName); ele_Query = ele_AffairType; ele_Root.AppendChild(ele_AffairType); } /// if (int_AffairTypeID==4) else { if (!str_PreAffairTypeID.EndsWith(str_AffairTypeID)) { ele_AffairType = doc_tmp.CreateElement(Table.AFFAIRTYPE); ele_AffairType.SetAttribute(Common.XML_PROP_AFFAIRTYPEID, str_AffairTypeID); ele_AffairType.SetAttribute(Common.XML_PROP_TEXT, str_AffairTypeName); str_PreAffairTypeID = str_AffairTypeID; ele_Root.AppendChild(ele_AffairType); } } /// 相同的事件类型,则不用重复创建 if (!str_PreEventTypeID.Equals(str_EventTypeID)) { ele_EventType = doc_tmp.CreateElement(Table.EVENTTYPE); ele_EventType.SetAttribute(Common.XML_PROP_EVENTTYPEID, str_EventTypeID); ele_EventType.SetAttribute(Common.XML_PROP_TEXT, str_EventTypeName); ele_EventType.SetAttribute(Common.XML_PROP_OPURL, str_OpURL); ele_AffairType.AppendChild(ele_EventType); str_PreEventTypeID = str_EventTypeID; } /// if (!str_PreEventTypeID.equals(str_EventTypeID)) } /// while (rst_UserRight.next()) /// 将查询事务节点,追加到权限功能树的最后 if (ele_Query != null) { XmlElement ele_TempQuery = (XmlElement)ele_Query.Clone(); XmlElement ele_QueryInfo = (XmlElement)doc_RightTree.getQueryInfoNode(); ele_QueryInfo.RemoveChild(ele_Query); ele_QueryInfo.AppendChild(ele_TempQuery); } /// if (ele_Query!=null) if (!doc_RightTree.addErrorResult(Common.RT_QUERY_SUCCESS)) { throw new Exception("添加函数返回结果失败"); } /// if (!doc_RightTree.addErrorResult(Common.RT_QUERY_SUCCESS)) return doc_RightTree.getXml(); } catch (Exception e) { return e.Message; } finally { rst_UserRight.Close(); } }