Пример #1
0
        public ZoomMeetingApi(UserConnection userConnection)
        {
            _userConnection = userConnection;
            Guid CUC = _userConnection.CurrentUser.ContactId;

            Select select = new Select(_userConnection)
                            .Column("ApiKey")
                            .Column("ApiSecret")
                            .Column("ZoomAccountUser", "UserId").As("UserId")
                            .From("ZoomAccounts")
                            .LeftOuterJoin("ZoomAccountUser").On("ZoomAccounts", "Id").IsEqual("ZoomAccountUser", "ZoomAccountId")
                            .Where("ZoomAccountUser", "ContactId").IsEqual(Column.Parameter(_userConnection.CurrentUser.ContactId.ToString())) as Select;

            using (DBExecutor dbExecutor = _userConnection.EnsureDBConnection())
            {
                using (IDataReader dataReader = select.ExecuteReader(dbExecutor))
                {
                    while (dataReader.Read())
                    {
                        this.ApiKey    = dataReader.GetColumnValue <string>("ApiKey");
                        this.ApiSecret = dataReader.GetColumnValue <string>("ApiSecret");
                        this.HostId    = dataReader.GetColumnValue <string>("UserId");
                    }
                }
            }
            ZoomToken zt = new ZoomToken(ApiKey, ApiSecret);

            //1. Find user who is creating the meeting
            //2. Find account that he/she relates to and grab Key and Secret
            //3. Generate Token
            this.MyToken = zt.Token;
        }
Пример #2
0
        private void GetAccountUsers(string ZoomApiKey, string ZoomApiSecret)
        {
            try
            {
                ZoomToken zt    = new ZoomToken(ZoomApiKey, ZoomApiSecret);
                string    Token = zt.Token;

                //Create new Request
                string         BaseUrl          = "https://api.zoom.us/v2/users?status=active&page_size=300&page_number=1";
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(BaseUrl);
                myHttpWebRequest.Method      = "GET";
                myHttpWebRequest.ContentType = "application/json;";
                myHttpWebRequest.Accept      = "application/json;";
                myHttpWebRequest.Headers.Add("Authorization", String.Format("Bearer {0}", Token));

                //Get the associated response for the above request
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
                using (StreamReader MyStreamReader = new StreamReader(myHttpWebResponse.GetResponseStream(), true))
                {
                    this.AccountUsers = JsonConvert.DeserializeObject <AccountUsers>(MyStreamReader.ReadToEnd());
                }

                myHttpWebResponse.Close();
                myHttpWebResponse.Dispose();
            }
            catch (WebException ex)
            {
                int errorCode = (int)((HttpWebResponse)ex.Response).StatusCode;
                if (errorCode != 0)
                {
                    ErrorCode = errorCode;
                    Stream       MyStream       = ex.Response.GetResponseStream();
                    StreamReader MyStreamReader = new StreamReader(MyStream, true);
                    //ZoomErrorResponse zm = JsonConvert.DeserializeObject<ZoomErrorResponse>(MyStreamReader.ReadToEnd());
                    //this.ZoomException = zm;
                    this.ZoomException = JsonConvert.DeserializeObject <ZoomErrorResponse>(MyStreamReader.ReadToEnd());

                    LocalizableString s = GetLocalizableString("ZoomApiErrorMessage");
                    throw new Exception(s);
                }
            }
        }