Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = Request.Url.ToString();
        ArrayList list = new ArrayList();
        string str = string.Empty;

        if (url.IndexOf("status") != -1)
        {
            string query = Request.QueryString["status"].ToString();
            switch (query.ToUpper())
            {
                case "QUERY":
                    {
                        if (url.IndexOf("storeNo") != -1)
                        {
                            string storeNo = Request.QueryString["storeNo"].ToString();

                            string path = AppDomain.CurrentDomain.BaseDirectory;
                            int idx = path.IndexOf("IMonitorWeb");
                            path = path.Substring(0, idx) + @"IMonitorAssist\bin\Debug\IMonitorAssist.exe";

                            Process p = new Process();
                            p.StartInfo.CreateNoWindow = true;
                            p.StartInfo.Arguments = "INDEXQUERY " + storeNo;
                            p.StartInfo.UseShellExecute = false;
                            p.StartInfo.FileName = path;
                            p.Start();
                            p.WaitForExit();

                            DataSet ds = SqlHelper.GetIndexQuery();
                            IndexQuery iq = new IndexQuery();
                            iq.RouterNetwork = ds.Tables[0].Rows[0]["routerNetwork"].ToString();
                            iq.PrinterNetwork = ds.Tables[0].Rows[0]["printerNetwork"].ToString();
                            iq.PrinterStatus = ds.Tables[0].Rows[0]["printerStatus"].ToString();
                            iq.TonerStatus = ds.Tables[0].Rows[0]["tonerStatus"].ToString();
                            iq.LaptopNetwork = ds.Tables[0].Rows[0]["laptopNetwork"].ToString();
                            iq.PrinterType = ds.Tables[0].Rows[0]["printerType"].ToString();
                            iq.TonerType = ds.Tables[0].Rows[0]["tonerType"].ToString();
                            list.Add(iq);
                        }
                    }
                    break;
            }
        }
        else
        {
            Response.Write("This is Iwooo Monitor System");
            Response.End();
            return;
        }

        JavaScriptSerializer json = new JavaScriptSerializer();
        str = json.Serialize(list);

        Response.Write(str);
        Response.End();
        return;
    }
Exemplo n.º 2
0
 public static void InsertIndexQuery(IndexQuery iq)
 {
     SqlParameter[] paras = {
                                 new SqlParameter("@storeNo",iq.StoreNo),
                                 new SqlParameter("@storeRegion",iq.StoreRegion),
                                 new SqlParameter("@storeType",iq.StoreType),
                                 new SqlParameter("@routerIP",iq.RouterIP),
                                 new SqlParameter("@routerNetwork",iq.RouterNetwork),
                                 new SqlParameter("@printerIP",iq.PrinterIP),
                                 new SqlParameter("@printerNetwork",iq.PrinterNetwork),
                                 new SqlParameter("@printerType",iq.PrinterType),
                                 new SqlParameter("@tonerType",iq.TonerType),
                                 new SqlParameter("@printerStatus",iq.PrinterStatus),
                                 new SqlParameter("@tonerStatus",iq.TonerStatus),
                                 new SqlParameter("@laptopNetwork",iq.LaptopNetwork),
                                 new SqlParameter("@laptopIP",iq.LaptopIP)
                            };
     SqlHelper.ExecuteNonQuery("InsertIndexQuery", paras);
 }
Exemplo n.º 3
0
        public static void SetPrinterInformation(IndexQuery iq)
        {
            RequestState state = new RequestState();
            PrinterInformation printer = new PrinterInformation();
            printer.StoreNo = iq.StoreNo;
            printer.StoreRegion = iq.StoreRegion;
            printer.StoreType = iq.StoreType;
            printer.PrinterType = iq.PrinterType;
            printer.TonerType = iq.TonerType;

            state.Host = Common.GetStoreHost(iq.StoreNo);
            state.Host.PrinterIP = iq.PrinterIP;
            state.Printer = printer;
            state.IsIndexQuery = true;
            try
            {
                if (new Ping().Send(state.Host.PrinterIP).Status == IPStatus.Success)
                {
                    BeginResponse(state);
                }
                else
                {
                    indexCount++;
                    state.Printer.PrinterStatus = "打印机无法连接";
                    state.Printer.TonerStatus = "打印机无法连接";
                    state.Printer.PrinterNetwork = "Down";
                    state.Printer.Date = DateTime.Now.ToString();
                    Console.WriteLine(count.ToString() + "/" + storeCount.ToString() + " " + state.Printer.StoreNo + ": 打印机无法连接");
                }
            }
            catch (System.Exception ex)
            {
                indexCount++;
                state.Printer.PrinterStatus = ex.Message;
                state.Printer.TonerStatus = ex.Message;
                state.Printer.PrinterNetwork = "Down";
                state.Printer.Date = DateTime.Now.ToString();
                Console.WriteLine(count.ToString() + "/" + storeCount.ToString() + " " + state.Printer.StoreNo + ": " + ex.Message.ToString());
            }

            while (true)
            {
                if (indexCount == 1)
                {
                    iq.PrinterNetwork = state.Printer.PrinterNetwork;
                    iq.PrinterStatus = state.Printer.PrinterStatus;
                    iq.TonerStatus = state.Printer.TonerStatus;
                    break;
                }
            }
        }
Exemplo n.º 4
0
 public static void SetLaptopInformation(IndexQuery iq)
 {
     LaptopInformation laptop = new LaptopInformation();
     laptop.StoreNo = iq.StoreNo;
     laptop.StoreRegion = iq.StoreRegion;
     laptop.StoreType = iq.StoreType;
     laptop.I = 0;
     laptop.Total = 1;
     laptop.Count = 0;
     laptop.IPs = iq.IPs;
     laptop.IsIndexQuery = true;
     LaptopAssist(laptop, laptop.Count);
     while (true)
     {
         if (indexlapCount == 1)
         {
             iq.LaptopNetwork = laptop.LaptopNetwork;
             iq.LaptopIP = laptop.IP;
             break;
         }
     }
 }
Exemplo n.º 5
0
        public static IndexQuery GetIndexData(string storeNo)
        {
            IndexQuery iq = new IndexQuery();
            DataSet ds = SqlHelper.GetStoreInformation(storeNo);
            iq.StoreNo = ds.Tables[0].Rows[0]["storeNo"].ToString();
            iq.StoreRegion = ds.Tables[0].Rows[0]["storeRegion"].ToString();
            iq.StoreType = ds.Tables[0].Rows[0]["storeType"].ToString();
            iq.PrinterType = ds.Tables[0].Rows[0]["printerType"].ToString();
            iq.TonerType = ds.Tables[0].Rows[0]["tonerType"].ToString();
            iq.RouterIP = ds.Tables[0].Rows[0]["routerIP"].ToString();
            iq.PrinterIP = ds.Tables[0].Rows[0]["printerIP"].ToString();
            string[] ip1 = ds.Tables[0].Rows[0]["laptopIP1"].ToString().Split(';');
            for (int j = 0; j < ip1.Length; j++)
            {
                iq.IPs.Add(ip1[j]);
            }

            string[] ip2 = ds.Tables[0].Rows[0]["laptopIP2"].ToString().Split(';');
            for (int k = 0; k < ip2.Length; k++)
            {
                iq.IPs.Add(ip2[k]);
            }
            iq.Count = 0;

            try
            {
                if (new Ping().Send(iq.RouterIP).Status == IPStatus.Success)
                {
                    iq.RouterNetwork = "Up";
                    SetPrinterInformation(iq);
                    SetLaptopInformation(iq);
                }
                else
                {
                    iq.RouterNetwork = "Down";
                    iq.PrinterNetwork = "Down";
                    iq.PrinterStatus = "";
                    iq.TonerStatus = "";
                    iq.LaptopIP = "";
                    iq.LaptopNetwork = "Down";
                    iq.PrinterService = "";
                }
            }
            catch (System.Exception ex)
            {
                iq.RouterNetwork = string.IsNullOrEmpty(iq.RouterNetwork) ? ex.Message : iq.RouterNetwork;
                iq.PrinterNetwork = string.IsNullOrEmpty(iq.PrinterNetwork) ? ex.Message : iq.PrinterNetwork;
                iq.PrinterStatus = string.IsNullOrEmpty(iq.PrinterStatus) ? ex.Message : iq.PrinterStatus;
                iq.TonerStatus = string.IsNullOrEmpty(iq.TonerStatus) ? ex.Message : iq.TonerStatus;
                iq.LaptopIP = string.IsNullOrEmpty(iq.LaptopIP) ? ex.Message : iq.LaptopIP;
                iq.LaptopNetwork = string.IsNullOrEmpty(iq.LaptopNetwork) ? ex.Message : iq.LaptopNetwork;
                iq.PrinterService = "";
            }
            return iq;
        }