Example #1
0
        /// <summary>
        /// method returns the ImageWeb data
        /// </summary>
        /// <param name="pathToGallery">path to the gallery</param>
        /// <returns>ImageWeb data</returns>
        public ImageWebData GetImageWebData(string pathToGallery)
        {
            SynchTcpClientHandler commChannel = new SynchTcpClientHandler();
            ImageWebData          webData;
            bool isConnected = commChannel.IsConnected;
            int  numberOfPics;

            if (pathToGallery != null && pathToGallery != "")
            {
                try
                {
                    numberOfPics = Directory.GetFiles(pathToGallery, "*.*", SearchOption.AllDirectories).Length;
                }
                catch
                {
                    numberOfPics = 0;
                }
            }
            else
            {
                numberOfPics = 0;
            }
            string[]      nameStrings = File.ReadAllLines(HttpContext.Current.Server.MapPath("/App_Data/Names.txt"));
            string[]      idStrings   = File.ReadAllLines(HttpContext.Current.Server.MapPath("/App_Data/Ids.txt"));
            List <string> names       = nameStrings.ToList <String>();
            List <string> ids         = idStrings.ToList <String>();

            webData = new ImageWebData {
                IsConnected = isConnected, NumberOfPics = numberOfPics, Names = names, IDs = ids
            };

            commChannel.Close();

            return(webData);
        }
Example #2
0
        /// <summary>
        /// method that returns the config data from the service
        /// </summary>
        /// <returns>config data</returns>
        public ConfigData GetConfig()
        {
            try
            {
                ConfigData            cData       = new ConfigData();
                string[]              args        = new string[1];
                SynchTcpClientHandler commChannel = new SynchTcpClientHandler();
                this.commConfigCommand = new ServerClientCommunicationCommand(CommandEnum.GetConfigCommand, args);

                string message = commChannel.Send(this.commConfigCommand.ToJson());
                ServerClientCommunicationCommand commCommand = ServerClientCommunicationCommand.FromJson(message);
                if (commCommand.CommId == CommandEnum.GetConfigCommand)
                {
                    string  jsonData      = commCommand.Args[0];
                    JObject appConfigData = JObject.Parse(jsonData);
                    cData.OutputDirectory = (string)appConfigData["OutputDir"];
                    cData.SourceName      = (string)appConfigData["SourceName"];
                    cData.LogName         = (string)appConfigData["LogName"];
                    cData.ThumbnailSize   = (string)appConfigData["ThumbnailSize"];
                    string dirPathsListString = (string)appConfigData["dirPathsToManageListString"];
                    cData.DirectoryHandlerPaths = new List <string>(JsonConvert.DeserializeObject <List <string> >(dirPathsListString));
                    commChannel.Close();
                    return(cData);
                }
                else
                {
                    commChannel.Close();
                    return(new ConfigData()
                    {
                        LogName = "", SourceName = "", ThumbnailSize = "", OutputDirectory = "", DirectoryHandlerPaths = new List <string>()
                    });
                }
            }
            catch
            {
                return(new ConfigData()
                {
                    LogName = "", SourceName = "", ThumbnailSize = "", OutputDirectory = "", DirectoryHandlerPaths = new List <string>()
                });
            }
        }