Ejemplo n.º 1
0
            public static void Run(object args)
            {
                AsyncLookup lookup = args as AsyncLookup;

                try
                {
                    var request = HttpWebRequest.Create(string.Format(URBAN_DICTIONARY_LOOKUP_URL, lookup.word));
                    var response = request.GetResponse();
                    string result = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();

                    const string DEF_TAG = "\"definition\":";
                    int start = result.IndexOf(DEF_TAG);
                    if (start < 0)
                    {
                        lookup.plugin.Host.Reply(lookup.msg, Meebey.SmartIrc4net.SendType.Message, "Dunno what -that- means");
                        return;
                    }

                    start = start + DEF_TAG.Length + 1;
                    int end = result.IndexOf('"', start);
                    if (end < start)
                    {
                        lookup.plugin.Host.Reply(lookup.msg, Meebey.SmartIrc4net.SendType.Message, "Dunno what -that- means");
                        return;
                    }
                    string definition = result.Substring(start, end - start);

                    lookup.plugin.Host.Reply(lookup.msg, Meebey.SmartIrc4net.SendType.Message, "definition of " + lookup.word + " - " + definition);
                }
                catch
                {
                    lookup.plugin.Host.Reply(lookup.msg, Meebey.SmartIrc4net.SendType.Message, "Dunno what -that- means");
                }
            }
Ejemplo n.º 2
0
        private void btnGetImageCode_Click(object sender, EventArgs e)
        {
            _bidnumber   = txtBidNumber.Text;
            _bidpassword = txtPassword.Text;
            _idcard      = txtidcard.Text;
            _timestamp   = gettimestamp_JS();
            _requestid   = _timestamp;

            //var request = (HttpWebRequest)WebRequest.Create("https://paimai2.alltobid.com/webwcf/BidCmd.svc/WebCmd");
            var request = (HttpWebRequest)WebRequest.Create("https://paimai.alltobid.com/webwcf/BidCmd.svc/WebCmd");

            var dto = new ImageCodeDto
            {
                version   = _version,
                timestamp = _timestamp,
                requestid = _requestid,
                request   = { }, //request={}
                checkcode = EncryptWithMD5(_timestamp + _requestid + _version)
            };

            var json        = JsonConvert.SerializeObject(dto);
            var encodedJson = HttpUtility.UrlEncode(json);

            var postData = new WebCmdDto
            {
                method = "getimagecode",
                cmd    = encodedJson
            };

            var postDataJson = JsonConvert.SerializeObject(postData);

            var data = Encoding.ASCII.GetBytes(postDataJson);

            request.Method        = "POST";
            request.ContentType   = "application/json";
            request.ContentLength = data.Length;
            request.Referer       = "https://paimai.alltobid.com/pubbid/2017112001/login.htm";


            using (var stream = request.GetRequestStream())
            {
                stream.Write(data, 0, data.Length);
            }

            var response       = (HttpWebResponse)request.GetResponse();
            var responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();
            var imagedata      = responseString.Substring(responseString.IndexOf("data") + 9, 36);

            _uniqueid = imagedata;
            var imgurl = responseString.Substring(responseString.IndexOf("data") + 9 + 36 + 1, 81).Replace("\\", "");

            pictureBoxLogin.Load(imgurl);
        }
Ejemplo n.º 3
0
        public static void ReadConfig()
        {
            if (System.IO.File.Exists(@"config\config.txt"))
            {
                string input = new System.IO
                               .StreamReader(@"config\config.txt", System.Text.Encoding.Default)
                               .ReadToEnd();
                if (input.Length > 0)
                {
                    int index = 0, configParamsCounter = 0;
                    while ((index = input.IndexOf(":", index)) != -1)
                    {
                        ++configParamsCounter;
                        ++index;
                    }

                    Info = new string[configParamsCounter];
                    int beginIndex = 0;
                    int endIndex   = 0;

                    for (int p = 0; p < configParamsCounter; p++)
                    {
                        beginIndex = input.IndexOf(":", beginIndex) + 1;
                        endIndex   = input.IndexOf("\r", beginIndex);

                        for (int i = beginIndex; i < endIndex; i++)
                        {
                            Info[p] += input[i];
                        }
                    }
                }
                else
                {
                    //handle config error
                }
            }
            else
            {
                //handle error
            }
        }