Example #1
0
        /// <summary>
        /// Sets the properties for a media object.
        /// </summary>
        /// <param name="id">The id of the media object.</param>
        /// <param name="properties">The properties for the media object.</param>
        /// <remarks>Documented by Dev03, 2008-08-05</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void SetProperties(int id, Dictionary <MLifter.DAL.Interfaces.MediaProperty, string> properties)
        {
            SqlCeCommand     cmd1 = MSSQLCEConn.CreateCommand(Parent.CurrentUser);
            SqlCeTransaction tran = cmd1.Connection.BeginTransaction();

            cmd1.CommandText = "DELETE FROM MediaProperties WHERE media_id=@id;";
            cmd1.Parameters.Add("@id", id);
            MSSQLCEConn.ExecuteNonQuery(cmd1);

            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "INSERT INTO MediaProperties (media_id, property, value) VALUES (@media_id, @property, @value);";
            cmd.Parameters.Add("@media_id", SqlDbType.Int, 4);
            cmd.Parameters.Add("@property", SqlDbType.NVarChar, 100);
            cmd.Parameters.Add("@value", SqlDbType.NVarChar, 100);
            foreach (KeyValuePair <MediaProperty, string> item in properties)
            {
                cmd.Parameters["@media_id"].Value = id;
                cmd.Parameters["@property"].Value = item.Key.ToString();
                cmd.Parameters["@value"].Value    = item.Value;
                MSSQLCEConn.ExecuteNonQuery(cmd);
            }

            tran.Commit();
        }
        /// <summary>
        /// Sets the chapter for a card.
        /// </summary>
        /// <param name="id">The card id.</param>
        /// <param name="chapter">The chapter id.</param>
        /// <remarks>Documented by Dev03, 2008-08-06</remarks>
        /// <remarks>Documented by Dev08, 2009-01-09</remarks>
        public void SetChapter(int id, int chapter)
        {
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
            {
                SqlCeTransaction transaction = cmd.Connection.BeginTransaction();
                cmd.CommandText = "SELECT count(*) FROM \"Chapters\" WHERE id=@chapterid";
                cmd.Parameters.Add("chapterid", chapter);
                if (Convert.ToInt32(MSSQLCEConn.ExecuteScalar(cmd)) < 1)
                {
                    throw new IdAccessException(chapter);
                }
                Dictionary <int, int> cardChapterCache = parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.CardChapterList, 0)] as Dictionary <int, int>;
                if (cardChapterCache != null)
                {
                    cardChapterCache[id] = chapter;
                }

                using (SqlCeCommand cmd2 = MSSQLCEConn.CreateCommand(parent.CurrentUser))
                {
                    cmd2.CommandText  = "DELETE FROM \"Chapters_Cards\" WHERE cards_id=@id; ";
                    cmd2.CommandText += "INSERT INTO \"Chapters_Cards\" (chapters_id, cards_id) VALUES (@chapterid, @id);";
                    cmd2.CommandText += "UPDATE Cards SET chapters_id=@chapterid WHERE id=@id;";
                    cmd2.Parameters.Add("@chapterid", chapter);
                    cmd2.Parameters.Add("@id", id);
                    MSSQLCEConn.ExecuteNonQuery(cmd2);
                }
                transaction.Commit();
            }
        }
Example #3
0
        /// <summary>
        /// Sets a single property value for a media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="property">The property.</param>
        /// <param name="value">The value.</param>
        /// <remarks>Documented by Dev02, 2008-08-07</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void SetPropertyValue(int id, MLifter.DAL.Interfaces.MediaProperty property, string value)
        {
            SqlCeCommand     cmd  = MSSQLCEConn.CreateCommand(Parent.CurrentUser);
            SqlCeTransaction tran = cmd.Connection.BeginTransaction();

            if (GetPropertyValue(id, property) == null)
            {
                cmd.CommandText = "INSERT INTO MediaProperties (media_id, property, value) VALUES (@media_id, @property, @value);";
            }
            else
            {
                cmd.CommandText = "UPDATE MediaProperties SET value=@value WHERE media_id=@media_id AND property=@property;";
            }

            Dictionary <MediaProperty, string> properties = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.MediaProperties, id)] as Dictionary <MediaProperty, string>;

            if (properties == null)
            {
                properties = new Dictionary <MediaProperty, string>();
            }
            properties[property] = value;
            Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.MediaProperties, id, new TimeSpan(1, 0, 0))] = properties;

            cmd.Parameters.Add("@media_id", id);
            cmd.Parameters.Add("@property", property.ToString());
            cmd.Parameters.Add("@value", value);
            MSSQLCEConn.ExecuteNonQuery(cmd);

            tran.Commit();
        }
Example #4
0
        /// <summary>
        /// Copies the statistics.
        /// </summary>
        /// <param name="lmId">The lm id.</param>
        /// <param name="statistic">The statistic.</param>
        /// <remarks>Documented by Dev08, 2009-02-09</remarks>
        public void CopyStatistics(int lmId, IStatistic statistic)
        {
            if (statistic.StartTimestamp == null || statistic.EndTimestamp == null)     //do not save invalid sessions
            {
                return;
            }

            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser);

            cmd.CommandText = "INSERT INTO LearningSessions(user_id, lm_id, starttime, endtime, sum_right, sum_wrong, " +
                              "pool_content, box1_content, box2_content, box3_content, box4_content, box5_content, box6_content, box7_content, box8_content, box9_content, box10_content)" +
                              "VALUES(@userid, @lmid, @starttime, @endtime, @sumright, @sumwrong, @pool, @b1, @b2, @b3, @b4, @b5, @b6, @b7, @b8, @b9, @b10)";

            cmd.Parameters.Add("@userid", parent.CurrentUser.Id);
            cmd.Parameters.Add("@lmid", lmId);
            cmd.Parameters.Add("@starttime", statistic.StartTimestamp);
            cmd.Parameters.Add("@endtime", statistic.EndTimestamp);
            cmd.Parameters.Add("@sumright", statistic.Right);
            cmd.Parameters.Add("@sumwrong", statistic.Wrong);
            int counter = 0;

            foreach (int box in statistic.Boxes)
            {
                ++counter;
                cmd.Parameters.Add("@b" + counter.ToString(), box);
            }

            cmd.Parameters.Add("@pool", parent.GetParentDictionary().Boxes.Box[0].MaximalSize);     //pool max size => cards in pools

            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
Example #5
0
        public void RecalculateBoxSizes(int sessionId)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE LearningSessions SET pool_content=@pool, box1_content=@b1, box2_content=@b2, box3_content=@b3, " +
                              "box4_content=@b4, box5_content=@b5, box6_content=@b6, box7_content=@b7, box8_content=@b8, box9_content=@b9, box10_content=@b10 WHERE id=@sid AND user_id=@uid AND lm_id=@lmid";
            cmd.Parameters.Add("sid", sessionId);
            cmd.Parameters.Add("@uid", Parent.CurrentUser.Id);
            cmd.Parameters.Add("@lmid", Parent.GetParentDictionary().Id);

            int      counter      = 0;
            int      cardsInBoxes = 0;
            BoxSizes boxContent   = GetCurrentBoxContent();

            foreach (int box in boxContent.Sizes)
            {
                if (counter == 0)
                {
                    cmd.Parameters.Add("@pool", box);
                    ++counter;
                    continue;
                }

                cmd.Parameters.Add("@b" + Convert.ToString(counter++), box);
                cardsInBoxes += box;
            }

            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
Example #6
0
        /// <summary>
        /// Deletes the chapter.
        /// </summary>
        /// <param name="lmid">The id of the learning module.</param>
        /// <param name="id">The id.</param>
        /// <remarks>Documented by Dev02, 2008-08-05</remarks>
        /// <remarks>Documented by Dev08, 2009-01-12</remarks>
        public void DeleteChapter(int lmid, int id)
        {
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
            {
                cmd.CommandText  = "DELETE FROM LearningModules_Cards WHERE cards_id IN (SELECT cards_id FROM Chapters_Cards WHERE chapters_id=@id); ";
                cmd.CommandText += "DELETE FROM Cards_MediaContent WHERE cards_id IN (SELECT cards_id FROM Chapters_Cards WHERE chapters_id=@id); ";
                cmd.CommandText += "DELETE FROM UserCardState WHERE cards_id IN (SELECT cards_id FROM Chapters_Cards WHERE chapters_id=@id); ";
                cmd.CommandText += "DELETE FROM TextContent WHERE cards_id IN (SELECT cards_id FROM Chapters_Cards WHERE chapters_id=@id); ";
                cmd.CommandText += "DELETE FROM LearnLog WHERE cards_id IN (SELECT cards_id FROM Chapters_Cards WHERE chapters_id=@id); ";
                cmd.CommandText += "DELETE FROM Chapters_Cards WHERE chapters_id=@id; ";
                cmd.CommandText += "DELETE FROM SelectedLearnChapters WHERE chapters_id=@id; ";
                cmd.CommandText += "DELETE FROM Cards_MediaContent WHERE cards_id NOT IN (SELECT cards_id FROM LearningModules_Cards); ";
                cmd.CommandText += "DELETE FROM UserCardState WHERE cards_id NOT IN (SELECT cards_id FROM LearningModules_Cards); ";
                cmd.CommandText += "DELETE FROM TextContent WHERE cards_id NOT IN (SELECT cards_id FROM LearningModules_Cards); ";
                cmd.CommandText += "DELETE FROM LearnLog WHERE cards_id NOT IN (SELECT cards_id FROM LearningModules_Cards); ";
                cmd.CommandText += "DELETE FROM Cards WHERE id NOT IN (SELECT cards_id FROM LearningModules_Cards); ";
                cmd.CommandText += "DELETE FROM Chapters WHERE id=@id";
                cmd.Parameters.Add("@id", id);
                if (MSSQLCEConn.ExecuteNonQuery(cmd) < 1)
                {
                    throw new IdAccessException(id);
                }

                parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.ChaptersList, lmid));
            }
        }
Example #7
0
        /// <summary>
        /// Deletes the media object.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <remarks>Documented by Dev03, 2008-08-05</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void DeleteMedia(int id)
        {
            SqlCeCommand deletecmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            deletecmd.CommandText = "DELETE FROM MediaProperties WHERE media_id=@id; DELETE FROM MediaContent WHERE id=@id;";
            deletecmd.Parameters.Add("@id", id);
            MSSQLCEConn.ExecuteNonQuery(deletecmd);
        }
        /// <summary>
        /// Sets the default.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="Default">if set to <c>true</c> [default].</param>
        /// <remarks>Documented by Dev03, 2009-01-09</remarks>
        public void SetDefault(int id, bool Default)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE TextContent SET is_default=@isdefault WHERE id=@id";
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@isdefault", Default);
            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
        /// <summary>
        /// Sets the type.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="Type">The type.</param>
        /// <remarks>Documented by Dev03, 2009-01-09</remarks>
        public void SetType(int id, WordType Type)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE TextContent SET type=@typ WHERE id=@id";
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@typ", Type);
            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
 /// <summary>
 /// Clears the media for card style.
 /// </summary>
 /// <param name="Id">The style id.</param>
 /// <remarks>Documented by Dev03, 2009-03-05</remarks>
 /// <remarks>Documented by Dev03, 2009-03-05</remarks>
 public void ClearMediaForCardStyle(int Id)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "DELETE FROM \"MediaContent_CardStyles\" WHERE cardstyles_id = @cardstyle_id";
         cmd.Parameters.Add("@cardstyle_id", Id);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
        /// <summary>
        /// Sets the word.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="Word">The word.</param>
        /// <remarks>Documented by Dev03, 2009-01-09</remarks>
        public void SetWord(int id, string Word)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE TextContent SET text=@text WHERE id=@id";
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@text", Word);
            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
 /// <summary>
 /// Deletes the extension.
 /// </summary>
 /// <param name="guid">The GUID.</param>
 public void DeleteExtension(Guid guid)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText  = "DELETE FROM \"ExtensionActions\" WHERE guid=@guid; ";
         cmd.CommandText += "DELETE FROM \"Extensions\" WHERE guid=@guid";
         cmd.Parameters.Add("@guid", guid.ToString());
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
 /// <summary>
 /// Sets the extension version.
 /// </summary>
 /// <param name="guid">The GUID.</param>
 /// <param name="versionName">Name of the version.</param>
 /// <remarks>Documented by Dev08, 2009-07-02</remarks>
 public void SetExtensionVersion(Guid guid, Version versionName)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"Extensions\" SET version=@version WHERE guid=@guid;";
         cmd.Parameters.Add("@guid", guid.ToString());
         cmd.Parameters.Add("@version", versionName.ToString());
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
Example #14
0
 /// <summary>
 /// Sets the GUID.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="guid">The GUID.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetGuid(int id, string guid)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"LearningModules\" SET guid=@guid WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@guid", guid);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
 /// <summary>
 /// Sets the type of the extension.
 /// </summary>
 /// <param name="guid">The GUID.</param>
 /// <param name="extensionType">Type of the extension.</param>
 /// <remarks>Documented by Dev08, 2009-07-02</remarks>
 public void SetExtensionType(Guid guid, ExtensionType extensionType)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"Extensions\" SET type=@type WHERE guid=@guid;";
         cmd.Parameters.Add("@guid", guid.ToString());
         cmd.Parameters.Add("@type", extensionType.ToString());
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
 /// <summary>
 /// Sets the extension LM.
 /// </summary>
 /// <param name="guid">The GUID.</param>
 /// <param name="lmid">The lmid.</param>
 public void SetExtensionLM(Guid guid, int lmid)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"Extensions\" SET lm_id=@lmid WHERE guid=@guid";
         cmd.Parameters.Add("@guid", guid.ToString());
         cmd.Parameters.Add("@lmid", lmid);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
Example #17
0
 /// <summary>
 /// Sets the description.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="description">The description.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetDescription(int id, string description)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"LearningModules\" SET description=@description WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@description", description);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
Example #18
0
 /// <summary>
 /// Sets the allowed settings.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="settingsId">The settings id.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetAllowedSettings(int id, int settingsId)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"LearningModules\" SET allowed_settings_id=@settingsid WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@settingsid", settingsId);
         MSSQLCEConn.ExecuteNonQuery(cmd);
         parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.AllowedLearningModuleSettings, id));
     }
 }
 public void ClearAllBoxes(int id)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"UserCardState\" SET box=0, active=1 WHERE user_id=@userid " +
                           "AND cards_id IN (SELECT cards_id FROM \"LearningModules_Cards\" WHERE lm_id=@lmid);";
         cmd.Parameters.Add("@lmid", id);
         cmd.Parameters.Add("@userid", Parent.CurrentUser.Id);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
Example #20
0
 /// <summary>
 /// Sets the author.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="author">The author.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetAuthor(int id, string author)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"LearningModules\" SET author=@author WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@author", author);
         MSSQLCEConn.ExecuteNonQuery(cmd);
         parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.LearningModuleAuthor, id));
     }
 }
Example #21
0
 /// <summary>
 /// Sets the title.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="title">The title.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetTitle(int id, string title)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"LearningModules\" SET title=@title WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@title", title);
         MSSQLCEConn.ExecuteNonQuery(cmd);
         parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.LearningModuleTitle, id));
     }
 }
Example #22
0
        public void CardFromBoxDeleted(int sessionId, int boxId)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = string.Format("UPDATE LearningSessions SET {0}_content={0}_content - 1 WHERE id=@sid AND user_id=@uid AND lm_id=@lmid", boxId > 0 ? "box" + boxId.ToString() : "pool");
            cmd.Parameters.Add("sid", sessionId);
            cmd.Parameters.Add("@uid", Parent.CurrentUser.Id);
            cmd.Parameters.Add("@lmid", Parent.GetParentDictionary().Id);

            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
Example #23
0
 /// <summary>
 /// Sets the description of the chapter.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="description">The description.</param>
 /// <remarks>Documented by Dev02, 2008-08-05</remarks>
 /// <remarks>Documented by Dev05, 2009-01-15</remarks>
 public void SetDescription(int id, string description)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"Chapters\" SET description=@description WHERE id=@id";
         cmd.Parameters.Add("@id", id);
         cmd.Parameters.Add("@description", description);
         MSSQLCEConn.ExecuteNonQuery(cmd);
         Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(CacheObject.ChapterDescription, id));
     }
 }
Example #24
0
        public void CardAdded(int sessionId)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE LearningSessions SET pool_content=pool_content + 1 WHERE id=@sid AND user_id=@uid AND lm_id=@lmid";
            cmd.Parameters.Add("sid", sessionId);
            cmd.Parameters.Add("@uid", Parent.CurrentUser.Id);
            cmd.Parameters.Add("@lmid", Parent.GetParentDictionary().Id);

            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
Example #25
0
        /// <summary>
        /// Updates the media.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="media">The media.</param>
        /// <remarks>Documented by Dev02, 2008-08-06</remarks>
        /// <remarks>Documented by Dev03, 2009-01-13</remarks>
        public void UpdateMedia(int id, System.IO.Stream media)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "UPDATE MediaContent SET data=@data WHERE id=@id";
            cmd.Parameters.Add("@data", SqlDbType.Image);
            cmd.Parameters.Add("@id", SqlDbType.Int, 4);
            cmd.Parameters["@data"].Value = GetByteArrayFromStream(media, null, null);
            cmd.Parameters["@id"].Value   = id;
            MSSQLCEConn.ExecuteNonQuery(cmd);
        }
 /// <summary>
 /// Sets the extension stream.
 /// </summary>
 /// <param name="guid">The GUID.</param>
 /// <param name="extensionStream">The extension stream.</param>
 /// <remarks>Documented by Dev08, 2009-07-02</remarks>
 public void SetExtensionStream(Guid guid, Stream extensionStream)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         cmd.CommandText = "UPDATE \"Extensions\" SET data=@data WHERE guid=@guid";
         cmd.Parameters.Add("@guid", guid.ToString());
         cmd.Parameters.Add("@data", SqlDbType.Image);
         cmd.Parameters["@data"].Value = GetByteArrayFromStream(extensionStream, null, null);
         MSSQLCEConn.ExecuteNonQuery(cmd);
     }
 }
Example #27
0
        /// <summary>
        /// Sets the settings.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="Settings">The settings.</param>
        /// <remarks>Documented by Dev05, 2009-01-15</remarks>
        public void SetSettings(int id, ISettings Settings)
        {
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser))
            {
                cmd.CommandText = "UPDATE \"Chapters\" SET settings_id=@value WHERE id=@id";
                cmd.Parameters.Add("@id", id);
                cmd.Parameters.Add("@value", (Settings as DbSettings).Id);

                MSSQLCEConn.ExecuteNonQuery(cmd);
                Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.ChapterSetting, id)] = (Settings as DbSettings).Id;
            }
        }
Example #28
0
        /// <summary>
        /// Sets the highscore.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="highscore">The highscore.</param>
        /// <remarks>Documented by Dev08, 2009-01-13</remarks>
        public void SetHighscore(int id, double highscore)
        {
            using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
            {
                cmd.CommandText = "UPDATE \"UserProfilesLearningModulesSettings\" SET highscore=@value WHERE user_id=@uid and lm_id=@lm_id;";
                cmd.Parameters.Add("@uid", parent.CurrentUser.Id);
                cmd.Parameters.Add("@lm_id", id);
                cmd.Parameters.Add("@value", highscore);

                MSSQLCEConn.ExecuteNonQuery(cmd);
            }
        }
        /// <summary>
        /// Clears all words.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="side">The side.</param>
        /// <param name="type">The type.</param>
        /// <remarks>Documented by Dev03, 2009-01-09</remarks>
        public void ClearAllWords(int id, Side side, WordType type)
        {
            SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser);

            cmd.CommandText = "DELETE FROM TextContent WHERE cards_id=@id AND side=@side AND type=@type";
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@side", side.ToString());
            cmd.Parameters.Add("@type", type.ToString());
            MSSQLCEConn.ExecuteNonQuery(cmd);

            Parent.CurrentUser.Cache.Uncache(ObjectLifetimeIdentifier.GetIdentifier(ObjectLifetimeIdentifier.GetCacheObject(side, type), id));
        }
 /// <summary>
 /// Sets the card style.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <param name="cardStyle">The card style.</param>
 /// <remarks>Documented by Dev08, 2009-01-12</remarks>
 public void SetCardStyle(int id, string cardStyle)
 {
     using (SqlCeCommand cmd = MSSQLCEConn.CreateCommand(parent.CurrentUser))
     {
         using (SqlCeCommand cmd2 = MSSQLCEConn.CreateCommand(parent.CurrentUser))
         {
             cmd2.CommandText = "UPDATE \"CardStyles\" SET value=@value WHERE id=@id";
             cmd2.Parameters.Add("@id", id);
             cmd2.Parameters.Add("@value", cardStyle);
             MSSQLCEConn.ExecuteNonQuery(cmd2);
         }
     }
 }