public object[] CheckManagerRight(object[] objParam) { string sDB = objParam[0].ToString(); string sUserId = objParam[1].ToString(); string password = (string)GetClientInfo(ClientInfoType.Password); if (ServerConfig.LoginObjectEnabled)//ILogin { if (ServerConfig.LoginObject.GetMenuRight(sUserId, password)) { return new object[] { 0, "0" }; } else { return new object[] { 0, "1" }; } } else { ClientType ct = ClientType.ctMsSql; IDbConnection mySqlConnection = AllocateConnection(sDB, ref ct, true); try { string sRet = ""; //为了区分不同的数据库 by Rei InfoCommand myInfoCommand = new InfoCommand(ClientInfo); myInfoCommand.CommandText = "SELECT USERID,AUTOLOGIN FROM USERS WHERE USERID = '" + sUserId + "'"; myInfoCommand.Connection = mySqlConnection; IDataReader aReader = myInfoCommand.ExecuteReader(); if (!aReader.Read()) // userid not found { sRet = "2"; } else { string autologin = aReader.GetValue(1).ToString(); if (string.Compare(autologin, "s", true) == 0)//IgnoreCase { sRet = "0"; } else { sRet = "1"; } } myInfoCommand.Cancel(); aReader.Close(); return new object[] { 0, sRet }; } finally { ReleaseConnection(sDB, mySqlConnection, true); } } }
public object[] CheckUser(object[] objParam) { string[] ss = objParam[0].ToString().Split(":".ToCharArray()); string username = ""; string useridindb = ""; try { string sUserId = ss[0]; string sUserPwd = ss[1]; string sDB = ss[2]; string relogin = ss[3]; //matida 2010/1/29 add String SharePoint = String.Empty; if (ss.Length == 5) SharePoint = ss[4].ToLower(); if (ss.Length == 7) SharePoint = ss[6].ToLower(); object computername = GetClientInfo(ClientInfoType.ComputerName); string strcomputer = computername != null ? computername.ToString() : string.Empty; if (!SrvGL.AllowLoginInOtherPC && relogin == "0" && SrvGL.isUserLogined(sUserId.ToLower())) { UserInfo info = SrvGL.GetUsersInfo(sUserId.ToLower()); if (!info.Contains(strcomputer)) { return new object[] { 0, LoginResult.RequestReLogin, username, useridindb }; } } if (ServerConfig.LoginObjectEnabled)//ILogin { if (!ServerConfig.LoginObject.CheckUser(sUserId, sUserPwd)) { return new object[] { 0, LoginResult.PasswordError, username, useridindb }; } username = ServerConfig.LoginObject.GetUserInfo(sUserId, sUserPwd, UserInfoType.UserName).ToString(); useridindb = sUserId; SrvGL.LogUser(sUserId.ToLower(), username, strcomputer, 1); } else { //rich modified, 根据andy的最高指示,systemtable和eepalias要分离;(如果systemtable未设置,则使用前端传过来的eepalias) ClientType ct = ClientType.ctMsSql; IDbConnection mySqlConnection = AllocateConnection(sDB, ref ct, true); try { //为了区分不同的数据库 by Rei InfoCommand myInfoCommand = new InfoCommand(ClientInfo); if (ServerConfig.UserDefination) { myInfoCommand.CommandText = string.Format("Select {0},{1},{2},'N','S' From {3} Where {0} = '{4}'", ServerConfig.UserID , ServerConfig.Password, ServerConfig.UserName, ServerConfig.UserTable, sUserId); } else { myInfoCommand.CommandText = "SELECT USERID,PWD,USERNAME,MSAD,AUTOLOGIN FROM USERS WHERE USERID = '" + sUserId + "'"; } myInfoCommand.Connection = mySqlConnection; IDataReader aReader = myInfoCommand.ExecuteReader(CommandBehavior.CloseConnection); if (!aReader.Read()) // userid not found { myInfoCommand.Cancel(); aReader.Close(); return new object[] { 0, LoginResult.UserNotFound, username, useridindb }; } if (string.Compare(aReader.GetValue(4).ToString(), "x", true) == 0) { myInfoCommand.Cancel(); aReader.Close(); return new object[] { 0, LoginResult.Disabled, username, useridindb }; } object sPwd = aReader.GetValue(1); if (ct == ClientType.ctOleDB && sPwd.ToString() == " ") sPwd = ""; username = aReader.GetValue(2).ToString(); useridindb = aReader.GetValue(0).ToString(); //get userid in database to avoid case problem string msad = aReader.GetValue(3).ToString(); string domainname = ss.Length == 6 ? ss[4] : string.Empty; string domaincheck = ss.Length == 6 ? ss[5] : string.Empty; myInfoCommand.Cancel(); aReader.Close(); if (domainname.Length == 0) { if (string.Compare(msad, "Y", true) == 0) { ADClass.ADPath = "LDAP://" + ServerConfig.DomainPath; ADClass.ADUser = ServerConfig.DomainUser; ADClass.ADPassword = ServerConfig.DomainPassword; if (!ADClass.IsUserValid(sUserId, sUserPwd)) { return new object[] { 0, LoginResult.PasswordError, username, useridindb }; } } else { if (sUserPwd.Length > 10) { return new object[] { 0, LoginResult.PasswordError, username, useridindb }; } string enPwd = sUserPwd; if (sUserPwd.Length > 0) { char[] p = new char[] { }; bool q = Encrypt.EncryptPassword(sUserId, sUserPwd, 10, ref p, false); enPwd = new string(p); } if (!Comparer.Equals(enPwd, sPwd.ToString().Trim()) && SharePoint != "sharepoint") // pwd not correct //matida 2010/1/29 add { return new object[] { 0, LoginResult.PasswordError, username, useridindb }; } } } else { if (string.Compare(domainname, ServerConfig.DomainPath, true) != 0 || (string.Compare(msad, "Y", true) != 0) || CliUtils.DomainCheckSum(domainname) != domaincheck) { return new object[] { 0, LoginResult.PasswordError, username, useridindb }; } } SrvGL.LogUser(sUserId.ToLower(), username, strcomputer, 1); } finally { ReleaseConnection(sDB, mySqlConnection, true); } } } catch (Exception e) { return new object[] { 1, e.Message }; } return new object[] { 0, LoginResult.Success, username, useridindb }; }
public object[] PackageRollback(object[] objParam) { string projectname = ((string)objParam[0]); string filename = ((string)objParam[1]); string dt = ((string)objParam[2]); PackageType ptype = ((PackageType)objParam[3]); string packagetype = ""; switch (ptype) { case PackageType.Client: packagetype = "C"; break; case PackageType.Server: packagetype = "S"; break; case PackageType.WebClient: packagetype = "W"; break; } ClientType ct = ClientType.ctMsSql; //IDbConnection nwindConn = AllocateConnection(GetSystemDBName(), ref ct, false); //menuchecklog用sysDB里的 IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); //取登陆后的DBAlias ——by Rei try { string strsql = ""; if (nwindConn is SqlConnection) strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND [FILENAME] ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE >'" + dt + "'"; else if (nwindConn is OdbcConnection) strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND FILENAME ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE > to_date('" + String.Format("{0:yyyyMMddHHmmss}", Convert.ToDateTime(dt)) + "', '%Y%m%d%H%M%S')"; else if (nwindConn is OracleConnection) strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND FILENAME ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE > to_date('" + dt + "', 'yyyy-mm-dd hh24:mi:ss')"; else if (nwindConn is OleDbConnection) strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND FILENAME ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE >'" + dt + "'"; else if (nwindConn.GetType().Name == "MySqlConnection") strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND FILENAME ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE > '" + dt + "'"; else if (nwindConn.GetType().Name == "IfxConnection") strsql = "DELETE FROM MENUCHECKLOG WHERE ITEMTYPE ='" + projectname + "' AND FILENAME ='" + filename + "' AND FILETYPE='" + packagetype + "' AND PACKAGEDATE > to_date('" + String.Format("{0:yyyyMMddHHmmss}", Convert.ToDateTime(dt)) + "', '%Y%m%d%H%M%S')"; InfoCommand cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = strsql; cmd.ExecuteNonQuery(); string strBlob = ""; if (nwindConn is SqlConnection) strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE [FILENAME] = '" + filename + "' AND PACKAGEDATE = '" + dt + "' AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; else if (nwindConn is OdbcConnection) strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE FILENAME = '" + filename + "' AND PACKAGEDATE = to_date('" + String.Format("{0:yyyyMMddHHmmss}", Convert.ToDateTime(dt)) + "', '%Y%m%d%H%M%S') " + " AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; else if (nwindConn is OracleConnection) strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE FILENAME = '" + filename + "' AND PACKAGEDATE = to_date('" + dt + "', 'yyyy-mm-dd hh24:mi:ss')" + " AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; else if (nwindConn is OleDbConnection) strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE FILENAME = '" + filename + "' AND PACKAGEDATE = '" + dt + "' AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; else if (nwindConn.GetType().Name == "MySqlConnection") strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE FILENAME = '" + filename + "' AND PACKAGEDATE = '" + dt + "'" + " AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; else if (nwindConn.GetType().Name == "IfxConnection") strBlob = "SELECT FILECONTENT, FILEDATE FROM MENUCHECKLOG WHERE FILENAME = '" + filename + "' AND PACKAGEDATE = to_date('" + String.Format("{0:yyyyMMddHHmmss}", Convert.ToDateTime(dt)) + "', '%Y%m%d%H%M%S') " + " AND ITEMTYPE ='" + projectname + "' AND FILETYPE='" + packagetype + "'"; cmd.CommandText = strBlob; IDataReader idr = cmd.ExecuteReader(); idr.Read(); try { byte[] blob = new byte[idr.GetBytes(0, 0, null, 0, int.MaxValue)]; idr.GetBytes(0, 0, blob, 0, blob.Length); DateTime dtfile = new DateTime(); try { dtfile = (DateTime)idr.GetValue(1); //找到记录 } catch { dtfile = DateTime.MinValue; } cmd.Cancel(); idr.Close(); PackageService ps = new PackageService(); ps.Upload(filename, projectname, ptype, blob, dtfile); return new object[] { 0, 0 }; } catch (Exception e) { return new object[] { 0, 1, e.Message }; } } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
public object[] SendMessage(object[] objParams) { bool bGroup = (bool)objParams[0]; string sUser = (string)objParams[1]; string sMsg = (string)objParams[2]; string sParams = (string)objParams[3]; string sNow = FormatDateTime(DateTime.Now); string sLoginUser = GetClientInfo(ClientInfoType.LoginUser).ToString(); string status = "S"; ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { //为了区分不同的数据库 by Rei InfoCommand myCommand = new InfoCommand(ClientInfo); myCommand.Connection = nwindConn; string strSql = ""; ArrayList arrUsers = new ArrayList(); if (bGroup) { strSql = string.Format("select distinct USERID from USERGROUPS where GROUPID = '{0}'", sUser); myCommand.CommandText = strSql; IDataReader aReader = myCommand.ExecuteReader(); try { bool b = aReader.Read(); while (b) { arrUsers.Add(aReader.GetString(0)); b = aReader.Read(); } } finally { aReader.Close(); } } else { arrUsers.Add(sUser); } for (int i = 0; i < arrUsers.Count; i++) { strSql = string.Format("insert into SYS_MESSENGER (USERID, MESSAGE, PARAS, SENDTIME, SENDERID, STATUS) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", (string)arrUsers[i], sMsg, sParams, sNow, sLoginUser, status); myCommand.CommandText = strSql; myCommand.ExecuteNonQuery(); } return new object[] { 0 }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
//FL use Cancel public object GetUserRole(object[] objParam) { ClientType ct = ClientType.ctNone; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { string user = (string)GetClientInfo(ClientInfoType.LoginUser); string orgKind = (string)GetClientInfo(ClientInfoType.OrgKind); StringBuilder role = new StringBuilder(); StringBuilder orgRole = new StringBuilder(); StringBuilder orgShare = new StringBuilder(); StringBuilder groupList = new StringBuilder(); InfoCommand cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = String.Format("SELECT GROUPID FROM GROUPS WHERE GROUPID IN (SELECT GROUPID FROM USERGROUPS WHERE USERID='{0}') AND ISROLE='Y'" , user); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (role.Length > 0) { role.Append(';'); groupList.Append(','); } role.Append((string)reader["GROUPID"]); groupList.Append(string.Format("'{0}'", reader["GROUPID"])); } cmd.Cancel(); reader.Close(); } if (role.Length > 0) { orgRole.Append(role); cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = string.Format("Select ORG_NO From SYS_ORG Where ORG_MAN IN({0}) and ORG_KIND='{1}'", groupList, orgKind); StringBuilder orglist = new StringBuilder(); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if (orglist.Length > 0) { orglist.Append(','); } orglist.Append(string.Format("'{0}'", reader["ORG_NO"])); } cmd.Cancel(); reader.Close(); } if (orglist.Length > 0)//找到Org_No { StringBuilder orgParentlist = new StringBuilder(); orgParentlist.Append(orglist); while (true)//递归找到所有的子org { cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = string.Format("Select ORG_NO,ORG_MAN From SYS_ORG Where UPPER_ORG IN ({0})", orgParentlist); using (IDataReader reader = cmd.ExecuteReader()) { orgParentlist = new StringBuilder(); while (reader.Read()) { orglist.Append(','); orglist.Append(string.Format("'{0}'", reader["ORG_NO"])); if (orgParentlist.Length > 0) { orgParentlist.Append(','); } orgParentlist.Append(string.Format("'{0}'", reader["ORG_NO"])); orgRole.Append(';'); orgRole.Append((string)reader["ORG_MAN"]); } cmd.Cancel(); reader.Close(); if (orgParentlist.Length == 0)//找到底了 { break; } } } cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = string.Format("Select ROLE_ID From SYS_ORGROLES WHERE ORG_NO IN ({0})", orglist); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { orgRole.Append(';'); orgRole.Append((string)reader["ROLE_ID"]); } cmd.Cancel(); reader.Close(); } orgShare.Append(orgRole); } else { orgShare.Append(role); cmd = new InfoCommand(ClientInfo); cmd.Connection = nwindConn; cmd.CommandText = string.Format("Select ROLE_ID From SYS_ORGROLES WHERE ORG_NO IN (Select ORG_NO From SYS_ORGROLES Where ROLE_ID IN ({0}))", groupList); using (IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { orgShare.Append(';'); orgShare.Append((string)reader["ROLE_ID"]); } cmd.Cancel(); reader.Close(); } } } return new object[] { 0, role.ToString(), orgRole.ToString(), orgShare.ToString() }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
public object AutoSeqMenuID(object[] objParam) { ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { string strSql = ""; //为了区分不同的数据库 by Rei InfoCommand cmd = new InfoCommand(ClientInfo); if (nwindConn is SqlConnection) { strSql = "select max(convert(int,MENUID)) from MENUTABLE where isnumeric(MENUID)=1"; } else if (nwindConn is OracleConnection) { strSql = "select max(to_number(MENUID)) from MENUTABLE"; } else if (nwindConn is OdbcConnection) { strSql = "select max(MENUID) from MENUTABLE"; } else if (nwindConn is OleDbConnection) { strSql = "select max(convert(int,MENUID)) from MENUTABLE"; } else if (nwindConn.GetType().Name == "MySqlConnection") { strSql = "select max(cast(MENUID as signed)) from MENUTABLE"; } else if (nwindConn.GetType().Name == "IfxConnection") { strSql = "select max(MENUID) from MENUTABLE"; } cmd.Connection = nwindConn; cmd.CommandText = strSql; IDataReader dr = cmd.ExecuteReader(); dr.Read(); string count = dr[0].ToString(); cmd.Cancel(); dr.Close(); int i = Convert.ToInt32(count) + 1; return new object[] { 0, i }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
public object GetTableNames(object[] parames) { ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, false); try { string strSql = ""; if (nwindConn is SqlConnection) { strSql = "select @@version as version"; InfoCommand cmd = new InfoCommand(ClientInfo); cmd.CommandText = strSql; cmd.Connection = nwindConn; Object o = cmd.ExecuteScalar(); if (o.ToString().ToLower().IndexOf("microsoft sql server 2005") >= 0) { strSql = @"select ( case when b.name != 'dbo' then case when (Charindex(' ',Rtrim(Ltrim(b.name)),0) > 0) then '[' + b.[name] + ']' else b.[name] end + '.' + case when (Charindex(' ',Rtrim(Ltrim(a.name)),0) != 0) then '[' + a.[name] + ']' else a.[name] end else case when (Charindex(' ',Rtrim(Ltrim(a.name)),0) != 0) then '[' + a.[name] + ']' else a.[name] end end )as name from sysobjects a,sys.schemas b where a.uid=b.schema_id and a.xtype in ('u','U','v','V') order by a.[name]"; } else { strSql = @"select( case when (Charindex(' ',Rtrim(Ltrim(name)),0) != 0) then '[' + [name] + ']' else [name] end ) as name from sysobjects where xtype in ('u','U','v','V') order by [name]"; } } else if (nwindConn is OdbcConnection) strSql = "select * from systables where (tabtype = 'T' or tabtype = 'V') and tabid >= 100 order by tabname"; else if (nwindConn is OracleConnection) { return new object[] { 0, GetTableNames(nwindConn.ConnectionString, nwindConn as DbConnection).ToArray() }; //strSql = "SELECT * FROM USER_OBJECTS WHERE OBJECT_TYPE = 'TABLE' OR OBJECT_TYPE = 'VIEW'order by OBJECT_NAME"; } else if (nwindConn is OleDbConnection) strSql = "sp_help"; else if (nwindConn.GetType().Name == "MySqlConnection") strSql = "show tables;"; else if (nwindConn.GetType().Name == "IfxConnection") strSql = "select * from SYSTABLES where (TABTYPE = 'T' or TABTYPE = 'V') and TABID >= 100 order by TABNAME"; InfoCommand cmd2 = new InfoCommand(ClientInfo); if (nwindConn is OleDbConnection) cmd2.CommandType = CommandType.StoredProcedure; cmd2.CommandText = strSql; cmd2.Connection = nwindConn; IDataReader reader = cmd2.ExecuteReader(); List<String> tablesList = new List<string>(); while (reader.Read()) { if (nwindConn is SqlConnection) tablesList.Add(reader["name"].ToString()); else if (nwindConn is OdbcConnection) tablesList.Add(reader["tabname"].ToString()); else if (nwindConn is OracleConnection) tablesList.Add(reader["OBJECT_NAME"].ToString()); else if (nwindConn is OleDbConnection) tablesList.Add(reader["NAME"].ToString()); else if (nwindConn.GetType().Name == "MySqlConnection") tablesList.Add(reader[0].ToString()); else if (nwindConn.GetType().Name == "IfxConnection") tablesList.Add(reader["tabname"].ToString()); } reader.Close(); return new object[] { 0, tablesList.ToArray() }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, false); } }
public object GetUserGroup(object[] objParam) { string userid = objParam[0].ToString(); string groupid = ""; string groupname = string.Empty; ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { string strSql = "select USERGROUPS.USERID,USERGROUPS.GROUPID,GROUPS.GROUPNAME FROM USERGROUPS LEFT JOIN GROUPS ON USERGROUPS.GROUPID=GROUPS.GROUPID where USERID ='" + userid + "'"; //为了区分不同的数据库 by Rei InfoCommand cmd = new InfoCommand(ClientInfo); cmd.CommandText = strSql; cmd.Connection = nwindConn; IDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { groupid += dr["GROUPID"].ToString() + ";"; groupname += dr["GROUPNAME"].ToString() + ";"; } if (groupid != "") { groupid = groupid.Substring(0, groupid.LastIndexOf(';')); groupname = groupname.Substring(0, groupname.LastIndexOf(';')); } cmd.Cancel(); dr.Close(); return new object[] { 0, groupid, groupname }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
public object GetRoles(object[] parames) { ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { List<string> list = new List<string>(); String sql = ""; String connectMark = "+"; if (nwindConn is SqlConnection) connectMark = "+"; else if (nwindConn is OdbcConnection) connectMark = "||"; else if (nwindConn is OracleConnection) connectMark = "||"; else if (nwindConn is OleDbConnection) connectMark = "+"; else if (nwindConn.GetType().Name == "MySqlConnection") connectMark = "||"; else if (nwindConn.GetType().Name == "IfxConnection") connectMark = "||"; if (nwindConn.GetType().Name == "MySqlConnection") sql = "select CONCAT(GROUPID,' ; ',GROUPNAME) from GROUPS where ISROLE='Y'"; else sql = "select GROUPID " + connectMark + " ' ; ' " + connectMark + " GROUPNAME from GROUPS where ISROLE='Y'"; InfoCommand command = new InfoCommand(ClientInfo); command.CommandText = sql; command.Connection = nwindConn; IDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { list.Add(reader[0].ToString()); } command.Cancel(); reader.Close(); return new object[] { 0, list.ToArray() }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, false); } }
public object GetParam(object[] objParam) { // byte[] buffer = new byte[24]; ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { string strCaption = (string)objParam[0]; string strItemType = (string)objParam[1]; string captionlanguage = (string)objParam[2]; string strSql = "select * from MENUTABLE where MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; //为了区分不同的数据库 by Rei InfoCommand cmd = new InfoCommand(ClientInfo); cmd.CommandText = strSql; cmd.Connection = nwindConn; ArrayList lst = new ArrayList(); IDataReader dr = cmd.ExecuteReader(); dr.Read(); lst.Add(dr["MENUID"].ToString()); lst.Add(dr["CAPTION" + captionlanguage].ToString()); lst.Add(dr["PARENT"].ToString()); lst.Add(dr["MODULETYPE"].ToString()); lst.Add(dr["IMAGEURL"].ToString()); lst.Add(dr["PACKAGE"].ToString()); lst.Add(dr["ITEMPARAM"].ToString()); lst.Add(dr["FORM"].ToString()); lst.Add(dr["ITEMTYPE"].ToString()); lst.Add(dr["SEQ_NO"].ToString()); cmd.Cancel(); dr.Close(); string strBlob = ""; //为了区分不同的数据库 by Rei if (nwindConn is SqlConnection) strBlob = "select [IMAGE] from MENUTABLE where MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; else if (nwindConn is OracleConnection) strBlob = "select IMAGE from MENUTABLE where MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; else if (nwindConn is OdbcConnection) strBlob = "select IMAGE from MENUTABLE WHERE MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; else if (nwindConn is OleDbConnection) strBlob = "select IMAGE from MENUTABLE WHERE MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; else if (nwindConn.GetType().Name == "MySqlConnection") strBlob = "select IMAGE from MENUTABLE WHERE MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; else if (nwindConn.GetType().Name == "IfxConnection") strBlob = "select IMAGE from MENUTABLE WHERE MENUID = '" + strCaption + "' and ITEMTYPE = '" + strItemType + "'"; InfoCommand cmd1 = new InfoCommand(ClientInfo); cmd1.Connection = nwindConn; cmd1.CommandText = strBlob; IDataReader idr = cmd1.ExecuteReader(); idr.Read(); try { byte[] blob = new byte[idr.GetBytes(0, 0, null, 0, int.MaxValue)]; idr.GetBytes(0, 0, blob, 0, blob.Length); cmd1.Cancel(); idr.Close(); return new object[] { 0, lst, blob }; } catch { cmd1.Cancel(); idr.Close(); return new object[] { 0, lst, new byte[1] }; } } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } //nwindConn.Close(); //return new object[] { 0, lst, blob}; }
public object GetOrgKinds(object[] parames) { ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { List<string> list = new List<string>(); string sql = "select ORG_KIND from SYS_ORGKIND"; InfoCommand command = new InfoCommand(ClientInfo); command.CommandText = sql; command.Connection = nwindConn; IDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { list.Add(reader[0].ToString()); } reader.Close(); return new object[] { 0, list.ToArray() }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
public object[] FLOvertimeList(object[] objParam) { ClientType ct = ClientType.ctMsSql; IDbConnection nwindConn = AllocateConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), ref ct, true); try { //获取本人的Roles List<string> lstRoles = new List<string>(); string currentUser = objParam[0].ToString(); string sqlCurRoles = "select GROUPID from USERGROUPS where " + (string.IsNullOrEmpty(currentUser) ? "" : "USERID = '" + currentUser + "' and ") + "GROUPID in (select GROUPID from GROUPS where ISROLE = 'Y')"; InfoCommand cmdCurRoles = new InfoCommand(ClientInfo); cmdCurRoles.Connection = nwindConn; cmdCurRoles.CommandText = sqlCurRoles; IDataReader drCurRoles = cmdCurRoles.ExecuteReader(); while (drCurRoles.Read()) { lstRoles.Add(drCurRoles["GROUPID"].ToString()); } cmdCurRoles.Cancel(); drCurRoles.Close(); List<string> lstOrgs = new List<string>(); int level = Convert.ToInt16(objParam[1]); for (int i = 0; i < level; i++) { string orgMans = ""; foreach (string man in lstRoles) { orgMans += "'" + man + "',"; } if (orgMans.IndexOf(',') != -1) orgMans = orgMans.Substring(0, orgMans.LastIndexOf(',')); string sqlOrg = string.IsNullOrEmpty(orgMans) ? "select ORG_NO from SYS_ORG where ORG_MAN IS NULL" : "select ORG_NO from SYS_ORG where ORG_MAN in (" + orgMans + ")"; InfoCommand cmdOrg = new InfoCommand(getConnectionType(nwindConn), ClientInfo); cmdOrg.Connection = nwindConn; cmdOrg.CommandText = sqlOrg; IDataReader drOrg = cmdOrg.ExecuteReader(); while (drOrg.Read()) { string org = drOrg["ORG_NO"].ToString(); if (!lstOrgs.Contains(org)) lstOrgs.Add(org); } cmdOrg.Cancel(); drOrg.Close(); string upperOrgs = ""; foreach (string org in lstOrgs) { upperOrgs += "'" + org + "',"; } if (upperOrgs.IndexOf(',') != -1) upperOrgs = upperOrgs.Substring(0, upperOrgs.LastIndexOf(',')); string sqlOrgManRole = string.IsNullOrEmpty(upperOrgs) ? "select ORG_MAN from SYS_ORG where UPPER_ORG IS NULL" : "select ORG_MAN from SYS_ORG where UPPER_ORG in (" + upperOrgs + ")"; InfoCommand cmdOrgManRole = new InfoCommand(getConnectionType(nwindConn), ClientInfo); cmdOrgManRole.Connection = nwindConn; cmdOrgManRole.CommandText = sqlOrgManRole; IDataReader drOrgManRole = cmdOrgManRole.ExecuteReader(); while (drOrgManRole.Read()) { string orgMan = drOrgManRole["ORG_MAN"].ToString(); if (!lstRoles.Contains(orgMan)) lstRoles.Add(orgMan); } cmdOrgManRole.Cancel(); drOrgManRole.Close(); } string roles = ""; foreach (string role in lstRoles) { roles += "'" + role + "',"; } if (roles.IndexOf(',') != -1) roles = roles.Substring(0, roles.LastIndexOf(',')); bool delay = Convert.ToBoolean(objParam[4]); //joy 2010/1/11 modify : 增加 ATTACHMENTS,MULTISTEPRETURN,PARAMETERS 欄位,因為逾時需要用到這些欄位 string sqlTodolist = "SELECT " + (delay ? "LISTID, FLOW_ID, FLOW_DESC, APPLICANT, S_USER_ID, S_STEP_ID, S_STEP_DESC, D_STEP_ID, D_STEP_DESC, EXP_TIME, URGENT_TIME, TIME_UNIT, USERNAME, FORM_NAME, NAVIGATOR_MODE, FLNAVIGATOR_MODE, PARAMETERS, SENDTO_KIND, SENDTO_ID, FLOWIMPORTANT, FLOWURGENT, STATUS, FORM_TABLE, FORM_KEYS, FORM_PRESENTATION, FORM_PRESENT_CT, REMARK, PROVIDER_NAME, VERSION, EMAIL_ADD, EMAIL_STATUS, VDSNAME, SENDBACKSTEP, LEVEL_NO, WEBFORM_NAME, UPDATE_DATE, UPDATE_TIME, FLOWPATH, PLUSAPPROVE, PLUSROLES, ATTACHMENTS, MULTISTEPRETURN, PARAMETERS" : "FLOW_DESC, TIME_UNIT, FLOWURGENT, UPDATE_DATE, UPDATE_TIME, URGENT_TIME, EXP_TIME") + " from SYS_TODOLIST where " + (string.IsNullOrEmpty(roles) ? "1=0" : ("(SENDTO_ID in (" + roles + ") and SENDTO_KIND='1') or (SENDTO_ID ='" + currentUser + "' and SENDTO_KIND='2')")) + (delay ? " ORDER BY UPDATE_DATE" : " ORDER BY FLOW_DESC"); InfoCommand cmdTodolist = new InfoCommand(getConnectionType(nwindConn), ClientInfo); cmdTodolist.Connection = nwindConn; cmdTodolist.CommandText = sqlTodolist; IDataAdapter adpater = DBUtils.CreateDbDataAdapter(cmdTodolist); DataTable allList = new DataTable(); (adpater as DbDataAdapter).Fill(allList); if (delay) { DataColumn colSendToDetail = new DataColumn("SENDTO_DETAIL", typeof(string), "SENDTO_ID+'('+USERNAME+')'"); DataColumn colUpdateWholeTime = new DataColumn("UPDATE_WHOLE_TIME", typeof(string), "UPDATE_DATE + ' ' + UPDATE_TIME"); DataColumn colOverTime = new DataColumn("OVERTIME", typeof(string)); allList.Columns.AddRange(new DataColumn[] { colSendToDetail, colUpdateWholeTime, colOverTime }); } List<DataRow> overTimeRows = new List<DataRow>(); #region find over time foreach (DataRow row in allList.Rows) { string TIME_UNIT = row["TIME_UNIT"].ToString(); string FLOWURGENT = row["FLOWURGENT"].ToString(); string UPDATE_DATE = row["UPDATE_DATE"].ToString(); string UPDATE_TIME = row["UPDATE_TIME"].ToString(); string URGENT_TIME = row["URGENT_TIME"].ToString(); string EXP_TIME = row["EXP_TIME"].ToString(); if (TIME_UNIT == "Day" && FLOWURGENT == "1") { if (Convert.ToDecimal(URGENT_TIME) == Decimal.Zero) continue; TimeSpan span = this.WorkTimeSpan(DateTime.Now.Date, Convert.ToDateTime(UPDATE_DATE), (bool)objParam[2], (objParam[3] == null) ? null : (List<string>)objParam[3]); int overtimes = span.Days - Convert.ToInt32(Convert.ToDecimal(URGENT_TIME)); if (delay) row["OVERTIME"] = overtimes.ToString() + "Days"; if (overtimes >= 0) { overTimeRows.Add(row); } } else if (TIME_UNIT == "Day" && FLOWURGENT == "0") { if (Convert.ToDecimal(EXP_TIME) == Decimal.Zero) continue; TimeSpan span = this.WorkTimeSpan(DateTime.Now.Date, Convert.ToDateTime(UPDATE_DATE), (bool)objParam[2], (objParam[3] == null) ? null : (List<string>)objParam[3]); int overtimes = span.Days - Convert.ToInt32(Convert.ToDecimal(EXP_TIME)); if (delay) row["OVERTIME"] = overtimes.ToString() + "Days"; if (overtimes >= 0) { overTimeRows.Add(row); } } else if (TIME_UNIT == "Hour" && FLOWURGENT == "1") { if (Convert.ToDecimal(URGENT_TIME) == Decimal.Zero) continue; TimeSpan spanDay = this.WorkTimeSpan(DateTime.Now.Date, Convert.ToDateTime(UPDATE_DATE), (bool)objParam[2], (objParam[3] == null) ? null : (List<string>)objParam[3]); int spanHour = DateTime.Now.Hour - Convert.ToDateTime(UPDATE_TIME).Hour; int overtimes = spanDay.Days * 8 + spanHour - Convert.ToInt32(Convert.ToDecimal(URGENT_TIME)); if (delay) row["OVERTIME"] = overtimes.ToString() + "Hours"; if (overtimes >= 0) { overTimeRows.Add(row); } } else if (TIME_UNIT == "Hour" && FLOWURGENT == "0") { if (Convert.ToDecimal(EXP_TIME) == Decimal.Zero) continue; TimeSpan spanDay = this.WorkTimeSpan(DateTime.Now.Date, Convert.ToDateTime(UPDATE_DATE), (bool)objParam[2], (objParam[3] == null) ? null : (List<string>)objParam[3]); int spanHour = DateTime.Now.Hour - Convert.ToDateTime(UPDATE_TIME).Hour; int overtimes = spanDay.Days * 8 + spanHour - Convert.ToInt32(Convert.ToDecimal(EXP_TIME)); if (delay) row["OVERTIME"] = overtimes.ToString() + "Hours"; if (overtimes >= 0) { overTimeRows.Add(row); } } } #endregion DataTable overtimeList = null; if (delay) { overtimeList = allList.Clone(); foreach (DataRow row in overTimeRows) { overtimeList.ImportRow(row); } } else { overtimeList = new DataTable(); DataColumn colFlowDesc = new DataColumn("FLOW_DESC", typeof(string)); DataColumn colDelayCount = new DataColumn("DELAY_COUNT", typeof(int)); overtimeList.Columns.AddRange(new DataColumn[] { colFlowDesc, colDelayCount }); string desc = ""; foreach (DataRow row in overTimeRows) { if (desc != row["FLOW_DESC"].ToString()) { desc = row["FLOW_DESC"].ToString(); int count = overTimeRows.FindAll(delegate(DataRow irow) { return irow["FLOW_DESC"].ToString() == desc; }).Count; DataRow newRow = overtimeList.NewRow(); newRow["FLOW_DESC"] = desc; newRow["DELAY_COUNT"] = count; overtimeList.Rows.Add(newRow); } } } return new object[] { 0, overtimeList }; } finally { ReleaseConnection(GetClientInfo(ClientInfoType.LoginDB).ToString(), nwindConn, true); } }
private void btnOK_Click(object sender, EventArgs e) { string DBName = this.cmbDB.Text; string DBString = this.cmbDB.SelectedValue.ToString(); string DBType = ""; string itemType = ""; foreach (DataRow dr in table.Rows) { if (dr["DBName"].ToString() == DBName) { DBType = dr["DBType"].ToString(); break; } } IDbConnection connection = AllocateConnection(DBType, DBString); InfoCommand cmd = new InfoCommand(); string strSql = "select * from MENUITEMTYPE"; cmd.CommandText = strSql; cmd.Connection = connection; connection.Open(); IDataReader dreader = cmd.ExecuteReader(); bool bItemTypeExisted = false; while (dreader.Read()) { if (dreader["ITEMNAME"].ToString() == this.itemName) { bItemTypeExisted = true; itemType = dreader["ITEMTYPE"].ToString(); } } dreader.Close(); if (!bItemTypeExisted) { //Solution原本不存在,新建一个Solution strSql = "insert into MENUITEMTYPE (ITEMTYPE, ITEMNAME) values ('" + this.itemName + "', '" + this.itemName + "')"; cmd.CommandText = strSql; cmd.Connection = connection; cmd.ExecuteNonQuery(); itemType = this.itemName; } foreach (string menu in this.menuList) { strSql = "select count(*) from MENUTABLE where PACKAGE = '" + menu + "' and MODULETYPE = 'S' and ITEMTYPE = '" + itemType + "'"; cmd.CommandText = strSql; cmd.Connection = connection; int count = (int)cmd.ExecuteScalar(); if (count == 0) { strSql = "insert into MENUTABLE (MENUID, CAPTION, PACKAGE, MODULETYPE, ITEMTYPE) " + "values ('" + menu + "id', '" + menu + "', '" + menu + "', 'S', '" + itemType + "')"; cmd.CommandText = strSql; cmd.Connection = connection; cmd.ExecuteNonQuery(); } } this.Close(); }