示例#1
0
            /// <summary>
            /// 폴더에 있는 파일을 이동시킨다.
            /// </summary>
            /// <param name="strSourcePath"></param>
            /// <param name="strTargetPath"></param>
            public static void FolderFileMove(string strSourcePath, string strTargetPath)
            {
                if (!FolderExists(strSourcePath))
                {
                    return;
                }

                FolderCreate(strTargetPath);

                foreach (string strFile in Directory.GetFiles(strSourcePath))
                {
                    string [] strf           = clsFile.FileSplitPath_Name(strFile);
                    string    strNewFileName = strTargetPath + @"\" + strf[1];

                    FileDelete(strNewFileName);

                    File.Move(strFile, strNewFileName);
                }

                foreach (string strDic in Directory.GetDirectories(strSourcePath))
                {
                    DirectoryInfo di = new DirectoryInfo(strDic);
                    FolderFileMove(strDic, Fnc.StringAdd(strTargetPath, di.Name, "\\"));
                }
            }
示例#2
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);
            }
        }