コード例 #1
0
        /// <summary>
        /// ÄÞº¸ ¹Ú½º¿¡ ¼±ÅÃµÈ °ªÀ» °¡Á®¿Â´Ù.(Invoke ¾Æ´Ô)
        /// </summary>
        /// <param name="cmb"></param>
        /// <param name="strField"></param>
        public static string Invoke_ComboBox_GetSelectValue(ComboBox cmb, string strField)
        {
            if (cmb.SelectedIndex < 0)
            {
                return(string.Empty);
            }

            DataRowView dv = (DataRowView)cmb.SelectedItem;

            return(Fnc.obj2String(dv[strField]));
        }
コード例 #2
0
        /// <summary>
        /// listview¿¡ datatable¿¡¼­ itemÀ» Ãß°¡ ÇÑ´Ù.
        /// </summary>
        /// <param name="lv"></param>
        /// <param name="dt"></param>
        /// <param name="strColumn">datatabel Ä÷³¸í ¼ø¼­µ¥·Î filed Ãß°¡ : '__NO'´Â count</param>
        public static void Invoke_ListView_AddItem(ListView lv, bool isClear, DataTable dt, string[] strColumn)
        {
            if (lv.InvokeRequired)
            {
                lv.Invoke(new delInvoke_ListView_AddItem(Invoke_ListView_AddItem), new object[] { lv, isClear, dt, strColumn });
                return;
            }

            if (isClear)
            {
                lv.Items.Clear();
            }

            string[] strValue = new string[strColumn.Length];

            int intRow = 1;

            foreach (DataRow dr in dt.Rows)
            {
                int intCol = 0;

                foreach (string strCol in strColumn)
                {
                    if (strCol == string.Empty)
                    {
                        strValue[intCol] = string.Empty;
                    }
                    else if (strCol == "__NO")
                    {
                        strValue[intCol] = (lv.Items.Count + 1).ToString();
                    }
                    else
                    {
                        strValue[intCol] = Fnc.obj2String(dr[strCol]);
                    }

                    intCol++;
                }

                ListViewItem item = new ListViewItem(strValue);

                lv.Items.Add(item);

                intRow++;
            }
        }
コード例 #3
0
        public bool UpdateCheck()
        {
            try
            {
                bool isUpdate = false;

                using (DataSet ds = clsSvr.File_GetList(strSvrType, strUpdateType, strConn, web))
                {
                    int intUpdateTotalCount = ds.Tables[0].Rows.Count;
                    int intUpdateCount      = 0;


                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        intUpdateCount++;

                        string   strFileName = Application.StartupPath + @"\" + Fnc.obj2String(dr["FileName"]);
                        string   strTempFileName;
                        string   strVersion  = Fnc.obj2String(dr["Version"]);
                        DateTime dtFileDate  = (DateTime)dr["FileDate"];
                        string   strCrc      = Fnc.obj2String(dr["CRC"]);
                        int      intFileSize = Convert.ToInt32(dr["FileSize"]);


                        string   strFileVersion = string.Empty;
                        DateTime dtFileFileDate = DateTime.Now;
                        TimeSpan tspan;

                        isUpdate = false;



                        if (system.clsFile.FileExists(strFileName))
                        {
                            System.IO.FileInfo fi = new System.IO.FileInfo(strFileName);

                            strFileVersion = Fnc.obj2String(system.clsFile.FileGetVersion(fi.FullName));
                            dtFileFileDate = fi.LastWriteTime;

                            tspan = dtFileFileDate - dtFileDate;

                            if (strFileVersion != strVersion || tspan.TotalSeconds > 30 || tspan.TotalSeconds < -30)
                            {
                                isUpdate = true;
                                break;
                            }
                        }
                        else
                        {
                            //파일이 없음
                            isUpdate = true;
                            break;
                        }
                    }
                }

                return(isUpdate);
            }
            catch
            {
                //ProcExecption(ex);
                throw;
            }
            finally
            {
                //this.Close();
            }
        }
コード例 #4
0
        private void FileDownload()
        {
            try
            {
                DoEvent(true, "서버에서 업데이트 내역을 확인합니다");

                using (DataSet ds = clsSvr.File_GetList(strSvrType, strUpdateType, strConn, web))
                {
                    int intUpdateTotalCount = ds.Tables[0].Rows.Count;
                    int intUpdateCount      = 0;

                    DoEvent(true, string.Format("업데이트 항목확인 {0}건 - 파일 다운로드 시작", intUpdateTotalCount));


                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        intUpdateCount++;
                        control.Invoke_Control_Text(lblSubCount, string.Format("{0:D2}/{1:D2}", intUpdateCount, intUpdateTotalCount));
                        control.Invoke_Control_Text(lblTotal, string.Format("{0:D0}%", 100 * intUpdateCount / intUpdateTotalCount));
                        control.Invoke_ProgressBar_Value(pBarTotal, intUpdateTotalCount, intUpdateCount);

                        string   strFileName = strTargetPath + Fnc.obj2String(dr["FileName"]);
                        string   strTempFileName;
                        string   strVersion  = Fnc.obj2String(dr["Version"]);
                        DateTime dtFileDate  = (DateTime)dr["FileDate"];
                        string   strCrc      = Fnc.obj2String(dr["CRC"]);
                        int      intFileSize = Convert.ToInt32(dr["FileSize"]);
                        bool     isUpdate    = false;

                        string   strFileVersion = string.Empty;
                        DateTime dtFileFileDate = DateTime.Now;
                        TimeSpan tspan;

                        isUpdate = false;

                        DoEvent(false, string.Format("파일[{0}]을 확인 합니다.", dr["FileName"]));

                        if (system.clsFile.FileExists(strFileName))
                        {
                            System.IO.FileInfo fi = new System.IO.FileInfo(strFileName);

                            strFileVersion = Fnc.obj2String(system.clsFile.FileGetVersion(fi.FullName));
                            dtFileFileDate = fi.LastWriteTime;

                            tspan = dtFileFileDate - dtFileDate;

                            if (strFileVersion != strVersion || tspan.TotalSeconds > 30 || tspan.TotalSeconds < -30)
                            {
                                isUpdate = true;
                                clsLog.WLog(string.Format("파일[{0}]을 업데이트 합니다. - VERSION[{1}] FILEDATE[{2}] -> VERSION[{3}] FILEDATE[{4}]",
                                                          dr["FileName"], strVersion, dtFileDate, strFileVersion, dtFileFileDate));
                            }
                        }
                        else
                        {
                            isUpdate = true;

                            clsLog.WLog(string.Format("파일[{0}]을 다운로드 받습니다. - VERSION[{1}] FILEDATE[{2}]",
                                                      dr["FileName"], strVersion, dtFileDate));
                        }


                        if (!isUpdate)
                        {
                            clsLog.WLog(string.Format("파일[{0}]은 업데이트 필요 없음- VERSION[{1}] FILEDATE[{2}]",
                                                      dr["FileName"], strVersion, dtFileDate));
                        }

                        int    intErrCnt  = 0;
                        string strFileCrc = string.Empty;
                        string field      = "FileName";
                        bool   isZipFile  = false;

                        while (isUpdate)
                        {
                            if (ds.Tables[0].Columns.Contains("ZipFilePath") && !Fnc.obj2String(dr["ZipFilePath"]).Equals(string.Empty))
                            {
                                field     = "ZipFilePath";
                                isZipFile = true;
                            }
                            else
                            {
                                field     = "FileName";
                                isZipFile = false;
                            }

                            strTempFileName = strPathUpdateTemp + Fnc.obj2String(dr[field]);

                            strFileCrc = clsSvr.FileInfo_GetFile(strSvrType, strUpdateType, Fnc.obj2String(dr[field]).ToUpper(),
                                                                 strPathUpdateTemp, intFileSize, evtReceiveFile, strConn, web);

                            GC.Collect();
                            Application.DoEvents();
                            GC.WaitForPendingFinalizers();

                            //crc검사
                            if (strCrc != strFileCrc)
                            {
                                intErrCnt++;

                                system.clsFile.FileDelete(strPathUpdateTemp + Fnc.obj2String(dr[field]));

                                //3회까지 시도한다.
                                if (intErrCnt > 2)
                                {
                                    isUpdate = false;
                                }
                                else
                                {
                                    isUpdate = true;
                                }
                            }
                            else
                            {
                                System.IO.FileInfo fi = new System.IO.FileInfo(strTempFileName);

                                if (isZipFile)
                                {                                   //zip 파일은 압축을 풀어주고
                                    System.IO.FileInfo newfi = new System.IO.FileInfo(strTempFileName);

                                    DoEvent(false, string.Format("파일[{0}]을 압축을 해제 합니다.", dr["FileName"]));

                                    ZipStorer zip;
                                    List <ZipStorer.ZipFileEntry> lstZip;

                                    zip    = ZipStorer.Open(fi.FullName, FileAccess.Read);
                                    lstZip = zip.ReadCentralDir();

                                    foreach (ZipStorer.ZipFileEntry z in lstZip)
                                    {
                                        string strNewFileName = fi.DirectoryName + "\\" + z.FilenameInZip;
                                        zip.ExtractFile(z, strNewFileName);

                                        newfi = new FileInfo(strNewFileName);
                                    }

                                    zip.Dispose();

                                    GC.Collect();
                                    Application.DoEvents();
                                    GC.WaitForPendingFinalizers();

                                    fi.Delete();

                                    newfi.LastWriteTime = dtFileDate;
                                    newfi.CreationTime  = dtFileDate;
                                }
                                else
                                {                                       //파일은 마지막 파일날짜를 변경 하여 준다
                                    fi.LastWriteTime = dtFileDate;
                                    fi.CreationTime  = dtFileDate;
                                }

                                isUpdate = false;
                            }
                        }
                    }
                }

                DoEvent(true, "서버에서 파일 다운로드가 완료 되었습니다.");
            }
            catch
            {
                //ProcExecption(ex);
                throw;
            }
            finally
            {
                //this.Close();
            }
        }