Esempio n. 1
0
        public static DataTable AssignedUser()
        {
            Cache Cache = HttpRuntime.Cache;

            bool   bTeamFilter = !Security.IS_ADMIN && Config.enable_team_management();
            string sCACHE_NAME = String.Empty;

            if (bTeamFilter)
            {
                sCACHE_NAME = "vwTEAMS_ASSIGNED_TO." + Security.USER_ID;
            }
            else
            {
                sCACHE_NAME = "vwUSERS_ASSIGNED_TO";
            }
            var dt = Cache.Get(sCACHE_NAME) as DataTable;

            if (dt == null)
            {
                var    oQuery = new InlineQueryDBManager();
                string innerSql;
                if (bTeamFilter)
                {
                    innerSql = ApplicationSQL.SQL["_code_CRMCache_256"].ToString();
                }
                else
                {
                    innerSql = "select ID                 " + ControlChars.CrLf
                               + "     , USER_NAME          " + ControlChars.CrLf
                               + "  from vwUSERS_ASSIGNED_TO" + ControlChars.CrLf
                               + " order by USER_NAME       " + ControlChars.CrLf;
                }
                oQuery.CommandText = innerSql;
                if (bTeamFilter)
                {
                    oQuery.Add("@MEMBERSHIP_USER_ID", SqlDbType.UniqueIdentifier, Security.USER_ID);
                }
                dt = oQuery.GetTable();
                Cache.Insert(sCACHE_NAME, dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration);
            }
            return(dt);
        }
Esempio n. 2
0
        public static DataTable ImportColumns(string sMODULE_NAME)
        {
            Cache Cache = HttpRuntime.Cache;
            var   dt    = Cache.Get("vwSqlColumns_Import." + sMODULE_NAME) as DataTable;

            if (dt == null)
            {
                string sTABLE_NAME =
                    CommonTypeConvert.ToString(HttpContext.Current.Application["Modules." + sMODULE_NAME + ".TableName"]);
                if (CommonTypeConvert.IsEmptyString(sTABLE_NAME))
                {
                    sTABLE_NAME = sMODULE_NAME.ToUpper();
                }

                var oQuery = new InlineQueryDBManager();


                dt = new DataTable();
                dt.Columns.Add("ColumnName", Type.GetType("System.String"));
                dt.Columns.Add("NAME", Type.GetType("System.String"));
                dt.Columns.Add("DISPLAY_NAME", Type.GetType("System.String"));
                dt.Columns.Add("ColumnType", Type.GetType("System.String"));
                dt.Columns.Add("Size", Type.GetType("System.Int32"));
                dt.Columns.Add("Scale", Type.GetType("System.Int32"));
                dt.Columns.Add("Precision", Type.GetType("System.Int32"));
                dt.Columns.Add("colid", Type.GetType("System.Int32"));
                dt.Columns.Add("CustomField", Type.GetType("System.Boolean"));
                {
                    oQuery = null;
                    try
                    {
                        oQuery = InlineQueryDBManager.Factory("stp_Zpro_" + sTABLE_NAME + "_Import");
                        if (oQuery == null)
                        {
                            throw new Exception();
                        }
                    }
                    catch
                    {
                        oQuery = InlineQueryDBManager.Factory("stp_Zpro_" + sTABLE_NAME + "_Update");
                    }
                    for (int i = 0; i < oQuery.Count; i++)
                    {
                        SqlParameter par = oQuery[i];
                        DataRow      row = dt.NewRow();
                        dt.Rows.Add(row);
                        row["ColumnName"]   = par.ParameterName;
                        row["NAME"]         = CommonTypeConvert.ExtractDbName(par.ParameterName);
                        row["DISPLAY_NAME"] = row["NAME"];
                        row["ColumnType"]   = par.DbType.ToString();
                        row["Size"]         = par.Size;
                        row["Scale"]        = par.Scale;
                        row["Precision"]    = par.Precision;
                        row["colid"]        = i;
                        row["CustomField"]  = false;
                    }


                    string sSQL;

                    if (Config.enable_team_management())
                    {
                        bool bModuleIsTeamed =
                            CommonTypeConvert.ToBoolean(
                                HttpContext.Current.Application["Modules." + sMODULE_NAME + ".Teamed"]);
                        DataRow row = dt.NewRow();
                        row = dt.NewRow();
                        row["ColumnName"]   = "@TEAM_NAME";
                        row["NAME"]         = "TEAM_NAME";
                        row["DISPLAY_NAME"] = "TEAM_NAME";
                        row["ColumnType"]   = "string";
                        row["Size"]         = 128;
                        row["colid"]        = dt.Rows.Count;
                        row["CustomField"]  = false;
                        dt.Rows.Add(row);
                    }

                    sSQL               = ApplicationSQL.SQL["_code_CRMCache_629"];
                    oQuery             = new InlineQueryDBManager();
                    oQuery.CommandText = sSQL;
                    oQuery.Add("@OBJECTNAME", SqlDbType.NVarChar, sTABLE_NAME + "_CSTM");
                    DataTable dtCSTM = oQuery.GetTable();
                    foreach (DataRow rowCSTM in dtCSTM.Rows)
                    {
                        DataRow row = dt.NewRow();
                        row["ColumnName"]   = CommonTypeConvert.ToString(rowCSTM["ColumnName"]);
                        row["NAME"]         = CommonTypeConvert.ToString(rowCSTM["ColumnName"]);
                        row["DISPLAY_NAME"] = CommonTypeConvert.ToString(rowCSTM["ColumnName"]);
                        row["ColumnType"]   = CommonTypeConvert.ToString(rowCSTM["CsType"]);
                        row["Size"]         = CommonTypeConvert.ToInteger(rowCSTM["length"]);

                        row["colid"]       = dt.Rows.Count;
                        row["CustomField"] = true;
                        dt.Rows.Add(row);
                    }

                    Cache.Insert("vwSqlColumns_Import." + sMODULE_NAME, dt, null, DefaultCacheExpiration(),
                                 Cache.NoSlidingExpiration);
                }
            }
            return(dt);

            //return new DataTable();
        }