public Paging<bas_app> GetAppListWithPaging(QueryEntity qe) { var result = _db.Select("*") .From("bas_app") .Where<_StartWith>("app_id", qe).IgnoreEmpty() //编码使用startwith查询 忽略空值 .Where<_Like>("app_name,app_name_en", qe).IgnoreEmpty() //中文名及英文名都使用like查询 忽略空值 .Where<_Eq>("*", qe).IgnoreEmpty() //剩下的其它的字段都使用equal查询 忽略空值 .Paging(qe, "app_id") //分页参数在qe中 默认按编码排序 .QueryManyWithPaging<bas_app>(); return result; }
//分页查询 public Paging<bas_tenant> GetTenantListWithPaging(QueryEntity qe) { var result = _db.Select("*") .From("bas_tenant") .Where<_StartWith>("tenant_id,tel", qe).IgnoreEmpty() //商户编码、手机号 使用startwith查询 忽略空值 .Where<_Like>("tenant_name,charge_person,addr", qe).IgnoreEmpty() //商户名、责任人、地址 使用like查询 忽略空值 .Where<_Eq>("*", qe).IgnoreEmpty() //剩下的其它的字段都 使用equal查询 忽略空值 .Paging(qe, "tenant_id") //分页参数在qe中 默认按商户编码排序 .QueryManyWithPaging<bas_tenant>(); return result; }
public bool SubmitOrderRequest(string secretStr,QueryEntity qe,ref string msg) { HttpClient client = new HttpClient(Cookies); if (StaticValues.Proxy != "") { client.Proxy = new WebProxy(StaticValues.Proxy); } string url = "https://kyfw.12306.cn/otn/leftTicket/submitOrderRequest"; string data = "secretStr={0}&train_date={1}&back_train_date={2}&tour_flag=dc&purpose_codes=ADULT&query_from_station_name={3}&query_to_station_name={4}&undefined"; object[] objs = new object[] { secretStr, qe.train_date, qe.train_date,qe.from_station_telecode_name, qe.to_station_telecode_name}; data = string.Format(data, objs); url = url + "?" + data; string result = client.Get(url, "kyfw.12306.cn", "https://kyfw.12306.cn", "https://kyfw.12306.cn/otn/leftTicket/init").Replace("\"",""); string status = HtmlHelper.GetContent(result, "status:", ","); msg = HtmlHelper.GetContent(result, "messages:", ",").Replace("[","").Replace("]",""); return status == "true"; }
public void BasicQueryOrderByAscendingValidTest() { const string objectName = "ProductPriceLists"; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity { Name = objectName, ObjectDefinitionFullName = objectName }; //add columns to the root entity rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ProductNumber"); rootEntity.PropertyList.Add("UnitPrice"); //set the sequence direction, note: Ascending is chosen by default rootEntity.SequenceList.Add(new Sequence("UnitPrice")); var query = new Query { IsTestQuery = false, RootEntity = rootEntity }; var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //Verify the correct result of the last element returned from the query Assert.AreEqual("0.0000", queryResults.First().Properties["UnitPrice"].ToString()); Assert.AreEqual("SW101", queryResults.First().Properties["ProductNumber"].ToString()); //Verify the correct result of the first element returned from the query Assert.AreEqual("20000", queryResults.Last().Properties["UnitPrice"].ToString()); Assert.AreEqual("CONSULT", queryResults.Last().Properties["ProductNumber"].ToString()); }
public Result Insert(QuestionEntity entity) { var con = new DapperConnectionManager(); var result = new Result(); using (var scope = new TransactionScope()) { var query = new QueryEntity(); query.Entity = entity; query.Query = @"INSERT INTO Questions (QuizId, Type, AspectId, Text, SubText, EmployerText, EmployerSubText, Requirements, Examples) VALUES(@QuizId, @Type, @AspectId, @Text, @SubText, @EmployerText, @EmployerSubText, @Requirements, @Examples)"; result = con.InsertQueryUnScoped(query); if (!result.Success) { return(result); } var questionId = (int)result.Entity; Result resultAnswers; var queryAnswers = new QueryEntity(); foreach (var q in entity.Answers) { q.QuestionId = questionId; queryAnswers.Entity = q; queryAnswers.Query = @"INSERT INTO Answers (QuestionId, Text, EmployerText, Value, MatchText, Type, TextValue) VALUES(@QuestionId, @Text, @EmployerText, @Value, @MatchText, @Type, @TextValue)"; resultAnswers = con.InsertQueryUnScoped(queryAnswers); if (!resultAnswers.Success) { resultAnswers.Message = "An error occurred"; return(resultAnswers); } } if (!entity.SectorsQuestions.Any()) { scope.Complete(); result.Message = result.Success ? "The Question has been created" : "An error occurred"; return(result); } Result resultSectors; var querySectors = new QueryEntity(); foreach (var q in entity.SectorsQuestions) { q.QuestionId = questionId; queryAnswers.Entity = q; queryAnswers.Query = @"INSERT INTO SectorsQuestions (QuestionId, SectorId, Value) VALUES(@QuestionId, @SectorId, @Value)"; resultSectors = con.ExecuteQueryUnScoped(queryAnswers); if (!resultSectors.Success) { resultSectors.Message = "An error occurred"; return(resultSectors); } } scope.Complete(); result.Message = result.Success ? "The Question has been created" : "An error occurred"; } return(result); }
public void QueryMultipleFilterWithOrderByValidTest() { string objectName = "ProductPriceLists"; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity { Name = objectName, ObjectDefinitionFullName = objectName }; //Create a list of properties for the root entity, not these are column names rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ProductNumber"); rootEntity.PropertyList.Add("UnitPrice"); rootEntity.PropertyList.Add("BaseUoMQuantity"); //set the sequence direction and field to order by rootEntity.SequenceList.Add(new Sequence("UnitPrice", SequenceDirection.Descending)); //create a new comparison expression object // consider **** SELECT [QueryEntity.PropertyList] FROM [QueryEntity.ObjectDefinitionFullName] // **** WHERE [ComparisonExpression.LeftValue] [ComparisonExpression.Operator] [ComparisonExpression.RightValue] var leftComparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Equal, LeftValue = new ComparisonValue(ComparisonValueType.Property, "ProductPriceLists.ProductNumber"), RightValue = new ComparisonValue(ComparisonValueType.Constant, "CONSULT") }; //create another comparison expression to add on the right of the AND clause var rightComparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Less, LeftValue = new ComparisonValue(ComparisonValueType.Property, "ProductPriceLists.BaseUoMQuantity"), RightValue = new ComparisonValue(ComparisonValueType.Constant, 50) }; //create a new query object, and set the root entity var query = new Query { IsTestQuery = false, RootEntity = rootEntity }; //create a new logical expression indicating an AND clause in filtering of the query LogicalExpression logicalExpression = new LogicalExpression( //Sets the opertor for the expression LogicalOperator.And, //add the expressions leftComparisionExpression, rightComparisionExpression, //since this is the parent expressions there is no parent to indicate here so set it to null null); //set the contraints in the query query.Constraints = logicalExpression; //set the expression type for the query constraints query.Constraints.ExpressionType = ExpressionType.Logical; //set the parent expression for the right and left comparison expressions since they are now part of the logical expression leftComparisionExpression.ParentExpression = query.Constraints; rightComparisionExpression.ParentExpression = query.Constraints; var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //Verify the proper first an last values returned by the query Assert.AreEqual("5500", queryResults.First().Properties["UnitPrice"].ToString()); Assert.AreEqual("150", queryResults.Last().Properties["UnitPrice"].ToString()); }
public void SimpleAndFilterValidTest() { string objectName = "Addresses"; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity { Name = objectName, ObjectDefinitionFullName = objectName }; //Create a list of properties for the root entity, not these are column names rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ContactName"); rootEntity.PropertyList.Add("ContactTitle"); rootEntity.PropertyList.Add("AddressType"); //create a new query object, and set the root entity var query = new Query { IsTestQuery = false, RootEntity = rootEntity }; //create a new comparison expression object // consider **** SELECT [QueryEntity.PropertyList] FROM [QueryEntity.ObjectDefinitionFullName] // **** WHERE [ComparisonExpression.LeftValue] [ComparisonExpression.Operator] [ComparisonExpression.RightValue] var leftComparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Equal, LeftValue = new ComparisonValue(ComparisonValueType.Property, "Addresses.AddressType"), RightValue = new ComparisonValue(ComparisonValueType.Constant, "Main") }; //create another comparison expression to add on the right of the AND clause var rightComparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Like, LeftValue = new ComparisonValue(ComparisonValueType.Property, "Addresses.ContactTitle"), RightValue = new ComparisonValue(ComparisonValueType.Constant, "President") }; //create a new logical expression indicating an AND clause in filtering of the query LogicalExpression logicalExpression = new LogicalExpression( //Sets the opertor for the expression LogicalOperator.And, //add the expressions leftComparisionExpression, rightComparisionExpression, //since this is the parent expressions there is no parent to indicate here so set it to null null); //set the contraints in the query query.Constraints = logicalExpression; //set the expression type for the query constraints query.Constraints.ExpressionType = ExpressionType.Logical; //set the parent expression for the right and left comparison expressions since they are now part of the logical expression leftComparisionExpression.ParentExpression = query.Constraints; rightComparisionExpression.ParentExpression = query.Constraints; var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //validate that the proper values are returned in the DataEntity properties Assert.AreEqual("President", queryResults.ElementAt(0).Properties["ContactTitle"].ToString()); Assert.AreEqual("Main", queryResults.ElementAt(0).Properties["AddressType"].ToString()); }
//O-D-|DDD|-D-O private static void Multipleinstance() { string process_guid = "40c4be7f-2c7d-4391-92a3-32e2dc24f58e"; string application_instance_id = Guid.NewGuid().ToString(); //var serviceurl = "http://172.16.22.26:8000/odata/"; var serviceurl = "http://localhost:53433/odata/"; var data = new Container(new Uri(serviceurl)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WfRunner appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr1"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr21", UserName = "******" }); appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr22", UserName = "******" }); var aa = data.StartProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr21"; app.UserName = "******"; var cc = data.GetReadyTasks(app).Execute(); appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr21"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "39c71004-d822-4c15-9ff2-94ca1068d745", UserID = "usr3", UserName = "******" }); string ss = data.RunProcess(appRunner).GetValue(); appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr22"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "39c71004-d822-4c15-9ff2-94ca1068d745", UserID = "usr3", UserName = "******" }); ss = data.RunProcess(appRunner).GetValue(); app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr3"; app.UserName = "******"; var dd = data.GetReadyTasks(app).Execute(); ///XXX //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr3"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "b70e717a-08da-419f-b2eb-7a3d71f054de", UserID = "", UserName = "" }); ss = data.RunProcess(appRunner).GetValue(); }
public void BasicQueryValidTest() { string objectName = "Addresses"; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity(); rootEntity.Name = objectName; rootEntity.ObjectDefinitionFullName = objectName; //Create a list of properties for the root entity, not these are column names rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ContactName"); rootEntity.PropertyList.Add("Phone"); rootEntity.PropertyList.Add("AddressType"); //create a new query object Query query = new Query(); //indicate whether or not this is a test query query.IsTestQuery = true; //set the root entity query.RootEntity = rootEntity; //Create a new instance of the Connector _sysConnector = new SYSConnector(); //Establish a connection to the data source _sysConnector.Connect(_connectionProperties); var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); }
/// <summary> /// Constructs the order by SQL syntax for a root entity. /// </summary> /// <param name="queryEntity"></param> /// <returns></returns> private StringBuilder ParseOrderBy(QueryEntity queryEntity) { var orderbyClause = new StringBuilder(OrderKeyword); foreach (var sequence in queryEntity.SequenceList) { orderbyClause.AppendFormat(" [{0}].[{1}] {2},", queryEntity.ObjectDefinitionFullName, sequence.PropertyName, sequence.Direction == SequenceDirection.Descending ? DescendingKeyword : AscendingKeyword); } // remove traling "," orderbyClause.Remove(orderbyClause.Length - 1, 1); return orderbyClause; }
public Result Insert(AspectEntity entity) { var con = new DapperConnectionManager(); var query = new QueryEntity(); var result = new Result(); using (var scope = new TransactionScope()) { var linkEntity = new LinkEntity { Href = " ", Name = entity.Title, Type = LinksTypes.ASPECT.ToString(), Active = false }; query.Entity = linkEntity; query.Query = @"INSERT INTO Links (Name, Type, Href, Active) VALUES(@Name, @Type, @Href, @Active)"; result = con.InsertQueryUnScoped(query); if (!result.Success) { result.Message = "An error occurred"; return(result); } var linkId = (int)result.Entity; entity.LinkId = linkId; query.Entity = entity; query.Query = @"INSERT INTO Aspects (DomainId, LinkId, Title, Text, Examples, OnlineResources, FurtherEducation, PeopleContact, Levels) VALUES(@DomainId, @LinkId, @Title, @Text,@Examples, @OnlineResources, @FurtherEducation, @PeopleContact, @Levels )"; result = con.InsertQueryUnScoped(query); if (!result.Success) { result.Message = "An error occurred"; return(result); } var aspectId = (int)result.Entity; var listActionsToCreate = entity.ActionsList.Where(x => x.Created); var listActionsToCopy = entity.ActionsList.Where(x => !x.Created).ToList(); foreach (var item in listActionsToCreate) { var queryActionCreate = new QueryEntity { Query = @"INSERT into Actions (Text, Title, Type) VALUES(@Text, @Title, @Type)", Entity = item }; var resultAction = con.InsertQueryUnScoped(queryActionCreate); if (!resultAction.Success) { result.Message = "An error occurred"; return(result); } item.ActionId = (int)resultAction.Entity; listActionsToCopy.Add(item); } foreach (var item in listActionsToCopy) { item.AspectId = aspectId; var queryActionCreate = new QueryEntity { Query = @"INSERT into AspectsActions (AspectId, ActionId, LevelAction, Position) VALUES( @AspectId, @ActionId, @LevelAction, @Position)", Entity = item }; var resultAction = con.ExecuteQueryUnScoped(queryActionCreate); if (!resultAction.Success) { result.Message = "An error occurred"; result.Success = false; return(result); } } //update link with href var queryUpdateLink = new QueryEntity() { Entity = new { Href = string.Concat("/aspects/", aspectId), LinkId = linkId }, Query = "UPDATE Links set Href = @Href where LinkId = @LinkId" }; var resultUpdateLink = con.ExecuteQueryUnScoped(queryUpdateLink); if (!resultUpdateLink.Success) { result.Message = "An error occurred"; result.Success = false; return(result); } scope.Complete(); result.Entity = aspectId; result.Message = "The aspect has been created"; } return(result); }
public static DataTable GetLeftTicket(ref QueryEntity qe) { DataTable dtTicket = CreateTicketDt(); if (qe.optionDates.Contains(qe.train_date)) { qe.optionDates.Remove(qe.train_date); } qe.optionDates.Insert(0, qe.train_date); TicketService service = new TicketService(StaticValues.MyCookies); for (int i = 0; i < qe.optionDates.Count; i++) { string date = qe.optionDates[i]; qe.train_date = date; QueryTicketResponseInfo rspInfo = service.QueryLeftTicketDTO(qe.train_date, qe.from_station_telecode, qe.to_station_telecode); if (rspInfo != null && rspInfo.status) { if (rspInfo.data != null && rspInfo.data.Count > 0) { string[] timeArray = qe.start_time_str.Split("--".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); int beginTime = Convert.ToInt32(timeArray[0].Replace(":", "")); int endTime = Convert.ToInt32(timeArray[1].Replace(":", "")); foreach (QueryLeftNewDTOData q in rspInfo.data) { bool flag = CheckTrainClass(q, qe); if (flag) { int startTime = Convert.ToInt32(q.queryLeftNewDTO.start_time.Replace(":", "")); if (startTime >= beginTime && endTime >= startTime) { if ((qe.trainNoList != null && qe.trainNoList.Count > 0 && qe.trainNoList.Contains(q.queryLeftNewDTO.station_train_code)) || qe.trainNoList == null || qe.trainNoList.Count == 0) { DataRow row = dtTicket.NewRow(); row["TrainCode"] = q.queryLeftNewDTO.station_train_code; row["TrainCodeKey"] = q.queryLeftNewDTO.train_no + "#" + q.queryLeftNewDTO.start_station_telecode + "#" + q.queryLeftNewDTO.to_station_telecode; row["StartStation"] = q.queryLeftNewDTO.from_station_name + "(" + q.queryLeftNewDTO.start_time + ")"; row["AimStation"] = q.queryLeftNewDTO.to_station_name + "(" + q.queryLeftNewDTO.arrive_time + ")"; row["TakeTime"] = q.queryLeftNewDTO.lishi; row["ShangWu"] = q.queryLeftNewDTO.swz_num; row["TeDeng"] = q.queryLeftNewDTO.tz_num; row["YiDeng"] = q.queryLeftNewDTO.zy_num; row["ErDeng"] = q.queryLeftNewDTO.ze_num; row["GaoJiRuanWo"] = q.queryLeftNewDTO.gr_num; row["RuanWo"] = q.queryLeftNewDTO.rw_num; row["YingWo"] = q.queryLeftNewDTO.yw_num; row["RuanZuo"] = q.queryLeftNewDTO.rz_num; row["YingZuo"] = q.queryLeftNewDTO.yz_num; row["WuZuo"] = q.queryLeftNewDTO.wz_num; row["QiTa"] = q.queryLeftNewDTO.qt_num; row["OrderKey"] = q.secretStr; bool last = q.queryLeftNewDTO.to_station_name == q.queryLeftNewDTO.end_station_name; row["Last"] = last; bool first = q.queryLeftNewDTO.from_station_name == q.queryLeftNewDTO.start_station_name; row["First"] = first; row["Order"] = Images.Order; dtTicket.Rows.Add(row); } } } } dtTicket = FilterResultBySeat(dtTicket, qe); } } if (dtTicket.Rows.Count > 0) { break; } } return(dtTicket); }
private static void SubProcess() { string process_guid = "40c4be7f-2c7d-4391-92a3-32e2dc24f585"; string application_instance_id = Guid.NewGuid().ToString(); //var serviceurl = "http://172.16.22.26:8000/odata/"; var serviceurl = "http://localhost:53433/odata/"; var data = new Container(new Uri(serviceurl)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WfRunner appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr1"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr2", UserName = "******" }); // appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr22", UserName = "******" }); var aa = data.StartProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr2"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "5fa796f6-2d5d-4ed6-84e2-a7c4e4e6aabc", UserID = "usr21", UserName = "******" }); // appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr22", UserName = "******" }); string aaa = data.RunProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr21"; app.UserName = "******"; var cc = data.GetReadyTasks(app).Execute(); appRunner = new WfRunner(); appRunner.ProcessGUID = "40c4be7f-2c7d-4391-92a3-32e2dc24f58c"; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr21"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "5fa796f6-2d5d-4ed6-84e2-a7c4e4e6aabc", UserID = "usr3", UserName = "******" }); string ss = data.RunProcess(appRunner).GetValue(); //appRunner = new WfRunner(); //appRunner.ProcessGUID = "40c4be7f-2c7d-4391-92a3-32e2dc24f58c"; //appRunner.AppInstanceID = application_instance_id; //appRunner.AppName = "ApiTest"; //appRunner.UserID = "usr22"; //appRunner.UserName = "******"; //appRunner.NextActivityPerformers.Add(new Point { PathID = "5fa796f6-2d5d-4ed6-84e2-a7c4e4e6aabc", UserID = "usr3", UserName = "******" }); //ss = data.RunProcess(appRunner).GetValue(); app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr3"; app.UserName = "******"; var dd = data.GetReadyTasks(app).Execute(); ///XXX //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr3"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "39c71004-d822-4c15-9ff2-94ca1068d745", UserID = "usr4", UserName = "******" }); ss = data.RunProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr4"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "b70e717a-08da-419f-b2eb-7a3d71f054de", UserID = "", UserName = "" }); ss = data.RunProcess(appRunner).GetValue(); }
/// <summary> /// 根据查询条件得到Userrole记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="UserroleQueryEntity">Userrole查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Userrole记录</returns> public DataSet GetUserroleByQueryList(QueryEntity userroleQuery) { return(userroleDA.GetUserroleByQueryList(userroleQuery)); }
public Result Get() { try { var con = new DapperConnectionManager(); ///Sections var query = new QueryEntity(); query.Query = @"SELECT s.SectionId, s.Name as SectionName, s.Title as SectionTitle, c.Name, c.Title, c.Type, c.ContentItemId, c.Position, c.Text, c.ButtonLink, c.Image, c.Carousel, c.TitleImage, c.Video, c.Link from Sections as s LEFT JOIN ContentItems as c on s.SectionId = c.SectionId where s.Published = 1 and s.Active = 1 ORDER BY s.SectionId, c.Position ASC"; query.Entity = new { }; var result = con.ExecuteQuery(query); var sections = FormatSections((IEnumerable <dynamic>)result.Entity); //DOMAINS query.Query = @"SELECT d.DomainId, d.Name, d.Text, d.Image, d.Icon, d.Title, d.Framework, d.Position, a.ActionId, a.Title as ActionTitle, a.Text as ActionText, a.Type FROM Domains as d LEFT JOIN DomainsActions as da on d.DomainId = da.DomainId LEFT JOIN Actions as a on da.ActionId = a.ActionId WHERE d.Active = 1 ORDER BY d.Position ASC, d.Name, da.Position ASC"; result = con.ExecuteQuery(query); var domains = FormatDomains((IEnumerable <dynamic>)result.Entity); //ASPECTS query.Query = @"SELECT d.DomainId, d.Name as DomainName, d.Framework, ap.AspectId, ap.Text, ap.Title, ap.Examples, ap.FurtherEducation, ap.Levels, ap.OnlineResources, ap.PeopleContact, ap.Position, a.ActionId, a.Title as ActionTitle, a.Text as ActionText, a.Type, aa.LevelAction FROM Aspects as ap LEFT JOIN Domains as d on ap.DomainId = d.DomainId LEFT JOIN AspectsActions as aa on ap.AspectId = aa.AspectId LEFT JOIN Actions as a on aa.ActionId = a.ActionId WHERE ap.Active = 1 ORDER BY ap.Position ASC, ap.Title ASC"; result = con.ExecuteQuery(query); var aspects = FormatAspects((IEnumerable <dynamic>)result.Entity); //SECTORS query.Query = @"SELECT s.SectorId, s.Title, s.Name, sv.Intro, sv.SectorViewId, sv.Video, sv.Type, sv.CareerOpportunities, sv.CareerPathways, sv.ContactText, sv.EducationOpportunities, sv.Type, sv.Framework, sv.MoreStories, sv.WorkEnvironments, sv.Active, sv.OnlineResources FROM Sectors as s LEFT JOIN SectorViews as sv on s.SectorId = sv.SectorId WHERE s.Active = 1 and s.Published = 1 ORDER BY s.Title ASC"; result = con.ExecuteQuery(query); var sectors = FormatSectors((IEnumerable <dynamic>)result.Entity); query.Query = @"SELECT * FROM Roles WHERE Active = 1 ORDER BY Name ASC"; var resultRoles = con.ExecuteQuery <RoleEntity>(query); var roles = (IEnumerable <RoleEntity>)resultRoles.Entity; query.Query = @"SELECT * FROM PostCards"; var resultPostCards = con.ExecuteQuery <PostCardEntity>(query); var postCards = (IEnumerable <PostCardEntity>)resultPostCards.Entity; query.Query = @"SELECT * FROM EndorsedLogos"; var resultEndorsedLogos = con.ExecuteQuery <EndorsedLogoEntity>(query); var endorsedLogos = (IEnumerable <EndorsedLogoEntity>)resultEndorsedLogos.Entity; query.Query = @"SELECT * FROM Definitions"; var resultDefinitions = con.ExecuteQuery <DefinitionEntity>(query); var definitions = (IEnumerable <DefinitionEntity>)resultDefinitions.Entity; query.Query = @"SELECT * FROM Actions"; var resultActions = con.ExecuteQuery <ActionEntity>(query); var actions = (IEnumerable <ActionEntity>)resultActions.Entity; query.Query = @"SELECT * FROM Menus"; var resultMenus = con.ExecuteQuery <MenuEntity>(query); var menus = (IEnumerable <MenuEntity>)resultMenus.Entity; //questions query.Query = @"SELECT DISTINCT q.QuestionId, q.QuizId, q.Type, q.AspectId, q.Text, q.SubText, q.EmployerText, q.EmployerSubText, q.Requirements, q.Position, q.Examples, a.AnswerId, a.Text as AnswerText, a.EmployerText as EmployerAnswerText, a.Value, a.MatchText, qu.Type as QuizType, usd.FieldName, a.Type as AnswerType, a.TextValue FROM Questions as q LEFT JOIN Answers as a on q.QuestionId = a.QuestionId LEFT JOIN Quizzes as qu on q.QuizId = qu.QuizId LEFT JOIN UserDataQuestions as usd on q.QuestionId = usd.QuestionId WHERE q.Active = 1 ORDER BY q.Position ASC"; result = con.ExecuteQuery(query); var questions = FormatQuestions((IEnumerable <dynamic>)result.Entity); //scoring sectors query.Query = @"SELECT sq.QuestionId, sq.SectorId, sq.Value, s.Name FROM SectorsQuestions as sq JOIN Sectors as s on sq.SectorId = s.SectorId "; result = con.ExecuteQuery <SectorsQuestionsEntity>(query); var scoring = FormatSectorQuestions((IEnumerable <SectorsQuestionsEntity>)result.Entity); //scoring sectors query.Query = @"SELECT * from Reasons"; result = con.ExecuteQuery <ReasonEntity>(query); var reasons = result.Entity; result.Entity = new { sections, domains, sectors, aspects, actions, roles, postCards, endorsedLogos, definitions, questions, menus, scoring, reasons }; return(result); } catch (Exception e) { Logger.Log(e); return(new Result(false)); } }
public void TestComplexPropLists() { var a = new TestModel.A(); var innerA = new TestModel.A { Str = "qqq", ManyStrs = new List <string> { "qwer", "cvbn" } }; a.Str = "xxx"; a.ManyStrs = new List <string> { "asdf", "Zxcv" }; a.SingleA = innerA; a.ManyAs = new List <TestModel.A> { innerA, innerA }; var qe = new QueryEntity { ObjectDefinitionFullName = "WasA", PropertyList = new List <string> { "Str", "ManyStrs" }, ChildList = new List <QueryEntity> { new QueryEntity { ObjectDefinitionFullName = "WasA", PropertyList = new List <string > { "Str", "ManyStrs" }, Name = "SingleA" }, new QueryEntity { ObjectDefinitionFullName = "WasA", PropertyList = new List <string > { "Str", "ManyStrs" }, Name = "ManyAs" } } }; var de = DataReflector.ToDataEntity(a, qe); Assert.AreEqual(2, de.Properties.Count); Assert.AreEqual("asdf", ((List <string>)de.Properties["ManyStrs"]).First()); Assert.AreEqual(2, de.Children.Count); Assert.AreEqual("WasA", de.Children["SingleA"].First().ObjectDefinitionFullName); Assert.AreEqual("qqq", de.Children["SingleA"].First().Properties["Str"]); Assert.AreEqual(2, de.Children["ManyAs"].Count); var childrenNested = de.Children["ManyAs"]; Assert.IsTrue( childrenNested.SelectMany(x => x.Properties.Where(kv => kv.Key == "Str")) .All(kv => kv.Value.ToString() == "qqq")); }
/// <summary> /// 根据查询条件得到Syssetting记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="SyssettingQueryEntity">Syssetting查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Syssetting记录</returns> public DataSet GetSyssettingByQueryList(QueryEntity syssettingQuery) { return(syssettingDA.GetSyssettingByQueryList(syssettingQuery)); }
public Result Update(QuestionEntity entity) { var con = new DapperConnectionManager(); var result = new Result(); using (var scope = new TransactionScope()) { var query = new QueryEntity(); query.Entity = entity; query.Query = @"UPDATE Questions set Text = @Text, SubText = @SubText, EmployerText = IFNULL(@EmployerText, @EmployerText), EmployerSubText = IFNULL(@EmployerSubText, @EmployerSubText) , SubText = @SubText , Requirements = @Requirements, Examples = @Examples WHERE QuestionId = @QuestionId"; result = con.ExecuteQueryUnScoped(query); if (!result.Success) { return(result); } var questionId = entity.QuestionId; Result resultAnswers; var queryAnswers = new QueryEntity(); if (entity.Answers.Any()) { queryAnswers.Entity = new { QuestionId = questionId }; queryAnswers.Query = @"DELETE FROM Answers where QuestionId = @QuestionId"; resultAnswers = con.ExecuteQueryUnScoped(queryAnswers); if (!resultAnswers.Success) { resultAnswers.Message = "An error occurred"; return(resultAnswers); } } foreach (var q in entity.Answers) { q.QuestionId = questionId; queryAnswers.Entity = q; queryAnswers.Query = @"INSERT INTO Answers (QuestionId, Text, EmployerText , Value, MatchText, Type, TextValue) VALUES(@QuestionId, @Text, @EmployerText, @Value, @MatchText, @Type, @TextValue)"; resultAnswers = con.InsertQueryUnScoped(queryAnswers); if (!resultAnswers.Success) { resultAnswers.Message = "An error occurred"; return(resultAnswers); } } if (!entity.SectorsQuestions.Any()) { scope.Complete(); result.Entity = entity.QuestionId; result.Message = result.Success ? "The Question has been created" : "An error occurred"; return(result); } var querySectors = new QueryEntity(); querySectors.Entity = new { QuestionId = questionId }; querySectors.Query = @"DELETE FROM SectorsQuestions where QuestionId = @QuestionId"; var resultSectors = con.ExecuteQueryUnScoped(querySectors); if (!resultSectors.Success) { resultSectors.Message = "An error occurred"; return(resultSectors); } foreach (var q in entity.SectorsQuestions) { q.QuestionId = questionId; queryAnswers.Entity = q; queryAnswers.Query = @"INSERT INTO SectorsQuestions (QuestionId, SectorId, Value) VALUES(@QuestionId, @SectorId, @Value)"; resultSectors = con.ExecuteQueryUnScoped(queryAnswers); if (!resultSectors.Success) { resultSectors.Message = "An error occurred"; return(resultSectors); } } scope.Complete(); result.Entity = entity.QuestionId; result.Message = result.Success ? "The Question has been updated" : "An error updated"; } return(result); }
public static DataTable GetLeftTicket(ref QueryEntity qe) { DataTable dtTicket = CreateTicketDt(); if (qe.optionDates.Contains(qe.train_date)) { qe.optionDates.Remove(qe.train_date); } qe.optionDates.Insert(0, qe.train_date); TicketService service = new TicketService(StaticValues.MyCookies); for (int i = 0; i < qe.optionDates.Count; i++) { string date=qe.optionDates[i]; qe.train_date = date; QueryTicketResponseInfo rspInfo = service.QueryLeftTicketDTO(qe.train_date, qe.from_station_telecode, qe.to_station_telecode); if (rspInfo!=null&&rspInfo.status) { if (rspInfo.data != null && rspInfo.data.Count > 0) { string[] timeArray = qe.start_time_str.Split("--".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); int beginTime = Convert.ToInt32(timeArray[0].Replace(":", "")); int endTime = Convert.ToInt32(timeArray[1].Replace(":", "")); foreach (QueryLeftNewDTOData q in rspInfo.data) { bool flag = CheckTrainClass(q, qe); if (flag) { int startTime = Convert.ToInt32(q.queryLeftNewDTO.start_time.Replace(":", "")); if (startTime >= beginTime && endTime >= startTime) { if ((qe.trainNoList!=null&&qe.trainNoList.Count>0&&qe.trainNoList.Contains(q.queryLeftNewDTO.station_train_code))||qe.trainNoList==null||qe.trainNoList.Count==0) { DataRow row = dtTicket.NewRow(); row["TrainCode"] = q.queryLeftNewDTO.station_train_code; row["TrainCodeKey"] = q.queryLeftNewDTO.train_no + "#" + q.queryLeftNewDTO.start_station_telecode + "#" + q.queryLeftNewDTO.to_station_telecode; row["StartStation"] = q.queryLeftNewDTO.from_station_name + "(" + q.queryLeftNewDTO.start_time + ")"; row["AimStation"] = q.queryLeftNewDTO.to_station_name + "(" + q.queryLeftNewDTO.arrive_time + ")"; row["TakeTime"] = q.queryLeftNewDTO.lishi; row["ShangWu"] = q.queryLeftNewDTO.swz_num; row["TeDeng"] = q.queryLeftNewDTO.tz_num; row["YiDeng"] = q.queryLeftNewDTO.zy_num; row["ErDeng"] = q.queryLeftNewDTO.ze_num; row["GaoJiRuanWo"] = q.queryLeftNewDTO.gr_num; row["RuanWo"] = q.queryLeftNewDTO.rw_num; row["YingWo"] = q.queryLeftNewDTO.yw_num; row["RuanZuo"] = q.queryLeftNewDTO.rz_num; row["YingZuo"] = q.queryLeftNewDTO.yz_num; row["WuZuo"] = q.queryLeftNewDTO.wz_num; row["QiTa"] = q.queryLeftNewDTO.qt_num; row["OrderKey"] = q.secretStr; bool last = q.queryLeftNewDTO.to_station_name == q.queryLeftNewDTO.end_station_name; row["Last"] = last; bool first = q.queryLeftNewDTO.from_station_name == q.queryLeftNewDTO.start_station_name; row["First"] = first; row["Order"] = Images.Order; dtTicket.Rows.Add(row); } } } } dtTicket = FilterResultBySeat(dtTicket, qe); } } if (dtTicket.Rows.Count > 0) { break; } } return dtTicket; }
// D // / \ //O-D-A A-D-O // \ / // D private static void AndSplit() { string process_guid = "40c4be7f-2c7d-4391-92a3-32e2dc24f58a"; string application_instance_id = Guid.NewGuid().ToString(); //var serviceurl = "http://172.16.22.26:8000/odata/"; var serviceurl = "http://localhost:53433/odata/"; var data = new Container(new Uri(serviceurl)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WfRunner appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr1"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "e60084e4-517a-4892-a290-517159f1b7f4", UserID = "usr21", UserName = "******" }); appRunner.NextActivityPerformers.Add(new Point { PathID = "ce3343b6-930d-4962-a2b9-2c4c4b2dab06", UserID = "usr22", UserName = "******" }); var aa = data.StartProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr21"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "0fdff3c0-be97-43d6-b4ff-90d52efb5d6f", UserID = "usr3", UserName = "******" }); //appRunner.TaskID = ; string ss = data.RunProcess(appRunner).GetValue(); QueryEntity app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr3"; app.UserName = "******"; var cc = data.GetReadyTasks(app).Execute(); appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr22"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "0fdff3c0-be97-43d6-b4ff-90d52efb5d6f", UserID = "usr3", UserName = "******" }); ss = data.RunProcess(appRunner).GetValue(); app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr3"; app.UserName = "******"; cc = data.GetReadyTasks(app).Execute(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr3"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "76f7ef75-b538-40c8-b529-0849ca777b94", UserID = "", UserName = "" }); ss = data.RunProcess(appRunner).GetValue(); }
/// <summary> /// Parse the properties that are required for the join /// </summary> /// <param name="queryEntity"></param> /// <param name="useAlias"></param> /// <returns></returns> private string ParseJoinProperties(QueryEntity queryEntity, bool useAlias) { var joinQueryProperties = new StringBuilder(); //convert the csv of parent and child properties to lists var parentProperties = queryEntity.RelationshipToParent.ParentProperties.Split(',').ToList(); var childProperties = queryEntity.RelationshipToParent.ChildProperties.Split(',').ToList(); // do we need an alias for a self join or the same table joined more than once? var childObjectName = useAlias ? queryEntity.Name : queryEntity.ObjectDefinitionFullName; //add each of the properties to the join for (var i = 0; i < parentProperties.Count; i++) { if (i > 0) { joinQueryProperties.Append("AND"); } joinQueryProperties.Append(" ["); joinQueryProperties.Append(childObjectName); joinQueryProperties.Append("].["); joinQueryProperties.Append(childProperties[i]); joinQueryProperties.Append("] = ["); joinQueryProperties.Append(queryEntity.ParentQueryEntity.ObjectDefinitionFullName); joinQueryProperties.Append("].["); joinQueryProperties.Append(parentProperties[i]); joinQueryProperties.Append("] "); } return joinQueryProperties.ToString(); }
/// <summary> /// 根据查询条件得到Itembrand记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="ItembrandQueryEntity">Itembrand查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Itembrand记录</returns> public DataSet GetItembrandByQueryList(QueryEntity itembrandQuery) { return(itembrandDA.GetItembrandByQueryList(itembrandQuery)); }
public Result Update(AspectEntity entity) { var con = new DapperConnectionManager(); var query = new QueryEntity(); var result = new Result(); using (var scope = new TransactionScope()) { query.Entity = entity; query.Query = @"Update Aspects set Title=@Title, Text=@Text, Examples=@Examples, OnlineResources=@OnlineResources, FurtherEducation =@FurtherEducation, PeopleContact = @PeopleContact, Levels = @Levels, Position = @Position where AspectId = @AspectId"; result = con.ExecuteQueryUnScoped(query); if (!result.Success) { result.Message = "An error occurred"; return(result); } var aspectId = entity.AspectId; var listActionsToRemove = entity.ActionsList.Where(x => x.Removed); var listActionsToCreate = entity.ActionsList.Where(x => x.Created); var listActionsToCopy = entity.ActionsList.Where(x => x.Added).ToList(); foreach (var item in listActionsToRemove) { var queryActionCreate = new QueryEntity { Query = @"DELETE from AspectsActions where ActionId = @ActionId", Entity = item }; var resultAction = con.ExecuteQuery(queryActionCreate); if (resultAction.Success) { continue; } result.Message = "An error occurred"; return(result); } foreach (var item in listActionsToCreate) { var queryActionCreate = new QueryEntity { Query = @"INSERT into Actions (Text, Title, Type) VALUES(@Text, @Title, @Type)", Entity = item }; var resultAction = con.InsertQueryUnScoped(queryActionCreate); item.ActionId = (int)resultAction.Entity; listActionsToCopy.Add(item); } foreach (var item in listActionsToCopy) { item.AspectId = aspectId; var queryActionCreate = new QueryEntity { Query = @"INSERT into AspectsActions (AspectId, ActionId, LevelAction, Position) VALUES( @AspectId, @ActionId, @LevelAction, @Position)", Entity = item }; var resultAction = con.ExecuteQueryUnScoped(queryActionCreate); if (resultAction.Success) { continue; } result.Message = "An error occurred"; return(result); } scope.Complete(); result.Entity = aspectId; result.Message = "The aspect has been created"; } return(result); }
/// <summary> /// Write query entity of the config. /// </summary> private static void WriteQueryEntity(BinaryWriter writer, QueryEntity entity, ClientProtocolVersion srvVer) { writer.WriteString(entity.KeyTypeName); writer.WriteString(entity.ValueTypeName); writer.WriteString(entity.TableName); writer.WriteString(entity.KeyFieldName); writer.WriteString(entity.ValueFieldName); var entityFields = entity.Fields; if (entityFields != null) { writer.WriteInt(entityFields.Count); foreach (var field in entityFields) { WriteQueryField(writer, field, srvVer); } } else { writer.WriteInt(0); } var entityAliases = entity.Aliases; if (entityAliases != null) { writer.WriteInt(entityAliases.Count); foreach (var queryAlias in entityAliases) { writer.WriteString(queryAlias.FullName); writer.WriteString(queryAlias.Alias); } } else { writer.WriteInt(0); } var entityIndexes = entity.Indexes; if (entityIndexes != null) { writer.WriteInt(entityIndexes.Count); foreach (var index in entityIndexes) { if (index == null) { throw new InvalidOperationException("Invalid cache configuration: QueryIndex can't be null."); } index.Write(writer); } } else { writer.WriteInt(0); } }
private static void TestMethod() { string process_guid = "40c4be7f-2c7d-4391-92a3-32e2dc24f58f"; string application_instance_id = "56"; // var serviceurl = "http://172.16.22.26:8000/odata/"; var serviceurl = "http://localhost:53433/odata/"; var data = new Container(new Uri(serviceurl)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Window w = new Window(); w.Id = 1; w.Name = "2"; w.CurrentShape = new Circle() { Radius = 1, HasBorder = true }; w.OptionalShapes.Add(new Circle() { Radius = 1, HasBorder = true }); var ls = data.ListAc(w).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var eventDataItems = data.Vedios.ToList(); data.AddObject("Vedios", new Vedio() { ID = 8, Title = "Inferno of Retribution", Year = 2005 }); data.SaveChanges(); var eventDataItemsw = data.Vedios.Where(p => p.Title == "2").ToList(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WfRunner appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr1"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "fc8c71c5-8786-450e-af27-9f6a9de8560f", UserID = "usr20", UserName = "******" }); var aa = data.StartProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QueryEntity app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr2"; app.UserName = "******"; var bb = data.GetRunningTasks(app).Execute(); var cc = data.GetReadyTasks(app).Execute(); }
public DataSet GetUserByQueryList(QueryEntity userQuery) { throw new NotImplementedException(); }
public Result InsertTest(int domainId, int copyId) { var con = new DapperConnectionManager(); var query = new QueryEntity(); var result = new Result(); query.Entity = new { DomainId = domainId }; query.Query = @"SELECT * FROM Aspects where DomainId = @DomainId"; var domainActions = con.ExecuteQuery <AspectEntity>(query); var aspectsList = (IEnumerable <AspectEntity>)domainActions.Entity; foreach (var entity in aspectsList) { using (var scope = new TransactionScope()) { entity.DomainId = copyId; var linkEntity = new LinkEntity { Href = " ", Name = entity.Title, Type = LinksTypes.ASPECT.ToString(), Active = true }; query.Entity = linkEntity; query.Query = @"INSERT INTO Links (Name, Type, Href, Active) VALUES(@Name, @Type, @Href, @Active)"; result = con.InsertQueryUnScoped(query); if (!result.Success) { result.Message = "An error occurred"; return(result); } var linkId = (int)result.Entity; entity.LinkId = linkId; query.Entity = entity; query.Query = @"INSERT INTO Aspects (DomainId, LinkId, Title, Text, Examples, OnlineResources, FurtherEducation, PeopleContact, Levels) VALUES(@DomainId, @LinkId, @Title, @Text,@Examples, @OnlineResources, @FurtherEducation, @PeopleContact, @Levels )"; result = con.InsertQueryUnScoped(query); if (!result.Success) { result.Message = "An error occurred"; return(result); } var aspectId = (int)result.Entity; var queryUpdateLink = new QueryEntity() { Entity = new { Href = string.Concat("/aspects/", aspectId), LinkId = linkId }, Query = "UPDATE Links set Href = @Href where LinkId = @LinkId" }; var resultUpdateLink = con.ExecuteQueryUnScoped(queryUpdateLink); if (!resultUpdateLink.Success) { result.Message = "An error occurred"; result.Success = false; return(result); } scope.Complete(); result.Entity = aspectId; result.Message = "The aspect has been created"; } } return(result); }
public void SimpleChildParentValidTest() { string objectName = "Addresses"; //add the root entity var rootEntity = new QueryEntity(); rootEntity.Name = objectName; rootEntity.ObjectDefinitionFullName = objectName; //add columns to the root entity rootEntity.PropertyList.Add("CustomerNumber"); rootEntity.PropertyList.Add("City"); rootEntity.PropertyList.Add("State"); rootEntity.PropertyList.Add("CreatedOn"); //add the parent entity var parentEntity = new QueryEntity(); parentEntity.Name = "Customers"; parentEntity.ObjectDefinitionFullName = "Customers"; //add columns to the parent entity parentEntity.PropertyList.Add("CustomerNumber"); parentEntity.PropertyList.Add("ContactName"); parentEntity.PropertyList.Add("Phone"); parentEntity.PropertyList.Add("CreatedOn"); //add the realtionship to the query parentEntity.RelationshipToParent = new Relationship { ParentProperties = "CustomerNumber", ChildProperties = "CustomerNumber" }; rootEntity.ChildList.Add(parentEntity); parentEntity.ParentQueryEntity = rootEntity; rootEntity.ParentQueryEntity = null; var query = new Query { IsTestQuery = false, RootEntity = rootEntity }; //retrieve the number of columns prior to running the query //after the query is run verify that no columns have been added int rootPropertyCount = query.RootEntity.PropertyList.Count; int childPropertyCount = query.RootEntity.ChildList.ElementAt(0).PropertyList.Count; var queryResults = _sysConnector.ExecuteQuery(query); foreach (var queryResult in queryResults) { break; } //verify that data has been returned from the query Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //verify that the first element has related values Assert.AreNotEqual(0, queryResults.ElementAt(0).Children.Count); //verify that no columns have been added //***Note this is a requirement of the system // If a value is added during the query to ensure uniqueness of the results, // they cannot be returned in the query results Assert.AreEqual(rootPropertyCount, queryResults.ElementAt(0).Properties.Count); Assert.AreEqual(childPropertyCount, queryResults.ElementAt(0).Children.ElementAt(0).Value.ElementAt(0).Properties.Count); }
public void ExecuteQueryValidTest() { //Declare the name of the table for the test string tableName = "Addresses"; //Retrieve the current metadata provoder var metaDataProvider = _sysConnector.GetMetadataProvider(); //Create a new root Query Enitity QueryEntity rootEntity = new QueryEntity(); //Add the table name to the query entity rootEntity.Name = tableName; rootEntity.ObjectDefinitionFullName = tableName; //Retrieve the column information for the selected table IObjectDefinition objectDefinition = metaDataProvider.RetrieveObjectDefinition(tableName, true, true); //Add each column to the list of properties foreach (IPropertyDefinition propertyDefinition in objectDefinition.PropertyDefinitions) { rootEntity.PropertyList.Add(propertyDefinition.Name); } //create a new query object Query queryObject = new Query(); //indicate whether or not this is a test query queryObject.IsTestQuery = true; //set the root entity queryObject.RootEntity = rootEntity; //execute the query using the method provided from the connector var queryEntity = _sysConnector.ExecuteQuery(queryObject); //validate that results have been returned Assert.IsNotNull(queryEntity); Assert.AreNotEqual(0, queryEntity.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryEntity.ElementAt(0).Properties.Count); }
public void SimpleLikeFilterValidTest() { string objectName = "Addresses"; //create a new comparison expression object // consider **** SELECT [QueryEntity.PropertyList] FROM [QueryEntity.ObjectDefinitionFullName] // **** WHERE [ComparisonExpression.LeftValue] [ComparisonExpression.Operator] [ComparisonExpression.RightValue] var comparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Like, LeftValue = new ComparisonValue(ComparisonValueType.Property, "Addresses.ContactName"), RightValue = new ComparisonValue(ComparisonValueType.Constant, "Mr.%") }; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity { Name = objectName, ObjectDefinitionFullName = objectName }; //Create a list of properties for the root entity, not these are column names rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ContactName"); rootEntity.PropertyList.Add("Phone"); rootEntity.PropertyList.Add("LocationName"); //create a new query object Query query = new Query(); //indicate whether or not this is a test query query.IsTestQuery = true; //set the root entity query.RootEntity = rootEntity; //set the constraints for the query query.Constraints = comparisionExpression; var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //validate that the proper values are returned in the DataEntity properties Assert.IsTrue(queryResults.ElementAt(0).Properties["ContactName"].ToString().Contains("Mr.")); }
public void SelfJoinValidTest() { string objectName = "SalesOrders"; //add the root entity var rootEntity = new QueryEntity(); rootEntity.Name = objectName; rootEntity.ObjectDefinitionFullName = objectName; //add columnc to the root entity rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("CustomerNumber"); rootEntity.PropertyList.Add("OriginalOrderNumber"); rootEntity.PropertyList.Add("Type"); rootEntity.PropertyList.Add("Status"); //add the entity for the self join var selfJoinEntity = new QueryEntity(); selfJoinEntity.Name = "SalesOrders2"; selfJoinEntity.ObjectDefinitionFullName = "SalesOrders"; //add the columns for the self join selfJoinEntity.PropertyList.Add("RecordId"); selfJoinEntity.PropertyList.Add("Type"); selfJoinEntity.PropertyList.Add("Status"); selfJoinEntity.PropertyList.Add("OrderNumber"); //add the relationship for the self join selfJoinEntity.RelationshipToParent = new Relationship { ParentProperties = "OriginalOrderNumber", ChildProperties = "OrderNumber" }; rootEntity.ChildList.Add(selfJoinEntity); selfJoinEntity.ParentQueryEntity = rootEntity; rootEntity.ParentQueryEntity = null; var query = new Query(); query.IsTestQuery = false; query.RootEntity = rootEntity; //retrieve the number of columns prior to running the query //after the query is run verify that no columns have been added var rootEntityPropertyCount = rootEntity.PropertyList.Count; var childEntityPropertyCount = selfJoinEntity.PropertyList.Count; var queryResults = _sysConnector.ExecuteQuery(query); foreach (var queryResult in queryResults) { break; } Assert.IsNotNull(queryResults); //there are no data in this object Assert.AreNotEqual(0, queryResults.Count()); //make sure that duplicates have not been received Assert.AreEqual(1, queryResults.ElementAt(0).Children.ElementAt(0).Value.Count); //check that no extra properties have been added Assert.AreEqual(rootEntityPropertyCount, queryResults.ElementAt(0).Properties.Count); Assert.AreEqual(childEntityPropertyCount, queryResults.ElementAt(0).Children.ElementAt(0).Value.ElementAt(0).Properties.Count); }
private static DataTable FilterResultBySeat(DataTable dt, QueryEntity qe) { DataTable dtTemp = dt.Clone(); //过滤座位 for (int i = 0; i < dt.Rows.Count; i++) { if (!FilterRowBySeat(dt.Rows[i], qe.seatTypeList)) { DataRow row = dtTemp.NewRow(); for (int j = 0; j < dtTemp.Columns.Count; j++) row[j] = dt.Rows[i][j]; dtTemp.Rows.Add(row); } } dtTemp.AcceptChanges(); return dtTemp; }
public DataSet GetUserByQueryList(Database db, DbTransaction tran, QueryEntity userQuery) { throw new NotImplementedException(); }
/// <summary> /// 根据查询条件得到Rolefunction记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="RolefunctionQueryEntity">Rolefunction查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Rolefunction记录</returns> public DataSet GetRolefunctionByQueryList(QueryEntity rolefunctionQuery) { return(rolefunctionDA.GetRolefunctionByQueryList(rolefunctionQuery)); }
public void SimpleFilterWithOrderByValidTest() { string objectName = "ProductPriceLists"; //Create a basic root query entity, //Set the name property and the object definition full name property //Note: 'Name' property is unique and is set by the user // 'ObjectDefinitionFullName' property will be the name of the table referenced var rootEntity = new QueryEntity { Name = objectName, ObjectDefinitionFullName = objectName }; //Create a list of properties for the root entity, not these are column names rootEntity.PropertyList.Add("RecordId"); rootEntity.PropertyList.Add("ProductNumber"); rootEntity.PropertyList.Add("UnitPrice"); rootEntity.PropertyList.Add("BaseUoMQuantity"); //set the sequence direction and field to order by rootEntity.SequenceList.Add(new Sequence("UnitPrice", SequenceDirection.Descending)); //create a new query object, and set the root entity var query = new Query { IsTestQuery = false, RootEntity = rootEntity }; //create a new comparison expression object // consider **** SELECT [QueryEntity.PropertyList] FROM [QueryEntity.ObjectDefinitionFullName] // **** WHERE [ComparisonExpression.LeftValue] [ComparisonExpression.Operator] [ComparisonExpression.RightValue] var comparisionExpression = new ComparisonExpression { ExpressionType = ExpressionType.Comparison, Operator = ComparisonOperator.Equal, LeftValue = new ComparisonValue(ComparisonValueType.Property, "ProductPriceLists.ProductNumber"), RightValue = new ComparisonValue(ComparisonValueType.Constant, "CAT5CBL") }; //set the contraints in the query to the comparison expression query.Constraints = comparisionExpression; var queryResults = _sysConnector.ExecuteQuery(query); //force a check of the query results foreach (var queryResult in queryResults) { break; } //validate that results have been returned Assert.IsNotNull(queryResults); Assert.AreNotEqual(0, queryResults.Count()); //validate that data has been returned Assert.AreNotEqual(0, queryResults.ElementAt(0).Properties.Count); //Verify that the highest price is returned in the first element of the results Assert.AreEqual("49.95", queryResults.First().Properties["UnitPrice"].ToString()); //Verify that the lowest price is returned in the last element of the results Assert.AreEqual("0.7", queryResults.Last().Properties["UnitPrice"].ToString()); }
/// <summary> /// 根据查询条件得到User记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="UserQueryEntity">User查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到User记录</returns> public DataSet GetUserByQueryList(QueryEntity userQuery) { return(userDA.GetUserByQueryList(userQuery)); }
public static bool CheckTrainClass(QueryLeftNewDTOData q, QueryEntity qe) { bool flag = false; if (qe.trainClass.Contains("QB")) { flag = true; } else { List<string> trainClasslist = qe.trainClass.Split("#".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); string trainCode = q.queryLeftNewDTO.station_train_code.Substring(0, 1).ToUpper(); trainClasslist.ForEach(t => { if (t.Contains(trainCode)) { flag = true; } }); } return flag; }
public QueryDescription GetQueryDescription(QueryEntity Query) { return(QueryLogic.Queries.QueryDescription(QueryLogic.QueryNames.GetOrThrow(Query.Key))); }
public static TicketInfo GetTicketInfo(string secretStr, QueryEntity qe,ref string msg) { TicketInfo ti = null; TicketService service = new TicketService(StaticValues.MyCookies); bool flag = service.SubmitOrderRequest(secretStr, qe, ref msg); if (flag) { ti = service.GetTicketInfo(); } return ti; }
public static object ToQueryName(this QueryEntity query) { return(QueryNames.GetOrThrow(query.Key, "QueryName with key {0} not found")); }
/// <summary> /// Provides formated columns for the select statement using the QueryEntity object /// </summary> /// <param name="queryEntity"></param> /// <returns></returns> private string ParseColumns(QueryEntity queryEntity) { var selectedChildColumns = new StringBuilder(); var selectedParentColumns = new StringBuilder(); var relationshipName = queryEntity.ParentQueryEntity != null ? queryEntity.Name : string.Empty; if (queryEntity.ChildList != null && queryEntity.ChildList.Count > 0) { //Append the columns of the child entities foreach (var relatedQueryEntity in queryEntity.ChildList) { //add the column to the query selectedChildColumns.Append(","); selectedChildColumns.Append(ParseColumns(relatedQueryEntity)); } } // if self join use the Name for an alias or the same table joined more than once. var useAlias = false; if (queryEntity.ParentQueryEntity != null) { useAlias = queryEntity.ObjectDefinitionFullName == queryEntity.ParentQueryEntity.ObjectDefinitionFullName || queryEntity.ParentQueryEntity.ChildList.Where(child => child.ObjectDefinitionFullName == queryEntity.ObjectDefinitionFullName).Count() > 1; } //Append the query properties selectedParentColumns.Append(ParseColumns(queryEntity.PropertyList, queryEntity.ObjectDefinitionFullName, relationshipName, useAlias)); selectedParentColumns.Append(selectedChildColumns.ToString()); return selectedParentColumns.ToString(); }
/// <summary> /// 根据查询条件得到Member记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="MemberQueryEntity">Member查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Member记录</returns> public DataSet GetMemberByQueryList(QueryEntity memberQuery) { return(memberDA.GetMemberByQueryList(memberQuery)); }
/// <summary> /// Parse query joins /// </summary> /// <param name="queryEntity"></param> /// <param name="joinClause">currently build join clause</param> private void ParseJoins(QueryEntity queryEntity, StringBuilder joinClause) { var useAlias = false; //loop through each of the child entities foreach (var relatedQueryEntity in queryEntity.ChildList) { //verify that the query entity has a parent relation present if (relatedQueryEntity.RelationshipToParent != null) { joinClause.Append(" "); joinClause.Append(LeftKeyWord); joinClause.Append(" "); joinClause.Append(JoinKeyword); joinClause.Append(" ["); joinClause.Append(relatedQueryEntity.ObjectDefinitionFullName); joinClause.Append("] "); // add alias if this is a self join or this table is joined more than once if (relatedQueryEntity.ObjectDefinitionFullName == relatedQueryEntity.ParentQueryEntity.ObjectDefinitionFullName || queryEntity.ChildList.Where(child => child.ObjectDefinitionFullName == relatedQueryEntity.ObjectDefinitionFullName).Count() > 1) { useAlias = true; joinClause.Append(AsKeyword); joinClause.Append(" ["); joinClause.Append(relatedQueryEntity.Name); joinClause.Append("] "); } joinClause.Append(OnKeyword); joinClause.Append(ParseJoinProperties(relatedQueryEntity, useAlias)); //add relationship keys to the Foreign Key list RelatedForeignKeys.Add(relatedQueryEntity.Name, relatedQueryEntity.RelationshipToParent.ChildProperties); } } }
/// <summary> /// Gets the query entity key. /// </summary> private static string GetQueryEntityKey(QueryEntity x) { return(x.KeyTypeName + "^" + x.ValueTypeName); }
private Query BuildComparisonQuery() { var sequence1 = new Sequence { PropertyName = "Name", Direction = SequenceDirection.Ascending }; var sequence2 = new Sequence { PropertyName = "Address", Direction = SequenceDirection.Descending }; var rootEntity = new QueryEntity { SequenceList = new List<Sequence>() }; rootEntity.SequenceList.Add(sequence1); rootEntity.SequenceList.Add(sequence2); var constraints = new ComparisonExpression { Operator = ComparisonOperator.Equal, ExpressionType = ExpressionType.Comparison, LeftValue = new ComparisonValue { Value = "Name", ValueType = ComparisonValueType.Property }, RightValue = new ComparisonValue { Value = "Bobby", ValueType = ComparisonValueType.Property } }; var query = new Query { Constraints = constraints, RootEntity = rootEntity }; return query; }
public static UserQueryEntity ToUserQuery(this QueryRequest request, QueryDescription qd, QueryEntity query, Pagination defaultPagination, bool withoutFilters) { var tuple = SmartColumns(request.Columns, qd); var defaultMode = defaultPagination.GetMode(); var defaultElementsPerPage = defaultPagination.GetElementsPerPage(); var mode = request.Pagination.GetMode(); var elementsPerPage = request.Pagination.GetElementsPerPage(); bool isDefaultPaginate = defaultMode == mode && defaultElementsPerPage == elementsPerPage; return(new UserQueryEntity { Query = query, WithoutFilters = withoutFilters, Owner = DefaultOwner(), Filters = withoutFilters ? new MList <QueryFilterEmbedded>() : request.Filters.Select(f => new QueryFilterEmbedded { Token = new QueryTokenEmbedded(f.Token), Operation = f.Operation, ValueString = FilterValueConverter.ToString(f.Value, f.Token.Type) }).ToMList(), ColumnsMode = tuple.mode, Columns = tuple.columns, Orders = request.Orders.Select(oo => new QueryOrderEmbedded { Token = new QueryTokenEmbedded(oo.Token), OrderType = oo.OrderType }).ToMList(), PaginationMode = isDefaultPaginate ? (PaginationMode?)null : mode, ElementsPerPage = isDefaultPaginate ? (int?)null : elementsPerPage, }); }
// D // / \ //O-D-R D-O // \ / // D private static void OrSplitEnd() { string process_guid = "40c4be7f-2c7d-4391-92a3-32e2dc24f58b"; string application_instance_id = Guid.NewGuid().ToString(); //var serviceurl = "http://172.16.22.26:8000/odata/"; var serviceurl = "http://localhost:53433/odata/"; var data = new Container(new Uri(serviceurl)); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// WfRunner appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr1"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "e60084e4-517a-4892-a290-517159f1b7f4", UserID = "usr21", UserName = "******" }); appRunner.NextActivityPerformers.Add(new Point { PathID = "76f7ef75-b538-40c8-b529-0849ca777b95", UserID = "", UserName = "" }); var aa = data.StartProcess(appRunner).GetValue(); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QueryEntity app = new QueryEntity(); app.ProcessGUID = process_guid; app.AppInstanceID = null; app.AppName = "ApiTest"; app.UserID = "usr21"; app.UserName = "******"; var cc = data.GetReadyTasks(app).Execute(); //XXX appRunner = new WfRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "ApiTest"; appRunner.UserID = "usr21"; appRunner.UserName = "******"; appRunner.NextActivityPerformers.Add(new Point { PathID = "76f7ef75-b538-40c8-b529-0849ca777b94", UserID = "", UserName = "" }); string ss = data.RunProcess(appRunner).GetValue(); }
/// <summary> /// 根据查询条件得到Operationlog记录 /// </summary> /// <param name="sqlWhere">查询条件集合</param> /// <param name="OperationlogQueryEntity">Operationlog查询实体类</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据查询条件得到Operationlog记录</returns> public DataSet GetOperationlogByQueryList(QueryEntity operationlogQuery) { return(operationlogDA.GetOperationlogByQueryList(operationlogQuery)); }