Esempio n. 1
0
        public Network(Core core, long networkId, NetworkLoadOptions loadOptions)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(Network_ItemLoad);

            bool containsInfoData = false;
            bool containsIconData = false;

            if (loadOptions == NetworkLoadOptions.Key)
            {
                try
                {
                    LoadItem(networkId);
                }
                catch (InvalidItemException)
                {
                    throw new InvalidNetworkException();
                }
            }
            else
            {
                SelectQuery query = new SelectQuery(Network.GetTable(typeof(Network)));
                query.AddFields(Network.GetFieldsPrefixed(core, typeof(Network)));
                query.AddCondition("`network_keys`.`network_id`", networkId);

                if ((loadOptions & NetworkLoadOptions.Info) == NetworkLoadOptions.Info)
                {
                    containsInfoData = true;

                    query.AddJoin(JoinTypes.Inner, NetworkInfo.GetTable(typeof(NetworkInfo)), "network_id", "network_id");
                    query.AddFields(NetworkInfo.GetFieldsPrefixed(core, typeof(NetworkInfo)));

                    if ((loadOptions & NetworkLoadOptions.Icon) == NetworkLoadOptions.Icon)
                    {
                        // TODO: Network Icon
                        /*containsIconData = true;

                        query.AddJoin(JoinTypes.Left, new DataField("network_info", "network_icon"), new DataField("gallery_items", "gallery_item_id"));
                        query.AddField(new DataField("gallery_items", "gallery_item_uri"));
                        query.AddField(new DataField("gallery_items", "gallery_item_parent_path"));*/
                    }
                }

                DataTable networkTable = db.Query(query);

                if (networkTable.Rows.Count > 0)
                {
                    loadItemInfo(typeof(Network), networkTable.Rows[0]);

                    if (containsInfoData)
                    {
                        networkInfo = new NetworkInfo(core, networkTable.Rows[0]);
                    }

                    if (containsIconData)
                    {
                        // TODO: Network Icon
                        //loadNetworkIcon(networkTable.Rows[0]);
                    }
                }
                else
                {
                    throw new InvalidNetworkException();
                }
            }
        }
Esempio n. 2
0
        public Network(Core core, DataRow networkRow, NetworkLoadOptions loadOptions)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(Network_ItemLoad);

            if (networkRow != null)
            {
                loadItemInfo(typeof(Network), networkRow);

                if ((loadOptions & NetworkLoadOptions.Info) == NetworkLoadOptions.Info)
                {
                    networkInfo = new NetworkInfo(core, networkRow);
                }

                if ((loadOptions & NetworkLoadOptions.Icon) == NetworkLoadOptions.Icon)
                {
                    // TODO: Network Icon
                    //loadUserGroupIcon(groupRow);
                }
            }
            else
            {
                throw new InvalidNetworkException();
            }
        }