コード例 #1
0
        public static ShouldDownloadStatus ShouldDownload(XML.indexDump dump)
        {
            string cnnStr = Devmasters.Config.GetWebConfigValue("CnnString");
            string sql    = @"select top 1 * from [DumpData] where mesic = @mesic and rok = @rok and den = @den order by created desc";

            using (var p = new Devmasters.PersistLib())
            {
                var ds = p.ExecuteDataset(cnnStr, System.Data.CommandType.Text, sql, new IDataParameter[] {
                    new System.Data.SqlClient.SqlParameter("den", (int)dump.den),
                    new System.Data.SqlClient.SqlParameter("mesic", (int)dump.mesic),
                    new System.Data.SqlClient.SqlParameter("rok", (int)dump.rok),
                });
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return(ShouldDownloadStatus.Yes);
                }
                DataRow dr      = ds.Tables[0].Rows[0];
                string  oldHash = (string)dr["hash"];

                if (string.IsNullOrEmpty(oldHash))
                {
                    return(ShouldDownloadStatus.Yes);
                }

                if (oldHash != dump.hashDumpu.Value)
                {
                    //if (dump.casGenerovani < DateTime.Now.Date)
                    //    return ShouldDownloadStatus.WaitForData;
                    //else
                    return(ShouldDownloadStatus.Yes);
                }

                return(ShouldDownloadStatus.No);
            }
        }
コード例 #2
0
        public static void SaveDumpProcessed(XML.indexDump dump, DateTime?processed, Exception ex = null)
        {
            string cnnStr = Devmasters.Config.GetWebConfigValue("CnnString");
            string sql    = @"INSERT INTO [dbo].[DumpData]
           ([Created]
           ,[Processed]
           ,[den]
           ,[mesic]
           ,[rok]
           ,[hash]
           ,[velikost]
           ,[casGenerovani], exception)
     VALUES
           (@Created
           ,@Processed
           ,@den
           ,@mesic
           ,@rok
           ,@hash
           ,@velikost
           ,@casGenerovani
            ,@exception)
";

            try
            {
                using (var p = new Devmasters.PersistLib())
                {
                    p.ExecuteNonQuery(cnnStr, System.Data.CommandType.Text, sql, new IDataParameter[] {
                        new System.Data.SqlClient.SqlParameter("created", DateTime.Now),
                        new System.Data.SqlClient.SqlParameter("processed", processed),
                        new System.Data.SqlClient.SqlParameter("den", (int)dump.den),
                        new System.Data.SqlClient.SqlParameter("mesic", (int)dump.mesic),
                        new System.Data.SqlClient.SqlParameter("rok", (int)dump.rok),
                        new System.Data.SqlClient.SqlParameter("hash", dump.hashDumpu.Value),
                        new System.Data.SqlClient.SqlParameter("velikost", (long)dump.velikostDumpu),
                        new System.Data.SqlClient.SqlParameter("casGenerovani", dump.casGenerovani),
                        new System.Data.SqlClient.SqlParameter("exception", ex == null ? (string)null : ex.ToString()),
                    });
                }
            }
            catch (Exception e)
            {
                HlidacStatu.Util.Consts.Logger.Error("SaveDumpProcessed error", e);
            }
        }