private async Task UpdateAccountGroupsAsync(IEnumerable <AccountGroupSyncDTO> accountGroups)
        {
            if (accountGroups == null || !accountGroups.Any())
            {
                return;
            }

            foreach (var accountGroup in accountGroups)
            {
                var userId = (await this.userRepository.GetFirstUserAsync()).Id;
                var accountGroupToUpdate = await this.accountGroupRepository.GetAccountGroupAsync(accountGroup.ExternalId);

                if (accountGroupToUpdate != null)
                {
                    if (accountGroupToUpdate.ModifiedOn < accountGroup.ModifiedOn)
                    {
                        accountGroupToUpdate.Edit(accountGroup.Name, userId);
                        accountGroupToUpdate.Delete(accountGroup.IsDeleted);
                        accountGroupToUpdate.SetModifiedOn(accountGroup.ModifiedOn);
                        await this.accountGroupRepository.UpdateAsync(accountGroupToUpdate);
                    }
                }
                else
                {
                    var accounGroupToAdd = AccountGroup.Create(accountGroup.Name, userId, accountGroup.ExternalId);
                    accounGroupToAdd.Delete(accountGroup.IsDeleted);
                    accounGroupToAdd.SetModifiedOn(accountGroup.ModifiedOn);
                    await this.accountGroupRepository.AddAccountGroupAsync(accounGroupToAdd);
                }
            }
        }
Ejemplo n.º 2
0
 public static void ConfigureAppModel(this ModelBuilder builder)
 {
     AppUserProfile.ConfigureFluent(builder);
     AppUserBank.ConfigureFluent(builder);
     AppUserRole.ConfigureFluent(builder);
     AppUserFile.ConfigureFluent(builder);
     Bank.ConfigureFluent(builder);
     Country.ConfigureFluent(builder);
     State.ConfigureFluent(builder);
     LGA.ConfigureFluent(builder);
     Staff.ConfigureFluent(builder);
     Supplier.ConfigureFluent(builder);
     BillPayable.ConfigureFluent(builder);
     BillReceivable.ConfigureFluent(builder);
     Journal.ConfigureFluent(builder);
     JournalLineItem.ConfigureFluent(builder);
     Payment.ConfigureFluent(builder);
     Receipt.ConfigureFluent(builder);
     PayableWorkFlow.ConfigureFluent(builder);
     ReceivableWorkFlow.ConfigureFluent(builder);
     AccountGroup.ConfigureFluent(builder);
     AccountSubType.ConfigureFluent(builder);
     LineItem.ConfigureFluent(builder);
     BankAccount.ConfigureFluent(builder);
     AppData.ConfigureFluent(builder);
 }
Ejemplo n.º 3
0
        public static void LoadUnlocked(AccountGroup g, IEnumerable <RawSimpleEntity> members)
        {
            var entities = new Dictionary <Guid, Entity>();
            var deserializedRawEntities = members
                                          .Select(m => new KeyValuePair <RawSimpleEntity, SerializableEntity>(m, LoadEntity(m)))
                                          .ToArray();

            foreach (var e in deserializedRawEntities)
            {
                var login = LoadLogin(e.Key, e.Value);
                if (login != null)
                {
                    g.Logins.Add(login);
                    entities[login.Guid] = login;
                }
                var target = LoadTarget(e.Key, e.Value);
                if (target != null)
                {
                    entities[target.Guid] = target;
                }
            }
            foreach (var e in deserializedRawEntities)
            {
                var account = LoadAccount(e.Key, e.Value, entities);
                if (account != null)
                {
                    g.Accounts.Add(account);
                }
            }
        }
        public int InitDatabase()
        {
            List <Administrator> list = db.Administrators.ToList();

            if (list.Count == 0)
            {
                //---------------------------------------------初始化超级管理员
                Administrator _admin = new Administrator()
                {
                    Admin_Name = "administrator",
                    Admin_Pwd  = "123456",
                };
                db.Administrators.Add(_admin);
                //---------------------------------------------新增根区域
                Area _area = new Area()
                {
                    Ar_Name  = "默认区域",
                    Ar_Admin = 1,
                };
                db.Areas.Add(_area);


                //---------------------------------------------新增根区域
                AccountGroup _acgp = new AccountGroup()
                {
                    Ag_Name = "默认列表",
                };
                db.AccountGroups.Add(_acgp);
                //---------------------------------------------更新表
                db.SaveChanges();
            }
            return(0);
        }
Ejemplo n.º 5
0
        public void Delete(AccountGroup entity)
        {
            AccountGroup groupToUpdate = GetById(entity.Id);

            context.AccountGroups.Remove(groupToUpdate);
            context.SaveChanges();
        }
Ejemplo n.º 6
0
 public ActionResult Edit(AccountGroup item)
 {
     if (ModelState.IsValid)
     {
         var error = AccountGroupDbContext.getInstance().edit(item);
         if (error != null)
         {
             ModelState.AddModelError("", error);
             ViewBag.AccessibleCategoryList = getAccessibleCategories(item.AccessibleCategories);
             return(View(item));
         }
         else
         {
             ModelState.Clear();
             ViewBag.AccessibleCategoryList = getAccessibleCategories(item.AccessibleCategories);
             ViewBag.Message = "Edit '" + item.Name + "' successfully";
             return(View(item));
         }
     }
     else
     {
         ViewBag.AccessibleCategoryList = getAccessibleCategories(item.AccessibleCategories);
         return(View(item));
     }
 }
Ejemplo n.º 7
0
        public void SaveChangesDealerFealdInAccountGroup()
        {
            var accGroup = new AccountGroup
            {
                SessionName    = "TestSessionName",
                SenderCompId   = "TestSenderCompId",
                HedgingAccount = "TestHedgingAccount",
                MessageQueue   = "TestMessageQueue"
            };

            using (var ctx = DatabaseContext.Instance.Make())
            { accGroup.Code = ctx.DEALER_GROUP.First().ACCOUNT_GROUP.Code; }

            var resultUpdate = dealerRepository.SaveChangesDealerFealdInAccountGroup(accGroup);

            Assert.IsTrue(resultUpdate);

            using (var ctx = DatabaseContext.Instance.Make())
            {
                var actualDealer = ctx.DEALER_GROUP.First();
                Assert.AreEqual("TestSessionName", actualDealer.SessionName);
                Assert.AreEqual("TestSenderCompId", actualDealer.SenderCompId);
                Assert.AreEqual("TestHedgingAccount", actualDealer.HedgingAccount);
                Assert.AreEqual("TestMessageQueue", actualDealer.MessageQueue);
            }

            accGroup.SessionName = "FaileSessionName";
            DatabaseContext.InitializeFake(exceptionConnectionPersistent);
            Assert.IsFalse(dealerRepository.SaveChangesDealerFealdInAccountGroup(accGroup));
        }
Ejemplo n.º 8
0
        private void FormMainWindow_Load(object sender, EventArgs e)
        {
            //窗口载入
            label_userName.Text = UserClient.UserAccount.UserName;
            label_grade.Text    = AccountGrade.GetDescription(UserClient.UserAccount.Grade);
            label_factory.Text  = UserClient.UserAccount.Factory;
            label_register.Text = UserClient.UserAccount.RegisterTime.ToString();
            label_last.Text     = UserClient.UserAccount.LastLoginTime.ToString();
            label_times.Text    = UserClient.UserAccount.LoginFrequency.ToString();
            label_address.Text  = UserClient.UserAccount.LastLoginIpAddress;
            label_group.Text    = AccountGroup.GetAccountDescription(UserClient.UserAccount.GroupCode);

            //绑定事件,仅执行一次,不能放到show方法里
            net_socket_client.MessageAlerts += Net_socket_client_MessageAlerts;
            net_socket_client.LoginFailed   += Net_socket_client_LoginFailed;
            net_socket_client.LoginSuccess  += Net_socket_client_LoginSuccess;
            net_socket_client.AcceptByte    += Net_socket_client_AcceptByte;
            net_socket_client.AcceptString  += Net_socket_client_AcceptString;
            //启动网络服务
            Net_Socket_Client_Initialization();

            label_Announcement.Text = UserClient.Announcement;

            toolStripStatusLabel1.Text = $"本软件著作权归{Resource.StringResouce.SoftCopyRight}所有";

            toolStripStatusLabel_Version.Text = UserClient.CurrentVersion.ToString();
        }
Ejemplo n.º 9
0
        public ActionResult _CreateGroup()
        {
            AccountGroup accountgroup = new AccountGroup();

            ViewBag.AccountCategoryID = new SelectList(db.AccountCategorys, "AccountCategoryID", "Name");
            return(PartialView(accountgroup));
        }
Ejemplo n.º 10
0
        public ActionResult _CreateGroupFor([Bind(Include = "AccountGroupID,Name,AccountCategoryID")] AccountGroup accountgroup)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            if (ModelState.IsValid)
            {
                AccountGroup exist = db.AccountGroups.Where(c => c.Name == accountgroup.Name).FirstOrDefault();
                if (exist != null)
                {
                    Session["err"] = "Group already exists";
                    data.message   = Session["err"].ToString();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }

                db.AccountGroups.Add(accountgroup);
                db.SaveChanges();

                ModelState.Clear();

                Session["err"] = "";
                Session["msg"] = "Created Successfully";
            }
            data.message = "/AccountHead/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public void AddAdminUserInBD(string LogIn)
        {
            var account = new Account {
                Login       = LogIn,
                EnabledEnum = UserStatus.Active,
                UserType    = TypeUsers.ControlPanelUser,
                Appointment = ""
            };

            DB.Account.Add(account);
            DB.SaveChanges();

            string AdminGroup = ConfigurationManager.AppSettings["AdminGroupName"];

            var GroupExsist = DB.AccountGroup.Any(xxx => xxx.Name == AdminGroup && xxx.TypeGroup == (sbyte)TypeUsers.ControlPanelUser);

            if (GroupExsist)
            {
                var Group = DB.AccountGroup.Where(xxx => xxx.Name == AdminGroup && xxx.TypeGroup == (sbyte)TypeUsers.ControlPanelUser).First();
                Group.Account.Add(account);
            }
            else
            {
                var Group = new AccountGroup();
                Group.Name    = AdminGroup;
                Group.Enabled = true;
                DB.AccountGroup.Add(Group);
                DB.SaveChanges();
                Group.Account.Add(account);
            }

            DB.SaveChanges();
        }
Ejemplo n.º 12
0
        public UserDetailPage(DataUser binding, AccountGroup issuer)
        {
            InitializeComponent();
            this.issuer = issuer;

            IssuerView.BindingContext = issuer.User;
            IssuerView.Update();

            UpdateBinding(binding);

            IssuerGroupView.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(async() =>
                {
                    try
                    {
                        var account = await Util.SelectAccount("전환할 계정을 선택하세요");
                        this.issuer = account;

                        IssuerView.BindingContext = this.issuer.User;
                        IssuerView.Update();
                        UpdateRelationship();
                    }
                    catch (Exception e)
                    {
                        Util.HandleException(e);
                    }
                })
            });
        }
Ejemplo n.º 13
0
        private ApiKeyManagement Resolve(Mock <IDatabaseContext> fakeContext, int currentUser)
        {
            var person = new Person
            {
                Id = currentUser,
            };

            var defaultGroup = new AccountGroup
            {
                Id = 1
            };

            var join = person.AddToGroup(defaultGroup, 1);

            join.PermissionLevel = PermissionLevel.Admin; //defaults to this

            fakeContext.Setup(x => x.List <Person>()).Returns(new[]
            {
                person
            }.AsQueryable());


            var result = new ApiKeyManagement(fakeContext.Object, currentUser, 1);

            return(result);
        }
Ejemplo n.º 14
0
        public AccountGroup GetAccountGroupRecord(string recordID, string UserID)
        {
            AccountGroup  AccountGroup = new AccountGroup();
            SqlDataReader dr           = null;

            try
            {
                SqlParameter[] Parameters = { new SqlParameter("@SNo", recordID), new SqlParameter("@UserID", Convert.ToInt32(UserID)) };
                dr = SqlHelper.ExecuteReader(ReadConnectionString.WebConfigConnectionString, CommandType.StoredProcedure, "GetRecordAccountGroup", Parameters);
                if (dr.Read())
                {
                    AccountGroup.SNo  = Convert.ToInt32(dr["SNo"]);
                    AccountGroup.Name = dr["Name"].ToString();
                    if (!String.IsNullOrEmpty(dr["IsActive"].ToString()))
                    {
                        AccountGroup.IsActive = Convert.ToBoolean(dr["IsActive"]);
                        AccountGroup.Active   = dr["Active"].ToString().ToUpper();
                    }
                    AccountGroup.UpdatedBy = dr["UpdatedUser"].ToString();
                    AccountGroup.CreatedBy = dr["CreatedUser"].ToString();
                }
            }
            catch (Exception ex)//
            {
                dr.Close();
                throw ex;
            }

            return(AccountGroup);
        }
Ejemplo n.º 15
0
        public void CreateNewAccountGroup(NewAccountGroup newAccountGroup)
        {
            if (newAccountGroup == null)
            {
                throw new ArgumentNullException(nameof(newAccountGroup));
            }

            if (String.IsNullOrEmpty(newAccountGroup.GroupName))
            {
                throw new BusinessLogicException("Input a group name");
            }

            if (String.IsNullOrEmpty(newAccountGroup.AdministratorUserName))
            {
                throw new BusinessLogicException("Who will you be known as?");
            }

            var accountGroup = new AccountGroup
            {
                CreatedDate = DateTime.Now,
                Name        = newAccountGroup.GroupName,
            };

            var person = new Person
            {
                Name        = newAccountGroup.AdministratorUserName,
                CreatedDate = DateTime.Now,
                Email       = newAccountGroup.Email
            };

            Context.Add(person);
            Context.Add(accountGroup);
            Context.SaveChanges();
        }
Ejemplo n.º 16
0
 private void RegisterGroup(AccountGroup g)
 {
     g.PropertyChanged += (s, evt) => {
         g.ModificationTracker.ModifiedElements.Add(g.Guid);
         if ("IsLocked".Equals(evt.PropertyName))
         {
             model.SelectedGroup = model.SelectedGroup;
         }
     };
     foreach (var l in g.Logins)
     {
         l.PropertyChanged += (s, evt) => {
             g.ModificationTracker.ModifiedElements.Add(l.Guid);
         };
     }
     g.Logins.CollectionChanged += (s, evt) => {
         if (evt.NewItems != null)
         {
             foreach (var l in evt.NewItems)
             {
                 g.ModificationTracker.ModifiedElements.Add(((Entity)l).Guid);
                 ((Entity)l).PropertyChanged += (s2, evt2) => {
                     g.ModificationTracker.ModifiedElements.Add(((Entity)l).Guid);
                 };
             }
         }
         if (evt.OldItems != null)
         {
             foreach (var l in evt.OldItems)
             {
                 g.ModificationTracker.ModifiedElements.Add(((Entity)l).Guid);
             }
         }
     };
     foreach (var a in g.Accounts)
     {
         RegisterAccount(g, a);
     }
     g.Accounts.CollectionChanged += (s, evt) =>
     {
         if (evt.NewItems != null)
         {
             foreach (var a in evt.NewItems)
             {
                 g.ModificationTracker.ModifiedElements.Add(((Entity)a).Guid);
                 RegisterAccount(g, (Account)a);
             }
             ;
         }
         if (evt.OldItems != null)
         {
             foreach (var a in evt.OldItems)
             {
                 g.ModificationTracker.ModifiedElements.Add(((Entity)a).Guid);
             }
             ;
         }
     };
 }
Ejemplo n.º 17
0
        private void AddGroupButton_Click(object sender, RoutedEventArgs e)
        {
            var group = new AccountGroup();

            group.Name = "<New Group>";
            AccountGroups.Groups.Add(group);
            Selected = group;
        }
Ejemplo n.º 18
0
        public ActionResult EditGroup(int id)
        {
            AccountGroup accountgroup = db.AccountGroups.Include(a => a.CurrentAccountCategory).Where(a => a.AccountGroupID == id).FirstOrDefault();

            ViewBag.AccountCategoryID = new SelectList(db.AccountCategorys, "AccountCategoryID", "Name", accountgroup.AccountCategoryID);
            ViewBag.Existing          = accountgroup.Name;
            return(View(accountgroup));
        }
Ejemplo n.º 19
0
        public HttpResponseMessage Delete([FromUri] int id, [FromBody] int modifiedBy)
        {
            AccountGroup Account = new AccountGroup();

            Account.Id         = id;
            Account.ModifiedBy = modifiedBy;
            return(Request.CreateResponse(HttpStatusCode.OK, Account.Delete()));
        }
Ejemplo n.º 20
0
        public void InsertAccountGroupData(string Name)
        {
            AccountGroup acg = new AccountGroup();

            acg.Name = Name;
            db.AccountGroup.Add(acg);
            db.SaveChanges();
        }
Ejemplo n.º 21
0
        public ActionResult DeleteConfirmed(int id)
        {
            AccountGroup accountGroup = db.AccountGroups.Find(id);

            db.AccountGroups.Remove(accountGroup);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public static AccountGroup GetAccountGroupByID(int accountGroupID)
        {
            DataRow AccountGroupRow = AccountGroupDataAccess.GetInstance.GetAccountGroupByID(accountGroupID);

            AccountGroup TheAccountGroup = DataRowToObject(AccountGroupRow);

            return(TheAccountGroup);
        }
Ejemplo n.º 23
0
 public List <Account> findAccountsByAccountGroup(AccountGroup accountGroup)
 {
     using (var db = new BaseDbContext())
     {
         var accounts = db.accountDb.Where(acc => acc.GroupID == accountGroup.AccountGroupID && acc.isRemoved != true)
                        .ToList();
         return(accounts);
     }
 }
Ejemplo n.º 24
0
        public void accountGroupAccountExists()
        {
            AccountGroup ag = AccountGroup.show(accountGroupID);

            Assert.IsNotNull(ag, "Account Group is null--bad call to API");
            Account acc = ag.Account;

            Assert.IsNotNull(acc);
        }
Ejemplo n.º 25
0
        protected override void Validation()
        {
            AccountGroup ag = IAccountGroupDal.GetAccountGroupByName(_AccountGroup.GroupName);

            if (ag != null && ag.PKID != _AccountGroup.PKID)
            {
                throw new Exception("已有相同命名的组");
            }
        }
        public ActionResult CreateGroup()
        {
            var model = new AccountGroup()
            {
                TypeGroup = (sbyte)TypeUsers.ProducerUser
            };

            return(View(model));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// A template for a whole bunch of things.
        /// Account groups 1, 2
        /// People 1-5 join to account groups in various ways. Some users
        /// have been disabled
        /// </summary>
        /// <param name="currentPerson"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public AccountManagement Resolve(Mock <IDatabaseContext> context, int currentPerson)
        {
            var accountGroup1 = new AccountGroup {
                Id = 1
            };
            var person1 = new Person {
                Id = 1,
            };
            var person2 = new Person {
                Id = 2, DisabledDate = DateTime.Now
            };
            var sharedPerson = new Person {
                Id = 3, DisabledDate = DateTime.Now
            };

            var g1 = person1.AddToGroup(accountGroup1, 1);
            var g2 = person2.AddToGroup(accountGroup1, 2);
            var g3 = sharedPerson.AddToGroup(accountGroup1, 3);

            var accountGroup2 = new AccountGroup {
                Id = 2
            };
            var person4 = new Person {
                Id = 4
            };
            var person5 = new Person {
                Id = 5
            };

            var g4 = person1.AddToGroup(accountGroup2, 4);
            var g5 = sharedPerson.AddToGroup(accountGroup2, 5);
            var g6 = person4.AddToGroup(accountGroup2, 6);
            var g7 = person5.AddToGroup(accountGroup2, 7);

            var disabledAccountGroup = new AccountGroup()
            {
                Id = 3, EndDate = DateTime.Now
            };
            var person6 = new Person {
                Id = 6
            };
            var g8 = person6.AddToGroup(disabledAccountGroup, 8);
            var g9 = sharedPerson.AddToGroup(disabledAccountGroup, 9);

            var accountGroup4 = new AccountGroup()
            {
                Id = 4
            };
            var g10 = person6.AddToGroup(accountGroup4, 10);

            var people = new[] { person1, person2, sharedPerson, person4, person5, person6 };

            context.Setup(x => x.List <Person>()).Returns(people.AsQueryable());
            context.Setup(x => x.List <AccountGroup>()).Returns(new AccountGroup[] { accountGroup1, accountGroup2, disabledAccountGroup, accountGroup4 }.AsQueryable());
            context.Setup(x => x.List <AccountGroupPerson>()).Returns(new AccountGroupPerson[] { g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 }.AsQueryable());
            return(new AccountManagement(context.Object, currentPerson));
        }
Ejemplo n.º 28
0
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            AccountGroup accountGroup = await db.AccountGroup.FindAsync(id);

            db.AccountGroup.Remove(accountGroup);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 29
0
        private int GetAccountId()
        {
            using (FalconOrchestratorDB db = new FalconOrchestratorDB())
            {
                int accountId;

                if (db.Accounts.Any(x => x.AccountName.Equals(data.UserName)))
                {
                    accountId = db.Accounts.Where(x => x.AccountName.Equals(data.UserName)).Select(x => x.AccountId).FirstOrDefault();
                }

                else
                {
                    Account user = new Account();
                    user.AccountName = data.UserName;
                    user.Timestamp   = DateTime.UtcNow;

                    db.Accounts.Add(user);
                    db.SaveChanges();
                    accountId = user.AccountId;

                    if (data.AccountModel != null)
                    {
                        user.City               = data.AccountModel.City;
                        user.Country            = data.AccountModel.Country;
                        user.Department         = data.AccountModel.Department;
                        user.EmailAddress       = data.AccountModel.EmailAddress;
                        user.FirstName          = data.AccountModel.FirstName;
                        user.JobTitle           = data.AccountModel.JobTitle;
                        user.LastLogon          = data.AccountModel.LastLogon != DateTime.MinValue ? data.AccountModel.LastLogon : null;
                        user.LastName           = data.AccountModel.LastName;
                        user.Manager            = data.AccountModel.Manager;
                        user.PhoneNumber        = data.AccountModel.PhoneNumber;
                        user.StateProvince      = data.AccountModel.StateProvince;
                        user.StreetAddress      = data.AccountModel.StreetAddress;
                        user.OrganizationalUnit = data.AccountModel.OrganizationalUnit;

                        if (data.AccountModel.Groups != null)
                        {
                            foreach (string line in data.AccountModel.Groups)
                            {
                                int          groupId      = GetGroupId(line);
                                AccountGroup accountGroup = new AccountGroup();
                                accountGroup.AccountId = accountId;
                                accountGroup.GroupId   = groupId;
                                db.AccountGroups.Add(accountGroup);
                            }
                        }
                        db.Entry(user).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                return(accountId);
            }
        }
Ejemplo n.º 30
0
        public UpdateAccountGroup(AccountGroup AccountGroup, string accountMember)
        {
            _AccountGroup  = AccountGroup;
            _AccountMember = accountMember;

            _AccountMember = _AccountMember.Replace(" ", "");
            _AccountMember = _AccountMember.Replace(" ", "");
            _AccountMember = _AccountMember.Replace('(', '(');
            _AccountMember = _AccountMember.Replace(')', ')');
            _AccountMember = _AccountMember.Replace(';', ';');
        }
Ejemplo n.º 31
0
 public static ACL GetACL(ISession session, AccountGroup instance, Type type) { return new ManagedAccountGroup(session, instance).GetACL(type); }
Ejemplo n.º 32
0
 public static string GetObjectName(AccountGroup instance, int id) { return instance.Name; }
Ejemplo n.º 33
0
        public static int GetOwnerId(AccountGroup group, int id) 
        {
            foreach (AccountGroupAccount instance in group.AccountGroupAccounts)
                if (instance.IsAdministrator)
                    return instance.Account.Id;

            throw new Exception(string.Format("Missing Owner: AccountGroup {0}", group.Id)); 
        }
Ejemplo n.º 34
0
        public IList<CY.UME.Core.Business.AccountGroup> GetAccountGroupByGroupIdAndRoleAndAccountId(CY.UME.Core.Business.Group Group, int type, int role, CY.UME.Core.Business.Account account, CY.UME.Core.PagingInfo pageInfo)
        {
            IList<Core.Business.AccountGroup> accountGroupList = new List<Core.Business.AccountGroup>();

            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            #region ����
            string tables = "AccountGroup";
            string pK = "Id";
            string sort = "Id Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            string fields = "[Id], [AccountId],[GroupId],[DateCreated],[Role],[LastVisitDate],[Name]";
            string group = String.Empty;
            string filter = "1=1";

            if (Group != null)
            {
                filter += " and [GroupId]=" + Group.Id.ToString();
            }
            if (type != -1)
            {
                if (type==-2)
                {
                    filter += " and [GroupId] in (select [Id] from [Group] where [type]>0 and [IsChecked]=1)";
                }
                else
                {
                    filter += " and [GroupId] in (select [Id] from [Group] where [type]=" + type.ToString() + " and [IsChecked]=1)";
                }
            }
            if (role != -1)
            {
                filter += " and [Role]=" + role.ToString();
            }

            if (account != null)
            {
                filter += " and [AccountId]=" + account.Id.ToString();
            }

            #endregion
            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.AccountGroup accountGroup = new AccountGroup();

                    if (!reader.IsDBNull(0)) accountGroup.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) accountGroup.AccountId = reader.GetInt64(1);
                    if (!reader.IsDBNull(2)) accountGroup.GroupId = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) accountGroup.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) accountGroup.Role = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) accountGroup.LastVisitDate = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) accountGroup.Name = reader.GetString(6);

                    accountGroup.MarkOld();
                    accountGroupList.Add(accountGroup);
                }
                reader.Close();
            }

            return accountGroupList;
        }
Ejemplo n.º 35
0
        public IList<CY.UME.Core.Business.AccountGroup> GetLatestVisitors(int groupId, CY.UME.Core.PagingInfo pageInfo)
        {
            IList<Core.Business.AccountGroup> accountGroupList = new List<Core.Business.AccountGroup>();

            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            #region ����
            string tables = "AccountGroup";
            string pK = "Id";
            string sort = "LastVisitDate Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            string fields = "[Id], [AccountId],[GroupId],[DateCreated],[Role],[LastVisitDate],[Name]";
            string filter = "[GroupId]=" + groupId.ToString();
            string group = String.Empty;
            #endregion
            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.AccountGroup accountGroup = new AccountGroup();

                    if (!reader.IsDBNull(0)) accountGroup.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) accountGroup.AccountId = reader.GetInt64(1);
                    if (!reader.IsDBNull(2)) accountGroup.GroupId = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) accountGroup.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) accountGroup.Role = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) accountGroup.LastVisitDate = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) accountGroup.Name = reader.GetString(6);

                    accountGroup.MarkOld();
                    accountGroupList.Add(accountGroup);
                }
                reader.Close();
            }

            return accountGroupList;
        }
Ejemplo n.º 36
0
        public IList<Core.Business.AccountGroup> GetAccountGroupByAccountIdOrGroupId(long accountId, int groupId)
        {
            IList<Core.Business.AccountGroup> accountGroupList = new List<Core.Business.AccountGroup>();

            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            sql.AddParameter("@AccountId", SqlDbType.BigInt, accountId);
            sql.AddParameter("@GroupId", SqlDbType.Int, groupId);

            SqlDataReader reader = sql.ExecuteSPReader("USP_AccountGroup_Select_By_AccountId_And_GroupId");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.AccountGroup accountGroup = new AccountGroup();

                    if (!reader.IsDBNull(0)) accountGroup.Id = reader.GetInt64(0);
                    if (!reader.IsDBNull(1)) accountGroup.AccountId = reader.GetInt64(1);
                    if (!reader.IsDBNull(2)) accountGroup.GroupId = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) accountGroup.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) accountGroup.Role = reader.GetInt32(4);
                    if (!reader.IsDBNull(5)) accountGroup.LastVisitDate = reader.GetDateTime(5);
                    if (!reader.IsDBNull(6)) accountGroup.Name = reader.GetString(6);

                    accountGroup.MarkOld();
                    accountGroupList.Add(accountGroup);
                }
                reader.Close();
            }

            return accountGroupList;
        }