示例#1
0
        protected void gvEndpoint_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "ChangeActive")
            {
                var splittedArgs = e.CommandArgument.ToString().Split('|');
                var endpoint_id  = int.Parse(splittedArgs[0]);
                var isActive     = bool.Parse(splittedArgs[1]);

                using (var sericeLocator = ServiceManager.GetServiceLocator(typeof(IQueryService)))
                {
                    var queryService = sericeLocator.GetService <IQueryService>();
                    var criteria     = new EndpointAvailabilityCriteria();
                    //when passing criteria to query service,
                    //ensure to call its ToSerializableCriteria() method
                    //to ensure it is serializable by WCF
                    var result = queryService.Select(criteria.And(criteria.Endpoint_id == endpoint_id).ToSerializableCriteria());
                    if (result != null && result.Rows.Count > 0)
                    {
                        result.Rows[0]["Active"] = !isActive;
                        //when passing criteria to query service,
                        //ensure to call its ToSerializableCriteria() method
                        //to ensure it is serializable by WCF
                        queryService.Update(criteria.ToSerializableCriteria(),
                                            result, ConflictOption.OverwriteChanges);
                    }
                }

                gvEndpoint.DataBind();
            }
        }
示例#2
0
        protected bool IsEndpointActive(int endpoint_id)
        {
            using (var sericeLocator = ServiceManager.GetServiceLocator(typeof(IQueryService)))
            {
                var queryService = sericeLocator.GetService <IQueryService>();
                var criteria     = new EndpointAvailabilityCriteria();
                var result       = queryService.Select(criteria.AddResultColumn(criteria.Active).And(criteria.Endpoint_id == endpoint_id).ToSerializableCriteria());
                if (result != null && result.Rows.Count > 0)
                {
                    return(Convert.ToBoolean(result.Rows[0][0]));
                }
            }

            return(false);
        }