예제 #1
0
        public static int StartFileDownload(PackageFileLog file)
        {
            int result = 0;
            StringBuilder strSql = new StringBuilder();

            //if (string.IsNullOrEmpty(file.StartDateTime.tos))
            //    file.StartDateTime = DateTime.Now;
            // Changed By JK and AJ. Added PackageDetailId to make sure unique record gets updated.
            strSql.AppendFormat("Update [tblPackageDetails] Set StartDateTime = '{0}', Complete = '{1}' Where DownloadDetailId = '{2}' and PackageDetailId = '{3}'",
                FormatDateTime(DateTime.Now), false, file.DownloadDetailId, file.PackageDetailId);

            if (log.IsInfoEnabled) log.Info(" sql query is:" + strSql);

            try
            {
                Open(strConnectionString);
                SqlCeCommand command = new SqlCeCommand(strSql.ToString());
                if (log.IsInfoEnabled) log.Info("Start File Download " + strSql);
                result = ExecuteNonQuery(command);

                if (result > 0)
                    if (log.IsInfoEnabled) log.Info(string.Format("Downlaod File Details {0} successfull.. for Download Detail Id.. ", file.DownloadDetailId));
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.AddFileDetails.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit

            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error("Generic Exception caught in  DBLogger.AddPackage.." + ex.Message);

            }

            return result;
        }
예제 #2
0
        private static PackageFileLog SelectPackageCommandInfo(string strSql)
        {
            if (log.IsInfoEnabled) log.Info("SelectPackage started..");
            PackageFileLog pkginfo = null;
            try
            {
                Open(strConnectionString);
                pkginfo = new PackageFileLog();
                SqlCeCommand command = new SqlCeCommand(strSql);
                SqlCeDataReader reader = ExecuteReader(command);

                while (reader.Read())
                {

                    pkginfo.PackageId = Convert.ToInt32(reader["PackageId"].ToString());
                    pkginfo.CommandExecuted = reader["CommandExecuted"] != null ? Convert.ToBoolean(reader["CommandExecuted"].ToString()) : false;
                    pkginfo.ExecutionDatetime = reader["ExecutionDatetime"] != null ? Convert.ToDateTime(reader["ExecutionDatetime"]) : DateTime.Now;
                    pkginfo.IssuedDatetime = reader["IssuedDatetime"] != null ? Convert.ToDateTime(reader["IssuedDatetime"]) : DateTime.Now;
                    pkginfo.QueueId = reader["QueueId"] != null ? Convert.ToInt32(reader["QueueId"].ToString()) : 0;

                    break;
                }
                reader.Close();
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.SelectPackage.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error("Generic exception caught in SelectPackage .." + ex.Message);
            }

            if (log.IsInfoEnabled) log.Info("SelectPackage ended..");

            return pkginfo;
        }
예제 #3
0
        public static List<PackageFileLog> GetNotDownloadedContent()
        {
            int result = 0;
            SqlCeDataReader dr;
            List<PackageFileLog> packglist = new List<PackageFileLog>();
            StringBuilder strSql = new StringBuilder();

            //strSql.Append("Select * from tblPackageDetails Where Complete = 'False'");
            strSql.Append("SELECT tblPackageMaster.KioskPackageId, tblPackageMaster.PackageId, tblPackageMaster.ReleaseVersion, tblPackageMaster.Deployed, tblPackageMaster.PlannedActivationDttm, tblPackageMaster.ActualActivationDttm, tblPackageMaster.Downloaded, tblPackageMaster.CommandIssued,  tblPackageDetails.PackageDetailId, tblPackageDetails.FileName, tblPackageDetails.FilePath, tblPackageDetails.FileType, tblPackageDetails.FileSize, tblPackageDetails.Complete,  tblPackageDetails.StartDateTime, tblPackageDetails.EndDateTime, tblPackageDetails.DownloadDetailId, tblPackageDetails.PkgDetId FROM tblPackageDetails INNER JOIN tblPackageMaster ON tblPackageDetails.PackageId = tblPackageMaster.PackageId Where Downloaded = 'False' order by KioskPackageId");

            try
            {
                Open(strConnectionString);
                SqlCeCommand command = new SqlCeCommand(strSql.ToString());
                dr = ExecuteReader(command);

                while (dr.Read())
                {
                    PackageFileLog pkg = new PackageFileLog();
                    pkg.KioskPackageId = Convert.ToInt32(dr["KioskPackageId"]);
                    pkg.PackageId = Convert.ToInt32(dr["PackageId"]);
                    pkg.FileName = Convert.ToString(dr["FileName"]);
                    pkg.FilePath = Convert.ToString(dr["FilePath"]);
                    pkg.FileType = Convert.ToString(dr["FileType"]);
                    pkg.FileSize = Convert.ToString(dr["FileSize"]);
                    pkg.Complete = Convert.ToBoolean(dr["Complete"]);
                    pkg.StartDateTime = Convert.ToDateTime(dr["StartDateTime"]);
                    //pkg.EndDateTime = Convert.ToDateTime(dr["EndDateTime"]);
                    pkg.DownloadDetailId = Convert.ToInt32(dr["DownloadDetailId"]);
                    pkg.PkgDetId = Convert.ToInt32(dr["PkgDetId"]);
                    pkg.ReleaseVersion = Convert.ToString(dr["ReleaseVersion"]);
                    pkg.PackageDetailId = Convert.ToInt32(dr["PackageDetailId"]);
                    packglist.Add(pkg);
                }
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.Get Package Details.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit

            }
            return packglist;
        }
예제 #4
0
        private static PackageFileLog SelectPackage(string strSql)
        {
            if (log.IsInfoEnabled) log.Info("SelectPackage started..");
            PackageFileLog pkginfo = null;
            try
            {

                Open(strConnectionString);

                //new

                SqlCeCommand getdate = new SqlCeCommand("select getdate()");
                SqlCeDataReader readerdate = ExecuteReader(getdate);

                while (readerdate.Read())
                {
                    string result = readerdate.GetValue(0).ToString();
                    if (log.IsInfoEnabled) log.Info("result getdate():" + result);

                }
                readerdate.Close();

                SqlCeCommand a1 = new SqlCeCommand("Select  PlannedActivationDttm from tblPackageMaster where  Deployed='false' and PackageStatus='2' and CommandIssued='false' order  by PlannedActivationDttm");
                SqlCeDataReader dr = ExecuteReader(a1);

                while (dr.Read())
                {
                    string result1 = dr.GetValue(0).ToString();
                    if (log.IsInfoEnabled) log.Info("result PlannedActivationDttm:" + result1);
                    break;

                }
                dr.Close();

                //new end

                pkginfo = new PackageFileLog();
                SqlCeCommand command = new SqlCeCommand(strSql);
                SqlCeDataReader reader = ExecuteReader(command);

                while (reader.Read())
                {
                    if (log.IsInfoEnabled) log.Info("Reading Started...");
                    pkginfo.PackageId = Convert.ToInt32(reader["PackageId"].ToString());
                    pkginfo.ReleaseVersion = reader["ReleaseVersion"].ToString();
                    if (log.IsInfoEnabled) log.Info("Reading Ended...");
                    break;
                }
                reader.Close();
            }
            catch (SqlCeException ex)
            {
                if (log.IsErrorEnabled) log.Error("SqlCeException caught in DBLogger.SelectPackage.." + ex.Message);
                Close();
                //System.Environment.Exit(1);  //  exit
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled) log.Error("Generic exception caught in SelectPackage .." + ex.Message);
            }

            if (log.IsInfoEnabled) log.Info("SelectPackage ended..");

            return pkginfo;
        }