public override string ResetPassword(string username, string answer) { if (!EnablePasswordReset) { throw new NotSupportedException(); } using (var transaction = new TransactionScope(_mConfiguration)) { var dataStore = new UserDataStore(transaction); User user = dataStore.FindByName(ApplicationName, username); if (user == null) { throw new UserNotFoundException(username); } if (RequiresQuestionAndAnswer && user.ValidatePasswordAnswer(answer, PasswordAttemptWindow, MaxInvalidPasswordAttempts) == false) { transaction.Commit(); throw new MembershipPasswordException(); } else { string newPassword = System.Web.Security.Membership.GeneratePassword(MinRequiredPasswordLength, MinRequiredNonAlphanumericCharacters); user.ChangePassword(newPassword); transaction.Commit(); return(newPassword); } } }
public override int DeleteInactiveProfiles(ProfileAuthenticationOption authenticationOption, DateTime userInactiveSinceDate) { ProfileType?profileType = null; if (authenticationOption == ProfileAuthenticationOption.Anonymous) { profileType = ProfileType.Anonymous; } else if (authenticationOption == ProfileAuthenticationOption.Authenticated) { profileType = ProfileType.Authenticated; } int profilesDeleted = 0; using (var transaction = new TransactionScope(mConfiguration)) { var profileStore = new ProfileUserDataStore(transaction); IList <ProfileUser> users = profileStore.FindByFields(ApplicationName, null, userInactiveSinceDate, profileType, PagingInfo.All); profilesDeleted = users.Count; foreach (ProfileUser user in users) { profileStore.Delete(user.Id); } transaction.Commit(); } return(profilesDeleted); }
public static void test123() { using (TransactionScope scope = ELDB2.DBFactory.NewTransactionScope(false)) { IRelationAccesser r = scope.NewRelationAccesser(); DataTable tb = r.DoQuery("select * from storages order by Address").Tables[0]; // ================================= System.Console.WriteLine(System.DateTime.Now.Second + ":" + System.DateTime.Now.Millisecond); ELDB2.HashSelectHandle h = new ELDB2.HashSelectHandle(tb); int j = 0; for (int k = 0; k < 1000; k++) { foreach (DataRow row in tb.Rows) { Hashtable t = h.Select <string>("Address", row.Field <string>("Address").Trim()); for (int i = 0; i < t.Count; i++) { j++; } } } System.Console.WriteLine(j.ToString()); System.Console.WriteLine(System.DateTime.Now.Second + ":" + System.DateTime.Now.Millisecond); // ================================= scope.Commit(); } }
/// <summary> /// Moves the calendar. /// </summary> /// <param name="calendar">The calendar.</param> /// <param name="newFolder">The new folder.</param> public static void MoveCalendar(Calendar calendar, CalendarFolder newFolder) { if (calendar == null) { throw new ArgumentNullException("calendar"); } if (newFolder == null) { throw new ArgumentNullException("newFolder"); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Raise Calendar Moving RaiseEvent(CalendarMoving, calendar, EventArgs.Empty); calendar.CalendarFolderId = newFolder.PrimaryKeyId.Value; calendar.Owner = newFolder.Owner; calendar.Save(); RaiseEvent(CalendarMoved, calendar, EventArgs.Empty); tran.Commit(); } }
/// <summary> /// Creates the folder. /// </summary> /// <param name="parent">The parent.</param> /// <param name="name">The name.</param> /// <returns></returns> public static CalendarFolder CreateFolder(CalendarFolder parent, string name) { if (parent == null) { throw new ArgumentNullException("parent"); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { // Create Detached Folder CalendarFolder newRoot = new CalendarFolder(); newRoot.Title = name; newRoot.ProjectId = parent.ProjectId; newRoot.Owner = parent.Owner; newRoot.Save(); // Append to TreeNode node = parent.GetTreeService().AppendChild(newRoot); parent.Save(); tran.Commit(); return(newRoot); } }
public SqliteChatRecordPersister(string sqlitePath) { try { bool isNew = !File.Exists(sqlitePath); //2014.11.27 string dirName = Path.GetDirectoryName(sqlitePath); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } //初始化Sqlite数据库 DataConfiguration config = new SqliteDataConfiguration(sqlitePath); TransactionScopeFactory transactionScopeFactory = new TransactionScopeFactory(config); transactionScopeFactory.Initialize(); if (isNew) { string sql = "CREATE TABLE ChatMessageRecord (AutoID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, SpeakerID VARCHAR( 0, 20 ) NOT NULL, AudienceID VARCHAR( 0, 20 ) NOT NULL, IsGroupChat BOOLEAN NOT NULL,IsNotice BOOLEAN NOT NULL, Content BLOB NOT NULL, OccureTime DATETIME NOT NULL ); " + "CREATE INDEX idx_ChatMessageRecord ON ChatMessageRecord ( SpeakerID, AudienceID, OccureTime DESC );" + "CREATE INDEX idx2_ChatMessageRecord ON ChatMessageRecord ( AudienceID, IsGroupChat, OccureTime );"; using (TransactionScope scope = transactionScopeFactory.NewTransactionScope()) { IRelationAccesser accesser = scope.NewRelationAccesser(); accesser.DoCommand(sql); scope.Commit(); } } base.Initialize(transactionScopeFactory); } catch { } }
/// <summary> /// Marks orphaned file records (the ones that do not have a referencing binary record anymore) as Deleted. /// </summary> public void CleanupFilesSetDeleteFlag() { var isLocalTransaction = false; if (!TransactionScope.IsActive) { TransactionScope.Begin(); isLocalTransaction = true; } try { using (var proc = new SqlProcedure { CommandText = CleanupFileSetIsdeletedScript, CommandType = CommandType.Text }) { proc.CommandType = CommandType.Text; proc.ExecuteNonQuery(); } if (isLocalTransaction && TransactionScope.IsActive) { TransactionScope.Commit(); } } catch (Exception ex) { if (isLocalTransaction && TransactionScope.IsActive) { TransactionScope.Rollback(); } throw new DataException("Error during setting deleted flag on files.", ex); } }
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { using (var transaction = new TransactionScope(mConfiguration)) { var usersInRolesStore = new UserInRoleDataStore(transaction); foreach (string userName in usernames) { foreach (string roleName in roleNames) { var rDS = new RoleDataStore(transaction); Role role = rDS.FindByName(mApplicationName, roleName); var uDS = new UserDataStore(transaction); User user = uDS.FindByName(mApplicationName, userName); UserInRole userInRole = usersInRolesStore.Find(ApplicationName, user, role); if (userInRole == null) { throw new UserInRoleNotFoundException(userName, roleName); } userInRole.Deleted = true; usersInRolesStore.Update(userInRole); } } transaction.Commit(); } }
public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; DateTime startDate = DateTime.Parse(cp.CommandArguments["primaryKeyId"], CultureInfo.InvariantCulture); TimeTrackingBlock[] mas = TimeTrackingBlock.List(FilterElement.EqualElement("OwnerId", Mediachase.IBN.Business.Security.CurrentUser.UserID), FilterElement.EqualElement("StartDate", startDate)); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (TimeTrackingBlock ttb in mas) { StateMachineService sms = ((BusinessObject)ttb).GetService <StateMachineService>(); // process only initial state if (sms.StateMachine.GetStateIndex(sms.CurrentState.Name) == 0) { StateTransition[] availableTransitions = sms.GetNextAvailableTransitions(true); if (availableTransitions.Length > 0) { sms.MakeTransition(availableTransitions[0].Uid); ttb.Save(); } } } tran.Commit(); } CHelper.RequireBindGrid(); } }
/// <summary> /// Deletes the navigation item. /// </summary> /// <param name="fullId">The full id.</param> /// <param name="profileId">The profile id.</param> /// <param name="principalId">The principal id.</param> public static void DeleteNavigationItem(string fullId, PrimaryKeyId?profileId, PrimaryKeyId?principalId) { FilterElementCollection filters = new FilterElementCollection(); filters.Add(new FilterElement(CustomizationItemEntity.FieldXmlFullId, FilterElementType.Like, fullId + "%")); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu)); filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)ItemCommandType.Add)); // delete user level only if (principalId.HasValue) { filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value)); } // delete profile and user level else if (profileId.HasValue) { OrBlockFilterElement block = new OrBlockFilterElement(); block.ChildElements.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value)); block.ChildElements.Add(FilterElement.IsNotNullElement(CustomizationItemEntity.FieldPrincipalId)); filters.Add(block); } // else delete all - we don't use filter in that case using (TransactionScope transaction = DataContext.Current.BeginTransaction()) { foreach (EntityObject item in BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray())) { BusinessManager.Delete(item); } transaction.Commit(); } ClearCache(profileId, principalId); }
public IList <TEntity> Select <TEntity>(string sql, bool isUsedHash) where TEntity : new() { List <TEntity> list = new List <TEntity>(); using (TransactionScope scope = ELDB2.DBFactory.NewTransactionScope(false)) { IRelationAccesser r = scope.NewRelationAccesser(); DataTable table = r.DoQuery(sql).Tables[0]; if (isUsedHash) { AddToHash(table); } foreach (DataRow row in table.Rows) { TEntity entity = new TEntity(); foreach (DataColumn col in row.Table.Columns) { ((ELDB2.IHashEntity)entity).PropertySet[col.ColumnName] = row[col.ColumnName]; } list.Add(entity); } scope.Commit(); } return(list); }
public override void CreateRegion(Region region) { if (region.RegionType == null) { throw new ArgumentNullException("region", "RegionType is null"); } if (string.IsNullOrEmpty(region.Name)) { throw new ProviderException("Region name cannot be empty or null."); } if (region.Name.IndexOf(',') > 0) { throw new ArgumentException("Region names cannot contain commas.", "region"); } using (var transaction = new TransactionScope(_configuration)) { if (!RegionTypeExists(region.RegionType)) { CreateRegionType(region.RegionType); } var rDs = new RegionDataStore(transaction); rDs.Insert(region); transaction.Commit(); } }
public void Invoke(object Sender, object Element) { if (Element is CommandParameters) { CommandParameters cp = (CommandParameters)Element; string[] elemsToDelete = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]); int error = 0; using (TransactionScope tran = DataContext.Current.BeginTransaction()) { foreach (string elem in elemsToDelete) { int id = Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture); if (id > 0) { try { ListManager.DeleteList(id); } catch { error++; } } } tran.Commit(); } if (error > 0) { ClientScript.RegisterStartupScript(((Control)Sender).Page, ((Control)Sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("alert('{0}');", CHelper.GetResFileString("{IbnFramework.ListInfo:RefItemException}")), true); } } }
public override Message CreateMessage(Topic topic, string idParentMessage, string owner, string title, string body, Attachment.FileInfo attachment) { //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, topic.Category.AttachExtensions, topic.Category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { TopicDataStore topicStore = new TopicDataStore(transaction); topicStore.Attach(topic); MessageDataStore messageStore = new MessageDataStore(transaction); Message parentMessage = messageStore.FindByKey(idParentMessage); if (parentMessage == null) { throw new MessageNotFoundException(idParentMessage); } Message newMessage = new Message(topic, idParentMessage, owner, title, body, attachment); messageStore.Insert(newMessage); transaction.Commit(); //Notify user for answer NotifyUserReply(parentMessage, newMessage); return(newMessage); } }
/// <summary> /// Create the topic and the relative root message. /// </summary> /// <param name="category"></param> /// <param name="owner"></param> /// <param name="title"></param> /// <param name="body"></param> /// <param name="attachment">Use null if you don't have any attachment</param> /// <param name="topic">Returns the topic created</param> /// <param name="rootMessage">Returns the message created</param> public override void CreateTopic(Category category, string owner, string title, string body, Attachment.FileInfo attachment, out Topic topic, out Message rootMessage, string groups) { //Check attachment if (attachment != null) { Attachment.FileHelper.CheckFile(attachment, category.AttachExtensions, category.AttachMaxSize); } using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore forumStore = new CategoryDataStore(transaction); forumStore.Attach(category); //Insert topic TopicDataStore topicStore = new TopicDataStore(transaction); topic = new Topic(category, owner, title); topic.Groups = groups; topicStore.Insert(topic); //Insert root message MessageDataStore messageStore = new MessageDataStore(transaction); rootMessage = new Message(topic, null, owner, title, body, attachment); messageStore.Insert(rootMessage); transaction.Commit(); } }
public override Draft UpsertDraft(Draft draft) { try { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { DraftDataStore dataStore = new DraftDataStore(transaction); IList <Draft> listDrafts = dataStore.FindItemByChapterId(draft.VersionId); if (listDrafts.Count > 0) { string tempContent = draft.Content; draft = listDrafts.First <Draft>(); draft.Content = tempContent; dataStore.Update(draft); } else { dataStore.Insert(draft); } transaction.Commit(); return(draft); } } catch (NotImplementedException ex) { throw ex; } }
public override void CreateRole(string roleName) { //Check required for MSDN if (roleName == null || roleName == "") { throw new ProviderException("Role name cannot be empty or null."); } if (roleName.IndexOf(',') > 0) { throw new ArgumentException("Role names cannot contain commas."); } if (RoleExists(roleName)) { throw new ProviderException("Role name already exists."); } using (var transaction = new TransactionScope(mConfiguration)) { var roleStore = new RoleDataStore(transaction); roleStore.Insert(new Role(ApplicationName, roleName)); transaction.Commit(); } }
public override void DeletePerson(string personId) { // If person regions exist. if (IsPersonInPersonRegion(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists in a Region"); } // If person persontypes exist. if (IsPersonInPersonType(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists in a PersonType"); } // If person personsite exist. if (IsPersonInPersonSite(personId)) { throw new SchemaIntegrityException("Unable to delete. Person exists at a Site"); } using (var transaction = new TransactionScope(_configuration)) { var ptDS = new PersonDataStore(transaction); Person person = ptDS.FindByKey(personId); User user = MembershipManager.GetUserByPerson(person); System.Web.Security.Membership.DeleteUser(user.Name); person.Deleted = true; ptDS.Update(person); transaction.Commit(); } }
static void TestCreate() { DataContext.Current = new DataContext("Data source=S2;Initial catalog=ibn48portal;Integrated Security=SSPI;"); using (TransactionScope tran = DataContext.Current.BeginTransaction()) { WorkflowDefinitionEntity entity1 = new WorkflowDefinitionEntity(); entity1.Name = "Test 111"; entity1.SupportedIbnObjectTypes = new int[] { 16 }; BusinessManager.Create(entity1); WorkflowDefinitionEntity entity2 = new WorkflowDefinitionEntity(); entity2.Name = "Test 222"; entity2.SupportedIbnObjectTypes = new int[] { 16, 5, 6, 7 }; BusinessManager.Create(entity2); WorkflowDefinitionEntity entity3 = new WorkflowDefinitionEntity(); entity3.Name = "Test 333"; entity3.SupportedIbnObjectTypes = new int[] { 5, 6, 7 }; BusinessManager.Create(entity3); tran.Commit(); } }
public override void CreatePersonSite(string personId, string siteId, bool?isAdministrator, bool?isManager, bool?isAssigned, bool isDefault) { // Create a new record in the PersonSite table. using (var transaction = new TransactionScope(_configuration)) { var psDS = new PersonSiteDataStore(transaction); var ps = new PersonSite(); var pDS = new PersonDataStore(transaction); ps.Person = pDS.FindByKey(personId); var sDS = new SiteDataStore(transaction); ps.Site = sDS.FindByKey(siteId); if (isAdministrator != null) { ps.IsAdministrator = (bool)isAdministrator; } if (isManager != null) { ps.IsManager = (bool)isManager; } if (isAssigned != null) { ps.IsAssigned = (bool)isAssigned; } ps.IsDefault = isDefault; psDS.Insert(ps); transaction.Commit(); } }
public async Task <IActionResult> DeleteConfirmed(int id, Guid fileId) { var transactions = new TransactionScope(); try { if (!fileId.Equals(Guid.Empty)) { transactions.Transactions.Add(_filesContext.Database.BeginTransaction()); await _fileRepository.ExecuteAsync( new DeleteFileCommand(_filesContext) { Id = fileId }); } transactions.Transactions.Add(_context.Database.BeginTransaction()); await _postRepository.ExecuteAsync( new DeletePostCommand(_context) { Id = id }); transactions.Commit(); } catch (Exception exception) { transactions.Rollback(); ExceptionDispatchInfo.Capture(exception.InnerException).Throw(); } return(RedirectToAction("Index")); }
public override void DeleteCategory(Category category) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { CategoryDataStore dataStore = new CategoryDataStore(transaction); // Delete should only be allowed if the following conditions are true: // 1. There are no child categories. if (dataStore.FindByChildOfCategory(category.Id).Count > 0) { throw new SchemaIntegrityException("Category has child categories"); } // 2. There are no articles associated with this category. ArticleDataStore ads = new ArticleDataStore(transaction); if (ads.FindByCategory(category).Count > 0) { throw new SchemaIntegrityException("Articles are associated with this category"); } // Delete all access items. AccessLayer.AccessDataStore accessDs = new AccessLayer.AccessDataStore(transaction); IList <AccessLayer.Access> allAccess = accessDs.FindAllByItem(category.Id); foreach (AccessLayer.Access access in allAccess) { access.Deleted = true; accessDs.Update(access); } category.Deleted = true; dataStore.Update(category); transaction.Commit(); } }
public CommandExecutionResult Execute(CommandBase cmd) { var executionResult = new CommandExecutionResult(); executionResult.PipelineResults = new List <CommandPipelineResult>(); // SECURITY var securityResult = cmd.SecurityPolicy.Validate(cmd); var securityPipelineResult = new CommandSecurityPolicyPipelineResult(securityResult, cmd.SecurityPolicy); executionResult.PipelineResults.Add(securityPipelineResult); if (!executionResult.Success) { return(executionResult); } // VALIDATORS if (!executionResult.Success) { return(executionResult); } // PROJECTIONS using (var tx = new TransactionScope()) { tx.Commit(); } return(executionResult); }
public override Article CreateArticle(Category category, string owner, string name, string fileName, string title, string description, string body, bool isUpload, bool isEnabled, bool isNumbChaps, bool isAckRequired) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore articleStore = new ArticleDataStore(transaction); if (articleStore.FindByName(name) != null) { throw new ArticleNameAlreadyExistsException(name); } CategoryDataStore dataStore = new CategoryDataStore(transaction); dataStore.Attach(category); Article article = new Article(category, name, fileName, owner, title, description, body, isUpload, isEnabled, isNumbChaps); article.Author = owner; //article.Tag = isAckRequired.ToString(); article.RequiresAck = isAckRequired; if (category.AutoApprove) { article.Approved = true; } articleStore.Insert(article); transaction.Commit(); return(article); } }
/// <summary> /// Deletes the folder. /// </summary> /// <param name="folder">The folder.</param> public static void DeleteFolder(CalendarFolder folder) { if (folder == null) { throw new ArgumentNullException("folder"); } using (TransactionScope tran = DataContext.Current.BeginTransaction()) { TreeService treeService = folder.GetTreeService(); //Erase all child folders foreach (TreeNode node in TreeManager.GetAllChildNodes(treeService.CurrentNode)) { CalendarFolder childFolder = (CalendarFolder)node.InnerObject; EraseFolder(childFolder); treeService.RemoveChild(node.ObjectId); childFolder.Delete(); } //Erase current folder EraseFolder(folder); folder.Delete(); tran.Commit(); } }
/// <summary> /// Update the specified article. Increment the version if required. /// </summary> /// <param name="article"></param> /// <param name="backupVersion">If true the previous article version is saved as a backup in the VersionedArticle and the current version is incremented.</param> public override void UpdateArticle(Article article, bool backupVersion) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ArticleDataStore dataStore = new ArticleDataStore(transaction); VersionedArticle versionedArticle = null; if (backupVersion) { //Retrive the previous version (before saving the new instance) and save a versioned row Article prevVersion = dataStore.FindByKey(article.Id); if (prevVersion == null) { throw new ArticleNotFoundException(article.Id); } versionedArticle = new VersionedArticle(prevVersion); VersionedArticleDataStore versionedStore = new VersionedArticleDataStore(transaction); versionedStore.Insert(versionedArticle); //Increment the current article version article.IncrementVersion(); } //flag the entity to be updated and attach the entity to the db // I must use InsertOrUpdateCopy because if backupVersion = true there is already a // persistent entity in the session and I must copy the values to this instance. The Update method in this case throw an exception article = dataStore.InsertOrUpdateCopy(article); transaction.Commit(); } }
protected void SaveButton_ServerClick(object sender, EventArgs e) { int fid = ListFolderId; ListInfo list; using (TransactionScope scope = DataContext.Current.BeginTransaction()) { int templateId = int.Parse(ddTemplates.SelectedValue); if (templateId > 0) { list = ListManager.CreateListFromTemplate(templateId, fid, ListNameTextBox.Text.Trim(), cbWithData.Checked); } else { list = ListManager.CreateList(fid, ListNameTextBox.Text.Trim()); } list.Description = txtDescription.Text; list.Properties["ListType"].Value = int.Parse(ddType.SelectedValue); list.Properties["Status"].Value = int.Parse(ddStatus.SelectedValue); list.Save(); scope.Commit(); } MetaClass mc = ListManager.GetListMetaClass(list); string url = String.Format(CultureInfo.InvariantCulture, "{0}?class={1}", CHelper.ListAdminPage, mc.Name); Response.Redirect(url, true); }
public override ChapterVersion CreateChapterVersion(string docId, ChapterVersion chapterVersion, VersionUpdateType versionUpdateType) { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ChapterVersionDataStore dataStore = new ChapterVersionDataStore(transaction); int maxSequenceNumber = 0; if (versionUpdateType == VersionUpdateType.New) { maxSequenceNumber = GetNewSequenceNo(docId); //only generate sequence number when adding a new chapter else use existing sequence number } else { maxSequenceNumber = chapterVersion.Sequence; } chapterVersion.Version = GenerateVersionNumber(versionUpdateType, chapterVersion.Version); chapterVersion.VersionOrder = GetVersionOrder(docId, chapterVersion.ChapterId); //if (!CheckChapterName(docId, chapterVersion.Name)) // { ChapterVersion chapterVer = new ChapterVersion(docId, chapterVersion.ChapterId, chapterVersion.Name, chapterVersion.Content, chapterVersion.Version, chapterVersion.VersionOrder, maxSequenceNumber); dataStore.Insert(chapterVer); transaction.Commit(); return(chapterVer); //} //else // return chapterVersion; } }
public static void test124() { using (TransactionScope scope = ELDB2.DBFactory.NewTransactionScope(false)) { IRelationAccesser r = scope.NewRelationAccesser(); DataTable tb = r.DoQuery("select * from storages order by Address").Tables[0]; // ======================== System.Console.WriteLine(System.DateTime.Now.Second + ":" + System.DateTime.Now.Millisecond); int j = 0; for (int i = 0; i < 1000; i++) { foreach (DataRow row0 in tb.Rows) { DataRow[] rows = tb.Select(string.Format("Address = '{0}'", row0["Address"])); foreach (DataRow row in rows) { j++; } } } System.Console.WriteLine(j.ToString()); System.Console.WriteLine(System.DateTime.Now.Second + ":" + System.DateTime.Now.Millisecond); // ========================= scope.Commit(); } }
public override void DeleteChapter(string chapterId) { try { using (TransactionScope transaction = new TransactionScope(mConfiguration)) { ChapterDataStore dataStore = new ChapterDataStore(transaction); dataStore.Delete(chapterId); ChapterVersionDataStore dsChapVersion = new ChapterVersionDataStore(transaction); IList <ChapterVersion> chVersionsList = dsChapVersion.FindAllItems(chapterId); foreach (ChapterVersion item in chVersionsList) { item.Deleted = true; dsChapVersion.Update(item); } transaction.Commit(); } } catch { throw new NotImplementedException(); } }