コード例 #1
0
ファイル: KeepAliveJob.cs プロジェクト: CapricornZ/bidHelper
        public void Execute()
        {
            logger.Debug("KeepAliveJob.Execute()");
            string hostName = System.Net.Dns.GetHostName();
            //String epKeepAlive = this.EndPoint + "/command/keepAlive.do";
            String epKeepAlive = this.EndPoint + "/rest/service/command/keepAlive";
            RestClient restKeepAlive = new RestClient(endpoint: epKeepAlive, method: HttpVerb.POST);
            String rtn = restKeepAlive.MakeRequest(String.Format("?ip={0}", hostName));
            tobid.rest.Client client = Newtonsoft.Json.JsonConvert.DeserializeObject<tobid.rest.Client>(rtn, new OperationConvert());

            if (!this.isManual && client.operation != null && client.operation.Length > 0)
            {
                foreach (tobid.rest.Operation operation in client.operation)
                {
                    if (operation is tobid.rest.LoginOperation){

                        if (LoginJob.setConfig(client.config, operation as LoginOperation))
                            this.receiveLogin(operation, client.config);
                    } else if (operation is tobid.rest.Step1Operation) {

                        if(SubmitPriceStep1Job.setConfig(operation as Step1Operation))
                            this.receiveOperation[0](operation);
                    } else if (operation is tobid.rest.Step2Operation) {

                        if (SubmitPriceStep2Job.setConfig(operation as Step2Operation))
                            this.receiveOperation[1](operation);
                    }
                }
            }
        }
コード例 #2
0
ファイル: SchedulerJob.cs プロジェクト: CapricornZ/autobid
        public void Execute()
        {
            logger.Debug(String.Format("{0} - {1} KeepAliveJob.Execute()", Thread.CurrentThread.Name, DateTime.Now));
            string hostName = System.Net.Dns.GetHostName();
            String epKeepAlive = this.EndPoint + "/command/keepAlive.do";
            RestClient restKeepAlive = new RestClient(endpoint: epKeepAlive, method: HttpVerb.POST);
            String rtn = restKeepAlive.MakeRequest(String.Format("?ip={0}", hostName));
            tobid.rest.Client client = Newtonsoft.Json.JsonConvert.DeserializeObject<tobid.rest.Client>(rtn, new OperationConvert());
            if (client.operation != null && client.operation.Length > 0)
            {
                foreach (tobid.rest.Operation operation in client.operation)
                {
                    if(operation is tobid.rest.BidOperation){

                        if (SubmitPriceJob.setConfig(client.config, operation))
                            this.receiveOperation(operation);
                    }
                    else if (operation is tobid.rest.LoginOperation)
                    {
                        LoginJob.setConfig(client.config, operation);
                    }
                }
            }
        }
コード例 #3
0
ファイル: BidDialog.cs プロジェクト: CapricornZ/autobid
        private void onSubmit_Click(object sender, EventArgs e)
        {
            Rectangle screen = new Rectangle();
            screen = Screen.GetWorkingArea(this);

            GivePrice givePrice = new GivePrice();
            givePrice.price = this.inputBox2Object(this.textBox1);//价格
            givePrice.inputBox = this.inputBox2Object(this.textBox2);//输入价格
            givePrice.button = this.inputBox2Object(this.textBox3);//出价按钮

            SubmitPrice submit = new SubmitPrice();
            submit.captcha = new Position[]{
                this.inputBox2Object(this.textBox4),//校验码
                this.inputBox2Object(this.textBox5)//校验码提示
            };
            submit.inputBox = this.inputBox2Object(this.textBox6);//输入校验码

            string[] posBtnOK = this.textBox7.Text.Split(new char[] { ',' });
            submit.buttons = new Position[]{
                this.inputBox2Object(this.textBox7),//确定按钮
                this.inputBox2Object(this.textBox7, offsetX:186, offsetY:0)//取消按钮
            };

            this.bid = new Bid();
            this.bid.give = givePrice;
            this.bid.submit = submit;

            MessageBoxButtons messButton = MessageBoxButtons.OKCancel;
            DialogResult dr = MessageBox.Show("确定要提交该配置吗?", "提交BID配置", messButton);
            if (dr == DialogResult.OK)
            {
                string hostName = System.Net.Dns.GetHostName();
                string endpoint = this.url + "/command/operation/screenconfig/BID/accept.do";
                RestClient rest = new RestClient(endpoint: endpoint, method: HttpVerb.POST, postObj: this.bid);
                String response = rest.MakeRequest("?fromHost=" + String.Format("host:{0}, screen:{1}*{2}", hostName, screen.Width, screen.Height));
            }
        }
コード例 #4
0
ファイル: ResourceUtil.cs プロジェクト: CapricornZ/autobid
        public static Resource getInstance(String endPoint)
        {
            Resource rtn = new Resource();
            String hostName = System.Net.Dns.GetHostName();
            String epKeepAlive = endPoint + "/command/global.do";
            RestClient restGlobalConfig = new RestClient(endpoint: epKeepAlive, method: HttpVerb.GET);

            GlobalConfig global = null;
            Stream stream = null;
            String urlResource = null;
            try
            {
                logger.DebugFormat("获取全局配置...【{0}】", String.Format("{0}?ip={1}", epKeepAlive, hostName));
                String jsonResponse = restGlobalConfig.MakeRequest(String.Format("?ip={0}", hostName));
                global = Newtonsoft.Json.JsonConvert.DeserializeObject<GlobalConfig>(jsonResponse);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("获取全局配置异常:{0}", ex);
            }

            try
            {
                urlResource = endPoint + global.repository;
                logger.DebugFormat("获取全局配置资源...【{0}】", urlResource);
                stream = new HttpUtil().getAsBinary(urlResource);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("获取全局配置资源异常:{0}", ex);
            }

            IDictionary<Bitmap, String> dictPrice = new Dictionary<Bitmap, String>();
            IDictionary<Bitmap, String> dictLoading = new Dictionary<Bitmap, String>();
            IDictionary<Bitmap, String> dictTips = new Dictionary<Bitmap, String>();
            IDictionary<Bitmap, String> dictTipsNo = new Dictionary<Bitmap, String>();

            ZipInputStream zip = new ZipInputStream(stream);
            ZipEntry entry = null;
            logger.Debug("解析资源...");
            while ((entry = zip.GetNextEntry()) != null)
            {
                if (entry.IsFile)
                {
                    logger.Debug(entry.Name);
                    MemoryStream binaryStream = new MemoryStream();
                    int size = 2048;
                    byte[] data = new byte[2048];
                    while (true)
                    {
                        size = zip.Read(data, 0, data.Length);
                        if (size > 0)
                            binaryStream.Write(data, 0, size);
                        else
                            break;
                    }

                    String[] array = entry.Name.Split(new char[] { '.', '/' });
                    Bitmap bitmap = new Bitmap(binaryStream);
                    if (entry.Name.ToLower().StartsWith("price"))
                        dictPrice.Add(bitmap, array[array.Length - 2]);
                    else if (entry.Name.ToLower().StartsWith("loading"))
                        dictLoading.Add(bitmap, array[array.Length - 2]);
                    else if (entry.Name.ToLower().StartsWith("captcha.tip"))
                    {
                        if (entry.Name.ToLower().StartsWith("captcha.tip/no"))
                            dictTipsNo.Add(bitmap, array[array.Length - 2]);
                        else
                            dictTips.Add(bitmap, array[array.Length - 2]);
                    }
                }
            }

            rtn.m_tag = global.tag;
            rtn.m_price = OrcUtil.getInstance(global.price, dictPrice);
            rtn.m_tips = new OrcUtil[]{
                OrcUtil.getInstance(global.tips0, dictTips),
                OrcUtil.getInstance(global.tips1, dictTips)
            };
            rtn.m_tipsNo = OrcUtil.getInstance(global.tipsNo, dictTipsNo);
            rtn.m_loading = OrcUtil.getInstance(global.loading, dictLoading);
            return rtn;
        }