Exemple #1
0
        public ActionResult Index()
        {
            ViewBag.IsClientValidationEnabled = ConfigSetGet.GetConfigData("ClientValidationEnabled").Equals("true", StringComparison.OrdinalIgnoreCase);
            var list = _productService.GetAllProductsIncludeCategory();

            return(View(list));
        }
Exemple #2
0
 public OpenSubtitlesXmlRpc(string movieFileName)
 {
     _movieFileName            = movieFileName;
     _client                   = XmlRpcProxyGen.Create <IOpenSubtitlesDb>();
     _client.Expect100Continue = false;
     _client.UserAgent         = "SubtitleTools";
     _client.Url               = ConfigSetGet.GetConfigData("OpensubtitlesOrgApiUri");
 }
 static AppConfig()
 {
     bool.TryParse(ConfigSetGet.GetConfigData("UseRandomImages"), out _useRandomImages);
     bool.TryParse(ConfigSetGet.GetConfigData("ShowPastHolidays"), out _showPastHolidays);
     int.TryParse(ConfigSetGet.GetConfigData("CalendarFontSize"), out _calendarFontSize);
     int.TryParse(ConfigSetGet.GetConfigData("CopyrightFontSize"), out _copyrightFontSize);
     int.TryParse(ConfigSetGet.GetConfigData("HolidaysFontSize"), out _holidaysFontSize);
     CalendarFontFileName = ConfigSetGet.GetConfigData("CalendarFontFileName");
     CopyrightFontName    = ConfigSetGet.GetConfigData("CopyrightFontName");
 }
        private static LastDownalodResult getImage(string dir)
        {
            var images = new DirectoryInfo(dir).GetFiles("*.jpg");

            if (!images.Any())
            {
                return(null);
            }

            FileInfo lastImage;
            var      useRandomImages = ConfigSetGet.GetConfigData("UseRandomImages");

            if (!string.IsNullOrWhiteSpace(useRandomImages) &&
                useRandomImages.Equals("true", StringComparison.InvariantCultureIgnoreCase))
            {
                var rnd = new Random();
                lastImage = images[rnd.Next(0, images.Length - 1)];
            }
            else
            {
                lastImage = images.OrderByDescending(fileInfo => fileInfo.LastWriteTime).FirstOrDefault();
                if (lastImage == null)
                {
                    return(null);
                }
            }

            var image     = lastImage.FullName;
            var xmlFile   = $"{image}.xml";
            var copyright = "";

            if (!File.Exists(xmlFile))
            {
                xmlFile = $"{image.Split('_').First()}.xml";
            }

            if (File.Exists(xmlFile))
            {
                try
                {
                    var info = XmlUtils.FromXmlFile <images>(xmlFile);
                    copyright = info.image.copyright;
                }
                catch { }
            }

            return(new LastDownalodResult
            {
                ImageFileName = image,
                Copyright = copyright,
                XmlFileName = ""
            });
        }
Exemple #5
0
        private static string tryDownloadRss()
        {
            var rssXml = string.Empty;

            try
            {
                var url = ConfigSetGet.GetConfigData("ProjectRSSFeed");
                rssXml = Downloader.FetchWebPage(url);
            }
            catch (Exception ex)
            {
                if (!ex.Message.Contains("The remote name could not be resolved"))
                {
                    ExceptionLogger.LogExceptionToFile(ex);
                    LogWindow.AddMessage(LogType.Error, ex.Message);
                }
            }
            return(rssXml);
        }
Exemple #6
0
        private DatabaseLogger()
        {
            AppDomain.MonitoringIsEnabled = true;
            var logger        = new ExceptionLogger();
            var baseInfoQueue = new InfoQueue <BaseInfo>();

            Profiler = new DbProfiler(baseInfoQueue)
            {
                AssembliesToExclude = new SortedSet <string>
                {
                    typeof(DbProfiler).Assembly.GetName().Name,
                    typeof(DatabaseLogger).Assembly.GetName().Name
                }
            };
            var serverUri           = new Uri(ConfigSetGet.GetConfigData("DNTProfilerServerUri"));
            var logFilePath         = ConfigSetGet.GetConfigData("DNTProfilerLogFilePath");
            var commandsTransmitter = new CommandsTransmitter(
                baseInfoQueue, logger, new SimpleHttp(), serverUri, LoggerPath.GetLogFileFullPath(logFilePath));

            commandsTransmitter.Start();
        }
        public MainWindowViewModel()
        {
            GuiModelData = new GuiModel
            {
                GitHubToken = ConfigSetGet.GetConfigData("GitHubToken")
            };
            GuiModelData.PropertyChanged += guiModelDataPropertyChanged;

            _gitHubDownloader = new GitHubDownloader(GuiModelData)
            {
                Finished = url =>
                {
                    addLog(string.Format("Finished {0}.", url));
                    _isStarted = false;
                }
            };

            StartCommand = new DelegateCommand <string>(doStart, canDoStart);
            StopCommand  = new DelegateCommand <string>(doStop, stat => true);

            AppMessenger.Messenger.Register <string>("ShowLog", log => addLog(log));
            manageAppExit();
        }
 private void loadConfig()
 {
     GuiModelData.ServerUri = ConfigSetGet.GetConfigData("ServerUri");
     GuiModelData.AllowRemoteConnections = bool.Parse(ConfigSetGet.GetConfigData("AllowRemoteConnections"));
 }
Exemple #9
0
 private void loadSettings()
 {
     GuiData.RunOnStartup = bool.Parse(ConfigSetGet.GetConfigData("RunOnStartup"));
 }
Exemple #10
0
        public string UploadSubtitle(long userImdbId, string subLanguageId, string subFileNamePath, Action <int> progress)
        {
            string finalUrl;

            subFileNamePath = new ChangeEncoding().TryReduceRtlLargeFileContent(subFileNamePath);
            var fileInfo = new MovieFileInfo(_movieFileName, subFileNamePath);

            //login
            if (progress != null)
            {
                progress(10);
            }

            LogWindow.AddMessage(LogType.Info, "TryLogin ...");
            tryLogin();

            if (progress != null)
            {
                progress(25);
            }

            LogWindow.AddMessage(LogType.Info, "TryUploadSubtitle ...");

            TryUploadResult res = null;

            try
            {
                res = _client.TryUploadSubtitles(_loginToken,
                                                 new[]
                {
                    new TryUploadInfo
                    {
                        subhash       = fileInfo.SubtitleHash,
                        subfilename   = fileInfo.SubFileName,
                        moviehash     = fileInfo.MovieHash,
                        moviebytesize = fileInfo.MovieFileLength,
                        moviefilename = fileInfo.MovieFileName
                    }
                }
                                                 );
            }
            catch (Exception ex)
            {
                if (!processNewMovieFile(ref userImdbId, fileInfo, ref res, ex))
                {
                    throw;
                }
            }

            if (res == null)
            {
                throw new InvalidOperationException("Bad response ...");
            }

            if (progress != null)
            {
                progress(50);
            }

            if (res.status != "200 OK")
            {
                throw new Exception("Bad response ...");
            }

            if (res.alreadyindb == 0)
            {
                if ((userImdbId == 0) && (res.data == null || res.data.Length == 0))
                {
                    throw new Exception("Bad format ...");
                }

                LogWindow.AddMessage(LogType.Info, string.Format("CheckSubHash({0})", fileInfo.SubtitleHash));
                var checkSubHashRes = _client.CheckSubHash(_loginToken, new[] { fileInfo.SubtitleHash });

                if (progress != null)
                {
                    progress(75);
                }

                var idSubtitleFile = int.Parse(checkSubHashRes.data[fileInfo.SubtitleHash].ToString());
                if (idSubtitleFile > 0)
                {
                    throw new Exception("Duplicate subHash, alreadyindb.");
                }

                LogWindow.AddMessage(LogType.Info, "PostData ...");
                //xml-rpc.net dll does not work here so, ...
                var post = PostXml.PostData(
                    ConfigSetGet.GetConfigData("OpensubtitlesOrgApiUri"),
                    UploadData.CreateUploadXml(_loginToken,
                                               new UploadBaseinfo
                {
                    idmovieimdb      = res.data != null ? res.data[0]["IDMovieImdb"].ToString() : userImdbId.ToString(),
                    sublanguageid    = subLanguageId,
                    movieaka         = string.Empty,
                    moviereleasename = fileInfo.MovieReleaseName,
                    subauthorcomment = string.Empty
                },
                                               new UploadCDsInfo
                {
                    moviebytesize = fileInfo.MovieFileLength.ToString(),
                    moviefilename = fileInfo.MovieFileName,
                    moviehash     = fileInfo.MovieHash,
                    subfilename   = fileInfo.SubFileName,
                    subhash       = fileInfo.SubtitleHash,
                    subcontent    = fileInfo.SubContentToUpload,
                    moviefps      = string.Empty,
                    movieframes   = string.Empty,
                    movietimems   = string.Empty
                }));

                LogWindow.AddMessage(LogType.Info, "Done!");
                finalUrl = RegexHelper.GetUploadUrl(post);
                LogWindow.AddMessage(LogType.Announcement, string.Format("Url: {0}", finalUrl));
            }
            else
            {
                throw new Exception("Duplicate file, alreadyindb");
            }

            if (progress != null)
            {
                progress(100);
            }
            return(finalUrl.Trim());
        }