Esempio n. 1
0
        public void AddUserToGroup(string sid, DataSet user, string groupName, string epriseName)
        {
            IDbTransaction t = null;
            try
            {
                Initialize(sid);
                int groupid = -1, enterpriseid = -1;
                string userName = DataTools.GetTextField(user, AdminFields.USERNAME);

                UserStruct us = new UserStruct();
                us.name = userName;
                if (ExistGroup(sid, groupName, ref groupid, epriseName, ref enterpriseid))
                {
                    us.groupid = groupid;
                    t = db.BeginTransaction();
                    us.published = DataTools.GetBoolField(user, AdminFields.PUBLISHED);
                    us.id = users.CreateUser(us);
                    cacheMem.SetCacheData(us, DBTables.USERS + us.name);
                    if (t != null) db.Commit(t);
                }
                else
                {
                    GroupStruct gs  = new GroupStruct();
                    gs.name         = groupName;
                    gs.published    = true;
                    gs.enterpriseid = enterpriseid;
                    t = db.BeginTransaction();
                    gs.id = groups.CreateGroup(gs);
                    cacheMem.SetCacheData(gs, DBTables.GROUPS + gs.name);
                    us.groupid = groupid;
                    us.id = users.CreateUser(us);
                    cacheMem.SetCacheData(us, DBTables.USERS + us.name);
                    if (t != null) db.Commit(t);
                }
            }
            catch (Exception ex)
            {
                Exception wrappedEx = new Exception(
                    ErrorManager.AddLayer(ex, RunningClass.GetName(this), RunningClass.GetMethod()));
                throw wrappedEx;
            }
            finally
            {
                if (t != null) db.Commit(t);
            }
        }
Esempio n. 2
0
        public static Tae ReadTae(string path)
        {
            Tae tae = new Tae();

            BinaryReader file = new BinaryReader(File.Open(path, FileMode.Open));

            tae.header = new Header();
            tae.data   = new Data();

            tae.header.signature = file.ReadBytes(4);

            if (Encoding.ASCII.GetString(tae.header.signature) == "TAE ")
            {
                tae.header.unk1 = file.ReadUInt32();
                tae.header.unk2 = file.ReadUInt32();

                tae.header.fileSize = file.ReadUInt32();
                tae.header.unk3     = file.ReadBytes(64);
                tae.header.id       = file.ReadUInt32();

                tae.header.idCount      = file.ReadUInt32();
                tae.header.idsOffset    = file.ReadUInt32();
                tae.header.groupsOffset = file.ReadUInt32();

                tae.header.unk4 = file.ReadUInt32();

                tae.header.dataCount  = file.ReadUInt32();
                tae.header.dataOffset = file.ReadUInt32();

                tae.header.unk5            = file.ReadBytes(40);
                tae.header.filenamesOffset = file.ReadUInt32();

                tae.data.skeletonHkxName = new NameStruct();
                tae.data.SibName         = new NameStruct();

                file.BaseStream.Seek(tae.header.filenamesOffset, SeekOrigin.Begin);
                tae.data.skeletonHkxName.offset = file.ReadUInt32();
                tae.data.SibName.offset         = file.ReadUInt32();

                tae.data.unk = file.ReadUInt64();

                file.BaseStream.Seek(tae.data.skeletonHkxName.offset, SeekOrigin.Begin);
                tae.data.skeletonHkxName.name = MyReadChars(file);

                file.BaseStream.Seek(tae.data.SibName.offset, SeekOrigin.Begin);
                tae.data.SibName.name = MyReadChars(file);

                file.BaseStream.Seek(tae.header.idsOffset, SeekOrigin.Begin);

                tae.data.ids = new List <IdStruct> {
                };

                for (int i = 0; i < tae.header.idCount; i++)
                {
                    IdStruct id = new IdStruct();

                    id.id     = file.ReadUInt32();
                    id.offset = file.ReadUInt32();

                    tae.data.ids.Add(id);
                }

                file.BaseStream.Seek(tae.header.groupsOffset, SeekOrigin.Begin);

                tae.data.groupCount      = file.ReadUInt32();
                tae.data.groupDataOffset = file.ReadUInt32();

                file.BaseStream.Seek(tae.data.groupDataOffset, SeekOrigin.Begin);

                tae.data.groups = new List <GroupStruct> {
                };

                for (int i = 0; i < tae.data.groupCount; i++)
                {
                    GroupStruct group = new GroupStruct();

                    group.firstId       = file.ReadUInt32();
                    group.lastId        = file.ReadUInt32();
                    group.firstIdOffset = file.ReadUInt32();

                    tae.data.groups.Add(group);
                }

                file.BaseStream.Seek(tae.header.dataOffset, SeekOrigin.Begin);

                tae.data.animDatas = new List <AnimDataStruct> {
                };

                long currpos = 0;

                for (int i = 0; i < tae.header.dataCount; i++)
                {
                    AnimDataStruct animData = new AnimDataStruct();

                    animData.eventCount        = file.ReadUInt32();
                    animData.eventHeaderOffset = file.ReadUInt32();
                    animData.unk = file.ReadUInt64();
                    animData.timeConstantsCount  = file.ReadUInt32();
                    animData.timeConstantsOffset = file.ReadUInt32();
                    animData.animFileOffset      = file.ReadUInt32();

                    currpos = file.BaseStream.Position;

                    file.BaseStream.Seek(animData.animFileOffset, SeekOrigin.Begin);

                    animData.animFile      = new AnimFileStruct();
                    animData.animFile.name = new NameStruct();

                    animData.animFile.type       = file.ReadUInt32();
                    animData.animFile.dataOffset = file.ReadUInt32();

                    if (animData.animFile.type == 0)
                    {
                        animData.animFile.name.offset = file.ReadUInt32();
                    }
                    else
                    {
                        animData.animFile.nextFileOffset = file.ReadUInt32();
                        animData.animFile.linkedAnimId   = file.ReadUInt32();
                    }

                    animData.animFile.unk1  = file.ReadUInt32();
                    animData.animFile.unk2  = file.ReadUInt32();
                    animData.animFile.nulla = file.ReadUInt32();

                    if (animData.animFile.type == 0)
                    {
                        file.BaseStream.Seek(animData.animFile.name.offset, SeekOrigin.Begin);
                        animData.animFile.name.name = MyReadChars(file);
                    }

                    animData.events = new List <EventStruct> {
                    };

                    for (int j = 0; j < animData.eventCount; j++)
                    {
                        EventStruct Event = new EventStruct();

                        file.BaseStream.Seek(animData.eventHeaderOffset + j * 12, SeekOrigin.Begin);

                        Event.startTimeOffset = file.ReadUInt32();
                        Event.endTimeOffset   = file.ReadUInt32();
                        Event.eventbodyOffset = file.ReadUInt32();

                        file.BaseStream.Seek(Event.startTimeOffset, SeekOrigin.Begin);
                        Event.startTime        = file.ReadSingle();
                        Event.startTimeOffset -= animData.timeConstantsOffset;

                        file.BaseStream.Seek(Event.endTimeOffset, SeekOrigin.Begin);
                        Event.endTime        = file.ReadSingle();
                        Event.endTimeOffset -= animData.timeConstantsOffset;

                        file.BaseStream.Seek(Event.eventbodyOffset, SeekOrigin.Begin);

                        Event.eventType        = file.ReadUInt32();
                        Event.eventParamOffset = file.ReadUInt32();

                        file.BaseStream.Seek(Event.eventParamOffset, SeekOrigin.Begin);

                        Event.parameters = ReadParams(Event.eventType, file);

                        if (Event.parameters[0] == null)
                        {
                            tae.err = "Unrecognized event type: " + BitConverter.ToInt32(Event.parameters[1], 0) + "\n\nPosition in the file: " + file.BaseStream.Position;
                            file.Close();
                            return(tae);
                        }

                        animData.events.Add(Event);
                    }

                    file.BaseStream.Seek(animData.timeConstantsOffset, SeekOrigin.Begin);

                    animData.timeConstants = new List <float> {
                    };

                    for (int j = 0; j < animData.timeConstantsCount; j++)
                    {
                        animData.timeConstants.Add(file.ReadSingle());
                    }

                    file.BaseStream.Seek((uint)currpos, SeekOrigin.Begin);

                    tae.data.animDatas.Add(animData);
                }
            }
            else
            {
                tae.err = "Specified file is not a TAE file.";
            }

            file.Close();

            return(tae);
        }
Esempio n. 3
0
        public void AddGroupToEnterprise(string sid, DataSet group, string epriseName)
        {
            IDbTransaction t = null;
            try
            {
                Initialize(sid);
                string groupName = DataTools.GetTextField(group, AdminFields.GROUPNAME);

                GroupStruct gs  = new GroupStruct();
                gs.name         = groupName;
                gs.published    = DataTools.GetBoolField(group, AdminFields.PUBLISHED);
                gs.enterpriseid = DataTools.GetIntField(group, AdminFields.EPRISEID);
                t = db.BeginTransaction();
                gs.id = groups.CreateGroup(gs);
                cacheMem.SetCacheData(gs, DBTables.GROUPS + gs.name);
                if (t != null) db.Commit(t);
            }
            catch (Exception ex)
            {
                Exception wrappedEx = new Exception(
                    ErrorManager.AddLayer(ex, RunningClass.GetName(this), RunningClass.GetMethod()));
                throw wrappedEx;
            }
            finally
            {
                if (t != null) db.Commit(t);
            }
        }