Exemplo n.º 1
0
        public bool IsSetting(string subject, string name, int coupon)
        {
            IContextData context = Access <IContextData>();
            string       user    = string.Empty;

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

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

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

                        if (item.Subject.ToLower() == subject.ToLower() && item.Name.ToLower() == name.ToLower())
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 2
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.º 3
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);
        }