Exemplo n.º 1
0
        public string GetItemValue(ContextItem item, bool onlyChanges, int coupon)
        {
            IContextData context = Access <IContextData>();

            if (coupon == -1)
            {
                coupon = _ContextManager.MostRecentContextCoupon;
            }

            if (context != null)
            {
                Subject s    = new Subject(item.Subject);
                object  data = null;

                s.Items.Add(item);
                data = context.GetItemValues(s.ToItemNameArray(), onlyChanges, coupon);
                if (data != null && data.GetType() == typeof(object[]))
                {
                    object[] info = (object[])data;

                    if (info.Length == 2)
                    {
                        return(info[1].ToString());
                    }
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        public bool IsUserLoggedIn()
        {
            IContextData data        = Access <IContextData>();
            bool         currentUser = false;

            if (data != null)
            {
                object contextData = new string[] { "User.Id.Logon" };

                contextData = data.GetItemValues(contextData, false, -100);
            }
            return(currentUser);
        }
Exemplo n.º 3
0
        public string GetCurrentUser(string suffix)
        {
            IContextData context = Access <IContextData>();
            string       user    = string.Empty;

            if (context != null)
            {
                object data = context.GetItemNames(_ContextManager.MostRecentContextCoupon);

                if (data != null && data.GetType() == typeof(string[]) && ((string[])data).Length > 0)
                {
                    string[] names = (string[])data;

                    data = null;
                    foreach (string name in names)
                    {
                        ContextItem item = new ContextItem(name);

                        if (item.Suffix.ToLower() == suffix && item.Subject.ToLower() == "user" &&
                            item.Name.ToLower() == "logon" && item.Role.ToLower() == "id")
                        {
                            data = new string[] { item.ToString() };
                            break;
                        }
                    }

                    if (data != null)
                    {
                        data = context.GetItemValues(data, false, _ContextManager.MostRecentContextCoupon);
                        if (data != null && data.GetType() == typeof(object[]))
                        {
                            object[] values = (object[])data;

                            if (values.Length == 2)
                            {
                                user = values[1].ToString();
                            }
                        }
                    }
                }
            }
            return(user);
        }
Exemplo n.º 4
0
        public NameValueCollection GetCurrentContext()
        {
            NameValueCollection context = new NameValueCollection();
            IContextData        data    = Access <IContextData>();

            if (data != null && _ContextManager.MostRecentContextCoupon != 0)
            {
                object contextData = null;

                _MainForm.Log("=> GetItemNames({0})", _ContextManager.MostRecentContextCoupon);
                contextData = data.GetItemNames(_ContextManager.MostRecentContextCoupon);
                if (contextData.GetType() == typeof(string[]) && ((string[])contextData).Length > 0)
                {
                    string[] names = (string[])contextData;

                    _MainForm.Log("     Available Item Names");
                    foreach (string name in names)
                    {
                        _MainForm.Log("          " + name);
                    }

                    _MainForm.Log("=> GetItemValues([{0}],false,{1})", string.Join(",", names), _ContextManager.MostRecentContextCoupon);
                    contextData = data.GetItemValues(contextData, false, _ContextManager.MostRecentContextCoupon);
                    if (contextData.GetType() == typeof(object[]))
                    {
                        object[] values = (object[])contextData;

                        for (int i = 0; i < values.Length; i += 2)
                        {
                            context.Add(values[i].ToString(), values[i + 1].ToString());
                            _MainForm.Log("          {0} ({1})", values[i], values[i + 1].ToString());
                        }
                    }
                }
            }

            return(context);
        }