serverstart/src/serverstartdlg.cpp
//------------------------------------------------------------------------------------------
// This callback will run when user press "Remove" button. It will send Access 
// "stop_server -y" command to the selected server.
//------------------------------------------------------------------------------------------
This callback will run when user press "Remove" button. It will send Access
"stop_server -y" command to the selected server.
This callback will run when user press " Remove " button . It will send Access " stop_server - y " command to the selected server .
void CServerStartDlg::OnRemove()  {
int service_port;
int tcp_addr;
CString proxy_name;
    switch(m_ModeSelector.GetCurSel()) {
        case 0 :    
                    if(NameServerGetService(m_SelectedService,service_port,tcp_addr)==1) {
	                    int socket = ConnectToServer(service_port,tcp_addr);
                        if(socket!=-1) {
                            CString command("stop_server -y");
                            DISCommand RPCcommand(command.GetBuffer(20),RESULT_BATCH_CMD_TYPE);
                            SendCommand(socket,&RPCcommand);
	                        closesocket(socket);
	                        HCURSOR save = SetCursor(LoadCursor(NULL, IDC_WAIT));
                            for(int i=0;i<400;i++) {
	                           if(NameServerGetService(m_SelectedService,service_port,tcp_addr)!=1) break;
							}
			                SetCursor(save);
						}
					}
					break;
		case 1 :    
			        proxy_name = "Proxy:"+m_SelectedService.Right(m_SelectedService.GetLength()-strlen("Dislite:"));
                    if(NameServerGetService(proxy_name,service_port,tcp_addr)==1) {
	                    int socket = ConnectToServer(service_port,tcp_addr);
                        if(socket!=-1) {
							CString command = "stop";
                            send(socket,command,strlen(command),0);
	                        closesocket(socket);
	                        HCURSOR save = SetCursor(LoadCursor(NULL, IDC_WAIT));
                            for(int i=0;i<400;i++) {
	                           if(NameServerGetService(proxy_name,service_port,tcp_addr)!=1) break;
							}
			                SetCursor(save);
						}
					} else {
                        if(NameServerGetService(m_SelectedService,service_port,tcp_addr)==1) {
	                        int socket = ConnectToServer(service_port,tcp_addr);
                            if(socket!=-1) {
                                CString command("stop_server -y");
                                DISCommand RPCcommand(command.GetBuffer(20),RESULT_BATCH_CMD_TYPE);
                                SendCommand(socket,&RPCcommand);
	                            closesocket(socket);
	                            HCURSOR save = SetCursor(LoadCursor(NULL, IDC_WAIT));
                                for(int i=0;i<400;i++) {
	                                if(NameServerGetService(m_SelectedService,service_port,tcp_addr)!=1) break;
								}
			                    SetCursor(save);
							}
						}
					}
					break;
	}
	int sel = m_ServiceList.GetCurSel();
	if(sel!=-1) {
		m_ServiceList.DeleteString(sel);
	}
}
void CServerStartDlg :: OnRemove ( ) { int service_port ; int tcp_addr ; CString proxy_name ; switch ( m_ModeSelector . GetCurSel ( ) ) { case 0 : if ( NameServerGetService ( m_SelectedService , service_port , tcp_addr ) == 1 ) { int socket = ConnectToServer ( service_port , tcp_addr ) ; if ( socket != -1 ) { CString command ( " " ) ; DISCommand RPCcommand ( command . GetBuffer ( 20 ) , RESULT_BATCH_CMD_TYPE ) ; SendCommand ( socket , & RPCcommand ) ; closesocket ( socket ) ; HCURSOR save = SetCursor ( LoadCursor ( NULL , IDC_WAIT ) ) ; for ( int i = 0 ; i < 400 ; i ++ ) { if ( NameServerGetService ( m_SelectedService , service_port , tcp_addr ) != 1 ) break ; } SetCursor ( save ) ; } } break ; case 1 : proxy_name = " " + m_SelectedService . Right ( m_SelectedService . GetLength ( ) - strlen ( " " ) ) ; if ( NameServerGetService ( proxy_name , service_port , tcp_addr ) == 1 ) { int socket = ConnectToServer ( service_port , tcp_addr ) ; if ( socket != -1 ) { CString command = " " ; send ( socket , command , strlen ( command ) , 0 ) ; closesocket ( socket ) ; HCURSOR save = SetCursor ( LoadCursor ( NULL , IDC_WAIT ) ) ; for ( int i = 0 ; i < 400 ; i ++ ) { if ( NameServerGetService ( proxy_name , service_port , tcp_addr ) != 1 ) break ; } SetCursor ( save ) ; } } else { if ( NameServerGetService ( m_SelectedService , service_port , tcp_addr ) == 1 ) { int socket = ConnectToServer ( service_port , tcp_addr ) ; if ( socket != -1 ) { CString command ( " " ) ; DISCommand RPCcommand ( command . GetBuffer ( 20 ) , RESULT_BATCH_CMD_TYPE ) ; SendCommand ( socket , & RPCcommand ) ; closesocket ( socket ) ; HCURSOR save = SetCursor ( LoadCursor ( NULL , IDC_WAIT ) ) ; for ( int i = 0 ; i < 400 ; i ++ ) { if ( NameServerGetService ( m_SelectedService , service_port , tcp_addr ) != 1 ) break ; } SetCursor ( save ) ; } } } break ; } int sel = m_ServiceList . GetCurSel ( ) ; if ( sel != -1 ) { m_ServiceList . DeleteString ( sel ) ; } }
This callback will run when user press "Remove" button.
This callback will run when user press " Remove " button .
// Will send the command only if selected service exists. // Will send stop command to the proxy and to the server