Пример #1
0
        public string ExtractThumbnail()
        {
            OpenWOPIClientConfiguration configuration = OpenWOPIClientConfiguration.Current;
            string tempfile = configuration["cache-location"] + Guid.NewGuid().ToString("N");
            using (Stream stream = this.GetDataStream())
            {
                Package package = Package.Open(stream);

                using (Stream s = package.GetPart(new Uri("/docProps/thumbnail.emf", UriKind.RelativeOrAbsolute)).GetStream())
                {
                    using (FileStream fs = new FileStream(tempfile, FileMode.CreateNew))
                    {
                        int len = 16384;
                        byte[] buffer = new byte[len];
                        int read = s.Read(buffer, 0, len);
                        while (read > 0)
                        {
                            fs.Write(buffer, 0, read);
                            read = s.Read(buffer, 0, len);
                        }
                    }
                }

            }
            return tempfile;
        }
Пример #2
0
        public OpenWOPIDiscoveryModel()
        {
            _zones = new List <OpenWOPIZone>();

            OpenWOPIClientConfiguration configuration = OpenWOPIClientConfiguration.Current;
            string protocols = configuration["protocols"];

            InternalBaseUrl = configuration["internal-url"];
            ExternalBaseUrl = configuration["external-url"];

            ProofKey = OpenWOPIProofKey.ReadFromConfiguration(configuration);

            if (protocols == "http" || protocols == "both")
            {
                if (!String.IsNullOrEmpty(InternalBaseUrl))
                {
                    _zones.Add(OpenWOPIZone.InternalHttp);
                }
                if (!String.IsNullOrEmpty(ExternalBaseUrl))
                {
                    _zones.Add(OpenWOPIZone.ExternalHttp);
                }
            }
            if (protocols == "https" || protocols == "both")
            {
                if (!String.IsNullOrEmpty(InternalBaseUrl))
                {
                    _zones.Add(OpenWOPIZone.InternalHttps);
                }
                if (!String.IsNullOrEmpty(ExternalBaseUrl))
                {
                    _zones.Add(OpenWOPIZone.ExternalHttps);
                }
            }

            var types = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
                         from type in assembly.GetTypes()
                         where (type.GetCustomAttributes(typeof(OpenWOPIAppAttribute), true).Length > 0)
                         select type).ToList();

            List <OpenWOPIApp> apps = new List <OpenWOPIApp>();

            foreach (var type in types)
            {
                apps.Add(new OpenWOPIApp(type));
            }
            foreach (var zone in _zones)
            {
                zone.Apps = apps;
            }
        }