Пример #1
0
 public static void Logout()
 {
     _instance = new AccountHelper();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        chkContacts.Enabled = (CurrentAccount.AccountPrimaryContactID != 0) || (CurrentAccount.AccountSecondaryContactID != 0);
        chkAddress.Enabled  = !String.IsNullOrEmpty(CurrentAccount.AccountAddress1) || !String.IsNullOrEmpty(CurrentAccount.AccountAddress2) || !String.IsNullOrEmpty(CurrentAccount.AccountCity) || !String.IsNullOrEmpty(CurrentAccount.AccountZIP);
        chkEmail.Enabled    = !String.IsNullOrEmpty(CurrentAccount.AccountEmail);
        chkURL.Enabled      = !String.IsNullOrEmpty(CurrentAccount.AccountWebSite);
        chkPhone.Enabled    = !String.IsNullOrEmpty(CurrentAccount.AccountPhone) || !String.IsNullOrEmpty(CurrentAccount.AccountFax);

        // Current account is global object
        if (ai.AccountSiteID == 0)
        {
            plcSite.Visible    = true;
            plcContact.Visible = false;
            // Display site selector in site manager
            if (ContactHelper.IsSiteManager)
            {
                siteOrGlobalSelector.Visible = false;
            }
            // Display 'site or global' selector in CMS desk for global objects
            else if (AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false) && AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false))
            {
                siteSelector.Visible = false;
            }
            else
            {
                plcSite.Visible = false;
            }
        }
    }
Пример #3
0
        public void UpdateUc()
        {
            var acc = GetSelectedAcc();

            buyAdventuresCheckBox.Checked        = acc.Hero.Settings.BuyAdventures;
            checkBoxAutoSendToAdventures.Checked = acc.Hero.Settings.AutoSendToAdventure;
            minHeroHealthUpDown.Value            = acc.Hero.Settings.MinHealth;
            autoReviveHero.Checked = acc.Hero.Settings.AutoReviveHero;
            refreshInfo.Checked    = acc.Hero.Settings.AutoRefreshInfo;
            helmetSwitcher.Checked = acc.Hero.Settings.AutoSwitchHelmets;
            autoEquip.Checked      = acc.Hero.Settings.AutoEquip;

            var heroUpgrade = acc.Hero.Settings.Upgrades;

            strength.Value  = 0;
            offBonus.Value  = 0;
            deffBonus.Value = 0;
            resources.Value = 0;
            strength.Value  = heroUpgrade[0];
            offBonus.Value  = heroUpgrade[1];
            deffBonus.Value = heroUpgrade[2];
            resources.Value = heroUpgrade[3];

            autoSetHeroPoints.Checked = acc.Hero.Settings.AutoSetPoints;
            maxDistanceUpDown.Value   = acc.Hero.Settings.MaxDistance;
            LimitHeroPoints();

            SupplyResVillageComboBox.Items.Clear();
            foreach (var vill in acc.Villages)
            {
                SupplyResVillageComboBox.Items.Add(vill.Name);
            }
            if (SupplyResVillageComboBox.Items.Count > 0)
            {
                SupplyResVillageComboBox.SelectedIndex = 0;
                SupplyResVillageSelected.Text          = "Selected: " + AccountHelper.GetHeroReviveVillage(acc).Name;
            }

            if (acc.Hero.Items == null)
            {
                return;
            }

            heroItemsList.Items.Clear();
            if (acc.Hero.Items.Count > 0)
            {
                foreach (var item in acc.Hero.Items)
                {
                    var viewItem = new ListViewItem();

                    var attr = item.Item.ToString().Split('_');

                    viewItem.SubItems[0].Text = attr[0];
                    viewItem.SubItems.Add(attr[1]);
                    viewItem.SubItems.Add(attr[2] == "0" ? "" : attr[2]);
                    viewItem.SubItems.Add(item.Count.ToString());

                    heroItemsList.Items.Add(viewItem);
                }
            }

            equiptList.Items.Clear();
            if (acc.Hero.Equipt == null)
            {
                acc.Hero.Equipt = new System.Collections.Generic.Dictionary <Classificator.HeroItemCategory, Classificator.HeroItemEnum>();
            }
            foreach (var pair in acc.Hero.Equipt)
            {
                var viewItem = new ListViewItem();

                var attr = pair.Value.ToString().Split('_');

                viewItem.SubItems[0].Text = attr[0];
                viewItem.SubItems.Add(attr[1]);
                viewItem.SubItems.Add(attr[2] == "0" ? "" : attr[2]);

                equiptList.Items.Add(viewItem);
            }

            // Update hero info
            string heroInfoStr = $"Health: {acc.Hero.HeroInfo.Health}\n";

            heroInfoStr  += $"Hero Status: {acc.Hero.Status}\n";
            heroInfoStr  += $"Hero home village: {HeroHelper.GetHeroHomeVillage(acc)?.Name ?? "UNKNOWN"}\n";
            heroInfoStr  += $"Hero Arrival: {acc.Hero.HeroArrival}\n";
            heroInfoStr  += $"Level: {acc.Hero.HeroInfo.Level}\n";
            heroInfoStr  += $"Experience: {acc.Hero.HeroInfo.Experience}\n";
            heroInfoStr  += $"Attack points: {acc.Hero.HeroInfo.FightingStrengthPoints}\n";
            heroInfoStr  += $"Off Bonus points: {acc.Hero.HeroInfo.OffBonusPoints}\n";
            heroInfoStr  += $"Deff Bonus points: {acc.Hero.HeroInfo.DeffBonusPoints}\n";
            heroInfoStr  += $"Resources points: {acc.Hero.HeroInfo.ResourcesPoints}\n";
            heroInfoStr  += $"Number of adventures: {acc.Hero.AdventureNum}";
            heroInfo.Text = heroInfoStr;

            //Adventures
            var advStr = new List <string>();

            foreach (var adv in acc.Hero.Adventures)
            {
                advStr.Add(adv.Coordinates.ToString() + " - " + adv.Difficulty.ToString() + " adventure");
            }
            adventures.Text = string.Join("\n", advStr);
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     _Account = AccountHelper.GetCurUser();
     _Account = AccountHelper.GetUser(_Account.Id);
     Id       = _Account.Id;
 }
        public override void Execute()
        {
            UserAccount user;

            bool hasPrivilegeForManagingQueues          = (base.HttpContext.Session[SessionHelper.PrivilegeForManagingQueues] is bool && ( bool )base.HttpContext.Session[SessionHelper.PrivilegeForManagingQueues]);
            bool hasPrivilegeForManagingAppraisalQueues = (base.HttpContext.Session[SessionHelper.DisplayAppraisalQueues] is bool && ( bool )base.HttpContext.Session[SessionHelper.DisplayAppraisalQueues]);
            bool hasPrivilegeForViewQueuesFilter        = (base.HttpContext.Session[SessionHelper.ViewQueuesFilter] is bool && ( bool )base.HttpContext.Session[SessionHelper.ViewQueuesFilter]);

            if (base.HttpContext.Session[SessionHelper.UserData] != null && (( UserAccount )base.HttpContext.Session[SessionHelper.UserData]).Username == base.HttpContext.User.Identity.Name)
            {
                user = ( UserAccount )base.HttpContext.Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(base.HttpContext.User.Identity.Name);
            }

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            FilterViewModel userFilterViewModel;

            if ((base.HttpContext != null) && (base.HttpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(base.HttpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                // possible state retrieval?
                userFilterViewModel = new FilterViewModel();
            }


            userFilterViewModel.CompanyId = Guid.Empty;

            userFilterViewModel.Channels.Clear();
            userFilterViewModel.Channels.Add(_genericItem);
            userFilterViewModel.ChannelId = 0;

            userFilterViewModel.Divisions.Clear();
            userFilterViewModel.Divisions.Add(_genericItem);
            userFilterViewModel.DivisionId = 0;

            userFilterViewModel.Branches.Clear();
            userFilterViewModel.Branches.Add(_genericItemGuid);
            userFilterViewModel.BranchId = Guid.Empty;

            userFilterViewModel.Users.Clear();
            userFilterViewModel.Users.Add(_genericItem);


            userFilterViewModel.UserId = 0;

            if (user.Roles.Any(r => r.RoleName.Equals(RoleName.Administrator)) || hasPrivilegeForManagingAppraisalQueues || hasPrivilegeForViewQueuesFilter)
            {
                // start filling user filters by loading companies
                LoadCompanies(userFilterViewModel);
            }
            else if (user.Roles.Any(r => r.RoleName.Equals(RoleName.BranchManager)) || user.Roles.Any(r => r.RoleName.Equals(RoleName.TeamLeader)) || hasPrivilegeForManagingQueues || hasPrivilegeForViewQueuesFilter)
            {
                // load only related users
                LoadRelatedUsers(userFilterViewModel, user);
            }
            else if (user.Roles.Any(r => r.RoleName.Equals(RoleName.LoanOfficer)) ||
                     user.Roles.Any(r => r.RoleName.Equals(RoleName.Concierge)))
            {
                AddCurrentUserToFilterModel(userFilterViewModel, user);
            }
            else if (user.Roles.Any(r => r.RoleName.Equals(RoleName.LoanOfficerAssistant)))
            {
                AddRelatedLoanOfficers(userFilterViewModel, user);
            }

            userFilterViewModel.Users = userFilterViewModel.Users.OrderBy(u => u.Text).ToList();



            if (user.Roles.Any(r => r.RoleName.Equals(RoleName.Administrator)) || hasPrivilegeForManagingAppraisalQueues || hasPrivilegeForViewQueuesFilter)
            {
                LoadCompanies(userFilterViewModel);
                userFilterViewModel.Users.Clear();
                userFilterViewModel.Users.Add(_genericItem);
            }

            ViewName = "_userfilter";
            ViewData = userFilterViewModel;

            /* Persist new state */
            base.HttpContext.Session[SessionHelper.FilterViewModel] = userFilterViewModel.ToXml();
            base.HttpContext.Session[SessionHelper.UserAccountIds]  = AccountHelper.PopulateUserAccountIdsList(user);
        }
Пример #6
0
    /// <summary>
    /// Reloads the data in the selector.
    /// </summary>
    public void ReloadData()
    {
        string where = null;
        bool authorizedSiteAccounts   = false;
        bool authorizedGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false);

        currentUser = CMSContext.CurrentUser;

        if (SiteID > 0)
        {
            authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteID, false);
        }
        else
        {
            authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false);
        }

        // Filter site objects
        if (this.SiteID > 0)
        {
            if (authorizedSiteAccounts)
            {
                where = "(AccountSiteID = " + this.SiteID + " AND AccountMergedWithAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Filter only global objects
        else if ((this.SiteID == UniSelector.US_GLOBAL_RECORD) || (this.SiteID == 0))
        {
            if (authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display current site and global contacts
        else if (this.SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD)
        {
            if (authorizedSiteAccounts && authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID = " + CMSContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)";
                uniSelector.AddGlobalObjectSuffix = true;
            }
            else if (authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountMergedWithAccountID IS NULL)";
            }
            else if (authorizedSiteAccounts)
            {
                where = "(AccountSiteID = " + CMSContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display all objects
        else if ((this.SiteID == UniSelector.US_ALL_RECORDS) && currentUser.UserSiteManagerAdmin)
        {
            where = "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))";
            uniSelector.AddGlobalObjectSuffix = true;
        }
        // Not enough permissions
        else
        {
            where = "(1=0)";
        }

        uniSelector.WhereCondition = SqlHelperClass.AddWhereCondition(this.WhereCondition, where);
        uniSelector.Reload(true);
    }
Пример #7
0
        public ActionResult IndexCompleted()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("SignOut", "Home", new { redirect = this.HttpContext.Request.RawUrl }));
            }


            Session[SessionHelper.DisplaySystemAdmin] = null;
            Session[SessionHelper.SearchTerm]         = null;

            UserAccount user = null;

            ViewBag.Title = "Loan Center";
            if (Session[SessionHelper.UserData] != null && (( UserAccount )Session[SessionHelper.UserData]).Username == User.Identity.Name)
            {
                user = ( UserAccount )Session[SessionHelper.UserData];
            }
            else
            {
                user = UserAccountServiceFacade.GetUserByName(User.Identity.Name);
            }

            if (user != null)
            {
                LoginHelper loginHelper = new LoginHelper();
                loginHelper.SetBranding(user);

                Session[SessionHelper.UserData] = user;

                if (!AccountHelper.IsInRole(RoleName.Administrator) && !AccountHelper.IsInRole(RoleName.Hvm))
                {
                    // Show only records where user is assigned to (either if it's as LO/Concierge, LOA or Loan Processor )
                    Session[SessionHelper.UserAccountIds] = new List <int> {
                        user.UserAccountId
                    };
                }
                else
                {
                    // Don't filter result list
                    Session[SessionHelper.UserAccountIds] = null;
                }
            }

            if (Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] == null || Session[SessionHelper.PrivilegeForManagingQueues] == null ||
                Session[SessionHelper.PrivilegeForManagingAppraisalOrders] == null || Session[SessionHelper.DisplayAppraisalQueues] == null)
            {
                List <RolePrivilege> privileges = (UserAccountServiceFacade.GetRolePrivileges(user.UserAccountId)).ToList();
                Session[SessionHelper.PrivilegeForUser] = privileges;

                Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = false;
                if (privileges != null && (privileges.Any(p => p.Category == ( int )ActionCategory.ReviewPreApprovalQueue)))
                {
                    Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForReviewPreApprovalQueue] = false;
                }

                if (privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.PrivilegeForManagingQueues] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForManagingQueues] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.DisplayAppraisalQueues)))
                {
                    Session[SessionHelper.DisplayAppraisalQueues] = true;
                }
                else
                {
                    Session[SessionHelper.DisplayAppraisalQueues] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewQueuesFilter)))
                {
                    Session[SessionHelper.ViewQueuesFilter] = true;
                }
                else
                {
                    Session[SessionHelper.ViewQueuesFilter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewSystemAdmin)))
                {
                    Session[SessionHelper.PrivilegeForViewSystemAdmin] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewSystemAdmin] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewConciergeHome)))
                {
                    Session[SessionHelper.PrivilegeForViewConciergeCenter] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewConciergeCenter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.ViewLoanCenter)))
                {
                    Session[SessionHelper.PrivilegeForViewLoanCenter] = true;
                }
                else
                {
                    Session[SessionHelper.PrivilegeForViewLoanCenter] = false;
                }

                if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.MailRoomQueue)) && !privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.NewLoanApplication;
                }
                else if (privileges.Any(p => p.Name.Trim().Equals(PrivilegeName.DisplayAppraisalQueues)) && !privileges.Any(p => p.Category == ( int )ActionCategory.ManagingQueues))
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.OrderRequested;
                }
                else
                {
                    Session[SessionHelper.CurrentTab] = LoanCenterTab.Prospect;
                }
            }
            else
            {
                Session[SessionHelper.CurrentTab] = LoanCenterTab.Prospect;
            }

            Session[SessionHelper.LoanCenterVersion] = AccountHelper.HasPrivilege(MML.Common.PrivilegeName.ViewLoanCenter3) ? _version : 2;

            return(View());
        }
Пример #8
0
        public ActionResult InsertTask(Worktask worktask)
        {
            int currentUID = AccountHelper.GetCurrentUser(User.Identity.Name).UID;
            ElasticIndexService eService  = new ElasticIndexService();
            Worktask            oldObject = null;

            if (ModelState.IsValid)
            {
                var isNew = false;

                // Assign Current user AS Owner, Assignee, Reporter
                if (worktask.Owner == 0)
                {
                    worktask.Owner = currentUID;
                }
                if (worktask.Assignee == 0)
                {
                    worktask.Assignee = currentUID;
                }
                if (worktask.Reporter == null || worktask.Reporter == 0)
                {
                    worktask.Reporter = currentUID;
                }
                if (worktask.TaskType == 0)
                {
                    worktask.TaskType = int.Parse(CategoryService.GetInstance().GetCategoryList(Contain.CatType.Category).ElementAt(1).Value);
                }
                if (worktask.Priority == 0)
                {
                    worktask.Priority = int.Parse(CategoryService.GetInstance().GetCategoryList(Contain.CatType.Priority).ElementAt(1).Value);
                }

                if (worktask.WorktaskID == 0)
                {
                    isNew              = true;
                    worktask.BoardID   = this.GetLastViewedBoardId(User.Identity.Name);
                    worktask.TaskMetas = new List <WorkTaskMetas>();
                    worktask           = WorktaskService.GetInstance().loadMetaInfoFromRequest(worktask, Request);
                    worktask.loadMetaInfo(repository, accRepository);
                    // create workflow instance
                    Board            board      = this.boardRepository.Get(worktask.BoardID);
                    Workflow         wf         = board.Workflow;
                    State            firstState = wf.States.Where(s => s.Type == (int)Contain.StateType.Init).FirstOrDefault();
                    WorkflowInstance wfi        = new WorkflowInstance()
                    {
                        WorkflowID     = wf.ID,
                        CurrentStateID = (firstState != null ? firstState.ID : 0)
                    };
                    worktask.WorkflowInstance = wfi;
                    worktask.Status           = firstState.ID;
                }
                else
                {
                    worktask = WorktaskService.GetInstance().loadMetaInfoFromRequest(worktask, Request);
                    worktask.loadMetaInfo(repository, accRepository);
                    oldObject = repository.Worktasks.Where(x => x.WorktaskID == worktask.WorktaskID).FirstOrDefault();
                    oldObject = repository.Detail(oldObject.WorktaskID);
                    oldObject.loadMetaInfo(repository, accRepository);
                }
                var diff = new List <TaskHistory>();
                if (repository.SaveWorktask(worktask))
                {
                    //save history worktask when create new
                    string action = "Cập nhật";
                    if (isNew)
                    {
                        // Save data path for the new task
                        string dataPathRoot = HostingEnvironment.MapPath(WebConfigurationManager.AppSettings["DataDirectoryRoot"]);
                        string taskDataPath = Path.Combine(dataPathRoot, worktask.WorktaskID.ToString());
                        worktask.DataPath = taskDataPath;
                        Directory.CreateDirectory(taskDataPath);
                        action = "Tạo mới";
                    }
                    List <DiffInfo> diffInfos = worktask.Compare(oldObject);
                    diff = CompareObjExtensions.GenerateDiff(action, diffInfos, currentUID, worktask.WorktaskID);
                    repository.SaveHistory(diff);

                    foreach (var item in worktask.Attachment)
                    {
                        var text = String.Empty;
                        if (System.IO.File.Exists(item.StoredPath))
                        {
                            text = new TextExtractor().Extract(item.StoredPath).Text;
                        }
                        item.Metadata = text.Replace("\r", string.Empty).Replace("\n", string.Empty);
                    }
                    if (repository.SaveAttachmentFile(worktask))
                    {
                        //save history
                        diff = CompareObjExtensions.DetailedCompare(null, worktask.Attachment, currentUID, worktask.WorktaskID, isNew);
                        if (repository.SaveHistory(diff))
                        {
                            // Save Index in Elastic

                            eService.CreateSingleIndex(repository.Detail(worktask.WorktaskID));

                            TempData["message"] = string.Format("Thông tin công việc {0} lưu thành công!", worktask.Identify);
                            return(Json(new
                            {
                                taskId = worktask.WorktaskID,
                                attachment = worktask.Attachment.Select(x => new { AttachmentID = x.AttachmentID, Name = x.Name }),
                                success = true,
                                redirectUrl = Url.Action("Detail", new { taskcode = worktask.Identify })
                            }, JsonRequestBehavior.AllowGet));
                        }
                    }

                    // Save Index in Elastic
                    eService.CreateSingleIndex(repository.Detail(worktask.WorktaskID));

                    TempData["message"] = string.Format("Thông tin công việc {0} lưu thành công!", worktask.Identify);
                    return(Json(new
                    {
                        taskId = worktask.WorktaskID,
                        success = true,
                        redirectUrl = Url.Action("Detail", new { taskcode = worktask.Identify })
                    }, JsonRequestBehavior.AllowGet));
                }
                TempData["message"] = string.Format("Lưu không thành công");
                return(Json(new { taskId = 0, success = false, message = TempData["message"] }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                TempData["message"] = string.Format(GetModelErrorMessages(ModelState));
                return(Json(new { taskId = 0, success = false, message = TempData["message"] }, JsonRequestBehavior.AllowGet));
            }
        }
Пример #9
0
        public ActionResult AccountListPartial()
        {
            List <AccountViewModel> accountsList = AccountHelper.GetAccounts("", false, null, "", "");

            return(PartialView("_List", accountsList));
        }
Пример #10
0
 public ActionResult Index(AccountListModel model)
 {
     model.Accounts = AccountHelper.GetAccounts(model.SearchText, true, model.Page, model.SortColumn, model.SortDirection);
     return(View(model));
 }
Пример #11
0
    /// <summary>
    /// Reloads the data in the selector.
    /// </summary>
    public void ReloadData()
    {
        string where = null;
        bool authorizedSiteAccounts   = false;
        bool authorizedGlobalAccounts = AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false);

        currentUser = MembershipContext.AuthenticatedUser;

        if (SiteID > 0)
        {
            authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteID, false);
        }
        else
        {
            authorizedSiteAccounts = AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false);
        }

        // Filter site objects
        if (SiteID > 0)
        {
            if (authorizedSiteAccounts)
            {
                where = "(AccountSiteID = " + SiteID + " AND AccountMergedWithAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Filter only global objects
        else if ((SiteID == UniSelector.US_GLOBAL_RECORD) || (SiteID == 0))
        {
            if (authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display current site and global contacts
        else if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD)
        {
            if (authorizedSiteAccounts && authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)";
                uniSelector.AddGlobalObjectSuffix = true;
            }
            else if (authorizedGlobalAccounts)
            {
                where = "(AccountSiteID IS NULL AND AccountMergedWithAccountID IS NULL)";
            }
            else if (authorizedSiteAccounts)
            {
                where = "(AccountSiteID = " + SiteContext.CurrentSiteID + " AND AccountMergedWithAccountID IS NULL)";
            }
            else
            {
                where = "(1=0)";
            }
        }
        // Display all objects
        else if ((SiteID == UniSelector.US_ALL_RECORDS) && currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
        {
            where = "((AccountSiteID IS NULL AND AccountGlobalAccountID IS NULL) OR (AccountSiteID > 0 AND AccountMergedWithAccountID IS NULL))";
            uniSelector.AddGlobalObjectSuffix = true;
        }
        // Not enough permissions
        else
        {
            where = "(1=0)";
        }

        uniSelector.WhereCondition = SqlHelper.AddWhereCondition(WhereCondition, where);
        uniSelector.Reload(true);
    }
Пример #12
0
        public ActionResult ListByAssignedUser(string assignedTo, string mockUser = "")
        {
            if (!(Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent")))
            {
                Response.Redirect("~/Unauthorized");
                return(View());
            }

            string thisUsername = AccountHelper.getCurrentUsername();

            if (Roles.IsUserInRole("Administrator"))
            {
                if (mockUser == null || mockUser.Equals("") || !accountHelper.userExists(mockUser))
                {
                    Response.Redirect("~/Routine");
                    return(View());
                }
                else
                {
                    ViewData["mockUser"] = mockUser;

                    if (assignedTo == null || !accountHelper.userExists(assignedTo))
                    {
                        if (Roles.IsUserInRole(mockUser, "Job Coach"))
                        {
                            ViewData["Assignees"] = accountHelper.getListOfUsersAssignedToJobCoach(mockUser);
                        }
                        else if (Roles.IsUserInRole(mockUser, "Parent"))
                        {
                            ViewData["Assignees"] = accountHelper.getListOfUsersChildOfParent(mockUser);
                        }
                    }
                    else
                    {
                        ViewData["AssignedTo"] = assignedTo;
                        ViewData["Routines"]   = helper.getMostRecentRoutinesAssignedTo(mockUser, assignedTo);
                    }
                }
            }
            else //user is jobcoach or parent
            {
                if (assignedTo == null || !accountHelper.userExists(assignedTo))
                {
                    if (Roles.IsUserInRole("Job Coach"))
                    {
                        ViewData["Assignees"] = accountHelper.getListOfUsersAssignedToJobCoach(thisUsername);
                    }
                    else if (Roles.IsUserInRole("Parent"))
                    {
                        ViewData["Assignees"] = accountHelper.getListOfUsersChildOfParent(thisUsername);
                    }
                }
                else
                {
                    ViewData["AssignedTo"] = assignedTo;
                    ViewData["Routines"]   = helper.getMostRecentRoutinesAssignedTo(assignedTo);
                }
            }

            return(View());
        }
Пример #13
0
        public ActionResult Create(RoutineModel model, string mockUser = "")
        {
            if (!(Roles.IsUserInRole("Administrator") || Roles.IsUserInRole("Job Coach") || Roles.IsUserInRole("Parent")))
            {
                Response.Redirect("~/Unauthorized");
                return(View());
            }

            EnumHelper enumhelp = new EnumHelper();

            ViewData["TaskCategories"] = enumhelp.getAllTaskCategoryNames().ToList();
            ViewData["FeedbackTypes"]  = enumhelp.getAllFeedbackTypeNames().ToList();
            ViewData["MediaTypes"]     = enumhelp.getAllMediaTypeNames().ToList();

            if (Roles.IsUserInRole("Administrator"))
            {
                ViewData["mockUser"] = mockUser;
                if (Roles.IsUserInRole(mockUser, "Job Coach"))
                {
                    ViewData["Assignees"] = accountHelper.getListOfUsersAssignedToJobCoach(mockUser);
                }
                else if (Roles.IsUserInRole(mockUser, "Parent"))
                {
                    ViewData["Assignees"] = accountHelper.getListOfUsersChildOfParent(mockUser);
                }
            }
            else if (Roles.IsUserInRole("Job Coach"))
            {
                string thisUsername = AccountHelper.getCurrentUsername();
                ViewData["Assignees"] = accountHelper.getListOfUsersAssignedToJobCoach(thisUsername);
            }
            else if (Roles.IsUserInRole("Parent"))
            {
                string thisUsername = AccountHelper.getCurrentUsername();
                ViewData["Assignees"] = accountHelper.getListOfUsersChildOfParent(thisUsername);
            }

            if (!(ModelState.IsValid))
            {
                return(View(model));
            }

            if (Roles.IsUserInRole("Administrator"))
            {
                if (mockUser == null || mockUser.Equals("") || !accountHelper.userExists(mockUser))
                {
                    Response.Redirect("~/Routine");
                    return(View());
                }
                else
                {
                    if (helper.routineExists(mockUser, model.routineTitle, model.assigneeUserName))
                    {
                        ModelState.AddModelError("", "Routine must have a unique name");
                        return(View(model));
                    }

                    helper.createRoutine(mockUser, model);
                    return(RedirectToAction("List", "Routine", new { mockUser = mockUser }));
                }
            }

            if (helper.routineExists(model.routineTitle, model.assigneeUserName))
            {
                ModelState.AddModelError("", "Routine must have a unique name");
                return(View(model));
            }

            helper.createRoutine(model);

            return(RedirectToAction("List", "Routine"));
        }
Пример #14
0
    /// <summary>
    /// 
    /// </summary>
    protected void BindData()
    {
        AccountAdmin accountAdmin = new AccountAdmin();
        AccountTypeAdmin accountTypeAdmin = new AccountTypeAdmin();
        ProfileAdmin profileAdmin = new ProfileAdmin();
        CustomerAdmin customerAdmin = new CustomerAdmin();
        ReferralCommissionAdmin referralCommissionAdmin = new ReferralCommissionAdmin();

        ZNode.Libraries.DataAccess.Entities.Account account = accountAdmin.GetByAccountID(AccountID);

        if (account != null)
        {
            // General Information
            lblAccountID.Text = account.AccountID.ToString();
            lblCompanyName.Text = account.BillingCompanyName;
            lblExternalAccNumber.Text = account.ExternalAccountNo;
            lblDescription.Text = account.Description;
            lblLoginName.Text = customerAdmin.GetByUserID(int.Parse(AccountID.ToString()));
            lblCustomerDetails.Text = account.AccountID.ToString() + " - " + account.BillingFirstName + " " + account.BillingLastName;
            lblWebSite.Text = account.Website;
            lblSource.Text = account.Source;
            lblCreatedDate.Text = account.CreateDte.ToShortDateString();
            lblCreatedUser.Text = account.CreateUser;

            // Referral Detail

            // Get Referral Type Name for a Account
            if (account.ReferralCommissionTypeID != null)
            {
                ReferralCommissionType referralType = referralCommissionAdmin.GetByReferralID(int.Parse(account.ReferralCommissionTypeID.ToString()));
                lblReferralType.Text = referralType.Name;
            }
            else
            {
                lblReferralType.Text = "";
            }

            if (account.ReferralStatus == "A")
            {
                string affiliateLink = "http://" + ZNodeConfigManager.SiteConfig.DomainName + "/default.aspx?affiliate_id=" + account.AccountID;
                hlAffiliateLink.Text = affiliateLink;
                hlAffiliateLink.NavigateUrl = affiliateLink;
            }
            else
            {
                hlAffiliateLink.Text = "NA";
            }

            if (account.ReferralCommission != null)
            {
                if (account.ReferralCommissionTypeID == 1)
                {
                    lblReferralCommission.Text = account.ReferralCommission.Value.ToString("N");
                }
                else
                {
                    lblReferralCommission.Text = account.ReferralCommission.Value.ToString("c");
                }
            }
            else
            {
                lblReferralCommission.Text = "";
            }

            lblTaxId.Text = account.TaxID;

            if (account.ReferralStatus != null)
            {
                //Getting the Status Description
                Array values = Enum.GetValues(typeof(ZNodeApprovalStatus.ApprovalStatus));
                Array names=Enum.GetNames(typeof(ZNodeApprovalStatus.ApprovalStatus));
                for (int i = 0; i < names.Length; i++)
                {
                    if (names.GetValue(i).ToString() == account.ReferralStatus)
                    {
                        lblReferralStatus.Text = ZNodeApprovalStatus.GetEnumValue(values.GetValue(i));
                        break;
                    }
                }

                BindPayments(accountAdmin);
            }
            else
            {
                pnlAffiliatePayment.Visible = false;
                lblReferralStatus.Text = "";
            }

            if (account.UpdateDte != null)
            {
                lblUpdatedDate.Text = account.UpdateDte.Value.ToShortDateString();
            }

            // Email Opt-In
            if (account.EmailOptIn)
            {
                EmailOptin.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(true);
            }
            else
            {
                EmailOptin.Src = ZNode.Libraries.Framework.Business.ZNodeHelper.GetCheckMark(false);
            }

            lblUpdatedUser.Text = account.UpdateUser;
            lblCustom1.Text = account.Custom1;
            lblCustom2.Text = account.Custom2;
            lblCustom3.Text = account.Custom3;

            // Get Profile Type Name for a Account
            Profile _profileList = profileAdmin.GetByProfileID(int.Parse(account.ProfileID.ToString()));
            lblProfileTypeName.Text = _profileList.Name;

            // Address Information

            ZNodeAddress AddressFormat = new ZNodeAddress();

            // Format Billing Address
            AddressFormat.FirstName = string.IsNullOrEmpty(account.BillingFirstName) ? string.Empty : account.BillingFirstName;
            AddressFormat.LastName = string.IsNullOrEmpty(account.BillingLastName) ? string.Empty : account.BillingLastName;
            AddressFormat.CompanyName = string.IsNullOrEmpty(account.BillingCompanyName) ? string.Empty : account.BillingCompanyName;
            AddressFormat.Street1 = string.IsNullOrEmpty(account.BillingStreet) ? string.Empty : account.BillingStreet;
            AddressFormat.Street2 = string.IsNullOrEmpty(account.BillingStreet1) ? string.Empty : account.BillingStreet1;
            AddressFormat.City = string.IsNullOrEmpty(account.BillingCity) ? string.Empty : account.BillingCity;
            AddressFormat.StateCode = string.IsNullOrEmpty(account.BillingStateCode) ? string.Empty : account.BillingStateCode;
            AddressFormat.PostalCode = string.IsNullOrEmpty(account.BillingPostalCode) ? string.Empty : account.BillingPostalCode;
            AddressFormat.CountryCode = string.IsNullOrEmpty(account.BillingCountryCode) ? string.Empty : account.BillingCountryCode;
            lblBillingAddress.Text = AddressFormat.ToString() + "Tel: " + account.BillingPhoneNumber + "<br>Email: " + account.BillingEmailID;

            // Format Shipping Address
            AddressFormat.FirstName = string.IsNullOrEmpty(account.ShipFirstName) ? string.Empty : account.BillingFirstName;
            AddressFormat.LastName = string.IsNullOrEmpty(account.ShipLastName) ? string.Empty : account.ShipLastName;
            AddressFormat.CompanyName = string.IsNullOrEmpty(account.ShipCompanyName) ? string.Empty : account.ShipCompanyName;
            AddressFormat.Street1 = string.IsNullOrEmpty(account.ShipStreet) ? string.Empty : account.ShipStreet;
            AddressFormat.Street2 = string.IsNullOrEmpty(account.ShipStreet1) ? string.Empty : account.ShipStreet1;
            AddressFormat.City = string.IsNullOrEmpty(account.ShipCity) ? string.Empty : account.ShipCity;
            AddressFormat.StateCode = string.IsNullOrEmpty(account.ShipStateCode) ? string.Empty : account.ShipStateCode;
            AddressFormat.PostalCode = string.IsNullOrEmpty(account.ShipPostalCode) ? string.Empty : account.ShipPostalCode;
            AddressFormat.CountryCode = string.IsNullOrEmpty(account.ShipCountryCode) ? string.Empty : account.ShipCountryCode;
            lblShippingAddress.Text = AddressFormat.ToString() + "Tel: " + account.ShipPhoneNumber + "<br>Email: " + account.ShipEmailID;

            //To get Amount owed
            AccountHelper helperAccess = new AccountHelper();
            DataSet myDataSet = helperAccess.GetCommisionAmount(ZNodeConfigManager.SiteConfig.PortalID, account.AccountID.ToString());

            lblAmountOwed.Text = "$" + myDataSet.Tables[0].Rows[0]["CommissionOwed"].ToString();

            // Orders Grid
            this.BindGrid();

            // Retrieves the Role for User using Userid
            if (account.UserID != null)
            {
                 Guid UserKey = new Guid();
                 UserKey = account.UserID.Value;
                 MembershipUser _user = Membership.GetUser(UserKey);
                 string roleList = "";

                //Get roles for this User account
                string[] roles = Roles.GetRolesForUser(_user.UserName);

                foreach (string Role in roles)
                {
                    roleList += Role + "<br>";
                }
                lblRoles.Text = roleList;

                string rolename = roleList;

                //Hide the Edit button if a NonAdmin user has entered this page
                if(!Roles.IsUserInRole("ADMIN"))
                {
                    if (Roles.IsUserInRole(_user.UserName, "ADMIN"))
                    {
                        EditCustomer.Visible = false;
                    }
                    else if (Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "CUSTOMER SERVICE REP"))
                    {
                        if (rolename == Convert.ToString("USER<br>") || rolename == Convert.ToString(""))
                        {
                            EditCustomer.Visible = true;
                        }
                        else
                        {
                            EditCustomer.Visible = false;
                        }
                    }
                }
            }
        }
    }
Пример #15
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            HttpCookie UserCookie = Request.Cookies["SvnAuth"];

            #region 验证当前用户信息
            if (Request.Headers["Authorization"] == null || UserCookie == null)
            {
                ToAuthenticate();
            }
            else
            {
                if (Request.Headers["Authorization"] != null)
                {
                    #region 设置认证凭据
                    string strAuth = Request.Headers["Authorization"];
                    if (strAuth.StartsWith("Basic ") && strAuth.Length > 6)
                    {
                        string accountInfo = Encoding.ASCII.GetString(Convert.FromBase64String(strAuth.Substring(6)));
                        if (accountInfo.Length < 3)
                        {
                            ToAuthenticate();
                        }
                        else
                        {
                            string[] IDPair = accountInfo.Split(':');
                            if (AccountHelper.TestAuth(IDPair[0], IDPair[1]))
                            {
                                HttpCookie cookie = new HttpCookie("SvnAuth");
                                cookie.Value    = IDPair[0];
                                cookie.HttpOnly = true;
                                cookie.Secure   = Request.IsSecureConnection;
                                cookie.Path     = "/";
                                Response.Cookies.Add(cookie);
                            }
                            else
                            {
                                ToAuthenticate();
                            }
                        }
                    }
                    else
                    {
                        ToAuthenticate();
                    }
                    #endregion
                }

                try
                {
                    UserCookie = HttpSecureCookie.Decode(UserCookie);
                }
                catch (Exception)
                {
                    Response.Write("无效的Cookie信息");
                    Response.End();
                }
            }
            #endregion
        }
Пример #16
0
 private void delete_Click(object sender, System.EventArgs e)
 {
     HandleResponse(_songManagementService.DeleteSong(AccountHelper.GetInstance().Id, _selectedSong), ResourceHelper.ResourceKey.SongRemovedSuccessfully);
 }
Пример #17
0
        private void InsertOrUpdateCurrentValueToDatabase(bool isUpdate = false)
        {
            string maGiangVien  = txtMaGiangVien.Text;
            string tenGiangVien = txtTenGiangVien.Text;

            int gioiTinh;

            if (rbNam.Checked)
            {
                gioiTinh = 1;
            }
            else
            {
                gioiTinh = 0;
            }

            DateTime ngaySinh = dateNgaySinh.Value;

            string diaChi = txtDiaChi.Text;

            string SDT;

            try
            {
                int soDienThoai = int.Parse(txtSDT.Text);
                SDT = txtSDT.Text;
            }
            catch (Exception e)
            {
                DialogHelper.ShowErrorDialog("Số điện thoại nhập vào không hợp lệ!");
                return;
            }

            string email   = txtEmail.Text;
            string trinhDo = txtTrinhDo.Text;
            string bangCap = txtBangCap.Text;

            DateTime ngayVL = dateNgayVaoLam.Value;

            double heSo;

            try { heSo = double.Parse(txtHeLuong.Text); }
            catch (Exception e)
            {
                DialogHelper.ShowErrorDialog("Hệ số lương nhập vào không hợp lệ!");
                return;
            }


            // điền thiếu thì báo lỗi
            if (maGiangVien == "" ||
                tenGiangVien == "" ||
                diaChi == "" ||
                SDT == "" ||
                email == "" ||
                trinhDo == "" ||
                heSo == 0)
            {
                DialogHelper.ShowMissingField();
                return;
            }


            if (isUpdate)
            {
                var row = GetCurrentRow();
                if (row == null)
                {
                    DialogHelper.ShowMissingSelectedRow();
                    return;
                }

                string _maGVRow = row.Cells["MAGV"].Value.ToString();

                if (maGiangVien != _maGVRow)
                {
                    DialogHelper.ShowCannotModifiyPrimaryKey();
                    return;
                }
            }


            bool isSuccess = true;

            if (!isUpdate)
            {
                isSuccess = gv.insert(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), maGiangVien, tenGiangVien, gioiTinh, ngaySinh.Date, diaChi, SDT, email, trinhDo, bangCap, ngayVL.Date, heSo) == 1;
            }
            else
            {
                isSuccess = gv.update(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), maGiangVien, tenGiangVien, gioiTinh, ngaySinh.Date, diaChi, SDT, email, trinhDo, bangCap, ngayVL.Date, heSo) == 1;
            }


            if (isSuccess)
            {
                ShowTable();
                ClearField();
                return;
            }
            else
            {
                DialogHelper.ShowErrorOnUpdate();
                return;
            }
        }
Пример #18
0
        public ActionResult InsertTask2(Worktask worktask)
        {
            // NOT ModelState.IsValid
            if (!ModelState.IsValid)
            {
                TempData["message"] = string.Format(GetModelErrorMessages(ModelState));
                return(Json(new { taskId = 0, success = false, message = TempData["message"] }, JsonRequestBehavior.AllowGet));
            }

            // ModelState.IsValid
            int currentUID = AccountHelper.GetCurrentUser(User.Identity.Name).UID;
            ElasticIndexService eService = new ElasticIndexService();

            // Assign Current user AS Owner, Assignee, Reporter
            if (worktask.Owner == 0)
            {
                worktask.Owner = currentUID;
            }
            if (worktask.Assignee == 0)
            {
                worktask.Assignee = currentUID;
            }
            if (worktask.Reporter == 0)
            {
                worktask.Reporter = currentUID;
            }
            if (worktask.TaskType == 0)
            {
                worktask.TaskType = int.Parse(CategoryService.GetInstance().GetCategoryList(Contain.CatType.Category).ElementAt(1).Value);
            }
            if (worktask.Priority == 0)
            {
                worktask.Priority = int.Parse(CategoryService.GetInstance().GetCategoryList(Contain.CatType.Priority).ElementAt(1).Value);
            }

            string[] selectedtaskcodes   = Request.Params.GetValues("RelatedTaskValue[]");
            int      relatedtaskmetatype = catRepository.Categories.Where(c => c.CatType == (int)Contain.CatType.MetaType && c.CategoryName.Equals("metastring")).FirstOrDefault().CatValue;
            var      isNew = false;

            // Set relate task
            if (worktask.WorktaskID == 0)
            {
                isNew            = true;
                worktask.BoardID = this.GetLastViewedBoardId(User.Identity.Name);

                // create workflow instance
                Board            board      = this.boardRepository.Get(worktask.BoardID);
                Workflow         wf         = board.Workflow;
                State            firstState = wf.States.Where(s => s.Type == (int)Contain.StateType.Init).FirstOrDefault();
                WorkflowInstance wfi        = new WorkflowInstance()
                {
                    WorkflowID     = wf.ID,
                    CurrentStateID = (firstState != null ? firstState.ID : 0)
                };
                worktask.WorkflowInstance = wfi;
                worktask.Status           = firstState.ID;
            }

            worktask.TaskMetas = new List <WorkTaskMetas>();
            if (selectedtaskcodes != null && selectedtaskcodes.Length > 0)
            {
                foreach (string code in selectedtaskcodes)
                {
                    worktask.TaskMetas.Add(new WorkTaskMetas()
                    {
                        MetaKey   = "RelatedTask",
                        MetaValue = code,
                        MetaType  = relatedtaskmetatype
                    });
                }
            }
            else
            {
                if (!isNew)
                {
                    var oldObject = repository.Worktasks.Where(x => x.WorktaskID == worktask.WorktaskID).FirstOrDefault();
                    oldObject = repository.Detail(oldObject.WorktaskID);

                    worktask.TaskMetas = oldObject.TaskMetas;
                }
            }

            //Save data
            if (!repository.SaveWorktask(worktask))
            {
                TempData["message"] = string.Format("Lưu không thành công");
                return(Json(new { taskId = 0, success = false, message = TempData["message"] }, JsonRequestBehavior.AllowGet));
            }


            var diff = new List <TaskHistory>();

            //save history worktask when create new
            if (isNew)
            {
                // Save data path for the new task
                string dataPathRoot = HostingEnvironment.MapPath(WebConfigurationManager.AppSettings["DataDirectoryRoot"]);
                string taskDataPath = Path.Combine(dataPathRoot, worktask.WorktaskID.ToString());
                worktask.DataPath = taskDataPath;
                Directory.CreateDirectory(taskDataPath);


                diff = CompareObjExtensions.DetailedCompare(null, worktask, currentUID, worktask.WorktaskID, isNew);
            }

            repository.SaveHistory(diff);

            //Save attach files
            foreach (var item in worktask.Attachment)
            {
                var text = String.Empty;
                if (System.IO.File.Exists(item.StoredPath))
                {
                    text = new TextExtractor().Extract(item.StoredPath).Text;
                }
                item.Metadata = text.Replace("\r", string.Empty).Replace("\n", string.Empty);
            }

            if (repository.SaveAttachmentFile(worktask)) // << Cái này không save được thì có rolback không?
            {
                //save history
                diff = CompareObjExtensions.DetailedCompare(null, worktask.Attachment, currentUID, worktask.WorktaskID, isNew);
                if (!repository.SaveHistory(diff))
                {
                    TempData["message"] = string.Format("Lưu không thành công");
                    return(Json(new { taskId = 0, success = false, message = TempData["message"] }, JsonRequestBehavior.AllowGet));
                }
            }

            // Save Index in Elastic
            eService.CreateSingleIndex(repository.Detail(worktask.WorktaskID));

            TempData["message"] = string.Format("Thông tin công việc {0} lưu thành công!", worktask.Identify);
            return(Json(new
            {
                taskId = worktask.WorktaskID,
                success = true,
                redirectUrl = Url.Action("Detail", new { taskcode = worktask.Identify })
            }, JsonRequestBehavior.AllowGet));
        }
Пример #19
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            if (Vill == null)
            {
                Vill = acc.Villages.First(x => x.Active);
            }

            if (!await VillageHelper.EnterBuilding(acc, Vill, Classificator.BuildingEnum.Smithy))
            {
                return(TaskRes.Executed);
            }

            var levels = TroopsParser.GetTroopLevels(acc.Wb.Html);

            if (levels == null)
            {
                acc.Wb.Log("There was an error at getting Smithy troop levels");
                return(TaskRes.Executed);
            }
            Vill.Troops.Levels = levels;
            TroopsHelper.UpdateResearchedTroops(Vill);

            var currentlyImproving = TroopsParser.GetImprovingTroops(acc.Wb.Html);
            var troop = TroopToImprove(Vill, currentlyImproving);

            if (troop == Classificator.TroopsEnum.None)
            {
                return(TaskRes.Executed);
            }

            //If we have plus account we can improve 2 troops at the same time
            int maxImproving = acc.AccInfo.PlusAccount ? 2 : 1;

            if (maxImproving <= currentlyImproving.Count())
            {
                this.NextExecute = DateTime.Now.Add(currentlyImproving.Last().Time);
                return(TaskRes.Executed);
            }
            //call NextImprove() after enough res OR when this improvement finishes.

            var cost = Vill.Troops.Levels.FirstOrDefault(x => x.Troop == troop);

            // Check if we have enough resources to improve the troop
            if (!ResourcesHelper.IsEnoughRes(Vill, cost.UpgradeCost.ToArray()))
            {
                ResourcesHelper.NotEnoughRes(acc, Vill, cost.UpgradeCost, this);
                return(TaskRes.Executed);
            }

            //Click on the button
            var troopNode = acc.Wb.Html.DocumentNode.Descendants("img").FirstOrDefault(x => x.HasClass("u" + (int)troop));

            while (!troopNode.HasClass("research"))
            {
                troopNode = troopNode.ParentNode;
            }

            var button = troopNode.Descendants("button").FirstOrDefault(x => x.HasClass("green"));

            if (button == null)
            {
                acc.Wb.Log($"Could not find Upgrade button to improve {troop}");
                this.NextExecute = DateTime.Now.AddMinutes(1);
                return(TaskRes.Retry);
            }

            await DriverHelper.ClickById(acc, button.Id);

            // If we have plus account and there is currently no other troop to improve, go ahead and improve the unit again
            this.NextExecute = (currentlyImproving.Count() == 0 && maxImproving == 2) ?
                               DateTime.MinValue :
                               DateTime.Now.Add(cost.TimeCost).AddMilliseconds(5 * AccountHelper.Delay());
            return(TaskRes.Executed);
        }
Пример #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Id      = Int32.Parse(Request.QueryString["id"]);
     account = AccountHelper.GetUser(Id);
 }
Пример #21
0
        protected void CalculateSafeLevel()
        {
            Account currUser
                = AccountHelper.GetAccount(Security.CurrentAccountID, new string[] { "FirstName", "MiddleName", "LastName", "Photo", "EmailValidate" });
            int level = 0;

            if (currUser.EmailValidate == 1)
            {
                level += 20;
            }
            if (!string.IsNullOrEmpty(currUser.FirstName + currUser.MiddleName + currUser.LastName))
            {
                level += 20;
            }
            if (!string.IsNullOrEmpty(currUser.Photo))
            {
                level += 20;
            }
            string informationUrl = "/User/AccountEdit.aspx";

            //AdvanceUserModel advanceUser = BaseMethod.GetAdvanceUserModelByUserID(Security.CurrentAccountID);
            //if (advanceUser != null && !string.IsNullOrEmpty(advanceUser.CardID))
            //{
            //    level += 20;
            //    if (!string.IsNullOrEmpty(advanceUser.Telphone) && !string.IsNullOrEmpty(advanceUser.Mobile) && !string.IsNullOrEmpty(advanceUser.QQ) && !string.IsNullOrEmpty(advanceUser.MSN))
            //    {
            //        level += 20;
            //    }
            //    else
            //    {
            //        informationUrl = "/Plugins/ShopPlugin/UI/Register_Mall.aspx";
            //    }
            //    IsAdvanceUser = true;
            //    SafePWDUrl = "/Plugins/ShopPlugin/UI/ChangeTradePWD.aspx";
            //}
            //else
            //{
            //    IsAdvanceUser = false;
            //    SafePWDUrl = "/Plugins/ShopPlugin/UI/Register_Mall.aspx";
            //}
            InfomationHref   = informationUrl;
            InfomationNumber = level;
            if (level <= 40)
            {
                InfomationClass = "hot";
            }
            else if (level <= 80)
            {
                InfomationClass = "yel";
            }
            else
            {
                InfomationClass = "";
            }

            CertText  = (currUser.EmailValidate == 1) ? "已认证" : "未认证";
            CertClass = (currUser.EmailValidate == 1) ? "Green" : "orange1";

            int safeLevel = (currUser.EmailValidate == 1) ? 80 : 60;

            AccountSafeLevelNumber = safeLevel;

            if (safeLevel <= 60)
            {
                AccountSafeLevel      = "低";
                AccountSafeLevelClass = "hot";
            }
            else
            {
                AccountSafeLevel      = "高";
                AccountSafeLevelClass = "";
            }
        }
        private EPasaErrorCode TryCompile(EPasaNode epasaNode, EPasa epasa)
        {
            EPasaErrorCode TryCompileAccount(AccountNode accountNode)
            {
                switch (accountNode.Type)
                {
                case TokenType.AccountName:
                    if (!Pascal64Encoding.IsValidEscaped(accountNode.Name.Value))
                    {
                        return(EPasaErrorCode.InvalidAccountName);
                    }
                    epasa.AccountName = Pascal64Encoding.Unescape(accountNode.Name.Value);
                    epasa.PayloadType = epasa.PayloadType.SetFlags(PayloadType.AddressedByName);
                    break;

                case TokenType.AccountNumber:
                    if (!uint.TryParse(accountNode.AccountNo.Value, out var accNo))
                    {
                        return(EPasaErrorCode.BadFormat);
                    }
                    if (accountNode.AccountNo.Value.StartsWith("0") && accNo != 0)
                    {
                        return(EPasaErrorCode.BadFormat);
                    }
                    epasa.Account = accNo;
                    var actualChecksum = AccountHelper.CalculateAccountChecksum(accNo);
                    if (accountNode.Checksum != null)
                    {
                        if (!uint.TryParse(accountNode.Checksum.Value, out var checksum))
                        {
                            return(EPasaErrorCode.BadFormat);
                        }
                        if (checksum != actualChecksum)
                        {
                            return(EPasaErrorCode.AccountChecksumInvalid);
                        }
                    }
                    epasa.AccountChecksum = actualChecksum;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(accountNode));
                }
                return(EPasaErrorCode.Success);
            }

            EPasaErrorCode TryCompilePayload(PayloadNode payloadNode)
            {
                epasa.PayloadType = epasa.PayloadType | payloadNode.Encryption;
                if (payloadNode.Content != null)
                {
                    switch (payloadNode.Content.Type)
                    {
                    case TokenType.PascalAsciiString:
                        epasa.PayloadType = epasa.PayloadType | PayloadType.AsciiFormatted;
                        epasa.Payload     = PascalAsciiEncoding.Unescape(payloadNode.Content.Value);
                        break;

                    case TokenType.Base58String:
                        epasa.PayloadType = epasa.PayloadType | PayloadType.Base58Formatted;
                        epasa.Payload     = payloadNode.Content.Value;
                        break;

                    case TokenType.HexString:
                        epasa.PayloadType = epasa.PayloadType | PayloadType.HexFormatted;
                        epasa.Payload     = payloadNode.Content.Value;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(payloadNode.Content.Type));
                    }
                    if (!EPasaHelper.IsValidPayloadLength(epasa.PayloadType, epasa.Payload))
                    {
                        return(EPasaErrorCode.PayloadTooLarge);
                    }
                }
                if (payloadNode.Password != null)
                {
                    if (!EPasaHelper.IsValidPasswordLength(payloadNode.Password.Value))
                    {
                        return(EPasaErrorCode.InvalidPassword);
                    }
                    epasa.Password = PascalAsciiEncoding.Unescape(payloadNode.Password.Value);
                }
                return(EPasaErrorCode.Success);
            }

            EPasaErrorCode TryCompileExtendedChecksum(ValueNode extendedChecksumNode)
            {
                var actualExtendedChecksum = EPasaHelper.ComputeExtendedChecksum(epasa.ToString(true));

                if (extendedChecksumNode != null && extendedChecksumNode.Value != actualExtendedChecksum)
                {
                    return(EPasaErrorCode.AccountChecksumInvalid);
                }
                epasa.ExtendedChecksum = actualExtendedChecksum;
                return(EPasaErrorCode.Success);
            }

            var result = TryCompileAccount(epasaNode.Account);

            if (result != EPasaErrorCode.Success)
            {
                return(result);
            }
            if (epasaNode.Payload != null)
            {
                result = TryCompilePayload(epasaNode.Payload);
                if (result != EPasaErrorCode.Success)
                {
                    return(result);
                }
            }
            result = TryCompileExtendedChecksum(epasaNode.ExtendedChecksum);
            if (result != EPasaErrorCode.Success)
            {
                return(result);
            }

            return(result);
        }
Пример #23
0
 private void Page_Load(object sender, EventArgs e)
 {
     // Check permission read
     AccountHelper.AuthorizedReadAccount(Account.AccountSiteID, true);
 }
Пример #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set title
        CurrentMaster.Title.TitleText = GetString("om.contact.collision");
        CurrentMaster.Title.TitleImage = GetImageUrl("CMSModules/CMS_ContactManagement/collisiondialog.png");
        CurrentMaster.Title.HelpTopicName = "account_collision";
        CurrentMaster.Title.HelpName = "helpTopic";

        // Validate hash
        Regex re = RegexHelper.GetRegex(@"[\w\d_$$]*");
        identifier = QueryHelper.GetString("params", "");
        if (!QueryHelper.ValidateHash("hash") || !re.IsMatch(identifier))
        {
            pnlContent.Visible = false;
            return;
        }

        // Load dialog parameters
        Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier.ToString());
        if (parameters != null)
        {
            mergedAccounts = (DataSet)parameters["MergedAccounts"];
            parentAccount = (AccountInfo)parameters["ParentAccount"];
            isSitemanager = ValidationHelper.GetBoolean(parameters["issitemanager"], false);

            if (isSitemanager)
            {
                stamp = SettingsKeyProvider.GetStringValue("CMSCMStamp");
            }
            else
            {
                stamp = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSCMStamp");
            }

            stamp = CMSContext.CurrentResolver.ResolveMacros(stamp);

            if (parentAccount != null)
            {
                // Check permissions
                AccountHelper.AuthorizedReadAccount(parentAccount.AccountSiteID, true);

                // Load data
                if (!RequestHelper.IsPostBack())
                {
                    Initialize();
                }
                LoadContactCollisions();
                LoadContactGroups();
                LoadCustomFields();

                // Init controls
                btnMerge.Click += new EventHandler(btnMerge_Click);
                btnCancel.Attributes.Add("onclick", "return CloseDialog();");
                btnStamp.OnClientClick = "AddStamp('" + htmlNotes.CurrentEditor.ClientID + "'); return false;";
                ScriptHelper.RegisterTooltip(Page);
                RegisterScripts();
                accountStatusSelector.SiteID = parentAccount.AccountSiteID;
                accountSelector.SiteID = parentAccount.AccountSiteID;
                accountSelector.WhereCondition = "((AccountMergedWithAccountID IS NULL) AND (AccountSiteID > 0)) OR ((AccountGlobalAccountID IS NULL) AND (AccountSiteID IS NULL))";
                accountSelector.WhereCondition = GetSubsidiaryWhere(accountSelector.WhereCondition);
                accountStatusSelector.IsSiteManager = isSitemanager;

                // Set groupping text
                pnlGeneral.GroupingText = GetString("general.general");
                pnlAddress.GroupingText = GetString("general.address");
                pnlNotes.GroupingText = GetString("om.contact.notes");

                // Set tabs
                tabFields.HeaderText = GetString("om.contact.fields");
                tabContacts.HeaderText = GetString("om.contact.list");
                tabContactGroups.HeaderText = GetString("om.contactgroup.list");
                tabCustomFields.HeaderText = GetString("general.customfields");
            }
        }

        // User relative messages placeholder so that JQueryTab isn't moved a bit
        MessagesPlaceHolder.UseRelativePlaceHolder = false;

        // Do not let the editor overflow dialog window
        htmlNotes.SetValue("width", "520");
    }
Пример #25
0
    private void OnTabCreated(object sender, TabCreatedEventArgs e)
    {
        if (e.Tab == null)
        {
            return;
        }

        switch (e.Tab.TabName.ToLowerCSafe())
        {
        case "account.customfields":
            // Check if contact has any custom fields
            var formInfo = FormHelper.GetFormInfo("OM.Account", false);
            if (!formInfo.GetFields(true, false, false).Any())
            {
                e.Tab = null;
            }
            break;

        case "account.contacts":
            // Display contacts tab only if user is authorized to read contacts
            if (!ContactHelper.AuthorizedReadContact(Account.AccountSiteID, false) && !AccountHelper.AuthorizedReadAccount(Account.AccountSiteID, false))
            {
                e.Tab = null;
            }
            break;

        case "account.merge":
        case "account.subsidiaries":
            if (Account.AccountMergedWithAccountID != 0)
            {
                e.Tab = null;
            }
            break;
        }
    }
Пример #26
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            var wb = acc.Wb.Driver;
            await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/build.php?tt=99&id=39");

            var flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);

            // If there is no rally point, switch to different village
            if (flNode == null)
            {
                var mainVill = AccountHelper.GetMainVillage(acc);
                if (mainVill == this.Vill)
                {
                    return(TaskRes.Executed);                       // No gold account?
                }
                await VillageHelper.SwitchVillage(acc, mainVill.Id);

                flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);
                if (flNode == null)
                {
                    return(TaskRes.Retry);
                }
            }

            if (acc.Farming.TrainTroopsAfterFL) // For TTWars servers
            {
                TaskExecutor.AddTask(acc, new TrainTroops()
                {
                    ExecuteAt       = DateTime.Now.AddSeconds(2),
                    Troop           = Vill.Troops.TroopToTrain ?? Classificator.TroopsEnum.Hero,
                    Vill            = this.Vill,
                    HighSpeedServer = true
                });
            }

            // If FL is collapsed, expand it
            if (acc.AccInfo.ServerVersion == ServerVersionEnum.T4_4 ||
                flNode.Descendants("div").Any(x => x.HasClass("expandCollapse") && x.HasClass("collapsed")))
            {
                await DriverHelper.ExecuteScript(acc, $"Travian.Game.RaidList.toggleList({this.FL.Id});");

                // Update flNode!
                flNode = GetFlNode(acc.Wb.Html, acc.AccInfo.ServerVersion);
            }

            foreach (var farm in flNode.Descendants("tr").Where(x => x.HasClass("slotRow")))
            {
                //iReport2 = yellow swords, iReport3 = red swords, iReport1 = successful raid
                var img = farm.ChildNodes.FirstOrDefault(x => x.HasClass("lastRaid"))?.Descendants("img");

                //there has to be an image (we already have a report) and wrong raid style to not check this farmlist:
                if (img.Count() != 0 && (                                                                                            //no image -> no recent attack
                        (img.FirstOrDefault(x => x.HasClass("iReport3")) != null && this.FL.RaidStyle != RaidStyle.RaidLost) || //raid was lost and we don't have RaidLost raidstyle
                        (img.FirstOrDefault(x => x.HasClass("iReport2")) != null && (this.FL.RaidStyle == RaidStyle.RaidSuccessful)) //some casualities, but we only attack on successful
                        ))
                {
                    continue;
                }

                var checkbox = farm.Descendants("input").FirstOrDefault(x => x.HasClass("markSlot"));
                var str      = $"document.getElementById('{checkbox.Id}').checked=true";
                wb.ExecuteScript(str); //Check the checkbox
            }

            await Task.Delay(AccountHelper.Delay() * 2);

            switch (acc.AccInfo.ServerVersion)
            {
            case ServerVersionEnum.T4_4:
                var sendFlScript = $"document.getElementById('{flNode.Id}').childNodes[1].submit()";
                wb.ExecuteScript(sendFlScript);
                break;

            case ServerVersionEnum.T4_5:
                var startRaid = flNode.Descendants("button").FirstOrDefault(x => x.HasClass("startButton"));
                acc.Wb.Driver.FindElementById(startRaid.Id).Click();
                break;
            }

            acc.Wb.Log($"FarmList '{this.FL.Name}' was sent");
            return(TaskRes.Executed);
        }
Пример #27
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            await base.Execute(acc); // Navigate to dorf2

            var building = Vill.Build.Buildings
                           .FirstOrDefault(x =>
                                           x.Type == Classificator.BuildingEnum.Residence ||
                                           x.Type == Classificator.BuildingEnum.Palace ||
                                           x.Type == Classificator.BuildingEnum.CommandCenter
                                           );

            if (building == null)
            {
                acc.Wb.Log($"Can't train settlers, there is no Residence/Palace/CommandCenter in this village!");
                return(TaskRes.Executed);
            }

            await acc.Wb.Navigate($"{acc.AccInfo.ServerUrl}/build.php?s=1&id={building.Id}");

            var settler   = TroopsHelper.TribeSettler(acc.AccInfo.Tribe);
            var troopNode = acc.Wb.Html.DocumentNode.Descendants("img").FirstOrDefault(x => x.HasClass("u" + (int)settler));

            if (troopNode == null)
            {
                acc.Wb.Log("No new settler can be trained, probably because 3 settlers are already (being) trained");
                SendSettlersTask(acc);
                return(TaskRes.Executed);
            }

            while (!troopNode.HasClass("details"))
            {
                troopNode = troopNode.ParentNode;
            }

            var maxNum    = Parser.RemoveNonNumeric(troopNode.ChildNodes.First(x => x.Name == "a").InnerText);
            var available = TroopsParser.ParseAvailable(troopNode);

            var costNode = acc.Wb.Html.DocumentNode.Descendants("div").FirstOrDefault(x => x.HasClass("resourceWrapper"));
            var cost     = ResourceParser.GetResourceCost(costNode);

            if (!ResourcesHelper.IsEnoughRes(Vill, cost.ToArray()))
            {
                ResourcesHelper.NotEnoughRes(acc, Vill, cost, this);
                return(TaskRes.Executed);
            }

            acc.Wb.Driver.ExecuteScript($"document.getElementsByName('t10')[0].value='{maxNum}'");
            await Task.Delay(AccountHelper.Delay());

            // Click Train button
            await TbsCore.Helpers.DriverHelper.ExecuteScript(acc, "document.getElementById('s1').click()");

            Vill.Troops.Settlers = (int)available + (int)maxNum;

            var training = TroopsHelper.TrainingDuration(acc.Wb.Html);

            if (training < DateTime.Now)
            {
                training = DateTime.Now;
            }

            if (Vill.Troops.Settlers < 3)
            {
                //In 1 minute, do the same task (to get total of 3 settlers)
                this.NextExecute = training.AddSeconds(3);
            }
            else
            {
                if (acc.NewVillages.AutoSettleNewVillages)
                {
                    SendSettlersTask(acc);
                }
            }
            return(TaskRes.Executed);
        }
Пример #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Account != null)
        {
            // Current account is global object
            if (Account.AccountSiteID == 0)
            {
                mFilter.SiteID = SiteContext.CurrentSiteID;
                // Display site selector in site manager
                if (ContactHelper.IsSiteManager)
                {
                    mFilter.DisplaySiteSelector = true;
                    mFilter.SiteID = UniSelector.US_GLOBAL_RECORD;
                }
                // Display 'site or global' selector in CMS desk for global objects
                else if (AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false))
                {
                    mFilter.DisplayGlobalOrSiteSelector = true;
                }
                mFilter.HideMergedIntoGlobal = true;
            }
            else
            {
                mFilter.SiteID = Account.AccountSiteID;
            }
            mFilter.ShowGlobalStatuses =
                ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) &&
                (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager);
            gridElem.WhereCondition = mFilter.WhereCondition;
            gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "AccountID <> " + Account.AccountID);
            gridElem.ZeroRowsText   = GetString("om.account.noaccountsfound");

            btnMergeSelected.Click += btnMergeSelected_Click;
            btnMergeAll.Click      += btnMergeAll_Click;

            if (Request[Page.postEventArgumentID] == "saved")
            {
                ShowConfirmation(GetString("om.account.merging"));

                // Clear selected items
                gridElem.ResetSelection();
            }
        }
        else
        {
            StopProcessing = true;
            Visible        = false;
        }
    }
Пример #29
0
 protected void formCustomFields_OnBeforeSave(object sender, EventArgs e)
 {
     // Check modify permissions
     AccountHelper.AuthorizedModifyAccount(siteId, true);
 }
Пример #30
0
    /// <summary>
    /// Bind Account Details
    /// </summary>
    private void BindData()
    {
        ZNode.Libraries.Admin.AccountAdmin _UserAccountAdmin = new ZNode.Libraries.Admin.AccountAdmin();
        ZNode.Libraries.DataAccess.Entities.Account _UserAccount = _UserAccountAdmin.GetByAccountID(AccountID);//new Account();

        if (_UserAccount != null)
        {
            //General Information
            txtExternalAccNumber.Text = _UserAccount.ExternalAccountNo;
            txtCompanyName.Text = _UserAccount.CompanyName;
            if (ListProfileType.SelectedIndex != -1)
            {
                ListProfileType.SelectedValue = _UserAccount.ProfileID.ToString();
            }

            txtWebSite.Text = _UserAccount.Website;
            txtSource.Text = _UserAccount.Source;

            //Description
            txtDescription.Text = _UserAccount.Description;

            //Login Info
            if (_UserAccount.UserID.HasValue)
            {
                UserID.Enabled = false;

                MembershipUser _user = Membership.GetUser(_UserAccount.UserID.Value);
                UserID.Text = _user.UserName;
                ddlSecretQuestions.Text = _user.PasswordQuestion;

                string roleList = "";
                //Get roles for this User account
                string[] roles = Roles.GetRolesForUser(_user.UserName);

                foreach (string Role in roles)
                {
                    roleList += Role + "<br>";
                    //Loop through the roles list
                    foreach (ListItem li in RolesCheckboxList.Items)
                    {
                        if (li.Text == Role)
                        {
                            li.Selected = true;
                        }

                        //Admin User should not remove the Admin role from their own account.
                        if (HttpContext.Current.User.Identity.Name.Equals(_user.UserName.ToLower()) && li.Text == "ADMIN")
                        {
                            li.Enabled = false;
                        }
                    }
                }

                string rolename = roleList;

                //Hide the Submit button if a NonAdmin user has entered this page
                if (!Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "ADMIN"))
                {
                    if (Roles.IsUserInRole(_user.UserName, "ADMIN"))
                    {
                        btnSubmitTop.Visible = false;
                        Submit.Visible = false;
                    }
                    else if (Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "CUSTOMER SERVICE REP"))
                    {
                        if (rolename == Convert.ToString("USER<br>") || rolename == Convert.ToString(""))
                        {
                            btnSubmitTop.Visible = true;
                            Submit.Visible = true;
                        }
                        else
                        {
                            btnSubmitTop.Visible = false;
                            Submit.Visible = false;
                        }
                    }
                }
            }

            //Billing Address

            //set field values
            txtBillingFirstName.Text = _UserAccount.BillingFirstName;
            txtBillingLastName.Text = _UserAccount.BillingLastName;
            txtBillingCompanyName.Text = _UserAccount.BillingCompanyName;
            txtBillingStreet1.Text = _UserAccount.BillingStreet;
            txtBillingStreet2.Text = _UserAccount.BillingStreet1;
            txtBillingCity.Text = _UserAccount.BillingCity;
            txtBillingState.Text = _UserAccount.BillingStateCode;
            txtBillingPostalCode.Text = _UserAccount.BillingPostalCode;

            if (_UserAccount.BillingCountryCode.Length > 0)
            {
                lstBillingCountryCode.SelectedValue = _UserAccount.BillingCountryCode;
            }

            txtBillingPhoneNumber.Text = _UserAccount.BillingPhoneNumber;
            txtBillingEmail.Text = _UserAccount.BillingEmailID;
            chkOptIn.Checked = _UserAccount.EmailOptIn;

            //Shipping Address

            //set field values
            txtShippingFirstName.Text = _UserAccount.ShipFirstName;
            txtShippingLastName.Text = _UserAccount.ShipLastName;
            txtShippingCompanyName.Text = _UserAccount.ShipCompanyName;
            txtShippingStreet1.Text = _UserAccount.ShipStreet;
            txtShippingStreet2.Text = _UserAccount.ShipStreet1;
            txtShippingCity.Text = _UserAccount.ShipCity;
            txtShippingState.Text = _UserAccount.ShipStateCode;
            txtShippingPostalCode.Text = _UserAccount.ShipPostalCode;

            //Referral Details
            if (_UserAccount.ReferralCommissionTypeID != null)
            {
                lstReferral.SelectedValue = _UserAccount.ReferralCommissionTypeID.ToString();
            }
            if (_UserAccount.ReferralCommission != null)
            {
                Discount.Text = _UserAccount.ReferralCommission.Value.ToString("N");
                discountAmount = Convert.ToDecimal(_UserAccount.ReferralCommission);
            }
            if (_UserAccount.ReferralStatus != null)
                lstReferralStatus.SelectedValue = _UserAccount.ReferralStatus;
            else
                lstReferralStatus.SelectedValue = _UserAccount.ReferralStatus;

            if (_UserAccount.ReferralStatus == "A")
            {
                string affiliateLink = "http://" + ZNodeConfigManager.SiteConfig.DomainName + "/default.aspx?affiliate_id=" + _UserAccount.AccountID;
                hlAffiliateLink.Text = affiliateLink;
                hlAffiliateLink.NavigateUrl = affiliateLink;
            }
            else
            {
                hlAffiliateLink.Text = "NA";
            }
            ToggleDiscountValidator();
            txtTaxId.Text = _UserAccount.TaxID;

            AccountHelper helperAccess = new AccountHelper();
            DataSet MyDataSet = helperAccess.GetCommisionAmount(ZNodeConfigManager.SiteConfig.PortalID, AccountID.ToString());

            lblAmountOwed.Text ="$" +  MyDataSet.Tables[0].Rows[0]["CommissionOwed"].ToString();

            if (_UserAccount.ShipCountryCode.Length > 0)
            {
                lstShippingCountryCode.SelectedValue = _UserAccount.ShipCountryCode;
            }

            txtShippingPhoneNumber.Text = _UserAccount.ShipPhoneNumber;
            txtShippingEmail.Text = _UserAccount.ShipEmailID;

            //Custom properties
            txtCustom1.Text = _UserAccount.Custom1;
            txtCustom2.Text = _UserAccount.Custom2;
            txtCustom3.Text = _UserAccount.Custom3;

        }
    }
Пример #31
0
 public ActionResult LogOff()
 {
     AccountHelper.Logout(HttpContext);
     return(View());
 }
Пример #32
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Params["itemid"] != null)
        {
            ItemId = int.Parse(Request.Params["itemid"].ToString());
        }
        else
        {
            ItemId = 0;
        }

        if (Request.Params["accId"] != null)
        {
            AccountId = int.Parse(Request.Params["accId"].ToString());
        }
        else
        {
            // Throw error here
        }

        if (ItemId > 0)
        {
            lblTitle.Text = "Edit Payment";
        }
        AccountHelper helperAccess = new AccountHelper();
        DataSet MyDataSet = helperAccess.GetCommisionAmount(ZNodeConfigManager.SiteConfig.PortalID, AccountId.ToString());

        lblAmountOwed.Text = "$" + MyDataSet.Tables[0].Rows[0]["CommissionOwed"].ToString();
    }
Пример #33
0
 private void add_Click(object sender, System.EventArgs e)
 {
     HandleResponse(_songManagementService.AddBandSong(AccountHelper.GetInstance().Id, (songList.SelectedItem as BaseViewModel).Id), ResourceHelper.ResourceKey.SongAddedSuccessfully);
 }