Example #1
0
    public static UserSession FromContext( HttpSessionState session, bool failOnMissing )
    {
        if( session == null )
            throw new ArgumentNullException( "session" );

        UserSession mySession = session[ "UserSession" ] as UserSession;
        if( ( mySession == null ) &&
            ( failOnMissing == false ) )
        {
            mySession = new UserSession();
            session.Add( "UserSession", mySession );
        }
        return mySession;
    }
Example #2
0
 public static void SetString(this  HttpSessionState session, string key, string value)
 {
     session.Add(key, value);
 }
Example #3
0
 public void Add(object key, object value)
 {
     _session.Add((String)key, value);
 }
Example #4
0
 //极验服务器的gt-server状态值
 public void setGtServerStatusSession(HttpSessionState session, int statusCode)
 {
     session.Add(GeetestLib.gtServerStatusSessionKey, statusCode);
 }
 public void Add(object key, object value)
 {
     _sessionState.Add((string)key, value);
 }
 public override void Add(string name, object value)
 {
     _session.Add(name, value);
 }
Example #7
0
 //将当前实例设置到session中
 public void setGtSession(HttpSessionState session)
 {
     session.Add(GeetestLib.gtSessionKey, this);
 }
Example #8
0
        public void AddSession(string name, object value)
        {
            HttpSessionState state = this.HttpContext.Items["AspSession"] as HttpSessionState;

            state.Add(name, value);
        }
Example #9
0
 /// <summary>
 /// 设置session
 /// </summary>
 /// <param name="name">session名</param>
 /// <param name="value">session值</param>
 public static void SetSession(string name, object value)
 {
     _session.Remove(name);
     _session.Add(name, value);
 }
Example #10
0
        /// <summary>
        /// Загрузить схему
        /// </summary>
        public bool LoadScheme(string clientID, int viewSetIndex, int viewIndex, out SchemeView.SchemeData schemeData)
        {
            bool result = false;

            schemeData = null;
            SchemeApp schemeApp = SchemeApp.GetSchemeApp();

            if (schemeApp.WorkMode == SchemeApp.WorkModes.Edit)
            {
                // загрузка схемы для SCADA-Редактора схем
                EditorData editorData = schemeApp.EditorData;
                SchemeView schemeView = null;

                if (editorData.ClientID == clientID)
                {
                    schemeView = editorData.SchemeView;
                }
                else
                {
                    editorData.ClientID = clientID;
                }

                if (schemeView == null)
                {
                    string errMsg;
                    if (editorData.LoadSchemeFromFile(out errMsg))
                    {
                        schemeView = editorData.SchemeView;
                    }
                    else
                    {
                        schemeApp.Log.WriteAction(errMsg, Log.ActTypes.Exception);
                    }
                }

                if (schemeView != null)
                {
                    schemeData         = new SchemeView.SchemeData(schemeView);
                    schemeData.CnlList = null;
                    result             = true;
                }
            }
            else
            {
                // загрузка схемы для SCADA-Web
                UserData    userData = UserData.GetUserData();
                HttpContext context  = HttpContext.Current;

                if (userData.LoggedOn)
                {
                    BaseView       baseView;
                    MainData.Right right;
                    bool           ok         = userData.GetView(typeof(SchemeView), viewSetIndex, viewIndex, out baseView, out right);
                    SchemeView     schemeView = baseView as SchemeView;

                    if (ok && schemeView != null && right.ViewRight)
                    {
                        schemeApp.Log.WriteAction(string.Format(Localization.UseRussian ?
                                                                "Загружена схема {0} пользователем {1}" : "Scheme {0} has been loaded by user {1}",
                                                                schemeView.Path, userData.UserLogin), Log.ActTypes.Action);

                        // сохранение списка входных каналов схемы в сессии
                        HttpSessionState session = context == null ? null : context.Session;
                        if (session != null && clientID != null)
                        {
                            Dictionary <string, object> schemeClients =
                                session["ScadaSchemeClients"] as Dictionary <string, object>;
                            if (schemeClients == null)
                            {
                                schemeClients = new Dictionary <string, object>();
                                session.Add("ScadaSchemeClients", schemeClients);
                            }
                            schemeClients[clientID] = schemeView.CnlList;
                        }

                        // получение данных схемы
                        schemeData           = new SchemeView.SchemeData(schemeView);
                        schemeData.CtrlRight = right.CtrlRight;
                        result = true;
                    }
                    else
                    {
                        string itfObjName = schemeView == null || string.IsNullOrEmpty(schemeView.Path) ?
                                            "" : " " + schemeView.Path;
                        schemeApp.Log.WriteAction(string.Format(Localization.UseRussian ?
                                                                "Не удалось загрузить схему{0} пользователем {1}" : "Unable to load scheme{0} by user {1}",
                                                                itfObjName, userData.UserLogin), Log.ActTypes.Error);
                    }
                }
                else
                {
                    HttpRequest request = context == null ? null : context.Request;
                    string      host    = request == null ? "" :
                                          (Localization.UseRussian ? ". Хост: " : ". Host: ") + request.UserHostAddress;
                    schemeApp.Log.WriteAction((Localization.UseRussian ?
                                               "Невозможно загрузить схему, т.к. пользователь не вошёл в систему" :
                                               "Unable to load scheme because user is not logged on") + host, Log.ActTypes.Error);
                }
            }

            return(result);
        }
Example #11
0
 public void Add(string name, object value)
 {
     sessionState.Add(name, value);
 }
Example #12
0
        public static void IniciarSesion(string username)
        {
            HttpSessionState session = HttpContext.Current.Session;

            session.Add("USERNAME", username);
        }