Пример #1
0
 public void AddOMQuery(OMQueryGroup omQuerygroup)
 {
     ListQueryGroup.Add(omQuerygroup);
 }
Пример #2
0
		/// <summary>
		/// Prepares the OMQuery Groups
		/// </summary>
		/// <param name="datagridview"></param>
		/// <returns></returns>
		private static OMQueryGroup PrepareQueryCollection(dbDataGridView datagridview)
		{
			//Get all the columns names from resource
			string fieldColumnName = Helper.GetResourceString(Constants.QUERY_GRID_FIELD);
			string conditionColumnName = Helper.GetResourceString(Constants.QUERY_GRID_CONDITION);
			string valueColumnName = Helper.GetResourceString(Constants.QUERY_GRID_VALUE);
			string operatorColumnName = Helper.GetResourceString(Constants.QUERY_GRID_OPERATOR);

		    OMQueryGroup objectManagerQueryGroup = null;

			try
			{
				OMETrace.WriteFunctionStart();

				int rowCount = datagridview.RowCount;
				if (rowCount > 0)
				{
                   
					objectManagerQueryGroup = new OMQueryGroup();
					string stringOperator = datagridview.Rows[0].Cells[operatorColumnName].Value.ToString();
					CommonValues.LogicalOperators clauseOperator = (CommonValues.LogicalOperators)Enum.Parse(typeof(CommonValues.LogicalOperators), stringOperator);
					for (int i = 0; i < rowCount; i++)
					{
                        string fieldName = datagridview.Rows[i].Cells[fieldColumnName].Value.ToString();
						string stringCondition = datagridview.Rows[i].Cells[conditionColumnName].Value.ToString();
						string className = datagridview.Rows[i].Cells[Constants.QUERY_GRID_CALSSNAME_HIDDEN].Value.ToString();
					    string fieldType = FieldTypeFor(datagridview.Rows[i]);
						//get the value for each expression if value not specified then return null
						string stringValue;
						if (datagridview.Rows[i].Cells[valueColumnName].Value != null)
						{
                            
                                stringValue = datagridview.Rows[i].Cells[valueColumnName].Value.ToString();
                           
                           
						}
						else
							return null;

						OMQueryClause queryClause = new OMQueryClause(className, fieldName, stringCondition, stringValue, clauseOperator, fieldType);
						objectManagerQueryGroup.AddOMQueryClause(queryClause);
					}
				}

				OMETrace.WriteFunctionEnd();
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}

			return objectManagerQueryGroup;
		}
Пример #3
0
		/// <summary>
		/// Preapers OMQuery object
		/// </summary>
		/// <returns></returns>
		public OMQuery PrepareOMQuery()
		{
			try
			{
				OMETrace.WriteFunctionStart();

				//Get count of query groups 
				int totalQueryGroups = tableLayoutPanelQueries.Controls.Count;

				//iterate through all query groups
				for (int i = 0; i < totalQueryGroups; i++)
				{
					DataGridViewGroup dataGridViewGrp = (DataGridViewGroup)tableLayoutPanelQueries.Controls[i];

					dbDataGridView datagridView = dataGridViewGrp.DataGridViewQuery;

					//Prepare the query expression for each query group
					OMQueryGroup omQueryGroup = PrepareQueryCollection(datagridView);

					//if query builder has only one group get new instance of OMQueryGroup
					//and set the logical operator to empty
					if (i == 0)
					{
						if (omQueryGroup == null)
						{
							omQueryGroup = new OMQueryGroup();
						}
						omQueryGroup.GroupLogicalOperator = CommonValues.LogicalOperators.EMPTY;
					}
					else //Get the selected operatior for each query group
					{
						//Ignore empty group
						if (omQueryGroup == null)
							continue;

						omQueryGroup.GroupLogicalOperator = (CommonValues.LogicalOperators)
															Enum.Parse(typeof(CommonValues.LogicalOperators),
																	   dataGridViewGrp.QueryGroupOperator);
					}

					if (omQuery.BaseClass != null)
						Helper.BaseClass = omQuery.BaseClass;
					else
					{
						if (Helper.HashTableBaseClass.Count > 0)
						{
							IDictionaryEnumerator enumerator = Helper.HashTableBaseClass.GetEnumerator();
							enumerator.MoveNext();
							string baseClass = enumerator.Key.ToString();

							Helper.BaseClass = baseClass;
						}
					}

					omQuery.AttributeList = GetSelectedAttributes(); //Helper.GetQueryAttributes();

					//Add OMQueryGroup to OMQuery
					if (omQueryGroup != null)
						omQuery.AddOMQuery(omQueryGroup);
				}

				omQuery.QueryString = omQuery.ToString();

				//Set the OMQuery object to the Resulted query
				if (Helper.OMResultedQuery.ContainsKey(omQuery.BaseClass))
				{
					//update omquery if query is prepared not for first time
					Helper.OMResultedQuery[omQuery.BaseClass] = omQuery;
				}
				else
				{
					//Add omquery if query is prepared for first time
					Helper.OMResultedQuery.Add(omQuery.BaseClass, omQuery);
				}

				OMETrace.WriteFunctionEnd();
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}

			return omQuery;
		}
Пример #4
0
        //public Common.Common.LogicalOperators logicalOperator;

        public void AddOMQuery(OMQueryGroup omQuerygroup)
        {
            //ValidateOMQueryToAdd(omQueryClause);
            ListQueryGroup.Add(omQuerygroup);
        }