コード例 #1
0
        /// <summary>
        /// Get current IP Camera's time zone and time.
        /// </summary>
        /// <returns></returns>
        void GetTime(out DateTime timeUtc, out TimeZoneInfo timeZone, out string ntpServer, out bool useNtp)
        {
            ///GetTime.cgi[?JsVar=variable[&OnJs=function]]
            timeUtc   = DateTime.MinValue;
            timeZone  = TimeZoneInfo.Local;
            ntpServer = "";
            useNtp    = false;

            RovioResponse dic = this.Request("/GetTime.cgi");

            if (dic == null)
            {
                return;
            }
            long sec1970;

            if (!(dic.ContainsKey("Sec1970") && long.TryParse(dic["Sec1970"], out sec1970)))
            {
                return;
            }
            int timeZoneMinutes;

            if (!(dic.ContainsKey("TimeZone") && int.TryParse(dic["TimeZone"], out timeZoneMinutes)))
            {
                return;
            }

            DateTime date1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            timeUtc  = date1970.AddSeconds(sec1970);
            timeZone = CreateTimeZone(TimeSpan.FromMinutes(-timeZoneMinutes));

            ntpServer = dic.ContainsKey("NtpServer") ? dic["NtpServer"] : "";
            useNtp    = dic.ContainsKey("UseNtp") ? (dic["UseNtp"] == "1") : false;
        }
コード例 #2
0
ファイル: RovioAPI.Users.cs プロジェクト: sunsunsun000/rovio
        /// <summary>
        /// Get the username who sent this HTTP request.
        /// </summary>
        /// <param name="ShowPrivilege"></param>
        /// <returns>Privilege = 0 (for common user),Privilege = 1 (for super user),(Always returns 0 if it is in Non-authorization mode under SetUserCheck.cgi)</returns>
        public UserInformation GetMyself(bool ShowPrivilege)
        {
            RovioResponse response = this.Request("/GetMyself.cgi",
                                                  new RequestItem("ShowPrivilege", ShowPrivilege ? 1 : 0));

            UserGroups group = UserGroups.Unknown;

            if (response.ContainsKey("Privilege"))
            {
                if (response["Privilege"] == "1")
                {
                    group = UserGroups.Administrator;
                }
                else if (response["Privilege"] == "0")
                {
                    group = UserGroups.User;
                }
                else
                {
                    group = UserGroups.Unknown;
                }
            }

            UserInformation info = new UserInformation(
                group, response["Name"]);

            return(info);
        }
コード例 #3
0
        /// <summary>
        /// Get camera's name.
        /// </summary>
        /// <returns></returns>
        public string GetName()
        {
            RovioResponse response = this.Request("/GetName.cgi");

            if (response == null || !response.ContainsKey("CameraName"))
            {
                return(null);
            }

            return(response["CameraName"]);
        }