Ejemplo n.º 1
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: retrieve many ScheduleDetail with workstation id and schedule date
 /// </summary>
 /// <param name="pintScheduleDetailID">int</param>
 //public DataSet CreateSchedule(ScheduleDetail pScheduleDetail)
 //{
 //    PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
 //    try
 //    {
 //        Open();
 //        ScheduleDetail.CreateSchedule(pScheduleDetail);
 //        Commit();
 //        return ScheduleDetail.Search(pScheduleDetail.WorkstationId, pScheduleDetail.ScheduleDate);
 //    }
 //    catch (Exception exp)
 //    {
 //        Rollback();
 //        throw exp;
 //    }
 //    finally
 //    {
 //        Close();
 //    }
 //}
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: wrilte download log
 /// </summary>
 /// <param name="pintScheduleDetailID">int</param>
 public void CheckDownloaded(DataRowCollection pDataRowsColl, int pintWorkstationID, DateTime pdteDateTime)
 {
     PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
     ScheduleDetail pScheduleDetail = new ScheduleDetail();
     pScheduleDetail.WorkstationId = pintWorkstationID;
     pScheduleDetail.ScheduleDate = pdteDateTime;
     try
     {
         Open();
         foreach (DataRow row in pDataRowsColl)
         {
             pScheduleDetail.ScheduleId = (int) row["SCHEDULE_ID"];
             pScheduleDetail.Downloaded = (byte) row["DOWNLOADED"];
             if (pScheduleDetail.Downloaded == 1)
                 ScheduleDetail.CheckDownloaded(pScheduleDetail);
         }
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/07/2008
        /// @Description: Update 1 ScheduleDetail with ScheduleDetail_id
        /// </summary>
        /// <param name="pScheduleDetail">ScheduleDetail</param>
        //public int CreateSchedule(ScheduleDetail pScheduleDetail)
        //{
        //    IDbDataParameter[] parameters = {
        //        MakeParameter("@workstation_id", DbType.Int32, 4),
        //        MakeParameter("@schedule_date", DbType.Date, 8),
        //    };
        //    parameters[0].Value = pScheduleDetail.WorkstationId;
        //    parameters[1].Value = pScheduleDetail.ScheduleDate;
        //    int rowAffected = 0;
        //    RunProcedure("sp_Init_Download_Schedule", parameters, out rowAffected);
        //    return rowAffected;
        //}
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/07/2008
        /// @Description: Write download log in schedule detail
        /// </summary>
        /// <param name="pScheduleDetail">ScheduleDetail</param>
        public bool CheckDownloaded(ScheduleDetail pScheduleDetail)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@Workstation_ID", DbType.Int32, 32),
                MakeParameter("@schedule_id", DbType.Int32, 32),
                MakeParameter("@schedule_date", DbType.DateTime, 18),
                MakeParameter("@hasdownloaded", DbType.Int16, 16),
            };

            parameters[0].Value = pScheduleDetail.WorkstationId;
            parameters[1].Value = pScheduleDetail.ScheduleId;
            parameters[2].Value = pScheduleDetail.ScheduleDate;
            parameters[3].Value = pScheduleDetail.Downloaded;

            int rowAffected = RunProcedure("sp_ADV_SCHEDULE_DETAIL_DOWNLOADED", parameters, out rowAffected);
            return (rowAffected == 1);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: wrilte download log
 /// </summary>
 /// <param name="pintScheduleDetailID">int</param>
 public bool CheckDownloaded(ScheduleDetail pScheduleDetail)
 {
     PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
     try
     {
         Open();
         bool bln = ScheduleDetail.CheckDownloaded(pScheduleDetail);
         Commit();
         return bln;
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// @author : KhoaHT
        /// @CreateDate:10/07/2008
        /// @Description: Load schedule if offline
        /// </summary>
        private void BindingGridOffline()
        {
            DataSet ds = new   DataSet();
            ds.ReadXmlSchema("schema.xsd");
            ds.ReadXml("Schedule.xml");
            try
            {
                // Get data view and bind to grid
                ScheduleDetail scheduleDetail = new ScheduleDetail();
                scheduleDetail.WorkstationId = Properties.Settings.Default.WorkstationId;
                scheduleDetail.ScheduleDate = mdteScheduleDate.Value;
                mdteSearh = scheduleDetail.ScheduleDate;

                // Set data to grid
               // DataSet ds = mbScheduleDetail.GetFromScheduleForWorkstation(scheduleDetail);
                bool blnReturn = BindingGridOffline(ds.Tables[0].DefaultView);
            }
            catch (Exception)
            {
                // NOT NEED TODO
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// @author : KhoaHT
        /// @CreateDate:04/03/2008
        /// @Description: load data into grid
        /// </summary>
        public bool BindingGrid()
        {
            if ((Global.Workstation == null) || (Global.Workstation.WorkstationId < 0))
                return false;
            try
            {
                // Get data view and bind to grid
                ScheduleDetail scheduleDetail = new ScheduleDetail();
                scheduleDetail.WorkstationId = Global.Workstation.WorkstationId;
                scheduleDetail.ScheduleDate = mdteScheduleDate.Value;
                mdteSearh = scheduleDetail.ScheduleDate;

                // Set data to grid
                DataSet ds = mbScheduleDetail.GetFromScheduleForWorkstation(scheduleDetail);
                bool blnReturn = BindingGrid(ds.Tables[0].DefaultView);
                // Etablish button status
                SetButtonStatus();
                // Save schedule
                SaveSchedule(ds);
                 GenSTT();
                return blnReturn;
            }
            catch (Exception exp)
            {
                SetButtonStatus();
                QTCMessageBox.Show(this, exp, "ERROR");
                return false;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// @author : TrungMT
        /// @CreateDate:04/07/2008
        /// @Description: Update 1 ScheduleDetail with ScheduleDetail_id
        /// </summary>
        /// <param name="pScheduleDetail">ScheduleDetail</param>
        public int Update(ScheduleDetail pScheduleDetail)
        {
            IDbDataParameter[] parameters = {
                MakeParameter("@schedule_id", DbType.Int32, 4),
                MakeParameter("@workstation_id", DbType.Int32, 4),
                MakeParameter("@schedule_date", DbType.DateTime, 18),
                MakeParameter("@clip_id", DbType.Int32, 4),
                MakeParameter("@freq", DbType.Byte, 8),
                MakeParameter("@downloaded", DbType.Int16, 8),
                MakeParameter("@status", DbType.Byte, 8)
            };

            parameters[0].Value = pScheduleDetail.ScheduleId;
            parameters[1].Value = pScheduleDetail.WorkstationId;
            parameters[2].Value = pScheduleDetail.ScheduleDate;
            parameters[3].Value = pScheduleDetail.ClipId;
            parameters[4].Value = pScheduleDetail.Freq;
            parameters[5].Value = pScheduleDetail.Downloaded;
            parameters[6].Value = pScheduleDetail.Status;
            int rowAffected = 0;
            RunProcedure("sp_ADV_Schedule_Detail_UPDATE", parameters, out rowAffected);
            return rowAffected;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// @author : KhoaHT
        /// @CreateDate:04/07/2008
        /// @Description: Processing upload clip to ftp server
        /// </summary>
        public override void Process()
        {
            try
            {
                int i = 0;
                //mftpConnection = QTC.Adv.BusinessModule.Global.
                mftpConnection = QTC.Adv.BusinessModule.Global.MakeFTPDownloadConnection();
                mftpConnection.BufferLength = 230400;
                mftpConnection.OpenConnection();

                ScheduleDetail pScheduleDetail = new ScheduleDetail();
                // Define how long to download
                int intLength = 0;
                // if download only one rows
                if (mRow != null)
                    intLength = 1;
                // Or many rows
                else
                    intLength = (mScheduleDetails == null) ? mRowCollection.Count : mScheduleDetails.Length;

                while (i < intLength)
                {
                    if (Cancel)
                        return;
                    if (!Pause)
                    {
                        if (mScheduleDetails != null)
                            pScheduleDetail = mScheduleDetails[i];
                        else if (mRowCollection != null)
                        {
                            pScheduleDetail.ClipId = (int)mRowCollection[i]["CLIP_ID"];
                            pScheduleDetail.URL = (string)mRowCollection[i]["URL"];
                            pScheduleDetail.FileName = (string)mRowCollection[i]["File_Name"];
                            pScheduleDetail.Downloaded = (byte)mRowCollection[i]["DOWNLOADED"];
                            pScheduleDetail.ScheduleId = (int)mRowCollection[i]["SCHEDULE_ID"];
                            // if downloaded one time, stop download
                            if (mclipStatus.IsDownloaded(pScheduleDetail.FileName))
                            {
                                mRowCollection[i]["DOWNLOADED"] = (byte) 1;
                                pScheduleDetail.Downloaded = 1;
                            }

                            pScheduleDetail.Code = (string)mRowCollection[i]["CODE"];
                            pScheduleDetail.Name = (string)mRowCollection[i]["NAME"];
                        }
                        else
                        {
                            pScheduleDetail.ClipId = (int)mRow["CLIP_ID"];
                            pScheduleDetail.URL = (string)mRow["URL"];
                            pScheduleDetail.FileName = (string)mRow["File_Name"];
                            pScheduleDetail.Downloaded = 0;
                            pScheduleDetail.Code = (string)mRow["CODE"];
                            pScheduleDetail.Name = (string)mRow["NAME"];
                            pScheduleDetail.ScheduleId = (int)mRow["SCHEDULE_ID"];
                        }

                        pScheduleDetail.ScheduleDate = mDateTime;
                        pScheduleDetail.WorkstationId = mWorkstationID;
                        // write a log that this clip has been downloaded
                        if (pScheduleDetail.Downloaded == 1)
                        {
                            mbScheduleDetail.CheckDownloaded(pScheduleDetail);
                        }
                        // download only if have'nt downloaded
                        if (pScheduleDetail.Downloaded == 0)
                        {
                            if (DownloadOneFile(pScheduleDetail))
                            {
                                pScheduleDetail.Downloaded = 1;
                                mbScheduleDetail.CheckDownloaded(pScheduleDetail);
                                if (mScheduleDetails != null)
                                {
                                    mclipStatus.SetDownloaded(pScheduleDetail.FileName);
                                    pScheduleDetail.Downloaded = 1;
                                }
                                else if (mRowCollection != null)
                                {
                                    mclipStatus.SetDownloaded((string)mRowCollection[i]["File_Name"]);
                                    mRowCollection[i]["DOWNLOADED"] = 1;
                                }
                                else
                                {
                                    mclipStatus.SetDownloaded((string)mRow["File_Name"]);
                                    mRow["DOWNLOADED"] = 1;
                                }
                            }
                        }
                        i++;
                        SetOverallValue(i);
                        //Thread.Sleep(100);
                    }
                }
            }
            catch (Exception exp)
            {
                QTCMessageBox.Show(this, exp, "");
                return;
            }
            finally
            {
                // Release connection
                mftpConnection.ReleaseConnection();
                CloseForm();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// @author : KhoaHT
        /// @CreateDate:04/07/2008
        /// @Description: Upload 1 clip
        /// </summary>
        /// <param name="pClip">Clip</param>
        private bool DownloadOneFile(ScheduleDetail pScheduleDetail)
        {
            try
            {
                //// Clear the url stored to db, just wait until file update okie
                String pstrLocalFilePath = Properties.Settings.Default.ClipPath + "\\";
                SetProcessingLabel("Downloading: " + pScheduleDetail.Code + "-" + pScheduleDetail.Name + " - " + pScheduleDetail.FileName);
                ////pClip.URL = "";

                //// Get local file infor
                //FileInfo fileInfo = new FileInfo(pstrLocalFilePath);
                //// check is file exists
                //if (!fileInfo.Exists)
                //    throw new Exception("Không tìm thấy file để tải lên server.");

                // Uploading percentage is 0%
                SetProcessingValue(0);

                // Get file size init for update, and init total uploaded is 0 bytes
                long lFileSize = mftpConnection.GetFileSize(pScheduleDetail.URL);
                //long lFileSize = 0;
                mftpConnection.InitStreamToDownload(pScheduleDetail.URL, pstrLocalFilePath + pScheduleDetail.FileName);
                int intDownloaded = 0;
                long lTotalDownloaded = 0;
                if (lFileSize <= 0)
                {
                    SetProcessingStyle(ProgressBarStyle.Marquee);
                    SetProcessingValue(100);
                }
                else
                {
                    SetProcessingStyle(ProgressBarStyle.Blocks);
                }

                do
                {
                    // but if pause click, don't download any content
                    if (Pause)
                        continue;
                    if (Cancel)
                        return false;

                    // Upload each part of content depend on buffer size
                    intDownloaded = mftpConnection.DownloadPartOfContent();
                    if (lFileSize > 0)
                    {
                        lTotalDownloaded += intDownloaded;
                        // Update processing percentage.
                        SetProcessingValue((int)((lTotalDownloaded * 100) / lFileSize));
                    }
                } while (intDownloaded > 0);
                return true;
                //mbScheduleDetail.
            }
            catch (Exception exp)
            {
                //Message.Show(exp.Message);
                //QTCMessageBox.Show(this, exp, "ERROR");
                mclipStatus.SetExceptionMsg(pScheduleDetail.FileName, "Lỗi khi download, hãy liên hệ với quản trị:\n" + exp.Message);
                return false;
                //throw exp;
                //Close();
            }
            finally
            {
                // release stream after using
                mftpConnection.ReleaseStream();
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// @author : KhoaHT
 /// @CreateDate:04/07/2008
 /// @Description: Set clips arrau to download
 /// </summary>
 /// <param name="pClips">Clip[]</param>
 public void SetDownloadClip(ScheduleDetail[] pScheduleDetails)
 {
     mScheduleDetails = pScheduleDetails;
     mRowCollection = null;
     mRow = null;
     OverallMax = mScheduleDetails.Length;
     OverallMin = 0;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: Update 1 ScheduleDetail with ScheduleDetail_id
 /// </summary>
 public int Update(ScheduleDetail pScheduleDetail)
 {
     PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
     int intRowAffected = 0;
     try
     {
         Open();
         intRowAffected = ScheduleDetail.Update(pScheduleDetail);
         Commit();
     }
     catch (Exception exp)
     {
         Rollback();
         throw exp;
     }
     finally
     {
         Close();
     }
     return intRowAffected;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: retrieve many ScheduleDetail with workstation id and schedule date
 /// </summary>
 /// <param name="pintScheduleDetailID">int</param>
 public DataSet RetrievesAll(ScheduleDetail pScheduleDetail)
 {
     PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
     try
     {
         Open();
         return ScheduleDetail.Search(pScheduleDetail.WorkstationId, pScheduleDetail.ScheduleDate);
     }
     catch (Exception exp)
     {
         throw exp;
     }
     finally
     {
         Close();
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// @author : TrungMT
 /// @CreateDate:04/07/2008
 /// @Description: retrieve many ScheduleDetail with workstation id and schedule date
 /// </summary>
 /// <param name="pintScheduleDetailID">int</param>
 public DataSet GetFromScheduleForWorkstation(ScheduleDetail pScheduleDetail)
 {
     PrScheduleDetail ScheduleDetail = new PrScheduleDetail(Connection);
     try
     {
         Open();
         return ScheduleDetail.GetFromScheduleForWorkstation(pScheduleDetail.WorkstationId, pScheduleDetail.ScheduleDate);
     }
     catch (Exception exp)
     {
         throw exp;
     }
     finally
     {
         Close();
     }
 }