Ejemplo n.º 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]));
        }
Ejemplo n.º 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++;
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
0
 private void ProcExecption(Exception ex)
 {
     Fnc.ShowMsg(ex.Message, string.Empty, frmMessage.enMessageType.OK);
 }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
0
        private void StartUp()
        {
            try
            {
                for (int i = 1; i < 11; i++)
                {
                    double dbl = i * 0.1;

                    control.Invoke_Form_Opacity(this, dbl);

                    Thread.Sleep(150);
                    Application.DoEvents();
                }

                DoEvent(true, "Config파일 읽는 중..");



                //업데이트 타입을 저장
                strUpdateType = xml.GetSingleNodeValue("UPDATETYPE");
                //대상폴더 지정
                strTargetPath = aPath + @"\" + xml.GetSingleNodeValue("TARGETFOLDER");

                if (strTargetPath != string.Empty && !strTargetPath.EndsWith("\\"))
                {
                    strTargetPath += @"\";
                }

#if (DEBUG)
                //strTargetPath = @"c:\Program Files (x86)\KPGMS\";
                //strPathUpdateTemp = @"c:\Program Files (x86)\KPGMS\Temp\";
#endif



                if (svcName != string.Empty)
                {
                    ServiceController service = new ServiceController(svcName);

                    try
                    {
                        if (service.Status == ServiceControllerStatus.Running)
                        {
                            DoEvent(true, string.Format("서비스 [{0}] 중지 중입니다.", svcName));
                            service.Stop();
                            service.WaitForStatus(ServiceControllerStatus.Stopped);
                        }
                    }
                    catch
                    {
                    }
                }



                strSTARTUPFILE = xml.GetSingleNodeValue("STARTUPFILE");

                strSvrType = xml.GetSingleNodeValue("SERVER/SERVERTYPE");

                bool use_en = xml.GetSingleNodeValue("USE_ENCRYPTO").Equals("Y");

                vari.Init(xml, ref strConn, ref web);


                xml.chNode2Root();

                //프로새스 종료 여부
                string strKillProcess = xml.GetSingleNodeValue("KILLPROCESS");

                if (strKillProcess != "N")
                {
                    string[] fi = strSTARTUPFILE.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

                    System.Diagnostics.Process[] s = System.Diagnostics.Process.GetProcessesByName(fi[0]);

                    foreach (System.Diagnostics.Process p in s)
                    {
                        p.Kill();
                        p.WaitForExit();
                    }

                    Application.DoEvents();


                    /*
                     * s = System.Diagnostics.Process.GetProcesses();
                     *
                     * //if (s.Length > 0) s[0].Kill();
                     *
                     * foreach(System.Diagnostics.Process p in s)
                     * {
                     *      Console.WriteLine(p.ProcessName);
                     *
                     *      if(p.ProcessName.ToUpper().Equals(strSTARTUPFILE.ToUpper()))
                     *      {
                     *              p.Kill();
                     *      }
                     * }
                     *
                     */
                }



                //cryptography CR = new cryptography();
                //CR.Key = key;
                //CR.IV = IV;

                //switch (strSvrType)
                //{
                //	case "ORACLE":
                //		strConn.strTNS = xml.GetSingleNodeValue("TNS");
                //		if (use_en)
                //		{
                //			strConn.strID = CR.Decrypting(xml.GetSingleNodeValue("ID"));
                //			strConn.strPass = CR.Decrypting(xml.GetSingleNodeValue("PASS"));
                //		}
                //		else
                //		{
                //			strConn.strID = xml.GetSingleNodeValue("ID"); //CR.Decrypting(xml.GetSingleNodeValue("ID"));
                //			strConn.strPass = xml.GetSingleNodeValue("PASS"); //CR.Decrypting(xml.GetSingleNodeValue("PASS"));
                //		}

                //		break;

                //	case "WEB":
                //		web = new AutoUpdateSvr.AutoUpdateServer();
                //		if(use_en)
                //			web.Url = CR.Decrypting(xml.GetSingleNodeValue("URL"));
                //		else
                //			web.Url = xml.GetSingleNodeValue("URL");
                //		break;

                //	default:
                //		throw new Exception("Server Type을 알 수 없습니다.");
                //}


                xml.chSingleNode("SERVER/" + strSvrType);


                DoEvent(true, "임시폴더 파일을 삭제합니다.");
                //temp폴더에 있는 파일을 삭제한다.
                system.clsFile.FolderFileDelete(strPathUpdateTemp);

                //파일을 다운로드 받는다.
                FileDownload();

                DoEvent(true, "업데이트 파일을 이동합니다.");
                //temp폴데에 있는 파일을 이동시킨다. -> 파일무버에서 처리 한다.
                //Function.system.clsFile.FolderFileMove(strPathUpdateTemp, strTargetPath);
            }
            catch (Exception ex)
            {
                clsLog.WLog_Exception("StartUp", ex);
            }
            finally
            {
                DoEvent(true, "업데이트가 완료되었습니다.");
                clsLog.WLog("업데이트 프로그램을 종료합니다.");

                try
                {
                    strPathUpdateTemp = strPathUpdateTemp.Replace(" ", chrEmpty.ToString());
                    strTargetPath     = strTargetPath.Replace(" ", chrEmpty.ToString());
                    strSTARTUPFILE    = strSTARTUPFILE.Replace(" ", chrEmpty.ToString());
                    svcName           = svcName.Replace(" ", chrEmpty.ToString());
                    strSTARTUPFILE    = Fnc.StringAdd(strTargetPath, strSTARTUPFILE, "\\");
                    if (strTargetPath.Trim().Equals(string.Empty))
                    {
                        strTargetPath = chrEmpty.ToString();
                    }


                    System.Diagnostics.Process pro = new System.Diagnostics.Process();
                    pro.StartInfo.FileName = aPath + @"\FileMover.exe";
                    //pro.StartInfo.Arguments = string.Format(@"""{0}"" """"{1}"" """"{2}""", strPathUpdate, strPath , strSTARTUPFILE);
                    pro.StartInfo.Arguments = string.Format(@"{0} {1} {2} {3}", strPathUpdateTemp, strTargetPath, strSTARTUPFILE, svcName);
                    pro.Start();
                }
                catch (Exception ex)
                {
                    clsLog.WLog_Exception("FileMove", ex);
                }

                control.Invoke_Form_Close(this);
            }
        }