private void ReceiveAndUse(UUID objectid, AssetType type)
 {
     if (type==AssetType.Clothing)
     {
         Received.Add(objectid);
     }
 }
Example #2
0
 public AssetKey(AssetType assetType, params string[] tags)
 {
     AssetType = assetType;
     Tags = tags.Select(x => x.ToUpperInvariant()).OrderBy(x => x).ToArray();
     var objects = Tags.Concat(new string[] { AssetType.ToString() }).ToArray();
     compoundKey = new CompoundKey(objects);
 }
Example #3
0
 private void CheckContainsReferences(AssetType assetType, bool expected)
 {
     AssetBase asset = new AssetBase();
     asset.Type = (sbyte)assetType;
     bool actual = asset.ContainsReferences;
     Assert.AreEqual(expected, actual, "Expected "+assetType+".ContainsReferences to be "+expected+" but was "+actual+".");
 }
Example #4
0
		/**
		 * Serialized constructor.
		 */
		public pb_MetaData(SerializationInfo info, StreamingContext context)
		{
			_fileId				= (string) info.GetValue("_fileId", typeof(string));
			_assetBundlePath	= (pb_AssetBundlePath) info.GetValue("_assetBundlePath", typeof(pb_AssetBundlePath));
			_assetType			= (AssetType) info.GetValue("_assetType", typeof(AssetType));
			componentDiff		= (pb_ComponentDiff) info.GetValue(	"componentDiff", typeof(pb_ComponentDiff));
		}
Example #5
0
        /// <summary>
        ///     Gather all the asset uuids associated with the asset referenced by a given uuid
        /// </summary>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
        /// <param name="assetType">The type of the asset for the uuid given</param>
        /// <param name="assetUuids">The assets gathered</param>
        /// <param name="scene"></param>
        public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids,
                                     IRegistryCore scene)
        {
            // avoid infinite loops
            if (assetUuids.ContainsKey(assetUuid))
                return;

            assetUuids[assetUuid] = assetType;

            switch (assetType)
            {
                case AssetType.Clothing:
                case AssetType.Bodypart:
                    GetWearableAssetUuids(assetUuid, assetUuids);
                    break;
                case AssetType.Gesture:
                    GetGestureAssetUuids(assetUuid, assetUuids);
                    break;
                case AssetType.LSLText:
                    GetScriptAssetUuids(assetUuid, assetUuids);
                    break;
                case AssetType.Object:
                    GetSceneObjectAssetUuids(assetUuid, assetUuids, scene);
                    break;
            }
        }
        public void StoreData(AssetType type, string path, IAssetCachedData metadata)
        {
            var metaDataPath = GetCachedDataFilePath(type, path);

            var data = JsonConvert.SerializeObject(metadata);
            File.WriteAllText(metaDataPath, data);
        }
 public MissingItemInfo(MemberInfo name,UUID id)
 {
     MemberName = name;
     MissingID = id;
     key = MemberName.DeclaringType.Name + "." + MemberName.Name + "=" + MissingID;
     AssetType = GuessType(name);
 }
 public AssetRequirement(AssetType type, string file, string inline = null, string addOnceToken = null)
 {
     Type = type;
     File = file;
     Inline = inline;
     AddOnceToken = addOnceToken;
 }
    virtual public void Initialize(Ilife lifeData, string resourcePath, AssetType resourceType)
    {
        m_LifeData = lifeData;
        m_iInstanceId = lifeData.GetInstanceId();

        m_ObjectInstance = GameObject.Instantiate(ResourceManager.Instance.LoadBuildInResource<GameObject>(resourcePath, resourceType));

        //load material
        string localpath = resourcePath.Substring(0, resourcePath.LastIndexOf('/'));
        m_NormalMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/Normal", AssetType.Char);
        m_HighlightMaterial = ResourceManager.Instance.LoadBuildInResource<Material>(localpath + "/SelectedHighlight", AssetType.Char);
        m_MeshRender = ComponentTool.FindChildComponent<SkinnedMeshRenderer>("Body", m_ObjectInstance);
        if (null == m_NormalMaterial || null == m_HighlightMaterial || null == m_MeshRender)
        {
            Debuger.LogWarning("can't load mesh render or normal&highlight materials !");
        }

        //mark transform
        m_CharContainer = m_ObjectInstance.AddComponent<CharTransformContainer>();
        m_CharContainer.Initialize(lifeData.GetInstanceId(), lifeData);

        if (null == m_ObjectInstance)
        {
            Debuger.LogError("Can't load resource " + resourcePath);
        }
        m_AnimatorAgent = new AnimatorAgent(m_ObjectInstance);
    }
Example #10
0
        private byte[] RequestXfer(UUID assetID, AssetType type, out string filename)
        {
            AutoResetEvent xferEvent = new AutoResetEvent(false);
            ulong xferID = 0;
            byte[] data = null;

            EventHandler<XferReceivedEventArgs> xferCallback =
                delegate(object sender, XferReceivedEventArgs e)
                    {
                        if (e.Xfer.XferID == xferID)
                        {
                            if (e.Xfer.Success)
                                data = e.Xfer.AssetData;
                            xferEvent.Set();
                        }
                    };

            Client.Assets.XferReceived += xferCallback;

            filename = assetID + ".asset";
            xferID = Client.Assets.RequestAssetXfer(filename, false, true, assetID, type, false);

            xferEvent.WaitOne(FETCH_ASSET_TIMEOUT, false);

            Client.Assets.XferReceived -= xferCallback;

            return data;
        }
        public AssetsGroup( AssetType assetType )
        {
            InitializeComponent( );

            _assets = new AssetsPool( );
            _assetType = assetType;
        }
        private string[] GetFilesInAssetPath(AssetType type)
        {
            switch (type)
            {
                case AssetType.Blueprint:
                    if (_parkitect.Paths.GetAssetPath(type) == null)
                        return new string[0];

                    return Directory.GetFiles(_parkitect.Paths.GetAssetPath(type), "*.png",
                        SearchOption.AllDirectories);
                case AssetType.Savegame:
                    if (_parkitect.Paths.GetAssetPath(type) == null)
                        return new string[0];

                    return Directory.GetFiles(_parkitect.Paths.GetAssetPath(type), "*.txt",
                        SearchOption.AllDirectories)
                        .Concat(Directory.GetFiles(_parkitect.Paths.GetAssetPath(type), "*.park",
                            SearchOption.AllDirectories)).ToArray();
                case AssetType.Mod:
                    if (_parkitect.Paths.GetAssetPath(type) == null)
                        return new string[0];
                    return Directory.GetDirectories(_parkitect.Paths.GetAssetPath(AssetType.Mod))
                        .Where(path => File.Exists(Path.Combine(path, "mod.json")))
                        .ToArray();
                default:
                    throw new Exception("unsupported asset type.");
            }
        }
 private List<string> CreateBundles(FileListsByAssetType fileListsByAssetType, AssetType assetType, Func<string, string[], Bundle> bundleFactory)
 {
     List<AssetPath> files = fileListsByAssetType.GetList(assetType);
     List<List<AssetPath>> filesByAreaController = RouteHelper.FilePathsSortedByRoute(files);
     List<string> bundleVirtualPaths = BundleHelper.AddFileListsAsBundles(_bundles, filesByAreaController, bundleFactory);
     return bundleVirtualPaths;
 }
Example #14
0
        /// <summary>
        ///   Gather all the asset uuids associated with the asset referenced by a given uuid
        /// </summary>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// <param name = "assetUuid">The uuid of the asset for which to gather referenced assets</param>
        /// <param name = "assetType">The type of the asset for the uuid given</param>
        /// <param name = "assetUuids">The assets gathered</param>
        public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids,
                                     IRegistryCore scene)
        {
            // avoid infinite loops
            if (assetUuids.ContainsKey(assetUuid))
                return;

            assetUuids[assetUuid] = assetType;

            if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
            {
                GetWearableAssetUuids(assetUuid, assetUuids);
            }
            else if (AssetType.Gesture == assetType)
            {
                GetGestureAssetUuids(assetUuid, assetUuids);
            }
            else if (AssetType.LSLText == assetType)
            {
                GetScriptAssetUuids(assetUuid, assetUuids);
            }
            else if (AssetType.Object == assetType)
            {
                GetSceneObjectAssetUuids(assetUuid, assetUuids, scene);
            }
        }
 public MultiRelationAttributeDefinition(Type type, PropertyInfo property, Type relatedType, AssetType assetType, AssetType relatedAssetType)
     : base(assetType, property.Name, false, relatedAssetType, true)
 {
     _type = type;
     _property = property;
     _relatedType = relatedType;
 }
            public Asset(string text, AssetType type)
            {
                if (text == null) throw new ArgumentNullException("text");

                Text = text;
                Type = type;
            }
 public Image GetImage(AssetType type)
 {
     return new Image()
     {
         Source =  this.LoadImage(type)
     };
 }
Example #18
0
 public Asset(AssetType type, string file, ScriptLocation location = ScriptLocation.Body, string inline = null, string addOnceToken = null)
 {
     this.Type = type;
       this.File = file;
       this.Location = location;
       this.Inline = inline;
       this.AddOnceToken = addOnceToken;
 }
Example #19
0
 public void AddAsset(string xnaName, AssetType xnaType)
 {
     Asset a = new Asset();
     a.xnaName = xnaName;
     a.assetType = xnaType;
     a.id = _asset_list.Count;
     _asset_list.Add(a);
 }
Example #20
0
 public static DirectiveParser ForType(AssetType assetType)
 {
     if (assetType == AssetType.Css)
         return CssParser;
     if (assetType == AssetType.Js)
         return JsParser;
     return null;
 }
Example #21
0
		/**
		 * Basic constructor (used on instance assets).
		 */
		public pb_MetaData()
		{
			_assetType = AssetType.Instance;
			_fileId = GUID_NOT_FOUND;
			_assetBundlePath = null;

			componentDiff = new pb_ComponentDiff();
		}
Example #22
0
 void request_OnComplete(TransferRequest request, AssetType type, UUID assetID, byte[] data)
 {
     AssetType = type;
     AssetID = assetID;
     AssetData = data;
     Status = StatusCode.Done;
     completeEvent.Set();
 }
 public MultiRelationAttributeDefinition(Type type, PropertyInfo property, Type relatedType, AssetType assetType, AssetType relatedAssetType, FilterTerm filterTerm)
     : base(assetType, property.Name+"["+filterTerm+"]", false, relatedAssetType, true)
 {
     _type = type;
     _property = property;
     _relatedType = relatedType;
     _filterTerm = filterTerm;
 }
Example #24
0
 public Asset(Guid id, string container, AssetType type, string owner, string title, Uri url)
 {
     Id = id;
     Container = container;
     Type = type;
     Owner = owner;
     Title = title;
     Url = url;
 }
        public void Initialize(AssetType assetType)
        {
            _assetType = assetType;
            _sprite = UIConstants.GetAssetTypeSprite(assetType);
            _iconColor = UIConstants.GetAssetTypeColor(assetType);

            width = UIConstants.FilterCheckBoxSize + UIConstants.FilterCheckBoxIconDistance + UIConstants.FilterIconSize;
            height = UIConstants.FilterIconSize;
        }
        public ntfGroupNotice(RadegastInstance instance, InstantMessage msg)
            : base(NotificationType.GroupNotice)
        {
            InitializeComponent();

            this.instance = instance;
            this.msg = msg;

            if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0)
            {
                type = (AssetType)msg.BinaryBucket[1];
                destinationFolderID = client.Inventory.FindFolderForType(type);
                int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower());
                if (icoIndx >= 0)
                {
                    icnItem.Image = frmMain.ResourceImages.Images[icoIndx];
                    icnItem.Visible = true;
                }
                txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19);
                btnSave.Enabled = true;
                btnSave.Visible = icnItem.Visible = txtItemName.Visible = true;
            }

            string group = string.Empty;
            string text = msg.Message.Replace("\n", System.Environment.NewLine);
            int pos = msg.Message.IndexOf('|');
            string title = msg.Message.Substring(0, pos);
            text = text.Remove(0, pos + 1);

            if (instance.Groups.ContainsKey(msg.FromAgentID))
            {
                group = instance.Groups[msg.FromAgentID].Name;
                if (instance.Groups[msg.FromAgentID].InsigniaID != UUID.Zero)
                {
                    imgGroup.Init(instance, instance.Groups[msg.FromAgentID].InsigniaID, string.Empty);
                }
            }

            lblTitle.Text = title;
            lblSentBy.Text = string.Format("Sent by {0}, {1}", msg.FromAgentName, group);
            txtNotice.Text = text;

            // Fire off event
            NotificationEventArgs args = new NotificationEventArgs(instance);
            args.Text = string.Format("{0}{1}{2}{3}{4}",
                lblTitle.Text, System.Environment.NewLine,
                lblSentBy.Text, System.Environment.NewLine,
                txtNotice.Text
                );
            if (btnSave.Visible == true)
            {
                args.Buttons.Add(btnSave);
                args.Text += string.Format("{0}Attachment: {1}", System.Environment.NewLine, txtItemName.Text);
            }
            args.Buttons.Add(btnOK);
            FireNotificationCallback(args);
        }
 public static void Initialize(TestContext context)
 {
     _typeOfString = typeof(string).AssemblyQualifiedName;
     _typeOfInt = typeof(int).AssemblyQualifiedName;
     _typeOfAssetEditable = new AssetEditable().GetType().AssemblyQualifiedName;
     _typeOfAssetStatus = new AssetStatus().GetType().AssemblyQualifiedName;
     _typeOfBool = typeof(bool).AssemblyQualifiedName;
     _typeOfAssetType = new AssetType().GetType().AssemblyQualifiedName;
 }
 protected AttributeDefinition(AssetType assetType, string name, bool nullable, AssetType relatedAssetType, bool isMultiValue)
 {
     AssetType = assetType;
     Token = $"{assetType.Token}.{name}";
     Name = name;
     IsNullable = nullable;
     RelatedAssetType = relatedAssetType;
     IsMultiValue = isMultiValue;
 }
 public AssetCreateRequest(string newName, int destinationFolderId, AssetType type)
 {
     this.destinationFolderId = destinationFolderId;
       this.newName = newName;
       this.type = (int)type;
       modelId = -1;
       workflowId = -1;
       templateId = -1;
 }
        public IEnumerable<Asset> this[AssetType type]
        {
            get
            {
                switch (type)
                {
                    case AssetType.Blueprint:
                        foreach (var path in GetFilesInAssetPath(type))
                        {
                            var metadata = _assetMetadataStorage.GetMetadata(type, path);
                            var cachedData = _assetCachedDataStorage.GetData(type, metadata, path).Result;
                            yield return new BlueprintAsset(path, metadata, cachedData);
                        }
                        break;
                    case AssetType.Savegame:
                        foreach (var path in GetFilesInAssetPath(type))
                        {
                            var metadata = _assetMetadataStorage.GetMetadata(type, path);
                            var cachedData =
                                _assetCachedDataStorage.GetData(type, metadata, path).Result as AssetWithImageCachedData;
                            yield return new SavegameAsset(path, metadata, cachedData);
                        }
                        break;
                    case AssetType.Mod:
                        foreach (var path in GetFilesInAssetPath(type))
                        {
                            ModAsset result = null;
                            try
                            {
                                var metadata = _assetMetadataStorage.GetMetadata(type, path) as IModMetadata;

                                var modInformationString = File.ReadAllText(Path.Combine(path, "mod.json"));
                                var modInformation = JsonConvert.DeserializeObject<ModInformation>(modInformationString);

                                var cachedData = metadata == null
                                    ? new AssetWithImageCachedData()
                                    : _assetCachedDataStorage.GetData(type, metadata, path).Result as
                                        AssetWithImageCachedData;

                                result = new ModAsset(path, metadata, cachedData, modInformation);
                            }
                            catch (Exception e)
                            {
                                _log.WriteLine($"Failed loading mod at path {path}", LogLevel.Fatal);
                                _log.WriteException(e);
                            }

                            if (result != null)
                                yield return result;
                        }
                        break;
                    default:
                        throw new Exception("Unsupported asset type");
                }
            }
        }
Example #31
0
    private int RecurseWorkUnit(AssetType in_type, System.IO.FileInfo in_workUnit, string in_currentPathInProj,
                                string in_currentPhysicalPath, System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons,
                                string in_parentPhysicalPath = "")
    {
        m_WwuToProcess.Remove(in_workUnit.FullName);
        var wwuIndex = -1;

        try
        {
            //Progress bar stuff
            var msg = "Parsing Work Unit " + in_workUnit.Name;
            UnityEditor.EditorUtility.DisplayProgressBar(s_progTitle, msg, m_currentWwuCnt / (float)m_totWwuCnt);
            m_currentWwuCnt++;

            in_currentPathInProj =
                System.IO.Path.Combine(in_currentPathInProj, System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name));
            in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(
                                        System.IO.Path.GetFileNameWithoutExtension(in_workUnit.Name), WwiseObjectType.WorkUnit));
            var WwuPhysicalPath = System.IO.Path.Combine(in_currentPhysicalPath, in_workUnit.Name);

            var wwu = ReplaceWwuEntry(WwuPhysicalPath, in_type, out wwuIndex);

            wwu.ParentPhysicalPath = in_parentPhysicalPath;
            wwu.PhysicalPath       = WwuPhysicalPath;
            wwu.Guid     = System.Guid.Empty;
            wwu.LastTime = System.IO.File.GetLastWriteTime(in_workUnit.FullName);

            using (var reader = System.Xml.XmlReader.Create(in_workUnit.FullName))
            {
                reader.MoveToContent();
                reader.Read();

                while (!reader.EOF && reader.ReadState == System.Xml.ReadState.Interactive)
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("WorkUnit"))
                    {
                        if (wwu.Guid.Equals(System.Guid.Empty))
                        {
                            var ID = reader.GetAttribute("ID");
                            try
                            {
                                wwu.Guid = new System.Guid(ID);
                            }
                            catch
                            {
                                UnityEngine.Debug.LogWarning("WwiseUnity: Error reading ID <" + ID + "> from work unit <" + in_workUnit.FullName + ">.");
                                throw;
                            }
                        }

                        var persistMode = reader.GetAttribute("PersistMode");
                        if (persistMode == "Reference")
                        {
                            // ReadFrom advances the reader
                            var matchedElement  = System.Xml.Linq.XNode.ReadFrom(reader) as System.Xml.Linq.XElement;
                            var newWorkUnitPath =
                                System.IO.Path.Combine(in_workUnit.Directory.FullName, matchedElement.Attribute("Name").Value + ".wwu");
                            var newWorkUnit = new System.IO.FileInfo(newWorkUnitPath);

                            // Parse the referenced Work Unit
                            if (m_WwuToProcess.Contains(newWorkUnit.FullName))
                            {
                                RecurseWorkUnit(in_type, newWorkUnit, in_currentPathInProj, in_currentPhysicalPath, in_pathAndIcons,
                                                WwuPhysicalPath);
                            }
                        }
                        else
                        {
                            // If the persist mode is "Standalone" or "Nested", it means the current XML tag
                            // is the one corresponding to the current file. We can ignore it and advance the reader
                            reader.Read();
                        }
                    }
                    else if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals("AuxBus"))
                    {
                        in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, reader.GetAttribute("Name"));
                        in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), WwiseObjectType.AuxBus));
                        var isEmpty = reader.IsEmptyElement;
                        AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex);

                        if (isEmpty)
                        {
                            in_currentPathInProj =
                                in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
                            in_pathAndIcons.RemoveLast();
                        }
                    }
                    // Busses and folders act the same for the Hierarchy: simply add them to the path
                    else if (reader.NodeType == System.Xml.XmlNodeType.Element &&
                             (reader.Name.Equals("Folder") || reader.Name.Equals("Bus")))
                    {
                        //check if node has children
                        if (!reader.IsEmptyElement)
                        {
                            // Add the folder/bus to the path
                            in_currentPathInProj = System.IO.Path.Combine(in_currentPathInProj, reader.GetAttribute("Name"));
                            if (reader.Name.Equals("Folder"))
                            {
                                in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), WwiseObjectType.Folder));
                            }
                            else if (reader.Name.Equals("Bus"))
                            {
                                in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), WwiseObjectType.Bus));
                            }
                        }

                        // Advance the reader
                        reader.Read();
                    }
                    else if (reader.NodeType == System.Xml.XmlNodeType.EndElement &&
                             (reader.Name.Equals("Folder") || reader.Name.Equals("Bus") || reader.Name.Equals("AuxBus")))
                    {
                        // Remove the folder/bus from the path
                        in_currentPathInProj =
                            in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
                        in_pathAndIcons.RemoveLast();

                        // Advance the reader
                        reader.Read();
                    }
                    else if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name.Equals(in_type.XmlElementName))
                    {
                        // Add the element to the list
                        AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex);
                    }
                    else
                    {
                        reader.Read();
                    }
                }
            }

            // Sort the newly populated Wwu alphabetically
            SortWwu(in_type, wwuIndex);
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError(e.ToString());
            wwuIndex = -1;
        }

        in_pathAndIcons.RemoveLast();
        return(wwuIndex);
    }
Example #32
0
    private static void AddElementToList(string in_currentPathInProj, System.Xml.XmlReader in_reader, AssetType in_type,
                                         System.Collections.Generic.LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, int in_wwuIndex)
    {
        switch (in_type.Type)
        {
        case WwiseObjectType.AuxBus:
        case WwiseObjectType.Event:
        case WwiseObjectType.Soundbank:
        case WwiseObjectType.GameParameter:
        case WwiseObjectType.Trigger:
        case WwiseObjectType.AcousticTexture:
        {
            var name       = in_reader.GetAttribute("Name");
            var valueToAdd = in_type.Type == WwiseObjectType.Event ? new AkWwiseProjectData.Event() : new AkWwiseProjectData.AkInformation();
            valueToAdd.Name         = name;
            valueToAdd.Guid         = new System.Guid(in_reader.GetAttribute("ID"));
            valueToAdd.PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            FlagForInsertion(valueToAdd, in_type.Type);

            switch (in_type.Type)
            {
            case WwiseObjectType.AuxBus:
                valueToAdd.Path = in_currentPathInProj;
                break;

            default:
                valueToAdd.Path = System.IO.Path.Combine(in_currentPathInProj, name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(name, in_type.Type));
                break;
            }

            switch (in_type.Type)
            {
            case WwiseObjectType.AuxBus:
                AkWwiseProjectInfo.GetData().AuxBusWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.Event:
                AkWwiseProjectInfo.GetData().EventWwu[in_wwuIndex].List.Add(valueToAdd as AkWwiseProjectData.Event);
                break;

            case WwiseObjectType.Soundbank:
                AkWwiseProjectInfo.GetData().BankWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.GameParameter:
                AkWwiseProjectInfo.GetData().RtpcWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.Trigger:
                AkWwiseProjectInfo.GetData().TriggerWwu[in_wwuIndex].List.Add(valueToAdd);
                break;

            case WwiseObjectType.AcousticTexture:
                AkWwiseProjectInfo.GetData().AcousticTextureWwu[in_wwuIndex].List.Add(valueToAdd);
                break;
            }
        }

            in_reader.Read();
            break;

        case WwiseObjectType.StateGroup:
        case WwiseObjectType.SwitchGroup:
        {
            var XmlElement      = System.Xml.Linq.XNode.ReadFrom(in_reader) as System.Xml.Linq.XElement;
            var ChildrenList    = System.Xml.Linq.XName.Get("ChildrenList");
            var ChildrenElement = XmlElement.Element(ChildrenList);
            if (ChildrenElement != null)
            {
                var name       = XmlElement.Attribute("Name").Value;
                var valueToAdd = new AkWwiseProjectData.GroupValue
                {
                    Name         = name,
                    Guid         = new System.Guid(XmlElement.Attribute("ID").Value),
                    Path         = System.IO.Path.Combine(in_currentPathInProj, name),
                    PathAndIcons = new System.Collections.Generic.List <AkWwiseProjectData.PathElement>(in_pathAndIcons),
                };
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(name, in_type.Type));

                FlagForInsertion(valueToAdd, in_type.Type);

                var ChildElem = System.Xml.Linq.XName.Get(in_type.ChildElementName);
                foreach (var element in ChildrenElement.Elements(ChildElem))
                {
                    if (element.Name != in_type.ChildElementName)
                    {
                        continue;
                    }

                    var elementName = element.Attribute("Name").Value;
                    var childValue  = new AkWwiseProjectData.AkBaseInformation
                    {
                        Name = elementName,
                        Guid = new System.Guid(element.Attribute("ID").Value),
                    };
                    childValue.PathAndIcons.Add(new AkWwiseProjectData.PathElement(elementName, in_type.ChildType));
                    valueToAdd.values.Add(childValue);

                    FlagForInsertion(childValue, in_type.ChildType);
                }

                switch (in_type.Type)
                {
                case WwiseObjectType.StateGroup:
                    AkWwiseProjectInfo.GetData().StateWwu[in_wwuIndex].List.Add(valueToAdd);
                    break;

                case WwiseObjectType.SwitchGroup:
                    AkWwiseProjectInfo.GetData().SwitchWwu[in_wwuIndex].List.Add(valueToAdd);
                    break;
                }
            }
        }
        break;

        default:
            UnityEngine.Debug.LogError("WwiseUnity: Unknown asset type in WWU parser");
            break;
        }
    }
Example #33
0
 public static bool IsTypeInGroup(AssetType type, AssetGroup group)
 {
     return(groups[group].Contains(type));
 }
    int RecurseWorkUnit(AssetType in_type, FileInfo in_workUnit, string in_currentPathInProj, string in_currentPhysicalPath, LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, string in_parentPhysicalPath = "")
    {
        m_WwuToProcess.Remove(in_workUnit.FullName);
        XmlReader reader   = null;
        int       wwuIndex = -1;

        try
        {
            //Progress bar stuff
            string msg = "Parsing Work Unit " + in_workUnit.Name;
            EditorUtility.DisplayProgressBar(s_progTitle, msg, (float)m_currentWwuCnt / (float)m_totWwuCnt);
            m_currentWwuCnt++;

            in_currentPathInProj = Path.Combine(in_currentPathInProj, Path.GetFileNameWithoutExtension(in_workUnit.Name));
            in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(Path.GetFileNameWithoutExtension(in_workUnit.Name), AkWwiseProjectData.WwiseObjectType.WORKUNIT));
            string WwuPhysicalPath = Path.Combine(in_currentPhysicalPath, in_workUnit.Name);

            AkWwiseProjectData.WorkUnit wwu = null;

            ReplaceWwuEntry(WwuPhysicalPath, in_type, out wwu, out wwuIndex);

            wwu.ParentPhysicalPath = in_parentPhysicalPath;
            wwu.PhysicalPath       = WwuPhysicalPath;
            wwu.Guid = "";
            wwu.SetLastTime(File.GetLastWriteTime(in_workUnit.FullName));

            reader = XmlReader.Create(in_workUnit.FullName);

            reader.MoveToContent();
            reader.Read();
            while (!reader.EOF && reader.ReadState == ReadState.Interactive)
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("WorkUnit"))
                {
                    if (wwu.Guid.Equals(""))
                    {
                        wwu.Guid = reader.GetAttribute("ID");
                    }

                    string persistMode = reader.GetAttribute("PersistMode");
                    if (persistMode == "Reference")
                    {
                        // ReadFrom advances the reader
                        var      matchedElement  = XNode.ReadFrom(reader) as XElement;
                        string   newWorkUnitPath = Path.Combine(in_workUnit.Directory.FullName, matchedElement.Attribute("Name").Value + ".wwu");
                        FileInfo newWorkUnit     = new FileInfo(newWorkUnitPath);

                        // Parse the referenced Work Unit
                        if (m_WwuToProcess.Contains(newWorkUnit.FullName))
                        {
                            RecurseWorkUnit(in_type, newWorkUnit, in_currentPathInProj, in_currentPhysicalPath, in_pathAndIcons, WwuPhysicalPath);
                        }
                    }
                    else
                    {
                        // If the persist mode is "Standalone" or "Nested", it means the current XML tag
                        // is the one corresponding to the current file. We can ignore it and advance the reader
                        reader.Read();
                    }
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("AuxBus"))
                {
                    in_currentPathInProj = Path.Combine(in_currentPathInProj, reader.GetAttribute("Name"));
                    in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.AUXBUS));
                    bool isEmpty = reader.IsEmptyElement;
                    AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex);

                    if (isEmpty)
                    {
                        in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(Path.DirectorySeparatorChar));
                        in_pathAndIcons.RemoveLast();
                    }
                }
                // Busses and folders act the same for the Hierarchy: simply add them to the path
                else if (reader.NodeType == XmlNodeType.Element && (reader.Name.Equals("Folder") || reader.Name.Equals("Bus")))
                {
                    //check if node has children
                    if (!reader.IsEmptyElement)
                    {
                        // Add the folder/bus to the path
                        in_currentPathInProj = Path.Combine(in_currentPathInProj, reader.GetAttribute("Name"));
                        if (reader.Name.Equals("Folder"))
                        {
                            in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.FOLDER));
                        }
                        else if (reader.Name.Equals("Bus"))
                        {
                            in_pathAndIcons.AddLast(new AkWwiseProjectData.PathElement(reader.GetAttribute("Name"), AkWwiseProjectData.WwiseObjectType.BUS));
                        }
                    }
                    // Advance the reader
                    reader.Read();
                }
                else if (reader.NodeType == XmlNodeType.EndElement && (reader.Name.Equals("Folder") || reader.Name.Equals("Bus") || reader.Name.Equals("AuxBus")))
                {
                    // Remove the folder/bus from the path
                    in_currentPathInProj = in_currentPathInProj.Remove(in_currentPathInProj.LastIndexOf(Path.DirectorySeparatorChar));
                    in_pathAndIcons.RemoveLast();

                    // Advance the reader
                    reader.Read();
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals(in_type.XmlElementName))
                {
                    // Add the element to the list
                    AddElementToList(in_currentPathInProj, reader, in_type, in_pathAndIcons, wwuIndex);
                }
                else
                {
                    reader.Read();
                }
            }
            // Sort the newly populated Wwu alphabetically
            SortWwu(in_type.RootDirectoryName, wwuIndex);
        }
        catch (Exception e)
        {
            Debug.LogError(e.ToString());
            wwuIndex = -1;
        }

        if (reader != null)
        {
            reader.Close();
        }

        in_pathAndIcons.RemoveLast();
        return(wwuIndex);
    }
Example #35
0
        public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type)
        {
            UUID key;

            if (UUID.TryParse(identifier, out key))
            {
                return(key);
            }

            TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);

            if (item != null && item.Type == (int)type)
            {
                return(item.AssetID);
            }

            if (part.LocalId != host.LocalId)
            {
                item = host.Inventory.GetInventoryItem(identifier);
                if (item != null && item.Type == (int)type)
                {
                    return(item.AssetID);
                }
            }
            return(UUID.Zero);
        }
Example #36
0
 public AssetFile(AssetType type) => DependencyType = type;
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (NOSEARCH_ANIM)
            {
                String str = args.str;
                WriteLine("PLAY ECHO " + str);
                return(Success("\nStart assets " + str + "\n"));
            }
            bool writeInfo = !args.IsFFI;

            if (args.Length < 1)
            {
                Dictionary <UUID, int> gestures = WorldSystem.TheSimAvatar.GetCurrentAnimDict();
                string alist = String.Empty;
                foreach (var anim in gestures)
                {
                    AppendItem("assets", WorldSystem.GetAsset(anim.Key));
                    if (!writeInfo)
                    {
                        continue;
                    }
                    alist += WorldSystem.GetAnimationName(anim.Key);
                    alist += " ";
                    alist += anim.Value;
                    alist += Environment.NewLine;
                }
                if (writeInfo)
                {
                    WriteLine("Currently: {0}", alist);
                }
                return(SuccessOrFailure());
                // " anim [seconds] HOVER [seconds] 23423423423-4234234234-234234234-23423423  +CLAP -JUMP STAND";
            }
            int argStart = 0;

            int time = 1300; //should be long enough for most animations

            base.SetWriteLine("message");
            string    directive       = args[0].ToLower();
            int       mode            = 0;
            int       defaultAnimTime = 2;
            int       animsRan        = 0;
            AssetType defaultSearch   = AssetType.Gesture;

            for (int i = argStart; i < args.Length; i++)
            {
                string a = args[i];
                if (String.IsNullOrEmpty(a))
                {
                    continue;
                }
                try
                {
                    float ia;
                    if (float.TryParse(a, out ia))
                    {
                        if (ia > 0.0)
                        {
                            time = (int)(ia * 1000);
                            Thread.Sleep(time);
                            continue;
                        }
                    }
                }
                catch (Exception)
                {
                }
                char c = a.ToCharArray()[0];
                if (c == '-')
                {
                    mode = -1;
                    a    = a.Substring(1);
                }
                else if (c == '+')
                {
                    mode = 1;
                    a    = a.Substring(1);
                }
                else
                {
                    mode = 0;
                }
                if (a == "")
                {
                    continue;
                }

                if (a.ToLower() == "stopall")
                {
                    Dictionary <UUID, bool> animations = new Dictionary <UUID, bool>();
                    var anims = TheSimAvatar.GetCurrentAnims();
                    foreach (var ani in anims)
                    {
                        animations[ani] = false;
                    }
                    int knownCount = animations.Count;

                    Client.Self.Animate(animations, true);
                    WriteLine("stopping all");
                    continue;
                }

                try
                {
                    defaultSearch = (AssetType)Enum.Parse(typeof(AssetType), a, true);
                    continue;
                }
                catch
                {
                }

                UUID anim = WorldSystem.GetAssetUUID(a, defaultSearch);

                if (anim == UUID.Zero)
                {
                    try
                    {
                        if (a.Substring(2).Contains("-"))
                        {
                            anim = UUIDParse(a);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                if (anim == UUID.Zero)
                {
                    anim = WorldSystem.GetAssetUUID(a, AssetType.Unknown);
                }
                if (anim == UUID.Zero)
                {
                    Failure("skipping unknown animation/gesture " + a);
                    continue;
                }
                SimAsset asset = SimAssetStore.FindAsset(anim);
                animsRan++;
                AppendItem("assets", WorldSystem.GetAsset(anim));
                if (asset is SimGesture)
                {
                    Client.Self.PlayGesture(asset.AssetID);
                    continue;
                }
                if (asset is SimSound)
                {
                    Client.Sound.PlaySound(asset.AssetID);
                    continue;
                }
                if (asset != null && !(asset is SimAnimation))
                {
                    Failure("Dont know how to play " + asset);
                    continue;
                }
                try
                {
                    switch (mode)
                    {
                    case -1:
                        Client.Self.AnimationStop(anim, true);
                        if (writeInfo)
                        {
                            WriteLine("\nStop anim " + WorldSystem.GetAnimationName(anim));
                        }
                        continue;

                    case +1:
                        Client.Self.AnimationStart(anim, true);
                        if (writeInfo)
                        {
                            WriteLine("\nStart anim " + WorldSystem.GetAnimationName(anim));
                        }
                        continue;

                    default:
                        try
                        {
                            int val = time;
                            Client.Self.AnimationStart(anim, true);
                            if (writeInfo)
                            {
                                WriteLine("\nRan anim " + WorldSystem.GetAnimationName(anim) + " for " + val / 1000 +
                                          " seconds.");
                            }
                            Thread.Sleep(val);
                        }
                        finally
                        {
                            Client.Self.AnimationStop(anim, true);
                        }
                        continue;
                    }
                }
                catch (Exception e)
                {
                    return(Failure("\nRan " + animsRan + " asserts but " + e));
                }
            }
            return(SuccessOrFailure());
        }
        /// <summary>
        ///     Load an asset
        /// </summary>
        /// <param name="assetPath"> </param>
        /// <param name="data"></param>
        /// <returns>true if asset was successfully loaded, false otherwise</returns>
        bool LoadAsset(string assetPath, byte [] data)
        {
            //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);

            int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR, StringComparison.Ordinal);

            if (i == -1)
            {
                MainConsole.Instance.ErrorFormat(
                    "[Inventory Archiver]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

                return(false);
            }

            string extension = filename.Substring(i);
            string uuid      = filename.Remove(filename.Length - extension.Length);
            UUID   assetID   = UUID.Parse(uuid);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE [extension];

                if (assetType == AssetType.Unknown)
                {
                    MainConsole.Instance.WarnFormat(
                        "[Inventory Archiver]: Importing {0} byte asset {1} with unknown type", data.Length,
                        uuid);
                }
                else if (assetType == AssetType.Object)
                {
                    string       xmlData     = Utils.BytesToString(data);
                    ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(
                        xmlData, m_registry);
                    if (sceneObject != null)
                    {
                        if (m_creatorIdForAssetId.ContainsKey(assetID))
                        {
                            foreach (
                                ISceneChildEntity sop in
                                from sop in sceneObject.ChildrenEntities()
                                where string.IsNullOrEmpty(sop.CreatorData)
                                select sop)
                            {
                                sop.CreatorID = m_creatorIdForAssetId [assetID];
                            }
                        }

                        foreach (ISceneChildEntity sop in sceneObject.ChildrenEntities())
                        {
                            //Fix ownerIDs and perms
                            sop.Inventory.ApplyGodPermissions((uint)PermissionMask.All);
                            sceneObject.ApplyPermissions((uint)PermissionMask.All);
                            foreach (TaskInventoryItem item in sop.Inventory.GetInventoryItems())
                            {
                                item.OwnerID = m_userInfo.PrincipalID;
                            }
                            sop.OwnerID = m_userInfo.PrincipalID;
                        }

                        data =
                            Utils.StringToBytes(
                                SceneEntitySerializer.SceneObjectSerializer.ToOriginalXmlFormat(sceneObject));
                    }
                }
                //MainConsole.Instance.DebugFormat("[Inventory Archiver]: Importing asset {0}, type {1}", uuid, assetType);

                AssetBase asset = new AssetBase(assetID, "From IAR", assetType, m_overridecreator)
                {
                    Data  = data,
                    Flags = AssetFlags.Normal
                };

                if (m_assetData != null && ReplaceAssets)
                {
                    m_assetData.Delete(asset.ID, true);
                }

                // check if this asset already exists in the database
                try {
                    if (!m_assetService.GetExists(asset.ID.ToString()))
                    {
                        m_assetService.Store(asset);
                    }
                } catch {
                    MainConsole.Instance.Error(
                        "[Inventory Archiver]: Error checking if asset exists. Possibly 'Path too long' for file based asset storage");
                }
                asset.Dispose();
                return(true);
            }
            MainConsole.Instance.ErrorFormat(
                "[Inventory Archiver]: Tried to dearchive data with path {0} with an unknown type extension {1}",
                assetPath, extension);

            return(false);
        }
        static public string argString(object arg)
        {
            if (arg == null)
            {
                return("NIL");
            }
            Type type = arg.GetType();

            if (arg is BotClient)
            {
                arg = ((BotClient)arg).GetAvatar();
                if (arg is BotClient)
                {
                    return(((BotClient)arg).ToString());
                }
            }
            if (arg is WorldObjects)
            {
                arg = ((WorldObjects)arg).TheSimAvatar;
            }
            if (arg is Simulator)
            {
                Simulator sim = (Simulator)arg;
                uint      globalX, globalY;
                Utils.LongToUInts(sim.Handle, out globalX, out globalY);
                return("'(simulator " + argString(sim.Name) + " " + globalX / 256 + " " + globalY / 256 + " " +
                       argString(sim.IPEndPoint.ToString()) + ")");
            }
            if (arg is Avatar)
            {
                Avatar prim = (Avatar)arg;
                arg = "'(SimAvatarFn "; //+ argString(prim.ID.ToString());
                if (prim.Name != null)
                {
                    arg = arg + " " + argString(prim.Name);
                }
                return(arg + ")");
            }

            if ((arg is AssetAnimation) || (arg is AssetTexture) || (arg is AssetSound))
            {
                Asset prim = (Asset)arg;
                arg = SimAssetStore.GetSimAsset(prim);
            }

            if (arg is SimAsset)
            {
                SimAsset  prim  = (SimAsset)arg;
                AssetType tyepe = prim.AssetType;
                arg = "'(Sim" + tyepe + "Fn "; //+ argString(prim.ID.ToString());
                if (prim.Name != null)
                {
                    arg = arg + " " + argString(prim.Name);
                }
                return(arg + ")");
            }

            if (arg is Primitive)
            {
                Primitive prim = (Primitive)arg;
                arg = "'(SimObjectFn  " + argString(prim.ID.ToString());
                if (prim.Properties != null)
                {
                    arg = arg + " " + argString(prim.Properties.Name);
                }
                return(arg + ")");
            }
            if (arg is SimAvatar)
            {
                SimAvatar prim = (SimAvatar)arg;
                arg = "'(SimAvatarFn  " + argString(prim.GetName());
                return(arg + ")");
            }
            if (arg is SimObject)
            {
                SimObject prim = (SimObject)arg;
                arg = "'(SimObjectFn  " + argString(prim.ID.ToString());
                string name = prim.GetName();
                if (!string.IsNullOrEmpty(name))
                {
                    arg = arg + " #|" + argString(name) + "|# ";
                }
                return(arg + ")");
            }
            if (type.IsEnum)
            {
                return(argString(arg.ToString()));
            }
            //InternalDictionary
            if (arg is IList)
            {
                String dictname = "'(list " + type.Name;
                IList  list     = (IList)arg;
                foreach (object key in list)
                {
                    dictname += " " + argString(key);
                }
                return(dictname + ")");
            }

            if (arg is Parcel)
            {
                String dictname = "'(parcel";
                Parcel list     = (Parcel)arg;
                dictname += " " + argString(list.SnapshotID.ToString());
                dictname += " " + argString(list.Name);
                return(dictname + ")");
            }
            if (arg is Group)
            {
                String dictname = "'(Group";
                Group  list     = (Group)arg;
                dictname += " " + argString(list.Name);
                return(dictname + ")");
            }
            if (arg is IDictionary)
            {
                String      dictname = "'(dict " + type.Name;
                IDictionary dict0    = (IDictionary)arg;
                IDictionary dict     = dict0;
                lock (dict.SyncRoot)
                {
                    foreach (object key in dict.Keys)
                    {
                        Object o = dict[key];
                        dictname += " " + argString(key) + "=" + argString(o);
                    }
                    return(dictname + ")");
                }
            }

            //if (arg is Quaternion)
            //{
            //    Quaternion quat = (Quaternion)arg;
            //    quat.Normalize();
            //    arg = WorldSystem.QuatToRotation(quat);
            //}

            if (arg is Quaternion)
            {
                Quaternion vect = (Quaternion)arg;
                return("'(Quaternion " + vect.X + " " + vect.Y + " " + vect.Z + " " + vect.W + ")");
            }

            if (arg is UUID)
            {
                //   if (true) return argString(arg.ToString());
                object found = WorldObjects.GridMaster.GetObject((UUID)arg);
                if (found == null || found is UUID)
                {
                    return(argString(arg.ToString()));
                }
                return(argString(found));
            }

            if (arg is Vector3)
            {
                Vector3 vect = (Vector3)arg;
                return("'(Vector3 " + vect.X + " " + vect.Y + " " + vect.Z + ")");
            }

            if (arg is Vector2)
            {
                Vector2 vect = (Vector2)arg;
                return("'(Vector2 " + vect.X + " " + vect.Y + ")");
            }

            if (arg is Vector3d)
            {
                Vector3d vect = (Vector3d)arg;
                return("'(Vector3d " + vect.X + " " + vect.Y + " " + vect.Z + ")");
            }

            if (type.IsArray)
            {
                Array a = (Array)arg;
                return("#{/*" + type + "*/" + argsListString(a) + "}");
            }
            if (arg is String)
            {
                return("\"" + arg.ToString().Replace("\"", "\\\"") + "\"");
            }
            if (type.Namespace.StartsWith("System"))
            {
                return("" + arg);
            }
            if (arg is IEnumerable)
            {
                IEnumerable a = (IEnumerable)arg;
                return("'(/*" + type + "*/" + argsListString(a) + ")");
            }
            if (type.IsValueType)
            {
                String tostr = "{" + arg + "";
                foreach (FieldInfo fi in type.GetFields())
                {
                    if (!fi.IsStatic)
                    {
                        tostr += ",";
                        tostr += fi.Name + "=";
                        tostr += argString(fi.GetValue(arg));
                    }
                }
                return(argString(tostr + "}"));
            }
            if (!type.IsValueType)
            {
                String tostr = "{" + arg + "";
                foreach (FieldInfo fi in type.GetFields())
                {
                    if (!fi.IsStatic)
                    {
                        tostr += ",";
                        tostr += fi.Name + "=";
                        tostr += fi.GetValue(arg);
                    }
                }
                return(argString(tostr + "}"));
            }
            return("" + arg);
        }
Example #40
0
 public bool ToUnknownExportType(ClassIDType classID, out AssetType assetType)
 {
     assetType = AssetType.Meta;
     return(true);
 }
Example #41
0
        /// <summary>
        /// adds a fixed asset type Adds an fixed asset type to the system
        /// </summary>
        /// <exception cref="Xero.NetStandard.OAuth2.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="xeroTenantId">Xero identifier for Tenant</param>
        /// <param name="assetType">Asset type to add (optional)</param>
        /// <returns>Task of AssetType</returns>
        public async System.Threading.Tasks.Task <AssetType> CreateAssetTypeAsync(string accessToken, string xeroTenantId, AssetType assetType = null)
        {
            Xero.NetStandard.OAuth2.Client.ApiResponse <AssetType> localVarResponse = await CreateAssetTypeAsyncWithHttpInfo(accessToken, xeroTenantId, assetType);

            return(localVarResponse.Data);
        }
Example #42
0
        public IAsset Load(string path, AssetType type)
        {
            var asset = LoadAsset(path, type, true);

            return(new AssetRef(asset));
        }
Example #43
0
        /// <summary>
        /// Return the UUID of the asset matching the specified key or name
        /// and asset type.
        /// </summary>
        /// <param name="part">Scene object part to search for inventory item</param>
        /// <param name="identifier"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
        {
            UUID key;

            if (!UUID.TryParse(identifier, out key))
            {
                TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
                if (item != null && item.Type == (int)type)
                {
                    key = item.AssetID;
                }
            }

            return(key);
        }
        private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
        {
            //MainConsole.Instance.InfoFormat("[INVENTORY TRANSFER]: OnInstantMessage {0}", im.dialog);

            IScene scene = FindClientScene(client.AgentId);

            if (scene == null) // Something seriously wrong here.
            {
                return;
            }

            if (im.dialog == (byte)InstantMessageDialog.InventoryOffered)
            {
                //MainConsole.Instance.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));

                if (im.binaryBucket.Length < 17) // Invalid
                {
                    return;
                }

                UUID           receipientID = im.toAgentID;
                IScenePresence user         = scene.GetScenePresence(receipientID);
                UUID           copyID;

                // Send the IM to the recipient. The item is already
                // in their inventory, so it will not be lost if
                // they are offline.
                //
                if (user != null)
                {
                    // First byte is the asset type
                    AssetType assetType = (AssetType)im.binaryBucket[0];

                    if (AssetType.Folder == assetType)
                    {
                        UUID folderID = new UUID(im.binaryBucket, 1);

                        MainConsole.Instance.DebugFormat("[INVENTORY TRANSFER]: Inserting original folder {0} " +
                                                         "into agent {1}'s inventory",
                                                         folderID, im.toAgentID);

                        InventoryFolderBase folderCopy      = null;
                        ILLClientInventory  inventoryModule = scene.RequestModuleInterface <ILLClientInventory>();
                        if (inventoryModule != null)
                        {
                            folderCopy = inventoryModule.GiveInventoryFolder(receipientID, client.AgentId, folderID,
                                                                             UUID.Zero);
                        }

                        if (folderCopy == null)
                        {
                            client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
                            return;
                        }

                        // The outgoing binary bucket should contain only the byte which signals an asset folder is
                        // being copied and the following bytes for the copied folder's UUID
                        copyID = folderCopy.ID;
                        byte[] copyIDBytes = copyID.GetBytes();
                        im.binaryBucket    = new byte[1 + copyIDBytes.Length];
                        im.binaryBucket[0] = (byte)AssetType.Folder;
                        Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);

                        if (user != null)
                        {
                            user.ControllingClient.SendBulkUpdateInventory(folderCopy);
                        }

                        im.imSessionID = folderID;
                    }
                    else
                    {
                        // First byte of the array is probably the item type
                        // Next 16 bytes are the UUID

                        UUID itemID = new UUID(im.binaryBucket, 1);

                        MainConsole.Instance.DebugFormat("[INVENTORY TRANSFER]: (giving) Inserting item {0} " +
                                                         "into agent {1}'s inventory",
                                                         itemID, im.toAgentID);

                        InventoryItemBase  itemCopy        = null;
                        ILLClientInventory inventoryModule = scene.RequestModuleInterface <ILLClientInventory>();
                        if (inventoryModule != null)
                        {
                            itemCopy = inventoryModule.GiveInventoryItem(
                                im.toAgentID,
                                im.fromAgentID, itemID, UUID.Zero);
                        }

                        if (itemCopy == null)
                        {
                            client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
                            return;
                        }

                        copyID = itemCopy.ID;
                        Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);

                        if (user != null)
                        {
                            user.ControllingClient.SendBulkUpdateInventory(itemCopy);
                        }

                        im.imSessionID = itemID;
                    }

                    user.ControllingClient.SendInstantMessage(im);
                    return;
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im);
                    }
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted)
            {
                IScenePresence user = scene.GetScenePresence(im.toAgentID);

                if (user != null) // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im);
                    }
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined)
            {
                // Here, the recipient is local and we can assume that the
                // inventory is loaded. Courtesy of the above bulk update,
                // It will have been pushed to the client, too
                //
                IInventoryService invService = scene.InventoryService;

                InventoryFolderBase trashFolder =
                    invService.GetFolderForType(client.AgentId, InventoryType.Unknown, AssetType.TrashFolder);

                UUID inventoryID = im.imSessionID; // The inventory item/folder, back from it's trip

                InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId);
                item = invService.GetItem(item);
                InventoryFolderBase folder = null;

                if (item != null && trashFolder != null)
                {
                    item.Folder = trashFolder.ID;

                    // Diva comment: can't we just update this item???
                    List <UUID> uuids = new List <UUID> {
                        item.ID
                    };
                    invService.DeleteItems(item.Owner, uuids);
                    ILLClientInventory inventory = client.Scene.RequestModuleInterface <ILLClientInventory>();
                    if (inventory != null)
                    {
                        inventory.AddInventoryItem(client, item);
                    }
                }
                else
                {
                    folder = new InventoryFolderBase(inventoryID, client.AgentId);
                    folder = invService.GetFolder(folder);

                    if (folder != null & trashFolder != null)
                    {
                        folder.ParentID = trashFolder.ID;
                        invService.MoveFolder(folder);
                    }
                }

                if ((null == item && null == folder) | null == trashFolder)
                {
                    string reason = String.Empty;

                    if (trashFolder == null)
                    {
                        reason += " Trash folder not found.";
                    }
                    if (item == null)
                    {
                        reason += " Item not found.";
                    }
                    if (folder == null)
                    {
                        reason += " Folder not found.";
                    }

                    client.SendAgentAlertMessage("Unable to delete " +
                                                 "received inventory" + reason, false);
                }

                IScenePresence user = scene.GetScenePresence(im.toAgentID);

                if (user != null) // Local
                {
                    user.ControllingClient.SendInstantMessage(im);
                }
                else
                {
                    if (m_TransferModule != null)
                    {
                        m_TransferModule.SendInstantMessage(im);
                    }
                }
            }
        }
Example #45
0
 public ProgressBarAssetImport(AssetContainerTool _mainContainerFile, List <Asset> _selectedAssets, AssetType _type, Window parent)
 {
     container      = _mainContainerFile;
     SelectedAssets = _selectedAssets;
     type           = _type;
     InitializeComponent();
     Owner = parent;
     InitProgressBar();
     DataContext = this;
 }
        public static Asset Create(string name, string description, string code, string barcode, DateTime adminssionDate, DateTime?purchaseDate, double price, double depreciationMonthsQty, AssetType assetType, Guid?categoryId, Guid creatorid, DateTime createDateTime, string brand, string modelstr, string plate, string series, bool isAToolKit, string companyName)
        {
            var @asset = new Asset
            {
                Id            = Guid.NewGuid(),
                Name          = name,
                Description   = description,
                Code          = code,
                Barcode       = barcode,
                AdmissionDate = adminssionDate,
                PurchaseDate  = purchaseDate,
                //   Price = price,
                DepreciationMonthsQty = depreciationMonthsQty,
                AssetType             = assetType,
                CategoryId            = categoryId,
                CreationTime          = createDateTime,
                CreatorUserId         = creatorid,
                IsDeleted             = false,
                IsAToolInKit          = isAToolKit,
                CustomFields          = new Collection <CustomField>(),
                ToolAssets            = new Collection <ToolAsset>(),
                Brand       = brand,
                Series      = series,
                ModelStr    = modelstr,
                CompanyName = companyName,
                Plate       = plate
            };

            return(@asset);
        }
Example #47
0
 public ManifestEntry(AssetType assetType, string assetPath)
 {
     this.AssetType = assetType;
     this.AssetPath = assetPath;
 }
 public void SetAssetType(AssetType assetType)
 {
     AssetType = assetType;
     //dviquez: see there any other funtionality
 }
    static void AddElementToList(string in_currentPathInProj, XmlReader in_reader, AssetType in_type, LinkedList <AkWwiseProjectData.PathElement> in_pathAndIcons, int in_wwuIndex)
    {
        if (in_type.RootDirectoryName == "Events" || in_type.RootDirectoryName == "Master-Mixer Hierarchy" || in_type.RootDirectoryName == "SoundBanks" || in_type.RootDirectoryName == "Game Parameters" || in_type.RootDirectoryName == "Triggers")
        {
            AkWwiseProjectData.Event valueToAdd = new AkWwiseProjectData.Event();

            valueToAdd.Name         = in_reader.GetAttribute("Name");
            valueToAdd.Guid         = new Guid(in_reader.GetAttribute("ID")).ToByteArray();
            valueToAdd.ID           = (int)AkUtilities.ShortIDGenerator.Compute(valueToAdd.Name);
            valueToAdd.PathAndIcons = new List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            if (in_type.RootDirectoryName == "Events")
            {
                valueToAdd.Path = Path.Combine(in_currentPathInProj, valueToAdd.Name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.EVENT));
                AkWwiseProjectInfo.GetData().EventWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else if (in_type.RootDirectoryName == "SoundBanks")
            {
                valueToAdd.Path = Path.Combine(in_currentPathInProj, valueToAdd.Name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.SOUNDBANK));
                AkWwiseProjectInfo.GetData().BankWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else if (in_type.RootDirectoryName == "Master-Mixer Hierarchy")
            {
                valueToAdd.Path = in_currentPathInProj;
                AkWwiseProjectInfo.GetData().AuxBusWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else if (in_type.RootDirectoryName == "Game Parameters")
            {
                valueToAdd.Path = Path.Combine(in_currentPathInProj, valueToAdd.Name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.GAMEPARAMETER));
                AkWwiseProjectInfo.GetData().RtpcWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else
            {
                valueToAdd.Path = Path.Combine(in_currentPathInProj, valueToAdd.Name);
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.TRIGGER));
                AkWwiseProjectInfo.GetData().TriggerWwu[in_wwuIndex].List.Add(valueToAdd);
            }

            in_reader.Read();
        }
        else if (in_type.RootDirectoryName == "States" || in_type.RootDirectoryName == "Switches")
        {
            var XmlElement = XNode.ReadFrom(in_reader) as XElement;

            AkWwiseProjectData.GroupValue      valueToAdd = new AkWwiseProjectData.GroupValue();
            AkWwiseProjectData.WwiseObjectType SubElemIcon;
            valueToAdd.Name         = XmlElement.Attribute("Name").Value;
            valueToAdd.Guid         = new Guid(XmlElement.Attribute("ID").Value).ToByteArray();
            valueToAdd.ID           = (int)AkUtilities.ShortIDGenerator.Compute(valueToAdd.Name);
            valueToAdd.Path         = Path.Combine(in_currentPathInProj, valueToAdd.Name);
            valueToAdd.PathAndIcons = new List <AkWwiseProjectData.PathElement>(in_pathAndIcons);

            if (in_type.RootDirectoryName == "States")
            {
                SubElemIcon = AkWwiseProjectData.WwiseObjectType.STATE;
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.STATEGROUP));
            }
            else
            {
                SubElemIcon = AkWwiseProjectData.WwiseObjectType.SWITCH;
                valueToAdd.PathAndIcons.Add(new AkWwiseProjectData.PathElement(valueToAdd.Name, AkWwiseProjectData.WwiseObjectType.SWITCHGROUP));
            }

            XName ChildrenList = XName.Get("ChildrenList");
            XName ChildElem    = XName.Get(in_type.ChildElementName);

            XElement ChildrenElement = XmlElement.Element(ChildrenList);
            if (ChildrenElement != null)
            {
                foreach (var element in ChildrenElement.Elements(ChildElem))
                {
                    if (element.Name == in_type.ChildElementName)
                    {
                        string elementName = element.Attribute("Name").Value;
                        valueToAdd.values.Add(elementName);
                        valueToAdd.ValueGuids.Add(new AkWwiseProjectData.ByteArrayWrapper(new Guid(element.Attribute("ID").Value).ToByteArray()));
                        valueToAdd.valueIDs.Add((int)AkUtilities.ShortIDGenerator.Compute(elementName));
                        valueToAdd.ValueIcons.Add(new AkWwiseProjectData.PathElement(elementName, SubElemIcon));
                    }
                }
            }

            if (in_type.RootDirectoryName == "States")
            {
                AkWwiseProjectInfo.GetData().StateWwu[in_wwuIndex].List.Add(valueToAdd);
            }
            else
            {
                AkWwiseProjectInfo.GetData().SwitchWwu[in_wwuIndex].List.Add(valueToAdd);
            }
        }
        else
        {
            Debug.LogError("WwiseUnity: Unknown asset type in WWU parser");
        }
    }
Example #50
0
        public override InventoryFolderBase GetFolderForType(UUID principalID, InventoryType invType, AssetType type)
        {
            InventoryFolderBase invFolder = GetRootFolder(principalID);

            switch (type)
            {
            case AssetType.Object:
                InventoryFolderBase objFolder = GetFolderType(principalID, invFolder.ID, type);
                if (objFolder == null)
                {
                    objFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Object, "Foreign Objects");
                }
                return(objFolder);

            case AssetType.LSLText:
                InventoryFolderBase lslFolder = GetFolderType(principalID, invFolder.ID, type);
                if (lslFolder == null)
                {
                    lslFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.LSLText, "Foreign Scripts");
                }
                return(lslFolder);

            case AssetType.Notecard:
                InventoryFolderBase ncFolder = GetFolderType(principalID, invFolder.ID, type);
                if (ncFolder == null)
                {
                    ncFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Notecard, "Foreign Notecards");
                }
                return(ncFolder);

            case AssetType.Animation:
                InventoryFolderBase aniFolder = GetFolderType(principalID, invFolder.ID, type);
                if (aniFolder == null)
                {
                    aniFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Notecard, "Foreign Animiations");
                }
                return(aniFolder);

            case AssetType.Bodypart:
            case AssetType.Clothing:
                InventoryFolderBase clothingFolder = GetFolderType(principalID, invFolder.ID, AssetType.Clothing);
                if (clothingFolder == null)
                {
                    clothingFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Clothing, "Foreign Clothing");
                }
                return(clothingFolder);

            case AssetType.Gesture:
                InventoryFolderBase gestureFolder = GetFolderType(principalID, invFolder.ID, type);
                if (gestureFolder == null)
                {
                    gestureFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Gesture, "Foreign Gestures");
                }
                return(gestureFolder);

            case AssetType.Landmark:
                InventoryFolderBase lmFolder = GetFolderType(principalID, invFolder.ID, type);
                if (lmFolder == null)
                {
                    lmFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Landmark, "Foreign Landmarks");
                }
                return(lmFolder);

            case AssetType.SnapshotFolder:
            case AssetType.Texture:
                InventoryFolderBase textureFolder = GetFolderType(principalID, invFolder.ID, type);
                if (textureFolder == null)
                {
                    textureFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Landmark, "Foreign Textures");
                }
                return(textureFolder);

            case AssetType.Sound:
                InventoryFolderBase soundFolder = GetFolderType(principalID, invFolder.ID, type);
                if (soundFolder == null)
                {
                    soundFolder = CreateFolder(principalID, invFolder.ID, (int)AssetType.Landmark, "Foreign Sounds");
                }
                return(soundFolder);

            default:
                return(invFolder);
            }
        }
Example #51
0
        public static (List <Section_AHDR> AHDRs, bool overwrite, bool simps, bool ledgeGrab, bool piptVColors, bool solidSimps) GetModels(Game game)
        {
            using (ImportModel a = new ImportModel())
                if (a.ShowDialog() == DialogResult.OK)
                {
                    List <Section_AHDR> AHDRs = new List <Section_AHDR>();

                    AssetType assetType = (AssetType)a.comboBoxAssetTypes.SelectedItem;

                    if (assetType == AssetType.MODL)
                    {
                        if (a.checkBoxGenSimps.Checked)
                        {
                            MessageBox.Show("a SIMP for each imported MODL will be generated and placed on a new DEFAULT layer.");
                        }
                    }

                    foreach (string filePath in a.filePaths)
                    {
                        string assetName;

                        byte[] assetData;

                        ReadFileMethods.treatStuffAsByteArray = false;

                        if (assetType == AssetType.MODL)
                        {
                            assetName = Path.GetFileNameWithoutExtension(filePath) + ".dff";

                            assetData = Path.GetExtension(filePath).ToLower().Equals(".dff") ?
                                        File.ReadAllBytes(filePath) :
                                        ReadFileMethods.ExportRenderWareFile(
                                CreateDFFFromAssimp(filePath,
                                                    a.checkBoxFlipUVs.Checked,
                                                    a.checkBoxIgnoreMeshColors.Checked),
                                modelRenderWareVersion(game));
                        }
                        else if (assetType == AssetType.BSP)
                        {
                            assetName = Path.GetFileNameWithoutExtension(filePath) + ".bsp";

                            assetData = Path.GetExtension(filePath).ToLower().Equals(".bsp") ?
                                        File.ReadAllBytes(filePath) :
                                        ReadFileMethods.ExportRenderWareFile(
                                CreateBSPFromAssimp(filePath,
                                                    a.checkBoxFlipUVs.Checked,
                                                    a.checkBoxIgnoreMeshColors.Checked),
                                modelRenderWareVersion(game));
                        }
                        else
                        {
                            throw new ArgumentException();
                        }

                        AHDRs.Add(new Section_AHDR(
                                      Functions.BKDRHash(assetName),
                                      assetType,
                                      ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType),
                                      new Section_ADBG(0, assetName, "", 0),
                                      assetData));
                    }

                    return(AHDRs, a.checkBoxOverwrite.Checked, a.checkBoxGenSimps.Checked, a.checkBoxLedgeGrab.Checked, a.checkBoxEnableVcolors.Checked, a.checkBoxSolidSimps.Checked);
                }

            return(null, false, false, false, false, false);
        }
Example #52
0
        private static bool LoadAsset(string assetPath, byte[] data, AssetLoadedCallback assetCallback, long bytesRead, long totalBytes)
        {
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
            int    i        = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

            if (i == -1)
            {
                Logger.Log(String.Format(
                               "[OarFile]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                               assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR), Helpers.LogLevel.Warning);
                return(false);
            }

            string extension = filename.Substring(i);
            UUID   uuid;

            UUID.TryParse(filename.Remove(filename.Length - extension.Length), out uuid);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
                Asset     asset     = null;

                switch (assetType)
                {
                case AssetType.Animation:
                    asset = new AssetAnimation(uuid, data);
                    break;

                case AssetType.Bodypart:
                    asset = new AssetBodypart(uuid, data);
                    break;

                case AssetType.Clothing:
                    asset = new AssetClothing(uuid, data);
                    break;

                case AssetType.Gesture:
                    asset = new AssetGesture(uuid, data);
                    break;

                case AssetType.Landmark:
                    asset = new AssetLandmark(uuid, data);
                    break;

                case AssetType.LSLBytecode:
                    asset = new AssetScriptBinary(uuid, data);
                    break;

                case AssetType.LSLText:
                    asset = new AssetScriptText(uuid, data);
                    break;

                case AssetType.Notecard:
                    asset = new AssetNotecard(uuid, data);
                    break;

                case AssetType.Object:
                    asset = new AssetPrim(uuid, data);
                    break;

                case AssetType.Sound:
                    asset = new AssetSound(uuid, data);
                    break;

                case AssetType.Texture:
                    asset = new AssetTexture(uuid, data);
                    break;

                default:
                    Logger.Log("[OarFile] Unhandled asset type " + assetType, Helpers.LogLevel.Error);
                    break;
                }

                if (asset != null)
                {
                    assetCallback(asset, bytesRead, totalBytes);
                    return(true);
                }
            }

            Logger.Log("[OarFile] Failed to load asset", Helpers.LogLevel.Warning);
            return(false);
        }
Example #53
0
        private void readfile(ISheet sheet, string path)
        {
            //read customer
            Customer customer = new Customer();

            customer.Firm    = sheet.GetRow(2).GetCell(0)?.StringCellValue;
            customer.Address = sheet.GetRow(2).GetCell(1)?.StringCellValue;
            if (sheet.GetRow(2).GetCell(2) == null)
            {
                customer.Date = DateTime.Now;
            }
            else
            {
                customer.Date = sheet.GetRow(2).GetCell(2).DateCellValue;
            }


            // read Assets + type + switch
            List <Asset>     assets     = new List <Asset>();
            List <AssetType> assetTypes = new List <AssetType>();

            for (int row = 7; row < sheet.LastRowNum + 1; row++)
            {
                Asset p = new Asset();
                for (int c = 0; c < 13; c++)
                {
                    var cell = sheet.GetRow(row).GetCell(c);
                    cell?.SetCellType(CellType.String);
                }

                p.Name        = sheet.GetRow(row).GetCell(0)?.StringCellValue;
                p.Address     = sheet.GetRow(row).GetCell(2)?.StringCellValue;
                p.Description = sheet.GetRow(row).GetCell(1)?.StringCellValue;
                p.HDD         = sheet.GetRow(row).GetCell(8)?.StringCellValue;
                p.RAM         = sheet.GetRow(row).GetCell(7)?.StringCellValue;
                p.IpAddress   = sheet.GetRow(row).GetCell(11)?.StringCellValue;
                p.Location    = sheet.GetRow(row).GetCell(3)?.StringCellValue;
                p.Login       = sheet.GetRow(row).GetCell(4)?.StringCellValue;
                p.Usedby      = sheet.GetRow(row).GetCell(10)?.StringCellValue;
                p.Password    = sheet.GetRow(row).GetCell(5)?.StringCellValue;
                p.Note        = sheet.GetRow(row).GetCell(6)?.StringCellValue;
                p.OS          = sheet.GetRow(row).GetCell(12)?.StringCellValue;
                string type = sheet.GetRow(row).GetCell(9)?.StringCellValue;


                // date
                if (sheet.GetRow(row).GetCell(13) == null)
                {
                    p.InstallationDate = DateTime.Now;
                }
                else
                {
                    p.InstallationDate = sheet.GetRow(row).GetCell(13).DateCellValue;
                    if (p.InstallationDate.Year == 1)
                    {
                        p.InstallationDate = DateTime.Now;
                    }
                }


                // date end
                if (type == null)
                {
                    type = " ";
                }
                // type
                if (assetTypes.Count(x => x.Description.ToLower().Equals(type.ToLower())) < 1)
                {
                    var typeAsset = new AssetType()
                    {
                        Description = type.ToLower()
                    };
                    assetTypes.Add(typeAsset);
                    p.Type = typeAsset;
                }
                else
                {
                    p.Type = assetTypes.FirstOrDefault(x => x.Description.ToLower().Equals(type.ToLower()));
                }
                // type end

                assets.Add(p);
            }
            // Add to Database

            var alreadyaddededtypes = dbaT.ReadAll();
            int i = 0;

            foreach (var t in assetTypes)
            {
                foreach (var at in alreadyaddededtypes)
                {
                    if (t.Description.ToLower().Equals(at.Description.ToLower()))
                    {
                        i++;
                        break;
                    }
                }
                if (i == 0)
                {
                    dbaT.Create(t);
                }
                i = 0;
            }
            alreadyaddededtypes = dbaT.ReadAll();

            var cus = dbc.Create(customer);

            foreach (var a in assets)
            {
                a.CustomerId = cus.Id;
                a.Customer   = cus;
                a.Type       =
                    alreadyaddededtypes.FirstOrDefault(x => x.Description.ToLower().Equals(a.Type.Description.ToLower()));
                a.TypeId = a.Type?.Id;
                db.Create(a);
            }
            System.IO.File.Delete(path);
        }
Example #54
0
    private static AkWwiseProjectData.WorkUnit ReplaceWwuEntry(string in_currentPhysicalPath, AssetType in_type, out int out_wwuIndex)
    {
        var list = AkWwiseProjectInfo.GetData().GetWwuListByString(in_type.RootDirectoryName);

        out_wwuIndex = list.BinarySearch(new AkWwiseProjectData.WorkUnit {
            PhysicalPath = in_currentPhysicalPath
        });
        AkWwiseProjectData.WorkUnit out_wwu = null;

        switch (in_type.Type)
        {
        case WwiseObjectType.Event:
            out_wwu = new AkWwiseProjectData.EventWorkUnit();
            break;

        case WwiseObjectType.StateGroup:
        case WwiseObjectType.SwitchGroup:
            out_wwu = new AkWwiseProjectData.GroupValWorkUnit();
            break;

        case WwiseObjectType.AuxBus:
        case WwiseObjectType.Soundbank:
        case WwiseObjectType.GameParameter:
        case WwiseObjectType.Trigger:
        case WwiseObjectType.AcousticTexture:
            out_wwu = new AkWwiseProjectData.AkInfoWorkUnit();
            break;
        }

        if (out_wwuIndex < 0)
        {
            out_wwuIndex = ~out_wwuIndex;
            list.Insert(out_wwuIndex, out_wwu);
        }
        else
        {
            list[out_wwuIndex] = out_wwu;
        }

        return(out_wwu);
    }
Example #55
0
        public static void SaveAssets(AssetManager assetManager, AssetType assetType, IList <UUID> assets, string assetsPath)
        {
            int count = 0;

            List <UUID>    remainingTextures     = new List <UUID>(assets);
            AutoResetEvent AllPropertiesReceived = new AutoResetEvent(false);

            for (int i = 0; i < assets.Count; i++)
            {
                UUID texture = assets[i];
                if (assetType == AssetType.Texture)
                {
                    assetManager.RequestImage(texture, (state, assetTexture) =>
                    {
                        string extension = string.Empty;

                        if (assetTexture == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                        {
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];
                        }

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), assetTexture.AssetData);
                        remainingTextures.Remove(assetTexture.AssetID);
                        if (remainingTextures.Count == 0)
                        {
                            AllPropertiesReceived.Set();
                        }
                        ++count;
                    });
                }
                else
                {
                    assetManager.RequestAsset(texture, assetType, false, (transfer, asset) =>
                    {
                        string extension = string.Empty;

                        if (asset == null)
                        {
                            Console.WriteLine("Missing asset " + texture);
                            return;
                        }

                        if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(assetType))
                        {
                            extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[assetType];
                        }

                        File.WriteAllBytes(Path.Combine(assetsPath, texture.ToString() + extension), asset.AssetData);
                        remainingTextures.Remove(asset.AssetID);
                        if (remainingTextures.Count == 0)
                        {
                            AllPropertiesReceived.Set();
                        }
                        ++count;
                    });
                }

                Thread.Sleep(200);
                if (i % 5 == 0)
                {
                    Thread.Sleep(250);
                }
            }
            AllPropertiesReceived.WaitOne(5000 + 350 * assets.Count);

            Logger.Log("Copied " + count + " textures to the asset archive folder", Helpers.LogLevel.Info);
        }
Example #56
0
        /// <summary>
        /// adds a fixed asset type Adds an fixed asset type to the system
        /// </summary>
        /// <exception cref="Xero.NetStandard.OAuth2.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="xeroTenantId">Xero identifier for Tenant</param>
        /// <param name="assetType">Asset type to add (optional)</param>
        /// <returns>Task of ApiResponse (AssetType)</returns>
        public async System.Threading.Tasks.Task <Xero.NetStandard.OAuth2.Client.ApiResponse <AssetType> > CreateAssetTypeAsyncWithHttpInfo(string accessToken, string xeroTenantId, AssetType assetType = null)
        {
            // verify the required parameter 'xeroTenantId' is set
            if (xeroTenantId == null)
            {
                throw new Xero.NetStandard.OAuth2.Client.ApiException(400, "Missing required parameter 'xeroTenantId' when calling AssetApi->CreateAssetType");
            }


            Xero.NetStandard.OAuth2.Client.RequestOptions requestOptions = new Xero.NetStandard.OAuth2.Client.RequestOptions();

            String[] @contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] @accepts = new String[] {
                "application/json"
            };

            foreach (var cType in @contentTypes)
            {
                requestOptions.HeaderParameters.Add("Content-Type", cType);
            }

            foreach (var accept in @accepts)
            {
                requestOptions.HeaderParameters.Add("Accept", accept);
            }

            if (xeroTenantId != null)
            {
                requestOptions.HeaderParameters.Add("Xero-Tenant-Id", Xero.NetStandard.OAuth2.Client.ClientUtils.ParameterToString(xeroTenantId)); // header parameter
            }
            requestOptions.Data = assetType;

            // authentication (OAuth2) required
            // oauth required
            if (!String.IsNullOrEmpty(accessToken))
            {
                requestOptions.HeaderParameters.Add("Authorization", "Bearer " + accessToken);
            }
            // make the HTTP request



            var response = await this.AsynchronousClient.PostAsync <AssetType>("/AssetTypes", requestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception exception = this.ExceptionFactory("CreateAssetType", response);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(response);
        }
Example #57
0
 public Asset(AssetType type)
 {
     Debug.Assert(type != AssetType.Unknown);
     Type = type;
 }
        protected override void Grid_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case (ListItemType.Item):
            case (ListItemType.AlternatingItem):
            {
                AssetType entity = (AssetType)e.Item.DataItem;

                Label NameLabel = (Label)e.Item.FindControl("NameLabel");
                NameLabel.Text = entity.Name.Trim();

                PlaceHolder FileExtensionsPlaceHolder = (PlaceHolder)e.Item.FindControl("FileExtensionsPlaceHolder");

                if (StringUtils.IgnoreCaseCompare(entity.Name, "generic"))
                {
                    Label lbl = new Label {
                        CssClass = "BodyTxt"
                    };
                    lbl.Attributes["style"] = "color:#666";
                    lbl.Text = "Generic asset type cannot have any file extensions";
                    FileExtensionsPlaceHolder.Controls.Add(lbl);
                }
                else
                {
                    foreach (var atfe in entity.AssetTypeFileExtensionList)
                    {
                        HyperLink link = new HyperLink {
                            Text = atfe.Extension, NavigateUrl = string.Format("ManageFileExtensionsForm.aspx?AssetTypeFileExtensionId={0}", atfe.AssetTypeFileExtensionId), CssClass = "BodyTxt Black"
                        };
                        link.Attributes["style"] = "margin-right:10px;";
                        FileExtensionsPlaceHolder.Controls.Add(link);
                    }

                    HyperLink addLink = new HyperLink {
                        Text = "[add new]", NavigateUrl = "ManageFileExtensionsForm.aspx?AssetTypeId=" + entity.AssetTypeId, CssClass = "BodyTxt Black Bold"
                    };
                    FileExtensionsPlaceHolder.Controls.Add(addLink);
                }

                Label IsVisibleLabel = (Label)e.Item.FindControl("IsVisibleLabel");
                IsVisibleLabel.Text = entity.IsVisible ? "Y" : "N";

                LinkButton DeleteLb = (LinkButton)e.Item.Cells[e.Item.Cells.Count - 1].FindControl("DeleteLb");
                DeleteLb.CommandArgument = entity.AssetTypeId.GetValueOrDefault().ToString();
            }
            break;

            case ListItemType.EditItem:
            {
                AssetType entity = (AssetType)e.Item.DataItem;

                TextBox NameTextBox = (TextBox)e.Item.FindControl("NameTextBox");
                NameTextBox.Text = entity.Name.Trim();

                PlaceHolder FileExtensionsPlaceHolder = (PlaceHolder)e.Item.FindControl("FileExtensionsPlaceHolder");

                foreach (string extension in entity.FileExtensionList)
                {
                    Label lbl = new Label {
                        Text = extension, CssClass = "BodyTxt"
                    };
                    lbl.Attributes["style"] = "margin-right:10px;color:#fff";
                    FileExtensionsPlaceHolder.Controls.Add(lbl);
                }

                CheckBox IsVisibleCheckBox = (CheckBox)e.Item.FindControl("IsVisibleCheckBox");
                IsVisibleCheckBox.Checked = entity.IsVisible;

                LinkButton lb = (LinkButton)e.Item.Cells[e.Item.Cells.Count - 1].Controls[0];
                lb.CommandArgument = entity.AssetTypeId.ToString();
            }
            break;
            }
        }
Example #59
0
 public void Add(AssetType assetType)
 {
     //var context = new AssetsContext();
     _context.AssetTypes.Add(assetType);
     _context.SaveChanges();
 }
Example #60
0
 public ResolvedFile(string sourcePath, string destinationSubDirectory, AssetType assetType = AssetType.None)
 {
     SourcePath = Path.GetFullPath(sourcePath);
     DestinationSubDirectory = destinationSubDirectory;
     Asset = assetType;
 }