Ejemplo n.º 1
0
        private void DownloadtFinished(int iID)
        {
            if (m_ulConnID == iID)
            {
                NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
                pbDownloadTime.Value      = 100;
                m_ulConnID                = 0;
                lbDownloadStatusTime.Text = "Download Finished";
                timerTime.Enabled         = false;
            }
            foreach (Download file in m_lstDownloadFile)
            {
                if (file.GetConnID() == iID)
                {
                    file.StopDownload();
                    m_lstDownloadFile.Remove(file);
                    for (int i = 0; i < lvFileData.Items.Count; i++)
                    {
                        string sFileName = lvFileData.Items[i].SubItems[1].Text.ToString();

                        if (sFileName == file.GetFilename())
                        {
                            lvFileData.Items[i].SubItems[6].Text = "Finished";
                        }
                    }

                    break;
                }
            }
            if (m_lstDownloadFile.Count == 0)
            {
                timerFile.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        public void StartDownloadByTime()
        {
            DoCallBack = new ReplayCallBackDelegate(DoCallBackFunction);

            int iRet = NVSSDK.NetClient_NetFileDownloadByTimeSpanEx(ref m_ulConnID,
                                                                    m_ClientInfo.m_iServerID,
                                                                    null,
                                                                    m_iRealChannel,
                                                                    ref m_begintime,
                                                                    ref m_endtime, 0, -1, 2);

            if (iRet < 0)
            {
                if (m_ulConnID != -1)
                {
                    NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
                    m_ulConnID = 0;
                }
                return;
            }
            else
            {
                IntPtr tmep = IntPtr.Zero;
                iRet = NVSSDK.NetClient_SetNetFileDownloadFileCallBack(m_ulConnID, DoCallBack, tmep);
            }
        }
Ejemplo n.º 3
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            string sFileName = "";

            for (int i = 0; i < lvFileData.Items.Count; i++)
            {
                if (lvFileData.Items[i].Checked)
                {
                    sFileName = lvFileData.Items[i].SubItems[1].Text.ToString();
                    break;
                }
            }
            sFileName = sFileName.Trim();
            if (m_iLogonID < 0 || sFileName == "")
            {
                return;
            }

            UInt32 iConnID = 0;

            if (IsFileInList(m_iLogonID, sFileName, ref iConnID))
            {
                DOWNLOAD_CONTROL tdc = new DOWNLOAD_CONTROL();// = {sizeof(DOWNLOAD_CONTROL)};
                tdc.m_iSize     = Marshal.SizeOf(tdc);
                tdc.m_iPosition = -1;
                tdc.m_iSpeed    = 16;
                tdc.m_iReqMode  = cbQueryMode.SelectedIndex;
                int iRet = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 2, StructToBytes(tdc), Marshal.SizeOf(tdc));
                //if (iRet < 0)
                //{
                //    MessageBox.Show("NetClient_NetFileDownload faild!");
                //}
            }
        }
Ejemplo n.º 4
0
        private void ProgressDownlondByTime()
        {
            if (m_ulConnID != -1)
            {
                int uiCurrentPos = 0;
                int iSize        = 0;
                if (NVSSDK.NetClient_NetFileGetDownloadPos(m_ulConnID, ref uiCurrentPos, ref iSize) >= 0)
                {
                    long uiBeginTime   = CommonFunction.NvsFileTimeToAbsSeconds(m_StartTime);
                    long uiEndTime     = CommonFunction.NvsFileTimeToAbsSeconds(m_EndTime);
                    long iTimeInterval = uiEndTime - uiBeginTime;
                    if (iTimeInterval > 0)
                    {
                        long iCurrentInterval = uiCurrentPos - uiBeginTime;
                        if (iCurrentInterval > 0 && iCurrentInterval < iTimeInterval)
                        {
                            long iProcess = iCurrentInterval * 100 / iTimeInterval;
                            if (iProcess > 100)
                            {
                                return;
                            }
                            pbDownloadTime.Value = Convert.ToInt32(iProcess);
                        }
                    }
                    DateTime dtTime = CommonFunction.ConvertIntToDateTime(uiCurrentPos);

                    lbDownloadStatusTime.Text = dtTime.Year.ToString() + "-" +
                                                dtTime.Month.ToString("D2") + "-" +
                                                dtTime.Day.ToString("D2") + " " +
                                                dtTime.Hour.ToString("D2") + ":" +
                                                dtTime.Minute.ToString("D2") + ":" +
                                                dtTime.Second.ToString("D2");
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Download location
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDLLocation_Click(object sender, EventArgs e)
        {
            if (m_ClientInfo.m_iServerID == -1 || m_ulConnID == -1)
            {
                return;
            }


            int iPos = 0;

            try
            {
                iPos = Convert.ToInt32(tbDLLocation.Text.ToString());
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Please input the Number: 0~100!" + ex.Message);
            }


            if (iPos >= 0 && iPos < 100)
            {
                NVSSDK.NetClient_NetFileDownloadFile(ref m_ulConnID, m_ClientInfo.m_iServerID, "", "", 1, iPos, -1);
                if (m_iPlayerID >= 0)
                {
                    PLAYSDK.TC_CleanStreamBuffer(m_iPlayerID);
                }
            }
        }
Ejemplo n.º 6
0
 private void UI_UpdateProgressByFile()
 {
     if (m_ulConnID != -1)
     {
         int iProgress = 0, iSize = 0;
         int iRet = NVSSDK.NetClient_NetFileGetDownloadPos(m_ulConnID, ref iProgress, ref iSize);
         if (iRet >= 0)
         {
             string sProgress = "***" + iProgress.ToString() + "%/" + iSize.ToString() + "dB***";
             lbDownloadProgress.Text = sProgress;
             if (iProgress > 0 & iProgress < 100)
             {
                 pgbDownload.Value = iProgress;
             }
         }
     }
     if (m_iPlayerID != -1)
     {
         if (PLAYSDK.TC_GetFrameCount(m_iPlayerID) == 0)
         {
             return;
         }
         int    i         = PLAYSDK.TC_GetPlayingFrameNum(m_iPlayerID);
         int    j         = PLAYSDK.TC_GetFrameCount(m_iPlayerID);
         int    iProgress = i * 100 / j;
         string sProgress = "***" + iProgress.ToString() + "%***";
         lbPlayProgress.Text = sProgress;
         if (iProgress <= 100 & iProgress >= 0)
         {
             pgbPlay.Value = iProgress;
         }
     }
 }
Ejemplo n.º 7
0
        private void timerFile_Tick(object sender, EventArgs e)
        {
            for (int i = 0; i < m_lstDownloadFile.Count; i++)
            {
                UInt32 iConnID = m_lstDownloadFile[i].GetConnID();
                if (iConnID != -1)
                {
                    string sName        = m_lstDownloadFile[i].GetFilename();
                    int    uiCurrentPos = 0;
                    int    iSize        = 0;
                    if (NVSSDK.NetClient_NetFileGetDownloadPos(iConnID, ref uiCurrentPos, ref iSize) >= 0)
                    {
                        string sPos = "0%";
                        if (uiCurrentPos > 0 & uiCurrentPos < 100)
                        {
                            sPos = uiCurrentPos.ToString() + "%/";
                        }

                        sPos += iSize.ToString() + "dB";
                        m_lstDownloadFile[i].SetPosition(iSize);
                        for (int j = 0; j < lvFileData.Items.Count; j++)
                        {
                            string sFileName = lvFileData.Items[j].SubItems[1].Text.ToString();

                            if (sName == sFileName)
                            {
                                lvFileData.Items[j].SubItems[6].Text = sPos;
                                break;
                            }
                        }
                    }
                } // enf of if (m_ulConnID != -1)
            }     // end of for (int i = 0; i < m_lstDownloadFile.Count, i++)
        }
Ejemplo n.º 8
0
        //选择页码,更新DataGridView列表
        private void cboDNSPage_SelectedIndexChanged(object sender, EventArgs e)
        {
            int iPage = cboDNSPage.SelectedIndex;

            if (iPage < 0)
            {
                return;
            }
            dgvDNS.Rows.Clear();

            //将回调保存,防止垃圾回收,出现异常
            DnsNotify = DNSListNotify;

            //获取DNS设备列表
            int iRet = NVSSDK.NSLook_GetList
                       (
                ServerID,
                Encoding.ASCII.GetBytes(UserName),
                Encoding.ASCII.GetBytes(Password),
                iPage,
                DnsNotify,
                null,
                NVSSDK.TYPE_DNS
                       );

            //刷新DataGridView
            dgvDNS.Invalidate();

            if (iRet != 0)
            {
                MessageBox.Show("NSLook_GetList DNS Error ! " + iRet);
            }
        }
Ejemplo n.º 9
0
        private void BreakContinue(int iLogonID)
        {
            foreach (Download dlfile in m_lstDownloadFile)
            {
                if (dlfile.GetLogonID() == iLogonID)
                {
                    if (dlfile.GetBreakContinue() == 1)
                    {
                        DOWNLOAD_FILE tdf = new DOWNLOAD_FILE();// = {sizeof(DOWNLOAD_CONTROL)};
                        tdf.m_cRemoteFilename = new char[255];
                        tdf.m_cLocalFilename  = new char[255];

                        CharsCopy(dlfile.GetFilename().ToCharArray(), tdf.m_cRemoteFilename);
                        CharsCopy(("E:\\netclientdemo_download\\" + dlfile.GetFilename()).ToCharArray(), tdf.m_cLocalFilename);

                        tdf.m_iSize     = Marshal.SizeOf(tdf);
                        tdf.m_iPosition = -1;
                        tdf.m_iSpeed    = 16;
                        tdf.m_iReqMode  = cbQueryMode.SelectedIndex;
                        UInt32 iConnID = 0;
                        int    iRet    = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 3, StructToBytes(tdf), Marshal.SizeOf(tdf));
                        if (iRet >= 0)
                        {
                            dlfile.SetConnID(iConnID);
                            timerFile.Enabled = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void Update_UI_IPAndID()
        {
            cbVideoType.SelectedIndex     = 0;
            cbFileType.SelectedIndex      = 0;
            cbBitStreamType.SelectedIndex = 0;
            cbQueryMode.SelectedIndex     = 0;

            DateTime dt = new DateTime(DateTime.Now.Year,
                                       DateTime.Now.Month,
                                       DateTime.Now.Day,
                                       0, 0, 0);

            dtStartTimeFile.Value = dt;
            dtEndTimeFile.Value   = DateTime.Now;
            dtStartTimeTime.Value = dt;
            dtEndTimeTime.Value   = DateTime.Now;


            int iChannelNum = 0;

            NVSSDK.NetClient_GetChannelNum(m_iLogonID, ref iChannelNum);
            cbPassNOFile.Items.Clear();
            cbPassNOFile.Items.Add("All");
            for (int i = 0; i < iChannelNum; i++)
            {
                cbPassNOFile.Items.Add(i.ToString());
            }
            if (cbPassNOFile.Items.Count > 0)
            {
                cbPassNOFile.SelectedIndex = 0;
            }


            int iAlarmChannelNo = 0, iAlarmOutPortNum = 0;
            int iRet = NVSSDK.NetClient_GetAlarmPortNum(m_iLogonID, ref iAlarmChannelNo, ref iAlarmOutPortNum);

            cbAlarmType.Items.Clear();
            for (int i = 0; i < iAlarmChannelNo; i++)
            {
                cbAlarmType.Items.Add(i.ToString());
            }
            if (cbAlarmType.Items.Count > 0)
            {
                cbAlarmType.SelectedIndex = 0;
            }



            cbPassNOTime.Items.Clear();
            cbPassNOTime.Items.Add("All");
            for (int i = 0; i < iChannelNum; i++)
            {
                cbPassNOTime.Items.Add(i.ToString());
            }
            if (cbPassNOTime.Items.Count > 0)
            {
                cbPassNOTime.SelectedIndex = 0;
            }
        }
Ejemplo n.º 11
0
 private void PlayForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     PLAYSDK.TC_Stop(m_iPlayerID);         //停止播放
     PLAYSDK.TC_StopAudio(m_iPlayerID);
     PLAYSDK.TC_DeletePlayer(m_iPlayerID); //删除播放器实例
     PLAYSDK.TC_DeleteSystem();
     NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
 }
Ejemplo n.º 12
0
        public void StopDownload()
        {
            int iret = NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);

            if (iret < 0)
            {
                MessageBox.Show("NetClient_NetFileStopDownloadFile faild!");
            }
        }
Ejemplo n.º 13
0
 private void btnStopDownloadTime_Click(object sender, EventArgs e)
 {
     if (m_ClientInfo.m_iServerID != -1 && m_ulConnID != -1)
     {
         NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
         pbDownloadTime.Value      = 0;
         m_ulConnID                = 0;
         lbDownloadStatusTime.Text = "Stop Download";
         timerTime.Enabled         = false;
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Get fileinfo and update ui
        /// </summary>
        private void Update_UI_Query_Result()
        {
            lbFileNumber.Text = "File Number:" + m_iTotalCount.ToString();

            cbTotolPage.Items.Clear();
            for (int i = 0; i < m_iTotalPage; i++)
            {
                cbTotolPage.Items.Add(i + 1);
            }
            //cbTotolPage.SelectedIndex = m_iCurrentPage;

            lvFileData.Items.Clear();

            for (int i = 0; i < m_iCurrentCount; i++)
            {
                NVS_FILE_DATA filedata = new NVS_FILE_DATA();
                int           iret     = NVSSDK.NetClient_NetFileGetQueryfile(m_iLogonID, i, ref filedata);
                if (iret < 0)
                {
                    MessageBox.Show("NetClient_NetFileGetQueryfile failed");
                    return;
                    //GetLastError()
                }
                else
                {
                    ListViewItem one = new ListViewItem();
                    one.Text = (m_iCurrentPage * NVSSDK.MAX_PAGESIZE + i).ToString();
                    string str = new string(filedata.m_cFileName, 0, filedata.m_cFileName.Length);
                    str = str.Trim("\0".ToCharArray());
                    one.SubItems.Add(str);
                    one.SubItems.Add(filedata.m_iType.ToString());
                    one.SubItems.Add(filedata.m_iFileSize.ToString());
                    string stime = filedata.m_struStartTime.m_iYear.ToString() + "-" +
                                   filedata.m_struStartTime.m_iMonth.ToString("D2") + "-" +
                                   filedata.m_struStartTime.m_iDay.ToString("D2") + " " +
                                   filedata.m_struStartTime.m_iHour.ToString("D2") + ":" +
                                   filedata.m_struStartTime.m_iSecond.ToString("D2") + ":" +
                                   filedata.m_struStartTime.m_iMinute.ToString("D2");
                    one.SubItems.Add(stime);
                    stime = filedata.m_struStoptime.m_iYear.ToString() + "-" +
                            filedata.m_struStoptime.m_iMonth.ToString("D2") + "-" +
                            filedata.m_struStoptime.m_iDay.ToString("D2") + " " +
                            filedata.m_struStoptime.m_iHour.ToString("D2") + ":" +
                            filedata.m_struStoptime.m_iSecond.ToString("D2") + ":" +
                            filedata.m_struStoptime.m_iMinute.ToString("D2");
                    one.SubItems.Add(stime);
                    one.SubItems.Add("");  // 预留增加下载进度
                    lvFileData.Items.Add(one);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Get File Count and init some value
        /// </summary>
        private void GetFileCountInfo()
        {
            int iret = -1;

            iret = NVSSDK.NetClient_NetFileGetFileCount(m_iLogonID, ref m_iTotalCount, ref m_iCurrentCount);
            if (iret < 0)
            {
                MessageBox.Show("NetClient_NetFileGetFileCount failed");
            }
            if (m_iTotalCount > 0)
            {
                m_iTotalPage = m_iTotalCount / (NVSSDK.MAX_PAGESIZE) + 1;
            }
        }
Ejemplo n.º 16
0
        //获取NVS设备列表
        private void btnNVSRefresh_Click(object sender, EventArgs e)
        {
            int iCount = 0;

            //获取NVS设备数量
            int iRet = NVSSDK.NSLook_GetCount
                       (
                ServerID,
                Encoding.ASCII.GetBytes(UserName),
                Encoding.ASCII.GetBytes(Password),
                ref iCount, NVSSDK.TYPE_NVS
                       );

            if (iRet != 0)
            {
                MessageBox.Show("NSLook_GetCount NVS Error ! " + iRet);
                textNVSCount.Text = "0";
                return;
            }
            textNVSCount.Text = iCount.ToString();

            //将回调保存,防止垃圾回收,出现异常
            NvsNotify = NVSListNotify;
            if (iCount > 0)
            {
                //清空DataGridView的内容
                dgvNVS.Rows.Clear();

                //获取NVS列表
                iRet = NVSSDK.NSLook_GetList
                       (
                    ServerID,
                    Encoding.ASCII.GetBytes(UserName),
                    Encoding.ASCII.GetBytes(Password),
                    0,
                    null,
                    NvsNotify,
                    NVSSDK.TYPE_NVS
                       );

                //操作失败
                if (iRet != 0)
                {
                    MessageBox.Show("NSLook_GetList NVS Error ! " + iRet);
                }
            }
        }
Ejemplo n.º 17
0
        private void btnPlayTime_Click(object sender, EventArgs e)
        {
            if (dtStartTimeTime.Value >= dtEndTimeTime.Value)
            {
                MessageBox.Show("Start Time > End Time!");
                return;
            }
            if (m_iLogonID < 0)
            {
                return;
            }
            m_StartTime.m_iYear   = Convert.ToUInt16(dtStartTimeTime.Value.Year);
            m_StartTime.m_iMonth  = Convert.ToUInt16(dtStartTimeTime.Value.Month);
            m_StartTime.m_iDay    = Convert.ToUInt16(dtStartTimeTime.Value.Day);
            m_StartTime.m_iHour   = Convert.ToUInt16(dtStartTimeTime.Value.Hour);
            m_StartTime.m_iMinute = Convert.ToUInt16(dtStartTimeTime.Value.Minute);
            m_StartTime.m_iSecond = Convert.ToUInt16(dtStartTimeTime.Value.Second);


            m_EndTime.m_iYear   = Convert.ToUInt16(dtEndTimeTime.Value.Year);
            m_EndTime.m_iMonth  = Convert.ToUInt16(dtEndTimeTime.Value.Month);
            m_EndTime.m_iDay    = Convert.ToUInt16(dtEndTimeTime.Value.Day);
            m_EndTime.m_iHour   = Convert.ToUInt16(dtEndTimeTime.Value.Hour);
            m_EndTime.m_iMinute = Convert.ToUInt16(dtEndTimeTime.Value.Minute);
            m_EndTime.m_iSecond = Convert.ToUInt16(dtEndTimeTime.Value.Second);

            int iChannelNo  = cbPassNOTime.SelectedIndex;
            int iStreamNo   = cbBitStreamType.SelectedIndex;
            int iChannelNum = 0;

            NVSSDK.NetClient_GetChannelNum(m_ClientInfo.m_iServerID, ref iChannelNum);
            int iRealChannel = iStreamNo * iChannelNum + iChannelNo;
            //m_PlayPage.SetDownloadParam(m_iLogonID, iRealChannel/*iChannelNo*/, &begintime, &endtime);
            //m_PlayPage.DoModal();

            int irt = -1;

            irt = PLAYSDK.TC_CreateSystem(IntPtr.Zero);
            if (irt < 0)
            {
                MessageBox.Show("TC_CreateSystem failed!");
            }
            PlayForm frmPlay = new PlayForm(m_ClientInfo, iRealChannel, m_StartTime, m_EndTime, this);

            frmPlay.ShowDialog();
        }
Ejemplo n.º 18
0
        //更新页码
        private void btnDNSRefresh_Click(object sender, EventArgs e)
        {
            cboDNSPage.SelectedIndex = -1;
            int iCount = 0;

            //获取DNS设备数量
            int iRet = NVSSDK.NSLook_GetCount
                       (
                ServerID,
                Encoding.ASCII.GetBytes(UserName),
                Encoding.ASCII.GetBytes(Password),
                ref iCount, NVSSDK.TYPE_DNS
                       );

            //获取失败退出
            if (iRet != 0)
            {
                MessageBox.Show("NSLook_GetCount DNS Error ! " + iRet);
                textDNSCount.Text = "0";
                return;
            }
            cboDNSPage.Items.Clear();
            if (iCount <= 0)
            {
                textDNSCount.Text = "0";
                return;
            }
            textDNSCount.Text = iCount.ToString();
            int iPage = 0;

            //计算页数
            iPage = iCount / REG_PAGE_SIZE + iCount % REG_PAGE_SIZE == 0 ? 0 : 1;

            //为页码下拉菜单添加子项
            for (int i = 0; i < iPage; i++)
            {
                cboDNSPage.Items.Add(i + 1);
            }

            //默认选择第一页
            cboDNSPage.SelectedIndex = 0;
        }
Ejemplo n.º 19
0
        public void StartDownloadByFile()
        {
            DoCallBack = new ReplayCallBackDelegate(DoCallBackFunction);

            int iRet = NVSSDK.NetClient_NetFileDownloadFile(ref m_ulConnID, m_ClientInfo.m_iServerID, m_szFileName.ToString(), "", 0, -1, 2);

            if (iRet >= 0)
            {
                IntPtr temp = IntPtr.Zero;
                int    irt  = NVSSDK.NetClient_SetNetFileDownloadFileCallBack(m_ulConnID, DoCallBack, temp);
            }
            else
            {
                //if (m_ulConnID != -1)  // INVALID_ID)
                {
                    NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
                    //m_ulConnID = -1;
                }
            }
        }
Ejemplo n.º 20
0
        public void ContinueDownload()
        {
            if (m_ClientInfo.m_iServerID == -1 || m_ulConnID == -1)
            {
                return;
            }

            if (m_iDownloadPause == 1)
            {
                int iState = 0;
                int iRet   = PLAYSDK.TC_GetStreamPlayBufferState(m_iPlayerID, ref iState);
                if (iRet == 0)
                {
                    if (iState == -19)             //RET_BUFFER_WILL_BE_EMPTY )
                    {
                        //iRet = NVSSDK.NetClient_NetFileDownloadFile(ref m_ulConnID, m_ClientInfo.m_iServerID, m_szFileName, "", 1, -1, 1);
                        iRet             = NVSSDK.NetClient_NetFileDownloadFile(ref m_ulConnID, m_ClientInfo.m_iServerID, "", "", 1, -1, 1);
                        m_iDownloadPause = 0;
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private void btnDLSpeedChange_Click(object sender, EventArgs e)
        {
            if (m_ClientInfo.m_iServerID == -1 || m_ulConnID == -1) //|| m_iDownloadPause)
            {
                return;
            }

            int iSpeed = 0;

            try
            {
                iSpeed = Convert.ToInt32(tbDLSpeed.Text.ToString());
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Please input the Number: 0~16!" + ex.Message);
            }
            if (iSpeed >= 0 && iSpeed <= 16)
            {
                m_iDownloadSpeed = iSpeed;
                NVSSDK.NetClient_NetFileDownloadFile(ref m_ulConnID, m_ClientInfo.m_iServerID, "", "", 1, -1, iSpeed);
            }
        }
Ejemplo n.º 22
0
        private void UI_UpdateProgressByTime()
        {
            if (m_ulConnID != -1)
            {
                int iCurrentDonwnTime = 0, iSize = 0;
                int iRet = NVSSDK.NetClient_NetFileGetDownloadPos(m_ulConnID, ref iCurrentDonwnTime, ref iSize);
                if (iRet >= 0)
                {
                    DateTime dtTime = CommonFunction.ConvertIntToDateTime(iCurrentDonwnTime);
                    lbDownloadProgress.Text = dtTime.Year.ToString() + "-" +
                                              dtTime.Month.ToString() + "-" +
                                              dtTime.Day.ToString() + " " +
                                              dtTime.Hour.ToString() + ":" +
                                              dtTime.Minute.ToString() + ":" +
                                              dtTime.Second.ToString() + " Size:" +
                                              iSize.ToString() + "db";


                    long uiBeginTime   = CommonFunction.NvsFileTimeToAbsSeconds(m_begintime);
                    long uiEndTime     = CommonFunction.NvsFileTimeToAbsSeconds(m_endtime);
                    long iTimeInterval = uiEndTime - uiBeginTime;
                    if (iTimeInterval > 0)
                    {
                        long iCurrentInterval = iCurrentDonwnTime - uiBeginTime;
                        if (iCurrentInterval > 0 && iCurrentInterval < iTimeInterval)
                        {
                            long iProcess = iCurrentInterval * 100 / iTimeInterval;
                            if (iProcess > 100)
                            {
                                return;
                            }
                            pgbDownload.Value = Convert.ToInt32(iProcess);
                        }
                    }
                }
            }
            if (m_iPlayerID != -1)
            {
                Int32 uiCurrentPlayTime = 0;
                PLAYSDK.TC_GetUserDataInfo(m_iPlayerID, -1, 0, ref uiCurrentPlayTime, Marshal.SizeOf(uiCurrentPlayTime));

                if (uiCurrentPlayTime > 0)
                {
                    DateTime dtTime = CommonFunction.ConvertIntToDateTime(uiCurrentPlayTime);
                    lbDownloadProgress.Text = dtTime.Year.ToString() + "-" +
                                              dtTime.Month.ToString() + "-" +
                                              dtTime.Day.ToString() + " " +
                                              dtTime.Hour.ToString() + ":" +
                                              dtTime.Minute.ToString() + ":" +
                                              dtTime.Second.ToString();


                    long uiBeginTime   = CommonFunction.NvsFileTimeToAbsSeconds(m_begintime);
                    long uiEndTime     = CommonFunction.NvsFileTimeToAbsSeconds(m_endtime);
                    long iTimeInterval = uiEndTime - uiBeginTime;
                    if (iTimeInterval > 0)
                    {
                        long iCurrentInterval = uiCurrentPlayTime - uiBeginTime;
                        if (iCurrentInterval > 0 && iCurrentInterval < iTimeInterval)
                        {
                            long iProcess = iCurrentInterval * 100 / iTimeInterval;
                            if (iProcess > 100)
                            {
                                return;
                            }
                            pgbDownload.Value = Convert.ToInt32(iProcess);
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
        private void btnDownloadTime_Click(object sender, EventArgs e)
        {
            if (dtStartTimeTime.Value >= dtEndTimeTime.Value)
            {
                MessageBox.Show("Start Time > End Time!");
                return;
            }

            m_StartTime.m_iYear   = Convert.ToUInt16(dtStartTimeTime.Value.Year);
            m_StartTime.m_iMonth  = Convert.ToUInt16(dtStartTimeTime.Value.Month);
            m_StartTime.m_iDay    = Convert.ToUInt16(dtStartTimeTime.Value.Day);
            m_StartTime.m_iHour   = Convert.ToUInt16(dtStartTimeTime.Value.Hour);
            m_StartTime.m_iMinute = Convert.ToUInt16(dtStartTimeTime.Value.Minute);
            m_StartTime.m_iSecond = Convert.ToUInt16(dtStartTimeTime.Value.Second);


            m_EndTime.m_iYear   = Convert.ToUInt16(dtEndTimeTime.Value.Year);
            m_EndTime.m_iMonth  = Convert.ToUInt16(dtEndTimeTime.Value.Month);
            m_EndTime.m_iDay    = Convert.ToUInt16(dtEndTimeTime.Value.Day);
            m_EndTime.m_iHour   = Convert.ToUInt16(dtEndTimeTime.Value.Hour);
            m_EndTime.m_iMinute = Convert.ToUInt16(dtEndTimeTime.Value.Minute);
            m_EndTime.m_iSecond = Convert.ToUInt16(dtEndTimeTime.Value.Second);



            string localfile = "Demo_Download" + m_StartTime.m_iYear.ToString()
                               + m_StartTime.m_iMonth.ToString()
                               + m_StartTime.m_iDay.ToString()
                               + m_StartTime.m_iHour.ToString()
                               + m_StartTime.m_iMinute.ToString()
                               + m_StartTime.m_iSecond.ToString()
                               + "-"
                               + m_EndTime.m_iYear.ToString()
                               + m_EndTime.m_iMonth.ToString()
                               + m_EndTime.m_iDay.ToString()
                               + m_EndTime.m_iHour.ToString()
                               + m_EndTime.m_iMinute.ToString()
                               + m_EndTime.m_iSecond.ToString()
                               + ".sdv";

            if (!System.IO.Directory.Exists("E:\\netclientdemo_download"))
            {
                System.IO.Directory.CreateDirectory("E:\\netclientdemo_download");
            }
            string path        = "E:\\netclientdemo_download\\" + localfile;
            int    iChannelNo  = cbPassNOTime.SelectedIndex;
            int    iStreamNo   = cbBitStreamType.SelectedIndex;
            int    iChannelNum = 0;

            NVSSDK.NetClient_GetChannelNum(m_ClientInfo.m_iServerID, ref iChannelNum);
            int iRealChannel = iStreamNo * iChannelNum + iChannelNo;
            int iRet         = NVSSDK.NetClient_NetFileDownloadByTimeSpanEx(ref m_ulConnID,
                                                                            m_ClientInfo.m_iServerID,
                                                                            path, iRealChannel, ref m_StartTime, ref m_EndTime,
                                                                            0, -1, 16);

            if (iRet < 0)
            {
                if (m_ulConnID != -1)
                {
                    NVSSDK.NetClient_NetFileStopDownloadFile(m_ulConnID);
                    //m_ulConnID = 0;
                }
                return;
            }
            else
            {
                iRet = NVSSDK.NetClient_NetFileDownloadByTimeSpanEx(ref m_ulConnID,
                                                                    m_ClientInfo.m_iServerID,
                                                                    path, iRealChannel, ref m_StartTime, ref m_EndTime,
                                                                    1, -1, 16);
            }

            pbDownloadTime.Value = 0;
            timerTime.Enabled    = true;
        }
Ejemplo n.º 24
0
        //进行DNS查询操作
        private void btnDNSQuery_Click(object sender, EventArgs e)
        {
            //创建REG_DNS结构体
            REG_DNS stRegDNS = new REG_DNS();

            //以ID方式进行查询
            if (rdoDNSID.Checked)
            {
                if (textDNSID.Text.Trim() == "")
                {
                    MessageBox.Show("DNS ID 不能为空 ! ");
                    return;
                }

                //Byte数组进行赋值
                Array.Copy(Encoding.ASCII.GetBytes(textDNSID.Text), stRegDNS.m_stDNSInfo.m_stNvs.m_btFactoryID, textDNSID.Text.Length);
            }
            else
            {
                //以域名方式进行查询
                if (textDNSDomainName.Text.Trim() == "")
                {
                    MessageBox.Show("DNS DomainName 不能为空 ! ");
                    return;
                }

                //Byte数组进行赋值
                Array.Copy(Encoding.ASCII.GetBytes(textDNSDomainName.Text), stRegDNS.m_stDNSInfo.m_stNvs.m_btNvsName, textDNSDomainName.Text.Length);
            }
            Array.Copy(Encoding.ASCII.GetBytes(UserName), stRegDNS.m_stDNSInfo.m_btUserName, UserName.Length);
            Array.Copy(Encoding.ASCII.GetBytes(Password), stRegDNS.m_stDNSInfo.m_btPwd, Password.Length);

            //清空DataGridView
            dgvDNS.Rows.Clear();

            int    iRet = -1;
            IntPtr pDns = IntPtr.Zero;

            try
            {
                //申请结构体REG_DNS所需的内存
                pDns = Marshal.AllocHGlobal(Marshal.SizeOf(stRegDNS));

                //将stRegDNS存入刚申请的内存
                Marshal.StructureToPtr(stRegDNS, pDns, true);

                //查询DNS设备信息
                iRet = NVSSDK.NSLook_Query(ServerID, pDns, IntPtr.Zero, NVSSDK.TYPE_DNS);

                //从内存中读出stRegDNS的值
                stRegDNS = (REG_DNS)Marshal.PtrToStructure(pDns, typeof(REG_DNS));
            }
            catch (Exception ex)
            {
                //将异常输出到Output窗口
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                //释放内存
                Marshal.FreeHGlobal(pDns);
            }

            //操作失败
            if (iRet != 0)
            {
                MessageBox.Show("NSLook_Query DNS Error ! " + iRet);
                return;
            }

            //为DataGridView添加新行
            dgvDNS.Rows.Add
            (
                new object[]
            {
                Bytes2Str(stRegDNS.m_stDNSInfo.m_stNvs.m_btNvsName),
                Bytes2Str(stRegDNS.m_stDNSInfo.m_stNvs.m_btFactoryID),
                Bytes2Str(stRegDNS.m_stDNSInfo.m_stNvs.m_btNvsIP),
                Bytes2Str(stRegDNS.m_stDNSInfo.m_stReserve.m_btReserved1),
                stRegDNS.m_stDNSInfo.m_iPort,
                stRegDNS.m_stDNSInfo.m_stNvs.m_iNvsType,
                stRegDNS.m_stDNSInfo.m_iChannel,
                "",
                "",
                DateTime.Now
            }
            );
        }
Ejemplo n.º 25
0
        private void btnDownload_Click(object sender, EventArgs e)
        {
            string sFileName = "";

            for (int i = 0; i < lvFileData.Items.Count; i++)
            {
                if (lvFileData.Items[i].Checked)
                {
                    sFileName = lvFileData.Items[i].SubItems[1].Text.ToString();
                    break;
                }
            }
            //sFileName = sFileName.Trim();
            if (m_iLogonID < 0 || sFileName == "")
            {
                return;
            }

            UInt32 iConnID = 0;

            if (IsFileInList(m_iLogonID, sFileName, ref iConnID))
            {
                return;
            }
            if (!System.IO.Directory.Exists("E:\\netclientdemo_download"))
            {
                System.IO.Directory.CreateDirectory("E:\\netclientdemo_download");
            }
            //int iRet = NetClient_NetFileDownloadFile(&iConnID, m_iLogonID, (char *)(LPCSTR)m_szFileName, (char *)(LPCSTR)(g_szDownloadPath + m_szFileName), 0, -1, -1);
            DOWNLOAD_FILE tdf = new DOWNLOAD_FILE();    //= {sizeof(DOWNLOAD_FILE)};

            tdf.m_cRemoteFilename = new char[255];
            tdf.m_cLocalFilename  = new char[255];
            //strcpy_s(tdf.m_cRemoteFilename,m_szFileName.GetLength()+1,(char *)(LPCSTR)m_szFileName);
            //strcpy_s(tdf.m_cLocalFilename,(g_szDownloadPath + m_szFileName).GetLength()+1,(char*)(LPCSTR)(g_szDownloadPath + m_szFileName));

            CharsCopy(sFileName.ToCharArray(), tdf.m_cRemoteFilename);
            //tdf.m_cRemoteFilename = sFileName.ToCharArray();
            CharsCopy(("E:\\netclientdemo_download\\" + sFileName).ToCharArray(), tdf.m_cLocalFilename);
            //tdf.m_cLocalFilename = "c:\\netclientdemo_download\\".ToCharArray();
            tdf.m_iPosition = -1;
            tdf.m_iSpeed    = 32;
            tdf.m_iReqMode  = cbQueryMode.SelectedIndex;

            int iRet = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 0, StructToBytes(tdf), Marshal.SizeOf(tdf));

            if (iRet >= 0)
            {
                //int iRet = NetClient_NetFileDownloadFile(&iConnID, m_iLogonID, (char *)(LPCSTR)m_szFileName, (char *)(LPCSTR)(g_szDownloadPath + m_szFileName), 1, -1, 16);//设置下载速度为32倍速
                DOWNLOAD_CONTROL tdc = new DOWNLOAD_CONTROL();        // = {sizeof(DOWNLOAD_CONTROL)};
                tdc.m_iSize     = Marshal.SizeOf(tdc);
                tdc.m_iPosition = -1;
                tdc.m_iSpeed    = 16;
                tdc.m_iReqMode  = cbQueryMode.SelectedIndex;
                iRet            = NVSSDK.NetClient_NetFileDownload(ref iConnID, m_ClientInfo.m_iServerID, 2, StructToBytes(tdc), Marshal.SizeOf(tdc));
                Download downloadfile = new Download(m_iLogonID, iConnID, sFileName, "", "");
                if (cbBreakContinue.Checked)
                {
                    downloadfile.SetBreakContinue(1);
                }
                else
                {
                    downloadfile.SetBreakContinue(0);
                }

                downloadfile.SetReqMode(tdc.m_iReqMode);
                m_lstDownloadFile.Add(downloadfile);
                timerFile.Enabled = true;
            }
        }
Ejemplo n.º 26
0
        private void QueryFile()
        {
            if (m_iLogonID < 0)
            {
                return;
            }
            if (dtStartTimeFile.Value > dtEndTimeFile.Value)
            {
                MessageBox.Show("Start time > End time");
            }
            //NVS_FILE_QUERY
            NVS_FILE_QUERY Query = new NVS_FILE_QUERY();

            int iType = cbVideoType.SelectedIndex;

            if (iType == 0)
            {
                Query.m_iType = 0xFF;
            }
            else if (iType <= 3)
            {
                Query.m_iType = iType;
            }
            else
            {
                Query.m_iType = 1431;
            }


            Query.m_iChannel = cbPassNOFile.SelectedIndex - 1;
            //if (Query.m_iChannel == -1)
            //{
            Query.m_iChannel = 0xFF;
            // }

            Query.m_struStartTime.m_iYear   = Convert.ToUInt16(dtStartTimeFile.Value.Year);
            Query.m_struStartTime.m_iMonth  = Convert.ToUInt16(dtStartTimeFile.Value.Month);
            Query.m_struStartTime.m_iDay    = Convert.ToUInt16(dtStartTimeFile.Value.Day);
            Query.m_struStartTime.m_iHour   = Convert.ToUInt16(dtStartTimeFile.Value.Hour);
            Query.m_struStartTime.m_iMinute = Convert.ToUInt16(dtStartTimeFile.Value.Minute);
            Query.m_struStartTime.m_iSecond = Convert.ToUInt16(dtStartTimeFile.Value.Second);


            Query.m_struStoptime.m_iYear   = Convert.ToUInt16(dtEndTimeFile.Value.Year);
            Query.m_struStoptime.m_iMonth  = Convert.ToUInt16(dtEndTimeFile.Value.Month);
            Query.m_struStoptime.m_iDay    = Convert.ToUInt16(dtEndTimeFile.Value.Day);
            Query.m_struStoptime.m_iHour   = Convert.ToUInt16(dtEndTimeFile.Value.Hour);
            Query.m_struStoptime.m_iMinute = Convert.ToUInt16(dtEndTimeFile.Value.Minute);
            Query.m_struStoptime.m_iSecond = Convert.ToUInt16(dtEndTimeFile.Value.Second);


            Query.m_iPageSize = NVSSDK.MAX_PAGESIZE;
            Query.m_iPageNo   = m_iCurrentPage;
            Query.m_iFiletype = cbFileType.SelectedIndex;


            int ret;

            //Int32 i = 0;
            //Int32 j = 0;

            try
            {
                ret = NVSSDK.NetClient_NetFileQuery(m_iLogonID, ref Query);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("NetClient_NetFileQuery failed" + ex.Message);
                return;
            }

            if (ret < 0)
            {
                MessageBox.Show("NetClient_NetFileQuery failed");
                return;
            }
        }
Ejemplo n.º 27
0
        //进行NVS查询
        private void btnNVSQuery_Click(object sender, EventArgs e)
        {
            //NVS ID 为空时,不能查询
            if (textNVSID.Text.Trim() == "")
            {
                MessageBox.Show("NVS ID 不能为空 ! ");
                return;
            }

            //创建结构体
            REG_NVS stRegNVS = new REG_NVS();

            //进行Byte数组赋值
            Array.Copy(Encoding.ASCII.GetBytes(textNVSID.Text), stRegNVS.m_stNvs.m_btFactoryID, textNVSID.Text.Length);

            //清空DataGridView内容
            dgvNVS.Rows.Clear();

            int    iRet = -1;
            IntPtr pNvs = IntPtr.Zero;

            try
            {
                //申请结构体REG_NVS所需的内存
                pNvs = Marshal.AllocHGlobal(Marshal.SizeOf(stRegNVS));

                //将stRegNVS存入刚申请的内存
                Marshal.StructureToPtr(stRegNVS, pNvs, true);

                //查询NVS设备信息
                iRet = NVSSDK.NSLook_Query(ServerID, IntPtr.Zero, pNvs, NVSSDK.TYPE_NVS);

                //从内存中读出stRegNVS的值
                stRegNVS = (REG_NVS)Marshal.PtrToStructure(pNvs, typeof(REG_NVS));
            }
            catch (Exception ex)
            {
                //将异常输出到Output窗口
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                //释放内存
                Marshal.FreeHGlobal(pNvs);
            }

            //查询失败,退出
            if (iRet != 0)
            {
                MessageBox.Show("NSLook_Query NVS Error ! " + iRet);
                return;
            }

            //为DatagGridView添加新行
            dgvNVS.Rows.Add
            (
                new object[]
            {
                Bytes2Str(stRegNVS.m_stNvs.m_btNvsIP),
                Bytes2Str(stRegNVS.m_stNvs.m_btNvsName),
                stRegNVS.m_stNvs.m_iNvsType,
                Bytes2Str(stRegNVS.m_stNvs.m_btFactoryID)
            }
            );
        }