Example #1
0
        /// <summary>
        /// 通过管理角色取得角色
        /// </summary>
        /// <param name="sendToField">管理角色字段</param>
        /// <param name="tableName">表名</param>
        /// <param name="wherePart">筛选条件/param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        public static string GetRoleIdByRefRole(FLInstance flInstance, string sendToField, string tableName, string wherePart, object[] clientInfo, bool isUser)
        {
            if (sendToField == null || sendToField == string.Empty)
            {
                String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdIsNull");
                throw new FLException(2, message);
            }

            var eepAlias = ((IFLRootActivity)flInstance.RootFLActivity).EEPAlias;
            var alias = string.Empty;
            if (!string.IsNullOrEmpty(eepAlias))
            {
                alias = (string)((object[])clientInfo[0])[2];
                ((object[])clientInfo[0])[2] = eepAlias;
            }

            EEPRemoteModule remoteModule = new EEPRemoteModule();

            string where = string.Empty;
            string s = wherePart.ToString();
            string[] ss = s.Split(';');
            foreach (string o in ss)
            {
                where += o.Replace("''", "'");
                where += " and ";
            }
            wherePart = where + " 1=1 ";

            //wherePart = wherePart.Replace("''", "'");

            string sql = string.Format(GET_ROLE_ID_BY_ERF_ROLE, tableName, wherePart);
            clientInfo[3] = sql;//modify by ccm hosttable sql use login db
            object[] objs = remoteModule.GetSqlCommand(clientInfo, "GLModule", "cmdWorkflow", "", false);
            //object[] objs = remoteModule.CallMethod(clientInfo, "GLModule", "ExcuteWorkFlow", new object[] { sql });

            string refRoleId = string.Empty;
            if (objs[0].ToString() == "0")
            {
                DataSet ds = (DataSet)objs[1];
                if (ds != null && ds.Tables.Count != 0 && ds.Tables[0].Rows.Count != 0)
                {
                    refRoleId = ds.Tables[0].Rows[0][sendToField].ToString();
                    if (string.IsNullOrEmpty(refRoleId.Trim()))
                    {
                        String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotExist");
                        throw new FLException(2, message);
                    }

                    if (!isUser)
                    {
                        int i = GetGroupCount(refRoleId, clientInfo);
                        if (i == 0)
                        {
                            String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdNotExist");
                            throw new FLException(2, message);
                        }
                    }
                }
                else
                {
                    String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "Logic", "SendToIdIsNull");
                    throw new FLException(2, message);
                }
            }
            else if (objs[0].ToString() == "1")
            {
                throw new FLException(objs[1].ToString());
            }

            if (!string.IsNullOrEmpty(alias))
            {
                ((object[])clientInfo[0])[2] = alias;
            }

            return refRoleId;
        }
Example #2
0
        //public static string GetWherePart(DataRow row, string keys)
        //{
        //    string[] k1 = keys.Split(';');
        //    string where = string.Empty;
        //    foreach (string k in k1)
        //    {
        //        string s = string.Empty;
        //        if (k != null && k.Length > 0)
        //        {
        //            DataColumn c = row.Table.Columns[k];
        //            string type = c.DataType.FullName;
        //            s += k;
        //            s += "=";
        //            s += Mark(type, TransformMarkerInColumnValue(type, row[k]));
        //            if (where.Length > 0)
        //            {
        //                where += " AND ";
        //            }
        //            where += s;
        //        }
        //    }
        //    return where;
        //}
        /// <summary>
        /// ȡ��Details����
        /// </summary>
        /// <param name="masterDataSet">��������</param>
        /// <param name="keys">ɸѡ����</param>
        /// <param name="detailsTableName">�ӱ���</param>
        /// <param name="relationKeys">��������</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        public static DataSet GetDetailsDataSet(FLInstance flInstance, DataSet masterDataSet, string keys, string detailsTableName, string relationKeys, object[] clientInfo)
        {
            if (string.IsNullOrEmpty(relationKeys))
            {
                return null;
            }

            if (string.IsNullOrEmpty(keys))
            {
                String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "HostTable", "KeysWasNotDefine");
                throw new FLException(3, message);
            }

            string[] k1 = keys.Split(";,".ToCharArray());
            string[] k2 = relationKeys.Split(";,".ToCharArray());

            if(k1.Length != k2.Length)
            {
                String message = SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "HostTable", "KeysLengthNotEqualRelation");
                throw new FLException(message);
            }

            int i = 0;
            string where = string.Empty;
            foreach (string k in k1)
            {
                string s = string.Empty;
                if (k != null && k.Length > 0)
                {
                    DataColumn c = masterDataSet.Tables[0].Columns[k];
                    string type = c.DataType.FullName;

                    s += k2[i];
                    s += "=";
                    s += Mark(type, TransformMarkerInColumnValue(type, masterDataSet.Tables[0].Rows[0][k]));

                    if (where.Length > 0)
                    {
                        where += " AND ";
                    }

                    where += s;
                }

                i++;
            }

            EEPRemoteModule remoteModule = new EEPRemoteModule();
            var eepAlias = ((IFLRootActivity)flInstance.RootFLActivity).EEPAlias;
            var alias = string.Empty;
            if (!string.IsNullOrEmpty(eepAlias))
            {
                alias = (string)((object[])clientInfo[0])[2];
                ((object[])clientInfo[0])[2] = eepAlias;
            }
            string sql = string.Format(GET_HOSTDATASET, Qutoe(clientInfo, detailsTableName), where);
            clientInfo[3] = sql;
            object[] objs = remoteModule.GetSqlCommand(clientInfo, "GLModule", "cmdWorkflow", "", false);
            if (!string.IsNullOrEmpty(alias))
            {
                ((object[])clientInfo[0])[2] = alias;
            }
            if (objs[0].ToString() == "0")
            {
                return (DataSet)objs[1];
            }
            else if (objs[0].ToString() == "1")
            {
                throw new FLException(objs[1].ToString());
            }
            else
            {
                return null;
            }
        }
Example #3
0
        /// <summary>
        /// �取得PresentCT
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="keys">筛选条件</param>
        /// <param name="values">�筛选值</param>
        /// <param name="presentFields">PresentCT�字段</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        public static string GetFormPresentCT(FLInstance flInstance, string keys, string values, string presentFields, object[] clientInfo, bool sqluse)
        {
            if (!string.IsNullOrEmpty(presentFields))
            {

                DataSet dataSet = HostTable.GetHostDataSet(flInstance, new object[] { keys, values }, clientInfo);
                if (dataSet != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows.Count != 0)
                {
                    DataRow row = dataSet.Tables[0].Rows[0];

                    string[] fields = presentFields.Split(",".ToCharArray());
                    foreach (string field in fields)
                    {
                        if (string.IsNullOrEmpty(field))
                            continue;

                        if (!string.IsNullOrEmpty(keys) && row.Table.Columns.Contains(field))
                        {
                            keys += string.Format(";{0}", field);
                            string value = string.Empty;

                            if (row.Table.Columns[field].DataType == typeof(DateTime) && row[field] != DBNull.Value)
                            {
                                value = ((DateTime)row[field]).ToString("yyyy/MM/dd");
                            }
                            else
                            {
                                value = row[field].ToString();
                                if (sqluse)
                                {
                                    value = value.Replace("'", "''");
                                }
                            }

                            values += string.Format(";{0}={1}", field, value);
                        }
                    }
                }
            }

            EEPRemoteModule remoteModule = new EEPRemoteModule();
            string tableName = ((IFLRootActivity)flInstance.RootFLActivity).TableName;
            string presentCT = values;
            string sql = "select * from COLDEF where TABLE_NAME = '" + tableName + "'";

            var eepAlias = ((IFLRootActivity)flInstance.RootFLActivity).EEPAlias;
            var alias = string.Empty;
            if (!string.IsNullOrEmpty(eepAlias))
            {
                alias = (string)((object[])clientInfo[0])[2];
                ((object[])clientInfo[0])[2] = eepAlias;
            }

            clientInfo[3] = sql;
            object[] objs = remoteModule.GetSqlCommand(clientInfo, "GLModule", "cmdDDUse", "", false);

            if (objs[0].ToString() == "0")
            {
                DataSet ds = (DataSet)objs[1];
                if (ds != null && ds.Tables.Count != 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count != 0)
                {
                    string[] dataKeys = keys.Split(';');
                    foreach (string key in dataKeys)
                    {
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            if (row["FIELD_NAME"].ToString().ToLower() == key.ToLower())
                            {
                                //presentCT = presentCT.Replace(key, row["CAPTION"].ToString());
                                presentCT = presentCT.Replace(key + "=", row["CAPTION"].ToString() + "=");
                                break;
                            }
                        }
                    }
                    presentCT.Replace("'", "");
                }

            }
            if (!string.IsNullOrEmpty(alias))
            {
                ((object[])clientInfo[0])[2] = alias;
            }
            return presentCT;
        }
Example #4
0
        /// <summary>
        /// ȡ��������
        /// </summary>
        /// <param name="hostTableName">��������</param>
        /// <param name="keyValues">�������ɸѡ����</param>
        /// <param name="clientInfo">ClientInfo</param>
        /// <returns></returns>
        private static DataSet GetHostDataSet(string hostTableName, object[] keyValues, object[] clientInfo)
        {
            EEPRemoteModule remoteModule = new EEPRemoteModule();
            if (hostTableName == null || hostTableName == string.Empty || keyValues.Length == 0)
            {
                String message = string.Format(SysMsg.GetSystemMessage((SYS_LANGUAGE)(((object[])(clientInfo[0]))[0]), "FLRuntime", "HostTable", "HostTableNotContainRecord"), hostTableName, keyValues[1].ToString());
                throw new FLException(message);
            }

            string where = string.Empty;
            string s = keyValues[1].ToString();
            string[] ss = s.Split(";".ToCharArray());
            foreach (object o in ss)
            {
                where += (o.ToString()).Replace("''", "'");
                where += " and ";
            }
            where = where + " 1=1 ";
            string sql = string.Format(GET_HOSTDATASET, Qutoe(clientInfo, hostTableName), where);
            clientInfo[3] = sql;
            object[] objs = remoteModule.GetSqlCommand(clientInfo, "GLModule", "cmdWorkflow", "", false);

            if (objs[0].ToString() == "0")
            {
                return (DataSet)objs[1];
            }
            else if (objs[0].ToString() == "1")
            {
                throw new FLException(objs[1].ToString());
            }
            else
            {
                return null;
            }
        }