none
Windows Server 2008 R2 64bit 작업스케쥴러 문의 입니다. RRS feed

  • 질문

  • 안녕하세요 Windows Server 2008 R2 64bit 작업스케쥴러 관련 문의 있어서 글 작성 합니다

    현재 작업스케쥴러 등록 전 bat파일을 기반으로한 exe파일은 수동으로 실행 시킬 경우 정상적으로 동작,종료가 실행이 됩니다.

    그러나 작업스케쥴러에 등록을 할 경우 시작은 하지만 동작,종료가 안되는 상황이 발생 하고 있습니다.

    OS는 64bit 기반이지만 소스 파일은 32bit 기반으로 이루어져 있으며 해당 파일의 cs 내용 첨부하겠습니다.

    내용은 다음 아래와 같습니다.

    =============================================================

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Windows.Forms;

    using System.Net;

    using System.Net.Sockets;

    using System.IO;

    using System.Threading;

    using UCBioBSPCOMLib;

    using UCSAPICOMLib;

    namespace door_state

    {

        public partial class Form1 : Form

        {

            public UCSAPICOMLib.UCSAPI ucsAPI;

            private IServerUserData serveruserData;

            private ITerminalUserData terminalUserData;

            private IServerAuthentication serverAuthentication;

            private IAccessLogData accessLogData;

            public int sPort;

            public int kisok_Port;

            public static Socket Server, Client;

            public static byte[] getByte = new byte[1024];

            public static byte[] setByte = new byte[1024];

            public int real_terminal_Id = 1;

            public string _send_FileName;

            public string _delete_FileName;

            public bool terminal_connection = false;

            public int terminal_id = 1;

            public Form1()

            {

                InitializeComponent();

            }

            private void Form1_Load(object sender, EventArgs e)

            {

                AutoMessageClose.Show("프로그램 시작", "alert", 3000);

                try

                {

                    ucsAPI = new UCSAPIClass();

                    serveruserData = ucsAPI.ServerUserData as IServerUserData;

                    terminalUserData = ucsAPI.TerminalUserData as ITerminalUserData;

                    accessLogData = ucsAPI.AccessLogData as IAccessLogData;

                    serverAuthentication = ucsAPI.ServerAuthentication as IServerAuthentication;

                    // 서버 시작

     

                    ucsAPI.ServerStart(255, 9870);

                    ucsAPI.EventTerminalConnected += new _DIUCSAPIEvents_EventTerminalConnectedEventHandler(UCSCOMObj_EventTerminalConnected);

                    //send_sockeet();

                }

                catch (Exception ex)

                {

                    try

                    {

                       

                        AutoMessageClose.Show("단말기 접속 애러:" + ex.ToString(), "alert", 3000);

                        ucsAPI.ServerStop();

                    }

                    catch (Exception ex1)

                    {

                       

                    }

                }

               

            }

            private void send_sockeet()

            {

                for (int i = 0; i < 10; i++)

                {

                    if (terminal_connection == true)

                    {

                        break;

                    }

                    else

                    {

                        Thread.Sleep(1000);

                    }

                }

                AutoMessageClose.Show("접속 시작", "alert", 3000);

                file_delete();

            }

            private void file_delete()

            {

                int counter = 0;

                string line;

                _send_FileName =  "E:\\hanguk\\door_state\\delete_user.txt";

                try

                {

                    System.IO.StreamReader file = new System.IO.StreamReader(_send_FileName);

               

                    while ((line = file.ReadLine()) != null)

                    {

                        terminalUserData.DeleteUserFromTerminal(0, terminal_id, int.Parse(line));

                        counter++;

                    }

                    file.Close();

                  

                }

                catch (Exception ex)

                {

                  

                }

                AutoMessageClose.Show("사용자 등록 삭제", "alert", 3000);

                file_read();

            }

            private void file_read()

            {

                AutoMessageClose.Show("사용자 등록 시작", "alert", 3000);

                int counter = 0;

                string line;

                string[] send_user = null;

                // Read the file and display it line by line.

                _send_FileName = "E:\\hangul\\door_state\\send_user.txt";

                try

                {

                    System.IO.StreamReader file = new System.IO.StreamReader(_send_FileName);

                    while ((line = file.ReadLine()) != null)

                    {

                        try

                        {

                            send_user = line.Split('/');

                            //MessageBox.Show(send_user[0] + "|" + send_user[1]);

                            ////단말기로 넣기

                            serveruserData.UserID = int.Parse(send_user[0]);

                            serveruserData.UniqueID = send_user[0];

                            serveruserData.UserName = "스마트워크 예약자";

                            serveruserData.IsAdmin = 0;

                            serveruserData.IsIdentify = 1;

                            serveruserData.SetAuthType(0, 1, 0, 1, 0, 0);

                            serveruserData.Password = send_user[1];

                            serveruserData.AddUserToTerminal(1, terminal_id, 1);

                            counter++;

                        }

                        catch (Exception ex)

                        {

                          

                        }

                    }

                    file.Close();

                  

                    AutoMessageClose.Show("사용자 등록 끝", "alert", 3000);

                    ucsAPI.ServerStop();

                }

                catch (Exception ex1)

                {

                  

                }

                this.Close();

               

                Application.ExitThread();

                Application.Exit();

                System.Diagnostics.Process[] mProcess = System.Diagnostics.Process.GetProcessesByName(Application.ProductName);

                foreach (System.Diagnostics.Process p in mProcess)

                {

                    p.Kill();

                }

                AutoMessageClose.Show("프로그램 종료", "alert", 3000);

               

            }       

            void UCSCOMObj_EventTerminalConnected(int TerminalID, string TerminalIP)

            {

                terminal_connection = true;

                terminal_id = TerminalID;

                //AutoMessageClose.Show("접속 시작", "alert", 3000);

            

                listView1.Items.Add(string.Format("   +TerminalID:{0}, +TerminalIP:{1}, +ErrorCode:{2}", TerminalID, TerminalIP, this.ucsAPI.ErrorCode));

                file_delete();

            }

        }

    }

    2016년 8월 24일 수요일 오전 2:03