Example #1
0
        public IList <AppSystem> GetAllAppSystems()
        {
            var list = new List <AppSystem>();

            foreach (DataRow row in this["AppSystem"].Rows)
            {
                var item = new AppSystem
                {
                    Id             = (Guid)row["Id"],
                    Code           = (string)row["Code"],
                    Description    = row["Description"] == DBNull.Value ? null : row["Description"].ToString(),
                    Icon           = row["Icon"] == DBNull.Value ? null : row["Icon"].ToString(),
                    ImageUrl       = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString(),
                    IsEnabled      = (int)row["IsEnabled"],
                    Name           = row["Name"] == DBNull.Value ? null : row["Name"].ToString(),
                    PrincipalId    = (Guid)row["PrincipalId"],
                    Etag           = (byte[])row["Etag"],
                    SortCode       = (int)row["SortCode"],
                    SsoAuthAddress = row["SSOAuthAddress"] == DBNull.Value ? null : row["SSOAuthAddress"].ToString()
                };
                var entity = item as IEntityBase;
                entity.CreateBy       = row["CreateBy"] == DBNull.Value ? null : row["CreateBy"].ToString();
                entity.CreateOn       = row["CreateOn"] == DBNull.Value ? null : (DateTime?)row["CreateOn"];
                entity.CreateUserId   = row["CreateUserId"] == DBNull.Value ? null : (Guid?)row["CreateUserId"];
                entity.ModifiedBy     = row["ModifiedBy"] == DBNull.Value ? null : row["ModifiedBy"].ToString();
                entity.ModifiedOn     = row["ModifiedOn"] == DBNull.Value ? null : (DateTime?)row["ModifiedOn"];
                entity.ModifiedUserId = row["ModifiedUserId"] == DBNull.Value ? null : (Guid?)row["ModifiedUserId"];

                list.Add(item);
            }
            return(list);
        }
    public static async void Save(Notes notes)
    {
        ObservableCollection <Notes> temp = new ObservableCollection <Notes>();
        StorageFolder folder = ApplicationData.Current.LocalFolder;
        bool          exists = await AppSystem.FileExists("Data");

        if (exists == true)
        {
            StorageFile file = await folder.GetFileAsync("Data");

            using (Stream stream = await file.OpenStreamForReadAsync())
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(Notes));
                temp = (ObservableCollection <Notes>)json.ReadObject(stream);
            }
            await file.DeleteAsync(StorageDeleteOption.PermanentDelete);
        }

        temp.Add(notes);
        StorageFile file1 = await folder.CreateFileAsync("Data", CreationCollisionOption.ReplaceExisting);

        using (Stream stream = await file1.OpenStreamForWriteAsync())
        {
            DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(Notes));
            json.WriteObject(stream, temp);
        }
    }
Example #3
0
    public SerializeSystem(AppSystem appSystem)
    {
        Floors   = new List <SFloor>();
        Walls    = new List <SWall>();
        Ceilings = new List <SCeiling>();
        Roofs    = new List <SRoof>();

        foreach (var dFloor in appSystem.Floors)
        {
            Floors.Add(new SFloor(dFloor));
        }

        foreach (var dWall in appSystem.Walls)
        {
            Walls.Add(new SWall(dWall));
        }

        foreach (var dCeiling in appSystem.Ceilings)
        {
            Ceilings.Add(new SCeiling(dCeiling));
        }

        foreach (var dRoof in appSystem.Roofs)
        {
            Roofs.Add(new SRoof(dRoof));
        }
    }
        public IList <AppSystem> GetAllAppSystems()
        {
            var list = new List <AppSystem>();

            foreach (DataRow row in this["AppSystem"].Rows)
            {
                var item = new AppSystem((Guid)row["Id"])
                {
                    Code           = (string)row["Code"],
                    Description    = row["Description"] == DBNull.Value ? null : row["Description"].ToString(),
                    Icon           = row["Icon"] == DBNull.Value ? null : row["Icon"].ToString(),
                    ImageUrl       = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString(),
                    IsEnabled      = (int)row["IsEnabled"],
                    Name           = row["Name"] == DBNull.Value ? null : row["Name"].ToString(),
                    PrincipalId    = (Guid)row["PrincipalId"],
                    ETag           = (byte[])row["ETag"],
                    SortCode       = (int)row["SortCode"],
                    SsoAuthAddress = row["SSOAuthAddress"] == DBNull.Value ? null : row["SSOAuthAddress"].ToString()
                };
                var entity = (IEntityBase)item;
                PopulateEntity(entity, row);

                list.Add(item);
            }
            return(list);
        }
Example #5
0
        public List <AppSystem> ListSystem()
        {
            List <AppSystem> List = new List <AppSystem>();

            try
            {
                string    Path    = System.Web.Hosting.HostingEnvironment.MapPath("~/BOSystemList.xml");
                XDocument xdoc    = XDocument.Load(Path);
                var       xmlTree = from c in xdoc.Descendants("System")
                                    select c;
                if (xmlTree.Count() > 0)
                {
                    foreach (var v in xmlTree)
                    {
                        AppSystem sys = new AppSystem();
                        sys.Name         = v.Attribute("Name").Value;
                        sys.Description  = v.Attribute("Description").Value;
                        sys.ObjectFolder = v.Attribute("ObjectFolder").Value;
                        List.Add(sys);
                    }
                }
            }
            catch
            {
            }
            return(List);
        }
Example #6
0
        static void Main(string[] args)
        {
            WriteLine("---- Application Started -----");


            AppSystem appSystem1 = SecAppManager.GetAppByName("AdWorks");
            AppUser   newUser    = CreateUser("anyone8");
            //AppRole newRole = CreateRole(appSystem1, "role7");
            AppRole newRole = SecRoleManager.GetRoleByName("role7");

            AddUserToRole(newUser, newRole);

            //SecRoleManager.DeleteRoleUsers(newRole);


            //AppRole tmpRole = SecRoleManager.GetRoleByName("Role1");
            //SecRoleManager.DeleteRole(tmpRole);


            //AppSystem appSystem = CreateSystem("AdWorks", "Adventure Works CRUD application.");
            //AppUser newUser = CreateUser("anyone6");
            //AppRole newRole = CreateRole("role6");
            //AddUserToRole(newUser, newRole);

            WriteLine("---- Application Finished -----");
            ReadKey();
        }
        public ActionResult EditApplication(string appGuid)
        {
            AppSystem     appSystem = SecAppManager.GetAppByGuid(appGuid);
            ViewAppSystem model     = new ViewAppSystem(appSystem);

            return(View(model));
        }
Example #8
0
        public static AppSystem Update(AppSystem appSystem)
        {
            using (var dbContext = new SqlExpIdentity())
            {
                try
                {
                    AppSystem tmpSystem = dbContext.appSystems.Where(w => w.Id == appSystem.Id).FirstOrDefault();
                    if (tmpSystem == null)
                    {
                        tmpSystem = new AppBuilder().AppName(appSystem.Name).AppDesc(appSystem.Desc).Build();
                        tmpSystem = Create(tmpSystem);
                    }
                    else
                    {
                        tmpSystem.Name       = appSystem.Name != appSystem.Name ? tmpSystem.Name : appSystem.Name;
                        tmpSystem.Desc       = appSystem.Desc != appSystem.Desc ? tmpSystem.Desc : appSystem.Desc;
                        tmpSystem.UpdateDate = DateTime.Now;
                        int updCount = dbContext.SaveChanges();
                    }

                    return(tmpSystem);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #9
0
        /// <summary>
        /// 生成token,并存于redis,同时新增一条sessionlog记录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="sys"></param>
        /// <param name="ip"></param>
        /// <returns>是否成功</returns>
        private async Task <bool> SetTokenAsync(UserInfoAndRoleRight user, AppSystem sys, string ip)
        {
            var utcNow = DateTime.UtcNow;
            var token  = SSOHelper.GenerateToken(user.UserInfo.UserID.ToString(), user.UserInfo.AccountName, user.UserInfo.UserName, ip);

            int timespan = ConfigService.TokenOverTime;//分钟

            #region  缓存token
            var tokenKey = ConfigService.GetTokenRedisKey(user.UserInfo.UserID.ToString(), user.UserInfo.AccountName, sys.SystemCode);
            //检查当前用户在当前system下是否已有token。已有则更新log,并在redis中覆盖原有token
            var existTokenValue = redisCache.Get(tokenKey).ToString();

            var userInfoKey = ConfigService.GetUserInfoRedisKey(token, sys.SystemCode);
            //缓存、db记录。
            redisCache.Set(tokenKey, token, TimeSpan.FromMinutes(timespan));
            redisCache.Set(userInfoKey, user, TimeSpan.FromMinutes(timespan));
            //检查是否缓存成功
            var cacheResult = redisCache.Get(tokenKey).ToString() == token && redisCache.Get(userInfoKey).ToString() == user.ToJson();

            if (!existTokenValue.IsNullOrWhiteSpace())
            {
                var existUserInfoKey = ConfigService.GetUserInfoRedisKey(existTokenValue, sys.SystemCode);
                redisCache.Remove(existUserInfoKey);

                //查询session日志记录
                var sessionLog = await masterContext.UserSessionLogs.FirstOrDefaultAsync(a => a.UserToken == existTokenValue && a.UserID == user.UserInfo.UserID);

                if (sessionLog != null)
                {
                    sessionLog.RealExpirationTime = utcNow;
                }
            }
            #endregion 缓存token

            //DB记录token记录
            await masterContext.UserSessionLogs.AddAsync(new UserSessionLog
            {
                AccessHost         = ip,
                CreateTime         = utcNow,
                ModifyTime         = utcNow,
                SystemID           = sys.ID,
                SystemName         = sys.SystemName,
                UserID             = user.UserInfo.UserID,
                UserToken          = token,
                ValidTime          = timespan * 60,
                RealExpirationTime = utcNow.AddMinutes(timespan)
            });

            var dbSaveResult = await masterContext.SaveChangesAsync();

            if (cacheResult && dbSaveResult > 0)
            {
                user.Token = token;
                return(true);
            }
            return(false);
        }
Example #10
0
        public SystemViewModel(AppSystem appSystem)
        {
            if (appSystem == null)
            {
                throw new ArgumentNullException(nameof(appSystem));
            }

            this.AppSystem = appSystem;
        }
Example #11
0
    void Awake()
    {
        Debug.Log(AppSystem.Dump());
        if (SystemInfo.supports3DTextures)
        {
            Application.backgroundLoadingPriority = ThreadPriority.High;
        }

        LoadConfig();
        StartCoroutine(InitVersionAndBugly());
    }
Example #12
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtMSGCONTENT.Text.Trim() == "")
            {
                ComfirmWindow.ConfirmationBox("提示信息", "消息内容不能为空!", "确定");
                return;
            }
            AppSystem system = cobSYSTEMCODE.SelectedItem as AppSystem;
            AppModel  model  = cobMODELCODE.SelectedItem as AppModel;

            if (system.Name == "0" || model.Name == "0")
            {
                ComfirmWindow.ConfirmationBox("提示信息", "请正确选择 [系统]和[模块]!", "确定");
                return;
            }
            if (this.cbCondition.SelectedIndex < 1)
            {
                ComfirmWindow.ConfirmationBox("提示信息", "请选择审核条件!", "确定");
                return;
            }

            if (ActionType == "0")
            {
                T_WF_DEFAULTMESSAGE ent = new T_WF_DEFAULTMESSAGE();
                ent.MESSAGEID      = Guid.NewGuid().ToString();
                ent.MESSAGECONTENT = txtMSGCONTENT.Text.Trim();
                ent.APPLICATIONURL = txtURL.Text.Trim();
                ent.AUDITSTATE     = this.cbCondition.SelectedIndex;
                ent.SYSTEMCODE     = (cobSYSTEMCODE.SelectedItem as AppSystem).Name;
                ent.SYSTEMNAME     = (cobSYSTEMCODE.SelectedItem as AppSystem).Description;
                ent.MODELCODE      = (cobMODELCODE.SelectedItem as AppModel).Name;
                ent.MODELNAME      = (cobMODELCODE.SelectedItem as AppModel).Description;
                //entity.CREATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName;
                //entity.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                client.AddMessageAsync(ent);
            }
            else
            {
                T_WF_DEFAULTMESSAGE ent = new T_WF_DEFAULTMESSAGE();
                ent.MESSAGEID      = entity.MESSAGEID;
                ent.MESSAGECONTENT = txtMSGCONTENT.Text.Trim();
                ent.APPLICATIONURL = txtURL.Text.Trim();
                ent.AUDITSTATE     = this.cbCondition.SelectedIndex;
                ent.SYSTEMCODE     = (cobSYSTEMCODE.SelectedItem as AppSystem).Name;
                ent.SYSTEMNAME     = (cobSYSTEMCODE.SelectedItem as AppSystem).Description;
                ent.MODELCODE      = (cobMODELCODE.SelectedItem as AppModel).Name;
                ent.MODELNAME      = (cobMODELCODE.SelectedItem as AppModel).Description;
                ent.CREATEUSERNAME = entity.CREATEUSERNAME;
                ent.CREATEUSERID   = entity.CREATEUSERID;
                //ent.UPDATEUSERNAME = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName;
                //ent.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                client.EditMessageAsync(ent);
            }
        }
        public JsonResult DeleteApplication(string appGuid)
        {
            AppSystem appSystem = SecAppManager.GetAppByGuid(appGuid);

            SecAppManager.Delete(appSystem);

            var jsonMessage = new { appGuid };

            HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
            return(Json(jsonMessage, JsonRequestBehavior.AllowGet));
        }
Example #14
0
        private void cobMODELCODE_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            AppSystem system     = cobSYSTEMCODE.SelectedItem as AppSystem;
            AppModel  model      = cobMODELCODE.SelectedItem as AppModel;
            string    strMsgOpen = string.Empty;

            if (system != null && model != null)
            {
                flowXmlClient.ListSystemFuncAsync(system.ObjectFolder, model.Name, strMsgOpen);
            }
        }
Example #15
0
        private void frmNavigation_Load(object sender, EventArgs e)
        {
            AppSystem sys = new AppSystem();

            sys.LoadModules(this, navBarControl, pContainer, SimageCollection);
            if (navBarControl.Groups.Count > 0)
            {
                if (navBarControl.Groups[0].ItemLinks.Count > 0)
                {
                    navBarControl.Groups[0].ItemLinks[0].PerformClick();
                }
            }
        }
Example #16
0
    public static void SaveObject(AppSystem appSystem)
    {
        string nameFile = DomaManager.Instance.fileNameTextBox.text;

        nameFile += ".dma";

        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/" + nameFile;
        FileStream      stream    = new FileStream(path, FileMode.Create);

        SerializeSystem data = new SerializeSystem(appSystem);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Example #17
0
 /// <summary>创建应用系统
 /// </summary>
 public void Handle(ICommandContext context, CreateAppSystem command)
 {
     _lockService.ExecuteInLock(typeof(AppSystem).Name, () =>
     {
         _accountService.CheckExist(command.AccountId);
         var info = new AppSystemInfo(
             command.Code,
             command.Name,
             command.AccountId,
             command.ReMark);
         var appSystem = new AppSystem(
             command.AggregateRootId,
             info,
             command.SafeKey);
         context.Add(appSystem);
     });
 }
Example #18
0
 public static AppSystem CreateSystem(string sysName, string sysDesc)
 {
     try
     {
         AppSystem appSystem = new AppSystem();
         appSystem.Name = sysName;
         appSystem.Desc = sysDesc;
         appSystem      = SecAppManager.Create(appSystem);
         WriteLine($"{appSystem.Name} was created.");
         return(appSystem);
     }
     catch (Exception ex)
     {
         WriteLine(ex.Message);
         return(null);
     }
 }
    public static async Task <ObservableCollection <Notes> > GetCollection()
    {
        ObservableCollection <Notes> temp = new ObservableCollection <Notes>();
        StorageFolder folder = ApplicationData.Current.LocalFolder;

        if (await AppSystem.FileExists("Data"))
        {
            StorageFile file = await folder.GetFileAsync("Data.txt");

            using (Stream stream = await file.OpenStreamForReadAsync())
            {
                DataContractJsonSerializer json = new DataContractJsonSerializer(typeof(Notes));
                temp = (ObservableCollection <Notes>)json.ReadObject(stream);
            }
        }
        return(temp);
    }
Example #20
0
 public static AppSystem GetAppByGuid(string appId)
 {
     using (var dbContext = new SqlExpIdentity())
     {
         try
         {
             AppSystem appSystem = dbContext.appSystems.Where(w => w.Id == appId).FirstOrDefault();
             if (appSystem != null)
             {
                 appSystem.AppRoles.ToList();
             }
             return(appSystem);
         }
         catch (Exception ex)
         { throw ex; }
     }
 }
Example #21
0
    public void LoadData(string nameFile)
    {
        SerializeSystem saveSystem = SaveSystem.LoadObject(nameFile);

        referencesToObjectsForRemove = GetReferencesToInstances();
        currentStatusDoma.appSystem  = null;

        if (saveSystem == null)
        {
            var startSystem = new AppSystem();

            currentStatusDoma.appSystem = startSystem;

            SetActiveFloorById(0);
            currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { currentStatusDoma.activeFloor.Id });
            return;
        }
        else
        {
            currentStatusDoma.appSystem = new AppSystem(saveSystem);

            foreach (var wall in currentStatusDoma.appSystem.Walls)
            {
                wall.Instance2D = wall.DrawWall2D();
                wall.Instance3D = wall.DrawWall3D();
            }

            foreach (var ceiling in currentStatusDoma.appSystem.Ceilings)
            {
                ceiling.Instance2D = ceiling.DrawCeiling2D();
                ceiling.Instance3D = ceiling.DrawCeiling3D();
            }

            foreach (var roof in currentStatusDoma.appSystem.Roofs)
            {
                //roof.Instance2D = roof.DrawRoofType1();
                roof.Instance3D = roof.DrawRoof3D();
            }

            SetActiveFloorById(0);
            currentStatusDoma.ShowWalls2dOnFloors(new Guid[] { currentStatusDoma.appSystem.Floors[0].Id });
        }

        RemoveAllInstances(referencesToObjectsForRemove);
    }
Example #22
0
        public void StateObjectEquals()
        {
            var acDomain = TestHelper.GetAcDomain();
            var entity = new AppSystem
            {
                Id = Guid.NewGuid(),
                Name = "app1",
                Code = "app1",
                Description = string.Empty,
                Icon = string.Empty,
                IsEnabled = 1,
                PrincipalId = acDomain.SysUserSet.GetDevAccounts().First().Id,
                SortCode = 10,
                SsoAuthAddress = string.Empty,
                ImageUrl = string.Empty
            };
            var appSystem1 = AppSystemState.Create(acDomain, entity);
            var appSystem2 = appSystem1;

            Assert.AreEqual(appSystem1, appSystem1);
            Assert.IsTrue(appSystem1 == appSystem2);
            Assert.IsTrue(appSystem1.Equals(appSystem2));
            entity = new AppSystem
            {
                Id = appSystem1.Id,
                Name = "app1",
                Code = "app1",
                Description = string.Empty,
                Icon = string.Empty,
                IsEnabled = 1,
                PrincipalId = appSystem1.PrincipalId,
                SortCode = 10,
                SsoAuthAddress = string.Empty,
                ImageUrl = string.Empty
            };
            appSystem2 = AppSystemState.Create(acDomain, entity);
            Assert.AreEqual(appSystem1, appSystem1);
            Assert.IsTrue(appSystem1 == appSystem2);
            Assert.IsTrue(appSystem1.Equals(appSystem2));
            entity.Code = "app";
            appSystem2 = AppSystemState.Create(acDomain, entity);
            Assert.AreNotEqual(appSystem1, appSystem2);
            Assert.IsFalse(appSystem1 == appSystem2);
            Assert.IsFalse(appSystem1.Equals(appSystem2));
        }
Example #23
0
        public void StateObjectEquals()
        {
            var acDomain = TestHelper.GetAcDomain();
            var entity   = new AppSystem
            {
                Id             = Guid.NewGuid(),
                Name           = "app1",
                Code           = "app1",
                Description    = string.Empty,
                Icon           = string.Empty,
                IsEnabled      = 1,
                PrincipalId    = acDomain.SysUserSet.GetDevAccounts().First().Id,
                SortCode       = 10,
                SsoAuthAddress = string.Empty,
                ImageUrl       = string.Empty
            };
            var appSystem1 = AppSystemState.Create(acDomain, entity);
            var appSystem2 = appSystem1;

            Assert.AreEqual(appSystem1, appSystem1);
            Assert.IsTrue(appSystem1 == appSystem2);
            Assert.IsTrue(appSystem1.Equals(appSystem2));
            entity = new AppSystem
            {
                Id             = appSystem1.Id,
                Name           = "app1",
                Code           = "app1",
                Description    = string.Empty,
                Icon           = string.Empty,
                IsEnabled      = 1,
                PrincipalId    = appSystem1.PrincipalId,
                SortCode       = 10,
                SsoAuthAddress = string.Empty,
                ImageUrl       = string.Empty
            };
            appSystem2 = AppSystemState.Create(acDomain, entity);
            Assert.AreEqual(appSystem1, appSystem1);
            Assert.IsTrue(appSystem1 == appSystem2);
            Assert.IsTrue(appSystem1.Equals(appSystem2));
            entity.Code = "app";
            appSystem2  = AppSystemState.Create(acDomain, entity);
            Assert.AreNotEqual(appSystem1, appSystem2);
            Assert.IsFalse(appSystem1 == appSystem2);
            Assert.IsFalse(appSystem1.Equals(appSystem2));
        }
Example #24
0
 public static AppSystem Create(AppSystem appSystem)
 {
     using (var dbContext = new SqlExpIdentity())
     {
         try
         {
             appSystem.CreateDate = DateTime.Now;
             appSystem.UpdateDate = DateTime.Now;
             dbContext.appSystems.Add(appSystem);
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     return(appSystem);
 }
        public JsonResult GetAppCounts(string appGuid)
        {
            int rolesCount = 0;
            int usersCount = 0;

            AppSystem appSystem = SecAppManager.GetAppByGuid(appGuid);

            rolesCount = appSystem.AppRoles.Count();

            foreach (AppRole appRole in appSystem.AppRoles)
            {
                usersCount += SecUserRoleManager.GetUsersInRole(appRole).Count;
            }

            var jsonMessage = new { appGuid, applicationName = appSystem.Name, rolesCount = rolesCount.ToString(), usersCount = usersCount.ToString() };

            HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
            return(Json(jsonMessage, JsonRequestBehavior.AllowGet));
        }
Example #26
0
 public static AppSystem Delete(AppSystem appSystem)
 {
     using (var dbContext = new SqlExpIdentity())
     {
         try
         {
             AppSystem tmpSystem = dbContext.appSystems.Where(w => w.Id == appSystem.Id).FirstOrDefault();
             if (tmpSystem != null)
             {
                 dbContext.appSystems.Remove(tmpSystem);
                 dbContext.SaveChanges();
             }
             return(tmpSystem);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #27
0
        public static AppRole CreateRole(AppSystem appSystem, string roleName)
        {
            try
            {
                AppRole appRole = new AppRole(roleName);
                SecAppManager.AddRole(appSystem.Name, appRole);
                WriteLine($"{appRole.Name} was created.");
                return(appRole);
            }
            catch (DbEntityValidationException ex)
            {
                WriteLine(GetExceptionMessage(ex));
                return(null);
            }

            catch (Exception ex)
            {
                WriteLine(GetExceptionMessage(ex));
                return(null);
            }
        }
Example #28
0
 public static AppRole AddRole(string appName, AppRole appRole)
 {
     using (var dbContext = new SqlExpIdentity())
     {
         try
         {
             AppSystem appSystem = dbContext.appSystems.Where(w => w.Name == appName).FirstOrDefault();
             if (appSystem == null)
             {
                 throw new ArgumentNullException("AppName");
             }
             appSystem.AppRoles.Add(appRole);
             dbContext.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
     return(appRole);
 }
Example #29
0
 //所属系统选择事件
 private void cobSYSTEMCODE_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         AppSystem appSystem = cobSYSTEMCODE.SelectedItem as AppSystem;
         if (appSystem.Name != "0")
         {
             clientXml.AppModelCompleted += (o, v) =>
             {
                 cobModule.ItemsSource = v.Result;
             };
             clientXml.AppModelAsync(appSystem.ObjectFolder);
         }
         else
         {
             cobModule.ItemsSource = null;
         }
     }
     catch
     {
     }
 }
Example #30
0
            private void Handle(IAcSession acSession, IAppSystemCreateIo input, bool isCommand)
            {
                var dicByCode  = _set._dicByCode;
                var dicById    = _set._dicById;
                var acDomain   = _set._acDomain;
                var repository = acDomain.RetrieveRequiredService <IRepository <AppSystem> >();

                if (string.IsNullOrEmpty(input.Code))
                {
                    throw new ValidationException("编码不能为空");
                }
                if (!input.Id.HasValue)
                {
                    throw new AnycmdException("标识是必须的");
                }
                AppSystem entity;

                lock (MessageLocker)
                {
                    if (acDomain.AppSystemSet.ContainsAppSystem(input.Id.Value))
                    {
                        throw new AnycmdException("给定标识的记录已经存在" + input.Id);
                    }
                    if (acDomain.AppSystemSet.ContainsAppSystem(input.Code))
                    {
                        throw new ValidationException("重复的应用系统编码" + input.Code);
                    }
                    AccountState principal;
                    // TODO:考虑将AppSystem.PrincipalId重命名为AppSystem.DevPrincipalId,从而与业务负责人分开。
                    if (!acDomain.SysUserSet.TryGetDevAccount(input.PrincipalId, out principal))
                    {
                        throw new ValidationException("意外的应用系统负责人,业务系统负责人必须是开发人员");
                    }

                    entity = AppSystem.Create(input);

                    var state = AppSystemState.Create(acDomain, entity);
                    if (!dicByCode.ContainsKey(state.Code))
                    {
                        dicByCode.Add(state.Code, state);
                    }
                    if (!dicById.ContainsKey(state.Id))
                    {
                        dicById.Add(state.Id, state);
                    }
                    // 如果是命令则持久化
                    if (isCommand)
                    {
                        try
                        {
                            repository.Add(entity);
                            repository.Context.Commit();
                        }
                        catch
                        {
                            if (dicByCode.ContainsKey(entity.Code))
                            {
                                dicByCode.Remove(entity.Code);
                            }
                            if (dicById.ContainsKey(entity.Id))
                            {
                                dicById.Remove(entity.Id);
                            }
                            repository.Context.Rollback();
                            throw;
                        }
                    }
                }
                // 如果是命令则分发事件
                if (isCommand)
                {
                    acDomain.MessageDispatcher.DispatchMessage(new AppSystemAddedEvent(acSession, entity, input, isPrivate: true));
                }
            }
Example #31
0
 private void treeListChucNang_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
 {
     AppSystem.TreeListModulesFocused(pContainer, e);
 }
        public IList<AppSystem> GetAllAppSystems()
        {
            var list = new List<AppSystem>();
            foreach (DataRow row in this["AppSystem"].Rows)
            {
                var item = new AppSystem
                {
                    Id = (Guid)row["Id"],
                    Code = (string)row["Code"],
                    Description = row["Description"] == DBNull.Value ? null : row["Description"].ToString(),
                    Icon = row["Icon"] == DBNull.Value ? null : row["Icon"].ToString(),
                    ImageUrl = row["ImageUrl"] == DBNull.Value ? null : row["ImageUrl"].ToString(),
                    IsEnabled = (int)row["IsEnabled"],
                    Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(),
                    PrincipalId = (Guid)row["PrincipalId"],
                    Etag = (byte[])row["Etag"],
                    SortCode = (int)row["SortCode"],
                    SsoAuthAddress = row["SSOAuthAddress"] == DBNull.Value ? null : row["SSOAuthAddress"].ToString()
                };
                var entity = item as IEntityBase;
                entity.CreateBy = row["CreateBy"] == DBNull.Value ? null : row["CreateBy"].ToString();
                entity.CreateOn = row["CreateOn"] == DBNull.Value ? null : (DateTime?)row["CreateOn"];
                entity.CreateUserId = row["CreateUserId"] == DBNull.Value ? null : (Guid?)row["CreateUserId"];
                entity.ModifiedBy = row["ModifiedBy"] == DBNull.Value ? null : row["ModifiedBy"].ToString();
                entity.ModifiedOn = row["ModifiedOn"] == DBNull.Value ? null : (DateTime?)row["ModifiedOn"];
                entity.ModifiedUserId = row["ModifiedUserId"] == DBNull.Value ? null : (Guid?)row["ModifiedUserId"];

                list.Add(item);
            }
            return list;
        }