public void ProcessRequest(HttpContext context) { //empcode String mode = context.Request.QueryString["SearchMode"]; IEnumerable retrievedData = (IEnumerable)context.Session[StaticInfo.SearchSessionVarName]; if (retrievedData.IsNull()) { return; } if (mode.IsNullOrEmpty() || mode.Equals("Load")) { String columnString = String.Empty; columnString = GetGridColumn(retrievedData); context.Response.ContentType = "text/plain"; context.Response.Write(columnString); } else { String MultiSelect = HttpContext.Current.Request.QueryString["MultiSelect"]; String[] vids = context.Request.QueryString["SelectedVids"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); CustomList <BaseItem> retrievedDataList = retrievedData.ToCustomList <BaseItem>(); retrievedDataList = retrievedDataList.FindAll(p => vids.Contains(p.VID.ToString())); if (MultiSelect.IsNullOrEmpty() || MultiSelect.ToBoolean().IsFalse()) { context.Session[STATIC.StaticInfo.SearchSessionVarName] = retrievedDataList.Count.IsZero() ? null : retrievedDataList[0]; } else { context.Session[STATIC.StaticInfo.SearchSessionVarName] = retrievedDataList; } } }
private void filterRetrievedData(ref IEnumerable retrievedData, string vid_Ref) { try { String SessionVarName_Ref = HttpContext.Current.Request.QueryString["SessionVarName_Ref"]; String filterCol_Ref = HttpContext.Current.Request.QueryString["filterCol_Ref"]; String filterCol = HttpContext.Current.Request.QueryString["filterCol"]; if ((SessionVarName_Ref.IsNull()) || filterCol_Ref.IsNull() || filterCol.IsNull()) { throw new Exception("Arguments are not specified."); } IEnumerable refData = (IEnumerable)HttpContext.Current.Session[SessionVarName_Ref]; CustomList <BaseItem> refDataList = refData.ToCustomList <BaseItem>(); BaseItem refRow = refDataList.Find(p => p.VID == vid_Ref.ToInt()); if ((refRow.IsNull()) || (refRow.State == ItemState.Detached)) { foreach (Object item in retrievedData) { ((BaseItem)item).Delete(); } } else { Object refColValue = refRow.GetType().GetProperty(filterCol_Ref).GetValue(refRow, null); if (refColValue.IsNotNull()) { CustomList <BaseItem> retrievedDataList = retrievedData.ToCustomList <BaseItem>(); CustomList <BaseItem> retrievedDataListTmp = null; retrievedDataListTmp = retrievedDataList.FindAll(p => p.GetType().GetProperty(filterCol).GetValue(p, null).ToString() == refColValue.ToString()); foreach (BaseItem item in retrievedData) { //retrievedDataListTmp.Find(p => p.VID != item.VID).Delete(); BaseItem obj = retrievedDataListTmp.Find(p => p.VID == item.VID); if (obj.IsNull()) { item.Delete(); } } } } } catch { throw new Exception("Error occured while filtering retrieved data."); } }
private void filterRetrievedDataDataSourceView(IEnumerable retrievedData, String parentColumnName, String parentColumnValue) { try { CustomList <BaseItem> retrievedDataList = retrievedData.ToCustomList <BaseItem>(); retrievedDataList = retrievedDataList.FindAll(p => p.GetType().GetProperty(parentColumnName).GetValue(p, null).ToString() == parentColumnValue); OnDataSourceViewSelectCallback(retrievedDataList); } catch (Exception ex) { throw ex; } }
private void GetFilterList() { try { IEnumerable retrievedData = (IEnumerable)HttpContext.Current.Session[SessionVarName]; CustomList <BaseItem> retrievedDataList = retrievedData.ToCustomList <BaseItem>(); String expression = String.Empty; foreach (String colName in HttpContext.Current.Request.QueryString) { if (colName != "SessionVarName" && colName != "rows" && colName != "page" && colName != "sidx" && colName != "sord" && colName != "_search" && colName != "nd" && colName != "nd_" && colName != "id" && colName != "AggregateColumn" && colName != "FooterRowCaption") { String colValue = HttpContext.Current.Request.QueryString[colName]; if (!String.IsNullOrEmpty(expression)) { expression += " And "; } // expression += MakePredicateString(colName, colValue); } } if (!String.IsNullOrEmpty(expression)) { retrievedDataList = retrievedDataList.FindAll(PredicateBuilder.Build <BaseItem>(expression)); } // PerformRequestData(retrievedDataList); } catch (Exception ex) { throw ex; } }
private void filterRetrievedDataDataSourceView(IEnumerable retrievedData, String parentColumnName, String parentColumnValue) { try { CustomList<BaseItem> retrievedDataList = retrievedData.ToCustomList<BaseItem>(); retrievedDataList = retrievedDataList.FindAll(p => p.GetType().GetProperty(parentColumnName).GetValue(p, null).ToString() == parentColumnValue); OnDataSourceViewSelectCallback(retrievedDataList); } catch (Exception ex) { throw ex; } }
private void filterRetrievedData(ref IEnumerable retrievedData, string vid_Ref) { try { String SessionVarName_Ref = HttpContext.Current.Request.QueryString["SessionVarName_Ref"]; String filterCol_Ref = HttpContext.Current.Request.QueryString["filterCol_Ref"]; String filterCol = HttpContext.Current.Request.QueryString["filterCol"]; if ((SessionVarName_Ref.IsNull()) || filterCol_Ref.IsNull() || filterCol.IsNull()) { throw new Exception("Arguments are not specified."); } IEnumerable refData = (IEnumerable)HttpContext.Current.Session[SessionVarName_Ref]; CustomList<BaseItem> refDataList = refData.ToCustomList<BaseItem>(); BaseItem refRow = refDataList.Find(p => p.VID == vid_Ref.ToInt()); if ((refRow.IsNull()) || (refRow.State == ItemState.Detached)) { foreach (Object item in retrievedData) { ((BaseItem)item).Delete(); } } else { Object refColValue = refRow.GetType().GetProperty(filterCol_Ref).GetValue(refRow, null); if (refColValue.IsNotNull()) { CustomList<BaseItem> retrievedDataList = retrievedData.ToCustomList<BaseItem>(); CustomList<BaseItem> retrievedDataListTmp = null; retrievedDataListTmp = retrievedDataList.FindAll(p => p.GetType().GetProperty(filterCol).GetValue(p, null).ToString() == refColValue.ToString()); foreach (BaseItem item in retrievedData) { //retrievedDataListTmp.Find(p => p.VID != item.VID).Delete(); BaseItem obj = retrievedDataListTmp.Find(p => p.VID == item.VID); if (obj.IsNull()) item.Delete(); } } } } catch { throw new Exception("Error occured while filtering retrieved data."); } }
/// <summary> /// Convert to CustomList /// </summary> /// <param name="source"></param> /// <param name="conversionType"></param> /// <returns></returns> public static CustomList <T> ToCustomList <T>(this IEnumerable source) { return(source.ToCustomList <T>(true)); }
//zaki - Insert record and get Scope_Identity() public object SaveDataCollectionThroughCollection(Boolean requiredTransaction, String conName, Util.CrudType opMode, IEnumerable saveItem) { CommandExecutor command; Boolean blnBeginTrans = false; CustomList<BaseItem> itemNew; try { if (saveItem.IsNull()) { throw new Exception("Collection not Initialized"); } if (requiredTransaction.IsFalse()) { if (conName.Length > 0) { OpenConnection(conName); } else { OpenConnection(String.Empty); } } if (disconnection.IsNotNull()) { if (requiredTransaction.IsFalse()) { transaction = disconnection.BeginTransaction(IsolationLevel.ReadUncommitted); blnBeginTrans = true; } else { if (transaction.IsNull()) { throw new Exception("Transaction is not initialized"); } blnBeginTrans = true; } } else { throw new Exception("Connection is not initialized"); } CustomList<BaseItem> saveItemBase = saveItem.ToCustomList<BaseItem>(); itemNew = saveItemBase.GetChanges(ItemState.Added); object retVal = null; switch (ProviderType) { case Util.ConnectionLibrary.SQlClient: command = new CommandExecutor(transaction, ProviderType); if (itemNew.IsNotNull() && itemNew.Count.NotEquals(0)) { retVal = command.Insert(itemNew, Util.OperationType.Insert); } break; default: break; } if (requiredTransaction.IsFalse()) { if (blnBeginTrans) { transaction.Commit(); blnBeginTrans = false; } disconnection.Close(); disconnection.Dispose(); disconnection = null; } return retVal; } catch (OleDbException exOleDb) { if (blnBeginTrans && requiredTransaction.IsFalse()) { transaction.Rollback(); if (disconnection.IsNotNull()) { if (disconnection.State == ConnectionState.Open) { disconnection.Close(); } disconnection.Dispose(); disconnection = null; } } throw (exOleDb); } catch (DBConcurrencyException exDbce) { if (blnBeginTrans && requiredTransaction.IsFalse()) { transaction.Rollback(); if (disconnection.IsNotNull()) { if (disconnection.State == ConnectionState.Open) { disconnection.Close(); } disconnection.Dispose(); disconnection = null; } } throw (exDbce); } catch (Exception ex) { if (blnBeginTrans && requiredTransaction.IsFalse()) { transaction.Rollback(); if (disconnection.IsNotNull()) { if (disconnection.State == ConnectionState.Open) { disconnection.Close(); } disconnection.Dispose(); disconnection = null; } } throw (ex); } }