Exemplo n.º 1
0
 protected override void GetItems(int pageNr, int itemsPerPage, IDbConnection connection)
 {
     returnedInfo = new PaginatedLVGetItemsCA(AutoEliminacaoRule.Current.GetItems(GisaDataSetHelper.GetInstance(), pageNr, itemsPerPage, connection));
 }
Exemplo n.º 2
0
 protected override void GetItems(int pageNr, int itemsPerPage, IDbConnection connection)
 {
     ArrayList rowIds = new ArrayList();
     rowIds = UFRule.Current.GetItems(GisaDataSetHelper.GetInstance(), pageNr, itemsPerPage, connection);
     PaginatedLVGetItemsUF items = new PaginatedLVGetItemsUF(rowIds);
     returnedInfo = items;
 }
 protected override void GetItems(int pageNr, int itemsPerPage, IDbConnection connection)
 {
     ArrayList rowIds = new ArrayList();
     rowIds = TrusteeRule.Current.GetODItems(GisaDataSetHelper.GetInstance(), pageNr, itemsPerPage, CurrentTrusteeID, connection);
     var nivelPerms = PermissoesRule.Current.CalculateEffectivePermissions(new List<long>() { CurrentNivelID }, CurrentTrusteeID, connection);
     currentNivelPerms = nivelPerms[CurrentNivelID];
     PaginatedLVGetItemsPN items = new PaginatedLVGetItemsPN(rowIds, CurrentTrusteeID);
     returnedInfo = items;
 }
Exemplo n.º 4
0
 protected override void GetItems(int pageNr, int itemsPerPage, IDbConnection connection)
 {
     returnedInfo = new PaginatedLVGetItemsCA(MovimentoRule.Current.Entidade_GetItems(GisaDataSetHelper.GetInstance(), pageNr, itemsPerPage, EntidadeFilter, connection));
 }
Exemplo n.º 5
0
        protected override void GetItems(int pageNr, int itemsPerPage, IDbConnection connection)
		{
            returnedInfo = new PaginatedLVGetItemsPesq(PesquisaRule.Current.GetItemsUF(GisaDataSetHelper.GetInstance(), pageNr, itemsPerPage, TipoNivel.OUTRO, connection));
		}
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above.
//ORIGINAL LINE: Public Sub LoadListData(Optional ByVal selectedItemTag As Object = null, Optional ByVal selectFirstItem As Boolean = true)
		public void LoadListData(object selectedItemTag, bool selectFirstItem)
		{
			long loadListDataTime = DateTime.Now.Ticks;
			Cursor oldCursor = null;
			try
			{
				oldCursor = Listview.Cursor;
				Listview.Parent.TopLevelControl.Cursor = Cursors.WaitCursor;

				try
				{
					GisaDataSetHelper.ManageDatasetConstraints(false);
					Listview.BeginUpdate();
					PaginatedLVGetItems returnedRows = null;

					bool deadlockOccurred = true;
					while (deadlockOccurred)
					{
						GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
						try
						{
							long calculate = DateTime.Now.Ticks;
							if (CalculateOrderedItems != null)
								CalculateOrderedItems(ho.Connection);
							Debug.WriteLine("<<CalculateOrderedItems>> total " + new TimeSpan(DateTime.Now.Ticks - calculate).ToString());


							// selectedItemTag virá preenchido se se pretender seleccionar 
							// um item específico após a população do lista
							if (selectedItemTag != null)
							{
								int pageNr = 0;
								// no caso deste evento não ser tratado por ninguém 
								// consideramos simplesmente que não é suportada a 
								// selecção de um item específico 
								if (GetPageForItemTag != null)
									GetPageForItemTag(selectedItemTag, ref pageNr, ho.Connection);
								CurrentPageNr = pageNr;
							}

							long count = DateTime.Now.Ticks;
							TotalPaginasCount = countPages(ho.Connection, ItemsCountLimit);
							//RemainingItemsCount = countItems(ho.Connection, LastBottomID) - ItemsCountLimit
							Debug.WriteLine("<<countItems>> total " + new TimeSpan(DateTime.Now.Ticks - count).ToString());

							long obterElementos = 0;
							obterElementos = DateTime.Now.Ticks;
							if (GetItems != null)
								GetItems(CurrentPageNr, ItemsCountLimit, ref returnedRows, ho.Connection);
							Debug.WriteLine("<<obterElementos>> total " + new TimeSpan(DateTime.Now.Ticks - obterElementos).ToString());

							//limpar
							long delete = DateTime.Now.Ticks;
							if (DeleteTemporaryResults != null)
								DeleteTemporaryResults(ho.Connection);
							Debug.WriteLine("<<DeleteTemporaryResults>> total " + new TimeSpan(DateTime.Now.Ticks - delete).ToString());

							deadlockOccurred = false;
						}
						catch (Exception ex)
						{
							Trace.WriteLine(ex);
							if (DBAbstractDataLayer.DataAccessRules.ExceptionHelper.isDeadlockException(ex))
							{
								returnedRows = null;
								deadlockOccurred = true;
							}
							else
								throw;
						}
						finally
						{
							ho.Dispose();
						}
					}
					long adicionarElementosLista = DateTime.Now.Ticks;
					if (AddItemsToList != null)
						AddItemsToList(returnedRows);
					Debug.WriteLine("<<adicionarElementosLista>> total " + new TimeSpan(DateTime.Now.Ticks - adicionarElementosLista).ToString());
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
					throw;
				}
				finally
				{
					Listview.EndUpdate();

					try
					{
						GisaDataSetHelper.ManageDatasetConstraints(true);
					}
                    catch (ConstraintException ex)
                    {
                        IDbConnection conn = GisaDataSetHelper.GetTempConnection();
                        conn.Open();

                        Trace.WriteLine("<EnforceContraints>");
                        Trace.WriteLine(ex.ToString());
                        GisaDataSetHelper.FixDataSet(GisaDataSetHelper.GetInstance(), conn);

                        conn.Close();
#if DEBUG
                        throw;
#endif
                    }
					catch (Exception ex)
					{
						Trace.WriteLine(ex);
						throw;
					}
				}
			}
			finally
			{
				Listview.Parent.TopLevelControl.Cursor = oldCursor;
			}

			refreshNavigationState();

			if (Listview.Items.Count == 1)
			{
				if (selectedItemTag != null)
				{
					// Se, por alguma razão, acontecer o item procurado não 
					// chegar a ser encontrado também não será seleccionado 
					// nenhum item
                    Listview.selectItem(GUIHelper.GUIHelper.findListViewItemByTag(selectedItemTag, Listview));
				}
				else if (selectFirstItem)
				{
					//Listview.Focus()
					Listview.selectItem(Listview.Items[0]);
				}
			}
			else if (Listview.Items.Count > 0)
			{
				Listview.selectItem(null);
			}

			Debug.WriteLine("<<LoadListData>> total " + new TimeSpan(DateTime.Now.Ticks - loadListDataTime).ToString());
		}