예제 #1
0
        private void ThreadMultiExecute()
        {
            try
            {
                for (int nIndex = 0; nIndex < IDDatas.getDataTable().Count; nIndex++)
                {
                    if (dataGridView_Info.Rows[nIndex].Selected == false)
                    {
                        continue;
                    }

                    if (IDDatas.getDataTable()[GetDataGridSelectID(nIndex)].nPID != -1)
                    {
                        ProcessControl.Display(IDDatas.getDataTable()[GetDataGridSelectID(nIndex)].nPID);
                    }
                    else
                    {
                        Thread_LE = new Thread(() => ThreadNewSequence(nIndex))
                        {
                            IsBackground = false
                        };
                        Thread_LE.Start();
                        Thread_LE.Join();
                    }
                }
            }
            catch (Exception)
            {
            }
        }
예제 #2
0
        private void SingleKillProcess(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0 || e.ColumnIndex !=
                    dataGridView_Info.Columns["Exit Program"].Index)
                {
                    return;
                }

                int    nIndex = e.RowIndex;
                string strID  = dataGridView_Info.Rows[nIndex].Cells["ID"].Value.ToString();

                int nID = IDDatas.getDataTable()[strID].nPID;

                if (nID != -1)
                {
                    ProcessControl.KillProcess(nID);
                    IDDatas.getDataTable()[strID].nPID = -1;
                    ChangeTextRow(nIndex, false);
                }

                //This is the code which will show the button click row data. Thank you.
            }
            catch (Exception ex)
            {
                logs.Format(ex.ToString());
            }
        }
예제 #3
0
        private void CommandInput(int nIndex, string strID)
        {
            if (strID == "" || IDDatas.getDataTable()[strID].nPID == -1)
            {
                return;
            }

            string strInput = dataGridView_Command.Rows[nIndex].Cells["명령어"].Value.ToString();

            ProcessControl.Display(IDDatas.getDataTable()[strID].nPID);

            string[] inputs = stringParser.ParserSpecial(strInput);

            foreach (string input in inputs)
            {
                if (input == "")
                {
                    continue;
                }

                if (input.ToUpper() == "enter".ToUpper())
                {
                    ProcessControl.keyInput(Keys.Enter, 100);
                }
                else
                {
                    SendKeys.SendWait(input);
                }
            }

            Log_move.Format(strID + ": " + strInput + "수행");
        }
예제 #4
0
        public static Image ImageCrop(int nPID, eImagetype type)
        {
            int   nType = (int)type;
            Image img   = null;

            try
            {
                Process process = new Process();
                ProcessControl.FindProcess(ref process, nPID);

                ScreenCapture sc = new ScreenCapture();

                if (type != eImagetype.total)
                {
                    img = sc.CaptureWindow(process.MainWindowHandle, List_Rect[nType]);
                }
                else
                {
                    img = sc.CaptureWindow(process.MainWindowHandle);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                img = null;
            }
            finally
            {
                img.Save(m_strFilePath + "temp.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            }
            return(img);
        }
예제 #5
0
        private void SingleExecute(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0 || e.ColumnIndex !=
                    dataGridView_Info.Columns["Single Execute"].Index)
                {
                    return;
                }

                int nIndex = e.RowIndex;

                if (IDDatas.getDataTable()[GetDataGridSelectID(nIndex)].nPID != -1)
                {
                    ProcessControl.Display(IDDatas.getDataTable()[GetDataGridSelectID(nIndex)].nPID);
                }
                else
                {
                    Thread_LE = new Thread(() => ThreadNewSequence(nIndex, true));
                    Thread_LE.Start();
                }
                //This is the code which will show the button click row data. Thank you.
            }
            catch (Exception ex)
            {
                logs.Format(ex.ToString());
            }
        }
예제 #6
0
        private void button_checkConnection_Click(object sender, EventArgs e)
        {
            try
            {
                int nIndex = 0;

                foreach (var data in IDDatas.getDataTable())
                {
                    if (connectDialog_check(nIndex++) == false)
                    {
                        int nID = IDDatas.getDataTable()[data.Key].nPID;

                        if (nID != -1)
                        {
                            ProcessControl.KillProcess(nID);
                            IDDatas.getDataTable()[data.Key].nPID = -1;
                            Log_move.Format(data.Key.ToString() + "연결해제로 프로세스 종료함.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #7
0
        private bool InputInfoProgram(int nIndex, int nID)
        {
            bool bRet = false;

            try
            {
                string strID = GetDataGridSelectID(nIndex);

                SendKeys.SendWait(dataGridView_Info.Rows[nIndex].Cells["ID"].Value.ToString());
                ProcessControl.keyInput(Keys.Tab, 250);

                SendKeys.SendWait(dataGridView_Info.Rows[nIndex].Cells["PW"].Value.ToString());

                ProcessControl.keyInput(Keys.Enter);

                int nTry = 0;

                do
                {
                    Image  img_capture = ImageProc.ImageCrop(nID, eImagetype.name);
                    string strFilePath = ImageProc.m_strIDInfo + GetDataGridSelectID(nIndex) + ".bmp";

                    if (File.Exists(strFilePath) == false)
                    {
                        logs.Format("이미지 없음 저장필요");
                        bRet = true;

                        Thread.Sleep(500);
                        Connectingcheck(nID);
                        Thread.Sleep(500);
                    }
                    else
                    {
                        bRet = ImageProc.ImageCompare(strFilePath, new Bitmap(img_capture));
                    }

                    if (bRet == true)
                    {
                        break;
                    }
                    else
                    {
                        Connectingcheck(nID);
                    }

                    Thread.Sleep(200);//Task.Delay(1000);
                } while (nTry++ < 10);
            }
            catch (Exception e)
            {
                logs.Format(e.ToString());
                bRet = false;
            }

            return(bRet);
        }
예제 #8
0
        private void button_return_Click(object sender, EventArgs e)
        {
            try
            {
                int    nIdIndex = dataGridView_IDInfo.CurrentCell.RowIndex;
                string strID    = GetDataGridSelectID(nIdIndex);

                string strPlace = textBox_place.Text;

                int iPos = 0;
                for (iPos = 0; iPos < PLACE.strPLACE.Length; iPos++)
                {
                    if (strPlace == PLACE.strPLACE[iPos])
                    {
                        break;
                    }
                }

                if (iPos >= PLACE.strPLACE.Length)
                {
                    Log_move.Format(strID + " 복귀실패 : 장소를 잘못 입력하셨습니다.");
                    throw new Exception();
                }

                ProcessControl.Display(IDDatas.getDataTable()[strID].nPID);

                Log_move.Format(strID + ": " + PLACE.strPLACE[iPos] + "에서 복귀시작");

                SendKeys.SendWait("04");
                ProcessControl.keyInput(Keys.Enter, 300);

                if (iPos >= 10)
                {
                    string str = "9굴" + PLACE.strPLACE[iPos][0];
                    SendKeys.SendWait(str);
                    ProcessControl.keyInput(Keys.Enter, 300);
                }
                else
                {
                    SendKeys.SendWait("9조그만삐삐");
                    ProcessControl.keyInput(Keys.Enter, 300);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #9
0
        private bool SelectSeverProgram(int nID)
        {
            bool bRet = false;

            try
            {
                ProcessControl.keyInput(Keys.Down);
                ProcessControl.keyInput(Keys.Enter, 1000);


                bRet = ImageCompareSeq(ImageProc.m_strLogin + "3.bmp", eImagetype.total, nID);
            }
            catch (Exception e) { logs.Format(e.ToString());  bRet = false; }

            return(bRet);
        }
예제 #10
0
        private void Refresh(int nIndex)
        {
            try
            {
                Datas tmp_data = IDDatas.getDataTable()[IDDataTable.Rows[nIndex]["ID"].ToString()];

                Boolean bCheck = ProcessControl.CheckProcess(tmp_data.nPID);

                ChangeTextRow(nIndex, bCheck);

                if (bCheck == false)
                {
                    IDDatas.getDataTable()[IDDataTable.Rows[nIndex]["ID"].ToString()].nPID = -1;
                }
            }
            catch (Exception) { }
        }
예제 #11
0
        private void eventMove(int nIndex)
        {
            string strID = GetDataGridSelectID(nIndex);

            string strPlace = textBox_place.Text;

            int iPos = 0;

            for (iPos = 0; iPos < PLACE.strPLACE.Length; iPos++)
            {
                if (strPlace == PLACE.strPLACE[iPos])
                {
                    break;
                }
            }

            if (iPos >= PLACE.strPLACE.Length)
            {
                Log_move.Format(strID + "이동실패 : 장소를 잘못 입력하셨습니다");
                return;
            }

            ProcessControl.Display(IDDatas.getDataTable()[strID].nPID);

            if (iPos >= 10)
            {
                SendKeys.SendWait("ZX");
                iPos -= 10;
            }

            ProcessControl.keyInput(Keys.Enter, 100);
            SendKeys.SendWait("귀환");
            ProcessControl.keyInput(Keys.Enter, 300);

            for (int i = 0; i < iPos + 1; i++)
            {
                ProcessControl.keyInput(Keys.Down, 10);
            }
            ProcessControl.keyInput(Keys.Enter, 300);

            SendKeys.SendWait("01");
            ProcessControl.keyInput(Keys.Enter);

            Log_move.Format(strID + ": " + strPlace + "이동완료.");
        }
예제 #12
0
        private void Connectingcheck(int nID)
        {
            bool bConnecting = false;

            try
            {
                string strFilePath    = ImageProc.m_strLogin + "6.bmp";
                Image  img_Connecting = ImageProc.ImageCrop(nID, eImagetype.isconnected);
                bConnecting = ImageProc.ImageCompare(strFilePath, new Bitmap(img_Connecting));

                if (bConnecting)
                {
                    ProcessControl.keyInput(Keys.Enter);
                    ProcessControl.keyInput(Keys.Enter, 400);
                }
            }
            catch (Exception e) { }
        }
예제 #13
0
        private bool ExecuteProgram(ref int nID)
        {
            bool bRet = false;

            try
            {
                Process temp = new Process();
                ProcessControl.executeFile(ref temp, textBox_FilePath.Text.ToString());

                nID = temp.Id;

                bRet = ImageCompareSeq(ImageProc.m_strLogin + "1.bmp", eImagetype.total, nID);
            }
            catch (Exception e)
            {
                bRet = false;
                logs.Format(e.ToString());
            }

            return(bRet);
        }
예제 #14
0
        private void BTDisplay_Click(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0 || e.ColumnIndex !=
                    dataGridView_IDInfo.Columns["BTDisplay"].Index)
                {
                    return;
                }

                int nIndex = e.RowIndex;

                string strID = GetDataGridSelectID(nIndex);

                ProcessControl.Display(GetDataGridSelectPID(nIndex));

                //This is the code which will show the button click row data. Thank you.
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #15
0
        private bool ConnectProgram(int nID)
        {
            bool bRet = false;

            try
            {
                ProcessControl.Display(nID);
                Thread.Sleep(400); // 어떻게 할수가없음.

                ProcessControl.keyInput(Keys.Tab);
                ProcessControl.keyInput(Keys.Tab);
                ProcessControl.keyInput(Keys.Enter, 1500);

                bRet = ImageCompareSeq(ImageProc.m_strLogin + "2.bmp", eImagetype.total, nID);
            }
            catch (Exception e)
            {
                logs.Format(e.ToString());
                bRet = false;
            }

            return(bRet);
        }
예제 #16
0
 public void LoadData(ref Datas data)
 {
     CheckState(ProcessControl.CheckProcess(data.nPID), ref data);
 }
예제 #17
0
        public void ThreadNewSequence(int nIndex, Boolean bSingle = false)
        {
            lock (lockObject)
            {
                string strID = GetDataGridSelectID(nIndex);
                Thread_Refresh.Suspend();
                logs.Format(strID + " 로그인 시작");

                int  nID  = -1;
                bool bRet = true;
                try
                {
                    eSeq_Login eSL      = eSeq_Login.LoginExecute;
                    string     strError = "Error!! : ";
                    while (eSL != eSeq_Login.LoginComplete)
                    {
                        switch (eSL)
                        {
                        case eSeq_Login.LoginExecute:
                            bRet = ExecuteProgram(ref nID);
                            break;

                        case eSeq_Login.LoginConnect:
                            bRet = ConnectProgram(nID);
                            break;

                        case eSeq_Login.LoginSelectServer:
                            bRet = SelectSeverProgram(nID);
                            break;

                        case eSeq_Login.LoginAgree:
                            bRet = AgreeProgram(nID);
                            break;

                        case eSeq_Login.LoginInputInfo:
                            bRet = InputInfoProgram(nIndex, nID);
                            break;

                        case eSeq_Login.LoginError:
                            throw new Exception(strError);
                        }
                        if (bRet == false)
                        {
                            strError += eSL.ToString();
                            eSL       = eSeq_Login.LoginError;
                            ProcessControl.KillProcess(nID);
                        }
                        else
                        {
                            eSL++;
                        }
                    }

                    if (eSL == eSeq_Login.LoginComplete)
                    {
                        IDDatas.getDataTable()[strID].nPID = nID;
                        DataTableToDicData();
                        FC.SaveData(IDDatas);

                        ProcessControl.MiniMizedProcess(nID);
                    }
                }
                catch (Exception e)
                {
                    ProcessControl.KillProcess(nID);
                    logs.Format(e.ToString());
                }
                finally
                {
                    logs.Format(strID + ": 로그인 " + ((bRet) ? "성공" : "실패"));
                }

                Thread_Refresh.Resume();
            }
        }