Ejemplo n.º 1
0
        public string CreatePagination(int CurrentPage, int PageSize, int DataCount, int PageCount)
        {
            if (_type != PageDataType.DataTable && _type != PageDataType.Xml) {
                throw new Exception("only DataTable or XPathDocument can be create pagination");
            }
            _pagination = string.Empty;
            if (PageCount % 2 == 0) { throw new Exception("PageCount should just odd"); }
            int PageMax = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(DataCount) / Convert.ToDecimal(PageSize)));
            int PageIndex = CurrentPage + 1;
            StringBuilder _tempsb = new StringBuilder();
            int pagestart = PageIndex - Convert.ToInt32(Math.Floor(PageCount / 2f));
            int pageend = PageIndex + Convert.ToInt32(Math.Floor(PageCount / 2f));
            if (PageMax < 0) {
                throw new Exception("PageMax less the 0");
            } else if (PageMax <= 1) {
                _pagination = "<Pages Max=\"1\" Current=\"1\"><Page Index=\"1\" /></Pages>";
            } else if (PageMax <= PageCount) {
                pagestart = 1;
                pageend = PageMax;
            } else {
                int temp = 0;
                if (pagestart < 1) {
                    temp = 1 - pagestart;
                    pagestart = 1;
                    pageend += temp;
                }
                if (pageend > PageMax) {
                    temp = pageend - PageMax;
                    pageend = PageMax;
                    pagestart -= temp;
                }
                if (pagestart < 1) { pagestart = 1; }

            }
            if (string.IsNullOrEmpty(_pagination)) {
                _tempsb.Append(string.Format("<Pages Max=\"{0}\" Current=\"{1}\">", PageMax, PageIndex));
                for (int i = pagestart; i <= pageend; i++) {
                    _tempsb.Append(string.Format("<Page Index=\"{0}\" />", i));
                }
                _tempsb.Append("</Pages>");
                _pagination = _tempsb.ToString();
            }
            if (_type == PageDataType.Xml && !_pageable) {
                System.Xml.XPath.XPathNavigator _xPathNavigator = _dataXml.CreateNavigator();
                System.Xml.XmlDocument _xmlDocument = new System.Xml.XmlDocument();
                _xmlDocument.LoadXml(_xPathNavigator.OuterXml);
                _xPathNavigator = _xmlDocument.CreateNavigator();
                _xPathNavigator.MoveToFirstChild();
                _xPathNavigator.AppendChild(_pagination);
                _dataXml = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(_xPathNavigator.OuterXml));
            }
            _pageable = true;
            return _pagination;
        }
        /// <summary>
        /// Return a specific application log by Id.
        /// </summary>
        /// <param name="context">
        /// An System.Web.HttpContext object that provides references to the intrinsic server objects (for example, Request, Response, Session, and 
        /// Server) used to service HTTP requests.
        /// </param>
        /// <param name="itemId">Id of the application log to return.</param>
        private void ReturnApplicationLogItem(HttpContext context, int itemId)
        {
            var config = CoreWebConfiguration.Configuration.ApplicationLogRssFeed;
            var connectionStringName = config.ConnectionString.Name;

            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                connectionStringName = DefaultConnectionStringName;
            }

            var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName];
            var applicationLogRepository = new ApplicationLogRepository(connectionString.ConnectionString);
            var log = applicationLogRepository.GetById(itemId);

            var xmlDocument = new System.Xml.XmlDocument();
            var xmlNavigator = xmlDocument.CreateNavigator();

            using (var writer = xmlNavigator.AppendChild())
            {
                var serializer = new DataContractSerializer(typeof(ApplicationLogDao));
                serializer.WriteObject(writer, log);
            }

            if (null != log.Data.FirstChild)
            {
                var dataElement = xmlDocument.CreateElement("Data", xmlDocument.FirstChild.NamespaceURI);
                var importedElement = xmlDocument.ImportNode(log.Data.FirstChild, true);
                dataElement.AppendChild(importedElement);
                xmlDocument.FirstChild.AppendChild(dataElement);
            }

            context.Response.ContentType = "text/xml";
            context.Response.Output.Write(xmlDocument.InnerXml);
            context.Response.StatusCode = (int) HttpStatusCode.OK;
            context.Response.Flush();
        }
Ejemplo n.º 3
0
    // For a list of platform targets, gather all the required folder names for the generated soundbanks. The goal is to know the list of required
    // folder names for a list of platforms. The size of the returned array is not guaranteed to be the safe size at the targets array since
    // a single platform is no guaranteed to output a single soundbank folder.
    public static bool GetWwiseSoundBankDestinationFoldersByUnityPlatform(UnityEditor.BuildTarget target,
                                                                          string WwiseProjectPath, out string[] paths, out string[] platformNames)
    {
        paths         = null;
        platformNames = null;

        try
        {
            if (WwiseProjectPath.Length == 0)
            {
                return(false);
            }

            var doc = new System.Xml.XmlDocument();
            doc.Load(WwiseProjectPath);
            var configNavigator = doc.CreateNavigator();

            var pathsList         = new System.Collections.Generic.List <string>();
            var platformNamesList = new System.Collections.Generic.List <string>();

            if (platformMapping.ContainsKey(target))
            {
                var referencePlatforms = platformMapping[target];

                // For each valid reference platform name for the provided Unity platform enum, list all the valid platform names
                // defined in the Wwise project XML, and for each of those accumulate the sound bank folders. In the end,
                // resultList will contain a list of soundbank folders that are generated for the provided unity platform enum.

                foreach (var reference in referencePlatforms)
                {
                    var expression =
                        System.Xml.XPath.XPathExpression.Compile(string.Format("//Platforms/Platform[@ReferencePlatform='{0}']",
                                                                               reference));
                    var nodes = configNavigator.Select(expression);

                    while (nodes.MoveNext())
                    {
                        var platform = nodes.Current.GetAttribute("Name", "");

                        // If the sound bank path information was located either in the user configuration or the project configuration, acquire the paths
                        // for the provided platform.
                        string sbPath = null;
                        if (s_ProjectBankPaths.TryGetValue(platform, out sbPath))
                        {
#if UNITY_EDITOR_OSX
                            sbPath = sbPath.Replace('\\', System.IO.Path.DirectorySeparatorChar);
#endif
                            pathsList.Add(sbPath);
                            platformNamesList.Add(platform);
                        }
                    }
                }
            }

            if (pathsList.Count != 0)
            {
                paths         = pathsList.ToArray();
                platformNames = platformNamesList.ToArray();
                return(true);
            }
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogException(e);
        }

        return(false);
    }
Ejemplo n.º 4
0
    private static System.Collections.Generic.HashSet <AkPluginInfo> ParsePluginsXML(string platform,
                                                                                     System.Collections.Generic.List <string> in_pluginFiles)
    {
        var newPlugins = new System.Collections.Generic.HashSet <AkPluginInfo>();

        foreach (var pluginFile in in_pluginFiles)
        {
            if (!System.IO.File.Exists(pluginFile))
            {
                continue;
            }

            try
            {
                var doc = new System.Xml.XmlDocument();
                doc.Load(pluginFile);
                var Navigator      = doc.CreateNavigator();
                var pluginInfoNode = Navigator.SelectSingleNode("//PluginInfo");
                var boolMotion     = pluginInfoNode.GetAttribute("Motion", "");

                var it = Navigator.Select("//Plugin");

                if (boolMotion == "true")
                {
                    AkPluginInfo motionPluginInfo = new AkPluginInfo();
                    motionPluginInfo.DllName = "AkMotion";
                    newPlugins.Add(motionPluginInfo);
                }

                foreach (System.Xml.XPath.XPathNavigator node in it)
                {
                    var rawPluginID = uint.Parse(node.GetAttribute("ID", ""));
                    if (rawPluginID == 0)
                    {
                        continue;
                    }

                    PluginID pluginID = (PluginID)rawPluginID;

                    if (alwaysSkipPluginsIDs.Contains(pluginID))
                    {
                        continue;
                    }

                    var dll = string.Empty;

                    if (platform == "Switch")
                    {
                        if (pluginID == PluginID.AkMeter)
                        {
                            dll = "AkMeter";
                        }
                    }
                    else if (builtInPluginIDs.Contains(pluginID))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(dll))
                    {
                        dll = node.GetAttribute("DLL", "");
                    }

                    AkPluginInfo newPluginInfo = new AkPluginInfo();
                    newPluginInfo.PluginID = rawPluginID;
                    newPluginInfo.DllName  = dll;

                    if (!PluginIDToStaticLibName.TryGetValue(pluginID, out newPluginInfo.StaticLibName))
                    {
                        newPluginInfo.StaticLibName = dll;
                    }

                    newPlugins.Add(newPluginInfo);
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message);
            }
        }

        return(newPlugins);
    }
Ejemplo n.º 5
0
    private static System.Collections.Generic.HashSet <string> ParsePluginsXML(string platform,
                                                                               System.Collections.Generic.List <string> in_pluginFiles)
    {
        var newDlls = new System.Collections.Generic.HashSet <string>();

        foreach (var pluginFile in in_pluginFiles)
        {
            if (!System.IO.File.Exists(pluginFile))
            {
                continue;
            }

            try
            {
                var doc = new System.Xml.XmlDocument();
                doc.Load(pluginFile);
                var Navigator      = doc.CreateNavigator();
                var pluginInfoNode = Navigator.SelectSingleNode("//PluginInfo");
                var boolMotion     = pluginInfoNode.GetAttribute("Motion", "");

                var it = Navigator.Select("//Plugin");

                if (boolMotion == "true")
                {
                    newDlls.Add("AkMotion");
                }

                foreach (System.Xml.XPath.XPathNavigator node in it)
                {
                    var pid = uint.Parse(node.GetAttribute("ID", ""));
                    if (pid == 0)
                    {
                        continue;
                    }

                    var dll = string.Empty;

                    if (platform == "Switch")
                    {
                        if ((PluginID)pid == PluginID.WwiseMeter)
                        {
                            dll = "AkMeter";
                        }
                    }
                    else if (builtInPluginIDs.Contains((PluginID)pid))
                    {
                        continue;
                    }

                    if (string.IsNullOrEmpty(dll))
                    {
                        dll = node.GetAttribute("DLL", "");
                    }

                    newDlls.Add(dll);
                }
            }
            catch (System.Exception ex)
            {
                UnityEngine.Debug.LogError("WwiseUnity: " + pluginFile + " could not be parsed. " + ex.Message);
            }
        }

        return(newDlls);
    }
Ejemplo n.º 6
0
    // Set soundbank-related bool settings in the wproj file.
    public static bool EnableBoolSoundbankSettingInWproj(string SettingName, string WwiseProjectPath)
    {
        try
        {
            if (WwiseProjectPath.Length == 0)
            {
                return(true);
            }

            var doc = new System.Xml.XmlDocument();
            doc.PreserveWhitespace = true;
            doc.Load(WwiseProjectPath);
            var Navigator = doc.CreateNavigator();

            // Navigate the wproj file (XML format) to where our setting should be
            var pathInXml  = string.Format("/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='{0}']", SettingName);
            var expression = System.Xml.XPath.XPathExpression.Compile(pathInXml);
            var node       = Navigator.SelectSingleNode(expression);
            if (node == null)
            {
                // Setting isn't in the wproj, add it
                // Navigate to the SoundBankHeaderFilePath property (it is always there)
                expression =
                    System.Xml.XPath.XPathExpression.Compile(
                        "/WwiseDocument/ProjectInfo/Project/PropertyList/Property[@Name='SoundBankHeaderFilePath']");
                node = Navigator.SelectSingleNode(expression);
                if (node == null)
                {
                    // SoundBankHeaderFilePath not in wproj, invalid wproj file
                    UnityEngine.Debug.LogError(
                        "WwiseUnity: Could not find SoundBankHeaderFilePath property in Wwise project file. File is invalid.");
                    return(false);
                }

                // Add the setting right above SoundBankHeaderFilePath
                var propertyToInsert = string.Format("<Property Name=\"{0}\" Type=\"bool\" Value=\"True\"/>", SettingName);
                node.InsertBefore(propertyToInsert);
            }
            else if (node.GetAttribute("Value", "") == "False")
            {
                // Value is present, we simply have to modify it.
                if (!node.MoveToAttribute("Value", ""))
                {
                    return(false);
                }

                // Modify the value to true
                node.SetValue("True");
            }
            else
            {
                // Parameter already set, nothing to do!
                return(true);
            }

            doc.Save(WwiseProjectPath);
            return(true);
        }
        catch
        {
            return(false);
        }
    }