예제 #1
0
        /// <summary>
        /// Get Info for an Image
        /// </summary>
        /// <param name="dir">Dirname</param>
        /// <param name="filename">Filename</param>
        /// <returns>Json-String with Imageinformation</returns>
        public bool GetImageInfo(string dir, string filename)
        {
            bool ret = false;

            try
            {
                string filepath = dir + "/" + filename;
                if (dir == "latest")
                {
                    filepath = dir;
                }

                string url;
                url = String.Format(urlGetFileInfo, CameraIP, filepath);

                if (simCamera)
                {
                    Content = File.ReadAllText(@"simfiles\info.txt");
                    ErrCode = "";
                }
                else
                {
                    http.HttpSend(url, "GET", "", out Content, out ErrCode);
                }

                if (!String.IsNullOrEmpty(ErrCode))
                {
                    throw new Exception(ErrCode);
                }
                else
                {
                    PhotoInfo = http.JsonDeserialize <photoinfo>(Content);
                }

                ret          = true;
                LastErrorStr = "";
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    LastErrorStr = String.Format("Error GetImageInfo: {0}", ex.Message);
                }
                else
                {
                    LastErrorStr = String.Format("Error GetImageInfo: {0}, InnerEx: {1}", ex.Message, ex.InnerException.Message);
                }

                log.Error(LastErrorStr);
            }
            return(ret);
        }
예제 #2
0
        /// <summary>
        /// Get Info for an Image
        /// </summary>
        /// <param name="dir">Dirname</param>
        /// <param name="filename">Filename</param>
        /// <returns>Json-String with Imageinformation</returns>
        public bool GetImageInfo(string dir, string filename)
        {
            bool ret = false;

            try
            {
                string filepath = dir + "/" + filename;
                if (dir == "latest") filepath = dir;

                string url;
                url = String.Format(urlGetFileInfo, CameraIP, filepath);

                if (simCamera)
                {
                    Content = File.ReadAllText(@"simfiles\info.txt");
                    ErrCode = "";
                }
                else
                {
                    http.HttpSend(url, "GET", "", out Content, out ErrCode);
                }

                if (!String.IsNullOrEmpty(ErrCode))
                {
                    throw new Exception(ErrCode);
                }
                else
                {
                    PhotoInfo = http.JsonDeserialize<photoinfo>(Content);
                }

                ret = true;
                LastErrorStr = "";
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                    LastErrorStr = String.Format("Error GetImageInfo: {0}", ex.Message);
                else
                    LastErrorStr = String.Format("Error GetImageInfo: {0}, InnerEx: {1}", ex.Message, ex.InnerException.Message);

                log.Error(LastErrorStr);
            }
            return ret;
        }