Ejemplo n.º 1
0
        public static Dictionary <string, string> GetAllowedApps(User user)
        {
            DBConnect connection = new DBConnect();

            try
            {
                connection.Connect(ConnectionsMgr.GetOCConnInfo(user, _Database.Home));
                Dictionary <string, string> ret = new Dictionary <string, string>();

                using (var queryUserLevelAP = connection.Select(appFlags, _Table.UserInfo, string.Format("WHERE {0}='{1}' AND {2}='{3}' AND {4}='{5}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape(), _Column.UserName, user.UserName.SQLEscape())))
                {
                    while (queryUserLevelAP.Read())
                    {
                        for (int i = 0; i < appFlags.Length; i++)
                        {
                            string f = queryUserLevelAP.Field(i);
                            if (f == "1")
                            {
                                string name = columnToDetail[appFlags[i]].appName;
                                string url  = columnToDetail[appFlags[i]].appURL;
                                if (!ret.ContainsKey(name))
                                {
                                    ret.Add(name, url);
                                }
                            }
                        }
                    }
                    if (ret.Count > 0)
                    {
                        return(ret);
                    }
                }

                using (var queryCustPartAP = connection.Select(appFlags, _Table.NetGroup, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape())))
                {
                    while (queryCustPartAP.Read())
                    {
                        for (int i = 0; i < appFlags.Length; i++)
                        {
                            string f = queryCustPartAP.Field(i);
                            if (f == "1")
                            {
                                string name = columnToDetail[appFlags[i]].appName;
                                string url  = columnToDetail[appFlags[i]].appURL;
                                if (!ret.ContainsKey(name))
                                {
                                    ret.Add(name, url);
                                }
                            }
                        }
                    }
                    return(ret);
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(AppManagement), nameof(GetAllowedApps), e.Message);
                return(new Dictionary <string, string>());
            }
        }
Ejemplo n.º 2
0
        private static string _GetElemDesc(User user, string usEleNum, string usCode)
        {
            DBConnect connect = new DBConnect();

            try
            {
                connect.Connect(ConnectionsMgr.GetAdminConnInfo());
                var queryCodes = connect.Select(_Column.CodeDesc, _Table.DisaCode, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.EleNum, usEleNum.SQLEscape(), _Column.Code, usCode.SQLEscape()));
                if (queryCodes.Read())
                {
                    return(queryCodes.Field(0));
                }
                else
                {
                    return("");
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, "ElementLookup", "_GetElemDesc", e.Message);
                return("");
            }
        }
Ejemplo n.º 3
0
        public static bool IsAllowed(User user, AppID app)
        {
            try
            {
                if (user == null || app == AppID.None)
                {
                    return(false);
                }
                var connection = ConnectionsMgr.GetOCConnection(user);

                using (var queryUserLevelAP = connection.Select(idToColumn[app], _Table.UserInfo, string.Format("WHERE {0}='{1}' AND {2}='{3}' AND {4}='{5}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape(), _Column.UserName, user.UserName.SQLEscape())))
                {
                    if (queryUserLevelAP.AffectedRows != 0)
                    {
                        queryUserLevelAP.Read();
                        return(queryUserLevelAP.Field(0) != "0");
                    }
                }

                using (var queryCustPartAP = connection.Select(idToColumn[app], _Table.NetGroup, string.Format("WHERE {0}='{1}' AND {2}='{3}'", _Column.Customer, user.Customer.SQLEscape(), _Column.Partner, user.ActivePartner.SQLEscape())))
                {
                    if (queryCustPartAP.AffectedRows == 0)
                    {
                        ProgramLog.LogError(user, nameof(AppManagement), nameof(IsAllowed), string.Format("Error: No information found for customer {0} and partner {1}.", user.Customer, user.ActivePartner));
                        return(false);
                    }
                    queryCustPartAP.Read();
                    return(queryCustPartAP.Field(0) != "0");
                }
            }
            catch (Exception e)
            {
                ProgramLog.LogError(user, nameof(AppManagement), nameof(IsAllowed), e.Message);
                return(false);
            }
        }