コード例 #1
0
ファイル: HomeController.cs プロジェクト: subhendude/Wutnu
        public void GetCopyBlobZip()
        {
            var path = Request.MapPath("/Files/BlobCopy/");
            //Convert the memorystream to an array of bytes.
            var me     = Wutcontext.Users.Single(u => u.UserId == UserId);
            var ApiUrl = string.Format("https://{0}/api/CopyUtil/", Request.Url.Authority);
            var zip    = BlobCopyZip.SetupZip(path, me.ApiKey, ApiUrl);

            // Clear all content output from the buffer stream
            Response.Clear();
            // Add a HTTP header to the output stream that specifies the default filename
            // for the browser's download dialog
            Response.AddHeader("Content-Disposition", "attachment; filename=BlobCopy.zip");
            // Add a HTTP header to the output stream that contains the
            // content length(File Size). This lets the browser know how much data is being transfered
            Response.AddHeader("Content-Length", zip.Length.ToString());
            // Set the HTTP MIME type of the output stream
            Response.ContentType = "application/octet-stream";
            // Write the data out to the client.
            Response.BinaryWrite(zip.ToArray());
        }
コード例 #2
0
        protected void Application_Start()
        {
            try
            {
                SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

                //Registration
                ControllerBuilder.Current.DefaultNamespaces.Add("Wutnu.Controllers");
                AreaRegistration.RegisterAllAreas();

                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                GlobalConfiguration.Configure(WebApiConfig.Register);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                AntiForgeryConfig.UniqueClaimTypeIdentifier = CustomClaimTypes.ObjectIdentifier;

                Cache.RedisConnectionString = ConfigurationManager.AppSettings["RedisConnection"];
                Cache.RedisUrlDBNum         = Convert.ToInt32(ConfigurationManager.AppSettings["RedisUrlDBNum"]);
                Cache.RedisUserDBNum        = Convert.ToInt32(ConfigurationManager.AppSettings["RedisUserDBNum"]);

                //IoC
                var builder = new ContainerBuilder();
                builder.Register(c => new WutNuContext())
                .AsSelf()
                .InstancePerRequest();
                builder.Register(c => new WutCache(c.Resolve <WutNuContext>()))
                .AsSelf()
                .InstancePerRequest();

                builder.RegisterControllers(typeof(MvcApplication).Assembly);
                builder.RegisterApiControllers(typeof(MvcApplication).Assembly);

                var container = builder.Build();
                DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
                GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);

                //Settings
                Settings.Setup(ConfigurationManager.AppSettings);
                var domainName = ConfigurationManager.AppSettings["ida:RedirectUri"] + "/";
                Startup.RedirectUri = domainName;

                WutStorage.ALLOWED_CORS_ORIGINS = new List <string> {
                    ConfigurationManager.AppSettings["ida:RedirectUri"]
                };

                var  ConfigStorageCors = Convert.ToBoolean(ConfigurationManager.AppSettings["ConfigStorageCors"]);
                bool forceConfig       = true;

                if (ConfigStorageCors)
                {
                    WutStorage.ConfigureCors(forceConfig);
                }

                Utils.ApplicationName = "Wut?";

                AADGraph.GraphToken = ConfigurationManager.AppSettings["B2BGraphKey"];
                AADGraph.ClientId   = ConfigurationManager.AppSettings["ida:ClientIdB2B"];
                AADGraph.TenantName = ConfigurationManager.AppSettings["ida:TenantB2B"];
                AADGraph.LoadGroups();

                //BlobCopy zip init
                BlobCopyZip.InitZip(Settings.AppRootPath);

                //Ensure cloud reports have initialized in blob storage
                ReportManager.InitBlobReports();

                //VPP
                System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new WutVirtualPathProvider());
            }
            catch (Exception ex)
            {
                Logging.WriteToAppLog("Error during application startup", System.Diagnostics.EventLogEntryType.Error, ex);
            }
        }