コード例 #1
0
 public OwnerRowChangeEvent(OwnerRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
コード例 #2
0
        public static void saveGlobalList(WorldSaveEventArgs e)
        {
            if (!System.IO.File.Exists(xmlSchema))
            {
                Console.WriteLine("Could not open {0}.", xmlSchema);
                Console.WriteLine("{0} must be in .\\Data\\Bounty System", xmlSchema);
                Console.WriteLine("Cannot save bounties.");
                return;
            }

            if (System.IO.File.Exists(xmlFileBackup))
            {
                System.IO.File.Delete(xmlFileBackup);
            }

            if (System.IO.File.Exists(xmlFile))
            {
                System.IO.File.Move(xmlFile, xmlFileBackup);
            }

            DataSet ds = new DataSet();

            ds.ReadXmlSchema(xmlSchema);
            DataRow bountyRow, OwnerRow, WantedRow, requestedRow, acceptedRow;

            foreach (BountyBoardEntry entry in m_Entries)
            {
                if (entry == null)
                {
                    continue;
                }

                if (entry.Owner == null || entry.Owner.Deleted)
                {
                    continue;
                }

                if (entry.Wanted == null || entry.Wanted.Deleted)
                {
                    BountyBoard.RemoveEntry(entry, true);
                    continue;
                }

                bountyRow               = ds.Tables["Bounty"].NewRow();
                bountyRow["Price"]      = entry.Price;
                bountyRow["ExpireTime"] = entry.ExpireTime;
                ds.Tables["Bounty"].Rows.Add(bountyRow);

                OwnerRow           = ds.Tables["Owner"].NewRow();
                OwnerRow["Name"]   = entry.Owner.Name;
                OwnerRow["Serial"] = entry.Owner.Serial.Value;
                OwnerRow.SetParentRow(bountyRow, ds.Relations["Bounty_Owner"]);
                ds.Tables["Owner"].Rows.Add(OwnerRow);

                WantedRow           = ds.Tables["Wanted"].NewRow();
                WantedRow["Name"]   = entry.Wanted.Name;
                WantedRow["Serial"] = entry.Wanted.Serial.Value;
                WantedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Wanted"]);
                ds.Tables["Wanted"].Rows.Add(WantedRow);

                foreach (Mobile requested in entry.Requested)
                {
                    if (requested == null || requested.Deleted)
                    {
                        continue;
                    }

                    requestedRow           = ds.Tables["Requested"].NewRow();
                    requestedRow["Name"]   = requested.Name;
                    requestedRow["Serial"] = requested.Serial.Value;
                    requestedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Requested"]);
                    ds.Tables["Requested"].Rows.Add(requestedRow);
                }

                foreach (Mobile accepted in entry.Accepted)
                {
                    if (accepted == null || accepted.Deleted)
                    {
                        continue;
                    }

                    acceptedRow           = ds.Tables["Accepted"].NewRow();
                    acceptedRow["Name"]   = accepted.Name;
                    acceptedRow["Serial"] = accepted.Serial.Value;
                    acceptedRow.SetParentRow(bountyRow, ds.Relations["Bounty_Accepted"]);
                    ds.Tables["Accepted"].Rows.Add(acceptedRow);
                }

                ds.WriteXml(xmlFile);
            }
        }