public void SendReportUsingPost()
        {
            string subject = "Chameleon crash report - " + ReportInfo.MainException.GetType().FullName;
            string to      = ReportInfo.ContactEmail;
            string from    = ReportInfo.SmtpFromAddress;

            string body = BuildEmailText();

            PostSubmitter post = new PostSubmitter();

            post.Url = "http://www.isquaredsoftware.com/DUMMYPASSreport.php";
            post.PostItems.Add("subject", subject);
            post.PostItems.Add("to", to);
            post.PostItems.Add("from", from);
            post.PostItems.Add("body", body);
            post.Type = PostSubmitter.PostTypeEnum.Post;

            bw         = new BackgroundWorker();
            bw.DoWork += (sender, e) =>
            {
                string result = post.Post();
                e.Result = result;
            };

            bw.RunWorkerCompleted += (sender, e) =>
            {
                string result = (string)e.Result;

                bool successful = result.Contains("Message successfully sent");
                _view.SetEmailCompletedState(successful);
            };

            bw.RunWorkerAsync();
        }
        public void StartAsyncLoadGet(String url, String tag)
        {
            httpClient = LuaEngine.Instance.GetHttpClient(this.tag, url);
            PostSubmitter ps = new PostSubmitter(httpClient, onComplete, onFail);

            ps.Submit(contentType);
        }
        public void StartAsyncLoad(String url, String data, String tag)
        {
            String[] arr = data.Split('#');
            Dictionary <String, Object> dict = new Dictionary <String, Object>();

            bool useFor = true;

            foreach (String s in arr)
            {
                String[] arrIn = s.Split('=');
                if (arrIn.Length > 1)
                {
                    dict.Add(arrIn[0], arrIn[1]);
                }
                else
                {
                    useFor = false;
                    break;
                }
            }
            if (!useFor)
            {
                dict.Add(data, null);
            }

            httpClient = LuaEngine.Instance.GetHttpClient(this.tag, url);
            PostSubmitter ps = new PostSubmitter(httpClient, onComplete, onFail);

            ps.parameters = dict;
            ps.Submit(contentType);
        }
Exemple #4
0
        private static void log(string line, string time, string type, string sha1)
        {
            try
            {
                string        ip   = LocalIPAddress();
                PostSubmitter post = new PostSubmitter();
                post.Url = Constant.readUrl();
                post.PostItems.Add("post", DateTime.Now.ToShortTimeString());
                post.PostItems.Add("timeStamp", time);
                post.PostItems.Add("sourceIp", ip);
                post.PostItems.Add("type", type);
                post.PostItems.Add("desc", line);
                post.PostItems.Add("sha1", sha1);

                post.Type = PostSubmitter.PostTypeEnum.Post;
                string result = post.Post();


                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"shids.log", true))
                //{
                //    file.WriteLine(string.Format("[SUCCESS][{0}][{1}][{2}][{3}]", time, ip, type, line));
                //}
            }
            catch (Exception ex)
            {
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"shids.log", true))
                //{
                //    file.WriteLine(string.Format("[ERROR][{0}]", ex.Message));
                //}
            }
        }
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            //WebClient wc = new WebClient();
            string pageData;
            //pageData = wc.DownloadString("http://www.fundamentus.com.br/resultado.php");
            PostSubmitter post = new PostSubmitter();
            post.Url = "http://www.fundamentus.com.br/resultado.php";
            post.PostItems.Add("pl_min", "1");
            post.PostItems.Add("pl_max", "20");
            post.PostItems.Add("roe_min", "0");
            post.PostItems.Add("pvp_min", "0");
            post.PostItems.Add("pvp_max", "10");
            post.PostItems.Add("liqcorr_min", "1");
            post.PostItems.Add("margemebit_min", "0");
            post.PostItems.Add("tx_cresc_rec_min", "0.08");
            post.PostItems.Add("liq_min", "100000");
            pageData = post.Post();

            List<Stock> stocks = new List<Stock>();
            HTMLSearchResult searcher = new HTMLSearchResult();
            HTMLSearchResult result;

            int i = 0;
            for (i = 0; i < 20; i++ )
            {
                result = searcher.GetTagData(pageData, "html", 1).GetTagData("body").
                            GetTagData("table").GetTagData("tr", i + 2).GetTagData("td").GetTagData("span").GetTagData("a");
                Stock stock = new Stock
                {
                    Name = result.TAGData
                };
                result = searcher.GetTagData(pageData, "html", 1).GetTagData("body").
                            GetTagData("table").GetTagData("tr", i + 2).GetTagData("td", 3);
                stock.PL = Convert.ToDouble(result.TAGData);
                result = searcher.GetTagData(pageData, "html", 1).GetTagData("body").
                            GetTagData("table").GetTagData("tr", i + 2).GetTagData("td", 16);
                stock.ROE = Convert.ToDouble(result.TAGData.Split('%').First());
                if (stock.PL > 1 && stock.PL < 20 && stock.ROE > 0)
                    stocks.Add(stock);

            }
            stocks = stocks.OrderBy(a => a.PL).ToList();
            i = 1;
            foreach (var stock in stocks)
            {
                stock.PLPosition = i;
                i++;
            }
            stocks = stocks.OrderByDescending(a => a.ROE).ToList();
            i = 1;
            foreach (var stock in stocks)
            {
                stock.ROEPosition = i;
                stock.Position = stock.PLPosition + stock.ROEPosition;
                i++;
            }

            return View(stocks.OrderBy(a=>a.Position).ToList());
        }
        private List<FpPost> GetPosts(int thread_id, int page)
        {
            PostSubmitter ps = new PostSubmitter();
            List<FpPost> posts = new List<FpPost>() { };
            ps.Type = PostSubmitter.PostTypeEnum.Get;
            ps.Url = "https://api.facepun.ch/";
            ps.PostItems.Add("username", FpAPI.Username);
            ps.PostItems.Add("password", FpAPI.Password);
            ps.PostItems.Add("action", "getposts");
            ps.PostItems.Add("thread_id", thread_id.ToString());
            ps.PostItems.Add("page", page.ToString());
            //ps.PostItems.Add("forum_id", "240");
            string response = ps.Post();
            JObject objeect = JObject.Parse(response);
            JArray events = (JArray)objeect["posts"];
            foreach (JToken ev in events)
            {
                int id = int.Parse(ev["id"].ToString());
                int userid = int.Parse(ev["userid"].ToString());
                string username = ev["username"].ToString();
                string message = ev["message"].ToString();
                //string avatar = ev["avatar"].ToString();

                FpPost post = new FpPost();
                //post.AvatarURL = avatar;
                post.UserID = userid;
                post.UserName = username;
                post.ID = id;
                post.Message = message;
                posts.Add(post);
            }
            return posts;
        }
Exemple #7
0
        public void UploadPhotoToServer(string server, byte[] photo, CallBack onSuccess, CallBack onError)
        {
            var postData = new Dictionary <string, object>()
            {
                { "access_token", this.access_token },
                { "photo", photo },
            };
            var postToServer = new PostSubmitter {
                url = server, parameters = postData
            };

            postToServer.PostResponseEvent += (sender, args) => this.SaveMessagesPhoto(
                args.Server,
                args.Photo,
                args.Hash,
                result =>
            {
                onSuccess((result as List <string>)[0]);
            },
                result =>
            {
                int i = 9;
            });
            postToServer.Submit();
        }
        public void StartAsyncLoadForm(String url, Object formData, String tag)
        {
            LuaObjectStore los = (LuaObjectStore)formData;
            Dictionary <String, Object> partList = (Dictionary <String, Object>)los.obj;

            httpClient = LuaEngine.Instance.GetHttpClient(this.tag, url);
            PostSubmitter ps = new PostSubmitter(httpClient, onComplete, onFail);

            ps.Submit(contentType);
        }
Exemple #9
0
        private static string PostHtml(string url, ref string strCookies)
        {
            PostSubmitter post = new PostSubmitter();

            System.Net.ServicePointManager.Expect100Continue = false;
            post.Url  = url;
            post.Type = PostSubmitter.PostTypeEnum.Post;
            // 加入cookies,必须是这么写,一次性添加是不正确的。
            post.strCookies = strCookies;
            string ret = post.Post();

            strCookies = post.strCookies;
            return(ret);
        }
Exemple #10
0
        public void TestMethod1()
        {
            var poster = new PostSubmitter("http://208.109.236.57:8012/recebe_post.asp", 45000)
            {
                Type = PostSubmitter.PostTypeEnum.Post
            };

            poster.PostItems.Add("campo1", "dado1§dado2§dado3");
            poster.PostItems.Add("campo2", "dado4§dado5§dado6");
            poster.PostItems.Add("campo3", "dado7§dado8§dado9");

            var resultado = poster.Post();

            Assert.IsFalse(string.IsNullOrWhiteSpace(resultado));
        }
Exemple #11
0
        private static void log(string line, string time, string type)
        {
            try
            {
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\log.log", true))
                //{
                //    file.Write(string.Format("{0} {1} {2} {3}",time,
                //    LocalIPAddress(),
                //    type,
                //    line));
                //}


                //r.Url = Constant.readUrl();
                //r.UseDefaultCredentials = true;

                //r.CallReportIncident(time,
                //    LocalIPAddress(),
                //    type,
                //    line);

                //time, LocalIPAddress(), type, line);
                string        ip   = LocalIPAddress();
                PostSubmitter post = new PostSubmitter();
                post.Url = Constant.readUrl();
                post.PostItems.Add("post", DateTime.Now.ToShortTimeString());
                post.PostItems.Add("timeStamp", time);
                post.PostItems.Add("sourceIp", ip);
                post.PostItems.Add("type", type);
                post.PostItems.Add("desc", line);
                post.Type = PostSubmitter.PostTypeEnum.Post;
                string result = post.Post();


                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"shids.log", true))
                {
                    file.WriteLine(string.Format("[SUCCESS][{0}][{1}][{2}][{3}]", time, ip, type, line));
                }
            }
            catch (Exception ex)
            {
                //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"shids.log", true))
                //{
                //    file.WriteLine(string.Format("[ERROR][{0}]", ex.Message));
                //}
            }
        }
Exemple #12
0
        public static string HttpRequest(string url, Dictionary<string,string> parameters)
        {
            string response = null;
            PostSubmitter submitter = new PostSubmitter();
          
            submitter.Type = PostTypeEnum.Post;
            submitter.PostEncoding = PostEncodingEnum.URLEncoded;
            submitter.Url = url;
            submitter.UserAgent = "Mozilla/5.0";
            parameters.ToList().ForEach(parameter =>
            {
                submitter.PostItems.Add(parameter.Key, parameter.Value);
            });

            response = submitter.Post();
            return response.Replace("&nbsp;","");
        }      
        //private methods
        private void OnOkClick(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();

            var picture = App.Settings.PhotoByUser;
            Dictionary <string, object> data = new Dictionary <string, object>()
            {
                { "user_file[]", picture.ToArray() }
            };
            PostSubmitter post = new PostSubmitter()
            {
                url = "http://www.ajapaik.ee/foto/" + App.Settings.SelectedPhoto.ID + "/upload/", parameters = data
            };

            post.theEvent += new EventHandler(post_theEvent);
            post.Submit();
        }
Exemple #14
0
    private void PostToEloqua()
    {
        PostSubmitter post = new PostSubmitter();

        post.Type = PostSubmitter.PostTypeEnum.Post;
        post.Url = "http://now.eloqua.com/e/f2.aspx";
        post.PostItems.Add("elqFormName", "MTVSForm");
        post.PostItems.Add("elqSiteID", "1163");
        post.PostItems.Add("Email", txtEmail.Text.Trim());
        post.PostItems.Add("FirstName", txtFirstName.Text.Trim());
        post.PostItems.Add("LastName", txtLastName.Text.Trim());
        post.PostItems.Add("Org", txtOrg.Text.Trim());
        post.PostItems.Add("AppType", ddlAppType.SelectedValue);
        post.PostItems.Add("elqCustomerGUID", elqCustomerGUID.Value);
        post.PostItems.Add("elqCookieWrite", elqCookieWrite.Value);

        // Add more fields here

        string result = post.Post();
    }
Exemple #15
0
    private void PostToEloqua()
    {
        PostSubmitter post = new PostSubmitter();

        post.Type = PostSubmitter.PostTypeEnum.Post;
        post.Url  = "http://now.eloqua.com/e/f2.aspx";
        post.PostItems.Add("elqFormName", "MTVSForm");
        post.PostItems.Add("elqSiteID", "1163");
        post.PostItems.Add("Email", txtEmail.Text.Trim());
        post.PostItems.Add("FirstName", txtFirstName.Text.Trim());
        post.PostItems.Add("LastName", txtLastName.Text.Trim());
        post.PostItems.Add("Org", txtOrg.Text.Trim());
        post.PostItems.Add("AppType", ddlAppType.SelectedValue);
        post.PostItems.Add("elqCustomerGUID", elqCustomerGUID.Value);
        post.PostItems.Add("elqCookieWrite", elqCookieWrite.Value);

        // Add more fields here

        string result = post.Post();
    }
Exemple #16
0
    public int Execute(int jobID)
    {
        try
        {
            var webServiceCharging3G = new WebServiceCharging3g();

            //string userName = AppEnv.GetSetting("userName_3g_WapVnm");
            //string userPass = AppEnv.GetSetting("password_3g_WapVnm");
            //string cpId = AppEnv.GetSetting("cpId_3g_WapVnm");

            string userName = AppEnv.GetSetting("userName_3g_visport");
            string userPass = AppEnv.GetSetting("password_3g_visport");
            string cpId     = AppEnv.GetSetting("cpId_3g_visport");

            string price;

            string notEnoughMoney = AppEnv.GetSetting("NotEnoughMoney");

            const string serviceType = "Charged Sub World Cup VTV";
            const string serviceName = "World_Cup_VTV";

            DataTable dtUsers = ViSport_S2_Registered_UsersController.WorldCupGetRegisterUserForChargedVtv();
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                foreach (DataRow dr in dtUsers.Rows)
                {
                    string userId = dr["User_ID"].ToString();

                    //price = "3000";
                    //string returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);

                    price = "3000";
                    string returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                    if (returnValue.Trim() == notEnoughMoney)
                    {
                        price       = "2000";
                        returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                        if (returnValue.Trim() == notEnoughMoney)
                        {
                            price       = "1000";
                            returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                        }
                    }

                    _log.Debug(" ");
                    _log.Debug(" ");
                    _log.Debug("UserId : " + userId);
                    _log.Debug("Price : " + price);
                    _log.Debug("ReturnValue : " + returnValue);
                    _log.Debug("UserName : "******" | UserPass : "******" | CpId : " + cpId);
                    _log.Debug(" ");
                    _log.Debug(" ");

                    if (returnValue == "1")//CHARGED THANH_CONG
                    {
                        #region GOI API sang VTV

                        string url = "http://worldcup.visport.vn/TelcoApi/service.php?action=VMGgiahan&msisdn=" + userId + "&price=" + price;

                        var post = new PostSubmitter();
                        post.Url  = url;
                        post.Type = PostSubmitter.PostTypeEnum.Get;
                        string message = post.Post();

                        _log.Debug(" ");
                        _log.Debug(" ");
                        _log.Debug("API Call : " + url);
                        _log.Debug("UserId : " + userId);
                        _log.Debug("Content From VTV : " + message);
                        _log.Debug(" ");
                        _log.Debug(" ");

                        //SendMtWorldCup(userId, message, dr["Service_ID"].ToString(), dr["Command_Code"].ToString(),dr["User_ID"].ToString());

                        #endregion

                        #region LOG DOANH THU

                        const string reasonLog = "Succ";

                        var logInfo = new SportGameHeroChargedUserLogInfo();

                        logInfo.ID           = ConvertUtility.ToInt32(dr["ID"].ToString());
                        logInfo.User_ID      = dr["User_ID"].ToString();
                        logInfo.Request_ID   = dr["Request_ID"].ToString();
                        logInfo.Service_ID   = dr["Service_ID"].ToString();
                        logInfo.Command_Code = dr["Command_Code"].ToString();

                        logInfo.Service_Type       = ConvertUtility.ToInt32(dr["Service_Type"].ToString());
                        logInfo.Charging_Count     = ConvertUtility.ToInt32(dr["Charging_Count"].ToString());
                        logInfo.FailedChargingTime = ConvertUtility.ToInt32(dr["FailedChargingTimes"].ToString());

                        logInfo.RegisteredTime = ConvertUtility.ToDateTime(dr["RegisteredTime"].ToString());
                        logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                        logInfo.Registration_Channel = dr["Registration_Channel"].ToString();
                        logInfo.Status   = ConvertUtility.ToInt32(dr["Status"].ToString());
                        logInfo.Operator = dr["Operator"].ToString();
                        logInfo.Price    = ConvertUtility.ToInt32(price);
                        logInfo.Reason   = reasonLog;

                        ViSport_S2_Registered_UsersController.WorldCupChargedUserLogForSubVtv6(logInfo);

                        #endregion
                    }
                }
            }
        }
        catch (Exception ex)
        {
            _log.Error("WC Loi lay Tap User VTV : " + ex);
            return(0);
        }
        return(1);
    }
        protected void Save_Data()
        {
            Status.Visible = false;
            if (ProfileDataGood())
            {
                if (Request.QueryString["eid"] != null)
                {
                    if (HairSlayer.includes.Functions.FromBase64(Request.QueryString["eid"]) == "newacc")
                    {
                        btnNext.Visible = true;
                    }
                }
                /**********GEO CODE ADDRESS*********************/
                string pst = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + Address.Text.Trim().Replace(" ", "+") + "," + City.Text.Trim().Replace(" ", "+") + "," + ddlState.SelectedValue + "&sensor=false";
                PostSubmitter post = new PostSubmitter(pst);
                post.PostItems = new System.Collections.Specialized.NameValueCollection();

                post.Type = PostSubmitter.PostTypeEnum.Post;
                string out_put = post.Post();
                XmlDocument xmlStuff = new XmlDocument();
                xmlStuff.Load(new System.IO.StringReader(out_put));
                double lat = 0, lng = 0;

                if (xmlStuff.SelectSingleNode("GeocodeResponse").FirstChild.InnerText == "OK")
                {

                    foreach (XmlNode xn in xmlStuff.SelectSingleNode("GeocodeResponse").LastChild.ChildNodes)
                    {
                        if (xn.Name == "geometry")
                        {
                            lat = Convert.ToDouble(xn.FirstChild.FirstChild.InnerText);
                            lng = Convert.ToDouble(xn.FirstChild.LastChild.InnerText);
                        }
                    }
                }
                /**********GEO CODE ADDRESS*********************/
                DataTable dtz = Worker.SqlTransaction("SELECT sp_UpdateEmail('" + Email.Text.Trim() + "', " + Request.Cookies["hr_main_ck"]["user_id"] + ")", connect_string);

                string user_id = Request.Cookies["hr_main_ck"]["user_id"];
                string sql = "UPDATE member SET city = @city, state = @state, zip = @zip, gender = @gender, latitude = @latitude, longitude = @longitude, firstname = @firstname, lastname = @lastname WHERE idMember = " + user_id;
                MySqlConnection oConn = new MySqlConnection(connect_string);
                oConn.Open();
                MySqlCommand oComm = new MySqlCommand(sql, oConn);
                oComm.Parameters.AddWithValue("@city", City.Text.Trim());
                oComm.Parameters.AddWithValue("@state", ddlState.SelectedValue);
                oComm.Parameters.AddWithValue("@zip", Zip.Text.Trim());
                oComm.Parameters.AddWithValue("@gender", ddlServicePreference.SelectedValue);
                oComm.Parameters.AddWithValue("@latitude", lat);
                oComm.Parameters.AddWithValue("@longitude", lng);
                oComm.Parameters.AddWithValue("@firstname", Firstname.Text);
                oComm.Parameters.AddWithValue("@lastname", Lastname.Text);
                oComm.ExecuteNonQuery();
                oComm.Dispose();

                Response.Cookies["hr_main_ck"]["user_id"] = user_id;
                Response.Cookies["hr_main_ck"]["user_name"] = Firstname.Text + " " + Lastname.Text;
                Response.Cookies["hr_main_ck"]["gender"] = ddlServicePreference.SelectedValue;
                Response.Cookies["hr_main_ck"]["location"] = ""; // dt.Rows[0]["location"].ToString();
                if (Request.QueryString["eid"] != null)
                {
                    string m_type = "4";
                    if (ddlServicePreference.SelectedValue == "F") { m_type = "5"; }
                    if (HairSlayer.includes.Functions.FromBase64(Request.QueryString["eid"]) == "newacc") { Response.Cookies["hr_main_ck"]["membership"] = m_type; }
                }
                Response.Cookies["hr_main_ck"]["last_visit"] = DateTime.Now.ToString();
                Response.Cookies["hr_main_ck"]["exp"] = DateTime.Now.AddDays(7).ToString();
                Response.Cookies["hr_main_ck"]["lat"] = lat.ToString();
                Response.Cookies["hr_main_ck"]["lng"] = lng.ToString();
                Response.Cookies["hr_main_ck"]["validate"] = "true";

                if (pnlShop.Visible)
                {
                    //sql = "UPDATE shop SET twitter = @twitter, facebook = @facebook, address = @address, city = @city, state = @state, zip = @zip, phone = @phone, website = @website, shop_name = @shopname, latitude = @latitude, longitude = @longitude WHERE idMember = " + Request.Cookies["hr_main_ck"]["user_id"];
                    oComm = new MySqlCommand("spShopSetup", oConn);
                    oComm.CommandType = System.Data.CommandType.StoredProcedure;
                    oComm.Parameters.AddWithValue("@mem_id", Convert.ToInt32(Request.Cookies["hr_main_ck"]["user_id"]));
                    oComm.Parameters.AddWithValue("@twitt", Twitter.Text.Trim());
                    oComm.Parameters.AddWithValue("@fbook", Facebook.Text.Trim());
                    oComm.Parameters.AddWithValue("@addr", Address.Text.Trim());
                    oComm.Parameters.AddWithValue("@city1", City.Text.Trim());
                    oComm.Parameters.AddWithValue("@state1", ddlState.SelectedValue);
                    oComm.Parameters.AddWithValue("@zip1", Zip.Text.Trim());
                    oComm.Parameters.AddWithValue("@phone1", Phone.Text.Trim());
                    oComm.Parameters.AddWithValue("@website1", Website.Text.Trim());
                    oComm.Parameters.AddWithValue("@shopname", Shopname.Text.Trim());
                    oComm.Parameters.AddWithValue("@lat", lat);
                    oComm.Parameters.AddWithValue("@lng", lng);
                    oComm.Parameters.AddWithValue("@bio1", Bio.Text.Trim().Replace(">", "").Replace("<", ""));
                    oComm.Parameters.AddWithValue("@instag", Instagram.Text.Trim());

                    MySqlDataAdapter sda = new MySqlDataAdapter(oComm);

                    System.Data.DataTable dt = new System.Data.DataTable();
                    sda.Fill(dt);

                    ShopID.Value = dt.Rows[0][0].ToString();

                    if (Request.QueryString["eid"] != null)
                    {
                        if (HairSlayer.includes.Functions.FromBase64(Request.QueryString["eid"]) == "newacc")
                        {
                            sql = "SELECT shop_name, password FROM shop JOIN member ON shop.idMember = member.idMember WHERE shop.idMember = " + Request.Cookies["hr_main_ck"]["user_id"];
                            System.Data.DataTable dt2 = Worker.SqlTransaction(sql, (System.Configuration.ConfigurationManager.ConnectionStrings["hslayer_connection"]).ToString());
                            string shop = "";
                            if (dt2.Rows.Count > 0) { shop = dt2.Rows[0]["shop_name"].ToString(); }
                            Status.Text = sql;
                            Status.Visible = true;
                            HairSlayer.includes.Functions.Create_New_Calendar(Request.Cookies["hr_main_ck"]["user_id"], Email.Text, HairSlayer.includes.Functions.FromBase64(dt2.Rows[0]["password"].ToString()), shop, Firstname.Text + " " + Lastname.Text);
                        }
                    }
                }
                oConn.Close();
                //Status.Text = "Profile succesfully updated.";
                //Status.Visible = true;
                //if (!btnNext.Visible) { btnViewProfile.Visible = true; /*btnFindStyles.Visible = true;*/ }
            }
        }
Exemple #18
0
        internal string GetWebPage(string webPageUrl, bool useCookieJar, byte[] payload)
        {
            int retries = 0;
            HttpWebResponse resp = null;
            HttpWebRequest req = null;
            RETRY:
            _lastUrl = webPageUrl;

            try
            {
                //string urlEncoded = System.Web.HttpUtility.UrlEncode(webPageUrl);
                Uri url = new Uri(webPageUrl);
                req = (HttpWebRequest)WebRequest.Create(url);
                //if (!string.IsNullOrEmpty(OutboundIp))
                //    req.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(Bind);
                //req.KeepAlive = true;
                if (XmlWebService)
                {
                    req.Accept = "application/xml";
                }
                else if (XmlHttpRequest)
                {
                    req.Accept = "text/javascript, text/html, application/xml, text/xml, */*";
                    req.Headers.Add("X-Requested-With", "XMLHttpRequest");
                }
                else
                {
                    req.Accept = Accept;
                }
                //req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; .NET CLR 3.0.30729; Creative AutoUpdate v1.40.01)";
                req.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
                req.Headers.Add("Accept-Language", "en-gb,en;q=0.5");
              //  req.Headers.Add("Accept-Language", "en-us");
                if (Compression)
                    req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                if (Referer.Any())
                    req.Referer = Referer;
                req.ProtocolVersion = HttpVersion.Version11;
                if (useCookieJar)
                    req.CookieContainer = _cookieJar;
                req.Timeout = Timeout;

                if (payload != null)
                {

                    req.Method = "POST";
                    req.ContentType = "application/x-www-form-urlencoded";
                    req.ContentLength = payload.Length;
                    Stream payloadStream = req.GetRequestStream();
                    payloadStream.Write(payload, 0, payload.Length);
                    payloadStream.Close();
                }

              //  WriteLog("START Web Rq " + webPageUrl);
                Console.WriteLine(DateTime.Now + " " + webPageUrl);
                resp = (HttpWebResponse)req.GetResponse();
            }
            catch (WebException ex)
            {

                if (retries==1)
                {
                    Console.WriteLine("trying post submitter with other method of getting webpage..........");
                    PostSubmitter post = new PostSubmitter();
                    post.Url = webPageUrl;
                    post.Type = PostSubmitter.PostTypeEnum.Post;
                    string result = post.Post();
                    return result;

                }

                //TODO: Test with PLOS URLs
                if (!SearchBase.isValidUrl(webPageUrl))
                {
                    InvalidURLException appExc = new InvalidURLException("Url Is Not Valid: " + webPageUrl, ex);
                   // ConsoleError(DateTime.Now + " Url Is Not Valid: " + webPageUrl);
                    throw appExc;
                }

                if (ex.Status == WebExceptionStatus.Timeout)
                {
                    if (retries > 5)
                        throw;

                    retries++;
                    if (retries == 5)
                        System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                    else
                        System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                   // ConsoleError(DateTime.Now + " RETRY (TO) " + webPageUrl);
                  //  WriteWarning("RETRY(WE-TO) " + webPageUrl);
                    if (useCookieJar && ClearCookieJarOnTimeout)
                        _cookieJar = new CookieContainer();
                    goto RETRY;
                }
                else if (ex.Status == WebExceptionStatus.ProtocolError)
                {
                    if (retries >= 1)
                    {
                        throw;
                    }

                    retries++;
                    resp = (HttpWebResponse)ex.Response;

                    //Common errors - least to most serious
                    if (resp.StatusCode == HttpStatusCode.NotFound)
                    {
                        System.Threading.Thread.Sleep(60 * 1000);
                       // ConsoleError(DateTime.Now + " RETRY (PE-NF) " + webPageUrl);
                      //  WriteWarning("RETRY(WE-PE-NF) " + webPageUrl);
                    }
                    else if (resp.StatusCode == HttpStatusCode.GatewayTimeout)
                    {
                        if (retries == 2)
                            System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                        else
                            System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                      //  ConsoleError(DateTime.Now + " RETRY (PE-GT) " + webPageUrl);
                        //WriteWarning("RETRY(WE-PE-GT) " + webPageUrl);
                    }
                    else if (resp.StatusCode == HttpStatusCode.InternalServerError)
                    {
                        if (retries == 2)
                            System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                        else
                            System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                       // ConsoleError(DateTime.Now + " RETRY (PE-IS) " + webPageUrl);
                        //WriteWarning("RETRY(WE-PE-IS) " + webPageUrl);
                    }
                    else if (resp.StatusCode == HttpStatusCode.ServiceUnavailable)
                    {
                        if (retries == 2)
                            System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                        else
                            System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                       // ConsoleError(DateTime.Now + " RETRY (PE-SU) " + webPageUrl);
                       // WriteWarning("RETRY(WE-PE-SU) " + webPageUrl);
                    }
                    else if (resp.StatusCode == HttpStatusCode.Forbidden)
                    {
                        if (retries == 2)
                            System.Threading.Thread.Sleep(24 * 60 * 60 * 1000);
                        else
                            System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                       // ConsoleError(DateTime.Now + " RETRY (PE-FO) " + webPageUrl);
                       // WriteWarning("RETRY(WE-PE-FO) " + webPageUrl);
                    }
                    else
                    {
                        if (retries == 2)
                            System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                        else
                            System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                       // ConsoleError(DateTime.Now + " RETRY (PE) " + webPageUrl);
                       // WriteWarning("RETRY(WE-PE) " + webPageUrl);
                    }
                    goto RETRY;
                }
                else if (ex.Status == WebExceptionStatus.ConnectFailure)
                {
                    if (retries > 2)
                        throw;

                    retries++;
                    if (retries == 2)
                        System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                    else
                        System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                  //  ConsoleError(DateTime.Now + " RETRY (CF) " + webPageUrl);
                    //WriteWarning("RETRY(WE-CF) " + webPageUrl);
                    goto RETRY;
                }
                else if (ex.Status == WebExceptionStatus.ReceiveFailure)
                {
                    if (retries > 2)
                        throw;

                    retries++;
                    if (retries == 2)
                        System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                    else
                        System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
                   // ConsoleError(DateTime.Now + " RETRY (RF) " + webPageUrl);
                    //WriteWarning("RETRY(WE-RF) " + webPageUrl);
                    goto RETRY;
                }
                else
                {
                    if (retries > 1)
                        throw;

                    retries++;
                    System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                 //   ConsoleError(DateTime.Now + " RETRY (OE) " + webPageUrl);
                  //  WriteWarning("RETRY(WE-OE) " + webPageUrl);
                    goto RETRY;
                }
            }
            catch (UriFormatException uriEx)
            {
               // UpdateConsoleTitle(CrawlerName + " - " + uriEx.Message);
                var appExc = new InvalidURLException("Url Is Not Valid: " + webPageUrl, uriEx);
               // ConsoleError(DateTime.Now + " Url Is Not Valid: " + webPageUrl);
                throw appExc;
            }

            if (resp != null)
            {
                LastResponseHeaders = resp.Headers;
                _lastResponseCookies = resp.Cookies;
                foreach (System.Net.Cookie c in _lastResponseCookies)
                {
                    //WriteLog("cookie: " + c);
                }

                LastResponseStatusCode = resp.StatusCode;
               // UpdateConsoleTitle(CrawlerName + " - " + LastResponseStatusCode);
                LastResponseUri = resp.ResponseUri;

                //CharacterSet defaults to "ISO-8859-1" - Elsevier can have a null CharacterSet
                if (!string.IsNullOrEmpty(resp.CharacterSet))
                    LastResponseEncoding = resp.CharacterSet.ToUpper();
            }
            if (resp.ResponseUri.AbsoluteUri != req.RequestUri.AbsoluteUri)
            {
                if (retries == 0 && RetryIfRedirected)
                {
                  //  WriteLog("RetryIfRedirected " + webPageUrl);
                    Console.WriteLine(DateTime.Now + " RetryIfRedirected");
                    System.Threading.Thread.Sleep(2000);
                    retries++;
                    goto RETRY;
                }
                else
                {
                 //   WriteLog("Redirected To " + resp.ResponseUri.AbsoluteUri);
                    Console.WriteLine(DateTime.Now + " Redirected");
                }
            }

              //  WriteLog("END Web Rq");

            //http://link.aip.org/link/ASMECP/v2005/i41855a/p103/s1&Agg=doi

            MemoryStream localStream = new MemoryStream();
            byte[] serverBytes = new byte[BUFF_SIZE];
            Stream serverFile = null;

            try
            {

                //if (resp.Headers["set-cookie"] != null)
                //{
                //    string rawHeader = resp.Headers["Set-Cookie"];

                //}
                //DateTime modifiedDate = resp.LastModified;
                serverFile = resp.GetResponseStream();

                int bytesRead = 1;

                do
                {
                    bytesRead = serverFile.Read(serverBytes, 0, serverBytes.Length);
                    if (bytesRead == 0)
                    {
                        break;
                    }

                    localStream.Write(serverBytes, 0, bytesRead);

                } while (bytesRead > 0);

            }
            catch (IOException ex)
            {
                //UpdateConsoleTitle(CrawlerName + " - " + ex.Message);
                //WriteWarning(DateTime.Now + " " + ex);
               // WriteWarning(DateTime.Now + " " + webPageUrl);

                if (retries > 5)
                    throw;

                retries++;
                System.Threading.Thread.Sleep(RetrySleepMultiplier * retries);
               // WriteWarning("RETRY(IO) " + webPageUrl);
                goto RETRY;

            }
            catch (WebException ex)
            {
               // UpdateConsoleTitle(CrawlerName + " - " + ex.Message);
               // WriteWarning(DateTime.Now + " " + ex);
               // WriteWarning(DateTime.Now + " " + webPageUrl);
               // WriteWarning("WebException.Status: " + ex.Status);

                if (ex.Status == WebExceptionStatus.Timeout)
                {
                    if (retries > 5)
                        throw;

                    retries++;
                    if (retries == 5)
                        System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                    else
                        System.Threading.Thread.Sleep(RetrySleepMultiplier*retries);
                    //ConsoleError(DateTime.Now + " RETRY (TO) " + webPageUrl);
                    //WriteWarning("RETRY(WE-TO) " + webPageUrl);
                    if (useCookieJar && ClearCookieJarOnTimeout)
                        _cookieJar = new CookieContainer();
                    goto RETRY;
                }
                else
                {
                    if (retries > 1)
                        throw;

                    retries++;
                    System.Threading.Thread.Sleep(4 * 60 * 60 * 1000);
                    //ConsoleError(DateTime.Now + " RETRY (OE) " + webPageUrl);
                   // WriteWarning("RETRY(WE-OE) " + webPageUrl);
                    goto RETRY;
                }
            }
            finally
            {
                if (serverFile != null) serverFile.Close();
                if (localStream != null) localStream.Close();
                if (resp != null) resp.Close();
            }

            //File.SetLastWriteTime(localFile, modifiedDate);

            //This assumes LastResponseEncoding (HttpWebResponse.CharacterSet) is an acceptable character set
            _lastResponsePayload = Encoding.GetEncoding(LastResponseEncoding).GetString(localStream.ToArray());

            //Look inside content to override encoding
            //UTF-16 is untested
            //<meta charset="utf-8"/>
            //<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
            //<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
            var matchCollection = Regex.Matches(_lastResponsePayload, @"[;\s]charset=([^/>\s]+)", RegexOptions.Multiline);
            if (matchCollection.Count > 0 && matchCollection[0].Groups.Count > 1)
            {
                var charset = matchCollection[0].Groups[1].Value.Replace("\"", "").Replace("'", "").ToUpper();
                if (String.CompareOrdinal(LastResponseEncoding, charset) != 0)
                {
                    if (String.CompareOrdinal(charset, "ISO-8859-1") == 0 || String.CompareOrdinal(charset, "US-ASCII") == 0
                        || String.CompareOrdinal(charset, "UTF-8") == 0 || String.CompareOrdinal(charset, "UTF-16") == 0)
                    {
                        LastResponseEncoding = charset;
                        _lastResponsePayload = Encoding.GetEncoding(LastResponseEncoding).GetString(localStream.ToArray());
                    }
                    else
                    {
                      //  WriteWarning("Ignoring Unknown Character Set: " + charset);
                    }
                }
            }
               // return _lastResponsePayload;

            //  Reparing all tags------------------------------
            PostSubmitter post1 = new PostSubmitter();
            post1.Url = "http://fixmyhtml.com/";
            post1.PostItems.Add("html", _lastResponsePayload);
            post1.Type = PostSubmitter.PostTypeEnum.Post;
            string result1 = post1.Post();
             // reapiring all tags
            //   string a= HttpContext.Current.Server.HtmlEncode(_lastResponsePayload);
               //return _lastResponsePayload;
            //_lastResponsePayload = _lastResponsePayload.Replace("&#150;", "-");
            return Mono.Web.HttpUtility.HtmlDecode(result1).ToString();

               // return Mono.Web.HttpUtility.HtmlDecode(_lastResponsePayload).ToString();
        }
        protected string[] HostIpToGeo()
        {
            string sourceIP = string.IsNullOrEmpty(Request.ServerVariables["HTTP_X_FORWARDED_FOR"])
            ? Request.ServerVariables["REMOTE_ADDR"]
            : Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            string url = "http://api.ipinfodb.com/v2/ip_query.php?key={0}&ip={1}&timezone=true";

            url = String.Format(url, "90d4f5e07ed75a6ed8ad13221d88140001aebf6730eec98978151d2a455d5e95", sourceIP);

            HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();

            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();

            xdoc.Load(httpWResponse.GetResponseStream());

            string zip = "";

            foreach (System.Xml.XmlNode x in xdoc.SelectSingleNode("Response").ChildNodes)
            {
                if (x.Name == "ZipPostalCode") { zip = x.InnerText; }
            }

            /**********GEO CODE ADDRESS*********************/
            string pst = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + zip + "&sensor=false";
            PostSubmitter post = new PostSubmitter(pst);
            post.PostItems = new System.Collections.Specialized.NameValueCollection();

            post.Type = PostSubmitter.PostTypeEnum.Post;
            string out_put = post.Post();
            XmlDocument xmlStuff = new XmlDocument();
            xmlStuff.Load(new System.IO.StringReader(out_put));
            double lat = 0, lng = 0;

            if (xmlStuff.SelectSingleNode("GeocodeResponse").FirstChild.InnerText == "OK")
            {

                foreach (XmlNode xn in xmlStuff.SelectSingleNode("GeocodeResponse").LastChild.ChildNodes)
                {
                    if (xn.Name == "geometry")
                    {
                        lat = Convert.ToDouble(xn.FirstChild.FirstChild.InnerText);
                        lng = Convert.ToDouble(xn.FirstChild.LastChild.InnerText);
                    }
                }
            }
            /**********GEO CODE ADDRESS*********************/

            string[] geo = { "", "" };
            geo[0] = lat.ToString();
            geo[1] = lng.ToString();
            return geo;
        }
Exemple #20
0
 /// <summary>
 /// 	Touches the specified URL.
 /// </summary>
 /// <returns>The result of accessing specified URL.</returns>
 public string TouchUrl( UrlInfo urlInfo )
 {
     var poster = new PostSubmitter( urlInfo.Url ) { Type = PostSubmitter.PostTypeEnum.Get, PostItems = urlInfo.Args };
     var results = poster.Post();
     return results;
 }
Exemple #21
0
      public bool SignIn(AIM.Administration.Models.AllClientsAccountModel allClientsModel ) {
        var result = false;
        ClientProperties clientProperties = null;
        using( DomainContext ctx = new DomainContext() ) {
          clientProperties = ctx.ClientProperties.SingleOrDefault( x => x.AllClientsUsername == allClientsModel.UserName&& x.AllClientsPassword == allClientsModel.Password );
        }
        if( clientProperties != null ) {
          allClientsModel.ClientId = clientProperties.ClientId;
          PostSubmitter submitter = new PostSubmitter();
          submitter.Url = "https://www.aimscrm.com/api/ApiSignOn.aspx";
          submitter.Type = global::Common.Messaging.PostTypeEnum.Post;
          submitter.PostEncoding = global::Common.Messaging.PostEncodingEnum.URLEncoded;
          submitter.PostItems.Add( "email", allClientsModel.UserName );
          submitter.PostItems.Add( "password", allClientsModel.Password );
          submitter.PostItems.Add( "url", "Home.aspx" );
          result = !submitter.Post().Contains( "Invalid Email/Password" );

        }
        if( result ) {
          SignIn( allClientsModel.ClientUsername, false );            
          System.Web.HttpContext.Current.Session.Add( "allClientsAccountModel", allClientsModel );
        }
        return result;
      }
Exemple #22
0
        private void FinalLoad()
        {
            Version ver = Assembly.GetEntryAssembly().GetName().Version;

            if (_config.Fields.Elpis_Version == null || _config.Fields.Elpis_Version < ver)
            {
                _loadingPage.UpdateStatus("Running update logic...");

                string oldVer = _config.Fields.Elpis_Version.ToString();

                _config.Fields.Elpis_Version = ver;
                _config.SaveConfig();

#if APP_RELEASE
                var post = new PostSubmitter(ReleaseData.AnalyticsPostURL);

                post.Add("guid", _config.Fields.Elpis_InstallID);
                post.Add("curver", oldVer);
                post.Add("newver", _config.Fields.Elpis_Version.ToString());
                post.Add("osver", SystemInfo.GetWindowsVersion());

                try
                {
                    post.Send();
                }
                catch (Exception ex)
                {
                    Log.O(ex.ToString());
                }
#endif
            }

            _loadingPage.UpdateStatus("Loading audio engine...");
            try
            {
                _player = new Player();
                _player.Initialize(_bassRegEmail, _bassRegKey); //TODO - put this in the login sequence?
                if (_config.Fields.Proxy_Address != string.Empty)
                {
                    _player.SetProxy(_config.Fields.Proxy_Address, _config.Fields.Proxy_Port,
                                     _config.Fields.Proxy_User, _config.Fields.Proxy_Password);
                }
            }
            catch (Exception ex)
            {
                ShowError(ErrorCodes.ENGINE_INIT_ERROR, ex);
                return;
            }

            LoadLastFM();

            _player.AudioFormat = _config.Fields.Pandora_AudioFormat;
            _player.SetStationSortOrder(_config.Fields.Pandora_StationSortOrder);
            _player.Volume      = _config.Fields.Elpis_Volume;
            _player.PauseOnLock = _config.Fields.Elpis_PauseOnLock;
            _player.MaxPlayed   = _config.Fields.Elpis_MaxHistory;

            //_player.ForceSSL = _config.Fields.Misc_ForceSSL;


            _loadingPage.UpdateStatus("Setting up cache...");
            string cachePath = Path.Combine(Config.ElpisAppData, "Cache");
            if (!Directory.Exists(cachePath))
            {
                Directory.CreateDirectory(cachePath);
            }
            _player.ImageCachePath = cachePath;

            _loadingPage.UpdateStatus("Starting Web Server...");

            startWebServer();

            _loadingPage.UpdateStatus("Setting up UI...");

            this.Dispatch(() => {
                _keyHost = new HotKeyHost(this);
                ConfigureHotKeys();
            });

            //this.Dispatch(SetupJumpList);

            this.Dispatch(SetupNotifyIcon);

            this.Dispatch(() => mainBar.DataContext = _player); //To bind playstate

            this.Dispatch(SetupPages);
            this.Dispatch(SetupUIEvents);
            this.Dispatch(SetupPageEvents);

            if (_config.Fields.Login_AutoLogin &&
                (!string.IsNullOrEmpty(_config.Fields.Login_Email)) &&
                (!string.IsNullOrEmpty(_config.Fields.Login_Password)))
            {
                _player.Connect(_config.Fields.Login_Email, _config.Fields.Login_Password);
            }
            else
            {
                transitionControl.ShowPage(_loginPage);
            }

            this.Dispatch(() => mainBar.Volume = _player.Volume);

            _finalComplete = true;
        }
        protected string[] HostIpToGeo()
        {
            /**********GEO CODE ADDRESS*********************/
            string pst = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + search_location.Text.Trim().Replace("<", "").Replace(">", "") + "&sensor=false";
            PostSubmitter post = new PostSubmitter(pst);
            post.PostItems = new System.Collections.Specialized.NameValueCollection();

            post.Type = PostSubmitter.PostTypeEnum.Post;
            string out_put = post.Post();
            XmlDocument xmlStuff = new XmlDocument();
            xmlStuff.Load(new System.IO.StringReader(out_put));
            double lat = 0, lng = 0;

            if (xmlStuff.SelectSingleNode("GeocodeResponse").FirstChild.InnerText == "OK")
            {

                foreach (XmlNode xn in xmlStuff.SelectSingleNode("GeocodeResponse").LastChild.ChildNodes)
                {
                    if (xn.Name == "geometry")
                    {
                        lat = Convert.ToDouble(xn.FirstChild.FirstChild.InnerText);
                        lng = Convert.ToDouble(xn.FirstChild.LastChild.InnerText);
                    }
                }
            }
            /**********GEO CODE ADDRESS*********************/

            string[] geo = { "", "" };
            geo[0] = lat.ToString();
            geo[1] = lng.ToString();
            return geo;
        }
Exemple #24
0
 private void actualizarPhoto()
 {
     if (TomoFoto == true)
     {
         this.Focus();
         Dictionary<string, object> data = new Dictionary<string, object>()
             {
                 {"UserProfileID",uid},
                 {"UserProfilePhoto",byteArray},
             };
         PostSubmitter post = new PostSubmitter() { url = "http://www.partyonapp.com/API/updatephotoprofile/", parameters = data };
         post.Submit();
     }
     else
     {
         MessageBox.Show("You should take a picture.", "PartyOn", MessageBoxButton.OK);
     }
 }