private static RoleEntity ConvertRoleEntity(DataRow dr)
 {
     RoleEntity entity = new RoleEntity();
     entity.RoleID = Convert.ToString(dr["UserRoleID"]).Trim();
     entity.RoleName = Convert.ToString(dr["UserRoleName"]).Trim();
     return entity;
 }
 public void CreateRole(Guid roleId, string applicationName, string roleName)
 {
     using (var session = OpenSesion())
     {
         var roleEntity = new RoleEntity
         {
             ApplicationName = applicationName,
             RoleId = roleId,
             RoleName = roleName
         };
         session.Save(roleEntity);
         session.SubmitChanges();
     }
 }
Exemple #3
0
 public ActionResult SubmitForm(RoleEntity roleEntity, string permissionIds, string keyValue)
 {
     roleApp.SubmitForm(roleEntity, permissionIds.Split(','), keyValue);
     return(Success("操作成功。"));
 }
Exemple #4
0
        /// <summary>
        /// Modifies the given role: it resets the system action rights for the given role to the given set of action rights and it modifies
        /// the role description for the given role. If the user specified a role description that is already available, false will be returned to signal
        /// that the save failed.
        /// </summary>
        /// <param name="actionRightIDs">The action rights.</param>
        /// <param name="roleID">The role ID.</param>
        /// <param name="roleDescription">The role description.</param>
        /// <returns>true if succeeded, false otherwise</returns>
        public static bool ModifyRole(List<int> actionRightIDs, int roleID, string roleDescription)
        {
            // read the existing role entity from the database.
            RoleEntity roleToModify = new RoleEntity(roleID);
            if(roleToModify.IsNew)
            {
                // not found
                return false;
            }

            // check if the description is different. If so, we've to check if the new roledescription is already present. If so, we'll
            // abort the save
            if(roleToModify.RoleDescription != roleDescription)
            {
                if(CheckIfRoleDescriptionIsPresent(roleDescription))
                {
                    // new description, is already present, fail
                    return false;
                }
            }

            // all set. We're going to delete all Role - SystemAction Rights combinations first, as we're going to re-insert them later on.
            // We'll use a transaction to be able to roll back all our changes if something fails.
            Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "ModifyRole");
            try
            {
                RoleSystemActionRightCollection roleActionRights = new RoleSystemActionRightCollection();
                // add this collection to the transaction so all actions executed through this collection will be inside the transaction
                trans.Add(roleActionRights);
                // delete all role-systemactionright combinations directly from the database, by issuing a direct delete on the database, using a filter
                // on roleid
                roleActionRights.DeleteMulti(RoleSystemActionRightFields.RoleID == roleID);

                // add new role-systemactionright entities which we'll save to the database after that
                foreach(int actionRightID in actionRightIDs)
                {
                    RoleSystemActionRightEntity toAdd = new RoleSystemActionRightEntity();
                    toAdd.ActionRightID = actionRightID;
                    toAdd.RoleID = roleID;
                    roleActionRights.Add(toAdd);
                }
                // save the new entities to the database
                roleActionRights.SaveMulti();

                // we'll now save the role and the role description, if it's changed. Otherwise the save action will be a no-op.
                // add it to the transaction
                trans.Add(roleToModify);
                roleToModify.RoleDescription = roleDescription;
                roleToModify.Save();

                // all done, commit the transaction
                trans.Commit();
                return true;
            }
            catch
            {
                // failed, roll back transaction.
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }
        }
 /// <summary>
 /// 从界面获取系统角色对象
 /// </summary>
 /// <returns></returns>
 private RoleEntity GetRoleUI()
 {
     RoleEntity Result = new RoleEntity();
     Result.RoleNo = RoleNo;
     Result.RoleName = txtRoleName.Text;
     Result.Description = txtDescription.Text;
     Result.OrderNo = Convert.ToInt32(txtOrderNo.Text);
     return Result;
 }
 /// <summary> setups the sync logic for member _role</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncRole(IEntityCore relatedEntity)
 {
     if(_role!=relatedEntity)
     {
         DesetupSyncRole(true, true);
         _role = (RoleEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _role, new PropertyChangedEventHandler( OnRolePropertyChanged ), "Role", SD.HnD.DAL.RelationClasses.StaticForumRoleForumActionRightRelations.RoleEntityUsingRoleIDStatic, true, ref _alreadyFetchedRole, new string[] {  } );
     }
 }
 protected void lbCancel_Click(object sender, EventArgs e)
 {
     EditRole = null;
 }
 internal static RoleEntity ToRoleEntity(RoleInfo roleInfo)
 {
     RoleEntity roleEntity = new RoleEntity();
     roleEntity.RoleID = roleInfo.RoleID;
     roleEntity.RoleName = roleInfo.RoleName;
     roleEntity.Remark = roleInfo.Remark;
     return roleEntity;
 }
Exemple #9
0
 /// <summary> Removes the sync logic for member _role</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncRole(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity(_role, new PropertyChangedEventHandler(OnRolePropertyChanged), "Role", PrintVendorPvuserEntity.Relations.RoleEntityUsingRoleId, true, signalRelatedEntity, "PrintVendorPvuser", resetFKFields, new int[] { (int)PrintVendorPvuserFieldIndex.RoleId });
     _role = null;
 }
 public ActionResult SaveForm(string keyValue, RoleEntity entity)
 {
     roleIBLL.SaveEntity(keyValue, entity);
     return(Success("保存成功!"));
 }
        public static void InitFreameworkDbData(this IApplicationBuilder app, IServiceProvider applicationServices, string webRootPath, EvolutionDBContext dbContext)
        {
            var sqlServerDatabase = dbContext.Database;

            //try
            //{
            //    int r = sqlServerDatabase.ExecuteSqlCommand("select count(*) from Sys_User");
            //    return;
            //}
            //catch(Exception ex)
            //{
            //    //这个ex是可预期的。

            //}
            try
            {
                sqlServerDatabase.EnsureDeleted();
            }
            catch { }

            if (sqlServerDatabase.EnsureCreated())
            {
                //sqlServerDatabase.Migrate();

                DataInitTool.ProcessFile("Sys_DbBackup.csv", webRootPath, colums => {
                    DbBackupEntity entity = new DbBackupEntity();
                    entity.Id             = colums[0];
                    entity.BackupType     = colums[1];
                    entity.DbName         = colums[2];
                    entity.FileName       = colums[3];
                    entity.FileSize       = colums[4];
                    entity.FilePath       = colums[5];
                    entity.BackupTime     = DateTime.Parse(colums[6]);
                    entity.EnabledMark    = bool.Parse(colums[9]);
                    entity.CreateTime     = DateTime.MinValue;
                    dbContext.DbBackups.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_FilterIP.csv", webRootPath, colums => {
                    FilterIPEntity entity = new FilterIPEntity();
                    entity.Id             = colums[0];
                    entity.Type           = bool.Parse(colums[1]);
                    entity.StartIP        = colums[2];
                    entity.EndIP          = colums[3];
                    entity.EnabledMark    = bool.Parse(colums[6]);
                    entity.Description    = colums[7];
                    entity.CreateTime     = DateTime.Parse(colums[8]);
                    dbContext.FilterIPs.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_Items.csv", webRootPath, colums => {
                    ItemsEntity entity = new ItemsEntity();
                    entity.Id          = colums[0];
                    entity.ParentId    = colums[1];
                    entity.EnCode      = colums[2];
                    entity.FullName    = colums[3];
                    entity.IsTree      = GetDefaultBool(colums[4], false);
                    entity.Layers      = int.Parse(colums[5]);
                    entity.SortCode    = int.Parse(colums[6]);
                    entity.DeleteMark  = GetDefaultBool(colums[7], false);
                    entity.EnabledMark = GetDefaultBool(colums[8], true);
                    entity.CreateTime  = DateTime.MinValue;
                    dbContext.Items.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_ItemsDetail.csv", webRootPath, colums => {
                    ItemsDetailEntity entity = new ItemsDetailEntity();
                    entity.Id          = colums[0];
                    entity.ItemId      = colums[1];
                    entity.ParentId    = colums[2];
                    entity.ItemCode    = colums[3];
                    entity.ItemName    = colums[4];
                    entity.IsDefault   = GetDefaultBool(colums[6], false);
                    entity.SortCode    = int.Parse(colums[8]);
                    entity.DeleteMark  = GetDefaultBool(colums[9], false);
                    entity.EnabledMark = GetDefaultBool(colums[10], true);
                    dbContext.ItemsDetails.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_Log.csv", webRootPath, colums => {
                    LogEntity entity     = new LogEntity();
                    entity.Id            = colums[0];
                    entity.Date          = DateTime.Parse(colums[1]);
                    entity.Account       = colums[2];
                    entity.NickName      = colums[3];
                    entity.Type          = colums[4];
                    entity.IPAddress     = colums[5];
                    entity.IPAddressName = colums[6];
                    entity.ModuleName    = colums[8];
                    entity.Result        = bool.Parse(colums[9]);
                    entity.Description   = colums[10];
                    entity.CreateTime    = DateTime.MinValue;
                    entity.CreatorUserId = colums[12];
                    dbContext.Logs.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_Menu.csv", webRootPath, colums => {
                    MenuEntity entity       = new MenuEntity();
                    entity.Id               = colums[0];
                    entity.ParentId         = colums[1];
                    entity.Layers           = int.Parse(colums[2]);
                    entity.FullName         = colums[4];
                    entity.Icon             = colums[5];
                    entity.UrlAddress       = colums[6];
                    entity.Target           = colums[7];
                    entity.IsMenu           = bool.Parse(colums[8]);
                    entity.IsExpand         = bool.Parse(colums[9]);
                    entity.IsPublic         = bool.Parse(colums[10]);
                    entity.AllowEdit        = bool.Parse(colums[11]);
                    entity.AllowDelete      = bool.Parse(colums[12]);
                    entity.SortCode         = int.Parse(colums[13]);
                    entity.DeleteMark       = bool.Parse(colums[14]);
                    entity.EnabledMark      = bool.Parse(colums[15]);
                    entity.Description      = colums[16];
                    entity.CreateTime       = DateTime.MinValue;
                    entity.LastModifyTime   = DateTime.MinValue;
                    entity.LastModifyUserId = colums[20];
                    dbContext.Menus.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_MenuButton.csv", webRootPath, colums => {
                    MenuButtonEntity entity = new MenuButtonEntity();
                    entity.Id       = colums[0];
                    entity.MenuId   = colums[1];
                    entity.ParentId = colums[2];
                    if (!string.IsNullOrEmpty(colums[3]))
                    {
                        entity.Layers = int.Parse(colums[3]);
                    }
                    entity.EnCode   = colums[4];
                    entity.FullName = colums[5];
                    if (!string.IsNullOrEmpty(colums[7]))
                    {
                        entity.Location = int.Parse(colums[7]);
                    }
                    entity.JsEvent    = colums[8];
                    entity.UrlAddress = colums[9];
                    if (!string.IsNullOrEmpty(colums[10]))
                    {
                        entity.Split = bool.Parse(colums[10]);
                    }
                    if (!string.IsNullOrEmpty(colums[11]))
                    {
                        entity.IsPublic = bool.Parse(colums[11]);
                    }
                    if (!string.IsNullOrEmpty(colums[12]))
                    {
                        entity.AllowEdit = bool.Parse(colums[12]);
                    }
                    if (!string.IsNullOrEmpty(colums[13]))
                    {
                        entity.AllowDelete = bool.Parse(colums[13]);
                    }
                    if (!string.IsNullOrEmpty(colums[14]))
                    {
                        entity.SortCode = int.Parse(colums[14]);
                    }
                    if (!string.IsNullOrEmpty(colums[15]))
                    {
                        entity.DeleteMark = bool.Parse(colums[15]);
                    }
                    if (!string.IsNullOrEmpty(colums[16]))
                    {
                        entity.EnabledMark = bool.Parse(colums[16]);
                    }
                    entity.CreateTime       = DateTime.MinValue;
                    entity.LastModifyTime   = DateTime.MinValue;
                    entity.LastModifyUserId = colums[20];
                    dbContext.ModuleButtons.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_Organize.csv", webRootPath, colums =>
                {
                    OrganizeEntity entity = new OrganizeEntity();
                    entity.Id             = colums[0];
                    entity.ParentId       = colums[1];
                    entity.Layers         = int.Parse(colums[2]);
                    entity.EnCode         = colums[3];
                    entity.FullName       = colums[4];
                    entity.ShortName      = colums[5];
                    entity.CategoryId     = colums[6];
                    entity.ManagerId      = colums[7];
                    entity.Address        = colums[14];
                    entity.SortCode       = int.Parse(colums[17]);
                    entity.DeleteMark     = bool.Parse(colums[18]);
                    entity.EnabledMark    = bool.Parse(colums[19]);
                    entity.CreateTime     = DateTime.MinValue;
                    dbContext.Organizes.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_Role.csv", webRootPath, colums => {
                    RoleEntity entity  = new RoleEntity();
                    entity.Id          = colums[0];
                    entity.OrganizeId  = colums[1];
                    entity.Category    = int.Parse(colums[2]);
                    entity.EnCode      = colums[3];
                    entity.FullName    = colums[4];
                    entity.Type        = colums[5];
                    entity.AllowEdit   = bool.Parse(colums[6]);
                    entity.AllowDelete = bool.Parse(colums[7]);
                    entity.SortCode    = int.Parse(colums[8]);
                    entity.DeleteMark  = bool.Parse(colums[9]);
                    entity.EnabledMark = bool.Parse(colums[10]);

                    entity.CreateTime       = DateTime.MinValue;
                    entity.LastModifyTime   = DateTime.MinValue;
                    entity.LastModifyUserId = colums[15];
                    dbContext.Roles.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_RoleAuthorize.csv", webRootPath, colums => {
                    RoleAuthorizeEntity entity = new RoleAuthorizeEntity();
                    entity.Id         = colums[0];
                    entity.ItemType   = int.Parse(colums[1]);
                    entity.ItemId     = colums[2];
                    entity.ObjectType = int.Parse(colums[3]);
                    entity.ObjectId   = colums[4];
                    //entity.SortCode = int.Parse(colums[5]);
                    entity.CreateTime    = DateTime.MinValue;
                    entity.CreatorUserId = colums[7];
                    dbContext.RoleAuthorize.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_User.csv", webRootPath, colums => {
                    UserEntity entity       = new UserEntity();
                    entity.Id               = colums[0];
                    entity.Account          = colums[1];
                    entity.RealName         = colums[2];
                    entity.NickName         = colums[3];
                    entity.Gender           = bool.Parse(colums[5]);
                    entity.MobilePhone      = colums[7];
                    entity.OrganizeId       = colums[13];
                    entity.DepartmentId     = colums[14];
                    entity.RoleId           = colums[15];
                    entity.DutyId           = colums[16];
                    entity.IsAdministrator  = bool.Parse(colums[17]);
                    entity.DeleteMark       = bool.Parse(colums[19]);
                    entity.EnabledMark      = bool.Parse(colums[20]);
                    entity.Description      = colums[21];
                    entity.CreateTime       = DateTime.MinValue;
                    entity.LastModifyTime   = DateTime.MinValue;
                    entity.LastModifyUserId = colums[25];
                    dbContext.Users.Add(entity);
                });
                DataInitTool.ProcessFile("Sys_UserLogOn.csv", webRootPath, colums => {
                    UserLogOnEntity entityt = new UserLogOnEntity();
                    entityt.Id            = colums[0];
                    entityt.UserId        = colums[1];
                    entityt.UserPassword  = colums[2];
                    entityt.UserSecretkey = colums[3];
                    if (!string.IsNullOrEmpty(colums[9]))
                    {
                        entityt.PreviousVisitTime = DateTime.Parse(colums[9]);
                    }
                    if (!string.IsNullOrEmpty(colums[10]))
                    {
                        entityt.LastVisitTime = DateTime.Parse(colums[10]);
                    }
                    if (!string.IsNullOrEmpty(colums[13]))
                    {
                        entityt.LogOnCount = int.Parse(colums[13]);
                    }
                    dbContext.UserLogOn.Add(entityt);
                });
                dbContext.SaveChanges();
            }
        }
Exemple #12
0
        public static int Edit(RoleEntity objRole)
        {
            int result = ProviderSoftv.Role.EditRole(objRole);

            return(result);
        }
Exemple #13
0
        public static int Add(RoleEntity objRole)
        {
            int result = ProviderSoftv.Role.AddRole(objRole);

            return(result);
        }
Exemple #14
0
        /// <summary>Creates a new, empty RoleEntity object.</summary>
        /// <returns>A new, empty RoleEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new RoleEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewRole
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
Exemple #15
0
 /// <summary>
 /// 保存岗位表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="jobEntity">岗位实体</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, RoleEntity jobEntity)
 {
     service.SaveForm(keyValue, jobEntity);
     CacheFactory.Cache().RemoveCache(CacheKey);
 }
Exemple #16
0
        public string ImportStandard(string standardtype, string categorycode)
        {
            if (OperatorProvider.Provider.Current().IsSystem)
            {
                return("超级管理员无此操作权限");
            }
            string orgId        = OperatorProvider.Provider.Current().OrganizeId;//所属公司
            int    error        = 0;
            string message      = "请选择文件格式正确的文件再导入!";
            string falseMessage = "";
            int    count        = HttpContext.Request.Files.Count;

            if (count > 0)
            {
                if (HttpContext.Request.Files.Count != 2)
                {
                    return("请按正确的方式导入两个文件.");
                }
                HttpPostedFileBase file  = HttpContext.Request.Files[0];
                HttpPostedFileBase file2 = HttpContext.Request.Files[1];
                if (string.IsNullOrEmpty(file.FileName) || string.IsNullOrEmpty(file2.FileName))
                {
                    return(message);
                }
                Boolean isZip1 = file.FileName.Substring(file.FileName.IndexOf('.')).Contains("zip");   //第一个文件是否为Zip格式
                Boolean isZip2 = file2.FileName.Substring(file2.FileName.IndexOf('.')).Contains("zip"); //第二个文件是否为Zip格式
                if ((isZip1 || isZip2) == false || (isZip1 && isZip2) == true)
                {
                    return(message);
                }
                string fileName1 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(Server.MapPath("~/Resource/temp/" + fileName1));
                string fileName2 = DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(file2.FileName);
                file2.SaveAs(Server.MapPath("~/Resource/temp/" + fileName2));
                string decompressionDirectory = Server.MapPath("~/Resource/decompression/") + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "\\";
                Aspose.Cells.Workbook wb      = new Aspose.Cells.Workbook();
                if (isZip1)
                {
                    UnZip(Server.MapPath("~/Resource/temp/" + fileName1), decompressionDirectory, "", true);
                    wb.Open(Server.MapPath("~/Resource/temp/" + fileName2));
                }
                else
                {
                    UnZip(Server.MapPath("~/Resource/temp/" + fileName2), decompressionDirectory, "", true);
                    wb.Open(Server.MapPath("~/Resource/temp/" + fileName1));
                }

                Aspose.Cells.Cells cells = wb.Worksheets[0].Cells;
                DataTable          dt    = cells.ExportDataTable(2, 0, cells.MaxDataRow - 1, cells.MaxColumn + 1, false);
                for (int i = 1; i < dt.Rows.Count; i++)
                {
                    //文件名称
                    string filename = dt.Rows[i][0].ToString();
                    //文件路径
                    string filepath = dt.Rows[i][1].ToString();
                    //相应元素
                    string relevantelement     = "";
                    string relevantelementname = "";
                    string relevantelementid   = "";
                    //实施日期
                    string carrydate = "";
                    if (standardtype == "1" || standardtype == "2" || standardtype == "3" || standardtype == "4" || standardtype == "5" || standardtype == "6")
                    {
                        relevantelement = dt.Rows[i][2].ToString();
                        carrydate       = dt.Rows[i][3].ToString();
                    }

                    //文学字号
                    string dispatchcode = "";
                    //颁布部门
                    string publishdept = "";
                    if (standardtype == "6")
                    {
                        dispatchcode = dt.Rows[i][4].ToString();
                        publishdept  = dt.Rows[i][5].ToString();
                    }


                    string dutyid   = "";
                    string dutyName = "";

                    //---****值存在空验证*****--
                    if (string.IsNullOrEmpty(filename) || string.IsNullOrEmpty(filepath))
                    {
                        falseMessage += "</br>" + "第" + (i + 3) + "行值存在空,未能导入.";
                        error++;
                        continue;
                    }

                    //---****文件格式验证*****--
                    if (!(filepath.Substring(filepath.IndexOf('.')).Contains("doc") || filepath.Substring(filepath.IndexOf('.')).Contains("docx") || filepath.Substring(filepath.IndexOf('.')).Contains("pdf")))
                    {
                        falseMessage += "</br>" + "第" + (i + 3) + "行附件格式不正确,未能导入.";
                        error++;
                        continue;
                    }

                    //---****文件是否存在验证*****--
                    if (!System.IO.File.Exists(decompressionDirectory + filepath))
                    {
                        falseMessage += "</br>" + "第" + (i + 3) + "行附件不存在,未能导入.";
                        error++;
                        continue;
                    }

                    //--**验证岗位是否存在 * *--
                    int startnum = 4;
                    if (standardtype == "1" || standardtype == "2" || standardtype == "3" || standardtype == "4" || standardtype == "5")
                    {
                        startnum = 4;
                    }
                    else if (standardtype == "6")
                    {
                        startnum = 6;
                    }
                    else if (standardtype == "7" || standardtype == "8" || standardtype == "9")
                    {
                        startnum = 2;
                    }
                    for (int j = startnum; j < dt.Columns.Count; j++)
                    {
                        if (!dt.Rows[i][j].IsEmpty())
                        {
                            foreach (var item in dt.Rows[i][j].ToString().Split(','))
                            {
                                DepartmentEntity dept = DepartmentBLL.GetList().Where(t => t.OrganizeId == orgId && t.FullName == dt.Rows[0][j].ToString()).FirstOrDefault();
                                if (dept == null)
                                {
                                    continue;
                                }
                                RoleEntity re = postBLL.GetList().Where(a => a.FullName == item.ToString() && a.OrganizeId == orgId && a.DeleteMark == 0 && a.EnabledMark == 1 && a.DeptId == dept.DepartmentId).FirstOrDefault();
                                if (re == null)
                                {
                                    //falseMessage += "</br>" + "第" + (i + 3) + "行岗位有误,未能导入.";
                                    //error++;
                                    continue;
                                }
                                else
                                {
                                    dutyid   += re.RoleId + ",";
                                    dutyName += re.FullName + ",";
                                }
                            }
                        }
                    }

                    dutyid   = dutyid.Length > 0 ? dutyid.Substring(0, dutyid.Length - 1) : "";
                    dutyName = dutyName.Length > 0 ? dutyName.Substring(0, dutyName.Length - 1) : "";
                    StandardsystemEntity standard = new StandardsystemEntity();
                    try
                    {
                        if (!string.IsNullOrEmpty(carrydate))
                        {
                            standard.CARRYDATE = DateTime.Parse(DateTime.Parse(carrydate).ToString("yyyy-MM-dd"));
                        }
                    }
                    catch
                    {
                        falseMessage += "</br>" + "第" + (i + 3) + "行时间有误,未能导入.";
                        error++;
                        continue;
                    }
                    if (!string.IsNullOrEmpty(relevantelement))
                    {
                        foreach (var item in relevantelement.Split(','))
                        {
                            ElementEntity re = elementBLL.GetList("").Where(a => a.NAME == item.ToString()).FirstOrDefault();
                            if (re == null)
                            {
                                //falseMessage += "</br>" + "第" + (i + 2) + "行相应元素有误,未能导入.";
                                //error++;
                                continue;
                            }
                            else
                            {
                                relevantelementname += re.NAME + ",";
                                relevantelementid   += re.ID + ",";
                            }
                        }
                    }
                    relevantelementname          = string.IsNullOrEmpty(relevantelementname) ? "" : relevantelementname.Substring(0, relevantelementname.Length - 1);
                    relevantelementid            = string.IsNullOrEmpty(relevantelementid) ? "" : relevantelementid.Substring(0, relevantelementid.Length - 1);
                    standard.FILENAME            = filename;
                    standard.STATIONID           = dutyid;
                    standard.STATIONNAME         = dutyName;
                    standard.RELEVANTELEMENTNAME = relevantelementname;
                    standard.RELEVANTELEMENTID   = relevantelementid;
                    standard.DISPATCHCODE        = dispatchcode;
                    standard.PUBLISHDEPT         = publishdept;
                    standard.STANDARDTYPE        = standardtype;
                    standard.CATEGORYCODE        = categorycode;
                    standard.CONSULTNUM          = 0;
                    standard.ID = Guid.NewGuid().ToString();
                    var            fileinfo       = new FileInfo(decompressionDirectory + filepath);
                    FileInfoEntity fileInfoEntity = new FileInfoEntity();
                    string         fileguid       = Guid.NewGuid().ToString();
                    fileInfoEntity.Create();
                    fileInfoEntity.RecId          = standard.ID; //关联ID
                    fileInfoEntity.FileName       = filepath;
                    fileInfoEntity.FilePath       = "~/Resource/StandardSystem/" + fileguid + fileinfo.Extension;
                    fileInfoEntity.FileSize       = (Math.Round(decimal.Parse(fileinfo.Length.ToString()) / decimal.Parse("1024"), 2)).ToString();//文件大小(kb)
                    fileInfoEntity.FileExtensions = fileinfo.Extension;
                    fileInfoEntity.FileType       = fileinfo.Extension.Replace(".", "");
                    TransportRemoteToServer(Server.MapPath("~/Resource/StandardSystem/"), decompressionDirectory + filepath, fileguid + fileinfo.Extension);
                    fileinfobll.SaveForm("", fileInfoEntity);
                    try
                    {
                        standardsystembll.SaveForm(standard.ID, standard);
                    }
                    catch
                    {
                        error++;
                    }
                }
                count    = dt.Rows.Count - 1;
                message  = "共有" + count + "条记录,成功导入" + (count - error) + "条,失败" + error + "条";
                message += "</br>" + falseMessage;
            }
            return(message);
        }
Exemple #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public bool Create(RoleEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var created = RolesGateway.Insert(entity, connection, transaction);

            return(created == 1);
        }
Exemple #18
0
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="channelId"></param>
        /// <param name="rechargeProductId"></param>
        public void Recharge(short channelId, int rechargeProductId)
        {
            //1.根据rechargeProductId 查询到充值产品信息
            RechargeProductEntity rechargeProductEntity = RechargeProductCacheModel.Instance.GetEntity(string.Format("[ChannelType]={0} and [ProductId]={1}", 0, rechargeProductId));
            int virtualMoney = rechargeProductEntity.Virtual;

            bool rechargeSuccess   = false;
            byte rechargeErrorType = 0;
            int  remainDays        = 0;

            //2.添加充值记录
            //⑴.检查充值的合法性
            //⑵.进行充值记录的添加

            //⑴.检查充值的合法性
            //如果是月卡 检查到期时间 是否可以购买
            //如果是礼包 检查是否已经购买过
            //如果是普通计费点 但是没有购买过 首充双倍

            RechargeRecordEntity monthCard = null;//定义月卡

            if (rechargeProductEntity.ProductType == 1)
            {
                //月卡
                //是否购买过月卡 或者购买时间超过一个月了
                MFReturnValue <List <RechargeRecordEntity> > retValue = RechargeRecordCacheModel.Instance.GetPageList(condition: string.Format("[RoleId]={0} and [ProductId]={1}", RoleId, rechargeProductId), orderby: "UpdateTime", pageSize: 1, pageIndex: 1);

                if (retValue.Value == null || retValue.Value.Count == 0)
                {
                    rechargeSuccess = true;
                }
                else
                {
                    //说明购买过月卡
                    monthCard = retValue.Value[0];

                    DateTime lastUpdateTime = retValue.Value[0].UpdateTime; //最后一次购买时间
                    remainDays = (DateTime.Now - lastUpdateTime).Days;

                    if (remainDays > 30)
                    {
                        //超过30天 可以购买
                        rechargeSuccess = true;
                    }
                    else
                    {
                        remainDays        = 30 - remainDays - 1;
                        rechargeErrorType = 1;
                    }
                }
            }
            else if (rechargeProductEntity.ProductType == 2)
            {
                //礼包
                RechargeRecordEntity rechargeRecordEntity = RechargeRecordCacheModel.Instance.GetEntity(string.Format("[RoleId]={0} and [ProductId]={1}", RoleId, rechargeProductId));
                if (rechargeRecordEntity == null) //没有买过礼包
                {
                    rechargeSuccess = true;
                }
                else
                {
                    rechargeErrorType = 2;
                }
            }
            else if (rechargeProductEntity.ProductType == 3)
            {
                rechargeSuccess = true;

                //检查是否已经购买过 没购买过就 首充双倍
                RechargeRecordEntity rechargeRecordEntity = RechargeRecordCacheModel.Instance.GetEntity(string.Format("[RoleId]={0} and [ProductId]={1}", RoleId, rechargeProductId));
                if (rechargeRecordEntity == null) //没有买过普通计费点
                {
                    virtualMoney *= 2;            //双倍
                }
            }

            //⑵.添加充值记录
            if (rechargeSuccess)
            {
                //查询是否有月卡记录 有的话先删除旧的
                if (monthCard != null)
                {
                    RechargeRecordCacheModel.Instance.Delete(monthCard.Id);
                }

                RechargeRecordEntity rechargeRecordEntity = new RechargeRecordEntity();
                rechargeRecordEntity.Status     = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
                rechargeRecordEntity.RoleId     = RoleId;
                rechargeRecordEntity.ProductId  = rechargeProductId;
                rechargeRecordEntity.CreateTime = DateTime.Now;
                rechargeRecordEntity.UpdateTime = DateTime.Now;

                RechargeRecordCacheModel.Instance.Create(rechargeRecordEntity);
            }


            //3.给玩家添加元宝 发放道具
            Dictionary <string, object> param = new Dictionary <string, object>();

            param["@Id"] = RoleId;


            RoleEntity entity    = RoleCacheModel.Instance.GetEntity(RoleId);
            int        currMoney = entity.Money; //角色当前身上的元宝

            currMoney += virtualMoney;           //加上充值后 获得的元宝

            param["@Money"]    = currMoney;
            param["@AddMoney"] = virtualMoney;

            this.Money += virtualMoney;

            RoleCacheModel.Instance.Update("[TotalRechargeMoney]=[TotalRechargeMoney]+@AddMoney, [Money]= @Money", "Id=@Id", param); //更新数据库

            //4.通知客户端元宝到账
            RoleData_RechargeReturnProto proto = new RoleData_RechargeReturnProto();

            proto.IsSuccess = rechargeSuccess;
            if (!rechargeSuccess)
            {
                switch (rechargeErrorType)
                {
                case 0:
                default:
                    proto.ErrorCode = 102002;
                    break;

                case 1:
                    proto.ErrorCode = 102004;     //月卡购买失败
                    proto.RemainDay = remainDays;
                    break;

                case 2:
                    proto.ErrorCode = 102005;     //礼包购买失败
                    break;
                }
            }
            else
            {
                proto.RechargeProductId   = rechargeProductId;
                proto.RechargeProductType = rechargeProductEntity.ProductType;
                proto.Money     = currMoney;
                proto.RemainDay = 29;
            }

            Client_Socket.SendMsg(proto.ToArray(this.SocketSendMS));
        }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="connection"></param>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public bool Update(RoleEntity entity, DbConnection connection, DbTransaction transaction)
        {
            var updated = RolesGateway.Update(entity, connection, transaction);

            return(updated == 1);
        }
 protected void rptBrand_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Edit")
     {
         EditRole = new RoleEntity(e.CommandArgument.ToString());
     }
     else if (e.CommandName == "Cancel")
     {
         EditRole = null;
     }
     else if (e.CommandName == "Delete")
     {
         string l_roleName = e.CommandArgument.ToString();
         Roles.DeleteRole(l_roleName);
         //dbRole.DeleteRole(int.Parse(e.CommandArgument.ToString()));
         lSuccess.Visible = true;
         lSuccess.Text = "Role was removed successfully.";
         EditRole = null;
     }
 }
Exemple #21
0
 public int AddRole(RoleEntity objRole)
 {
     return(Role.Add(objRole));
 }
    protected void lbSave_Click(object sender, EventArgs e)
    {
        bool l_isValid = true;
        string l_RoleName = tbRoleName.Text.Trim();

        if (string.IsNullOrEmpty(l_RoleName))
        {
            l_isValid = false;
            tbRoleName.Focus();
        }

        if (!l_isValid) return;

        if (EditRole.IsNewRole)
        {
            if (Roles.RoleExists(l_RoleName))
            {
                lInvalidRole.Visible = true;
                l_isValid = false;
                tbRoleName.Focus();
            }
        }

        if (!l_isValid) return;

        if (EditRole.IsNewRole)
        {
            Roles.DeleteRole(EditRole.RoleName);
            Roles.CreateRole(l_RoleName);
        }
        else
        {
            string[] usernames = Roles.GetUsersInRole(EditRole.RoleName);

            if (usernames != null && usernames.Length>0) Roles.RemoveUsersFromRole(usernames, EditRole.RoleName);
            Roles.DeleteRole(EditRole.RoleName);
            Roles.CreateRole(l_RoleName);
            if (usernames != null && usernames.Length>0) Roles.AddUsersToRole(usernames, l_RoleName);
        }

        //check login aviability
        EditRole = null;
        lSuccess.Visible = true;
    }
Exemple #23
0
 public int UpdateRole(RoleEntity objRole)
 {
     return(Role.Edit(objRole));
 }
 /// <summary> Retrieves the related entity of type 'RoleEntity', using a relation of type 'n:1'</summary>
 /// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
 /// <returns>A fetched entity of type 'RoleEntity' which is related to this entity.</returns>
 public virtual RoleEntity GetSingleRole(bool forceFetch)
 {
     if( ( !_alreadyFetchedRole || forceFetch || _alwaysFetchRole) && !this.IsSerializing && !this.IsDeserializing  && !this.InDesignMode)
     {
         bool performLazyLoading = this.CheckIfLazyLoadingShouldOccur(Relations.RoleEntityUsingRoleID);
         RoleEntity newEntity = new RoleEntity();
         bool fetchResult = false;
         if(performLazyLoading)
         {
             AddToTransactionIfNecessary(newEntity);
             fetchResult = newEntity.FetchUsingPK(this.RoleID);
         }
         if(fetchResult)
         {
             newEntity = (RoleEntity)GetFromActiveContext(newEntity);
         }
         else
         {
             if(!_roleReturnsNewIfNotFound)
             {
                 RemoveFromTransactionIfNecessary(newEntity);
                 newEntity = null;
             }
         }
         this.Role = newEntity;
         _alreadyFetchedRole = fetchResult;
     }
     return _role;
 }
Exemple #25
0
 public int ChangeStateRole(RoleEntity objRole, bool State)
 {
     return(Role.ChangeState(objRole.IdRol, State));
 }
 /// <summary>
 /// There are no comments for RoleEntitySet in the schema.
 /// </summary>
 public void AddToRoleEntitySet(RoleEntity roleEntity)
 {
     base.AddObject("RoleEntitySet", roleEntity);
 }
Exemple #27
0
 public ActionResult SaveForm(string keyValue, RoleEntity jobEntity)
 {
     jobBLL.SaveForm(keyValue, jobEntity);
     return(Success("操作成功。"));
 }
        public async Task <IActionResult> SubmitForm(RoleEntity roleEntity, string keyValue)
        {
            await dutyApp.Save(roleEntity, keyValue, this.UserId);

            return(Success("操作成功。"));
        }
Exemple #29
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="entity"></param>
 public Role(RoleEntity entity)
 {
     this._entity        = entity;
     this.Memberships    = new Collection <long>();
     this.Authorizations = new Collection <long>();
 }
 public void Update(RoleEntity e)
 {
     throw new NotImplementedException();
 }
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected SystemDataEntityBase(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _roleForAnonymous = (RoleEntity)info.GetValue("_roleForAnonymous", typeof(RoleEntity));
            if(_roleForAnonymous!=null)
            {
                _roleForAnonymous.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _roleForAnonymousReturnsNewIfNotFound = info.GetBoolean("_roleForAnonymousReturnsNewIfNotFound");
            _alwaysFetchRoleForAnonymous = info.GetBoolean("_alwaysFetchRoleForAnonymous");
            _alreadyFetchedRoleForAnonymous = info.GetBoolean("_alreadyFetchedRoleForAnonymous");

            _roleForNewUser = (RoleEntity)info.GetValue("_roleForNewUser", typeof(RoleEntity));
            if(_roleForNewUser!=null)
            {
                _roleForNewUser.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _roleForNewUserReturnsNewIfNotFound = info.GetBoolean("_roleForNewUserReturnsNewIfNotFound");
            _alwaysFetchRoleForNewUser = info.GetBoolean("_alwaysFetchRoleForNewUser");
            _alreadyFetchedRoleForNewUser = info.GetBoolean("_alreadyFetchedRoleForNewUser");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Exemple #32
0
 public ActionResult SaveForm(string keyValue, RoleEntity roleEntity)
 {
     roleBLL.SaveRole(keyValue, roleEntity);
     return(Success("操作成功。"));
 }
 /// <summary> Removes the sync logic for member _roleForAnonymous</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncRoleForAnonymous(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _roleForAnonymous, new PropertyChangedEventHandler( OnRoleForAnonymousPropertyChanged ), "RoleForAnonymous", SD.HnD.DAL.RelationClasses.StaticSystemDataRelations.RoleEntityUsingAnonymousRoleStatic, true, signalRelatedEntity, "SystemDataAnonymousRole", resetFKFields, new int[] { (int)SystemDataFieldIndex.AnonymousRole } );
     _roleForAnonymous = null;
 }
 public ActionResult SaveForm(string keyValue, RoleEntity userGroupEntity)
 {
     userGroupBLL.SaveForm(keyValue, userGroupEntity);
     return(Success("操作成功。"));
 }
 /// <summary> Removes the sync logic for member _roleForNewUser</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncRoleForNewUser(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _roleForNewUser, new PropertyChangedEventHandler( OnRoleForNewUserPropertyChanged ), "RoleForNewUser", SD.HnD.DAL.RelationClasses.StaticSystemDataRelations.RoleEntityUsingDefaultRoleNewUserStatic, true, signalRelatedEntity, "SystemDataDefaultRoleNewUser", resetFKFields, new int[] { (int)SystemDataFieldIndex.DefaultRoleNewUser } );
     _roleForNewUser = null;
 }
Exemple #36
0
        protected override void Seed(JuCheapContext context)
        {
            #region 用户

            var admin = new UserEntity
            {
                LoginName      = "jucheap",
                RealName       = "超级管理员",
                Password       = "******".ToMD5(),
                Email          = "*****@*****.**",
                Status         = 2,
                CreateDateTime = now
            };
            var guest = new UserEntity
            {
                LoginName      = "admin",
                RealName       = "游客",
                Password       = "******".ToMD5(),
                Email          = "*****@*****.**",
                Status         = 2,
                CreateDateTime = now
            };
            //用户
            var user = new List <UserEntity>
            {
                admin,
                guest
            };
            #endregion

            #region 菜单

            var system = new MenuEntity
            {
                Name           = "系统设置",
                Url            = "#",
                Type           = 1,
                CreateDateTime = now,
                Order          = 1
            };
            var menuMgr = new MenuEntity
            {
                ParentId       = 1,
                Name           = "菜单管理",
                Url            = "/Adm/Menu/Index",
                Type           = 2,
                CreateDateTime = now,
                Order          = 2
            };//2
            var roleMgr = new MenuEntity
            {
                ParentId       = 1,
                Name           = "角色管理",
                Url            = "/Adm/Role/Index",
                Type           = 2,
                CreateDateTime = now,
                Order          = 3
            };//3
            var userMgr = new MenuEntity
            {
                ParentId       = 1,
                Name           = "用户管理",
                Url            = "/Adm/User/Index",
                Type           = 2,
                CreateDateTime = now,
                Order          = 4
            };//4
            var roleAuthMgr = new MenuEntity
            {
                ParentId       = 1,
                Name           = "角色授权",
                Url            = "/Adm/Role/AuthMenus",
                Type           = 2,
                CreateDateTime = now,
                Order          = 5
            };//5

            var mail = new MenuEntity
            {
                Name           = "邮件系统",
                Url            = "#",
                Type           = 1,
                CreateDateTime = now,
                Order          = 6
            };//6
            var mailMgr = new MenuEntity
            {
                ParentId       = 6,
                Name           = "邮件列表",
                Url            = "/Adm/Email/Index",
                Type           = 2,
                CreateDateTime = now,
                Order          = 7
            };//7
            var log = new MenuEntity
            {
                Name           = "日志查看",
                Url            = "#",
                Type           = 1,
                CreateDateTime = now,
                Order          = 8
            };//8

            //菜单
            var menus = new List <MenuEntity>
            {
                system,
                menuMgr,
                roleMgr,
                userMgr,
                roleAuthMgr,
                mail,
                mailMgr,
                log,
                new MenuEntity
                {
                    ParentId       = 8,
                    Name           = "登录日志",
                    Url            = "/Adm/Loginlog/Index",
                    Type           = 2,
                    CreateDateTime = now,
                    Order          = 9
                },
                new MenuEntity
                {
                    ParentId       = 8,
                    Name           = "访问日志",
                    Url            = "/Adm/PageView/Index",
                    Type           = 2,
                    CreateDateTime = now,
                    Order          = 10
                }
            };
            var menuBtns = GetMenuButtons(2, "Menu"); //13
            var rolwBtns = GetMenuButtons(3, "Role"); //16
            var userBtns = GetMenuButtons(4, "User"); //19
            userBtns.Add(new MenuEntity
            {
                ParentId       = 4,
                Name           = "用户角色授权",
                Url            = string.Format("/Adm/{0}/Authen", "User"),
                Type           = 3,
                CreateDateTime = now,
                Order          = 11
            });                       //20

            menus.AddRange(menuBtns); //23
            menus.AddRange(rolwBtns); //26
            menus.AddRange(userBtns); //29
            var demo = new MenuEntity
            {
                ParentId       = 0, Name = "示例文档", Url = "#", Type = 1, Order = 12,
                CreateDateTime = now
            };//30
            var demoAdv = new MenuEntity
            {
                ParentId       = 0, Name = "高级示例", Url = "#", Type = 1,
                Order          = 13,
                CreateDateTime = now
            };//31
            menus.Add(new MenuEntity {
                ParentId = mailMgr.Id, Name = "发送邮件", Url = "/Adm/Email/Add", Type = 3, Order = 14, CreateDateTime = now
            });
            menus.Add(demo);
            menus.Add(demoAdv);
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "按钮", Url = "/Adm/Demo/Base", Type = 2, Order = 15, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "ICON图标", Url = "/Adm/Demo/Fontawosome", Type = 2, Order = 16, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "表单", Url = "/Adm/Demo/Form", Type = 2, Order = 17, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "高级控件", Url = "/Adm/Demo/Advance", Type = 2, Order = 18, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "相册", Url = "/Adm/Demo/Gallery", Type = 2, Order = 19, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "个人主页", Url = "/Adm/Demo/Profile", Type = 2, Order = 20, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "邮件-收件箱", Url = "/Adm/Demo/InBox", Type = 2, Order = 21, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "邮件-查看邮件", Url = "/Adm/Demo/InBoxDetail", Type = 2, Order = 22, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 22, Name = "邮件-写邮件", Url = "/Adm/Demo/InBoxCompose", Type = 2, Order = 23, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "编辑器", Url = "/Adm/Demo/Editor", Type = 2, Order = 24, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "表单验证", Url = "/Adm/Demo/FormValidate", Type = 2, Order = 25, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "图表", Url = "/Adm/Demo/Chart", Type = 2, Order = 26, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "图表-Morris", Url = "/Adm/Demo/ChartMorris", Type = 2, Order = 27, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "ChartJs", Url = "/Adm/Demo/ChartJs", Type = 2, Order = 28, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "表格", Url = "/Adm/Demo/DataTable", Type = 2, Order = 29, CreateDateTime = now
            });
            menus.Add(new MenuEntity {
                ParentId = 23, Name = "高级表格", Url = "/Adm/Demo/DataTableAdv", Type = 2, Order = 30, CreateDateTime = now
            });


            #endregion

            #region 角色

            var superAdminRole = new RoleEntity {
                Name = "超级管理员", Description = "超级管理员"
            };
            var guestRole = new RoleEntity {
                Name = "guest", Description = "游客"
            };
            List <RoleEntity> roles = new List <RoleEntity>
            {
                superAdminRole,
                guestRole
            };

            #endregion

            #region 用户角色关系

            List <UserRoleEntity> userRoles = new List <UserRoleEntity>
            {
                new UserRoleEntity {
                    UserId = 1, RoleId = 1
                },
                new UserRoleEntity {
                    UserId = 2, RoleId = 2
                }
            };

            #endregion

            #region 角色菜单权限关系
            //超级管理员授权/游客授权
            List <RoleMenuEntity> roleMenus = new List <RoleMenuEntity>();
            var len = menus.Count;
            for (int i = 0; i < len; i++)
            {
                roleMenus.Add(new RoleMenuEntity {
                    RoleId = 1, MenuId = i + 1
                });
                roleMenus.Add(new RoleMenuEntity {
                    RoleId = 2, MenuId = i + 1
                });
            }

            #endregion

            AddOrUpdate(context, m => m.LoginName, user.ToArray());

            AddOrUpdate(context, m => new { m.ParentId, m.Name, m.Type }, menus.ToArray());

            AddOrUpdate(context, m => m.Name, roles.ToArray());

            AddOrUpdate(context, m => new { m.UserId, m.RoleId }, userRoles.ToArray());

            AddOrUpdate(context, m => new { m.MenuId, m.RoleId }, roleMenus.ToArray());
        }
 /// <summary> setups the sync logic for member _roleForAnonymous</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncRoleForAnonymous(IEntityCore relatedEntity)
 {
     if(_roleForAnonymous!=relatedEntity)
     {
         DesetupSyncRoleForAnonymous(true, true);
         _roleForAnonymous = (RoleEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _roleForAnonymous, new PropertyChangedEventHandler( OnRoleForAnonymousPropertyChanged ), "RoleForAnonymous", SD.HnD.DAL.RelationClasses.StaticSystemDataRelations.RoleEntityUsingAnonymousRoleStatic, true, ref _alreadyFetchedRoleForAnonymous, new string[] {  } );
     }
 }
Exemple #38
0
 public ActionResult SubmitForm(RoleEntity roleEntity, string keyValue)
 {
     dutyApp.SubmitForm(roleEntity, keyValue);
     return(Success("操作成功。"));
 }
 /// <summary> setups the sync logic for member _roleForNewUser</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncRoleForNewUser(IEntityCore relatedEntity)
 {
     if(_roleForNewUser!=relatedEntity)
     {
         DesetupSyncRoleForNewUser(true, true);
         _roleForNewUser = (RoleEntity)relatedEntity;
         this.PerformSetupSyncRelatedEntity( _roleForNewUser, new PropertyChangedEventHandler( OnRoleForNewUserPropertyChanged ), "RoleForNewUser", SD.HnD.DAL.RelationClasses.StaticSystemDataRelations.RoleEntityUsingDefaultRoleNewUserStatic, true, ref _alreadyFetchedRoleForNewUser, new string[] {  } );
     }
 }
 internal static RoleInfo ToRoleInfo(RoleEntity roleEntity)
 {
     RoleInfo roleInfo = new RoleInfo();
     roleInfo.RoleID = roleEntity.RoleID;
     roleInfo.RoleName = roleEntity.RoleName;
     roleInfo.Remark = roleEntity.Remark;
     return roleInfo;
 }
Exemple #41
0
    public void EquipPutOff(int roleId, int goodsId, int goodsServerId, ref List <Role_BackpackItemChangeEntity> changeList)
    {
        MFReturnValue <object> retValue = null;

        //1.把当前的装备卸下(卸下的装备加入背包更新项 新增)
        //excel表格中的数据
        EquipEntity entity = DataTableManager.Instance.EquipDBModel.Get(goodsId);

        RoleEntity roleEntity = this.GetEntity(roleId);

        switch (entity.Type)
        {
        case 100:
            roleEntity.Equip_Weapon = -1;     //
            break;

        case 200:
            roleEntity.Equip_Cuff = -1;     //
            break;

        case 300:
            roleEntity.Equip_Clothes = -1;     //
            break;

        case 400:
            roleEntity.Equip_Pants = -1;     //
            break;

        case 500:
            roleEntity.Equip_Shoe = -1;     //
            break;

        case 600:
            roleEntity.Equip_Ring = -1;     //
            break;

        case 700:
            roleEntity.Equip_Necklace = -1;     //
            break;

        case 800:
            roleEntity.Equip_Belt = -1;     //
            break;
        }

        //找到当前身上穿的武器 设置状态为脱下
        Role_EquipEntity equipPutOffEntity = Role_EquipDBModel.Instance.GetEntity(goodsServerId);

        equipPutOffEntity.IsPutOn = false;
        Role_EquipDBModel.Instance.Update(equipPutOffEntity);

        //把脱下的武器加入背包
        Role_BackpackEntity backpackEntity = new Role_BackpackEntity();

        backpackEntity.Status            = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
        backpackEntity.RoleId            = roleId;
        backpackEntity.GoodsType         = (byte)0;
        backpackEntity.GoodsId           = goodsId;
        backpackEntity.GoodsOverlayCount = 1;
        backpackEntity.GoodsServerId     = goodsServerId;
        backpackEntity.CreateTime        = DateTime.Now;
        backpackEntity.UpdateTime        = DateTime.Now;

        retValue          = Role_BackpackDBModel.Instance.Create(backpackEntity);
        backpackEntity.Id = retValue.GetOutputValue <int>("Id");

        changeList.Add(new Role_BackpackItemChangeEntity()
        {
            BackpackId    = backpackEntity.Id.Value,
            Type          = BackpackItemChangeType.Add,
            GoodsType     = GoodsType.Equip,
            GoodsId       = goodsId,
            GoodsCount    = 1,
            GoodsServerId = goodsServerId
        });

        //2.重新计算角色战斗力(发送角色战斗里更新消息)
        UpdateFighting(roleEntity);
    }
 public static List<RoleEntity> GetRoles(string[] rolenames)
 {
     List<RoleEntity> l_RoleEntities = new List<RoleEntity>();
     if (rolenames != null)
     {
         foreach (string l_Rolename in rolenames)
         {
             RoleEntity l_CustomRole = new RoleEntity(l_Rolename);
             l_RoleEntities.Add(l_CustomRole);
         }
     }
     return l_RoleEntities;
 }
Exemple #43
0
    //100 武器
    //200 护腕
    //300 衣服
    //400 护腿
    //500 鞋
    //600 戒指
    //700 项链
    //800 腰带

    public void EquipPutOn(int roleId, int goodsId, int goodsServerId, ref List <Role_BackpackItemChangeEntity> changeList)
    {
        //1.检查原来的装备槽上是否有装备 有的话先卸下(卸下的装备加入背包更新项 新增)
        //2.把当前装备穿戴到身上(穿戴的装备加入背包更新项目 删除)
        //3.重新计算角色战斗力(发送角色战斗里更新消息)

        MFReturnValue <object> retValue = null;

        //excel表格中的数据
        EquipEntity entity = DataTableManager.Instance.EquipDBModel.Get(goodsId);

        //1.检查原来的装备槽上是否有装备 有的话先卸下(卸下的装备加入背包更新项 新增)
        bool isHasPutOffEquip    = false;
        int  putOffEquipServerId = 0; //脱下的装备服务器端编号

        RoleEntity roleEntity = this.GetEntity(roleId);

        switch (entity.Type)
        {
        case 100:
            if (roleEntity.Equip_Weapon > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Weapon;
            }
            roleEntity.Equip_Weapon = goodsServerId;     //设置新装备
            break;

        case 200:
            if (roleEntity.Equip_Cuff > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Cuff;
            }
            roleEntity.Equip_Cuff = goodsServerId;     //设置新装备
            break;

        case 300:
            if (roleEntity.Equip_Clothes > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Clothes;
            }
            roleEntity.Equip_Clothes = goodsServerId;     //设置新装备
            break;

        case 400:
            if (roleEntity.Equip_Pants > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Pants;
            }
            roleEntity.Equip_Pants = goodsServerId;     //设置新装备
            break;

        case 500:
            if (roleEntity.Equip_Shoe > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Shoe;
            }
            roleEntity.Equip_Shoe = goodsServerId;     //设置新装备
            break;

        case 600:
            if (roleEntity.Equip_Ring > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Ring;
            }
            roleEntity.Equip_Ring = goodsServerId;     //设置新装备
            break;

        case 700:
            if (roleEntity.Equip_Necklace > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Necklace;
            }
            roleEntity.Equip_Necklace = goodsServerId;     //设置新装备
            break;

        case 800:
            if (roleEntity.Equip_Belt > 0)
            {
                isHasPutOffEquip    = true;
                putOffEquipServerId = roleEntity.Equip_Belt;
            }
            roleEntity.Equip_Belt = goodsServerId;     //设置新装备
            break;
        }

        if (isHasPutOffEquip)
        {
            //找到当前身上穿的武器 设置状态为脱下
            Role_EquipEntity equipPutOffEntity = Role_EquipDBModel.Instance.GetEntity(putOffEquipServerId);
            equipPutOffEntity.IsPutOn = false;
            Role_EquipDBModel.Instance.Update(equipPutOffEntity);

            //把脱下的武器加入背包
            Role_BackpackEntity backpackEntity = new Role_BackpackEntity();
            backpackEntity.Status            = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
            backpackEntity.RoleId            = roleId;
            backpackEntity.GoodsType         = (byte)0;
            backpackEntity.GoodsId           = equipPutOffEntity.EquipId;
            backpackEntity.GoodsOverlayCount = 1;
            backpackEntity.GoodsServerId     = putOffEquipServerId;
            backpackEntity.CreateTime        = DateTime.Now;
            backpackEntity.UpdateTime        = DateTime.Now;

            retValue          = Role_BackpackDBModel.Instance.Create(backpackEntity);
            backpackEntity.Id = retValue.GetOutputValue <int>("Id");

            changeList.Add(new Role_BackpackItemChangeEntity()
            {
                BackpackId    = backpackEntity.Id.Value,
                Type          = BackpackItemChangeType.Add,
                GoodsType     = GoodsType.Equip,
                GoodsId       = equipPutOffEntity.EquipId,
                GoodsCount    = 1,
                GoodsServerId = putOffEquipServerId
            });
        }

        //2.把当前装备穿戴到身上(穿戴的装备加入背包更新项目 删除)
        Role_EquipEntity equipPutOnEntity = Role_EquipDBModel.Instance.GetEntity(goodsServerId);

        equipPutOnEntity.IsPutOn = true;
        Role_EquipDBModel.Instance.Update(equipPutOnEntity);

        //查询当前装备的背包项
        Role_BackpackEntity currEquipBackpackEntity = Role_BackpackDBModel.Instance.GetEntity(string.Format(" [RoleId]={0} and [GoodsId]={1} and [GoodsType]=0 and [GoodsServerId]={2}", roleId, goodsId, goodsServerId));

        Role_BackpackDBModel.Instance.Delete(currEquipBackpackEntity.Id); //从背包中移除
        changeList.Add(new Role_BackpackItemChangeEntity()
        {
            BackpackId    = currEquipBackpackEntity.Id.Value,
            Type          = BackpackItemChangeType.Delete,
            GoodsType     = GoodsType.Equip,
            GoodsId       = goodsId,
            GoodsCount    = 1,
            GoodsServerId = goodsServerId
        });

        //3.重新计算角色战斗力
        UpdateFighting(roleEntity);
    }
 protected void lbNew_Click(object sender, EventArgs e)
 {
     EditRole = new RoleEntity("-1", true);
 }
Exemple #45
0
    /// <summary>
    /// 更新角色战斗力
    /// </summary>
    /// <param name="roleEntity"></param>
    private void UpdateFighting(RoleEntity roleEntity)
    {
        //1.计算角色基础属性 和等级有关
        //给角色战斗相关的属性赋值
        //职业 等级
        JobEntity jobEntity = DataTableManager.Instance.JobDBModel.Get(roleEntity.JobId);

        //职业等级数据
        JobLevelEntity jobLevelEntity = DataTableManager.Instance.JobLevelDBModel.Get(roleEntity.Level);

        roleEntity.MaxHP = jobLevelEntity.HP;
        roleEntity.MaxMP = jobLevelEntity.MP;

        //roleEntity.Attack = (int)Math.Round(jobEntity.Attack * jobLevelEntity.Attack * 0.01f);
        //roleEntity.Defense = (int)Math.Round(jobEntity.Defense * jobLevelEntity.Defense * 0.01f);
        //roleEntity.Hit = (int)Math.Round(jobEntity.Hit * jobLevelEntity.Hit * 0.01f);
        //roleEntity.Dodge = (int)Math.Round(jobEntity.Dodge * jobLevelEntity.Dodge * 0.01f);
        //roleEntity.Cri = (int)Math.Round(jobEntity.Cri * jobLevelEntity.Cri * 0.01f);
        //roleEntity.Res = (int)Math.Round(jobEntity.Res * jobLevelEntity.Res * 0.01f);

        //2.计算角色装备增加的属性
        List <Role_EquipEntity> lst = Role_EquipDBModel.Instance.GetList(condition: string.Format("[RoleId]={0} and [IsPutOn]=1", roleEntity.Id));

        if (lst != null && lst.Count > 0)
        {
            for (int i = 0; i < lst.Count; i++)
            {
                Role_EquipEntity role_EquipEntity = lst[i];

                //0=HP 1=MP 2=攻击 3=防御 4=命中 5=闪避 6=暴击 7=抗性

                #region 基础属性1
                switch (role_EquipEntity.BaseAttr1Type)
                {
                case 0:
                    roleEntity.MaxHP += role_EquipEntity.BaseAttr1Value;
                    break;

                case 1:
                    roleEntity.MaxMP += role_EquipEntity.BaseAttr1Value;
                    break;
                    //case 2:
                    //    roleEntity.Attack += role_EquipEntity.BaseAttr1Value;
                    //    break;
                    //case 3:
                    //    roleEntity.Defense += role_EquipEntity.BaseAttr1Value;
                    //    break;
                    //case 4:
                    //    roleEntity.Hit += role_EquipEntity.BaseAttr1Value;
                    //    break;
                    //case 5:
                    //    roleEntity.Dodge += role_EquipEntity.BaseAttr1Value;
                    //    break;
                    //case 6:
                    //    roleEntity.Cri += role_EquipEntity.BaseAttr1Value;
                    //    break;
                    //case 7:
                    //    roleEntity.Res += role_EquipEntity.BaseAttr1Value;
                    //    break;
                }
                #endregion

                #region 基础属性2
                switch (role_EquipEntity.BaseAttr2Type)
                {
                case 0:
                    roleEntity.MaxHP += role_EquipEntity.BaseAttr2Value;
                    break;

                case 1:
                    roleEntity.MaxMP += role_EquipEntity.BaseAttr2Value;
                    break;
                    //case 2:
                    //    roleEntity.Attack += role_EquipEntity.BaseAttr2Value;
                    //    break;
                    //case 3:
                    //    roleEntity.Defense += role_EquipEntity.BaseAttr2Value;
                    //    break;
                    //case 4:
                    //    roleEntity.Hit += role_EquipEntity.BaseAttr2Value;
                    //    break;
                    //case 5:
                    //    roleEntity.Dodge += role_EquipEntity.BaseAttr2Value;
                    //    break;
                    //case 6:
                    //    roleEntity.Cri += role_EquipEntity.BaseAttr2Value;
                    //    break;
                    //case 7:
                    //    roleEntity.Res += role_EquipEntity.BaseAttr2Value;
                    //    break;
                }
                #endregion

                //roleEntity.Attack += role_EquipEntity.Attack;
                //roleEntity.Defense += role_EquipEntity.Defense;
                //roleEntity.Hit += role_EquipEntity.Hit;
                //roleEntity.Dodge += role_EquipEntity.Dodge;
                //roleEntity.Cri += role_EquipEntity.Cri;
                //roleEntity.Res += role_EquipEntity.Res;
            }
        }

        //3.计算综合战斗力
        //roleEntity.Fighting = roleEntity.Attack * 4 + roleEntity.Defense * 4 + roleEntity.Hit * 2 + roleEntity.Dodge * 2 + roleEntity.Cri + roleEntity.Res;

        RoleDBModel.Instance.Update(roleEntity);
    }
Exemple #46
0
 protected override IdentityRoleClaim <long> CreateRoleClaim(RoleEntity role, Claim claim)
 {
     return(new IdentityRoleClaim <long> {
         RoleId = role.Id, ClaimType = claim.Type, ClaimValue = claim.Value
     });
 }
Exemple #47
0
        public ActionResult GetTreeJson(string organize_id)
        {
            var treeList = new List <TreeViewModel>();
            //获取所有分公司和部门信息
            var data = organizeApp.GetList();
            //分公司
            OrganizeEntity        company        = organizeApp.GetOrgById(organize_id);
            TreeViewModel         tree           = new TreeViewModel();
            List <OrganizeEntity> departmentList = data.FindAll(t => t.F_ParentId == company.F_Id);
            bool hasChildren = departmentList.Count == 0 ? false : true;

            tree.id          = company.F_Id;
            tree.text        = company.F_FullName;
            tree.value       = company.F_EnCode;
            tree.parentId    = company.F_ParentId;
            tree.isexpand    = true;
            tree.complete    = true;
            tree.hasChildren = hasChildren;
            tree.nodeDepth   = 1;
            treeList.Add(tree);
            //部门
            if (hasChildren)
            {
                for (int i = 0; i < departmentList.Count; i++)
                {
                    OrganizeEntity    department     = departmentList[i];
                    TreeViewModel     departmentTree = new TreeViewModel();
                    var               roleData       = roleApp.GetDutyList();
                    List <RoleEntity> dutyList       = roleData.FindAll(t => t.F_OrganizeId == department.F_Id && t.F_Category == 2);
                    hasChildren                = dutyList.Count == 0 ? false : true;
                    departmentTree.id          = department.F_Id;
                    departmentTree.text        = department.F_FullName;
                    departmentTree.value       = department.F_EnCode;
                    departmentTree.parentId    = company.F_Id;
                    departmentTree.isexpand    = true;
                    departmentTree.complete    = true;
                    departmentTree.hasChildren = hasChildren;
                    departmentTree.nodeDepth   = 2;
                    treeList.Add(departmentTree);
                    //岗位
                    if (hasChildren)
                    {
                        for (int j = 0; j < dutyList.Count; j++)
                        {
                            RoleEntity        duty     = dutyList[j];
                            TreeViewModel     dutyTree = new TreeViewModel();
                            var               userData = userApp.GetList();
                            List <UserEntity> userList = userData.FindAll(t => t.F_DutyId == duty.F_Id && t.F_OrganizeId == company.F_Id && t.F_DepartmentId == department.F_Id);
                            hasChildren          = userList.Count == 0 ? false : true;
                            dutyTree.id          = duty.F_Id;
                            dutyTree.text        = duty.F_FullName;
                            dutyTree.value       = duty.F_EnCode;
                            dutyTree.parentId    = department.F_Id;
                            dutyTree.isexpand    = true;
                            dutyTree.complete    = true;
                            dutyTree.hasChildren = hasChildren;
                            dutyTree.nodeDepth   = 3;
                            treeList.Add(dutyTree);
                            if (hasChildren)
                            {
                                for (int k = 0; k < userList.Count; k++)
                                {
                                    UserEntity    user     = userList[k];
                                    TreeViewModel userTree = new TreeViewModel();
                                    hasChildren          = false;
                                    userTree.id          = user.F_Id;
                                    userTree.text        = user.F_RealName;
                                    userTree.value       = user.F_Id;
                                    userTree.parentId    = duty.F_Id;
                                    userTree.isexpand    = true;
                                    userTree.complete    = true;
                                    userTree.hasChildren = hasChildren;
                                    userTree.nodeDepth   = 4;
                                    treeList.Add(userTree);
                                }
                            }
                        }
                    }
                }
            }
            return(Content(treeList.TreeViewJson(company.F_ParentId)));
        }
        /// <summary>Private CTor for deserialization</summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected ForumRoleForumActionRightEntityBase(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            _actionRight = (ActionRightEntity)info.GetValue("_actionRight", typeof(ActionRightEntity));
            if(_actionRight!=null)
            {
                _actionRight.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _actionRightReturnsNewIfNotFound = info.GetBoolean("_actionRightReturnsNewIfNotFound");
            _alwaysFetchActionRight = info.GetBoolean("_alwaysFetchActionRight");
            _alreadyFetchedActionRight = info.GetBoolean("_alreadyFetchedActionRight");

            _forum = (ForumEntity)info.GetValue("_forum", typeof(ForumEntity));
            if(_forum!=null)
            {
                _forum.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _forumReturnsNewIfNotFound = info.GetBoolean("_forumReturnsNewIfNotFound");
            _alwaysFetchForum = info.GetBoolean("_alwaysFetchForum");
            _alreadyFetchedForum = info.GetBoolean("_alreadyFetchedForum");

            _role = (RoleEntity)info.GetValue("_role", typeof(RoleEntity));
            if(_role!=null)
            {
                _role.AfterSave+=new EventHandler(OnEntityAfterSave);
            }
            _roleReturnsNewIfNotFound = info.GetBoolean("_roleReturnsNewIfNotFound");
            _alwaysFetchRole = info.GetBoolean("_alwaysFetchRole");
            _alreadyFetchedRole = info.GetBoolean("_alreadyFetchedRole");
            this.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance());
            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Exemple #49
0
        public async Task InitDefaultRoles()
        {
            await Execute(async() =>
            {
                using (UnitOfWork db = new UnitOfWork())
                {
                    IRepo <RoleEntity> roleRepo = db.GetRepo <RoleEntity>();

                    IList <RoleEntity> defaultRoles        = await roleRepo.Get(role => role.is_default);
                    IList <DbPermissionEntity> permissions = await db.GetRepo <DbPermissionEntity>().Get();

                    if (defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.AUTHORIZED.ToName()) == null)
                    {
                        RoleEntity authorizedRole = new RoleEntity()
                        {
                            is_default = true,
                            name       = DefaultRoles.AUTHORIZED.ToName()
                        };

                        authorizedRole.DbPermissions.AddRange(
                            permissions.Where(p =>
                                              p.table_name == DbTable.Account.ToName() && (
                                                  p.DbPermissionType.name == InteractionDbType.READ.ToName() ||
                                                  p.DbPermissionType.name == InteractionDbType.UPDATE.ToName()
                                                  )
                                              ).ToArray()
                            );

                        authorizedRole.DbPermissions.AddRange(
                            permissions.Where(p =>
                                              p.table_name == DbTable.Company.ToName() &&
                                              p.DbPermissionType.name == InteractionDbType.CREATE.ToName()
                                              ).ToArray()
                            );

                        await roleRepo.Create(authorizedRole);
                    }

                    if (defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.HIRED.ToName()) == null)
                    {
                        RoleEntity hiredRole = new RoleEntity()
                        {
                            is_default = true,
                            name       = DefaultRoles.HIRED.ToName()
                        };

                        hiredRole.DbPermissions.AddRange(
                            permissions.Where(p =>
                                              p.table_name == DbTable.Account.ToName() && (
                                                  p.DbPermissionType.name == InteractionDbType.READ.ToName() ||
                                                  p.DbPermissionType.name == InteractionDbType.UPDATE.ToName()
                                                  )
                                              ).ToArray()
                            );

                        await roleRepo.Create(hiredRole);
                    }

                    if (defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.OWNER.ToName()) == null)
                    {
                        RoleEntity ownerRole = new RoleEntity()
                        {
                            is_default = true,
                            name       = DefaultRoles.OWNER.ToName()
                        };

                        ownerRole.DbPermissions.AddRange(
                            permissions.Where(p =>
                                              (
                                                  (
                                                      p.table_name != DbTable.DbPermissionType.ToName() &&
                                                      p.table_name != DbTable.DbPermission.ToName() &&
                                                      p.table_name != DbTable.DataType.ToName() &&
                                                      p.table_name != DbTable.VisualizerType.ToName()
                                                  ) || p.DbPermissionType.name == InteractionDbType.READ.ToName()
                                              ) &&
                                              (
                                                  p.table_name != DbTable.Company.ToName() ||
                                                  p.DbPermissionType.name != InteractionDbType.CREATE.ToName()
                                              )
                                              ).ToArray()
                            );

                        await roleRepo.Create(ownerRole);
                    }

                    if (defaultRoles.FirstOrDefault(role => role.name == DefaultRoles.SUPERADMIN.ToName()) == null)
                    {
                        RoleEntity superadminRole = new RoleEntity()
                        {
                            is_default = true,
                            name       = DefaultRoles.SUPERADMIN.ToName()
                        };

                        superadminRole.DbPermissions.AddRange(
                            permissions.Where(
                                p => p.table_name == DbTable.DataType.ToName() ||
                                p.table_name == DbTable.DbPermissionType.ToName() ||
                                p.table_name == DbTable.DbPermission.ToName() ||
                                p.table_name == DbTable.VisualizerType.ToName()
                                ).ToArray()
                            );

                        await roleRepo.Create(superadminRole);
                    }

                    await db.Save();
                }
            });
        }
 /// <summary> Removes the sync logic for member _role</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncRole(bool signalRelatedEntity, bool resetFKFields)
 {
     this.PerformDesetupSyncRelatedEntity( _role, new PropertyChangedEventHandler( OnRolePropertyChanged ), "Role", SD.HnD.DAL.RelationClasses.StaticForumRoleForumActionRightRelations.RoleEntityUsingRoleIDStatic, true, signalRelatedEntity, "ForumRoleForumActionRights", resetFKFields, new int[] { (int)ForumRoleForumActionRightFieldIndex.RoleID } );
     _role = null;
 }
Exemple #51
0
        /// <summary>
        /// Modifies the given role: it resets the system action rights for the given role to the given set of action rights and it modifies
        /// the role description for the given role. If the user specified a role description that is already available, false will be returned to signal
        /// that the save failed.
        /// </summary>
        /// <param name="actionRightIDs">The action rights.</param>
        /// <param name="roleID">The role ID.</param>
        /// <param name="roleDescription">The role description.</param>
        /// <returns>true if succeeded, false otherwise</returns>
        public static bool ModifyRole(List <int> actionRightIDs, int roleID, string roleDescription)
        {
            // read the existing role entity from the database.
            RoleEntity roleToModify = new RoleEntity(roleID);

            if (roleToModify.IsNew)
            {
                // not found
                return(false);
            }

            // check if the description is different. If so, we've to check if the new roledescription is already present. If so, we'll
            // abort the save
            if (roleToModify.RoleDescription != roleDescription)
            {
                if (CheckIfRoleDescriptionIsPresent(roleDescription))
                {
                    // new description, is already present, fail
                    return(false);
                }
            }

            // all set. We're going to delete all Role - SystemAction Rights combinations first, as we're going to re-insert them later on.
            // We'll use a transaction to be able to roll back all our changes if something fails.
            Transaction trans = new Transaction(IsolationLevel.ReadCommitted, "ModifyRole");

            try
            {
                RoleSystemActionRightCollection roleActionRights = new RoleSystemActionRightCollection();
                // add this collection to the transaction so all actions executed through this collection will be inside the transaction
                trans.Add(roleActionRights);
                // delete all role-systemactionright combinations directly from the database, by issuing a direct delete on the database, using a filter
                // on roleid
                roleActionRights.DeleteMulti(RoleSystemActionRightFields.RoleID == roleID);

                // add new role-systemactionright entities which we'll save to the database after that
                foreach (int actionRightID in actionRightIDs)
                {
                    RoleSystemActionRightEntity toAdd = new RoleSystemActionRightEntity();
                    toAdd.ActionRightID = actionRightID;
                    toAdd.RoleID        = roleID;
                    roleActionRights.Add(toAdd);
                }
                // save the new entities to the database
                roleActionRights.SaveMulti();

                // we'll now save the role and the role description, if it's changed. Otherwise the save action will be a no-op.
                // add it to the transaction
                trans.Add(roleToModify);
                roleToModify.RoleDescription = roleDescription;
                roleToModify.Save();

                // all done, commit the transaction
                trans.Commit();
                return(true);
            }
            catch
            {
                // failed, roll back transaction.
                trans.Rollback();
                throw;
            }
            finally
            {
                trans.Dispose();
            }
        }
 /// <summary>
 /// Create a new RoleEntity object.
 /// </summary>
 /// <param name="id">Initial value of Id.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="description">Initial value of Description.</param>
 public static RoleEntity CreateRoleEntity(int id, string name, string description)
 {
     RoleEntity roleEntity = new RoleEntity();
     roleEntity.Id = id;
     roleEntity.Name = name;
     roleEntity.Description = description;
     return roleEntity;
 }
        internal bool SetUserSso()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(false);
            }

            string email = null;

            foreach (var claim in ((ClaimsPrincipal)User).Claims)
            {
                if (claim.Type == "preferred_username")
                {
                    email = claim.Value;
                    break;
                }
            }

            var user = UserServices.GetUser(email);

            if (user == null)
            {
                user = new UserEntity
                {
                    Email       = email,
                    Name        = email,
                    Surname     = email,
                    AdLogonName = email
                };
                user = UserServices.CreateUser(user);

                if (user != null)
                {
                    UserRoleServices.CreateUserRole(new UserRoleEntity
                    {
                        UserId = user.UserId,
                        RoleId = 3
                    });
                }
            }

            if (user == null)
            {
                return(false);
            }

            var userRoles = GetUserRoles(user.UserId);

            User.AddUpdateClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", user.Email.ToLower());
            User.AddUpdateClaim("sub", user.Email.ToLower());

            foreach (var userRole in userRoles)
            {
                User.AddClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", userRole.RoleName);
            }

            var list = ((ClaimsPrincipal)User).Claims.Where(claim => claim.Type.EndsWith("role")).Select(claim =>
            {
                var roleEntity = new RoleEntity
                {
                    RoleId          = 1,
                    Name            = claim.Value,
                    ApplicationId   = WebConfigHelper.ApplicationIdCed,
                    ApplicationName = "ITE.CED"
                };
                return(roleEntity);
            }).ToList();

            CurrentCedUser = new CedUser(user, list);
            CurrentCedUser.IsPrimaryDirector   = EventDirectorServices.IsPrimaryDirector(CurrentCedUser.CurrentUser.Email, null, WebConfigHelper.ApplicationIdCed);
            CurrentCedUser.IsAssistantDirector = EventDirectorServices.IsAssistantDirector(CurrentCedUser.CurrentUser.Email, null, WebConfigHelper.ApplicationIdCed);

            return(true);
        }
 public static void CreateRoles(IDocumentStore documentStore, params string[] roles)
 {
     using (var session = documentStore.OpenSession())
     {
         foreach (var roleName in roles)
         {
             var role = new RoleEntity
                 {
                     ApplicationName = MembershipSettings.DefaultApplicationName,
                     RoleId = Guid.NewGuid(),
                     RoleName = roleName,
                     Description = roleName
                 };
             session.Store(role);
         }
         session.SaveChanges();
     }
 }
Exemple #55
0
        /// <summary>
        /// Creates a new Role in the system. If the user specified a role description that is already available, the unique constraint violation will be 
        /// caught and 0 is returned in that case.
        /// </summary>
        /// <param name="roleDescription">Description to store</param>
        /// <returns>new RoleID if succeeded. If the description was already available, 0 is returned</returns></returns>
        public static int CreateNewRole(string roleDescription)
        {
            if(CheckIfRoleDescriptionIsPresent(roleDescription))
            {
                // is already present
                return 0;
            }

            RoleEntity newRole = new RoleEntity();
            newRole.RoleDescription = roleDescription;

            int toReturn = 0;
            bool result = newRole.Save();
            if(result)
            {
                // save was succesful, read back the ID that was just created so we can return that to the caller.
                toReturn = newRole.RoleID;
            }
            return toReturn;
        }