Ejemplo n.º 1
0
        /// <summary>
        /// Initiates the CCache
        /// </summary>
        internal Cache()
        {
            //myInterface = callerInterface;
            // Init cache from embedded file
            _startup = new DSStartupResources();
            _startup.ReadXml(
                CEmbeddedResources.GetEmbeddedXmlFile(
                    "Allberg.Shooter.Common.DSStartupResources.xml"));

            // init cache from local file
            _localCacheFilename = CreateLocalFilename();
            _localCache         = new DSLocalCache();
            if (File.Exists(_localCacheFilename))
            {
                _localCache.ReadXml(_localCacheFilename);
            }
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     DSLocalCache ds = new DSLocalCache();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     DSLocalCache ds = new DSLocalCache();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "ClubsDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Ejemplo n.º 4
0
		private void menuImportInfoFromWinShooterCaache_Click(object sender, EventArgs e)
		{
			this.openFileDialog1.Filter = "*.xml|*.xml";
			DialogResult res = this.openFileDialog1.ShowDialog();
			if (res != DialogResult.OK)
				return;

			DSLocalCache temp = new DSLocalCache();
			temp.ReadXml(this.openFileDialog1.FileName);

			foreach (DSLocalCache.ClubsRow clubRow in temp.Clubs)
			{
				checkToUpdate(clubRow);
			}

			foreach (DSLocalCache.ShootersRow shooterRow in temp.Shooters)
			{
				if (int.Parse(shooterRow.Cardnr) > 0)
					checkToUpdate(shooterRow);
			}
			MessageBox.Show("Done!");
		}
Ejemplo n.º 5
0
		private void checkToUpdate(DSLocalCache.ShootersRow shooterRow)
		{
			if (int.Parse(shooterRow.Cardnr) > 45000)
				return;
			try
			{
				DSStartupResources.ShootersRow current = getShooter(shooterRow.Cardnr);

				// Since we got here, shooter already exist
				bool changed = false;
				string startString = "Do you want to update shooter " +
					current.Surname + " " + current.Givenname;
				string toView = startString;
				if (current.Class != shooterRow.Class)
				{
					toView += "\r\nClass=" + current.Class + " < " + shooterRow.Class;
					changed = true;
				}

				if (current.ClubId != shooterRow.ClubId)
				{
					toView += "\r\nClubId=" + current.ClubId + " < " + shooterRow.ClubId;
					changed = true;
				}

				if (current.Email != shooterRow.Email)
				{
					toView += "\r\nEmail=" + current.Email + " < " + shooterRow.Email;
					changed = true;
				}

				if (current.Givenname != shooterRow.Givenname)
				{
					toView += "\r\nGivenname=" + current.Givenname + " < " + shooterRow.Givenname;
					changed = true;
				}

				if (current.Surname != shooterRow.Surname)
				{
					toView += "\r\nSurname=" + current.Surname + " < " + shooterRow.Surname;
					changed = true;
				}

				toView += "\r\nLastUpdate=" + current.LastUpdate + " < " + shooterRow.LastUpdate;

				if (changed)
				{
					DialogResult res = MessageBox.Show(toView, "Update", MessageBoxButtons.YesNo);

					if (res == DialogResult.Yes)
					{
						current.Cardnr = shooterRow.Cardnr;
						current.Class = shooterRow.Class;
						current.ClubId = shooterRow.ClubId;
						current.Email = shooterRow.Email;
						current.Givenname = shooterRow.Givenname;
						current.Surname = shooterRow.Surname;
						current.LastUpdate = shooterRow.LastUpdate;
					}
				}
				else
				{
					if (current.LastUpdate < shooterRow.LastUpdate)
						current.LastUpdate = shooterRow.LastUpdate;
				}
			}
			catch(ApplicationException)
			{
				string toView = "Do you want to add shooter\r\n" +
					"Cardnr = " + shooterRow.Cardnr + "\r\n" +
					"Class = " + shooterRow.Class + "\r\n" +
					"ClubId = " + shooterRow.ClubId + "\r\n" +
					"Email = " + shooterRow.Email + "\r\n" +
					"Givenname = " + shooterRow.Givenname + "\r\n" +
					"Surname = " + shooterRow.Surname;
				DialogResult res = MessageBox.Show(toView, "Add", MessageBoxButtons.YesNo);

				if (res == DialogResult.Yes)
				{
					DSStartupResources.ShootersRow newShooter = this.ds.Shooters.NewShootersRow();
					newShooter.Cardnr = shooterRow.Cardnr;
					newShooter.Class = shooterRow.Class;
					newShooter.ClubId = shooterRow.ClubId;
					newShooter.Email = shooterRow.Email;
					newShooter.Givenname = shooterRow.Givenname;
					newShooter.Surname = shooterRow.Surname;
					newShooter.LastUpdate = shooterRow.LastUpdate;
					this.ds.Shooters.AddShootersRow(newShooter);
				}
			}
		}
Ejemplo n.º 6
0
		private void checkToUpdate(DataSetWinShooter.ShootersRow shooterRow)
		{
			DSLocalCache temp = new DSLocalCache();
			DSLocalCache.ShootersRow newShooterRow = temp.Shooters.NewShootersRow();
			newShooterRow.Cardnr = shooterRow.Cardnr;
			newShooterRow.Class = shooterRow.Class;
			newShooterRow.ClubId = shooterRow.ClubId;
			newShooterRow.Email = shooterRow.Email;
			newShooterRow.Givenname = shooterRow.Givenname;
			newShooterRow.LastUpdate = DateTime.Parse("2004-01-01");
			newShooterRow.Surname = shooterRow.Surname;

			checkToUpdate(newShooterRow);
		}
Ejemplo n.º 7
0
		private void checkToUpdate(DSLocalCache.ClubsRow clubRow)
		{
			if (clubRow.IsBankgiroNull())
				clubRow.Bankgiro = "";
			if (clubRow.IsPlusgiroNull())
				clubRow.Plusgiro = "";
			if (clubRow.IsEmailNull())
				clubRow.Email = "";
			try
			{
				DSStartupResources.ClubsRow current = getClub(clubRow.ClubId);

				// Since we got here, the club already exist
				if ((current.Bankgiro != clubRow.Bankgiro & clubRow.Bankgiro!="")|
					current.Country != clubRow.Country |
					(current.Email != clubRow.Email & clubRow.Email != "") |
					current.Name != clubRow.Name |
					(current.Plusgiro != clubRow.Plusgiro & clubRow.Plusgiro != ""))
				{
					//do update
					string toView = "Do you want to update club " + current.Name;

					if (current.Bankgiro != clubRow.Bankgiro &&
                        clubRow.Bankgiro != "")
						toView += "\r\nBankgiro: " + current.Bankgiro + " < " + clubRow.Bankgiro;

					if (current.Country != clubRow.Country)
						toView += "\r\nCountry: " + current.Country + " < " + clubRow.Country;

					if (current.Email != clubRow.Email &&
                        clubRow.Email != "")
						toView += "\r\nEmail: \"" + current.Email + "\" < \"" + clubRow.Email + "\"";

					if (current.Name != clubRow.Name)
						toView += "\r\nName: " + current.Name + " < " + clubRow.Name;

					if (current.Plusgiro != clubRow.Plusgiro &&
                        clubRow.Plusgiro != "")
						toView += "\r\nPlusgiro: " + current.Plusgiro + " < " + clubRow.Plusgiro;

					toView += "\r\nLastUpdate: " + current.LastUpdate + " < " + clubRow.LastUpdate;

					DialogResult res = MessageBox.Show(toView, 
						"Update", MessageBoxButtons.YesNo);
					if (res == DialogResult.Yes)
					{
						current.Bankgiro = clubRow.Bankgiro;
						current.Country = clubRow.Country;
						current.Email = clubRow.Email;
						current.Name = clubRow.Name;
						current.LastUpdate = clubRow.LastUpdate;
						current.Plusgiro = clubRow.Plusgiro;
					}
				}
			}
			catch(ApplicationException)
			{
				DialogResult res = MessageBox.Show("Do you want to add club" +
					clubRow.ClubId + " (" + clubRow.Name  + ")", "Add", MessageBoxButtons.YesNo);

				if (res == DialogResult.Yes)
				{
					DSStartupResources.ClubsRow newRow = this.ds.Clubs.NewClubsRow();
					newRow.Bankgiro = clubRow.Bankgiro;
					newRow.ClubId = clubRow.ClubId;
					newRow.Country = clubRow.Country;
					newRow.Email = clubRow.Email;
					newRow.Name = clubRow.Name;
					newRow.Plusgiro = clubRow.Plusgiro;
					newRow.LastUpdate = clubRow.LastUpdate;
					this.ds.Clubs.AddClubsRow(newRow);
				}
			}
		}
Ejemplo n.º 8
0
		private void checkToUpdate(DataSetWinShooter.ClubsRow clubRow)
		{
			DSLocalCache temp = new DSLocalCache();
			DSLocalCache.ClubsRow newClubsRow = temp.Clubs.NewClubsRow();

			newClubsRow.Bankgiro = clubRow.Bankgiro;
			newClubsRow.ClubId = clubRow.ClubId;
			newClubsRow.Country = clubRow.Country;
			newClubsRow.Email = clubRow.Email;
			newClubsRow.Name = clubRow.Name;
			newClubsRow.Plusgiro = clubRow.Plusgiro;
			newClubsRow.LastUpdate = DateTime.Parse("2004-01-01");

			checkToUpdate(newClubsRow);
		}