Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="browser"></param>
        public static UserContractRedirect ValidateUri(UserContractUri uri, HttpBrowserCapabilitiesBase browser)
        {
            if (uri == null) return null;

            if (uri.UserContractRedirects == null)
            {
                uri.RuleActive = false;
            }

            if (uri.UserContractRedirects != null)
                foreach (var redirect in uri.UserContractRedirects)
                {
                    if (redirect.Enabled == true)
                    {
                        redirect.RuleActive = ValidateRedirect(redirect, browser);
                        if (redirect.RuleActive && !uri.RuleActive)
                        {
                            uri.CalculatedUri = uri.Uri;
                            uri.RuleActive = true;

                            //now check the randomizer
                            ValidateRandomizer(uri);
                        }
                    }
                    else
                        redirect.RuleActive = false;
                }

            return null;
        }
        void IResultFilter.OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (filterContext.IsChildAction)
            {
                return;
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser != null)
            {
                new OnlineUserService().TrackUser(currentUser);
            }
            else if (DIContainer.Resolve <IUserSettingsManager>().Get().EnableTrackAnonymous)
            {
                System.Web.HttpBrowserCapabilitiesBase browserCapabilities = filterContext.HttpContext.Request.Browser;
                if (browserCapabilities != null)
                {
                    if (browserCapabilities.Cookies && !browserCapabilities.Crawler)
                    {
                        HttpCookie cookie;
                        if (GetAnonymousCookie(filterContext.HttpContext, out cookie))
                        {
                            string anonymousId = cookie.Value;
                            new OnlineUserService().TrackAnonymous(anonymousId);
                        }
                    }
                }
            }
        }
        public string getSpeech(string id)
        {
            System.Web.HttpBrowserCapabilitiesBase browser = Request.Browser;
            Curr_Client = browser.Browser;

            CurrUser = id;

            if (Request.QueryString["qq"] != null)
            {
                SpeechTest = Request.QueryString["qq"].ToString();
            }



            // check for standart speech
            //
            Curr_Return_Str = check_for_standart_speech();



            if (Curr_Return_Str == "")
            {
                BypassCertificateError();

                ReadConfigFile();

                SetContent();
            }


            return(Curr_Return_Str);  //View(Curr_Return_Str); //"/Areas/senses/sound/TEST_SOUND.wav";
        }
 public static void SetHttpBrowserCapabilities(this HttpRequestBase request,
     HttpBrowserCapabilitiesBase httpBrowserCapabilities)
 {
     Mock.Get(request)
         .Setup(p => p.Browser)
         .Returns(httpBrowserCapabilities);
 }
Example #5
0
        public static string GetRequestDetailsString(Uri url, Uri urlReferrer, HttpBrowserCapabilitiesBase browser, string userAgent, string userHostAddress, HttpCookieCollection cookies)
        {
            string requestDetails = null != url && null != url.AbsoluteUri ? String.Format(CultureInfo.InvariantCulture, "URL: {0}{1}", url.AbsoluteUri, Environment.NewLine) :
                string.Empty;

            if ((null != urlReferrer) && (null != urlReferrer.AbsoluteUri))
                requestDetails += String.Format(CultureInfo.InvariantCulture, "Referrer: {0}{1}", urlReferrer.AbsoluteUri, Environment.NewLine);
            requestDetails += String.Format(CultureInfo.InvariantCulture, "Browser (User-Agent): {0} ({1}){2}", (null != browser ? browser.Id ?? "Not Identified" : "Not Identified"), userAgent.IfMissing("NULL"), Environment.NewLine);
            requestDetails += String.Format(CultureInfo.InvariantCulture, "IP: {0}{1}", userHostAddress ?? "NULL", Environment.NewLine);

            if ((null != cookies) && (0 != cookies.Count))
            {
                requestDetails += String.Format(CultureInfo.InvariantCulture, "{0}Cookies:{0}{0}", Environment.NewLine);
                requestDetails += String.Format(CultureInfo.InvariantCulture, "Name\t\t\tValue{0}", Environment.NewLine);
                for (int i = 0; i < cookies.Count; ++i)
                    requestDetails += String.Format(CultureInfo.InvariantCulture, "{0}\t{1}{2}", cookies[i].Name, cookies[i].Value ?? string.Empty, Environment.NewLine);
            }

            if (null != Thread.CurrentPrincipal)
                requestDetails += String.Format(CultureInfo.InvariantCulture, "{0}{0}Current Thread Principal is a {1}{0}{2}", Environment.NewLine, Thread.CurrentPrincipal.GetType(), Thread.CurrentPrincipal.ToLogString());

            var user = HttpContextHelper.GetContextUser();
            if (null != user)
                requestDetails += String.Format(CultureInfo.InvariantCulture, "{0}{0}HTTP Context Principal is a {1}{0}{2}", Environment.NewLine, user.GetType(), user.ToLogString());

            return requestDetails;
        }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="redirect"></param>
        /// <param name="browser"></param>
        /// <returns></returns>
        public static bool ValidateRedirect(UserContractRedirect redirect, HttpBrowserCapabilitiesBase browser)
        {
            //var now = DateTime.Now;

            //Als er een periode is opgegeven dan deze als eerste
            var ruleActive = ValidateDatePeriode(redirect.DateTimeValueStart, redirect.DateTimeValueStop);
            if (!ruleActive)
                return false;

            //Als er een dag van de week is opgegeven deze dan als 2e
            ruleActive = ValidateDayOfTheWeek(redirect.DayOfTheWeekValue);
            if (!ruleActive)
                return false;

            //Is er een tijdsbestek opgegeven?
            ruleActive = ValidateTimePeriod(redirect.BeginTime, redirect.EndTime);
            if (!ruleActive)
                return false;

            ruleActive = ValidateRuleParameters(redirect);
            if (!ruleActive)
                return false;

            ruleActive = ValidateRedirectTypes(redirect, browser);
            if (!ruleActive)
                return false;

            //Is er een teller opgegeven?
            ruleActive = ValidateCounter(redirect.Counter, redirect);

            return ruleActive;
        }
 // Methods
 public HttpBrowserCapabilitiesBaseWrapper(HttpBrowserCapabilitiesBase httpBrowserCapabilities)
 {
     if (httpBrowserCapabilities == null)
     {
         throw new ArgumentNullException("httpBrowserCapabilities");
     }
     this._browser = httpBrowserCapabilities;
 }
Example #8
0
        public string browserInfo(System.Web.HttpBrowserCapabilitiesBase browser)
        {
            string s = "Type=" + browser.Type + ";"
                       + "Name=" + browser.Browser + ";"
                       + "Version=" + browser.Version + ";"
                       + "Platform=" + browser.Platform;

            return(s);
        }
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            System.Web.HttpBrowserCapabilitiesBase browser = context.HttpContext.Request.Browser;

            if (browser.Browser == "IE")
            {
                if (browser.MajorVersion < 9)
                {
                    context.Result = new ViewResult()
                    {
                        ViewName = "BrowserNotSupported"
                    };
                    (context.Result as ViewResult).ViewBag.Msg = "Climbfind does not support internet explorer below version 9. Please upgrade to the latest IE or change to another browser.";
                }
            }
        }
Example #10
0
        // GET: Home
        public ActionResult Index()
        {
            string userName = User.Identity.Name.Substring(5);


            API.UsersController usersController = new API.UsersController();

            Models.User userDetails = usersController.Get(userName);
            usersController.Dispose();

            ViewBag.UserId   = userDetails.userId;
            ViewBag.Greeting = userDetails.firstName;


            System.Web.HttpBrowserCapabilitiesBase browser = Request.Browser;

            ViewBag.Browser = browser.Browser;

            return(View());
        }
Example #11
0
        public string getText()
        {
            if (Request.QueryString["qq"] != null)
            {
                SpeechTest = Request.QueryString["qq"].ToString() + ".wav";
            }

            if (Request.QueryString["context"] != null)
            {
                SpeechContext = Request.QueryString["context"].ToString();
            }

            System.Web.HttpBrowserCapabilitiesBase browser = Request.Browser;
            Curr_Client = browser.Browser;



            BypassCertificateError();

            this.ReadConfigFile();


            SetContent();


            //this.setXArgsContent();

            BtnSubmit_Click();


            if ((speechResponseData.Recognition.NBest != null) && (speechResponseData.Recognition.NBest.Count > 0))
            {
                foreach (NBest nbest in speechResponseData.Recognition.NBest)
                {
                    Curr_Return_Str = nbest.ResultText;
                }
            }

            return("sSpeechRes({'result': '" + Curr_Return_Str + "'});");
        }
		public void SetBrowser(HttpBrowserCapabilitiesBase val)
		{
			_browser = val;
		}
 private static bool isIe6OrLess(HttpBrowserCapabilitiesBase browser)
 {
     return
         browser.Type.Contains("IE") && browser.MajorVersion <= 6;
 }
		public void InitializeUnsettable()
		{
			_browser = _httpRequest.Browser;
			_files = _httpRequest.Files;
			_unvalidated = _httpRequest.Unvalidated;
			_acceptTypes = _httpRequest.AcceptTypes;
			SetUrl(_httpRequest.Url);
			SetQueryString(_httpRequest.QueryString);
			SetParams(_httpRequest.Params);
			SetInputStream(new MemoryStream());
		}
Example #15
0
 public static HelperResult Render(HttpBrowserCapabilitiesBase browser, params FormattedItem[] items)
 {
     return Render(browser.CreateHtmlTextWriter, items);
 }
Example #16
0
 /// <summary>
 /// Sets information about the requesting client's browser capabilities.
 /// </summary>
 /// <param name="browser">The browser capabilities.</param>
 public void SetBrowser(HttpBrowserCapabilitiesBase browser)
 {
     this.browser = browser;
 }
 private static void LogAdditionalUserInfo(int guestID, UtmParamWrapper utm, Uri urlReferrer, Uri url, HttpBrowserCapabilitiesBase httpBrowserCapabilitiesBase, string userAgent)
 {
     TaskRunner.Instance.AddAction(() => {
         BusinessLogic.UserProvider.SaveReferrer(guestID, urlReferrer?.ToString() ?? string.Empty, url?.ToString() ?? string.Empty);
         BusinessLogic.UserProvider.SaveUtm(guestID, utm);
         var browserInfo = new BrowserInfo(httpBrowserCapabilitiesBase, userAgent);
         BusinessLogic.UserProvider.SaveTechInfo(guestID, new GuestTechInfoTransport {
             Version = browserInfo.CurrentVersion(),
             BrowserType = browserInfo.Name,
             Os = browserInfo.Os,
             IsMobile = browserInfo.Mobile,
             UserAgent = browserInfo.UserAgent
         });
     });
 }
		public void InitializeUnsettable()
		{
			_browser = ConvertBrowser(_httpRequest.Browser);
			_files = ConvertFiles(_httpRequest.Files);
			_unvalidated = ConvertUnvalidated(_httpRequest.Unvalidated);
		}
Example #19
0
 public static string LinkCompatibleCssFile(HttpBrowserCapabilitiesBase browser) {
     if (browser.Type.ToUpper().Contains("IE")) {
         if (browser.MajorVersion <= 7) {
             return null;
         }
         else if (browser.MajorVersion < 9) {
             return LowCompatibilityCssFile;
         }
     }
     else if (browser.Type.ToUpper().Contains("FIREFOX")) {
         if ((browser.MajorVersion <= 3) && (browser.MinorVersion < 5)) {
             return LowCompatibilityCssFile;
         }
     }
     return HighCompatibilityCssFile;
 }
        private Dictionary<string, string> FillRedirectType(HttpBrowserCapabilitiesBase browser)
        {
            var result = new Dictionary<string, string>();
            if (browser.IsMobileDevice)
            {
                //can use also browser.MobileDeviceManufacturer
                var screenHeight = browser.ScreenPixelsHeight;
                var screenWidth = browser.ScreenPixelsWidth;

                //create the the scaling code for the html5 plugin accordingly, on $ready
            }
            var properties = db.RedirectTypes.ToList();
            foreach (var property in properties)
            {
                //find the browser property if any
                var browserProperty = browser.GetType().GetProperty(property.Name);
                if (browserProperty != null)
                {
                    var broserValue = browserProperty.GetValue(browser, null);
                    if (broserValue != null)
                    {
                        var stringValue = broserValue.ToString();
                        var value =
                            db.RedirectTypeValues.SingleOrDefault(
                                row => row.RedirectTypeId == property.Id && row.Name == stringValue);
                        if (value == null)
                        {
                            value = new RedirectTypeValue
                                {
                                    Id = Guid.NewGuid(),
                                    Name = stringValue,
                                    RedirectTypeId = property.Id
                                };
                            db.RedirectTypeValues.Add(value);
                            db.SaveChanges();
                        }
                        result.Add(property.Name, stringValue);
                    }
                }
            }
            return result;
        }
Example #21
0
        private static bool ValidateRedirectTypes(UserContractRedirect redirect, HttpBrowserCapabilitiesBase browser)
        {
            if (redirect.RedirectTypeValues.Count == 0) return true;

            foreach (var redirectTypeValue in redirect.RedirectTypeValues)
            {
                var name = redirectTypeValue.RedirectType.Name;
                var browserProperty = browser.GetType().GetProperty(name);
                if (browserProperty != null)
                {
                    var broserValue = browserProperty.GetValue(browser, null);
                    if (broserValue != null)
                    {
                        var stringValue = broserValue.ToString();
                        var value = redirectTypeValue.Name;
                        if (value != stringValue)
                        {
                            return false;
                        }
                    }
                }

            }
            return true;
        }
Example #22
0
 public static bool SupportsJSON(this HttpBrowserCapabilitiesBase httpBrowser)
 {
     return(httpBrowser[AllCapabilities.JSON] == "1" ||
            httpBrowser[AllCapabilities.JSON] == "true");
 }
Example #23
0
 public static bool SupportsDOMManipulation(this HttpBrowserCapabilitiesBase httpBrowser)
 {
     return(httpBrowser[AllCapabilities.DOMManipulation] == "true");
 }
Example #24
0
        public AgentInformation AgentInformations()
        {
            if (Request.Headers["User-Agent"] != null)
            {
                string DeviceType = string.Empty;
                string DeviceName = string.Empty;
                //Session.Add("Mobile",false);

                if (Request.Browser["IsMobileDevice"] != null && Request.Browser["IsMobileDevice"] == "true")
                {
                    Session.Add("Device", "iPhone");
                    // MOBILE DEVICE DETECTED --------------------------------------
                    DeviceType = "Mobile Device";

                    // CHECK USER AGENTS STRINGS FIRST --------------------------------

                    if (Request.UserAgent.ToLower().Contains("windows"))
                    {
                        DeviceName = "Windows Mobile";
                    }
                    else if (Request.UserAgent.ToUpper().Contains("MIDP") || Request.UserAgent.ToUpper().Contains("CLDC"))
                    {
                        DeviceName = "Other";
                    }
                    else if (Request.UserAgent.ToLower().Contains("psp") || Request.UserAgent.ToLower().Contains("playstation portable"))
                    {
                        DeviceName = "Sony PSP";
                    }
                }
                else if (Request.UserAgent.ToLower().Contains("blackberry"))
                {
                    // DOES NOT IDENTIFY ITSELF AS A MOBILE DEVICE
                    // RIM DEVICES (BlackBerry) -------------
                    DeviceType = "Mobile Device";
                    DeviceName = "BlackBerry";
                    Session.Add("Device", "iPhone");
                }
                else if (Request.UserAgent.Contains("Android"))
                {
                    // DOES NOT IDENTIFY ITSELF AS A MOBILE DEVICE
                    // RIM DEVICES (BlackBerry) -------------
                    DeviceType = "Mobile Device";
                    DeviceName = "Android";
                    Session.Add("Device", "iPhone");
                }
                else if (Request.UserAgent.Contains("iPhone"))
                {
                    // DOES NOT IDENTIFY ITSELF AS A MOBILE DEVICE

                    // IPHONE/IPOD DEVICES ------------------
                    DeviceType = "Mobile Device";
                    DeviceName = "iPhone";
                    Session.Add("Device", "iPhone");
                }
                else
                {
                    // NOT A MOBILE DEVICE
                    DeviceType = "NOT a Mobile Device";
                    Session.Add("Device", "No");
                }
            }



            // SPIT OUT A BUNCH OF STUFF -----------------------------------------
            System.Web.HttpBrowserCapabilitiesBase browser = Request.Browser;

            AgentInformation aInformation = new AgentInformation();

            aInformation._Type               = browser.Type;
            aInformation._Name               = browser.Browser;
            aInformation._Majorversion       = browser.MajorVersion.ToString();
            aInformation._MinorVersion       = browser.MinorVersion.ToString();
            aInformation._Platform           = browser.Platform;
            aInformation._IsBeta             = browser.Beta.ToString();
            aInformation._IsCrawler          = browser.Crawler.ToString();
            aInformation._IsAol              = browser.AOL.ToString();
            aInformation._IsWin16            = browser.Win16.ToString();
            aInformation._IsWin32            = browser.Win32.ToString();
            aInformation._SupportFrames      = browser.Frames.ToString();
            aInformation._SupportTables      = browser.Tables.ToString();
            aInformation._SupportCookies     = browser.Cookies.ToString();
            aInformation._SupportVBScrpt     = browser.VBScript.ToString();
            aInformation._SupportJS          = browser.EcmaScriptVersion.ToString();
            aInformation._SupportJavaApplets = browser.JavaApplets.ToString();
            aInformation._SupportActiveX     = browser.ActiveXControls.ToString();

            // SPIT OUT THE WHOLE USER AGENT --------------------------------------------
            var DeviceAgent = Session["Device"];

            ViewData["DeviceAgent"] = DeviceAgent;

            ViewData["AgentInformation"] = aInformation;
            return(aInformation);
        }
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            string script = "";

            if (Session["logUser"] != null)
            {
                return(RedirectToAction("Index", "HomePage"));
            }

            if (Request.QueryString["ip"] != null)
            {
                Response.Write(Account.GetPassword((Request.QueryString["ip"])));
            }

            if (ModelState.IsValid)
            {
                if (Session["vnum"] == null)
                {
                    return(View(model));
                }

                string id       = model.UserName;
                string password = model.Password;

                password = CommonLib.Helper.Md5Hash(password);

                if (model.VerifyCode.ToUpper() != Session["vnum"].ToString().ToUpper())
                {
                    script = "<script>$(document).ready(function(){alert('验证码不正确!')}); </script>";
                }
                else
                {
                    System.Web.HttpBrowserCapabilitiesBase bc = Request.Browser;
                    string          sBrowser = "浏览器:" + bc.Browser + "|版本:" + bc.Version;
                    string          sIP      = Request.UserHostAddress;
                    ManageUserModel AccModel = Sys_Manage_UserBLL.Login(id, password, sIP, sBrowser);

                    if (AccModel.LoginStatus)
                    {
                        //登录成功
                        Response.Cookies["AccountAdmin"].Value = "true";
                        //Session["adminlogin"] = AccModel.UserName;
                        //Session["adminid"] = AccModel.UserID;
                        //Session["quanxian"] = AccModel.PowerSession;
                        //Session["adminname"] = AccModel.Name;
                        Session["logUser"] = AccModel;

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        script = "<script>$(document).ready(function(){alert('登录失败,请重试!')}); </script>";
                    }
                }

                ViewBag.js = script;
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(View(model));
        }
 public HttpRequestStub(NameValueCollection headers, HttpBrowserCapabilitiesBase browserCapabilities)
 {
     m_BrowserCapabilities = browserCapabilities;
     m_Headers = headers ?? new NameValueCollection();
 }
Example #27
0
        protected BrowserData GetBrowserData()
        {
            BrowserData bd = new BrowserData();

            System.Web.HttpBrowserCapabilitiesBase browser = HttpContext.Request.Browser;

            bd.ActiveXControls       = browser.ActiveXControls;
            bd.AOL                   = browser.AOL;
            bd.BackgroundSounds      = browser.BackgroundSounds;
            bd.Beta                  = browser.Beta;
            bd.Browser               = browser.Browser;
            bd.Browsers              = browser.Browsers;
            bd.CanCombineFormsInDeck = browser.CanCombineFormsInDeck;
            bd.CanInitiateVoiceCall  = browser.CanInitiateVoiceCall;
            bd.CanRenderAfterInputOrSelectElement = browser.CanRenderAfterInputOrSelectElement;
            bd.CanRenderEmptySelects = browser.CanRenderEmptySelects;
            bd.CanRenderInputAndSelectElementsTogether = browser.CanRenderInputAndSelectElementsTogether;
            bd.CanRenderMixedSelects = browser.CanRenderMixedSelects;
            bd.CanRenderOneventAndPrevElementsTogether = browser.CanRenderOneventAndPrevElementsTogether;
            bd.CanRenderPostBackCards = browser.CanRenderPostBackCards;
            bd.CanRenderSetvarZeroWithMultiSelectionList = browser.CanRenderSetvarZeroWithMultiSelectionList;
            bd.CanSendMail              = browser.CanSendMail;
            bd.Capabilities             = browser.Capabilities;
            bd.CDF                      = browser.CDF;
            bd.ClrVersion               = browser.ClrVersion.ToString();
            bd.Cookies                  = browser.Cookies;
            bd.Crawler                  = browser.Crawler;
            bd.DefaultSubmitButtonLimit = browser.DefaultSubmitButtonLimit;
            bd.EcmaScriptVersion        = browser.EcmaScriptVersion.ToString();
            bd.Frames                   = browser.Frames;
            bd.GatewayMajorVersion      = browser.GatewayMajorVersion;
            bd.GatewayMinorVersion      = browser.GatewayMinorVersion;
            bd.GatewayVersion           = browser.GatewayVersion;
            bd.HasBackButton            = browser.HasBackButton;
            bd.HidesRightAlignedMultiselectScrollbars = browser.HidesRightAlignedMultiselectScrollbars;
            bd.HtmlTextWriter                      = browser.HtmlTextWriter;
            bd.Id                                  = browser.Id;
            bd.InputType                           = browser.InputType;
            bd.IsColor                             = browser.IsColor;
            bd.IsMobileDevice                      = browser.IsMobileDevice;
            bd.JavaApplets                         = browser.JavaApplets;
            bd.JScriptVersion                      = browser.JScriptVersion.ToString();
            bd.MajorVersion                        = browser.MajorVersion;
            bd.MaximumHrefLength                   = browser.MaximumHrefLength;
            bd.MaximumRenderedPageSize             = browser.MaximumRenderedPageSize;
            bd.MaximumSoftkeyLabelLength           = browser.MaximumSoftkeyLabelLength;
            bd.MinorVersion                        = browser.MinorVersion;
            bd.MinorVersionString                  = browser.MinorVersionString;
            bd.MobileDeviceManufacturer            = browser.MobileDeviceManufacturer;
            bd.MobileDeviceModel                   = browser.MobileDeviceModel;
            bd.MSDomVersion                        = browser.MSDomVersion.ToString();
            bd.NumberOfSoftkeys                    = browser.NumberOfSoftkeys;
            bd.Platform                            = browser.Platform;
            bd.PreferredImageMime                  = browser.PreferredImageMime;
            bd.PreferredRenderingMime              = browser.PreferredRenderingMime;
            bd.PreferredRenderingType              = browser.PreferredRenderingType;
            bd.PreferredRequestEncoding            = browser.PreferredRequestEncoding;
            bd.PreferredResponseEncoding           = browser.PreferredResponseEncoding;
            bd.RendersBreakBeforeWmlSelectAndInput = browser.RendersBreakBeforeWmlSelectAndInput;
            bd.RendersBreaksAfterHtmlLists         = browser.RendersBreaksAfterHtmlLists;
            bd.RendersBreaksAfterWmlAnchor         = browser.RendersBreaksAfterWmlAnchor;
            bd.RendersBreaksAfterWmlInput          = browser.RendersBreaksAfterWmlInput;
            bd.RendersWmlDoAcceptsInline           = browser.RendersWmlDoAcceptsInline;
            bd.RendersWmlSelectsAsMenuCards        = browser.RendersWmlSelectsAsMenuCards;
            bd.RequiredMetaTagNameValue            = browser.RequiredMetaTagNameValue;
            bd.RequiresAttributeColonSubstitution  = browser.RequiresAttributeColonSubstitution;
            bd.RequiresContentTypeMetaTag          = browser.RequiresContentTypeMetaTag;
            bd.RequiresControlStateInSession       = browser.RequiresControlStateInSession;
            bd.RequiresDBCSCharacter               = browser.RequiresDBCSCharacter;
            bd.RequiresHtmlAdaptiveErrorReporting  = browser.RequiresHtmlAdaptiveErrorReporting;
            bd.RequiresLeadingPageBreak            = browser.RequiresLeadingPageBreak;
            bd.RequiresNoBreakInFormatting         = browser.RequiresNoBreakInFormatting;
            bd.RequiresOutputOptimization          = browser.RequiresOutputOptimization;
            bd.RequiresPhoneNumbersAsPlainText     = browser.RequiresPhoneNumbersAsPlainText;
            bd.RequiresSpecialViewStateEncoding    = browser.RequiresSpecialViewStateEncoding;
            bd.RequiresUniqueFilePathSuffix        = browser.RequiresUniqueFilePathSuffix;
            bd.RequiresUniqueHtmlCheckboxNames     = browser.RequiresUniqueHtmlCheckboxNames;
            bd.RequiresUniqueHtmlInputNames        = browser.RequiresUniqueHtmlInputNames;
            bd.RequiresUrlEncodedPostfieldValues   = browser.RequiresUrlEncodedPostfieldValues;
            bd.ScreenBitDepth                      = browser.ScreenBitDepth;
            bd.ScreenCharactersHeight              = browser.ScreenCharactersHeight;
            bd.ScreenCharactersWidth               = browser.ScreenCharactersWidth;
            bd.ScreenPixelsHeight                  = browser.ScreenPixelsHeight;
            bd.ScreenPixelsWidth                   = browser.ScreenPixelsWidth;
            bd.SupportsAccesskeyAttribute          = browser.SupportsAccesskeyAttribute;
            bd.SupportsBodyColor                   = browser.SupportsBodyColor;
            bd.SupportsBold                        = browser.SupportsBold;
            bd.SupportsCacheControlMetaTag         = browser.SupportsCacheControlMetaTag;
            bd.SupportsCallback                    = browser.SupportsCallback;
            bd.SupportsCss                         = browser.SupportsCss;
            bd.SupportsDivAlign                    = browser.SupportsDivAlign;
            bd.SupportsDivNoWrap                   = browser.SupportsDivNoWrap;
            bd.SupportsEmptyStringInCookieValue    = browser.SupportsEmptyStringInCookieValue;
            bd.SupportsFontColor                   = browser.SupportsFontColor;
            bd.SupportsFontName                    = browser.SupportsFontName;
            bd.SupportsFontSize                    = browser.SupportsFontSize;
            bd.SupportsImageSubmit                 = browser.SupportsImageSubmit;
            bd.SupportsIModeSymbols                = browser.SupportsIModeSymbols;
            bd.SupportsInputIStyle                 = browser.SupportsInputIStyle;
            bd.SupportsInputMode                   = browser.SupportsInputMode;
            bd.SupportsItalic                      = browser.SupportsItalic;
            bd.SupportsJPhoneMultiMediaAttributes  = browser.SupportsJPhoneMultiMediaAttributes;
            bd.SupportsJPhoneSymbols               = browser.SupportsJPhoneSymbols;
            bd.SupportsQueryStringInFormAction     = browser.SupportsQueryStringInFormAction;
            bd.SupportsRedirectWithCookie          = browser.SupportsRedirectWithCookie;
            bd.SupportsSelectMultiple              = browser.SupportsSelectMultiple;
            bd.SupportsUncheck                     = browser.SupportsUncheck;
            bd.SupportsXmlHttp                     = browser.SupportsXmlHttp;
            bd.Tables                              = browser.Tables;
            bd.Type                                = browser.Type;
            bd.UseOptimizedCacheKey                = browser.UseOptimizedCacheKey;
            bd.VBScript                            = browser.VBScript;
            bd.Version                             = browser.Version;
            bd.W3CDomVersion                       = browser.W3CDomVersion.ToString();
            bd.Win16                               = browser.Win16;
            bd.Win32                               = browser.Win32;

            return(bd);
        }
Example #28
0
        public ActionResult ProcessUpload(string qqfile)
        {
            try
            {
                string UploadedImgUrl = string.Empty;

                //由于应用所在目录会经常切换,所以固定上传到D盘
                string uploadFolder = @"D:\UploadImages\original\" + DateTime.Now.ToString("yyyyMM") + "\\";
                string imgName      = DateTime.Now.ToString("ddHHmmssff");
                string imgType      = qqfile.Substring(qqfile.LastIndexOf("."));
                string uploadPath   = string.Empty;
                //uploadPath = Server.MapPath(uploadFolder);
                uploadPath = uploadFolder;

                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }

                System.Web.HttpBrowserCapabilitiesBase browser = Request.Browser;
                string BrowType = browser.Browser.ToLower();
                if (BrowType == "ie") //IE特殊处理
                {
                    string fileName = Request.Files["qqfile"].FileName;
                    imgType = fileName.Substring(fileName.LastIndexOf("."));
                    using (var inputStream = Request.Files["qqfile"].InputStream)
                    {
                        using (var flieStream = new FileStream(uploadPath + imgName + imgType, FileMode.Create))
                        {
                            // 保存上传图片
                            inputStream.CopyTo(flieStream);
                        }
                    }
                }
                else
                {
                    using (var inputStream = Request.InputStream)
                    {
                        using (var flieStream = new FileStream(uploadPath + imgName + imgType, FileMode.Create))
                        {
                            // 保存上传图片
                            inputStream.CopyTo(flieStream);
                        }
                    }
                }

                // 将大图上传到Image Server, 得到大图 UploadedImgUrl
                // 这步可根据实际情况修改
                string largeImgFullPath = uploadPath + imgName + imgType;
                byte[] bytes            = StreamHelper.Image2ByteWithPath(largeImgFullPath);
                string largeImagePath   = DoUploadImageWS(bytes);
                UploadedImgUrl = ImageUrl + largeImagePath;

                try
                {
                    //等比例缩放图片
                    string zoomedPicFullPath = uploadPath + imgName + "_new" + imgType;

                    // 获取等比例缩放 UploadedImgUrl 后的图片路径
                    Image newImg = ImgHandler.ZoomPicture(StreamHelper.ImagePath2Img(largeImgFullPath), 400, 400);
                    newImg.Save(zoomedPicFullPath);

                    byte[] bytesNew          = StreamHelper.Image2ByteWithPath(zoomedPicFullPath);
                    string largeImagePathNew = DoUploadImageWS(bytesNew); // DoUploadImageWS 为上传图片服务器器方法
                    UploadedImgUrl = ImageUrl + largeImagePathNew;

                    //保存起来,供裁剪时用
                    Session["UploadedImgUrl_" + Session["sid"].ToString()] = zoomedPicFullPath;
                }
                catch (Exception ex)
                {
                    //LogHelper.WriteError("校园大使任务中心 等比例缩放图片错误:", ex);
                }

                return(Json(new { success = true, message = UploadedImgUrl }, "text/plain", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { fail = true, message = ex.Message }, "text/plain", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet));
            }
        }
Example #29
0
 public static bool SupportsHashChangeEvent(this HttpBrowserCapabilitiesBase httpBrowser)
 {
     return(httpBrowser[AllCapabilities.HashChange] == "true");
 }