Example #1
0
        private void K_S2_Init()
        {
            log.Debug("K_S2_Init");

            Filelist  = new filelist();
            Parameter = new parameter();
            CameraIP  = "192.168.0.1";
            simCamera = false;
        }
Example #2
0
        /// <summary>
        /// Gets the filelist from K-S2
        /// </summary>
        /// <returns>success or not</returns>
        public bool GetFilelist()
        {
            bool ret = false;

            try
            {
                string url = String.Format(urlGetFilelist, CameraIP);

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

                if (!String.IsNullOrEmpty(ErrCode))
                {
                    throw new Exception(ErrCode);
                }
                else
                {
                    if ((Filelist.thumbcache != null) && (Filelist.thumbcache.Count > 0))
                    {
                        Dictionary <string, Bitmap> tmp = Filelist.thumbcache;
                        Filelist            = http.JsonDeserialize <filelist>(Content);
                        Filelist.thumbcache = tmp;
                    }
                    else
                    {
                        Filelist            = http.JsonDeserialize <filelist>(Content);
                        Filelist.thumbcache = new Dictionary <string, Bitmap>();
                    }
                }

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

                log.Error(LastErrorStr);
                ret = false;
            }
            return(ret);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ip">Url to load from something like "192.168.0.1"</param>
        /// <param name="filelist">filelist as object</param>
        public Thumbnails(string ip, ref filelist filelist)
        {
            this.ip = ip;
            this.urllist = new List<string>();
            this.filelist = filelist;

            this.thumbsReceived = 0;
            this.thumbsCount = 0;

            //Count all files to fetch
            foreach (dirs d in filelist.dirs)
            {
                foreach (string s in d.files)
                {
                    string filepath = d.name + "/" + s;
                    urllist.Add(filepath);
                }
            }
            this.thumbsCount = urllist.Count;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ip">Url to load from something like "192.168.0.1"</param>
        /// <param name="filelist">filelist as object</param>
        public Thumbnails(string ip, ref filelist filelist)
        {
            this.ip       = ip;
            this.urllist  = new List <string>();
            this.filelist = filelist;

            this.thumbsReceived = 0;
            this.thumbsCount    = 0;

            //Count all files to fetch
            foreach (dirs d in filelist.dirs)
            {
                foreach (string s in d.files)
                {
                    string filepath = d.name + "/" + s;
                    urllist.Add(filepath);
                }
            }
            this.thumbsCount = urllist.Count;
        }
Example #5
0
        /// <summary>
        /// Gets the filelist from K-S2
        /// </summary>
        /// <returns>success or not</returns>
        public bool GetFilelist()
        {
            bool ret = false;

            try
            {
                string url = String.Format(urlGetFilelist, CameraIP);

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

                if (!String.IsNullOrEmpty(ErrCode))
                {
                    throw new Exception(ErrCode);
                }
                else
                {
                    if ((Filelist.thumbcache != null)&&(Filelist.thumbcache.Count >0))
                    {
                        Dictionary<string, Bitmap> tmp = Filelist.thumbcache;
                        Filelist = http.JsonDeserialize<filelist>(Content);
                        Filelist.thumbcache = tmp;
                    }
                    else
                    {
                        Filelist = http.JsonDeserialize<filelist>(Content);
                        Filelist.thumbcache = new Dictionary<string, Bitmap>();
                    }
                }

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

                log.Error(LastErrorStr);
                ret = false;
            }
            return ret;
        }
Example #6
0
        private void K_S2_Init()
        {
            log.Debug("K_S2_Init");

            Filelist = new filelist();
            Parameter = new parameter();
            CameraIP = "192.168.0.1";
            simCamera = false;
        }