public static void MergeRolledBackTransaction(Session session, long timestamp, object[] list, int start, int limit) { int index = start; while (index < limit) { RowAction action = (RowAction)list[index]; Row memoryRow = action.MemoryRow; if (memoryRow != null) { goto Label_003F; } if (action.type != 0) { memoryRow = (Row)action.Store.Get(action.GetPos(), false); goto Label_003F; } Label_0039: index++; continue; Label_003F: if (memoryRow == null) { goto Label_0039; } lock (memoryRow) { action.MergeRollback(session, timestamp, memoryRow); goto Label_0039; } } }
public void RollbackPartial(Session session, int start, long timestamp) { object[] objArray = session.RowActionList.ToArray(); int count = session.RowActionList.Count; if (start != count) { for (int i = count - 1; i >= start; i--) { RowAction action = (RowAction)objArray[i]; if (((action != null) && (action.type != 0)) && (action.type != 3)) { Row memoryRow = action.MemoryRow; if (memoryRow == null) { memoryRow = (Row)action.Store.Get(action.GetPos(), false); } if (memoryRow != null) { action.Rollback(session, timestamp); int changeAction = action.MergeRollback(session, timestamp, memoryRow); action.Store.RollbackRow(session, memoryRow, changeAction, base.TxModel); } } } session.RowActionList.RemoveRange(start, session.RowActionList.Count - start); } }
public void SetTransactionInfo(ICachedObject obj) { Row row = (Row)obj; RowAction action = base.RowActionMap.Get(row.Position); row.rowAction = action; }
public override Row GetNewCachedObject(Session session, object obj) { int num2 = this._rowIdSequence; this._rowIdSequence = num2 + 1; int position = num2; if (this._isCached) { Row row2 = new RowAVLDisk(base.table, (object[])obj); this.Add(row2); if (this._isTempTable) { RowAction.AddInsertAction(session, base.table, row2); } return(row2); } this._memoryRowCount++; if (this._useCache && (this._memoryRowCount > this._maxMemoryRowCount)) { this.ChangeToDiskTable(); return(this.GetNewCachedObject(session, obj)); } RowAVL row = new RowAVL(base.table, (object[])obj, position); row.SetNewNodes(); if (this._isTempTable) { RowAction action = new RowAction(session, base.table, 1, row, null); row.rowAction = action; } return(row); }
protected override RowChangeEventArgs CreateEventArgs(RowAction rowAction) { return(new RowChangeEventArgs { ChangeType = rowAction, rType = RowType.Species, SelectedSpecies = SpeciesSelection }); }
public bool CanRead(Session session, int id, int mode) { RowAction action = base.RowActionMap.Get(id); if (action != null) { return(action.CanRead(session, mode)); } return(true); }
public void AddInsertAction(Session session, Table table, Row row) { RowAction rowAction = row.rowAction; session.RowActionList.Add(rowAction); if (!row.IsMemory()) { base.RowActionMap.Put(rowAction.GetPos(), rowAction); } }
public bool CanRead(Session session, Row row, int mode, int[] colMap) { RowAction rowAction = row.rowAction; if (rowAction != null) { return(rowAction.CanRead(session, 0)); } return(true); }
protected override RowChangeEventArgs CreateEventArgs(RowAction rowAction) { return(new RowChangeEventArgs { ChangeType = rowAction, AdvLevel = AdvanceSelection, RowNum = RowID, rType = RowType.Career }); }
static void PrepareTables() { const int NDX_LABEL = 0; const int NDX_SPOT_VALUE = 1; IDatumProvider dp = AppContext.AccessPath.GetDataProvider(InternalTablesID.TRANSACTION); List <RowAction>[] actions = { new List <RowAction>(), new List <RowAction>() }; using (var pump = new DataPump(dp)) { pump.Connect(); DataPump.Item item = pump.NextItem; while (item != null) { var trans = item.Row as Transaction; int ndx = trans.TableID == InternalTablesID.TR_LABEL ? NDX_LABEL : trans.TableID == InternalTablesID.TR_SPOT_VALUE ? NDX_SPOT_VALUE : -1; if (ndx != -1) { RowAction ra = actions[ndx].Find(a => a.RowID == trans.RowID); if (ra == null) { actions[ndx].Add(new RowAction(trans.RowID, trans.Action)); } else if (ra.ActionCode == ActionCode_t.AddRow && trans.Action == ActionCode_t.DeleteRow) { actions[ndx].Remove(ra); } else { ra.ActionCode = SelectAction(ra.ActionCode, trans.Action); } dp.Delete(item.Index); } item = pump.NextItem; } } foreach (RowAction ra in actions[NDX_LABEL]) { UpdateTextTable(ra.RowID, ra.ActionCode); } foreach (RowAction ra in actions[NDX_SPOT_VALUE]) { UpdateSpotTable(ra.RowID, ra.ActionCode); } }
public RowAction[] GetRowActionList() { lock (this.Lock) { bool flag; Session[] allSessions = this.database.sessionManager.GetAllSessions(); int[] numArray = new int[allSessions.Length]; int num = 0; int num2 = 0; for (int i = 0; i < allSessions.Length; i++) { num2 += allSessions[i].GetTransactionSize(); } RowAction[] actionArray2 = new RowAction[num2]; Label_0053: flag = false; long actionTimestamp = 0x7fffffffffffffffL; int index = 0; for (int j = 0; j < allSessions.Length; j++) { int transactionSize = allSessions[j].GetTransactionSize(); if (numArray[j] < transactionSize) { RowAction action = allSessions[j].RowActionList[numArray[j]]; if (action.ActionTimestamp < actionTimestamp) { actionTimestamp = action.ActionTimestamp; index = j; } flag = true; } } if (flag) { List <RowAction> rowActionList = allSessions[index].RowActionList; while (numArray[index] < rowActionList.Count) { RowAction action2 = rowActionList[numArray[index]]; if (action2.ActionTimestamp == (actionTimestamp + 1L)) { actionTimestamp += 1L; } if (action2.ActionTimestamp != actionTimestamp) { break; } actionArray2[num++] = action2; numArray[index]++; } goto Label_0053; } return(actionArray2); } }
public override Row GetNewCachedObject(Session session, object obj) { RowAVL wavl = new RowAVLDisk(base.table, (object[])obj); this.Add(wavl); if (session != null) { RowAction action = new RowAction(session, base.table, 1, wavl, null); wavl.rowAction = action; } return(wavl); }
public RowAction AddDeleteAction(Session session, Table table, Row row, int[] colMap) { RowAction action; lock (row) { action = RowAction.AddDeleteAction(session, table, row, colMap); } session.RowActionList.Add(action); session.sessionData.GetRowStore(table).Delete(session, row); row.rowAction = null; return(action); }
public void PersistCommit(Session session, object[] list, int limit) { bool flag = false; for (int i = 0; i < limit; i++) { RowAction action = (RowAction)list[i]; if (action.type != 0) { int commitTypeOn = action.GetCommitTypeOn(session.ActionTimestamp); Row row = action.MemoryRow ?? ((Row)action.Store.Get(action.GetPos(), false)); if (action.table.hasLobColumn) { switch (commitTypeOn) { case 1: session.sessionData.AdjustLobUsageCount(action.table, row.RowData, 1); break; case 2: session.sessionData.AdjustLobUsageCount(action.table, row.RowData, -1); flag = true; break; } } try { action.Store.CommitRow(session, row, commitTypeOn, this.TxModel); } catch (CoreException exception) { this.database.logger.LogWarningEvent(FwNs.Core.LC.cResources.SR.TransactionManagerCommon_PersistCommit_data_commit_failed, exception); } } } try { if (flag && (this.TransactionCount == 0)) { this.database.lobManager.DeleteUnusedLobs(); } session.LogSequences(); if (limit > 0) { this.database.logger.WriteCommitStatement(session); } } catch (CoreException) { } }
public void FinaliseRows(Session session, object[] list, int start, int limit, bool commit) { bool flag = false; for (int i = start; i < limit; i++) { RowAction action = (RowAction)list[i]; if (!action.IsMemory && (action.type == 0)) { this.RowActionMap.WriteLock(); try { lock (action) { if (action.type == 0) { this.RowActionMap.Remove(action.GetPos()); } } } finally { this.RowActionMap.WriteUnLock(); } } if ((action.type == 3) && !action.DeleteComplete) { try { action.DeleteComplete = true; if (action.table.GetTableType() != 3) { Row row = action.MemoryRow ?? ((Row)action.Store.Get(action.GetPos(), false)); if (commit && action.table.hasLobColumn) { flag = true; } action.Store.CommitRow(session, row, action.type, this.TxModel); } } catch (Exception) { } } } if (flag && (this.TransactionCount == 0)) { this.database.lobManager.DeleteUnusedLobs(); } }
public bool CanRead(Session session, Row row, int mode, int[] colMap) { RowAction rowAction = row.rowAction; if (mode == 0) { return((rowAction == null) || rowAction.CanRead(session, 0)); } if (mode == 2) { return((rowAction == null) || rowAction.CanRead(session, 0)); } return((rowAction == null) || rowAction.CanRead(session, mode)); }
public RowAction AddDeleteAction(Session session, Table table, Row row, int[] colMap) { bool flag; RowAction action; lock (row) { flag = row.rowAction == null; action = RowAction.AddDeleteAction(session, table, row, colMap); } session.RowActionList.Add(action); if (flag && !row.IsMemory()) { base.RowActionMap.Put(action.GetPos(), action); } return(action); }
public RowAction AddDeleteAction(Session session, Table table, Row row, int[] colMap) { RowAction item = this.AddDeleteActionToRow(session, table, row, colMap); if (item == null) { lock (base.Lock) { this.RollbackAction(session); if ((session.IsolationLevel == 0x10000) || (session.IsolationLevel == 0x100000)) { session.TempSet.Clear(); session.AbortTransaction = true; throw Error.GetError(0x1307); } if ((row.rowAction != null) && row.rowAction.IsDeleted()) { session.TempSet.Clear(); session.RedoAction = true; this._redoCount++; throw Error.GetError(0x1307); } if (base.CheckDeadlock(session, session.TempSet)) { Session key = session.TempSet.Get(0); session.RedoAction = true; key.WaitingSessions.Add(session); session.WaitedSessions.Add(key); session.Latch.CountUp(); } else { session.RedoAction = false; session.AbortTransaction = true; } session.TempSet.Clear(); this._redoCount++; throw Error.GetError(0x1307); } } session.RowActionList.Add(item); return(item); }
public virtual void ConvertTransactionIDs(DoubleIntIndex lookup) { lock (this.Lock) { RowAction[] actionArray = new RowAction[this.RowActionMap.Size()]; Iterator <RowAction> iterator = this.RowActionMap.GetValues().GetIterator(); for (int i = 0; iterator.HasNext(); i++) { actionArray[i] = iterator.Next(); } this.RowActionMap.Clear(); for (int j = 0; j < actionArray.Length; j++) { int firstEqual = lookup.LookupFirstEqual(actionArray[j].GetPos()); actionArray[j].SetPos(firstEqual); this.RowActionMap.Put(firstEqual, actionArray[j]); } } }
public override Row GetNewCachedObject(Session session, object obj) { int num; lock (this) { int rowIdSequence = this.RowIdSequence; this.RowIdSequence = rowIdSequence + 1; num = rowIdSequence; } RowAVL row = new RowAVL(base.table, (object[])obj, num); row.SetNewNodes(); if (session != null) { RowAction action = new RowAction(session, base.table, 1, row, null); row.rowAction = action; } return(row); }
public void RollbackPartial(Session session, int start, long timestamp) { object[] list = session.RowActionList.ToArray(); int count = session.RowActionList.Count; if (start != count) { for (int i = start; i < count; i++) { RowAction action = (RowAction)list[i]; if (action != null) { action.Rollback(session, timestamp); } } TransactionManagerCommon.MergeRolledBackTransaction(session, timestamp, list, start, count); base.FinaliseRows(session, list, start, count, false); session.RowActionList.RemoveRange(start, session.RowActionList.Count - start); } }
//private: List <TableUpdate> BuildTablesUpdate() { PrepareTables(); Dictionary <uint, List <RowAction> > actions = new Dictionary <uint, List <RowAction> >(); foreach (Transaction trans in AppContext.AccessPath.GetDataProvider(InternalTablesID.TRANSACTION).Enumerate()) { List <RowAction> lst; if (!actions.TryGetValue(trans.TableID, out lst)) { lst = new List <RowAction>(); actions[trans.TableID] = lst; } RowAction ra = lst.Find(item => item.RowID == trans.RowID); if (ra == null) { lst.Add(new RowAction(trans.RowID, trans.Action)); } else if (ra.ActionCode == ActionCode_t.AddRow && trans.Action == ActionCode_t.DeleteRow) { lst.Remove(ra); } else { ra.ActionCode = SelectAction(ra.ActionCode, trans.Action); } } return(BuildTablesUpdate(actions)); }
private RowAction AddDeleteActionToRow(Session session, Table table, Row row, int[] colMap) { RowAction action; lock (row) { if (row.IsMemory()) { action = RowAction.AddDeleteAction(session, table, row, colMap); } else { base.RowActionMap.WriteLock(); try { action = base.RowActionMap.Get(row.GetPos()); if (action == null) { action = RowAction.AddDeleteAction(session, table, row, colMap); if (action != null) { base.RowActionMap.Put(row.GetPos(), action); } return(action); } row.rowAction = action; return(RowAction.AddDeleteAction(session, table, row, colMap)); } finally { base.RowActionMap.WriteUnLock(); } } } return(action); }
public async void CallRowAction(RowAction action) { switch (action.ActionType) { case RowActionType.Favorite: FavoriteCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Retweet: RetweetCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Quote: QuoteCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Reply: ReplyCommand.Execute(action.Parameter as Tweet); break; case RowActionType.TweetDetail: var tweetParameter = action.Parameter as TweetDetailParameter; TweetDetailCommand.Execute(tweetParameter); break; case RowActionType.UserDetail: var userParameter = action.Parameter as UserDetailParameter; UserDetailCommand.Execute(userParameter); break; case RowActionType.Search: var searchParameter = action.Parameter as SearchDetailParameter; SearchCommand.Execute(searchParameter); break; case RowActionType.Browse: BrowseCommand.Execute(action.Parameter.ToString()); break; case RowActionType.Description: DescriptionDommand.Execute(action.Parameter as Tweet); break; case RowActionType.Delete: var tweet = action.Parameter as Tweet; var client=AccountList.Where(q => q.UserInfomation.screen_name == tweet.user.screen_name).Select(q=>q.TwitterClient).Single(); await client.DestroyStatusAsync(tweet); break; case RowActionType.DirectMessage: var dmParameter = action.Parameter as DirectMessageDetailParameter; DirectMessageDetailCommand.Execute(dmParameter); break; case RowActionType.Share: break; case RowActionType.SavePreviewImage: Uri uri = action.Parameter as Uri; FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".bmp"); picker.FileTypeFilter.Add(".gif"); var folder=await picker.PickSingleFolderAsync(); if (folder != null) { HttpClient hClient = new HttpClient(); var bytes = await hClient.GetByteArrayAsync(uri); var file =await folder.CreateFileAsync(DateTime.Now.ToString("yyyMMhhmmss")+".png"); DataWriter writer = new DataWriter(await file.OpenAsync(FileAccessMode.ReadWrite)); writer.WriteBytes(bytes); await writer.StoreAsync(); await writer.FlushAsync(); writer.DetachStream(); await NotificationAsync(new NotificationMessage { Message = "画像を保存しました", TweetMessage = Tweet.ZeroTweet }); } break; } }
protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item) { int i = 0; object objSysRowAction = Item[i++]; object objCode = Item[i++]; //Variation object objListPrice = Item[i++]; object objTaxCategoryId = Item[i++]; object objTrackInventory = Item[i++]; object objMerchantId = Item[i++]; object objWarehouseId = Item[i++]; object objWeight = Item[i++]; object objPackageId = Item[i++]; object objMinQuantity = Item[i++]; object objMaxQuantity = Item[i++]; //Inventory object objInStockQuantity = Item[i++]; object objReservedQuantity = Item[i++]; object objReorderMinQuantity = Item[i++]; object objPreorderQuantity = Item[i++]; object objBackorderQuantity = Item[i++]; object objAllowBackorder = Item[i++]; object objAllowPreorder = Item[i++]; object objInventoryStatus = Item[i++]; object objPreorderAvailabilityDate = Item[i++]; object objBackorderAvailabilityDate = Item[i++]; CatalogEntryDto.VariationRow variationRow = null; CatalogEntryDto.InventoryRow inventoryRow = null; try { RowAction sysRowAction = RowAction.Default; if (objSysRowAction != null) { sysRowAction = GetRowActionEnum((string)objSysRowAction); } string Code; if (objCode != null) { Code = (string)objCode; } else { throw new AbsentValue("Code"); } bool bVariationIsNew = false; bool bInventoryIsNew = false; CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(Code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull)); if (catalogEntryDto.CatalogEntry.Count > 0) { CatalogEntryDto.CatalogEntryRow entry = catalogEntryDto.CatalogEntry[0]; if (entry.ClassTypeId.Equals(EntryType.Variation, StringComparison.OrdinalIgnoreCase) || entry.ClassTypeId.Equals(EntryType.Package, StringComparison.OrdinalIgnoreCase)) { if (catalogEntryDto.Variation.Count > 0) { if (sysRowAction == RowAction.Insert) { throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' already exists.", Code)); } variationRow = catalogEntryDto.Variation[0]; if (sysRowAction == RowAction.Delete) { variationRow.Delete(); } } else { if (sysRowAction == RowAction.Update) { throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code)); } if (sysRowAction == RowAction.Delete) { throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code)); } variationRow = catalogEntryDto.Variation.NewVariationRow(); variationRow.CatalogEntryId = entry.CatalogEntryId; variationRow.ListPrice = 0; variationRow.TaxCategoryId = 0; variationRow.TrackInventory = false; variationRow.WarehouseId = 0; variationRow.Weight = 1; variationRow.PackageId = 0; variationRow.MinQuantity = 1; variationRow.MaxQuantity = 100; bVariationIsNew = true; } if (catalogEntryDto.Inventory.Count > 0) { if (sysRowAction == RowAction.Insert) { throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' already exists.", Code)); } inventoryRow = catalogEntryDto.Inventory[0]; if (sysRowAction == RowAction.Delete) { inventoryRow.Delete(); } } else { if (sysRowAction == RowAction.Update) { throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code)); } if (sysRowAction == RowAction.Delete) { throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code)); } inventoryRow = catalogEntryDto.Inventory.NewInventoryRow(); inventoryRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId; inventoryRow.SkuId = entry.Code; inventoryRow.InStockQuantity = 10; inventoryRow.ReservedQuantity = 2; inventoryRow.ReorderMinQuantity = 1; inventoryRow.PreorderQuantity = 10; inventoryRow.BackorderQuantity = 10; inventoryRow.AllowBackorder = false; inventoryRow.AllowPreorder = false; inventoryRow.InventoryStatus = 0; inventoryRow.PreorderAvailabilityDate = DateTime.UtcNow; inventoryRow.BackorderAvailabilityDate = DateTime.UtcNow; bInventoryIsNew = true; } } else { throw new MDPImportException(String.Format("The Entry with code '{0}' has wrong type ('{1}') for Variation/Inventory import.", Code, entry.ClassTypeId)); } } else { throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", Code)); } if (sysRowAction == RowAction.Delete) { CatalogContext.Current.SaveCatalogEntry(catalogEntryDto); return(0); } //Variation if (objListPrice != null) { decimal ListPrice = (decimal)objListPrice; variationRow.ListPrice = ListPrice; } if (objTaxCategoryId != null) { variationRow.TaxCategoryId = GetTaxCategoryId((string)objTaxCategoryId); } if (objTrackInventory != null) { variationRow.TrackInventory = (bool)objTrackInventory; } if (objMerchantId != null) { Guid merchantId = GetMerchantId((string)objMerchantId); if (merchantId != Guid.Empty) { variationRow.MerchantId = merchantId; } } if (objWarehouseId != null) { variationRow.WarehouseId = GetWarehouseId((string)objWarehouseId); } if (objWeight != null) { variationRow.Weight = (double)objWeight; } if (objPackageId != null) { variationRow.PackageId = GetPackageId((string)objPackageId); } if (objMinQuantity != null) { variationRow.MinQuantity = (decimal)objMinQuantity; } if (objMaxQuantity != null) { variationRow.MaxQuantity = (decimal)objMaxQuantity; } if (bVariationIsNew) { catalogEntryDto.Variation.AddVariationRow(variationRow); } //Inventory if (objInStockQuantity != null) { inventoryRow.InStockQuantity = (decimal)objInStockQuantity; } if (objReservedQuantity != null) { inventoryRow.ReservedQuantity = (decimal)objReservedQuantity; } if (objReorderMinQuantity != null) { inventoryRow.ReorderMinQuantity = (decimal)objReorderMinQuantity; } if (objPreorderQuantity != null) { inventoryRow.PreorderQuantity = (decimal)objPreorderQuantity; } if (objBackorderQuantity != null) { inventoryRow.BackorderQuantity = (decimal)objBackorderQuantity; } if (objAllowBackorder != null) { inventoryRow.AllowBackorder = (bool)objAllowBackorder; } if (objAllowPreorder != null) { inventoryRow.AllowPreorder = (bool)objAllowPreorder; } if (objInventoryStatus != null) { inventoryRow.InventoryStatus = (int)objInventoryStatus; } if (objPreorderAvailabilityDate != null) { inventoryRow.PreorderAvailabilityDate = ((DateTime)objPreorderAvailabilityDate).ToUniversalTime(); } if (objBackorderAvailabilityDate != null) { inventoryRow.BackorderAvailabilityDate = ((DateTime)objBackorderAvailabilityDate).ToUniversalTime(); } if (bInventoryIsNew) { catalogEntryDto.Inventory.AddInventoryRow(inventoryRow); } using (TransactionScope tx = new TransactionScope()) { // Save modifications if (catalogEntryDto.HasChanges()) { CatalogContext.Current.SaveCatalogEntry(catalogEntryDto); } tx.Complete(); } } catch (Exception ex) { throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item); } return(variationRow.CatalogEntryId); }
public RecordChangedEventArgs(RowAction action) { this.Action = action; }
//------------------------------------------------------------------------------------------- public DataAccess(RowAction actions, params String[] roles) { this.Actions = actions; this.AllowedRoles = roles; }
protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item) { int i = 0; object objSysRowAction = Item[i++]; //CatalogNode object objCode = Item[i++]; object objParentCode = Item[i++]; object objName = Item[i++]; object objStartDate = Item[i++]; object objEndDate = Item[i++]; object objTemplateName = Item[i++]; object objIsActive = Item[i++]; object objSortOrder = Item[i++]; //SEO object objSeoTitle = Item[i++]; object objSeoUrl = Item[i++]; object objSeoDescription = Item[i++]; object objSeoKeywords = Item[i++]; CatalogNodeDto.CatalogNodeRow nodeRow = null; try { RowAction sysRowAction = RowAction.Default; if (objSysRowAction != null) { sysRowAction = GetRowActionEnum((string)objSysRowAction); } string Code; if (!String.IsNullOrEmpty((string)objCode)) { Code = (string)objCode; } else { throw new AbsentValue("Code"); } int parentNodeId = 0; if (objParentCode != null) { if (!objParentCode.Equals(String.Empty)) { CatalogNodeDto parentNodeDto = CatalogNodeManager.GetCatalogNodeDto((string)objParentCode, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeInfo)); if (parentNodeDto.CatalogNode.Count > 0) { parentNodeId = parentNodeDto.CatalogNode[0].CatalogNodeId; } } } bool bIsNew = false; CatalogNodeDto catalogNodeDto = CatalogNodeManager.GetCatalogNodeDto(Code, new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeFull)); if (catalogNodeDto.CatalogNode.Count > 0) { if (sysRowAction == RowAction.Insert) { throw new MDPImportException(String.Format("The Catalog Node with Code '{0}' already exists.", Code)); } nodeRow = catalogNodeDto.CatalogNode[0]; if (sysRowAction == RowAction.Delete) { CatalogContext.Current.DeleteCatalogNode(nodeRow.CatalogNodeId, nodeRow.CatalogId); return(0); } if (objParentCode != null && parentNodeId > -1) { nodeRow.ParentNodeId = parentNodeId; } } else { if (sysRowAction == RowAction.Update) { throw new MDPImportException(String.Format("The Catalog Node with code '{0}' does not exists.", Code)); } if (sysRowAction == RowAction.Delete) { throw new MDPImportException(String.Format("The Catalog Node with code '{0}' does not exists.", Code)); } nodeRow = catalogNodeDto.CatalogNode.NewCatalogNodeRow(); nodeRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId; nodeRow.CatalogId = _CatalogId; nodeRow.Code = Code; nodeRow.ParentNodeId = parentNodeId; nodeRow.Name = String.Empty; nodeRow.StartDate = DateTime.UtcNow; nodeRow.EndDate = DateTime.UtcNow.AddYears(3); nodeRow.TemplateName = String.Empty; nodeRow.IsActive = false; nodeRow.SortOrder = 0; bIsNew = true; } if (objName != null) { nodeRow.Name = (string)objName; } if (objStartDate != null) { nodeRow.StartDate = ((DateTime)objStartDate).ToUniversalTime(); } if (objEndDate != null) { nodeRow.EndDate = ((DateTime)objEndDate).ToUniversalTime(); } if (objTemplateName != null) { nodeRow.TemplateName = (string)objTemplateName; } if (objIsActive != null) { nodeRow.IsActive = (bool)objIsActive; } if (objSortOrder != null) { nodeRow.SortOrder = (int)objSortOrder; } int oldMetaClassId = 0; if (!_isSystemClass && _metaClassId > 0) { if (!bIsNew) { oldMetaClassId = nodeRow.MetaClassId; } nodeRow.MetaClassId = _metaClassId; } else if (bIsNew) { throw new MDPImportException("The new category cannot be created without metaclass definition."); } if (bIsNew) { catalogNodeDto.CatalogNode.AddCatalogNodeRow(nodeRow); } //SEO CatalogNodeDto.CatalogItemSeoRow catalogItemSeoRow = null; bool bSeoIsNew = false; if (!String.IsNullOrEmpty(this.Context.Language)) { if (catalogNodeDto.CatalogItemSeo.Count > 0) { DataRow[] drs = catalogNodeDto.CatalogItemSeo.Select(String.Format("LanguageCode LIKE '{0}' AND CatalogNodeId = {1}", this.Context.Language, nodeRow.CatalogNodeId)); if (drs.Length > 0) { catalogItemSeoRow = (CatalogNodeDto.CatalogItemSeoRow)drs[0]; } } if (catalogItemSeoRow == null) { catalogItemSeoRow = catalogNodeDto.CatalogItemSeo.NewCatalogItemSeoRow(); catalogItemSeoRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId; catalogItemSeoRow.LanguageCode = this.Context.Language.ToLower(); catalogItemSeoRow.CatalogNodeId = nodeRow.CatalogNodeId; catalogItemSeoRow.Description = String.Empty; catalogItemSeoRow.Keywords = String.Empty; bSeoIsNew = true; } if (objSeoTitle != null) { catalogItemSeoRow.Title = (string)objSeoTitle; } if (objSeoUrl != null) { catalogItemSeoRow.Uri = (string)objSeoUrl; } else if (bSeoIsNew) { // Auto generate the URL if empty string name = catalogNodeDto.CatalogNode[0].Name; string url = String.Format("{0}.aspx", CommerceHelper.CleanUrlField(name)); int index = 1; while (CatalogContext.Current.GetCatalogEntryByUriDto(url, this.Context.Language).CatalogEntry.Count != 0 || CatalogContext.Current.GetCatalogNodeDto(url, this.Context.Language).CatalogNode.Count != 0) { url = String.Format("{0}-{1}.aspx", CommerceHelper.CleanUrlField(name), index.ToString()); index++; } catalogItemSeoRow.Uri = url; } if (objSeoDescription != null) { catalogItemSeoRow.Description = (string)objSeoDescription; } if (objSeoKeywords != null) { catalogItemSeoRow.Keywords = (string)objSeoKeywords; } if (bSeoIsNew) { catalogNodeDto.CatalogItemSeo.AddCatalogItemSeoRow(catalogItemSeoRow); } } using (TransactionScope tx = new TransactionScope()) { // Save modifications if (catalogNodeDto.HasChanges()) { CatalogContext.Current.SaveCatalogNode(catalogNodeDto); } if (!bIsNew && !_isSystemClass && oldMetaClassId != nodeRow.MetaClassId) { MetaObject.Delete(this.Context, nodeRow.CatalogNodeId, oldMetaClassId); MetaObject obj = MetaObject.NewObject(this.Context, nodeRow.CatalogNodeId, nodeRow.MetaClassId); obj.AcceptChanges(this.Context); } tx.Complete(); } } catch (Exception ex) { throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item); } return(nodeRow.CatalogNodeId); }
//------------------------------------------------------------------------------------------- public void GenerateMenu(RowAction currentPage, Type type) { string[] allowedRoles = GetUserRoles(); MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo method in methods) { foreach (object attrib in method.GetCustomAttributes(typeof(DynamicDataWebMethod), true)) { DynamicDataWebMethod ddMethod = (DynamicDataWebMethod)attrib; if (ddMethod.HasAnyRole(allowedRoles)) { LinkButton webMethod = new LinkButton(); webMethod.ID = "DynamicWebMethod_" + method.Name; webMethod.Text = ((DynamicDataWebMethod)attrib).MethodName; webMethod.CommandName = method.Name; webMethod.Click += new EventHandler(DynamicWebMethod_Click); webMethod.CssClass = "attachmentLink"; webMethod.ToolTip = "Accessible to: " + String.Join(", ", ddMethod.Roles); AvailableActions.Controls.Add(webMethod); if (ddMethod.RequiresPostback) { PostBackTrigger trig1 = new PostBackTrigger(); trig1.ControlID = "DynamicWebMethod_" + method.Name; UpdatePanel1.Triggers.Add(trig1); } break; } //if (attrib.GetType() == typeof(CSSAttribute)) //{ // ShowError(((CSSAttribute)attrib)._CSS); //} } } ICustomTypeDescriptor descriptor = FormView1.DataItem as ICustomTypeDescriptor; if (descriptor != null) { EntityObject owner = (EntityObject)descriptor.GetPropertyOwner(null); if (typeof(INavigationActions).IsAssignableFrom(owner.GetType())) { var NavActions = owner as INavigationActions; List <WeavverMenuItem> items = (List <WeavverMenuItem>)NavActions.GetItemMenu(); if (items != null) { foreach (WeavverMenuItem item in items) { if (item.Link.StartsWith("control://")) { string controlPath = item.Link.Substring(10); if (File.Exists(Server.MapPath(controlPath))) { WeavverUserControl customControl = (WeavverUserControl)LoadControl(controlPath); //quickAdd.DataSaved += new DataSavedHandler(QuickAdd_DataSaved); AvailableActions.Controls.Add(customControl); } } else { LinkButton webMethod = new LinkButton(); webMethod.ID = "DynamicMethod_" + item.Name; webMethod.Text = item.Name; webMethod.CommandName = item.Name; webMethod.CssClass = "attachmentLink"; AvailableActions.Controls.Add(webMethod); } } } } } }
protected void Reroll(RowAction change) { OnRowChanged(CreateEventArgs(change)); }
//------------------------------------------------------------------------------------------- public void GenerateMenu(RowAction currentPage, Type type) { string[] allowedRoles = GetUserRoles(); MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo method in methods) { foreach (object attrib in method.GetCustomAttributes(typeof(DynamicDataWebMethod), true)) { DynamicDataWebMethod ddMethod = (DynamicDataWebMethod)attrib; if (ddMethod.HasAnyRole(allowedRoles)) { LinkButton webMethod = new LinkButton(); webMethod.ID = "DynamicWebMethod_" + method.Name; webMethod.Text = ((DynamicDataWebMethod)attrib).MethodName; webMethod.CommandName = method.Name; webMethod.Click += new EventHandler(DynamicWebMethod_Click); webMethod.CssClass = "attachmentLink"; webMethod.ToolTip = "Accessible to: " + String.Join(", ", ddMethod.Roles); AvailableActions.Controls.Add(webMethod); if (ddMethod.RequiresPostback) { PostBackTrigger trig1 = new PostBackTrigger(); trig1.ControlID = "DynamicWebMethod_" + method.Name; UpdatePanel1.Triggers.Add(trig1); } break; } //if (attrib.GetType() == typeof(CSSAttribute)) //{ // ShowError(((CSSAttribute)attrib)._CSS); //} } } ICustomTypeDescriptor descriptor = FormView1.DataItem as ICustomTypeDescriptor; if (descriptor != null) { EntityObject owner = (EntityObject)descriptor.GetPropertyOwner(null); if (typeof(INavigationActions).IsAssignableFrom(owner.GetType())) { var NavActions = owner as INavigationActions; List<WeavverMenuItem> items = (List<WeavverMenuItem>)NavActions.GetItemMenu(); if (items != null) { foreach (WeavverMenuItem item in items) { if (item.Link.StartsWith("control://")) { string controlPath = item.Link.Substring(10); if (File.Exists(Server.MapPath(controlPath))) { WeavverUserControl customControl = (WeavverUserControl)LoadControl(controlPath); //quickAdd.DataSaved += new DataSavedHandler(QuickAdd_DataSaved); AvailableActions.Controls.Add(customControl); } } else { LinkButton webMethod = new LinkButton(); webMethod.ID = "DynamicMethod_" + item.Name; webMethod.Text = item.Name; webMethod.CommandName = item.Name; webMethod.CssClass = "attachmentLink"; AvailableActions.Controls.Add(webMethod); } } } } } }
protected abstract RowChangeEventArgs CreateEventArgs(RowAction rowAction);
public void ManualUpdate(RowAction action) { OnRowChanged(CreateEventArgs(action)); }