int IBaseBOL.GetCount(SearchFilterCollection sFilterCols) { int RecordCount = 1; string WhereCond = Tools.GetCondition(sFilterCols).Replace("''", "'"); var ResultQuery = new DBToolsDataContext().spGetCount(TableOrViewName, WhereCond); RecordCount = (int)ResultQuery.ReturnValue; return(RecordCount); }
public DataTable GetDataSource(SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { dataContext = new HardCodeDataContext(); string WhereCond = Tools.GetCondition(sFilterCols); var ListResult = dataContext.ExecuteQuery <HCYesNo>(string.Format("exec spGetPaged '{0}','{1}','{2}','{3}',N'{4}'", TableOrViewName, SortString, PageSize, CurrentPage, WhereCond)); DataTable dt = new Converter <HCYesNo>().ToDataTable(ListResult); return(dt); }
DataTable IBaseBOL.GetDataSource(SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { string WhereCond = Tools.GetCondition(sFilterCols); string TableOrViewName = "vAccessGroups"; //var ListResult = dataContext.ExecuteQuery<AccessGroups>(string.Format("exec spGetList '{0}','{1}'", TableOrViewName, WhereCond)); var ListResult = dataContext.ExecuteQuery <vAccessGroups>(string.Format("exec spGetPaged '{0}','{1}','{2}','{3}',N'{4}'", TableOrViewName, SortString, PageSize, CurrentPage, WhereCond)); DataTable dt = new Converter <vAccessGroups>().ToDataTable(ListResult); return(dt); }
public void Serialize_ItemTypeFilter() { var filters = new SearchFilterCollection { new ItemTypeFilter{ItemType = ItemType.Restaurant} }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains("{\"item_type\":1}", json); }
public void Serialize_NotItemTypeFilter() { var filters = new SearchFilterCollection { new ItemTypeFilter{ItemType = ItemType.USDA, Negated = true} }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains("{\"not\":{\"item_type\":3}}", json); }
public void Serialize_RangeFilter() { var filters = new SearchFilterCollection { new RangeFilter(x => x.NutritionFact_Calories){ From = 100, To = 200} }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains("{\"nf_calories\":{\"from\":100.0,\"to\":200.0}}", json); }
public void Serialize_ComparisionFilter(ComparisonOperator op, string expectedJson) { var filters = new SearchFilterCollection { new ComparisonFilter(x => x.NutritionFact_Calories){Operator = op, Value = 100} }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains(expectedJson, json); }
DataTable IBaseBOL.GetDataSource(SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { dataContext = new UsersDataContext(); string WhereCond = Tools.GetCondition(sFilterCols); var ListResult = from v in dataContext.Resources where !v.MasterCode.HasValue //|| v.TypeCode.Equals(2) || v.TypeCode.Equals(3) || v.TypeCode.Equals(4) select v; DataTable dt = new Converter <Resources>().ToDataTable(ListResult); return(dt); }
public int GetCount(SearchFilterCollection sFilterCols) { int RecordCount = 1; DBToolsDataContext dcTools = new DBToolsDataContext(); string WhereCond = Tools.GetCondition(sFilterCols); WhereCond = WhereCond.Replace("''", "'"); string TableOrViewName = "Resources"; var ResultQuery = dcTools.spGetCount(TableOrViewName, WhereCond); RecordCount = (int)ResultQuery.ReturnValue; return(RecordCount); }
public void Serialize_ItemTypeFilter() { var filters = new SearchFilterCollection { new ItemTypeFilter { ItemType = ItemType.Restaurant } }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains("{\"item_type\":1}", json); }
public void Serialize_NotItemTypeFilter() { var filters = new SearchFilterCollection { new ItemTypeFilter { ItemType = ItemType.USDA, Negated = true } }; string json = JsonConvert.SerializeObject(filters); StringAssert.Contains("{\"not\":{\"item_type\":3}}", json); }
internal string GetNameByCode(int Code) { string Result = ""; SearchFilterCollection sfcol = new SearchFilterCollection(); SearchFilter sf = new SearchFilter("Code", SqlOperators.Equal, Code.ToString()); sfcol.Add(sf); DataTable dt = GetDataSource(sfcol, "Code", 10, 1); if (dt.Rows.Count > 0) { Result = Convert.ToString(dt.Rows[0]["Name"]); } return Result; }
public int GetCodeByName(string Name) { int Result = 0; SearchFilterCollection sfcol = new SearchFilterCollection(); SearchFilter sf = new SearchFilter("Name", SqlOperators.Equal, Name); sfcol.Add(sf); DataTable dt = GetDataSource(sfcol, "Code", 10, 1); if (dt.Rows.Count > 0) { Result = Convert.ToInt32(dt.Rows[0]["Code"]); } return Result; }
DataTable IBaseBOL.GetDataSource(SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { string WhereCond; WhereCond = Tools.GetCondition(sFilterCols); //if (WhereCond == "") // WhereCond = " UserCode = " + MasterCode; //else // WhereCond = " UserCode = " + MasterCode + " and " + WhereCond; var ListResult = dataContext.ExecuteQuery <vUserLogs>(string.Format("exec spGetPaged '{0}','{1}','{2}','{3}',N'{4}'", TableOrViewName, SortString, PageSize, CurrentPage, WhereCond)); DataTable dt = new Converter <vUserLogs>().ToDataTable(ListResult); return(dt); }
int IBaseBOL.GetCount(SearchFilterCollection sFilterCols) { //int RecordCount = 1; //DBToolsDataContext dcTools = new DBToolsDataContext(); //string WhereCond = Tools.GetCondition(sFilterCols); //WhereCond = WhereCond.Replace("''", "'"); //string TableOrViewName = "AccessGroups"; //var ResultQuery = dcTools.spGetCount(TableOrViewName, WhereCond); //RecordCount = (int)ResultQuery.ReturnValue; //return RecordCount; int RecordCount = 1; string WhereCond = Tools.GetCondition(sFilterCols).Replace("''", "'"); var ResultQuery = new DBToolsDataContext().spGetCount(TableOrViewName, WhereCond); RecordCount = (int)ResultQuery.ReturnValue; return(RecordCount); }
public int GetCount(SearchFilterCollection sFilterCols) { string WhereCond; int RecordCount = 1; DBToolsDataContext dcTools = new DBToolsDataContext(); WhereCond = Tools.GetCondition(sFilterCols); //if (WhereCond == "") // WhereCond = " UserCode = " + MasterCode; //else // WhereCond = " UserCode = " + MasterCode + " and " + WhereCond; WhereCond = WhereCond.Replace("''", "'"); var ResultQuery = dcTools.spGetCount(TableOrViewName, WhereCond); RecordCount = (int)ResultQuery.ReturnValue; return(RecordCount); }
public DataTable GetValidAccess(List <AccessListStruct> AccessList, SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { DataTable dt = new DataTable(); UsersDataContext dataContext = new UsersDataContext(); string WhereCond = Tools.GetCondition(sFilterCols); if (HttpContext.Current.Session["UserCode"] != null) { //AccessListStruct s=new AccessListStruct("Edit", ArrayList EditAccess = new ArrayList(); ArrayList ViewAccess = new ArrayList(); for (int i = 0; i < AccessList.Count; i++) { if (AccessList[i].AccessName == "EDIT") { EditAccess.Add(AccessList[i].FieldName); } else if (AccessList[i].AccessName == "VIEW") { ViewAccess.Add(AccessList[i].FieldName); } } //string[] EditAccess = HttpContext.Current.Session["Edit"].ToString().Split(','); //string[] ViewAccess = HttpContext.Current.Session["View"].ToString().Split(','); string[] arrEditAccess = (string[])EditAccess.ToArray(typeof(string)); string[] arrViewAccess = (string[])ViewAccess.ToArray(typeof(string)); System.Collections.Generic.IEnumerable <String> AllAccess = arrEditAccess.Union(arrViewAccess); if (AllAccess.Count <string>() > 0) { var ListResult = from v in dataContext.Resources orderby v.Ordering where (v.HCResourceTypeCode.Equals(1) || v.HCResourceTypeCode.Equals(2)) && (AllAccess.Contains(v.ResName)) select v ; dt = new Converter <Resources>().ToDataTable(ListResult); } } return(dt); }
public int GetCount(SearchFilterCollection sFilterCols) { string WhereCond; int RecordCount = 1; Khabardaan.Code.DAL.DBToolsDataContext dcTools = new Khabardaan.Code.DAL.DBToolsDataContext(); WhereCond = Tools.GetCondition(sFilterCols); if (WhereCond == "") { WhereCond = " EntityCode = " + MasterCode; } else { WhereCond = " EntityCode = " + MasterCode + " and " + WhereCond; } WhereCond = WhereCond.Replace("''", "'"); var ResultQuery = dcTools.spGetCount(TableOrViewName, WhereCond); RecordCount = (int)ResultQuery.ReturnValue; return(RecordCount); }
/// <summary> /// Gets the search filter instance. /// </summary> /// <param name="localName">Name of the local.</param> /// <returns></returns> private static SearchFilter GetSearchFilterInstance(string localName) { SearchFilter searchFilter; switch (localName) { case XmlElementNames.Exists: searchFilter = new Exists(); break; case XmlElementNames.Contains: searchFilter = new ContainsSubstring(); break; case XmlElementNames.Excludes: searchFilter = new ExcludesBitmask(); break; case XmlElementNames.Not: searchFilter = new Not(); break; case XmlElementNames.And: searchFilter = new SearchFilterCollection(LogicalOperator.And); break; case XmlElementNames.Or: searchFilter = new SearchFilterCollection(LogicalOperator.Or); break; case XmlElementNames.IsEqualTo: searchFilter = new IsEqualTo(); break; case XmlElementNames.IsNotEqualTo: searchFilter = new IsNotEqualTo(); break; case XmlElementNames.IsGreaterThan: searchFilter = new IsGreaterThan(); break; case XmlElementNames.IsGreaterThanOrEqualTo: searchFilter = new IsGreaterThanOrEqualTo(); break; case XmlElementNames.IsLessThan: searchFilter = new IsLessThan(); break; case XmlElementNames.IsLessThanOrEqualTo: searchFilter = new IsLessThanOrEqualTo(); break; default: searchFilter = null; break; } return searchFilter; }
protected void Page_Load(object sender, EventArgs e) { try { //System.Threading.Thread.Sleep(5000); string BaseID = Request["BaseID"]; string OldOrder = Request["OldOrder"]; string Order = Request["Order"]; string Repeat = Request["Repeat"]; string RowsPerPage = Request["RowsPerPage"]; string CurPage = Request["CurPage"]; string Keyword = Request["Keyword"]; string Condition = Request["Condition"]; string FilterClm = Request["FilterClm"]; string DelCode = Request["DelCode"]; string ShowMode = Request["ShowMode"]; string SearchOperand = Request["SearchOperand"]; string ViewName = Request["ViewName"]; if (Keyword != null && Keyword != "") { Keyword = Tools.PersianTextCorrection(Keyword); } int MasterCode = string.IsNullOrEmpty(Request["MasterCode"]) ? -1 : Convert.ToInt32(Request["MasterCode"]); IBaseBOL BOLClass; BOLClass = UITools.GetBOLClass(BaseID, MasterCode); #region Security check Tools tools = new Tools(); tools.AccessList = tools.GetAccessList(BaseID); int AccessVal = 0; if (tools.HasAccess("New", BaseID)) { AccessVal += 1; } if (tools.HasAccess("Edit", BaseID)) { AccessVal += 2; } if (tools.HasAccess("Delete", BaseID)) { AccessVal += 4; } if (tools.HasAccess("View", BaseID)) { AccessVal += 8; } if (tools.HasAccess("Print", BaseID)) { AccessVal += 16; } if (!tools.HasAccess("View", BaseID)) { Response.Write("Message:" + " دسترسی " + BOLClass.PageLable + " برای این کاربر وجود ندارد "); return; } #endregion int UserCode = Convert.ToInt32(Session["UserCode"]); BOLUserLogs UserLogsBOL = new BOLUserLogs(UserCode); int HCUserActionCode = 1;//مشاهده string ClientIP = Request.ServerVariables["REMOTE_ADDR"]; //UserLogsBOL.InsertLog(UserCode, HCUserActionCode, DateTime.Now, null, BaseID, ClientIP); if (UITools.IsHardCode(BaseID)) { BOLClass.QueryObjName = BaseID; } int TopStr = 10; if (CurPage != null && RowsPerPage != null) { TopStr = Convert.ToInt32(CurPage) * Convert.ToInt32(RowsPerPage); } if (CurPage == null || CurPage == "") { CurPage = "1"; } if (Repeat == null) { Repeat = "1"; } string OrderCol = Order; if (Order != null) { if (Order == OldOrder && Repeat == "0") { OrderCol = OrderCol + " DESC"; } else { OrderCol = Order; } } else { Order = "Code DESC"; OrderCol = "Code DESC"; } if (RowsPerPage == null) { RowsPerPage = "20"; } #region Generate SearchFilter SqlOperators CurOperator; CellCollection CellCol; SearchFilter sFilter; long? RowCount; DataTable dt; SearchFilterCollection sfCols = new SearchFilterCollection(); if (FilterClm != null && FilterClm != "") { string[] FilterClmArray = FilterClm.Split(';'); string[] ConditionArray = Condition.Split(';'); string[] KeywordArray = Keyword.Split(';'); for (int c = 0; c < ConditionArray.Length; c++) { switch (ConditionArray[c]) { case "0": CurOperator = SqlOperators.Like; break; case "1": CurOperator = SqlOperators.Equal; break; case "2": CurOperator = SqlOperators.GreaterThan; break; case "3": CurOperator = SqlOperators.GreaterThanOrEqual; break; case "4": CurOperator = SqlOperators.LessThan; break; case "5": CurOperator = SqlOperators.Equal; break; case "6": CurOperator = SqlOperators.NotEqual; break; case "7": CurOperator = SqlOperators.DontHave; break; case "9": CurOperator = SqlOperators.StartsWith; break; default: CurOperator = SqlOperators.Like; break; } sFilter = new SearchFilter(FilterClmArray[c], CurOperator, KeywordArray[c]); if (SearchOperand != "" && SearchOperand != null) { if (SearchOperand == "AND") { sFilter.CurOperand = Operands.AND; } else { sFilter.CurOperand = Operands.OR; } } sfCols.Add(sFilter); } } #endregion if (DelCode != null) { try { if (ViewName == "" || ViewName == null) //normal browse { if (BaseID == "UserLogs" || BaseID == "UserTransactions") { Response.Write("Message:" + " رکورد قابل حذف نیست "); return; } BOLClass.DeleteRecord(DelCode); HCUserActionCode = 4;//حذف //UserLogsBOL.InsertLog(UserCode, HCUserActionCode, DateTime.Now, DelCode, BaseID, ClientIP); } else { } Response.Write("DELETED"); } catch (Exception e1) { string DelError = e1.Message; if (e1.Message.StartsWith("The DELETE statement conflicted with the REFERENCE constraint")) { DelError = "رکورد انتخاب شده دارای اطلاعات مرتبط میباشد و قابل حذف نیست"; } Response.Write(DelError); } return; } if (ViewName == "" || ViewName == null) //normal browse { dt = BOLClass.GetDataSource(sfCols, OrderCol, Convert.ToInt32(RowsPerPage), Convert.ToInt32(CurPage)); RowCount = BOLClass.GetCount(sfCols); if (ShowMode != "List") { CellCol = BOLClass.GetCellCollection(); } else { CellCol = BOLClass.GetListCellCollection(); } } else //Custom Views { BrowseSchema BS = new BrowseSchema(); CellCol = BS.CellCollection; dt = BS.DataTBL; RowCount = BS.Count; } dt.ExtendedProperties.Add("RecCount", RowCount.ToString()); dt.ExtendedProperties.Add("CurPage", CurPage); dt.ExtendedProperties.Add("RowsPerPage", RowsPerPage); dt.ExtendedProperties.Add("Order", Order); dt.ExtendedProperties.Add("CurRepeat", Repeat); dt.ExtendedProperties.Add("AccessVal", AccessVal); int ColCount = dt.Columns.Count; string DelColList = ""; for (int i = 0; i < ColCount; i++) { if (!IsInSelectedList(dt.Columns[i], CellCol)) { if (DelColList == "") { DelColList = dt.Columns[i].ColumnName; } else { DelColList = DelColList + "," + dt.Columns[i].ColumnName; } } //dt.Columns.Remove(dt.Columns[i].ColumnName); } if (DelColList != "") { string[] DelColListArray = DelColList.Split(','); for (int d = 0; d < DelColListArray.Length; d++) { dt.Columns.Remove(DelColListArray[d]); } } #region Removing Null Values foreach (DataRow loRow in dt.Rows) { foreach (DataColumn loColumn in dt.Columns) { if (loRow[loColumn.ColumnName] == DBNull.Value) { try { switch (loColumn.DataType.ToString()) { case "System.DateTime": loRow[loColumn.ColumnName] = ""; break; case "System.Int64": case "System.Int32": case "System.Int16": case "System.Single": case "System.Decimal": case "System.Byte": case "System.Double": loRow[loColumn.ColumnName] = 0; break; case "System.Boolean": loRow[loColumn.ColumnName] = true; break; default: loRow[loColumn.ColumnName] = ""; break; } } catch { } } } } #endregion for (int i = 0; i < dt.Columns.Count; i++) { dt.Columns[i].ExtendedProperties.Add("DataType", dt.Columns[i].DataType); } for (int i = 0; i < CellCol.Count; i++) { if (CellCol[i].DataBGCellCol.Name != "0") { dt.Columns[i].ExtendedProperties.Add("BgColor", CellCol[i].DataBGCellCol.Name); } if (CellCol[i].HeaderBGCellCol.Name != "0") { dt.Columns[i].ExtendedProperties.Add("HeaderBgColor", CellCol[i].HeaderBGCellCol.Name); } if (CellCol[i].Direction != Directions.None) { dt.Columns[i].ExtendedProperties.Add("Direction", CellCol[i].Direction.ToString()); } if (CellCol[i].Align != AlignTypes.None) { dt.Columns[i].ExtendedProperties.Add("Alignment", CellCol[i].Align.ToString()); } if (CellCol[i].Width != 0) { dt.Columns[i].ExtendedProperties.Add("Width", CellCol[i].Width.ToString()); } if (CellCol[i].IsListTitle != false) { dt.Columns[i].ExtendedProperties.Add("IsListTitle", "1"); } dt.Columns[i].ExtendedProperties.Add("DisplayMode", CellCol[i].DisplayMode.ToString()); if (CellCol[i].IsKey) { dt.Columns[i].ExtendedProperties.Add("IsKey", "1"); } dt.Columns[i].ExtendedProperties.Add("Caption", CellCol[i].CaptionName); } dt.ExtendedProperties.Add("EditForm", BOLClass.EditForm); dt.ExtendedProperties.Add("ViewForm", BOLClass.ViewForm); dt.ExtendedProperties.Add("LabelName", BOLClass.PageLable); dt.ExtendedProperties.Add("EditWidth", BOLClass.EditWidth); dt.ExtendedProperties.Add("EditHeight", BOLClass.EditHeight); dt.ExtendedProperties.Add("ViewName", ViewName); dt.TableName = BaseID; dt.WriteXml(Response.OutputStream, XmlWriteMode.WriteSchema); //dt.WriteXml(Response.OutputStream); } catch (Exception exp) { Response.Write("Message:" + " بروز خطای غیر منتظره " + exp.Message); return; } }
protected void Page_Load(object sender, EventArgs e) { string RealBaseID; BOLClass = new BOLEntityKeywords(); Label MasterPageTitle = (Label)Master.FindControl("lblTitle"); MasterPageTitle.Text = BOLClass.PageLable; if (Code == null) { if (!NewMode) { return; } } if (!Page.IsPostBack) { string InstanceName = Request["InstanceName"]; ViewState["InstanceName"] = InstanceName; // cboHCEntityTypeCode.DataSource = new BOLHardCode().GetHCDataTable("HCEntities"); RealBaseID = Request["BaseID"]; SavedBaseID = RealBaseID; if (!NewMode) { LoadData((int)Code); } else { int MasterCode = Convert.ToInt32(Request["MasterCode"]); hflEntityCode.Value = MasterCode.ToString(); RealBaseID = RealBaseID.Replace("Keywords", ""); if (!RealBaseID.EndsWith("s")) { if (RealBaseID.EndsWith("y")) { RealBaseID = RealBaseID.Substring(0, RealBaseID.Length - 1) + "ies"; } else if (RealBaseID.EndsWith("es")) { RealBaseID = RealBaseID.Substring(0, RealBaseID.Length - 2) + "es"; } else { RealBaseID = RealBaseID + "s"; } } if (RealBaseID == "Thesis") { RealBaseID = "Thesises"; } BOLHardCode HardCodeBOL = new BOLHardCode(); SearchFilterCollection sfc = new SearchFilterCollection(); sfc.Add(new SearchFilter("Name", SqlOperators.Equal, RealBaseID)); HardCodeBOL.TableOrViewName = "HCEntities"; DataTable dt = HardCodeBOL.GetDataSource(sfc, "Code", 10, 1); if (dt.Rows.Count > 0) { hflHCEntityTypeCode.Value = dt.Rows[0]["Code"].ToString(); } } } }
DataTable IBaseBOL.GetDataSource(SearchFilterCollection sFilterCols, string SortString, int PageSize, int CurrentPage) { return(this.GetDataSource(sFilterCols, SortString, PageSize, CurrentPage)); }