Beispiel #1
0
        public static void WriteToError(string _link, string _detail, int _year)
        {
            TheNumbersDataContext dc = new TheNumbersDataContext();

            dc.Errors.InsertOnSubmit(new Error {
                detail = _detail, link = _link.Replace(@"http://www.the-numbers.com/", String.Empty), year = _year
            });
            dc.SubmitChanges();
        }
Beispiel #2
0
        /// <summary>
        /// Write into log.
        /// </summary>
        /// <param name="status">Status of the program</param>
        /// <param name="desc">Default is ""</param>
        public static void WriteToLog(ProgramStatus status, string desc = "")
        {
            string log = "";

            switch (status)
            {
            case ProgramStatus.Error:
                log = "ERROR - " + DateTime.Now;
                break;

            case ProgramStatus.End:
                log = "END - " + DateTime.Now;
                break;

            case ProgramStatus.Start:
                log = "START - " + DateTime.Now;
                break;

            case ProgramStatus.Success:
                log = "SUCCESS - " + DateTime.Now;
                break;

            default:
                break;
            }

            try
            {
                TheNumbersDataContext dc = new TheNumbersDataContext();

                dc.Logs.InsertOnSubmit(new DataModel.Log {
                    LogTime = DateTime.Now, Desc = log
                });
                dc.SubmitChanges();
            }
            catch
            {
                throw;
            }

            return;
        }
Beispiel #3
0
        private void Redownload_Click(object sender, EventArgs e)
        {
            TheNumbersDataContext dc = new TheNumbersDataContext();
            var errors = dc.Errors.DistinctBy(x => x.link);

            foreach (var error in errors)
            {
                dc.ExecuteCommand("TRUNCATE TABLE [dbo].[log]"); // clears the log first.
                SingleMovieLink tempsml = new SingleMovieLink(error.link, error.year);
                dc.Connection.Close();
                tempsml.GetMovie();
                if (dc.Connection.State.Equals(ConnectionState.Closed))
                {
                    dc.Connection.Open();
                }
                if (!dc.IsThereAnyError())
                {
                    var tempdelete = dc.Errors.Where(err => err.link.Equals(error.link));
                    dc.Errors.DeleteAllOnSubmit(tempdelete);
                    dc.SubmitChanges();
                }
            }
        }