internal SoundEnvelope(BaseChannel channel)
 {
     _channel = channel;
 }
        private void CommonShims()
        {
            ShimECNSession.Constructor = instance => { };
            var session = CreateInstance <ECNSession>();

            _currentUser = new User
            {
                IsActive             = true,
                UserID               = GetNumber(),
                CustomerID           = GetNumber(),
                CurrentSecurityGroup = new SecurityGroup
                {
                    AdministrativeLevel = SecurityGroupAdministrativeLevel.ChannelAdministrator,
                    IsActive            = true
                },
                IsPlatformAdministrator = true
            };
            _currentBaseChannel = new BaseChannel
            {
                BaseChannelID = GetNumber()
            };
            _currentCustomer = new Customer
            {
                BaseChannelID = _currentBaseChannel.BaseChannelID,
                CustomerID    = _currentUser.CustomerID
            };
            session.CurrentUser        = _currentUser;
            session.CurrentBaseChannel = _currentBaseChannel;
            session.CurrentCustomer    = _currentCustomer;
            ShimOmnitureBaseChannelSetup.AllInstances.MasterGet = instance =>
            {
                return(new ShimCommunicator
                {
                    UserSessionGet = () => session
                });
            };
            ShimECNSession.CurrentSession       = () => session;
            ShimPage.AllInstances.IsPostBackGet = instance => false;
            ShimLinkTrackingSettings.GetByBaseChannelID_LTIDInt32Int32 = (baseChannelId, linkTrackingId) =>
            {
                return(new LinkTrackingSettings
                {
                    XMLConfig = CreateLinkTrackingSettingsXmlConfig(_xmlQueryString, _xmlDelimiter,
                                                                    _xmlAllowCustomrOverride)
                });
            };
            ShimCustomer.HasProductFeatureInt32EnumsServicesEnumsServiceFeatures =
                (customerId, serviceCode, featureCode) => true;
            ShimLinkTrackingParam.GetByLinkTrackingIDInt32 = (id) =>
            {
                if (_linkTrackingParamGetByLinkTrackingIDException != null)
                {
                    throw _linkTrackingParamGetByLinkTrackingIDException;
                }
                return(Enumerable.Range(1, 10)
                       .Select(i => new LinkTrackingParam
                {
                    DisplayName = $"omniture{i}",
                    LTID = i,
                    IsActive = true,
                    LTPID = i
                }).ToList());
            };
            ShimLinkTrackingParamSettings.Get_LTPID_BaseChannelIDInt32Int32 = (lptId, baseChannelId) =>
            {
                return(new LinkTrackingParamSettings
                {
                    DisplayName = $"omniture{lptId}",
                    IsRequired = true,
                    IsDeleted = true,
                    AllowCustom = true,
                });
            };
            ShimLinkTrackingParamOption.Get_LTPID_BaseChannelIDInt32Int32 = (lptId, baseChannelId) =>
            {
                return(new List <LinkTrackingParamOption>
                {
                    new LinkTrackingParamOption
                    {
                        IsActive = true,
                        IsDeleted = false,
                        IsDefault = true,
                        IsDynamic = true,
                        LTPOID = 1,
                        LTPID = 1,
                        BaseChannelID = 1,
                        DisplayName = $"omniture{lptId}"
                    }
                });
            };
        }
示例#3
0
    void InitComponents()
    {
        uiPanel = GameObject.Find("SendBirdUnity/UIPanel");
        (Instantiate(uiThemePrefab) as GameObject).transform.parent = uiPanel.transform;

        editPopup = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditPopup");
        editPopup.gameObject.SetActive(false);

        uiTheme = GameObject.FindObjectOfType(typeof(SendBirdTheme)) as SendBirdTheme;

        #region MenuPanel

        menuPanel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel");
        menuPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG;

        var txtMenuTitle = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/TxtTitle").GetComponent <Text>();
        txtMenuTitle.color = uiTheme.titleColor;

        btnConnect = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnConnect").GetComponent <Button>();
        btnConnect.GetComponent <Image>().sprite = uiTheme.sendButton;
        btnConnect.GetComponent <Image>().type   = Image.Type.Sliced;
        btnConnect.onClick.AddListener(() => {
            nickname = inputUserName.text;
            userId   = nickname;           // Please assign user's unique id.

            if (nickname == null || nickname.Length <= 0)
            {
                return;
            }

            btnConnect.gameObject.SetActive(false);

            btnOpenChannelList.gameObject.SetActive(true);
            btnStartGroupChannel.gameObject.SetActive(true);
            btnGroupChannelList.gameObject.SetActive(true);

            SendBirdClient.Connect(userId, (user, e) => {              //
                if (e != null)
                {
                    Debug.Log(e.Code + ": " + e.Message);
                    return;
                }

                SendBirdClient.UpdateCurrentUserInfo(nickname, null, (e1) => {
                    if (e1 != null)
                    {
                        Debug.Log(e.Code + ": " + e.Message);
                        return;
                    }
                });
            });
        });


        btnOpenChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnOpenChannel").GetComponent <Button>();
        btnOpenChannelList.GetComponent <Image>().sprite = uiTheme.sendButton;
        btnOpenChannelList.GetComponent <Image>().type   = Image.Type.Sliced;
        btnOpenChannelList.onClick.AddListener(() => {
            menuPanel.SetActive(false);
            OpenOpenChannelList();
        });

        btnStartGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnStartGroupChannel").GetComponent <Button>();
        btnStartGroupChannel.GetComponent <Image>().sprite = uiTheme.sendButton;
        btnStartGroupChannel.GetComponent <Image>().type   = Image.Type.Sliced;
        btnStartGroupChannel.onClick.AddListener(() => {
            menuPanel.SetActive(false);

            OpenUserList();
        });

        btnGroupChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnGroupChannel").GetComponent <Button>();
        btnGroupChannelList.GetComponent <Image>().sprite = uiTheme.sendButton;
        btnGroupChannelList.GetComponent <Image>().type   = Image.Type.Sliced;
        btnGroupChannelList.onClick.AddListener(() => {
            menuPanel.SetActive(false);

            OpenGroupChannelList();
        });

        inputUserName = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/InputUserName").GetComponent <InputField>();
        inputUserName.GetComponent <Image>().sprite = uiTheme.inputTextBG;

        #endregion

        #region OpenChannel

        openChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel");
        openChannelPanel.GetComponent <Image>().sprite = uiTheme.chatFrameBG;

        txtOpenChannelContent       = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/ScrollArea/TxtContent").GetComponent <Text>();  // (Text);
        txtOpenChannelContent.color = uiTheme.messageColor;

        txtOpenChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/TxtTitle").GetComponent <Text>();
        txtOpenChannelTitle.color = uiTheme.titleColor;

        openChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/Scrollbar").GetComponent <Scrollbar>();

        ColorBlock cb = openChannelScrollbar.colors;
        cb.normalColor              = uiTheme.scrollBarColor;
        cb.pressedColor             = uiTheme.scrollBarColor;
        cb.highlightedColor         = uiTheme.scrollBarColor;
        openChannelScrollbar.colors = cb;
        openChannelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                autoScroll        = true;
                lastTextPositionY = txtOpenChannelContent.transform.position.y;
                return;
            }

            if (lastTextPositionY - txtOpenChannelContent.transform.position.y >= 100)
            {
                autoScroll = false;
            }

            lastTextPositionY = txtOpenChannelContent.transform.position.y;
        });

        inputOpenChannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel").GetComponent <InputField>();
        inputOpenChannel.GetComponent <Image>().sprite = uiTheme.inputTextBG;
        inputOpenChannel.onEndEdit.AddListener((string msg) => {
            SubmitOpenChannel();
        });

        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Placeholder").GetComponent <Text>().color = uiTheme.inputTextPlaceholderColor;
        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Text").GetComponent <Text>().color        = uiTheme.inputTextColor;

        btnOpenChannelSend = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelSend").GetComponent <Button>();
        btnOpenChannelSend.GetComponent <Image>().sprite         = uiTheme.sendButton;
        btnOpenChannelSend.GetComponentInChildren <Text>().color = uiTheme.sendButtonColor;
        btnOpenChannelSend.onClick.AddListener(() => {
            SubmitOpenChannel();
        });

        btnOpenChannelClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelClose").GetComponent <Button>();
        btnOpenChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton;
        btnOpenChannelClose.onClick.AddListener(() => {
            openChannelPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        #endregion

        #region ChannelList

        openChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel");
        openChannelListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG;

        channelGridPannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor;

        var channelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/Scrollbar").GetComponent <Scrollbar>();
        cb                      = channelScrollbar.colors;
        cb.normalColor          = uiTheme.scrollBarColor;
        cb.pressedColor         = uiTheme.scrollBarColor;
        cb.highlightedColor     = uiTheme.scrollBarColor;
        channelScrollbar.colors = cb;

        channelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadOpenChannels();
            }
        });

        btnOpenChannelListClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/BtnOpenChannelListClose").GetComponent <Button>();
        btnOpenChannelListClose.GetComponent <Image>().sprite = uiTheme.closeButton;
        btnOpenChannelListClose.onClick.AddListener(() => {
            openChannelListPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        #endregion

        #region GroupChannel

        groupChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel");
        groupChannelPanel.GetComponent <Image>().sprite = uiTheme.chatFrameBG;

        txtGroupChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text>();
        txtGroupChannelTitle.color = uiTheme.titleColor;

        groupScrollArea    = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea");
        editableScrollArea = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea");
        editableGridPannel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/GridPanel");

        btnGroupChannelLeave = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelLeave").GetComponent <Button>();
        btnGroupChannelLeave.GetComponent <Image>().sprite = uiTheme.channelButtonOff;
        btnGroupChannelLeave.onClick.AddListener(() => {
            groupChannelPanel.SetActive(false);
            menuPanel.SetActive(true);

            foreach (UnityEngine.Object obj in btnMessage)
            {
                GameObject.Destroy(obj);
            }
            btnMessage.Clear();

            string channelUrl = currentChannel.Url;
            GroupChannel.GetChannel(channelUrl, new GroupChannel.GroupChannelGetHandler((GroupChannel groupChannel1, SendBirdException e1) =>
            {
                try
                {
                    if (e1 != null)
                    {
                    }

                    groupChannel1.Leave(new GroupChannel.GroupChannelLeaveHandler((SendBirdException e2) =>
                    {
                    }));
                    // When you delete a Group Channel you no longer use
                    if (groupChannel1.Members.Count == 0)
                    {
                        groupChannel1.DeleteChannel(channelUrl, new GroupChannel.GroupChannelLeaveHandler((SendBirdException e3) =>
                        {
                        }));
                    }
                }
                catch (Exception z)
                {
                    Debug.Log(z);
                }
            }));
        });

        btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelClose").GetComponent <Button>();
        btnGroupChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton;
        btnGroupChannelClose.onClick.AddListener(() => {
            groupChannelPanel.SetActive(false);
            menuPanel.SetActive(true);

            // sskim add
            string channelUrl = currentChannel.Url;
            GroupChannel.GetChannel(channelUrl, new GroupChannel.GroupChannelGetHandler((GroupChannel groupChannel1, SendBirdException e1) =>
            {
                try
                {
                    if (e1 != null)
                    {
                    }
                    groupChannelListPanel.SetActive(false);
                }
                catch (Exception z)
                {
                    Debug.Log(z);
                }
            }));
        });

        txtGroupChannelContent       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/TxtContent").GetComponent <Text>();  // (Text);
        txtGroupChannelContent.color = uiTheme.messageColor;

        //txtGroupChannelContent2 = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/GridPanel/PrevChatListItem/TxtContent").GetComponent<Text>(); // (Text);
        //txtGroupChannelContent2.color = uiTheme.messageColor;

        txtGroupChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text>();
        txtGroupChannelTitle.color = uiTheme.titleColor;

        groupChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/Scrollbar").GetComponent <Scrollbar>();
        ColorBlock cb_groupChannel = groupChannelScrollbar.colors;
        cb_groupChannel.normalColor      = uiTheme.scrollBarColor;
        cb_groupChannel.pressedColor     = uiTheme.scrollBarColor;
        cb_groupChannel.highlightedColor = uiTheme.scrollBarColor;
        groupChannelScrollbar.colors     = cb_groupChannel;
        groupChannelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                autoScroll        = true;
                lastTextPositionY = txtGroupChannelContent.transform.position.y;
                return;
            }

            if (lastTextPositionY - txtGroupChannelContent.transform.position.y >= 30)
            {
                autoScroll = false;
            }

            lastTextPositionY = txtGroupChannelContent.transform.position.y;
        });

        inputGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel").GetComponent <InputField>();
        inputGroupChannel.GetComponent <Image>().sprite = uiTheme.inputTextBG;
        inputGroupChannel.onEndEdit.AddListener((string msg) => {
            SubmitGroupChannel();
        });

        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Placeholder").GetComponent <Text>().color = uiTheme.inputTextPlaceholderColor;
        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Text").GetComponent <Text>().color        = uiTheme.inputTextColor;

        btnGroupChannelSend = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelSend").GetComponent <Button>();
        btnGroupChannelSend.GetComponent <Image>().sprite         = uiTheme.sendButton;
        btnGroupChannelSend.GetComponentInChildren <Text>().color = uiTheme.sendButtonColor;
        btnGroupChannelSend.onClick.AddListener(() => {
            SubmitGroupChannel();
        });

        groupChannelScrollbar2 = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/EditableScrollArea/Scrollbar2").GetComponent <Scrollbar>();
        cb                            = groupChannelScrollbar2.colors;
        cb.normalColor                = uiTheme.scrollBarColor;
        cb.pressedColor               = uiTheme.scrollBarColor;
        cb.highlightedColor           = uiTheme.scrollBarColor;
        groupChannelScrollbar2.colors = cb;
        groupChannelScrollbar2.onValueChanged.AddListener((float value) => {
            if (btnMessage.Count > 0)
            {
                if (value <= 0)
                {
                    autoScroll        = true;
                    lastTextPositionY = ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y;
                    return;
                }

                if (lastTextPositionY - ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y >= 30)
                {
                    autoScroll = false;
                }

                lastTextPositionY = ((GameObject)btnMessage[btnMessage.Count - 1]).transform.position.y;
            }
        });

        #endregion

        #region UserList

        userListPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel");
        userListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG;

        userListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor;

        var userListScrollBar = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/Scrollbar").GetComponent <Scrollbar>();
        cb                       = userListScrollBar.colors;
        cb.normalColor           = uiTheme.scrollBarColor;
        cb.pressedColor          = uiTheme.scrollBarColor;
        cb.highlightedColor      = uiTheme.scrollBarColor;
        userListScrollBar.colors = cb;
        userListScrollBar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadUsers();
            }
        });

        btnUserListClose = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnUserListClose").GetComponent <Button>();
        btnUserListClose.GetComponent <Image>().sprite = uiTheme.closeButton;
        btnUserListClose.onClick.AddListener(() => {
            userListPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        btnInvite = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnInvite").GetComponent <Button>();
        btnInvite.GetComponent <Image>().sprite = uiTheme.sendButton;
        btnInvite.onClick.AddListener(() => {
            if (mUserList.Count <= 0)
            {
                Debug.Log("Please select one or more.");
                return;
            }

            GroupChannel.CreateChannelWithUserIds(mUserList, false, (channel, e) => {
                if (e != null)
                {
                    Debug.Log(e.Code + ": " + e.Message);
                    return;
                }

                userListPanel.SetActive(false);

                editableScrollArea.SetActive(true);
                groupScrollArea.SetActive(false);

                groupChannelPanel.SetActive(true);
                currentChannel = channel;
                ResetGroupChannelContent();
                txtGroupChannelTitle.text = channel.Name + ":" + GetDisplayMemberNames(channel.Members);
            });
        });

        #endregion

        #region GroupChannelList

        groupChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel");
        groupChannelListPanel.GetComponent <Image>().sprite = uiTheme.channelListFrameBG;

        groupChannelListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/TxtTitle").GetComponent <Text>().color = uiTheme.titleColor;

        var groupChannelListScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/Scrollbar").GetComponent <Scrollbar>();
        cb                  = groupChannelListScrollbar.colors;
        cb.normalColor      = uiTheme.scrollBarColor;
        cb.pressedColor     = uiTheme.scrollBarColor;
        cb.highlightedColor = uiTheme.scrollBarColor;
        groupChannelListScrollbar.colors = cb;
        groupChannelListScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadGroupChannels();
            }
        });

        btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/BtnGroupChannelListClose").GetComponent <Button>();
        btnGroupChannelClose.GetComponent <Image>().sprite = uiTheme.closeButton;
        btnGroupChannelClose.onClick.AddListener(() => {
            groupChannelListPanel.SetActive(false);
            if (!groupChannelListPanel.activeSelf)
            {
                menuPanel.SetActive(true);
            }
        });

        #endregion

        uiPanel.SetActive(true);
        menuPanel.SetActive(true);
        openChannelListPanel.SetActive(false);
        openChannelPanel.SetActive(false);
        groupChannelPanel.SetActive(false);
        userListPanel.SetActive(false);
        groupChannelListPanel.SetActive(false);
    }
        public void SetMessagesVisibility(BaseChannel channel, Visibility visibility)
        {
            GridView gridView = ((GridView)(presentationElements[channel].controls[PresentationElement.ControlKeys.MessagesGridView]));

            gridView.Visibility = visibility;
        }
示例#5
0
        public bool WriteChannel(BaseChannel bc)
        {
            bool ret = C4dApiPINVOKE.HyperFile_WriteChannel(swigCPtr, BaseChannel.getCPtr(bc));

            return(ret);
        }
示例#6
0
文件: RfidManager.cs 项目: renyh/dp2
        public static NormalResult GetState(string style)
        {
            try
            {
                // 因为 GetState 是可有可无的请求,如果 Url 为空就算了
                if (string.IsNullOrEmpty(Base.Url))
                {
                    return(new NormalResult());
                }

                BaseChannel <IRfid> channel = null;
                bool old_checkState         = _checkState;
                _checkState = false;
                try
                {
                    channel = Base.GetChannel();
                }
                finally
                {
                    _checkState = old_checkState;
                }

                try
                {
                    var result = channel.Object.GetState(style);
                    if (result.Value == -1)
                    {
                        Base.TriggerSetError(result,
                                             new SetErrorEventArgs {
                            Error = result.ErrorInfo
                        });
                    }
                    else
                    {
                        Base.TriggerSetError(result,
                                             new SetErrorEventArgs {
                            Error = null
                        });                                          // 清除以前的报错
                    }
                    return(result);
                }
                finally
                {
                    Base.ReturnChannel(channel);
                }
            }
            catch (Exception ex)
            {
                Base.TriggerSetError(ex,
                                     new SetErrorEventArgs
                {
                    Error = $"RFID 中心出现异常: {ExceptionUtil.GetAutoText(ex)}"
                });
                return(new NormalResult
                {
                    Value = -1,
                    ErrorInfo = ex.Message,
                    ErrorCode = NotResponseException.GetErrorCode(ex)
                });
            }
        }
示例#7
0
        // 크롤러 생성
        bool MakeCrawler(CHANNEL channel)
        {
            bool bResult = true;

            if (BaseChannel_ != null)
            {
                return(true);
            }

            switch (channel)
            {
            case CHANNEL.COUPANG:     // 쿠팡
            {
                BaseChannel_ = new Coupang();
            }
            break;

            case CHANNEL.TIKET_MONSTER:     // 티몬
            {
                BaseChannel_ = new TicketMonster();
            }
            break;

            case CHANNEL.WEMAPE:     // 위메프
            {
                BaseChannel_ = new WeMakePrice();
            }
            break;

            case CHANNEL.EZWELL:     // ezwell
            {
                BaseChannel_ = new EzWell();
            }
            break;

            case CHANNEL.AUCTION:     // 옥션
            {
                BaseChannel_ = new eBay_Auction();
            }
            break;

            case CHANNEL.G9:        // 지마켓/지구
            {
                BaseChannel_ = new eBay_G9();
            }
            break;

            case CHANNEL.CJOCLOCK:        // CJ 오클락
            {
                BaseChannel_ = new CJOClock();
            }
            break;

            case CHANNEL.GOODBYESELLY:     //굿바이셀리
            {
                BaseChannel_ = new GoodByeSelly();
            }
            break;

            case CHANNEL.ETBS:     //이제너두
            {
                bResult = false;
            }
            break;

            case CHANNEL.ONEDAYMOM:     //원데이맘
            {
                BaseChannel_ = new OneDayMom();
            }
            break;

            case CHANNEL.STREET_11:     //11번가
            {
                BaseChannel_ = new Street11();
            }
            break;

            case CHANNEL.GSSHOP:     //gs샵
            {
                //BaseChannel_ = new GS_Shop();
                BaseChannel_ = new GSShop();
            }
            break;

            case CHANNEL.LG:     //:LG
            {
                BaseChannel_ = new LG();
            }
            break;

            case CHANNEL.MOMSCHOOL:     //:MOMSCHOOL
            {
                BaseChannel_ = new MomSchool();
            }
            break;

            case CHANNEL.SALESTONIGHT:     //:세일즈투나잇
            {
                BaseChannel_ = new SaleToNight();
            }
            break;

            case CHANNEL.TICKETSUDA:     //:티켓수다
            {
                BaseChannel_ = new TicketSuDa();
            }
            break;

            case CHANNEL.MOMSTODAY:     //:맘스투데이
            {
                BaseChannel_ = new moms2Day();
            }
            break;

            case CHANNEL.WEEKON:      //위크온
            {
                BaseChannel_ = new WeekOn();
            }
            break;

            default:
                bResult = false;
                break;
            }

            return(bResult);
        }
示例#8
0
	void InitComponents ()
	{
		uiPanel = GameObject.Find ("SendBirdUnity/UIPanel");
		(Instantiate (uiThemePrefab) as GameObject).transform.parent = uiPanel.transform;

		uiTheme = GameObject.FindObjectOfType (typeof(SendBirdTheme)) as SendBirdTheme;

		#region MenuPanel

		menuPanel = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel");
		menuPanel.GetComponent<Image> ().sprite = uiTheme.channelListFrameBG;

		var txtMenuTitle = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/TxtTitle").GetComponent<Text> ();
		txtMenuTitle.color = uiTheme.titleColor;

		btnConnect = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/BtnConnect").GetComponent<Button> ();
		btnConnect.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnConnect.GetComponent<Image> ().type = Image.Type.Sliced;
		btnConnect.onClick.AddListener (() => {
			nickname = inputUserName.text;
			userId = nickname; // Assign user's unique id.

			if (nickname == null || nickname.Length <= 0) {
				return;
			}

			SendBirdClient.Connect (userId, (user, e) => {
				if (e != null) {
					Debug.Log (e.Code + ": " + e.Message);
					return;
				}


				btnConnect.gameObject.SetActive (false);

				btnOpenChannelList.gameObject.SetActive (true);
				btnStartGroupChannel.gameObject.SetActive (true);
				btnGroupChannelList.gameObject.SetActive (true);

				SendBirdClient.UpdateCurrentUserInfo (nickname, null, (e1) => {
					if (e1 != null) {
						Debug.Log (e.Code + ": " + e.Message);
						return;
					}

				});
			});
		});


		btnOpenChannelList = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/BtnOpenChannel").GetComponent<Button> ();
		btnOpenChannelList.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnOpenChannelList.GetComponent<Image> ().type = Image.Type.Sliced;
		btnOpenChannelList.onClick.AddListener (() => {
			menuPanel.SetActive (false);
			OpenOpenChannelList ();
		});

		btnStartGroupChannel = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/BtnStartGroupChannel").GetComponent<Button> ();
		btnStartGroupChannel.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnStartGroupChannel.GetComponent<Image> ().type = Image.Type.Sliced;
		btnStartGroupChannel.onClick.AddListener (() => {
			menuPanel.SetActive (false);

			OpenUserList ();
		});

		btnGroupChannelList = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/BtnGroupChannel").GetComponent<Button> ();
		btnGroupChannelList.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnGroupChannelList.GetComponent<Image> ().type = Image.Type.Sliced;
		btnGroupChannelList.onClick.AddListener (() => {
			menuPanel.SetActive (false);

			OpenGroupChannelList ();
		});

		inputUserName = GameObject.Find ("SendBirdUnity/UIPanel/MenuPanel/InputUserName").GetComponent<InputField> ();
		inputUserName.GetComponent<Image> ().sprite = uiTheme.inputTextBG;

		#endregion

		#region OpenChannel

		openChannelPanel = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel");
		openChannelPanel.GetComponent<Image> ().sprite = uiTheme.chatFrameBG;

		txtOpenChannelContent = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/ScrollArea/TxtContent").GetComponent<Text> (); // (Text);
		txtOpenChannelContent.color = uiTheme.messageColor;

		txtOpenChannelTitle = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/TxtTitle").GetComponent<Text> ();
		txtOpenChannelTitle.color = uiTheme.titleColor;

		openChannelScrollbar = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/Scrollbar").GetComponent<Scrollbar> ();

		ColorBlock cb = openChannelScrollbar.colors;
		cb.normalColor = uiTheme.scrollBarColor;
		cb.pressedColor = uiTheme.scrollBarColor;
		cb.highlightedColor = uiTheme.scrollBarColor;
		openChannelScrollbar.colors = cb;
		openChannelScrollbar.onValueChanged.AddListener ((float value) => {
			if (value <= 0) {
				autoScroll = true;
				lastTextPositionY = txtOpenChannelContent.transform.position.y;
				return;
			}

			if (lastTextPositionY - txtOpenChannelContent.transform.position.y >= 100) {
				autoScroll = false;
			}

			lastTextPositionY = txtOpenChannelContent.transform.position.y;
		});

		inputOpenChannel = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel").GetComponent<InputField> ();
		inputOpenChannel.GetComponent<Image> ().sprite = uiTheme.inputTextBG;
		inputOpenChannel.onEndEdit.AddListener ((string msg) => {
			SubmitOpenChannel ();
		});

		GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Placeholder").GetComponent<Text> ().color = uiTheme.inputTextPlaceholderColor;
		GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Text").GetComponent<Text> ().color = uiTheme.inputTextColor;

		btnOpenChannelSend = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelSend").GetComponent<Button> ();
		btnOpenChannelSend.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnOpenChannelSend.GetComponentInChildren<Text> ().color = uiTheme.sendButtonColor;
		btnOpenChannelSend.onClick.AddListener (() => {
			SubmitOpenChannel ();
		});

		btnOpenChannelClose = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelClose").GetComponent<Button> ();
		btnOpenChannelClose.GetComponent<Image> ().sprite = uiTheme.closeButton;
		btnOpenChannelClose.onClick.AddListener (() => {
			openChannelPanel.SetActive (false);
			menuPanel.SetActive (true);
		});

		#endregion

		#region ChannelList

		openChannelListPanel = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelListPanel");
		openChannelListPanel.GetComponent<Image> ().sprite = uiTheme.channelListFrameBG;

		channelGridPannel = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelListPanel/ScrollArea/GridPanel");

		GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelListPanel/TxtTitle").GetComponent<Text> ().color = uiTheme.titleColor;

		var channelScrollbar = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelListPanel/Scrollbar").GetComponent<Scrollbar> ();
		cb = channelScrollbar.colors;
		cb.normalColor = uiTheme.scrollBarColor;
		cb.pressedColor = uiTheme.scrollBarColor;
		cb.highlightedColor = uiTheme.scrollBarColor;
		channelScrollbar.colors = cb;

		channelScrollbar.onValueChanged.AddListener ((float value) => {
			if (value <= 0) {
				LoadOpenChannels ();
			}
		});

		btnOpenChannelListClose = GameObject.Find ("SendBirdUnity/UIPanel/OpenChannelListPanel/BtnOpenChannelListClose").GetComponent<Button> ();
		btnOpenChannelListClose.GetComponent<Image> ().sprite = uiTheme.closeButton;
		btnOpenChannelListClose.onClick.AddListener (() => {
			openChannelListPanel.SetActive (false);
			menuPanel.SetActive(true);
		});

		#endregion

		#region GroupChannel

		groupChannelPanel = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel");
		groupChannelPanel.GetComponent<Image> ().sprite = uiTheme.chatFrameBG;

		txtGroupChannelTitle = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent<Text> ();
		txtGroupChannelTitle.color = uiTheme.titleColor;

		btnGroupChannelClose = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelClose").GetComponent<Button> ();
		btnGroupChannelClose.GetComponent<Image> ().sprite = uiTheme.closeButton;
		btnGroupChannelClose.onClick.AddListener (() => {
			groupChannelPanel.SetActive (false);
			menuPanel.SetActive (true);
		});

		txtGroupChannelContent = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/TxtContent").GetComponent<Text> (); // (Text);
		txtGroupChannelContent.color = uiTheme.messageColor;

		txtGroupChannelTitle = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent<Text> ();
		txtGroupChannelTitle.color = uiTheme.titleColor;

		groupChannelScrollbar = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/Scrollbar").GetComponent<Scrollbar> ();
		ColorBlock cb_groupChannel = groupChannelScrollbar.colors;
		cb_groupChannel.normalColor = uiTheme.scrollBarColor;
		cb_groupChannel.pressedColor = uiTheme.scrollBarColor;
		cb_groupChannel.highlightedColor = uiTheme.scrollBarColor;
		groupChannelScrollbar.colors = cb_groupChannel;
		groupChannelScrollbar.onValueChanged.AddListener ((float value) => {
			if (value <= 0) {
				autoScroll = true;
				lastTextPositionY = txtGroupChannelContent.transform.position.y;
				return;
			}

			if (lastTextPositionY - txtGroupChannelContent.transform.position.y >= 100) {
				autoScroll = false;
			}

			lastTextPositionY = txtGroupChannelContent.transform.position.y;
		});

		inputGroupChannel = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel").GetComponent<InputField> ();
		inputGroupChannel.GetComponent<Image> ().sprite = uiTheme.inputTextBG;
		inputGroupChannel.onEndEdit.AddListener ((string msg) => {
			SubmitGroupChannel ();
		});

		GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Placeholder").GetComponent<Text> ().color = uiTheme.inputTextPlaceholderColor;
		GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Text").GetComponent<Text> ().color = uiTheme.inputTextColor;

		btnGroupChannelSend = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelSend").GetComponent<Button> ();
		btnGroupChannelSend.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnGroupChannelSend.GetComponentInChildren<Text> ().color = uiTheme.sendButtonColor;
		btnGroupChannelSend.onClick.AddListener (() => {
			SubmitGroupChannel ();
		});

		#endregion

		#region UserList

		userListPanel = GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel");
		userListPanel.GetComponent<Image> ().sprite = uiTheme.channelListFrameBG;

		userListGridPanel = GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel/ScrollArea/GridPanel");

		GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel/TxtTitle").GetComponent<Text> ().color = uiTheme.titleColor;

		var userListScrollBar = GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel/Scrollbar").GetComponent<Scrollbar> ();
		cb = userListScrollBar.colors;
		cb.normalColor = uiTheme.scrollBarColor;
		cb.pressedColor = uiTheme.scrollBarColor;
		cb.highlightedColor = uiTheme.scrollBarColor;
		userListScrollBar.colors = cb;
		userListScrollBar.onValueChanged.AddListener ((float value) => {
			if (value <= 0) {
				LoadUsers ();
			}
		});

		btnUserListClose = GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel/BtnUserListClose").GetComponent<Button> ();
		btnUserListClose.GetComponent<Image> ().sprite = uiTheme.closeButton;
		btnUserListClose.onClick.AddListener (() => {
			userListPanel.SetActive (false);
			menuPanel.SetActive (true);
		});

		btnInvite = GameObject.Find ("SendBirdUnity/UIPanel/UserListPanel/BtnInvite").GetComponent<Button> ();
		btnInvite.GetComponent<Image> ().sprite = uiTheme.sendButton;
		btnInvite.onClick.AddListener (() => {
			if(mUserList.Count <= 0)
			{
				return;
			}

			userListPanel.SetActive (false);
			groupChannelPanel.SetActive (true);

			GroupChannel.CreateChannelWithUserIds(mUserList, false, (channel, e) => {
				if(e != null)
				{
					Debug.Log(e.Code + ": " + e.Message);
					return;
				}

				currentChannel = channel;
				ResetGroupChannelContent();
				txtGroupChannelTitle.text = GetDisplayMemberNames(channel.Members);
			});
		});

		#endregion

		#region GroupChannelList

		groupChannelListPanel = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelListPanel");
		groupChannelListPanel.GetComponent<Image> ().sprite = uiTheme.channelListFrameBG;

		groupChannelListGridPanel = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelListPanel/ScrollArea/GridPanel");

		GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelListPanel/TxtTitle").GetComponent<Text> ().color = uiTheme.titleColor;

		var groupChannelListScrollbar = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelListPanel/Scrollbar").GetComponent<Scrollbar> ();
		cb = groupChannelListScrollbar.colors;
		cb.normalColor = uiTheme.scrollBarColor;
		cb.pressedColor = uiTheme.scrollBarColor;
		cb.highlightedColor = uiTheme.scrollBarColor;
		groupChannelListScrollbar.colors = cb;
		groupChannelListScrollbar.onValueChanged.AddListener ((float value) => {
			if (value <= 0) {
				LoadGroupChannels();
			}
		});

		btnGroupChannelClose = GameObject.Find ("SendBirdUnity/UIPanel/GroupChannelListPanel/BtnGroupChannelListClose").GetComponent<Button> ();
		btnGroupChannelClose.GetComponent<Image> ().sprite = uiTheme.closeButton;
		btnGroupChannelClose.onClick.AddListener (() => {
			groupChannelListPanel.SetActive (false);
			if (!groupChannelListPanel.activeSelf) {
				menuPanel.SetActive (true);
			}
		});

		#endregion

		uiPanel.SetActive (true);
		menuPanel.SetActive (true);
		openChannelListPanel.SetActive (false);
		openChannelPanel.SetActive (false);
		groupChannelPanel.SetActive (false);
		userListPanel.SetActive (false);
		groupChannelListPanel.SetActive (false);
	}
        public void SetUp()
        {
            _stringWriter = new StringWriter();

            _file = new Mock <IFileSystem>();
            _file.Setup(x => x.CloseTextWriter(It.IsAny <TextWriter>()));
            _file.Setup(x => x.CreateDirectory(It.IsAny <string>()));
            _file.Setup(x => x.DirectoryExists(It.IsAny <string>())).Returns(false);
            _file.Setup(x => x.FileAppendText(It.IsAny <string>())).Returns(_stringWriter);
            _file.Setup(x => x.FileDelete(It.IsAny <string>()));
            _file.Setup(x => x.FileExists(It.IsAny <string>())).Returns(true);

            _server = new Mock <HttpServerUtilityBase>();
            _server.Setup(x => x.MapPath(It.IsAny <string>())).Returns(string.Empty);

            var noThresholdChannels = new List <ChannelNoThresholdList>();

            noThresholdChannels.Add(new ChannelNoThresholdList()
            {
                EmailAddress = FirstEmail,
                CreatedDate  = MinDateTime
            });
            noThresholdChannels.Add(new ChannelNoThresholdList()
            {
                EmailAddress = SecondEmail,
                CreatedDate  = MaxDateTime
            });
            _channelNoThresholdList = new Mock <IChannelNoThresholdList>();
            _channelNoThresholdList
            .Setup(x => x.GetByEmailAddress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <User>()))
            .Returns(noThresholdChannels);

            _response = new Mock <HttpResponseBase>();

            var baseChannel = new BaseChannel()
            {
                BaseChannelID = ChannelIdValue
            };

            var masterSuppressionChannels = new List <ChannelMasterSuppressionList>();

            masterSuppressionChannels.Add(new ChannelMasterSuppressionList()
            {
                EmailAddress = FirstEmail,
                CreatedDate  = MinDateTime
            });
            masterSuppressionChannels.Add(new ChannelMasterSuppressionList()
            {
                EmailAddress = SecondEmail,
                CreatedDate  = MaxDateTime
            });
            var channelMasterSuppressionList = new Mock <IChannelMasterSuppressionList>();

            channelMasterSuppressionList
            .Setup(x => x.GetByEmailAddress(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <User>()))
            .Returns(masterSuppressionChannels);

            _controller = new GroupController(
                _file.Object,
                _server.Object,
                _channelNoThresholdList.Object,
                _response.Object,
                baseChannel,
                new User(),
                channelMasterSuppressionList.Object);
        }
示例#10
0
	void LoadOpenChannels()
	{
		mChannelListQuery.Next ((list, e) => {
			if (e != null) {
				Debug.Log (e.Code + ": " + e.Message);
				return;
			}	

			foreach (OpenChannel channel in list) {
				GameObject btnChannel = Instantiate (channelListItemPrefab) as GameObject;
				btnChannel.GetComponent<Image> ().sprite = uiTheme.channelButtonOff;

				if (channel.Url == selectedChannelUrl) {
					btnChannel.GetComponent<Image> ().overrideSprite = uiTheme.channelButtonOn;
					btnChannel.GetComponentInChildren<Text> ().color = uiTheme.channelButtonOnColor;
				} else {
					btnChannel.GetComponent<Image> ().overrideSprite = null;
					btnChannel.GetComponentInChildren<Text> ().color = uiTheme.channelButtonOffColor;
				}
				Text text = btnChannel.GetComponentInChildren<Text> ();
				text.text = "#" + channel.Name;
				btnChannel.transform.SetParent (channelGridPannel.transform);
				btnChannel.transform.localScale = Vector3.one;
				btnChannels.Add (btnChannel);

				OpenChannel final = channel;
				btnChannel.GetComponent<Button> ().onClick.AddListener (() => {
					foreach (KeyValuePair<string, OpenChannel> entry in enteredChannels) {
						entry.Value.Exit (null);
					}

					final.Enter ((e1) => {
						if (e1 != null) {
							Debug.Log (e1.Code + ": " + e1.Message);
							return;
						}

						currentChannel = final;
						ResetOpenChannelContent();
						txtOpenChannelTitle.text = "#" + final.Name;

						enteredChannels [final.Url] = final;

						openChannelListPanel.SetActive (false);
						openChannelPanel.SetActive(true);
					});
				});
			}
		});
	}
示例#11
0
	void LoadGroupChannels()
	{
		mGroupChannelListQuery.Next ((list, e) => {
			if (e != null) {
				Debug.Log (e.Code + ": " + e.Message);
				return;
			}

			foreach (GroupChannel groupChannel in list) {
				GameObject btnGroupChannel = Instantiate (channelListItemPrefab) as GameObject;
				btnGroupChannel.GetComponent<Image> ().sprite = uiTheme.channelButtonOff;
				btnGroupChannel.GetComponent<Image> ().type = Image.Type.Sliced;

				if (groupChannel.Url == selectedChannelUrl) {
					btnGroupChannel.GetComponent<Image> ().overrideSprite = uiTheme.channelButtonOn;
					btnGroupChannel.GetComponentInChildren<Text> ().color = uiTheme.channelButtonOnColor;
				} else {
					btnGroupChannel.GetComponent<Image> ().overrideSprite = null;
					btnGroupChannel.GetComponentInChildren<Text> ().color = uiTheme.channelButtonOffColor;
				}

				Text text = btnGroupChannel.GetComponentInChildren<Text> ();
				text.text = string.Format ("{0} ({1})", GetDisplayMemberNames (groupChannel.Members), groupChannel.UnreadMessageCount);

				btnGroupChannel.transform.SetParent (groupChannelListGridPanel.transform);
				btnGroupChannel.transform.localScale = Vector3.one;
				btnGroupChannels.Add (btnGroupChannel);

				GroupChannel final = groupChannel;
				btnGroupChannel.GetComponent<Button> ().onClick.AddListener (() => {
					groupChannelListPanel.SetActive (false);
					groupChannelPanel.SetActive (true);


					currentChannel = final;
					ResetGroupChannelContent();
					txtGroupChannelTitle.text = GetDisplayMemberNames(final.Members);
				});
			}

		});
	}
示例#12
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BaseChannel obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
示例#13
0
        } /* <Vector_csout> */

        public bool Compare(BaseChannel dst)
        {
            bool ret = C4dApiPINVOKE.BaseChannel_Compare(swigCPtr, BaseChannel.getCPtr(dst));

            return(ret);
        }
示例#14
0
        public bool HandleSelectedTextureFilename(BaseChannel bc, Filename fn, Filename resfilename, bool undo, SWIGTYPE_p_GEMB_R already_answered)
        {
            bool ret = C4dApiPINVOKE.BaseDocument_HandleSelectedTextureFilename(swigCPtr, BaseChannel.getCPtr(bc), Filename.getCPtr(fn), Filename.getCPtr(resfilename), undo, SWIGTYPE_p_GEMB_R.getCPtr(already_answered));

            if (C4dApiPINVOKE.SWIGPendingException.Pending)
            {
                throw C4dApiPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#15
0
        public static void Refresh(BaseChannel <IRfid> channel,
                                   List <OneTag> list,
                                   delegate_notifyChanged notifyChanged,
                                   delegate_setError setError)
        {
            setError?.Invoke("rfid", null);

            List <TagAndData> new_books   = new List <TagAndData>();
            List <TagAndData> new_patrons = new List <TagAndData>();

            List <TagAndData> error_books   = new List <TagAndData>();
            List <TagAndData> error_patrons = new List <TagAndData>();

            // 从当前列表中发现已有的图书。用于交叉运算
            List <TagAndData> found_books = new List <TagAndData>();
            // 从当前列表中发现已有的读者。用于交叉运算
            List <TagAndData> found_patrons = new List <TagAndData>();

            foreach (OneTag tag in list)
            {
                // 检查以前的列表中是否已经有了
                var book = FindBookTag(tag.UID);
                if (book != null)
                {
                    found_books.Add(book);

                    if (string.IsNullOrEmpty(book.Error) == false)
                    {
                        error_books.Add(book);
                    }
                    continue;
                }
                var patron = FindPatronTag(tag.UID);
                if (patron != null)
                {
                    found_patrons.Add(patron);
                    if (string.IsNullOrEmpty(patron.Error) == false)
                    {
                        error_patrons.Add(patron);
                    }
                    continue;
                }

                // ISO14443A 的一律当作读者证卡
                if (tag.Protocol == InventoryInfo.ISO14443A)
                {
                    patron = new TagAndData {
                        OneTag = tag, Type = "patron"
                    };
                    new_patrons.Add(patron);
                }
                else
                {
                    // 根据缓存的 typeOfUsage 来判断
                    string typeOfUsage = (string)_typeTable[tag.UID];
                    if (typeOfUsage != null && typeOfUsage.StartsWith("8"))
                    {
                        patron = new TagAndData {
                            OneTag = tag, Type = "patron"
                        };
                        new_patrons.Add(patron);
                        found_books.Remove(patron);
                    }
                    else
                    {
                        // ISO15693 的则先添加到 _books 中。等类型判断完成,有可能还要调整到 _patrons 中
                        book = new TagAndData {
                            OneTag = tag
                        };
                        new_books.Add(book);
                    }
                }
            }

            List <TagAndData> remove_books   = new List <TagAndData>();
            List <TagAndData> remove_patrons = new List <TagAndData>();

            // 交叉运算
            foreach (TagAndData book in _books)
            {
                if (found_books.IndexOf(book) == -1)
                {
                    remove_books.Add(book);
                }
            }

            foreach (TagAndData patron in _patrons)
            {
                if (found_patrons.IndexOf(patron) == -1)
                {
                    remove_patrons.Add(patron);
                }
            }

            // 兑现添加
            lock (_sync_books)
            {
                foreach (TagAndData book in new_books)
                {
                    if (_books.IndexOf(book) == -1)
                    {
                        _books.Add(book);
                    }
                }
                // 兑现删除
                foreach (TagAndData book in remove_books)
                {
                    _books.Remove(book);
                }
            }

            lock (_sync_patrons)
            {
                foreach (TagAndData patron in new_patrons)
                {
                    if (_patrons.IndexOf(patron) == -1)
                    {
                        _patrons.Add(patron);
                    }
                }
                foreach (TagAndData patron in remove_patrons)
                {
                    _patrons.Remove(patron);
                }
            }

            // 通知一次变化
            notifyChanged(new_books, null, remove_books,
                          new_patrons, null, remove_patrons);

            // 需要获得 Tag 详细信息的。注意还应当包含以前出错的 Tag
            //List<TagAndData> news = new_books;
            // news.AddRange(error_books);

            List <TagAndData> news = new List <TagAndData>();

            news.AddRange(_books);
            news.AddRange(new_patrons);

            new_books      = new List <TagAndData>();
            remove_books   = new List <TagAndData>();
            new_patrons    = new List <TagAndData>();
            remove_patrons = new List <TagAndData>();

            {
                List <TagAndData> update_books   = new List <TagAndData>();
                List <TagAndData> update_patrons = new List <TagAndData>();

                // 逐个获得新发现的 ISO15693 标签的详细数据,用于判断图书/读者类型
                foreach (TagAndData data in news)
                {
                    OneTag tag = data.OneTag;
                    if (tag == null)
                    {
                        continue;
                    }
                    if (tag.TagInfo != null && data.Error == null)
                    {
                        continue;
                    }
                    if (tag.Protocol == InventoryInfo.ISO14443A)
                    {
                        continue;
                    }
                    {
                        var gettaginfo_result = GetTagInfo(channel, tag.UID);
                        if (gettaginfo_result.Value == -1)
                        {
                            setError?.Invoke("rfid", gettaginfo_result.ErrorInfo);
                            // TODO: 是否直接在标签上显示错误文字?
                            data.Error = gettaginfo_result.ErrorInfo;
                            if (data.Type == "patron")
                            {
                                update_patrons.Add(data);
                            }
                            else
                            {
                                update_books.Add(data);
                            }
                            continue;
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(data.Error) == false)
                            {
                                data.Error = null;
                                if (data.Type == "patron")
                                {
                                    update_patrons.Add(data);
                                }
                                else
                                {
                                    update_books.Add(data);
                                }
                            }
                        }

                        TagInfo info = gettaginfo_result.TagInfo;

                        // 记下来。避免以后重复再次去获取了
                        if (tag.TagInfo == null)
                        {
                            tag.TagInfo = info;
                        }

                        // 观察 typeOfUsage 元素
                        var chip = LogicChip.From(info.Bytes,
                                                  (int)info.BlockSize,
                                                  "");

                        string typeOfUsage = chip.FindElement(ElementOID.TypeOfUsage)?.Text;

                        // 分离 ISO15693 图书标签和读者卡标签
                        if (string.IsNullOrEmpty(data.Type))
                        {
                            if (typeOfUsage != null && typeOfUsage.StartsWith("8"))
                            {
                                // 需要调整到 _patrons 中
                                data.Type = "patron";
                                // 删除列表? 同时添加列表
                                remove_books.Add(data);
                                update_books.Remove(data);  // 容错
                                new_patrons.Add(data);
                            }
                            else
                            {
                                data.Type = "book";
                                update_books.Add(data);
                                update_patrons.Remove(data);
                            }

                            // 保存到缓存
                            if (typeOfUsage != null)
                            {
                                if (_typeTable.Count > 1000)
                                {
                                    _typeTable.Clear();
                                }
                                _typeTable[data.OneTag.UID] = typeOfUsage;
                            }
                        }
                    }
                } // end of foreach

                // 再次兑现添加和删除
                // 兑现添加
                lock (_sync_books)
                {
                    foreach (TagAndData book in new_books)
                    {
                        _books.Add(book);
                    }
                    // 兑现删除
                    foreach (TagAndData book in remove_books)
                    {
                        _books.Remove(book);
                    }
                }

                lock (_sync_patrons)
                {
                    foreach (TagAndData patron in new_patrons)
                    {
                        _patrons.Add(patron);
                    }
                    foreach (TagAndData patron in remove_patrons)
                    {
                        _patrons.Remove(patron);
                    }
                }

                // 再次通知变化
                notifyChanged(new_books, update_books, remove_books,
                              new_patrons, update_patrons, remove_patrons);
            }
        }
        private void CommonShims()
        {
            ShimUserSession();
            Shimbasechanneleditor.AllInstances.getBaseChannelID = instance => _baseChannelId;
            ShimBaseChannel.ValidateBaseChannelUser             = (baseCannel, user) =>
            {
                if (_validateErrorToThrow != null)
                {
                    var errors = _validateErrorToThrow.Split(new[] { ValidateSeparator },
                                                             StringSplitOptions.RemoveEmptyEntries)
                                 .Select(message => new ECNError {
                        ErrorMessage = message
                    })
                                 .ToList();
                    throw new ECNException(errors);
                }
            };
            ShimClientGroup.AllInstances.SelectInt32Boolean = (instance, clientGroupId, includeObjects) =>
            {
                return(_clientGroupSelectResult);
            };
            var clientGroupSaveCallCount = 0;

            ShimClientGroup.AllInstances.SaveClientGroup = (instance, clientGroup) =>
            {
                ++clientGroupSaveCallCount;
                _clientGroupPassedToSave = clientGroup;
                if (_clientGroupSaveException != null && clientGroupSaveCallCount > 1)
                {
                    throw _clientGroupSaveException;
                }
                return(_clientGroupSaveResult);
            };
            ShimClientGroupServiceMap.AllInstances.SaveClientGroupServiceMap = (instance, groupServiceMap) =>
            {
                _clientGroupServicePassedToSave = groupServiceMap;
                return(_clientGroupServiceMapSaveResult);
            };
            ShimClientGroupServiceFeatureMap.AllInstances.SaveClientGroupServiceFeatureMap = (instance, map) =>
            {
                _clientGroupServiceFeatureMapPassedToSave = _clientGroupServiceFeatureMapPassedToSave ?? map;
                return(_clientGroupServiceFeatureMapSaveResult);
            };
            ShimSecurityGroup.AllInstances.CreateFromTemplateForClientGroupStringInt32StringUser =
                (instance, securityGroupTemplateName, clientGroupId, administrativeLevel, user) =>
            {
                _securityGroupTemplateNamePassedToCreateFromTemplate = securityGroupTemplateName;
                _clientGroupIdPassedToCreateFromTemplate             = clientGroupId;
                _administrativeLevelPassedToCreateFromTemplate       = administrativeLevel;
                _userPassedToCreateFromTemplate = user;
                return(GetAnyNumber());
            };
            ShimContactEntity.ConstructorStringStringStringStringStringStringStringStringStringStringStringString =
                (instace, salutation, firstName, lastName, title, phone, fax, email, address, city, state, country,
                 zip) =>
            {
            };
            ShimBaseChannel.SaveBaseChannelUser = (baseChannel, user) =>
            {
                if (_baseChannelSaveException != null)
                {
                    throw _baseChannelSaveException;
                }
                _baseChannelPassedToSave = baseChannel;
            };
            ShimServiceFeature.AllInstances.GetClientGroupTreeListNullableOfInt32Boolean =
                (instance, clientGroupId, isAdditionalCost) =>
            {
                return(new List <ClientGroupTreeListRow>
                {
                    new ClientGroupTreeListRow
                    {
                        ServiceFeatureID = GetAnyNumber()
                    }
                });
            };

            ShimPage.AllInstances.ResponseGet = instance =>
            {
                return(new System.Web.HttpResponse(_responseStreamWriter));
            };
            ShimHttpResponse.AllInstances.RedirectString = (instance, url) =>
            {
            };
            ShimEmailDirect.SaveEmailDirect = email =>
            {
                return(GetAnyNumber());
            };
        }
示例#17
0
文件: RfidManager.cs 项目: renyh/dp2
 public static void ReturnChannel(BaseChannel <IRfid> channel)
 {
     Base.ReturnChannel(channel);
 }
示例#18
0
        /**********************************************************************************************//**
        * Evaluates.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \param   evaluationMode  The evaluation mode.
        * \param   network         The network.
        * \param   process         The process.
        * \param   channel         The channel.
        * \param   message         The message.
        *
        * \return  true if it succeeds, false if it fails.
        *  .
        **************************************************************************************************/

        public bool Evaluate(EvaluationMode evaluationMode, BaseNetwork network, BaseProcess process, BaseChannel channel, BaseMessage message)
        {
            string resultString;
            bool   result;

            if (or[brp.ork.Enable] == false)
            {
                resultString = "False : The breakpoint is enabeled";
                result       = false;
            }
            else
            {
                try
                {
                    //Duplicate the list of parameters because it can change for the evaluation (in AdjustForOtherElementsBreakpoints)
                    //and the original list have to stay as the original
                    AttributeList parametersList = new AttributeList(or[brp.ork.Parameters]);
                    AdjustForOtherElementsBreakpoints(parametersList, network);
                    AttributeList parameters = new AttributeList();

                    for (int idx = 0; idx < parametersList.Count; idx++)
                    {
                        parameters.Add(EvaluateParameter(evaluationMode, network, process, channel, message, parametersList.GetAttribute(idx)));
                    }
                    if (parameters.Count == 0)
                    {
                        resultString = "False : There are no parameters";
                        result       = false;
                    }
                    else
                    {
                        if (parameters.Count == 1)
                        {
                            //If unary value the operator will work on the first
                            //argument only the first argument is duplicatted
                            //for comaptibillity
                            parameters.Add(parameters.GetAttribute(0));
                        }

                        result       = Evaluate(parameters);
                        resultString = result.ToString();
                    }
                }
                catch (EvaluationException exception)
                {
                    resultString = "False : " + exception.Message;
                    result       = false;
                }
            }
            int processId = process.ea[ne.eak.Id];

            CreateResultsLists(network.Processes);
            if (evaluationMode == EvaluationMode.Running)
            {
                or[brp.ork.LastRunningResult][processId] = resultString;
            }
            else if (evaluationMode == EvaluationMode.Checking)
            {
                or[brp.ork.LastCheckResult][processId] = resultString;
            }
            return(result);
        }
示例#19
0
 public void SetEvents(BaseChannel channel)
 {
     events.onConnected    = channel.onConnected;
     events.onDisconnected = channel.onDisconnected;
     events.onException    = channel.onException;
 }
示例#20
0
        /*
         * The possible parameters are:
         * key - in this case find the attribute
         * if the attribute found is a list
         *  if only one value from the list is requested
         *      return the value according to an index
         *  else return the list
         * else (the value is not a list) return the value
         */

        /**********************************************************************************************//**
        * Evaluate parameter.
        *
        * \author  Ilan Hindy
        * \date    29/09/2016
        *
        * \exception   EvaluationException Thrown when an Evaluation error condition occurs.
        *
        * \param   evaluationMode  The evaluation mode.
        * \param   network         The network.
        * \param   process         The process.
        * \param   channel         The channel.
        * \param   message         The message.
        * \param   parameter       The parameter.
        *
        * \return  An Attribute.
        *  .
        **************************************************************************************************/

        private Attribute EvaluateParameter(EvaluationMode evaluationMode, BaseNetwork network, BaseProcess process, BaseChannel channel, BaseMessage message, Attribute parameter)
        {
            if (parameter.Value.GetType().IsEnum)
            {
                if (!NetworkElementExist(network, process, channel, message))
                {
                    return(new Attribute()
                    {
                        Value = false
                    });
                }
                Attribute attribute = FindAttribute(network, process, channel, message, parameter.Value);
                if (attribute == null)
                {
                    string typeOfHostingElementStr = TypesUtility.GetKeyToString(or[brp.ork.HostingElementType]);
                    throw new EvaluationException("Could not find attribute " + TypesUtility.GetKeyToString(parameter.Value) + " In element of type " + typeOfHostingElementStr);
                }
                else
                {
                    if (Attribute.GetValueCategory(attribute) == Attribute.AttributeCategory.ListOfAttributes)
                    {
                        if (or[brp.ork.ListParameterOneOrAll] == ListParameterOneOrAll.One)
                        {
                            object[] elements       = TypesUtility.InvokeMethodOfList(attribute.Value, "ToArray", new object[0], true);
                            int      requestedIndex = or[brp.ork.IndexInList];
                            if (elements.Count() <= requestedIndex)
                            {
                                throw new EvaluationException("The index requested : " + requestedIndex.ToString() + " is larger or equal to the number of elements in the list : " + elements.Count());
                            }
                            else
                            {
                                if (Attribute.GetValueCategory(attribute) == Attribute.AttributeCategory.ListOfAttributes)
                                {
                                    return((Attribute)elements[requestedIndex]);
                                }
                                else
                                {
                                    return(new Attribute()
                                    {
                                        Value = elements[requestedIndex]
                                    });
                                }
                            }
                        }
                    }
                    return(attribute);
                }
            }
            if (parameter.Value.GetType().Equals(typeof(Breakpoint)))
            {
                return(new Attribute()
                {
                    Value = parameter.Value.Evaluate(evaluationMode, network, process, channel, message)
                });
            }
            return(parameter);
        }
示例#21
0
文件: TagList.cs 项目: zgren/dp2
        // parameters:
        //      readerNameList  list中包含的内容的读卡器名(列表)。注意 list 中包含的标签,可能并不是全部读卡器的标签。对没有包含在其中的标签,本函数需要注意跳过(维持现状),不要当作被删除处理
        // 异常:
        //      可能抛出 TagInfoException
        public static void Refresh(BaseChannel <IRfid> channel,
                                   string readerNameList,
                                   List <OneTag> list,
                                   delegate_notifyChanged notifyChanged,
                                   delegate_setError setError /*,
                                                               * delegate_detectType detectType = null*/)
        {
            try
            {
                setError?.Invoke("rfid", null);

                List <TagAndData> new_books   = new List <TagAndData>();
                List <TagAndData> new_patrons = new List <TagAndData>();

                List <TagAndData> error_books   = new List <TagAndData>();
                List <TagAndData> error_patrons = new List <TagAndData>();

                // 从当前列表中发现已有的图书。用于交叉运算
                List <TagAndData> found_books = new List <TagAndData>();
                // 从当前列表中发现已有的读者。用于交叉运算
                List <TagAndData> found_patrons = new List <TagAndData>();

                // 即便是发现已经存在 UID 的标签,也要再判断一下 Antenna 是否不同。如果有不同,要进行变化通知
                // 从当前列表中发现(除了 UID) 内容有变化的图书。这些图书也会进入 found_books 集合
                List <TagAndData> changed_books = new List <TagAndData>();

                foreach (OneTag tag in list)
                {
                    // 检查以前的列表中是否已经有了
                    var book = FindBookTag(tag.UID);
                    if (book != null)
                    {
                        found_books.Add(book);
                        if (book.OneTag.AntennaID != tag.AntennaID ||
                            book.OneTag.ReaderName != tag.ReaderName)       // // 2020/10/17
                        {
                            // 修改 AntennaID
                            book.OneTag.AntennaID = tag.AntennaID;
                            // 修改 ReaderName
                            book.OneTag.ReaderName = tag.ReaderName;
                            changed_books.Add(book);

                            // 只清理缓存
                            _tagTable.Remove(book.OneTag.UID);
                        }

                        if (string.IsNullOrEmpty(book.Error) == false)
                        {
                            error_books.Add(book);
                        }
                        continue;
                    }
                    var patron = FindPatronTag(tag.UID);
                    if (patron != null)
                    {
                        found_patrons.Add(patron);
                        if (string.IsNullOrEmpty(patron.Error) == false)
                        {
                            error_patrons.Add(patron);
                        }
                        continue;
                    }

                    // ISO14443A 的一律当作读者证卡
                    if (tag.Protocol == InventoryInfo.ISO14443A)
                    {
                        patron = new TagAndData {
                            OneTag = tag, Type = "patron"
                        };
                        new_patrons.Add(patron);
                    }
                    else
                    {
                        // 根据缓存的 typeOfUsage 来判断
                        string typeOfUsage = (string)_typeTable[tag.UID];
                        if (typeOfUsage != null && typeOfUsage.StartsWith("8"))
                        {
                            patron = new TagAndData {
                                OneTag = tag, Type = "patron"
                            };
                            new_patrons.Add(patron);
                            found_books.Remove(patron);
                        }
                        else
                        {
                            // ISO15693 的则先添加到 _books 中。等类型判断完成,有可能还要调整到 _patrons 中
                            book = new TagAndData {
                                OneTag = tag
                            };
                            new_books.Add(book);
                        }
                    }
                }

                List <TagAndData> remove_books   = new List <TagAndData>();
                List <TagAndData> remove_patrons = new List <TagAndData>();

                // 交叉运算
                // 注意对那些在 readerNameList 以外的标签不要当作 removed 处理
                foreach (TagAndData book in _books)
                {
                    if (InRange(book, readerNameList) == false)
                    {
                        continue;
                    }
                    if (found_books.IndexOf(book) == -1)
                    {
                        remove_books.Add(book);
                    }
                }

                foreach (TagAndData patron in _patrons)
                {
                    if (InRange(patron, readerNameList) == false)
                    {
                        continue;
                    }

                    if (found_patrons.IndexOf(patron) == -1)
                    {
                        remove_patrons.Add(patron);
                    }
                }

                bool array_changed = false;

                // 兑现添加
                lock (_sync_books)
                {
                    foreach (TagAndData book in new_books)
                    {
                        if (_books.IndexOf(book) == -1)
                        {
                            _books.Add(book);
                            array_changed = true;
                        }
                    }
                    // 兑现删除
                    foreach (TagAndData book in remove_books)
                    {
                        _books.Remove(book);
                        array_changed = true;
                    }
                }

                lock (_sync_patrons)
                {
                    foreach (TagAndData patron in new_patrons)
                    {
                        if (_patrons.IndexOf(patron) == -1)
                        {
                            _patrons.Add(patron);
                            array_changed = true;
                        }
                    }
                    foreach (TagAndData patron in remove_patrons)
                    {
                        _patrons.Remove(patron);
                        array_changed = true;
                    }
                }

                // 通知一次变化
                if (array_changed ||
                    changed_books.Count > 0 ||
                    new_books.Count > 0 || remove_books.Count > 0 ||
                    new_patrons.Count > 0 || remove_patrons.Count > 0)       // 2019/8/15 优化
                {
                    notifyChanged(new_books, changed_books, remove_books,
                                  new_patrons, null, remove_patrons);
                }

                // 需要获得 Tag 详细信息的。注意还应当包含以前出错的 Tag
                //List<TagAndData> news = new_books;
                // news.AddRange(error_books);

                List <TagAndData> news = new List <TagAndData>();
                news.AddRange(_books);
                news.AddRange(new_patrons);

                new_books      = new List <TagAndData>();
                remove_books   = new List <TagAndData>();
                new_patrons    = new List <TagAndData>();
                remove_patrons = new List <TagAndData>();

                // .TagInfo 是否发生过填充
                bool taginfo_changed = false;
                {
                    List <TagAndData> update_books   = new List <TagAndData>();
                    List <TagAndData> update_patrons = new List <TagAndData>();

                    // 逐个获得新发现的 ISO15693 标签的详细数据,用于判断图书/读者类型
                    foreach (TagAndData data in news)
                    {
                        OneTag tag = data.OneTag;
                        if (tag == null)
                        {
                            continue;
                        }
                        if (tag.TagInfo != null && data.Error == null)
                        {
                            continue;
                        }
                        if (tag.Protocol == InventoryInfo.ISO14443A)
                        {
                            continue;
                        }
                        {
                            /*
                             * // TODO
                             * GetTagInfoResult gettaginfo_result = null;
                             * if (tag.InventoryInfo == null)
                             *  gettaginfo_result = GetTagInfo(channel, tag.UID);
                             * else
                             *  gettaginfo_result = GetTagInfo(channel, tag.InventoryInfo);
                             */
                            // 自动重试一次
                            GetTagInfoResult gettaginfo_result = null;
                            for (int i = 0; i < 2; i++)
                            {
                                gettaginfo_result = GetTagInfo(channel, tag.ReaderName, tag.UID, tag.AntennaID);
                                if (gettaginfo_result.Value != -1)
                                {
                                    break;
                                }
                            }

                            if (gettaginfo_result.Value == -1)
                            {
                                setError?.Invoke("rfid", gettaginfo_result.ErrorInfo);
                                // TODO: 是否直接在标签上显示错误文字?
                                data.Error = gettaginfo_result.ErrorInfo;
                                if (data.Type == "patron")
                                {
                                    update_patrons.Add(data);
                                }
                                else
                                {
                                    update_books.Add(data);
                                }
                                continue;
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(data.Error) == false)
                                {
                                    data.Error = null;
                                    if (data.Type == "patron")
                                    {
                                        update_patrons.Add(data);
                                    }
                                    else
                                    {
                                        update_books.Add(data);
                                    }
                                }
                            }

                            TagInfo info = gettaginfo_result.TagInfo;

                            // 记下来。避免以后重复再次去获取了
                            if (tag.TagInfo == null)
                            {
                                tag.TagInfo     = info;
                                taginfo_changed = true;

                                // 2019/8/25
                                if (data.Type == "patron")
                                {
                                    if (update_patrons.IndexOf(data) == -1)
                                    {
                                        update_patrons.Add(data);
                                    }
                                }
                                else
                                {
                                    /*
                                     * if (update_books.IndexOf(data) == -1)
                                     *  update_books.Add(data);
                                     */
                                }
                            }

                            // 对于不确定类型的标签(data.Type 为空的),再次确定类型以便分离 ISO15693 图书标签和读者卡标签
                            if (string.IsNullOrEmpty(data.Type))
                            {
                                LogicChip chip        = null;
                                string    typeOfUsage = "";
                                try
                                {
                                    // 观察 typeOfUsage 元素
                                    // Exception:
                                    //      可能会抛出异常 ArgumentException TagDataException
                                    chip = LogicChip.From(info.Bytes,
                                                          (int)info.BlockSize,
                                                          "");
                                    typeOfUsage = chip.FindElement(ElementOID.TypeOfUsage)?.Text;
                                }
                                catch (TagDataException ex)
                                {
                                    // throw new TagInfoException(ex.Message, info);

                                    // 解析错误的标签,当作图书标签处理
                                    typeOfUsage = "";
                                }

                                if (typeOfUsage != null && typeOfUsage.StartsWith("8"))
                                {
                                    // 需要调整到 _patrons 中
                                    data.Type = "patron";
                                    // 删除列表? 同时添加列表
                                    remove_books.Add(data);
                                    update_books.Remove(data);  // 容错
                                    new_patrons.Add(data);
                                }
                                else
                                {
                                    data.Type = "book";
                                    update_books.Add(data);
                                    update_patrons.Remove(data);
                                }

                                // 保存到缓存
                                if (typeOfUsage != null)
                                {
                                    if (_typeTable.Count > 1000)
                                    {
                                        _typeTable.Clear();
                                    }
                                    _typeTable[data.OneTag.UID] = typeOfUsage;
                                }
                            }
                        }
                    } // end of foreach

                    array_changed = false;
                    // 再次兑现添加和删除
                    // 兑现添加
                    lock (_sync_books)
                    {
                        foreach (TagAndData book in new_books)
                        {
                            _books.Add(book);
                            array_changed = true;
                        }
                        // 兑现删除
                        foreach (TagAndData book in remove_books)
                        {
                            _books.Remove(book);
                            array_changed = true;
                        }
                    }

                    lock (_sync_patrons)
                    {
                        foreach (TagAndData patron in new_patrons)
                        {
                            _patrons.Add(patron);
                            array_changed = true;
                        }
                        foreach (TagAndData patron in remove_patrons)
                        {
                            _patrons.Remove(patron);
                            array_changed = true;
                        }
                    }

                    // 再次通知变化
                    if (array_changed == true ||
                        taginfo_changed == true ||
                        new_books.Count > 0 ||
                        update_books.Count > 0 ||
                        remove_books.Count > 0 ||
                        new_patrons.Count > 0 ||
                        update_patrons.Count > 0 ||
                        remove_patrons.Count > 0)       // 2019/8/15 优化
                    {
                        notifyChanged(new_books, update_books, remove_books,
                                      new_patrons, update_patrons, remove_patrons);
                    }
                }
            }
            finally
            {
                // _dataReady = true;
            }
        }
示例#22
0
    void InitComponents()
    {
        uiPanel = GameObject.Find("SendBirdUnity/UIPanel");
        (Instantiate(uiThemePrefab) as GameObject).transform.parent = uiPanel.transform;

        uiTheme = GameObject.FindObjectOfType(typeof(SendBirdTheme)) as SendBirdTheme;

        #region MenuPanel

        menuPanel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel");
        menuPanel.GetComponent <Image> ().sprite = uiTheme.channelListFrameBG;

        var txtMenuTitle = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/TxtTitle").GetComponent <Text> ();
        txtMenuTitle.color = uiTheme.titleColor;

        btnConnect = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnConnect").GetComponent <Button> ();
        btnConnect.GetComponent <Image> ().sprite = uiTheme.sendButton;
        btnConnect.GetComponent <Image> ().type   = Image.Type.Sliced;
        btnConnect.onClick.AddListener(() => {
            nickname = inputUserName.text;
            userId   = nickname;           // Assign user's unique id.

            if (nickname == null || nickname.Length <= 0)
            {
                return;
            }

            SendBirdClient.Connect(userId, (user, e) => {
                if (e != null)
                {
                    Debug.Log(e.Code + ": " + e.Message);
                    return;
                }


                btnConnect.gameObject.SetActive(false);

                btnOpenChannelList.gameObject.SetActive(true);
                btnStartGroupChannel.gameObject.SetActive(true);
                btnGroupChannelList.gameObject.SetActive(true);

                SendBirdClient.UpdateCurrentUserInfo(nickname, null, (e1) => {
                    if (e1 != null)
                    {
                        Debug.Log(e.Code + ": " + e.Message);
                        return;
                    }
                });
            });
        });


        btnOpenChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnOpenChannel").GetComponent <Button> ();
        btnOpenChannelList.GetComponent <Image> ().sprite = uiTheme.sendButton;
        btnOpenChannelList.GetComponent <Image> ().type   = Image.Type.Sliced;
        btnOpenChannelList.onClick.AddListener(() => {
            menuPanel.SetActive(false);
            OpenOpenChannelList();
        });

        btnStartGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnStartGroupChannel").GetComponent <Button> ();
        btnStartGroupChannel.GetComponent <Image> ().sprite = uiTheme.sendButton;
        btnStartGroupChannel.GetComponent <Image> ().type   = Image.Type.Sliced;
        btnStartGroupChannel.onClick.AddListener(() => {
            menuPanel.SetActive(false);

            OpenUserList();
        });

        btnGroupChannelList = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/BtnGroupChannel").GetComponent <Button> ();
        btnGroupChannelList.GetComponent <Image> ().sprite = uiTheme.sendButton;
        btnGroupChannelList.GetComponent <Image> ().type   = Image.Type.Sliced;
        btnGroupChannelList.onClick.AddListener(() => {
            menuPanel.SetActive(false);

            OpenGroupChannelList();
        });

        inputUserName = GameObject.Find("SendBirdUnity/UIPanel/MenuPanel/InputUserName").GetComponent <InputField> ();
        inputUserName.GetComponent <Image> ().sprite = uiTheme.inputTextBG;

        #endregion

        #region OpenChannel

        openChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel");
        openChannelPanel.GetComponent <Image> ().sprite = uiTheme.chatFrameBG;

        txtOpenChannelContent       = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/ScrollArea/TxtContent").GetComponent <Text> ();   // (Text);
        txtOpenChannelContent.color = uiTheme.messageColor;

        txtOpenChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/TxtTitle").GetComponent <Text> ();
        txtOpenChannelTitle.color = uiTheme.titleColor;

        openChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/Scrollbar").GetComponent <Scrollbar> ();

        ColorBlock cb = openChannelScrollbar.colors;
        cb.normalColor              = uiTheme.scrollBarColor;
        cb.pressedColor             = uiTheme.scrollBarColor;
        cb.highlightedColor         = uiTheme.scrollBarColor;
        openChannelScrollbar.colors = cb;
        openChannelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                autoScroll        = true;
                lastTextPositionY = txtOpenChannelContent.transform.position.y;
                return;
            }

            if (lastTextPositionY - txtOpenChannelContent.transform.position.y >= 100)
            {
                autoScroll = false;
            }

            lastTextPositionY = txtOpenChannelContent.transform.position.y;
        });

        inputOpenChannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel").GetComponent <InputField> ();
        inputOpenChannel.GetComponent <Image> ().sprite = uiTheme.inputTextBG;
        inputOpenChannel.onEndEdit.AddListener((string msg) => {
            SubmitOpenChannel();
        });

        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Placeholder").GetComponent <Text> ().color = uiTheme.inputTextPlaceholderColor;
        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/InputOpenChannel/Text").GetComponent <Text> ().color        = uiTheme.inputTextColor;

        btnOpenChannelSend = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelSend").GetComponent <Button> ();
        btnOpenChannelSend.GetComponent <Image> ().sprite         = uiTheme.sendButton;
        btnOpenChannelSend.GetComponentInChildren <Text> ().color = uiTheme.sendButtonColor;
        btnOpenChannelSend.onClick.AddListener(() => {
            SubmitOpenChannel();
        });

        btnOpenChannelClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelPanel/BtnOpenChannelClose").GetComponent <Button> ();
        btnOpenChannelClose.GetComponent <Image> ().sprite = uiTheme.closeButton;
        btnOpenChannelClose.onClick.AddListener(() => {
            openChannelPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        #endregion

        #region ChannelList

        openChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel");
        openChannelListPanel.GetComponent <Image> ().sprite = uiTheme.channelListFrameBG;

        channelGridPannel = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/TxtTitle").GetComponent <Text> ().color = uiTheme.titleColor;

        var channelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/Scrollbar").GetComponent <Scrollbar> ();
        cb                      = channelScrollbar.colors;
        cb.normalColor          = uiTheme.scrollBarColor;
        cb.pressedColor         = uiTheme.scrollBarColor;
        cb.highlightedColor     = uiTheme.scrollBarColor;
        channelScrollbar.colors = cb;

        channelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadOpenChannels();
            }
        });

        btnOpenChannelListClose = GameObject.Find("SendBirdUnity/UIPanel/OpenChannelListPanel/BtnOpenChannelListClose").GetComponent <Button> ();
        btnOpenChannelListClose.GetComponent <Image> ().sprite = uiTheme.closeButton;
        btnOpenChannelListClose.onClick.AddListener(() => {
            openChannelListPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        #endregion

        #region GroupChannel

        groupChannelPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel");
        groupChannelPanel.GetComponent <Image> ().sprite = uiTheme.chatFrameBG;

        txtGroupChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text> ();
        txtGroupChannelTitle.color = uiTheme.titleColor;

        btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelClose").GetComponent <Button> ();
        btnGroupChannelClose.GetComponent <Image> ().sprite = uiTheme.closeButton;
        btnGroupChannelClose.onClick.AddListener(() => {
            groupChannelPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        txtGroupChannelContent       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/ScrollArea/TxtContent").GetComponent <Text> ();   // (Text);
        txtGroupChannelContent.color = uiTheme.messageColor;

        txtGroupChannelTitle       = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/TxtTitle").GetComponent <Text> ();
        txtGroupChannelTitle.color = uiTheme.titleColor;

        groupChannelScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/Scrollbar").GetComponent <Scrollbar> ();
        ColorBlock cb_groupChannel = groupChannelScrollbar.colors;
        cb_groupChannel.normalColor      = uiTheme.scrollBarColor;
        cb_groupChannel.pressedColor     = uiTheme.scrollBarColor;
        cb_groupChannel.highlightedColor = uiTheme.scrollBarColor;
        groupChannelScrollbar.colors     = cb_groupChannel;
        groupChannelScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                autoScroll        = true;
                lastTextPositionY = txtGroupChannelContent.transform.position.y;
                return;
            }

            if (lastTextPositionY - txtGroupChannelContent.transform.position.y >= 100)
            {
                autoScroll = false;
            }

            lastTextPositionY = txtGroupChannelContent.transform.position.y;
        });

        inputGroupChannel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel").GetComponent <InputField> ();
        inputGroupChannel.GetComponent <Image> ().sprite = uiTheme.inputTextBG;
        inputGroupChannel.onEndEdit.AddListener((string msg) => {
            SubmitGroupChannel();
        });

        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Placeholder").GetComponent <Text> ().color = uiTheme.inputTextPlaceholderColor;
        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/InputGroupChannel/Text").GetComponent <Text> ().color        = uiTheme.inputTextColor;

        btnGroupChannelSend = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelPanel/BtnGroupChannelSend").GetComponent <Button> ();
        btnGroupChannelSend.GetComponent <Image> ().sprite         = uiTheme.sendButton;
        btnGroupChannelSend.GetComponentInChildren <Text> ().color = uiTheme.sendButtonColor;
        btnGroupChannelSend.onClick.AddListener(() => {
            SubmitGroupChannel();
        });

        #endregion

        #region UserList

        userListPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel");
        userListPanel.GetComponent <Image> ().sprite = uiTheme.channelListFrameBG;

        userListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/TxtTitle").GetComponent <Text> ().color = uiTheme.titleColor;

        var userListScrollBar = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/Scrollbar").GetComponent <Scrollbar> ();
        cb                       = userListScrollBar.colors;
        cb.normalColor           = uiTheme.scrollBarColor;
        cb.pressedColor          = uiTheme.scrollBarColor;
        cb.highlightedColor      = uiTheme.scrollBarColor;
        userListScrollBar.colors = cb;
        userListScrollBar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadUsers();
            }
        });

        btnUserListClose = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnUserListClose").GetComponent <Button> ();
        btnUserListClose.GetComponent <Image> ().sprite = uiTheme.closeButton;
        btnUserListClose.onClick.AddListener(() => {
            userListPanel.SetActive(false);
            menuPanel.SetActive(true);
        });

        btnInvite = GameObject.Find("SendBirdUnity/UIPanel/UserListPanel/BtnInvite").GetComponent <Button> ();
        btnInvite.GetComponent <Image> ().sprite = uiTheme.sendButton;
        btnInvite.onClick.AddListener(() => {
            if (mUserList.Count <= 0)
            {
                return;
            }

            userListPanel.SetActive(false);
            groupChannelPanel.SetActive(true);

            GroupChannel.CreateChannelWithUserIds(mUserList, false, (channel, e) => {
                if (e != null)
                {
                    Debug.Log(e.Code + ": " + e.Message);
                    return;
                }

                currentChannel = channel;
                ResetGroupChannelContent();
                txtGroupChannelTitle.text = GetDisplayMemberNames(channel.Members);
            });
        });

        #endregion

        #region GroupChannelList

        groupChannelListPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel");
        groupChannelListPanel.GetComponent <Image> ().sprite = uiTheme.channelListFrameBG;

        groupChannelListGridPanel = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/ScrollArea/GridPanel");

        GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/TxtTitle").GetComponent <Text> ().color = uiTheme.titleColor;

        var groupChannelListScrollbar = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/Scrollbar").GetComponent <Scrollbar> ();
        cb                  = groupChannelListScrollbar.colors;
        cb.normalColor      = uiTheme.scrollBarColor;
        cb.pressedColor     = uiTheme.scrollBarColor;
        cb.highlightedColor = uiTheme.scrollBarColor;
        groupChannelListScrollbar.colors = cb;
        groupChannelListScrollbar.onValueChanged.AddListener((float value) => {
            if (value <= 0)
            {
                LoadGroupChannels();
            }
        });

        btnGroupChannelClose = GameObject.Find("SendBirdUnity/UIPanel/GroupChannelListPanel/BtnGroupChannelListClose").GetComponent <Button> ();
        btnGroupChannelClose.GetComponent <Image> ().sprite = uiTheme.closeButton;
        btnGroupChannelClose.onClick.AddListener(() => {
            groupChannelListPanel.SetActive(false);
            if (!groupChannelListPanel.activeSelf)
            {
                menuPanel.SetActive(true);
            }
        });

        #endregion

        uiPanel.SetActive(true);
        menuPanel.SetActive(true);
        openChannelListPanel.SetActive(false);
        openChannelPanel.SetActive(false);
        groupChannelPanel.SetActive(false);
        userListPanel.SetActive(false);
        groupChannelListPanel.SetActive(false);
    }