Esempio n. 1
0
        public void SampleUpdate(ContextRequest contextRequest)
        {
            Guid       guidProject = Guid.Parse("C9930D58-DA0B-4379-A76C-78C7E68F199");
            KstProject project     = new KstProject();

            project.Name        = "Proyecto X";
            project.GuidProject = guidProject;
            project             = BR.KstProjectsBR.Instance.Create(project, contextRequest);

            // Actualización rápida sin ir a la base de datos
            var projectForUpdate = new KstProject();

            projectForUpdate.GuidProject = guidProject;
            projectForUpdate.Name        = "Proyecto Z";
            BR.KstProjectsBR.Instance.UpdateAgile(projectForUpdate, contextRequest, KstProject.PropertyNames.Name);

            // Actualización de todos los campos
            projectForUpdate      = BR.KstProjectsBR.Instance.GetBy(p => p.GuidProject == guidProject).FirstOrDefault();
            projectForUpdate.Name = "Proyecto Y";
            BR.KstProjectsBR.Instance.Update(projectForUpdate, contextRequest);

            // Actualización de todos los campos en un proceso masivo
            var allProjects = BR.KstProjectsBR.Instance.GetBy(p => true);

            foreach (var itemProject in allProjects)
            {
                itemProject.Name = "test";
            }
            BR.KstProjectsBR.Instance.UpdateBulk(allProjects, contextRequest);
        }
Esempio n. 2
0
        public void SampleCreate(ContextRequest contextRequest)
        {
            KstProject project = new KstProject();

            project.Name = "Proyecto X";

            project = BR.KstProjectsBR.Instance.Create(project, contextRequest);

            KstActivity activity = new KstActivity();

            activity.Name       = "Actividad 1";
            activity.KstProject = project;
            activity            = BR.KstActivitiesBR.Instance.Create(activity, contextRequest);

            activity             = new KstActivity();
            activity.Name        = "Actividad 2";
            activity.GuidProject = project.GuidProject;
            activity             = BR.KstActivitiesBR.Instance.Create(activity, contextRequest);

            List <KstActivity> activities = new List <KstActivity>();

            for (int i = 0; i < 10000; i++)
            {
                activities.Add(new KstActivity()
                {
                    GuidProject = project.GuidProject,
                    Name        = "test " + i.ToString()
                });
            }
            BR.KstActivitiesBR.Instance.Create(activities, contextRequest);
        }
Esempio n. 3
0
        public void SampleGet(ContextRequest contextRequest)
        {
            var activities = BR.KstActivitiesBR.Instance.GetBy(
                p => p.KstProject.Name.Contains("abc") && p.KstProject.KstProjectUsers.Count() == 0
                , contextRequest);

            activities = BR.KstActivitiesBR.Instance.GetBy(
                "it.KstProject.Name.Contains(\"abc\") AND it.KstProject.KstProjectUsers.Count() = 0"
                , contextRequest);

            DateTime date = new DateTime(2020, 12, 12);

            activities = BR.KstActivitiesBR.Instance.GetBy(p => p.KstProject.CreatedDate > date,
                                                           contextRequest);

            activities = BR.KstActivitiesBR.Instance.GetBy(
                $"it.KstProject.CreatedDate > DateTime({date.Year},{date.Month},{date.Day})",
                contextRequest);

            contextRequest.CustomQuery.Page          = 1;
            contextRequest.CustomQuery.PageSize      = 10;
            contextRequest.CustomQuery.SortDirection = SFS.Core.Data.SortDirection.Descending;
            contextRequest.CustomQuery.OrderBy       = KstActivity.PropertyNames.Name;
            activities = BR.KstActivitiesBR.Instance.GetBy(
                $"it.KstProject.CreatedDate > DateTime({date.Year},{date.Month},{date.Day})",
                contextRequest);
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            //取得处事类型
            string action = ContextRequest.GetQueryString("action");

            switch (action)
            {
            case "SingleFile":     //单文件
                SingleFile(context);
                break;

            case "MultipleFile":     //多文件
                MultipleFile(context);
                break;

            case "AttachFile":     //附件
                AttachFile(context);
                break;

            case "EditorFile":     //编辑器文件
                EditorFile(context);
                break;

            case "ManagerFile":     //管理文件
                ManagerFile(context);
                break;
            }
        }
Esempio n. 5
0
        private void MultipleFile(HttpContext context)
        {
            string         _upfilepath  = context.Request.QueryString["UpFilePath"]; //取得上传的对象名称
            HttpPostedFile _upfile      = context.Request.Files[_upfilepath];
            bool           _iswater     = false;                                     //默认不打水印
            bool           _isthumbnail = false;                                     //默认不生成缩略图

            if (ContextRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (ContextRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }

            if (_upfile == null)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater);

            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Esempio n. 6
0
    public void NotifyHandContextRequest(HandsPosition handsPosition)
    {
        ContextRequest request = new ContextRequest();

        request.m_context = m_storedContext;
        request.m_hands   = handsPosition;
        m_contextRequest.Invoke(request);
    }
Esempio n. 7
0
        public EFContext(ContextRequest contextRequest) : base(SFSdotNet.Framework.Configuration.ConfigurationSettings.GetConnectionString("SFSServiceDeskContext", "SFS.ServiceDesk"), (contextRequest != null ? (contextRequest.CurrentContext != null ? (contextRequest.CurrentContext.ApplicationPath != null ? (contextRequest.CurrentContext.ApplicationPath + "App_Data\\") : null) : null): null))

        {
            var objectContext = (this as IObjectContextAdapter).ObjectContext;

            // Sets the command timeout for all the commands
            objectContext.CommandTimeout = 500;
        }
Esempio n. 8
0
        public static List <IQueryFilter <Movie> > Movies(ContextRequest <GetMoviesRequest> contextRequest)
        {
            var request = contextRequest.Request;

            return(new List <IQueryFilter <Movie> >()
            {
                new MoviesFilter(request.Title),
                new IsActiveFilter <Movie>(true)
            });
        }
Esempio n. 9
0
        public void SampleDelete(ContextRequest contextRequest)
        {
            Guid guidProject = Guid.Parse("C9930D58-DA0B-4379-A76C-78C7E68F199");
            var  project     = BR.KstProjectsBR.Instance.GetBy(p => p.GuidProject == guidProject).FirstOrDefault();

            BR.KstProjectsBR.Instance.Delete(project, contextRequest);

            var activities = BR.KstActivitiesBR.Instance.GetBy(p => true);

            BR.KstActivitiesBR.Instance.DeleteBulk(activities, contextRequest);
        }
Esempio n. 10
0
        static partial void OnCreatingRolesAndUsers(object sender, SFSdotNet.Framework.Security.BusinessObjects.secModule module)
        {
            ContextRequest contextRequest   = new ContextRequest();
            secPermission  createPermission = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("c", "Create", module, contextRequest);
            secPermission  readPermission   = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("r", "Read", module, contextRequest);
            secPermission  updatePermission = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("u", "Update", module, contextRequest);
            secPermission  deletePermission = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("d", "Delete", module, contextRequest);

            //secPermission activate = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("activate", "Activar", module, );

            // AddPermissionIfNotExist(module, bo, activate);
            //secPermission payment = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("payment", "Pagar", module, contextRequest);
            //secPermission cancel = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("cancel", "Cancelar", module, contextRequest);

            //secPermission preventAll = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("prevent-all", "Evitar ver todo (Solo lo suyo)", module, contextRequest);
            //secPermission allWaitingForMe = SFSdotNet.Framework.Security.Permissions.AddPermissionIfNotExist("all-waiting-for-me", "Todas en espera de acción", module, contextRequest);
        }
Esempio n. 11
0
        public Guid New(ContextRequest Req)
        {
            var g = Guid.NewGuid();
            var connectionString = new SqlConnectionStringBuilder()
            {
                ApplicationName = "SqlNotebook",
                InitialCatalog  = Req.Database,
                Password        = Req.Password,
                UserID          = Req.Username
            };

            connectionString["server"] = Req.Server;
            var context = new SqlConnection(connectionString.ConnectionString);

            context.Open();
            Contexts[g] = context;
            return(g);
        }
        private void ReportFile(HttpContext context)
        {
            string         _refilepath = ContextRequest.GetQueryString("ReFilePath"); //取得返回的对象名称
            string         _upfilepath = ContextRequest.GetQueryString("UpFilePath"); //取得上传的对象名称
            string         _delfile    = ContextRequest.GetString(_refilepath);
            HttpPostedFile _upfile     = context.Request.Files[_upfilepath];

            if (_upfile == null)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.ExcelFileSaveAs(_upfile, true);

            //删除已存在的旧文件
            Utils.DeleteUpFile(_delfile);
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
Esempio n. 13
0
        public FileTransferResponsed WriteFile(FileTransferRequest transferData)
        {
            var id = transferData.RequestId;

            if (!_contextDic.ContainsKey(transferData.RequestId))//若同一个服务同时上传多个文件,则创建多个维护状态模式的Context,通过RequestID识别
            {
                _contextDic.Add(id, new FileWriteHandleContext(new StateFileFirstUpdate()));

                ContextRequest contextRequest = new ContextRequest(this._receiveProgressHandler)
                {
                    WorkingPath = FileNameTools.GetDownloadingFullPath(transferData.FileName)
                };
                _contextRequestDic.Add(id, contextRequest);
            }

            _contextRequestDic[id].FileRequest = transferData;
#if DEBUG
            //Console.WriteLine($"Data ID={id}");
#endif
            var responsed = _contextDic[id].Request(_contextRequestDic[id]);
            transferData.BlockData = null;//销毁缓存
            return(responsed);
        }
Esempio n. 14
0
        public void NotifyUser(secUser user, string roleName, ContextRequest contextRequest)
        {
            var template = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "user-added", contextRequest.CopySafe()).FirstOrDefault();

            //var layoutTemplate = ubiEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "email-template", contextRequest.CopySafe()).FirstOrDefault();

            if (template != null && template.Content != null)
            {
                string content = template.Content;

                string code = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                user.EmailCodeVerirication = code;
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(user, contextRequest, secUser.PropertyNames.EmailCodeVerirication);

                content = content.Replace("{APP-NAME}", contextRequest.Module.Name);
                content = content.Replace("{FROM-USER-NAME}", contextRequest.User.FirstName);
                content = content.Replace("{ROLE-NAME}", roleName);
                content = content.Replace("{URL-LINK}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/set-password/email/{user.Email}/code/{user.EmailCodeVerirication}");
                var module = SFS.Core.Cache.Caching.SystemObjects.GetModuleByKey("KSTime");

                SFS.Core.Net.Mail.SendMailAsync(user.Email, "Bienvenido a " + module.Name, content, contextRequest);
            }
        }
Esempio n. 15
0
        public void NotifyUser(secUser user, ContextRequest contextRequest)
        {
            var template = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "welcome", contextRequest.CopySafe()).FirstOrDefault();

            //var layoutTemplate = ubiEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "email-template", contextRequest.CopySafe()).FirstOrDefault();

            if (template != null && template.Content != null)
            {
                string content = template.Content;

                string code = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                user.EmailCodeVerirication = code;
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(user, contextRequest, secUser.PropertyNames.EmailCodeVerirication);
                //content = content.Replace("{{NOMBRE-COMPLETO}}", user.FirstName + " " + user.LastName);

                content = content.Replace("{{URL-LINK}}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/activate-account/email/{user.Email}/code/{user.EmailCodeVerirication}");
                content = content.Replace("{{URL}}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/activate-account/email/{user.Email}/code/{user.EmailCodeVerirication}");
                content = content.Replace("{{EMAIL}}", user.Email);


                SFS.Core.Net.Mail.SendMailAsync(user.Email, "Bienvenid@ a TodoSí", content, contextRequest);
            }
        }
Esempio n. 16
0
        private void SingleFile(HttpContext context)
        {
            string         _refilepath  = ContextRequest.GetQueryString("ReFilePath"); //取得返回的对象名称
            string         _upfilepath  = ContextRequest.GetQueryString("UpFilePath"); //取得上传的对象名称
            string         _delfile     = ContextRequest.GetString(_refilepath);
            HttpPostedFile _upfile      = context.Request.Files[_upfilepath];
            bool           _iswater     = false; //默认不打水印
            bool           _isthumbnail = false; //默认不生成缩略图
            bool           _isimage     = false;

            if (ContextRequest.GetQueryString("IsWater") == "1")
            {
                _iswater = true;
            }
            if (ContextRequest.GetQueryString("IsThumbnail") == "1")
            {
                _isthumbnail = true;
            }
            if (ContextRequest.GetQueryString("IsImage") == "1")
            {
                _isimage = true;
            }

            if (_upfile == null)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"请选择要上传文件!\"}");
                return;
            }
            UpLoad upFiles = new UpLoad();
            string msg     = upFiles.fileSaveAs(_upfile, _isthumbnail, _iswater, _isimage);

            //删除已存在的旧文件
            Utils.DeleteUpFile(_delfile);
            //返回成功信息
            context.Response.Write(msg);
            context.Response.End();
        }
        public void GetRouteParamAsStringGeneratesCorrectPolicy(string paramName, bool inline, string expected)
        {
            var policy = ContextRequest.GetRouteParamAsString(paramName, inline);

            policy.Should().Be(expected);
        }
Esempio n. 18
0
 public static Boolean SaveBlobInDataBase(ContextRequest contextRequest)
 {
     return((Boolean)SFS.Core.Configuration.ModuleAppSettings.GetValue("save-files-db", "KSTime", "Boolean", false, false));
 }
Esempio n. 19
0
 public EFContext(ContextRequest contextRequest) : base(SFS.Core.Configuration.ConfigurationSettings.GetConnectionString("KSTimeContext", "KS.Time", contextRequest))
 {
     this.Database.SetCommandTimeout(300);
 }
Esempio n. 20
0
        partial void OnUserLoging(UserLoginEventArgs e)
        {
            ContextRequest contextRequest = new ContextRequest();
            string         userOrEmail    = e.Username;

            if (string.IsNullOrEmpty(userOrEmail))
            {
                userOrEmail = e.Email;
            }
            if (!string.IsNullOrEmpty(userOrEmail))
            {
                userOrEmail = userOrEmail.ToLower();
            }



            contextRequest.UseMode = "withPassword";
            var  userProxy  = KstProxyUsersBR.Instance.GetBy(p => (p.Username != null && p.Username.ToLower() == userOrEmail) || (p.Email != null && p.Email.ToLower() == userOrEmail), contextRequest).FirstOrDefault();
            bool findInCore = false;

            if (userProxy != null)
            {
                if (userProxy.Password == null)
                {
                    findInCore = true;
                }
                else if (e.Password == Decrypt(userProxy.Password))
                {
                    if (string.IsNullOrEmpty(userProxy.Username))
                    {
                        userProxy.Username = userProxy.Email;
                    }
                    // si existe el usuario
                    e.Result = new secUser()
                    {
                        GuidUser = userProxy.GuidUser, FirstName = userProxy.FirstName, LastName = userProxy.LastName, DisplayName = userProxy.DisplayName, Email = userProxy.Email, UserName = userProxy.Username
                    };
                }
                else
                {
                    findInCore = true;
                }
            }
            else
            {
                findInCore = true;
            }
            if (findInCore)
            {
                if (!string.IsNullOrEmpty(e.Password) && e.User == null)
                {
                    string     encryptedPassword = SFS.Core.Globals.Security.EncryptString(e.Password);
                    secUsersBR brUser            = new secUsersBR(true);
                    e.Result = brUser.GetBy(p => (p.LoweredUserName == userOrEmail && p.Password == encryptedPassword) || (p.Email.ToLower() == userOrEmail && p.Password == encryptedPassword), contextRequest).FirstOrDefault();
                }
            }
            if (userProxy != null)
            {
                //var customer = BR.ubiCustomersBR.Instance.GetBy(p => p.GuidUser == userProxy.GuidUser, contextRequest).FirstOrDefault();
                //if (customer != null)
                //{
                //    e.SetParam("GuidCustomer", customer.GuidCustomer);
                //    e.SetParam("NumAddresses", BR.ubiAddressesBR.Instance.GetCount(p => p.GuidCustomer == customer.GuidCustomer, contextRequest));

                //}
            }

            // e.PreventGlobalHtml = true;
        }
Esempio n. 21
0
 public void NotifyUserAsync(secUser user, ContextRequest contextRequest)
 {
     Task.Run(() => {
         this.NotifyUser(user, contextRequest);
     });
 }
Esempio n. 22
0
 public static String ENGINE_API_KEY(ContextRequest contextRequest)
 {
     return((String)SFS.Core.Configuration.ModuleAppSettings.GetValue("ENGINE_API_KEY", "KSTime", "String", "", false));
 }
Esempio n. 23
0
 public static String EngineURL(ContextRequest contextRequest)
 {
     return((String)SFS.Core.Configuration.ModuleAppSettings.GetValue("EngineURL", "KSTime", "String", "", false));
 }
Esempio n. 24
0
        public void Start(object sender, IServiceCollection services)
        {
            try
            {
                //System.Threading.Thread.Sleep(30000);
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.AssemblyResolve += CustomResolver;

                string appNamespace      = "KS.Time";
                Guid   guidCompany       = Guid.Parse("F8A6AAE5-624F-4D42-AF85-C1E71F6D769A");
                string nameCompany       = "Kata Software";
                string userAdminEmail    = "*****@*****.**";
                string userAdminPassword = "******";
                Guid   guidAdminRole     = Guid.Parse("FD385E50-E344-4260-98D8-44E99BEF5CEC");

                SFS.Core.Security.BR.secModulesBR br = new SFS.Core.Security.BR.secModulesBR(true);
                var secModule = br.GetBy(p => p.ModuleNamespace == appNamespace, new ContextRequest()).FirstOrDefault();
                if (secModule == null)
                {
                    secModule = new SFS.Core.Security.BusinessObjects.secModule();
                    secModule.ModuleNamespace = appNamespace;
                    secModule.ModuleKey       = secModule.ModuleNamespace.Replace(".", "");
                    secModule.Name            = "KSTime";
                    secModule.IsAllowed       = true;


                    secModule = br.Create(secModule, new ContextRequest());
                }
                SFS.Core.Security.BR.secCompaniesBR brCompanies = new SFS.Core.Security.BR.secCompaniesBR(true);
                var company = brCompanies.GetBy(p => p.GuidCompany == guidCompany, new ContextRequest()).FirstOrDefault();
                if (company == null)
                {
                    company             = new SFS.Core.Security.BusinessObjects.secCompany();
                    company.Name        = nameCompany;
                    company.GuidCompany = guidCompany;

                    company = brCompanies.Create(company, new ContextRequest());
                }
                SFS.Core.Security.BR.secUserCompaniesBR brUserCompanies = new SFS.Core.Security.BR.secUserCompaniesBR(true);
                SFS.Core.Security.BR.secUsersBR         brUsers         = new SFS.Core.Security.BR.secUsersBR(true);


                SFS.Core.Security.BR.secRolesBR brRoles = new SFS.Core.Security.BR.secRolesBR(true);



                var contextRole = new ContextRequest();
                contextRole.PreventInterceptors = true;
                var userOperator = brRoles.GetBy(p => p.NameKey == "KSTime-operator", contextRole).FirstOrDefault();
                if (userOperator == null)
                {
                    userOperator          = new SFS.Core.Security.BusinessObjects.secRole();
                    userOperator.NameKey  = "KSTime-operator";
                    userOperator.RoleName = "Operador KSTime";
                    //userOperator.OwnerCompany = guidCompany;
                    userOperator.GuidRole           = Guid.NewGuid();
                    contextRole                     = new ContextRequest();
                    contextRole.PreventInterceptors = true;
                    userOperator                    = brRoles.Create(userOperator, contextRole);
                }
                contextRole = new ContextRequest();
                contextRole.PreventInterceptors = true;
                BR.KstProxyRolesBR brProxyRoles = new BR.KstProxyRolesBR(true);
                var userOperatorProxy           = brProxyRoles.GetBy(p => p.GuidRole == userOperator.GuidRole, contextRole).FirstOrDefault();
                if (userOperatorProxy == null)
                {
                    userOperatorProxy          = new BusinessObjects.KstProxyRole();
                    userOperatorProxy.GuidRole = userOperator.GuidRole;
                    userOperatorProxy.RoleName = userOperator.RoleName;
                    userOperatorProxy.NameKey  = userOperator.NameKey;
                    brProxyRoles.Create(userOperatorProxy, contextRole);
                }

                contextRole = new ContextRequest();
                contextRole.PreventInterceptors = true;
                var userEmployee = brRoles.GetBy(p => p.NameKey == "KSTime-employee", contextRole).FirstOrDefault();
                if (userEmployee == null)
                {
                    userEmployee          = new SFS.Core.Security.BusinessObjects.secRole();
                    userEmployee.NameKey  = "KSTime-employee";
                    userEmployee.RoleName = "Empleado";
                    //userEmployee.OwnerCompany = guidCompany;
                    userEmployee.GuidRole     = Guid.NewGuid();
                    userEmployee.IsFullAccess = true;
                    contextRole = new ContextRequest();
                    contextRole.PreventInterceptors = true;
                    userEmployee = brRoles.Create(userEmployee, contextRole);
                }
                var userEmployeeProxy = brProxyRoles.GetBy(p => p.GuidRole == userEmployee.GuidRole, contextRole).FirstOrDefault();
                if (userEmployeeProxy == null)
                {
                    userEmployeeProxy          = new BusinessObjects.KstProxyRole();
                    userEmployeeProxy.GuidRole = userEmployee.GuidRole;
                    userEmployeeProxy.RoleName = userEmployee.RoleName;
                    userEmployeeProxy.NameKey  = userEmployee.NameKey;
                    brProxyRoles.Create(userEmployeeProxy, contextRole);
                }



                var contextUser = new ContextRequest();
                contextUser.PreventInterceptors = true;
                //agregar usuario
                var userAdmin = brUsers.GetBy(p => p.Email == userAdminEmail, contextUser).FirstOrDefault();
                if (userAdmin == null)
                {
                    contextUser = new ContextRequest();
                    contextUser.PreventInterceptors = true;

                    userAdmin           = new SFS.Core.Security.BusinessObjects.secUser();
                    userAdmin.GuidUser  = Guid.NewGuid();
                    userAdmin.UserId    = Guid.NewGuid();
                    userAdmin.Email     = userAdminEmail;
                    userAdmin.Password  = SFS.Core.Globals.Security.EncryptString(userAdminPassword);
                    userAdmin.UserName  = userAdminEmail;
                    userAdmin.FirstName = "First name";
                    userAdmin.LastName  = "Last name";
                    userAdmin           = brUsers.Create(userAdmin, contextUser);
                }
                else
                {
                    userAdmin.Password = SFS.Core.Globals.Security.EncryptString(userAdminPassword);
                    brUsers.UpdateAgile(userAdmin, "Password");
                }
                // agregar superadmin a modulo app
                var contextUserCompany = new ContextRequest();
                contextUserCompany.PreventInterceptors = true;

                var adminUserComapny = brUserCompanies.GetBy(p => p.GuidUser == userAdmin.GuidUser && p.GuidModule == secModule.GuidModule && p.GuidCompany == guidCompany && p.GuidRole == guidAdminRole, contextUserCompany).FirstOrDefault();
                if (adminUserComapny == null)
                {
                    contextUserCompany = new ContextRequest();
                    contextUserCompany.PreventInterceptors = true;
                    adminUserComapny             = new SFS.Core.Security.BusinessObjects.secUserCompany();
                    adminUserComapny.GuidCompany = guidCompany;
                    adminUserComapny.GuidRole    = guidAdminRole;
                    adminUserComapny.GuidUser    = userAdmin.GuidUser;
                    adminUserComapny.GuidModule  = secModule.GuidModule;
                    adminUserComapny             = brUserCompanies.Create(adminUserComapny, contextUserCompany);
                }


                AddEntities.AddOrUpdateEntitiesAsync();
            }
            catch (Exception ex)
            {
                SFS.Core.My.EventLog.Exception(ex);
            }
        }
        public void GetQueryParamGeneratesCorrectPolicy(string paramName, string defaultValue, bool inline, string expected)
        {
            var policy = ContextRequest.GetQueryParam(paramName, defaultValue, inline);

            policy.Should().Be(expected);
        }
Esempio n. 26
0
        public void Map(T entity, ContextRequest <TRequest> request)
        {
            var baseRequest = request.Request;

            entity?.InjectFrom(baseRequest);
        }
Esempio n. 27
0
        private void Updating(KstProxyUser user, ContextRequest contextRequest)
        {
            Guid?guidUser = user.GuidUser;
            var  sysUser  = SFS.Core.Security.BR.secUsersBR.Instance.GetBy(p => p.GuidUser == guidUser, contextRequest).FirstOrDefault();

            if (sysUser != null)
            {
                List <string> props = new List <string>();
                sysUser.UserName = user.Username;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Username))
                {
                    props.Add("UserName");
                }
                sysUser.FirstName = user.FirstName;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.FirstName))
                {
                    props.Add("FirstName");
                }
                sysUser.LastName = user.LastName;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.LastName))
                {
                    props.Add("LastName");
                }

                if (!string.IsNullOrEmpty(user.Password))
                {
                    if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Password))
                    {
                        props.Add("Password");
                    }
                    sysUser.Password = SFS.Core.Globals.Security.EncryptString(user.Password);
                    user.Password    = null;
                }
                sysUser.Email = user.Email;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Email))
                {
                    props.Add("Email");
                }
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(sysUser, contextRequest.CopySafe(), props.ToArray());
            }



            if (user.GuidRole != null)
            {
                Guid?guidCompany     = contextRequest.Company.GuidCompany;
                var  module          = SFS.Core.Cache.Caching.SystemObjects.GetModuleByKey("KSTime");
                Guid?guidModule      = module.GuidModule;
                var  userCompanyRole = SFS.Core.Security.BR.secUserCompaniesBR.Instance.GetBy(p => p.GuidUser == guidUser && p.GuidCompany == guidCompany && p.GuidModule == guidModule).FirstOrDefault();

                if (userCompanyRole != null)
                {
                    userCompanyRole.GuidRole = user.GuidRole;
                    SFS.Core.Security.BR.secUserCompaniesBR.Instance.UpdateAgile(userCompanyRole, contextRequest.CopySafe(), "GuidRole");
                }
                else
                {
                    userCompanyRole             = new SFS.Core.Security.BusinessObjects.secUserCompany();
                    userCompanyRole.GuidUser    = guidUser;
                    userCompanyRole.GuidRole    = user.GuidRole;
                    userCompanyRole.GuidModule  = guidModule;
                    userCompanyRole.GuidCompany = guidCompany.Value;

                    userCompanyRole = SFS.Core.Security.BR.secUserCompaniesBR.Instance.Create(userCompanyRole, contextRequest);
                }
            }
        }
Esempio n. 28
0
 public void DisableUser(Guid guidUser, ContextRequest contextRequest)
 {
 }
        public void GetBodyAsStringGeneratesCorrectPolicy(bool inline, string expected)
        {
            var policy = ContextRequest.GetBodyAsString(inline);

            policy.Should().Be(expected);
        }
Esempio n. 30
0
 public void NotifyUserAsync(secUser user, string roleName, ContextRequest contextRequest)
 {
     Task.Run(() => {
         this.NotifyUser(user, roleName, contextRequest);
     });
 }