Esempio n. 1
0
        public int DeleteActivities(ActivitySearchParams searchParams, bool addFlowIsNullQuery)
        {
            List <object> whereValues;
            string        tableNames;
            string        whereColumns = ConstructSearchWhereValues(searchParams, addFlowIsNullQuery, out whereValues, out tableNames);

            string selectIdText = CreateSelectSqlParamText(tableNames, whereColumns,
                                                           (whereValues == null) ? 0 : whereValues.Count,
                                                           null, "DISTINCT a.Id");

            IDbParameters parameters = AppendDbParameters(null, whereValues);

            string deleteSqlCommand = string.Format("DELETE FROM {0} WHERE Id IN ({1})",
                                                    TABLE_NAME, selectIdText);
            string updateSqlCommand = string.Format("UPDATE {0} SET LastExecuteActivityId = NULL WHERE LastExecuteActivityId IN ({1})",
                                                    ScheduleDao.TABLE_NAME, selectIdText);

            int deleteCount = 0;

            TransactionTemplate.Execute(delegate
            {
                AdoTemplate.ExecuteNonQuery(CommandType.Text, updateSqlCommand, parameters);
                deleteCount = AdoTemplate.ExecuteNonQuery(CommandType.Text, deleteSqlCommand, parameters);
                return(null);
            });
            return(deleteCount);
        }
Esempio n. 2
0
        public SortableCollection <Activity> Search(ActivitySearchParams searchParams,
                                                    bool addFlowIsNullQuery, bool includeActivityEntries)
        {
            SortableCollection <Activity> list = null;
            List <object> whereValues;

            string sql = ConstructJDBCSearchSql(searchParams, addFlowIsNullQuery, out whereValues);

            DoJDBCQueryWithRowCallbackDelegate(sql, whereValues,
                                               delegate(IDataReader reader)
            {
                if (list == null)
                {
                    list = new SortableCollection <Activity>();
                }
                Activity activity = MapActivity(reader);
                list.Add(activity);
            });

            if (includeActivityEntries)
            {
                PostMapActivityEntries(list);
            }
            return(list);
        }
Esempio n. 3
0
        public int DeleteActivities(ActivitySearchParams search, NodeVisit visit)
        {
            LogicAuditBaseManager.ValidateByRole(visit, SystemRoleType.Admin);

            bool addFlowIsNullQuery;

            if (!FilterSearchParamsForVisit(search, visit, out addFlowIsNullQuery))
            {
                return(0);
            }

            return(_activityDao.DeleteActivities(search, addFlowIsNullQuery));
        }
Esempio n. 4
0
        public SortableCollection <Activity> Search(ActivitySearchParams search,
                                                    NodeVisit visit,
                                                    bool includeActivityEntries)
        {
            LogicAuditBaseManager.ValidateByRole(visit, SystemRoleType.Program);

            bool addFlowIsNullQuery;

            if (!FilterSearchParamsForVisit(search, visit, out addFlowIsNullQuery))
            {
                return(null);
            }

            return(_activityDao.Search(search, addFlowIsNullQuery, includeActivityEntries));
        }
Esempio n. 5
0
 protected bool FilterSearchParamsForVisit(ActivitySearchParams search, NodeVisit visit,
                                           out bool addFlowIsNullQuery)
 {
     if (visit.IsAdmin)
     {
         addFlowIsNullQuery = false;
     }
     else
     {
         IList <string> flowNames = null;
         if (CollectionUtils.IsNullOrEmpty(search.FlowNames))
         {
             addFlowIsNullQuery = true;
             flowNames          = GetAllFlowNames(visit);
             if (CollectionUtils.IsNullOrEmpty(flowNames))
             {
                 flowNames = new List <string>(1);
                 flowNames.Add("____BOGUS____FLOW____NAME____");
             }
         }
         else
         {
             addFlowIsNullQuery = false;
             flowNames          = new List <string>();
             foreach (string flowName in search.FlowNames)
             {
                 if (visit.IsFlowPermittedByName(flowName, FlowRoleType.View))
                 {
                     flowNames.Add(flowName);
                 }
             }
             if (flowNames.Count == 0)
             {
                 // Flows were specified to search on, but none of the flows are allowed for the user,
                 // so return no results
                 return(false);
             }
         }
         search.FlowNames = flowNames;
     }
     return(true);
 }
Esempio n. 6
0
        public IList <Activity> GetRecentActivities(int maxNumToReturn, bool returnUsernames,
                                                    NodeVisit visit)
        {
            LogicAuditBaseManager.ValidateByRole(visit, SystemRoleType.Program);

            ActivitySearchParams search = new ActivitySearchParams();

            bool addFlowIsNullQuery;

            if (!FilterSearchParamsForVisit(search, visit, out addFlowIsNullQuery))
            {
                return(null);
            }

            IList <Activity> activities =
                _activityDao.GetRecentActivities(search, addFlowIsNullQuery,
                                                 maxNumToReturn, returnUsernames);

            return(activities);
        }
        public IActionResult Search(ActivitySearchParams searchParams)
        {
            var query = applicationDbContext.Activities.AsQueryable();

            if (!string.IsNullOrEmpty(searchParams.Keyword))
            {
                query = query.Where(x => x.PrgName.Contains(searchParams.Keyword));
            }

            query = query.OrderByDescending(x => x.Id);
            //if (!string.IsNullOrEmpty(searchParams.Order))
            //{

            //    query = query.OrderBy(x => EF.Property<string>(x, searchParams.Order));
            //}

            query.Skip((searchParams.PageIndex) * 30).Take(30);


            return(View("Index", query.ToList()));
        }
Esempio n. 8
0
        public IList <Activity> GetRecentActivities(ActivitySearchParams searchParams,
                                                    bool addFlowIsNullQuery, int maxNumToReturn,
                                                    bool returnUsernames)
        {
            List <object>   whereValues;
            List <Activity> list = null;

            string sql = ConstructJDBCSearchSql(searchParams, addFlowIsNullQuery, out whereValues);

            sql += " ORDER BY ModifiedOn DESC";
            DoJDBCQueryWithCancelableRowCallbackDelegate(sql, whereValues,
                                                         delegate(IDataReader reader)
            {
                if (list == null)
                {
                    list = new List <Activity>();
                }
                if (list.Count == maxNumToReturn)
                {
                    return(false);
                }
                Activity activity = MapActivity(reader);
                list.Add(activity);
                return(true);
            });

            if (list != null)
            {
                if (returnUsernames)
                {
                    foreach (Activity activity in list)
                    {
                        activity.ModifiedById = _accountDao.GetUsernameById(activity.ModifiedById);
                    }
                }
            }
            return(list);
        }
Esempio n. 9
0
        protected string ConstructJDBCSearchSql(ActivitySearchParams searchParams, bool addFlowIsNullQuery,
                                                out List <object> whereValues)
        {
            // TODO:
            // TransactionStatus

            if (searchParams == null)
            {
                throw new ArgumentException("searchParams");
            }
            const string  TABLE_NAMES_KEY = "___TABLE_NAMES___";
            StringBuilder sql             = new StringBuilder();

            sql.AppendFormat("SELECT DISTINCT {0} FROM {1} WHERE a.ModifiedOn >= ? AND a.ModifiedOn <= ?",
                             MAP_ACTIVITY_COLUMNS.Replace(';', ','), TABLE_NAMES_KEY);

            whereValues =
                new List <object>(new object[] { ActivitySearchParams.ConstrainDate(searchParams.CreatedFrom),
                                                 ActivitySearchParams.ConstrainDate(searchParams.CreatedTo) });

            bool addedTransaction = false, addedDetail = false;

            if (!CollectionUtils.IsNullOrEmpty(searchParams.FlowNames))
            {
                StringBuilder flowNameColumns = new StringBuilder();
                foreach (string flowName in searchParams.FlowNames)
                {
                    if (flowNameColumns.Length > 0)
                    {
                        flowNameColumns.Append(" OR UPPER(a.FlowName) = UPPER(?)");
                    }
                    else
                    {
                        flowNameColumns.Append(" AND (UPPER(a.FlowName) = UPPER(?)");
                    }
                    whereValues.Add(flowName);
                }
                if (addFlowIsNullQuery)
                {
                    flowNameColumns.Append(" OR a.FlowName IS NULL)");
                }
                else
                {
                    flowNameColumns.Append(")");
                }
                sql.Append(flowNameColumns.ToString());
            }
            if (!string.IsNullOrEmpty(searchParams.OperationName))
            {
                sql.Append(" AND a.Operation = UPPER(?)");
                whereValues.Add(searchParams.OperationName);
            }
            if (!string.IsNullOrEmpty(searchParams.TransactionId))
            {
                sql.Append(" AND (UPPER(a.TransactionId) = UPPER(?) OR UPPER(t.NetworkId) = UPPER(?))");
                addedTransaction = true;
                whereValues.Add(searchParams.TransactionId);
                whereValues.Add(searchParams.TransactionId);
            }
            if (!string.IsNullOrEmpty(searchParams.IP))
            {
                sql.Append(" AND UPPER(a.IP) = UPPER(?)");
                whereValues.Add(searchParams.IP);
            }
            if (searchParams.Type != ActivityType.None)
            {
                sql.Append(" AND UPPER(a.Type) = UPPER(?)");
                whereValues.Add(searchParams.Type.ToString());
            }
            if (searchParams.NodeMethod != NodeMethod.None)
            {
                sql.Append(" AND UPPER(a.WebMethod) = UPPER(?)");
                whereValues.Add(searchParams.NodeMethod.ToString());
            }
            if (!string.IsNullOrEmpty(searchParams.CreatedByUsername))
            {
                string userId = _accountDao.GetUserIdByName(searchParams.CreatedByUsername);
                sql.Append(" AND UPPER(a.ModifiedBy) = UPPER(?)");
                whereValues.Add(userId);
            }
            if (!string.IsNullOrEmpty(searchParams.DetailContains))
            {
                sql.Append(" AND UPPER(d.Detail) LIKE " + SqlConcat("'%'", "UPPER(?)", "'%'"));
                addedDetail = true;
                whereValues.Add(searchParams.DetailContains);
            }
            string tableNames = TABLE_NAME + " a";

            if (addedTransaction)
            {
                sql.Append(" AND t.Id = a.TransactionId");
                tableNames += ", " + Windsor.Node2008.WNOS.Data.TransactionDao.TABLE_NAME + " t";
            }
            if (addedDetail)
            {
                sql.Append(" AND d.ActivityId = a.Id");
                tableNames += ", " + DETAIL_TABLE_NAME + " d";
            }
            return(sql.ToString().Replace(TABLE_NAMES_KEY, tableNames));
        }
Esempio n. 10
0
        protected string ConstructSearchWhereValues(ActivitySearchParams searchParams, bool addFlowIsNullQuery,
                                                    out List <object> whereValues, out string tableNames)
        {
            // TODO:
            // TransactionStatus
            // NodeMethod

            if (searchParams == null)
            {
                throw new ArgumentException("searchParams");
            }
            tableNames = TABLE_NAME + " a";

            bool          addedTransactionTable = false;
            StringBuilder whereColumns          = new StringBuilder("(a.ModifiedOn >=;a.ModifiedOn <=");

            whereValues =
                new List <object>(new object[] { ActivitySearchParams.ConstrainDate(searchParams.CreatedFrom),
                                                 ActivitySearchParams.ConstrainDate(searchParams.CreatedTo) });

            if (!CollectionUtils.IsNullOrEmpty(searchParams.FlowNames))
            {
                StringBuilder flowNameColumns = new StringBuilder();
                foreach (string flowName in searchParams.FlowNames)
                {
                    if (flowNameColumns.Length > 0)
                    {
                        flowNameColumns.Append("; OR a.FlowName");
                    }
                    else
                    {
                        flowNameColumns.Append(";(a.FlowName");
                    }
                    whereValues.Add(flowName);
                }
                if (addFlowIsNullQuery)
                {
                    flowNameColumns.Append("; OR a.FlowName IS NULL)");
                }
                else
                {
                    flowNameColumns.Append(")");
                }
                whereColumns.Append(flowNameColumns.ToString());
            }
            if (!string.IsNullOrEmpty(searchParams.OperationName))
            {
                whereColumns.Append(";a.Operation");
                whereValues.Add(searchParams.OperationName);
            }
            if (!string.IsNullOrEmpty(searchParams.TransactionId))
            {
                if (!addedTransactionTable)
                {
                    tableNames           += ", " + Windsor.Node2008.WNOS.Data.TransactionDao.TABLE_NAME + " t";
                    addedTransactionTable = true;
                }
                whereColumns.Append(";(a.TransactionId; OR t.NetworkId)");
                whereValues.Add(searchParams.TransactionId);
                whereValues.Add(searchParams.TransactionId);
            }
            if (!string.IsNullOrEmpty(searchParams.IP))
            {
                whereColumns.Append(";a.IP");
                whereValues.Add(searchParams.IP);
            }
            if (searchParams.Type != ActivityType.None)
            {
                whereColumns.Append(";a.Type");
                whereValues.Add(searchParams.Type.ToString());
            }
            if (searchParams.NodeMethod != NodeMethod.None)
            {
                whereColumns.Append(";a.WebMethod");
                whereValues.Add(searchParams.NodeMethod.ToString());
            }
            if (!string.IsNullOrEmpty(searchParams.CreatedByUsername))
            {
                string userId = _accountDao.GetUserIdByName(searchParams.CreatedByUsername);
                whereColumns.Append(";a.ModifiedBy");
                whereValues.Add(userId);
            }
            if (!string.IsNullOrEmpty(searchParams.DetailContains))
            {
                tableNames += ", " + DETAIL_TABLE_NAME + " d";
                whereColumns.Append(";d.Detail LIKE '%'p'%';d.ActivityId = a.Id");
                whereValues.Add(searchParams.DetailContains);
            }
            if (addedTransactionTable)
            {
                whereColumns.Append(";a.TransactionId = t.Id");
            }
            whereColumns.Append(")");
            return(whereColumns.ToString());
        }
        protected override void OnInitializeControls(EventArgs e)
        {
            base.OnInitializeControls(e);

            if (!this.IsPostBack)
            {
                NodeVisit nodeVisit = VisitHelper.GetVisit();

                SecureMasterPage.SetupPage(SideTabs, SelectedTabIndex);

                introParagraphs.DataSource = IntroParagraphs;
                introParagraphs.DataBind();

                ActivitySearchParams activitySearchParams = (_dataModel != null) && (_dataModel.SearchParams != null) ? _dataModel.SearchParams : null;

                exchangeDropDownList.DataSource = DataService.GetAllFlowNames(nodeVisit);
                exchangeDropDownList.DataBind();
                exchangeDropDownList.Items.Insert(0, NOT_SELECTED_TEXT);
                exchangeDropDownList.SelectedIndex = 0;

                operationDropDownList.DataSource = DataService.GetAllOperationNames(nodeVisit);
                operationDropDownList.DataBind();
                operationDropDownList.Items.Insert(0, NOT_SELECTED_TEXT);
                operationDropDownList.SelectedIndex = 0;

                List <string> nodeMethodTypes = new List <string>(EnumUtils.GetAllDescriptions <NodeMethod>());
                nodeMethodTypes.Sort();
                nodeMethodTypeDropdown.DataSource = nodeMethodTypes;
                nodeMethodTypeDropdown.DataBind();
                nodeMethodTypeDropdown.Items.Insert(0, NOT_SELECTED_TEXT);
                nodeMethodTypeDropdown.SelectedIndex = 0;

                List <string> activityTypes = new List <string>(EnumUtils.GetAllDescriptions <ActivityType>());
                activityTypes.Sort();
                activityTypeCtrl.DataSource = activityTypes;
                activityTypeCtrl.DataBind();
                activityTypeCtrl.Items.Insert(0, NOT_SELECTED_TEXT);
                activityTypeCtrl.SelectedIndex = 0;

                fromIpCtrl.DataSource = DataService.GetDistinctFromIpList();
                fromIpCtrl.DataBind();
                fromIpCtrl.Items.Insert(0, NOT_SELECTED_TEXT);
                fromIpCtrl.SelectedIndex = 0;

                List <string> userNames = new List <string>(_dataModel.UserIdToNameMap.Values);
                userNames.Sort();
                byUserCtrl.DataSource = userNames;
                byUserCtrl.DataBind();
                byUserCtrl.Items.Insert(0, NOT_SELECTED_TEXT);
                byUserCtrl.SelectedIndex = 0;

                if (activitySearchParams != null)
                {
                    if (!CollectionUtils.IsNullOrEmpty(activitySearchParams.FlowNames))
                    {
                        exchangeDropDownList.SelectedValue = activitySearchParams.FlowNames[0];
                    }
                    if (!string.IsNullOrEmpty(activitySearchParams.OperationName))
                    {
                        operationDropDownList.SelectedValue = activitySearchParams.OperationName;
                    }
                    if (activitySearchParams.NodeMethod != NodeMethod.None)
                    {
                        nodeMethodTypeDropdown.SelectedValue = EnumUtils.ToDescription(activitySearchParams.NodeMethod);
                    }
                    if (activitySearchParams.Type != ActivityType.None)
                    {
                        activityTypeCtrl.SelectedValue = EnumUtils.ToDescription(activitySearchParams.Type);
                    }
                    if (!string.IsNullOrEmpty(activitySearchParams.IP))
                    {
                        fromIpCtrl.SelectedValue = activitySearchParams.IP;
                    }
                    if (!string.IsNullOrEmpty(activitySearchParams.CreatedByUsername))
                    {
                        byUserCtrl.SelectedValue = activitySearchParams.CreatedByUsername;
                    }
                    if (!string.IsNullOrEmpty(activitySearchParams.TransactionId))
                    {
                        transactionIdCtrl.Text = activitySearchParams.TransactionId;
                    }
                    if (!string.IsNullOrEmpty(activitySearchParams.DetailContains))
                    {
                        contentCtrl.Text = activitySearchParams.DetailContains;
                    }
                    if (activitySearchParams.CreatedFrom != ActivitySearchParams.MIN_DATETIME)
                    {
                        fromDateImageButton.Text = activitySearchParams.CreatedFrom.ToString(fromDateCalendarExtender.Format);
                        fromDateCalendarExtender.SelectedDate = activitySearchParams.CreatedFrom;
                    }
                    if (activitySearchParams.CreatedTo != ActivitySearchParams.MAX_DATETIME)
                    {
                        toDateImageButton.Text = activitySearchParams.CreatedTo.ToString(toDateCalendarExtender.Format);
                        toDateCalendarExtender.SelectedDate = activitySearchParams.CreatedTo;
                    }
                }

                resultsPerPage.Text = _dataModel.ResultsPerPage.ToString();

                if (!nodeVisit.IsAdmin)
                {
                    DeleteAllButton.Visible = false;
                }
            }

            _dataModel.RebindResults = false;
            if (!CollectionUtils.IsNullOrEmpty(_dataModel.SearchResults))
            {
                BindSearchResults();
            }

            //Page.Form.DefaultButton = searchBtn.ID;
        }