protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_accountAuthorizationRequestManagerService == null)
            {
                throw new ArgumentNullException("_accountAuthorizationRequestManagerService");
            }
            if (_flowService == null)
            {
                throw new ArgumentNullException("_flowService");
            }

            _modelState = new PageModelState();

            IList <DataFlow> flows = _flowService.GetProtectedFlows(VisitHelper.GetVisit(), false);

            _modelState.Flows = new SortedList <string, DataFlow>();
            if (!CollectionUtils.IsNullOrEmpty(flows))
            {
                foreach (DataFlow flow in flows)
                {
                    _modelState.Flows.Add(flow.FlowName.ToUpper(), flow);
                }
            }

            LoadRequests();
        }
Ejemplo n.º 2
0
 protected void selectBtn_Click(object sender, EventArgs e)
 {
     if (listNaasUsers.SelectedIndex > -1)
     {
         string username = listNaasUsers.SelectedItem.Value;
         int    index    = username.LastIndexOf('(');
         if (index > 0)
         {
             username = username.Substring(0, index).Trim();
         }
         try
         {
             UserAccount userAccount = _dataItemService.Get(username, VisitHelper.GetVisit());
             ResponseRedirect("SecurityPolicyEdit.aspx?id=" + username);
         }
         catch (ArgumentException)
         {
             ResponseRedirect("SecurityPolicyEdit.aspx?naas=" + HttpUtility.UrlEncode(username));
         }
     }
     else
     {
         divPageError.Visible = true;
         if (listNaasUsers.Items.Count < 1)
         {
             divPageError.InnerText = "Please enter the first few characters of the NAAS account you would like to select.";
         }
         else
         {
             divPageError.InnerText = "Please select a NAAS account from the list box.";
         }
     }
 }
 protected void DoSearch()
 {
     if (divPageError.Visible || !Page.IsValid)
     {
         // Error on page, get out of here
         return;
     }
     try
     {
         FillSearchParams();
         _dataModel.SearchResults =
             _dataService.Search(DataItem, VisitHelper.GetVisit(), false);
         if (CollectionUtils.IsNullOrEmpty(_dataModel.SearchResults))
         {
             noItemsDiv.Visible = true;
         }
         else
         {
             noItemsDiv.Visible = false;
             foreach (Activity activity in _dataModel.SearchResults)
             {
                 activity.ModifiedById = GetUsernameById(activity.ModifiedById);
             }
             _dataModel.SearchResults.Sort(_dataModel.SortProperty, _dataModel.SortAscending);
         }
         _dataModel.PageIndex     = 0;
         _dataModel.RebindResults = true;
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
 protected void SavePolicies(object sender, EventArgs e)
 {
     try
     {
         if (_dataItem != null)
         {
             IList <UserAccessPolicy> oldPolicies = _dataItem.Policies;
             try
             {
                 _dataItem.Policies = GetPolicies();
                 _dataItem          = _dataItemService.Save(_dataItem, VisitHelper.GetVisit());
             }
             catch
             {
                 _dataItem.Policies = oldPolicies;
                 throw;
             }
         }
         ResponseRedirect("../Secure/SecurityPolicy.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = UIUtility.ParseException(ex);
     }
 }
        protected IList <UserAccessPolicy> GetPolicies()
        {
            Repeater repeater = list.RepeaterList;
            List <UserAccessPolicy> policies = null;
            AdminVisit visitor = VisitHelper.GetVisit();

            foreach (RepeaterItem item in repeater.Items)
            {
                CheckBox checkBox = item.FindControl("checkBox") as CheckBox;
                if ((checkBox != null) && checkBox.Checked && checkBox.Enabled)
                {
                    Label checkTag = item.FindControl("checkTag") as Label;
                    if (checkTag != null)
                    {
                        if (policies == null)
                        {
                            policies = new List <UserAccessPolicy>();
                        }
                        UserAccessPolicy policy = _dataItemService.CreatePolicy(_dataItem.Id, checkTag.Text, true);
                        policy.ModifiedById = visitor.Account.Id;
                        policies.Add(policy);
                    }
                }
            }
            return(policies);
        }
        protected void OnSaveUser(object sender, EventArgs e)
        {
            if (!this.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                AssignEditUserAccount(true);

                ICollection <FlowNameAndRole> permissionedFlows = GetPermissionedFlows();
                SystemRoleType role     = EnumUtils.FromDescription <SystemRoleType>(roleCtrl.SelectedValue);
                bool           isActive = activeCtrl.Checked;
                _accountService.BulkAddUser(_editUserAccount.NaasAccount, false, string.Empty, role,
                                            permissionedFlows, isActive, VisitHelper.GetVisit());

                ResponseRedirect("../Secure/SecurityUser.aspx");
            }
            catch (Exception ex)
            {
                LOG.Error(ex.Message, ex);
                SetDivPageError(ex);
            }
        }
        private void RebindFlowRepeater()
        {
            IList <DataFlow> flows = _flowService.GetFlows(VisitHelper.GetVisit(), false);

            flowRepeaterList.DataSource = flows;
            flowRepeaterList.DataBind();
        }
        protected void SaveDataItem(object sender, EventArgs e)
        {
            if (divPageError.Visible || !Page.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                _modelState.DataItem =
                    _dataItemService.Save(_modelState.DataItem, passwordCtrl.Text, VisitHelper.GetVisit());

                Button btn = sender as Button;

                if (btn != null && btn.ID == savePolicyBtn.ID)
                {
                    ResponseRedirect("../Secure/SecurityPolicyEdit.aspx?id=" + _modelState.DataItem.NaasAccount);
                }
                else
                {
                    ResponseRedirect("../Secure/SecurityUser.aspx");
                }
            }
            catch (Exception ex)
            {
                LOG.Error(ex.Message, ex);
                divPageError.Visible   = true;
                divPageError.InnerText = UIUtility.ParseException(ex);
            }
        }
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_dataItemService == null)
            {
                throw new ArgumentNullException("DataItemService");
            }
            _dataItem = VisitHelper.GetVisit().Account;
        }
Ejemplo n.º 10
0
        protected void CollapseAllLinkButton_Click(object sender, EventArgs e)
        {
            IList <DataFlow> flows = FlowService.GetFlows(VisitHelper.GetVisit(), true);

            SessionStateData.HiddenFlows.Clear();
            CollectionUtils.ForEach(flows, delegate(DataFlow dataFlow)
            {
                SessionStateData.HiddenFlows.Add(dataFlow.Id);
            });
            UserSettingsManager.SaveAdminFlowPageHiddenFlowIds(GetCurrentUsername(), SessionStateData.HiddenFlows);
            NeedsRebind = true;
        }
Ejemplo n.º 11
0
        protected void CollapseAllLinkButton_Click(object sender, EventArgs e)
        {
            IDictionary <string, string> flows = DataItemService.GetExchangeList(VisitHelper.GetVisit(), false);

            SessionStateData.HiddenSchedules.Clear();
            CollectionUtils.ForEach(flows, delegate(KeyValuePair <string, string> pair)
            {
                SessionStateData.HiddenSchedules.Add(pair.Key);
            });
            UserSettingsManager.SaveAdminSchedulePageHiddenScheduleIds(GetCurrentUsername(), SessionStateData.HiddenSchedules);
            NeedsRebind = true;
        }
Ejemplo n.º 12
0
 protected void DeleteDataItem(object sender, EventArgs e)
 {
     try
     {
         FlowService.DeleteFlow(Model.DataFlow, VisitHelper.GetVisit());
         ResponseRedirect("../Secure/Flow.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         SetDivPageError(ex);
     }
 }
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_dataItemService == null)
            {
                throw new ArgumentNullException("_dataItemService");
            }

            _modelState = new ModelState();

            string id = Request["id"];

            _modelState.IsNewUser = string.IsNullOrEmpty(id);
            if (!_modelState.IsNewUser)
            {
                _modelState.DataItem = _dataItemService.Get(id, VisitHelper.GetVisit());
                if (_dataItemService.IsDemoNode)
                {
                    if (_modelState.DataItem.IsDemoUser == null)
                    {
                        _modelState.DataItem.IsDemoUser = new bool?(false);
                    }
                    else
                    {
                        _modelState.WasDemoUser = _modelState.DataItem.IsDemoUser.Value;
                    }
                    _modelState.UserPasswordExistsInDB =
                        _dataItemService.UserPasswordExistsInDB(_modelState.DataItem.NaasAccount);
                }
                string affiliate;
                bool   canDelete, canRemove = false;
                _modelState.UserExistsInNAAS =
                    _dataItemService.UserExistsInNAAS(_modelState.DataItem.NaasAccount, VisitHelper.GetVisit(),
                                                      //out affiliate, out canDelete, out canRemove);
                                                      out affiliate, out canDelete);
                _modelState.Affiliate = affiliate;
                _modelState.CanDelete = canDelete;
                _modelState.CanRemove = canRemove;
            }
            else
            {
                _modelState.DataItem          = new UserAccount();
                _modelState.DataItem.IsActive = true;
                if (_dataItemService.IsDemoNode)
                {
                    _modelState.DataItem.IsDemoUser = new bool?(false);
                }
            }
        }
Ejemplo n.º 14
0
 protected void DeleteDataItem(object sender, EventArgs e)
 {
     try
     {
         _dataItemService.Delete(_dataItem, VisitHelper.GetVisit());
         ResponseRedirect("../Secure/ConfigDs.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = UIUtility.ParseException(ex);
     }
 }
Ejemplo n.º 15
0
        protected override void InitializeModel()
        {
            base.InitializeModel();

            string id = UniqueDataModelKey;

            if (!string.IsNullOrEmpty(id))
            {
                DataItem = EndpointUserService.GetByName(id, VisitHelper.GetVisit());
            }
            else
            {
                DataItem = new UserAccount();
            }
        }
 protected void ResetDataItem(object sender, EventArgs e)
 {
     try
     {
         _modelState.DataItem =
             _dataItemService.ResetPassword(_modelState.DataItem, VisitHelper.GetVisit());
         ResponseRedirect("../Secure/SecurityUser.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = UIUtility.ParseException(ex);
     }
 }
Ejemplo n.º 17
0
 protected void LoadModel()
 {
     try
     {
         NodeVisit visit     = VisitHelper.GetVisit();
         string    serviceId = Request["serviceid"];
         string    flowId    = Request["flowid"];
         if (string.IsNullOrEmpty(flowId))
         {
             throw new ArgumentException("Missing flow id");
         }
         if (!CanViewFlowById(flowId))
         {
             ResponseRedirect("~/Secure/Flow.aspx");
             return;
         }
         string flowName = FlowService.GetFlowNameFromId(flowId, visit);
         if (string.IsNullOrEmpty(flowName))
         {
             throw new ArgumentException("Flow not found");
         }
         flowNameLabel.Text = flowName;
         Model             = new DataModel();
         Model.FlowId      = flowId;
         Model.GlobalArgs  = FlowService.GetGlobalArgs();
         Model.DataSources = FlowService.GetDataSourceNames();
         if (!string.IsNullOrEmpty(serviceId))
         {
             Model.DataService = FlowService.GetService(serviceId, visit);
             if (Model.DataService == null)
             {
                 throw new ArgumentNullException("Model.DataService");
             }
         }
         else
         {
             Model.DataService          = new DataService();
             Model.DataService.FlowId   = flowId;
             Model.DataService.IsActive = true;
             Model.IsNewService         = true;
         }
     }
     catch (Exception ex)
     {
         Model = null;
         SetDivPageError("Failed to load data for flow service: ", ex);
     }
 }
Ejemplo n.º 18
0
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_transactionService == null)
            {
                throw new ArgumentNullException("_transactionService");
            }
            if (_accountService == null)
            {
                throw new ArgumentNullException("_accountService");
            }

            string id   = Request["id"];
            string back = Request["back"];

            if (!string.IsNullOrEmpty(id))
            {
                try
                {
                    NodeTransaction nodeTransaction = _transactionService.Get(id, VisitHelper.GetVisit());
                    if (nodeTransaction == null)
                    {
                        throw new ArgumentException(string.Format("Could not find transaction with id: {0}.", id));
                    }
                    _pageData = new DataModel();
                    _pageData._nodeTransaction = nodeTransaction;
                    _pageData._createdByName   = _accountService.GetUsernameById(nodeTransaction.ModifiedById);
                }
                catch (Exception ex)
                {
                    _pageData = null;
                    SetDivPageError(ex);
                }
            }
            else
            {
                SetDivPageErrorFormat("Transaction Id is required");
            }
            if (!string.IsNullOrEmpty(back))
            {
                BackBtnTableRow.Visible = string.Equals(back, true.ToString(), StringComparison.InvariantCultureIgnoreCase);
            }
            else
            {
                BackBtnTableRow.Visible = false;
            }
        }
        protected void OnResetPassword(object sender, EventArgs e)
        {
            try
            {
                AssignEditUserAccount(true);

                _accountService.ResetPassword(_editUserAccount, VisitHelper.GetVisit());

                ResponseRedirect("../Secure/SecurityUser.aspx");
            }
            catch (Exception ex)
            {
                LOG.Error(ex.Message, ex);
                SetDivPageError(ex);
            }
        }
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_dataItemService == null)
            {
                throw new ArgumentNullException("DataItemService");
            }
            if (!string.IsNullOrEmpty(Request["id"]))
            {
                _dataItem = _dataItemService.GetByName(Request["id"], VisitHelper.GetVisit());
            }
            else
            {
                _dataItem = new PartnerIdentity();
            }
        }
        private void AssignEditUserAccount(bool throwException)
        {
            _editUserAccount = null;
            string id = Request["id"];

            if (!string.IsNullOrEmpty(id))
            {
                _editUserAccount = _accountService.Get(id, VisitHelper.GetVisit());
                if ((_editUserAccount == null) && throwException)
                {
                    throw new ArgumentException(string.Format("Failed to load user account with id \"{0}\" from database.",
                                                              id));
                }
            }
            else if (throwException)
            {
                throw new ArgumentException("Failed to load user account from database.");
            }
        }
 protected void OnChangePassword(object sender, EventArgs e)
 {
     if (divPageError.Visible || !Page.IsValid)
     {
         // Error on page, get out of here
         return;
     }
     try
     {
         _dataItem = _dataItemService.ResetPassword(currentPasswordValue.Text, newPasswordValue1.Text,
                                                    _dataItem, VisitHelper.GetVisit());
         ResponseRedirect("../Secure/Profile.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         SetDivPageError(ex);
     }
 }
Ejemplo n.º 23
0
 protected void SaveDataItem(object sender, EventArgs e)
 {
     try
     {
         if (divPageError.Visible || !Page.IsValid)
         {
             // Error on page, get out of here
             return;
         }
         _dataItem = _dataItemService.Save(_dataItem, VisitHelper.GetVisit());
         ResponseRedirect("../Secure/ConfigDs.aspx");
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = UIUtility.ParseException(ex);
     }
 }
 protected void OnDeleteAllActivities(object sender, EventArgs e)
 {
     if (divPageError.Visible || !Page.IsValid)
     {
         // Error on page, get out of here
         return;
     }
     try
     {
         FillSearchParams();
         _dataService.DeleteActivities(DataItem, VisitHelper.GetVisit());
         DoSearch();
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
Ejemplo n.º 25
0
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (DataItemService == null)
            {
                throw new ArgumentNullException("DataItemService");
            }
            if (UserSettingsManager == null)
            {
                throw new ArgumentNullException("Missing UserSettingsManager");
            }

            _modelState = new PageModelState();

            IList <ScheduledItem> scheduledItems = DataItemService.GetSchedules(VisitHelper.GetVisit());

            if (!CollectionUtils.IsNullOrEmpty(scheduledItems))
            {
                IDictionary <string, string> flows = DataItemService.GetExchangeList(VisitHelper.GetVisit(), false);
                _modelState.FlowToScheduledItems = new Dictionary <string, Dictionary <string, ScheduledItem> >();
                _modelState.Flows          = new Dictionary <string, string>();
                _modelState.ScheduledItems = new Dictionary <string, ScheduledItem>();
                foreach (ScheduledItem scheduledItem in scheduledItems)
                {
                    Dictionary <string, ScheduledItem> scheduledItemList;
                    if (!_modelState.FlowToScheduledItems.TryGetValue(scheduledItem.FlowId, out scheduledItemList))
                    {
                        scheduledItemList = new Dictionary <string, ScheduledItem>();
                        _modelState.FlowToScheduledItems.Add(scheduledItem.FlowId, scheduledItemList);
                    }
                    scheduledItemList.Add(scheduledItem.Id, scheduledItem);
                    _modelState.ScheduledItems.Add(scheduledItem.Id, scheduledItem);
                    if (!_modelState.Flows.ContainsKey(scheduledItem.FlowId))
                    {
                        string flowName = flows[scheduledItem.FlowId];
                        _modelState.Flows.Add(scheduledItem.FlowId, flowName);
                    }
                }
            }
        }
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_accountService == null)
            {
                throw new ArgumentNullException("_accountService");
            }
            if (_policyService == null)
            {
                throw new ArgumentNullException("_policyService");
            }
            if (_flowService == null)
            {
                throw new ArgumentNullException("_flowService");
            }
            if (_centralProcessor == null)
            {
                throw new ArgumentNullException("_centralProcessor");
            }

            _modelState = new PageModelState();

            _modelState.NaasUserList = _policyService.GetCachedNaasUsernameList(true, VisitHelper.GetVisit());

            _isAddUsers = true;

            AssignEditUserAccount(false);

            if (_editUserAccount != null)
            {
                bool userExistsInNAAS =
                    _accountService.UserExistsInNAAS(_editUserAccount.NaasAccount, VisitHelper.GetVisit(),
                                                     out _userAffiliate, out _canDeleteUser, out _canRemoveUser);
                _canResetPassword = _canDeleteUser;
                if (userExistsInNAAS)
                {
                    _isAddUsers = false;
                }
            }
        }
Ejemplo n.º 27
0
        protected void UploadPlugin(object sender, EventArgs e)
        {
            if (divPageError.Visible || !Page.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                _dataItemService.InstallPluginForFlow(fileUpload.FileBytes, Model.FlowName,
                                                      VisitHelper.GetVisit());

                ResponseRedirect("Flow.aspx");
            }
            catch (Exception ex)
            {
                LOG.Error(ex.Message, ex);
                divPageError.Visible   = true;
                divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
            }
        }
Ejemplo n.º 28
0
        protected void UpdateStatusOfScheduledItemsInModel()
        {
            if (CollectionUtils.IsNullOrEmpty(_modelState.ScheduledItems))
            {
                return;
            }
            IList <ScheduledItemExecuteStatus> scheduleStatusList =
                DataItemService.GetScheduledItemExecuteStatus(VisitHelper.GetVisit());

            CollectionUtils.ForEach(scheduleStatusList, delegate(ScheduledItemExecuteStatus scheduledItemExecuteStatus)
            {
                ScheduledItem scheduledItem;
                if (_modelState.ScheduledItems.TryGetValue(scheduledItemExecuteStatus.Id, out scheduledItem))
                {
                    scheduledItem.ExecuteStatus         = scheduledItemExecuteStatus.ExecuteStatus;
                    scheduledItem.LastExecuteActivityId = scheduledItemExecuteStatus.LastExecuteActivityId;
                    scheduledItem.LastExecutedOn        = scheduledItemExecuteStatus.LastExecutedOn;
                    scheduledItem.NextRunOn             = scheduledItemExecuteStatus.NextRunOn;
                }
            });
        }
Ejemplo n.º 29
0
        protected void SaveDataItem(object sender, EventArgs e)
        {
            if (divPageError.Visible || !Page.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                ControlsToModel();

                Model.DataService = FlowService.SaveService(Model.DataService, VisitHelper.GetVisit());

                ResponseRedirect("../Secure/Flow.aspx");
            }
            catch (Exception ex)
            {
                LOG.Error(ex.Message, ex);
                SetDivPageError(ex);
            }
        }
        protected override void InitializeModel()
        {
            base.InitializeModel();

            if (_dataItemService == null)
            {
                throw new ArgumentNullException("DataItemService");
            }
            if (_accountService == null)
            {
                throw new ArgumentNullException("AccountService");
            }

            string id = Request["id"];

            if (!string.IsNullOrEmpty(id))
            {
                _dataItem = _dataItemService.GetOrCreateUser(id, VisitHelper.GetVisit(), out _naasUserInfo);
                if (_accountService.IsDemoNode && (_dataItem.IsDemoUser != null) && (_dataItem.IsDemoUser.Value == true))
                {
                    _naasUserInfo.Owner = _accountService.GetUsernameById(_dataItem.ModifiedById);
                }
            }
            else
            {
                string naasAccount = Request["naas"];
                if (!string.IsNullOrEmpty(naasAccount))
                {
                    _naasUserInfo      = _dataItemService.GetNaasUserInfo(naasAccount);
                    _dataItem          = new UserAccount();
                    _dataItem.IsActive = true;
                    if (_accountService.IsDemoNode)
                    {
                        _dataItem.IsDemoUser = new bool?(false);
                    }
                    _dataItem.NaasAccount = naasAccount;
                    _dataItem.Role        = SystemRoleType.Authed;
                }
            }
        }