Ejemplo n.º 1
0
        private static void RunAsConsole()
        {
            Service1 serv = new Service1();

            serv.StartService();

            Console.WriteLine("Running service as console. Press any key to stop.");
            Console.WriteLine("Running service as console. Press any key to stop.");

            serv.Stop();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>{
        public static void Main(string[] args)
        {
            bool console = false;

            for (int i = 0; i < args.Length; i++)
            {
                Console.WriteLine(args[i]);
                if (args[i] == "-console")
                {
                    console = true;
                    break;
                }
            }
            if (console)
            {
                Service1.RunCmd(new Service1());
            }
            else
            {
                System.ServiceProcess.ServiceBase sb = new System.ServiceProcess.ServiceBase();
                System.ServiceProcess.ServiceBase.Run(new Service1());
            }
        }
Ejemplo n.º 3
0
        public void search(Service1 obj)
        {
            obj.OnStart(null);
            conn = new MySqlConnection("server=localhost;user id=root;database=medical;pwd=123456");
            Console.Read();
            dt.ReadXml(@"D:\mySQL\report_his\20200604_55981.xml", XmlReadMode.Auto);
            int      userID     = 0;
            string   result     = "";
            string   proposal   = "";
            string   descttext  = "";
            DateTime aprotime   = DateTime.Now;
            int      aprovebyID = 0;

            foreach (DataRow item in dt.Tables[0].Rows)
            {
                userID     = (int)item["MaBacSiKetLuan"];
                result     = item["KetLuan"].ToString();
                proposal   = item["DeNghi"].ToString();
                descttext  = item["MoTa"].ToString();
                aprotime   = (DateTime)item["ThoiGianThucHien"];
                aprovebyID = (int)item["MaBacSiKetLuan"];
            }
            conn.Open();
            var          queryselect = "select * from m_study where OrgCode = " + userID;
            MySqlCommand mySql       = new MySqlCommand(queryselect, conn);
            int          id          = mySql.ExecuteNonQuery();

            if (id > 0)
            {
                conn.Close();
                conn = new MySqlConnection("server=localhost;user id=root;database=medical;pwd=123456");
                var query = "insert into m_study(UserID,Result,Proposal,DescTxt,AproTime,AproveByID) values (UserID = '" + userID + "',Result = '" + result + "',Proposal = '" + proposal + "',DescTxt ='" + descttext + "',AproTime = '" + aprotime + "',AproveByID = '" + aprovebyID + "')";
            }
            else
            {
            }
        }
Ejemplo n.º 4
0
 public static void RunCmd(Service1 obj)
 {
     obj.OnStart(null);
     obj.OnStop();
 }