Exemple #1
0
        public void PageInit()
        {
            var entMan = new EntityManager();
            var relMan = new EntityRelationManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            var entityRelations = relMan.Read().Object.Where(x => x.TargetEntityId == ErpEntity.Id || x.OriginEntityId == ErpEntity.Id).ToList();

            Relation = entityRelations.SingleOrDefault(x => x.Id == RecordId);
            if (Relation == null)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/r/{Relation.Id}/";
            }

            HeaderActions.AddRange(new List <string>()
            {
                PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Save Relation", formId: "ManageRecord"),
                PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/r/{Relation.Id}/")
            });

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "relations"));

            TypeOptions = ModelExtensions.GetEnumAsSelectOptions <EntityRelationType>().FindAll(x => x.Value != "1").ToList();
        }
Exemple #2
0
 public WebHooks()
 {
     recMan = new RecordManager();
     secMan = new SecurityManager();
     entMan = new EntityManager();
     relMan = new EntityRelationManager();
 }
 private static void Patch20190529(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
 {
     #region << ***Create field***  Entity: email Field Name: attachments >>
     {
         InputTextField textboxField = new InputTextField();
         textboxField.Id                    = new Guid("3e24f113-0236-4474-b6ed-adf0f29c052f");
         textboxField.Name                  = "attachments";
         textboxField.Label                 = "Attachments";
         textboxField.PlaceholderText       = null;
         textboxField.Description           = null;
         textboxField.HelpText              = null;
         textboxField.Required              = true;
         textboxField.Unique                = false;
         textboxField.Searchable            = false;
         textboxField.Auditable             = false;
         textboxField.System                = true;
         textboxField.DefaultValue          = "[]";
         textboxField.MaxLength             = null;
         textboxField.EnableSecurity        = false;
         textboxField.Permissions           = new FieldPermissions();
         textboxField.Permissions.CanRead   = new List <Guid>();
         textboxField.Permissions.CanUpdate = new List <Guid>();
         //READ
         //UPDATE
         {
             var response = entMan.CreateField(new Guid("085e2442-820a-4df7-ab92-516ce23197c4"), textboxField, false);
             if (!response.Success)
             {
                 throw new Exception("System error 10060. Entity: email Field: attachments Message:" + response.Message);
             }
         }
     }
     #endregion
 }
 public ApiController()
 {
     recMan                = new RecordManager();
     secMan                = new SecurityManager();
     entityManager         = new EntityManager();
     entityRelationManager = new EntityRelationManager();
 }
Exemple #5
0
 public ApiDevelopersController(IErpService service) : base(service)
 {
     em     = new EntityManager(service.StorageService);
     rm     = new EntityRelationManager(service.StorageService);
     recMan = new RecordManager(service);
     fs     = service.StorageService.GetFS();
 }
Exemple #6
0
        private static void Patch20211013(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update page body node*** Page: track-time ID: 9946104a-a6ec-4a0b-b996-7bc630c16287 >>
            {
                var  id            = new Guid("9946104a-a6ec-4a0b-b996-7bc630c16287");
                Guid?parentId      = new Guid("6694f852-c49e-4dd2-a4dc-dd2f6faaf4b4");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("e9c8f7ef-4714-40e9-90cd-3814d89603b1");
                var  componentName = "WebVella.Erp.Web.Components.PcButton";
                var  containerId   = "footer";
                var  options       = @"{
  ""type"": ""0"",
  ""text"": ""Cancel"",
  ""color"": ""0"",
  ""size"": ""3"",
  ""class"": """",
  ""id"": """",
  ""icon_class"": """",
  ""is_block"": ""false"",
  ""is_outline"": ""false"",
  ""icon_right"": ""false"",
  ""is_active"": ""false"",
  ""is_disabled"": ""false"",
  ""is_visible"": """",
  ""onclick"": ""$('#wv-6694f852-c49e-4dd2-a4dc-dd2f6faaf4b4').modal(\""hide\"")"",
  ""href"": """",
  ""new_tab"": ""false"",
  ""form"": """"
}";
                var  weight        = 2;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
Exemple #7
0
        private static void Patch20190208(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update page body node*** Page: track-time ID: c57d94a6-9c90-4071-b54b-2c05b79aa522 >>
            {
                var  id            = new Guid("c57d94a6-9c90-4071-b54b-2c05b79aa522");
                Guid?parentId      = new Guid("e84c527a-4feb-4d60-ab91-4b1ecd89b39c");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("e9c8f7ef-4714-40e9-90cd-3814d89603b1");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldHtml";
                var  containerId   = "column2";
                var  options       = @"{
  ""label_mode"": ""0"",
  ""label_text"": """",
  ""mode"": ""4"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\n\\npublic class SelectOptionsConvertCodeVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\ttry{\\n\\t\\t\\t//if pageModel is not provided, returns empty List<SelectOption>()\\n\\t\\t\\tif (pageModel == null)\\n\\t\\t\\t\\treturn null;\\n\\t\\n\\t\\t\\t//try read data source by name and get result as specified type object\\n\\t\\t\\tvar dataSource = pageModel.TryGetDataSourceProperty<EntityRecord>(\\\""RowRecord\\\"");\\n\\t\\n\\t\\t\\t//if data source not found or different type, return empty List<SelectOption>()\\n\\t\\t\\tif (dataSource == null)\\n\\t\\t\\t\\treturn null;\\n\\t        var loggedSeconds = ((int)dataSource[\\\""logged_minutes\\\""])*60;\\n\\t        var logStartedOn = (DateTime?)dataSource[\\\""timelog_started_on\\\""];\\n\\t        var logStartString = \\\""\\\"";\\n\\t        if(logStartedOn != null){\\n\\t            //loggedSeconds = loggedSeconds + (int)((DateTime.UtcNow - logStartedOn.Value).TotalSeconds);\\n\\t            logStartString = logStartedOn.Value.ToString(\\\""o\\\"");\\n\\t        }\\n\\n\\t        var hours = (int)(loggedSeconds/3600);\\n\\t        var loggedSecondsLeft = loggedSeconds - hours*3600;\\n\\t        var hoursString = \\\""00\\\"";\\n\\t        if(hours < 10)\\n\\t            hoursString = \\\""0\\\"" + hours;\\n            else\\n                hoursString = hours.ToString();\\n\\t            \\n\\t        var minutes = (int)(loggedSecondsLeft/60);\\n\\t        var minutesString = \\\""00\\\"";\\n\\t        if(minutes < 10)\\n\\t            minutesString = \\\""0\\\"" + minutes;\\n            else\\n                minutesString = minutes.ToString();\\t        \\n                \\n            var seconds =  loggedSecondsLeft -  minutes*60;\\n\\t        var secondsString = \\\""00\\\"";\\n\\t        if(seconds < 10)\\n\\t            secondsString = \\\""0\\\"" + seconds;\\n            else\\n                secondsString = seconds.ToString();\\t                    \\n            \\n            var result = $\\\""<span class='go-gray wv-timer' style='font-size:16px;'>{hoursString + \\\"" : \\\"" + minutesString + \\\"" : \\\"" + secondsString}</span>\\\\n\\\"";\\n            result += $\\\""<input type='hidden' name='timelog_total_seconds' value='{loggedSeconds}'/>\\\\n\\\"";\\n            result += $\\\""<input type='hidden' name='timelog_started_on' value='{logStartString}'/>\\\"";\\n            return result;\\n\\t\\t}\\n\\t\\tcatch(Exception ex){\\n\\t\\t\\treturn \\\""Error: \\\"" + ex.Message;\\n\\t\\t}\\n\\t}\\n}\\n\"",\""default\"":\""<span class=\\\""go-gray\\\"" style='font-size:16px;'>00 : 00 : 00</span>\""}"",
  ""name"": ""field"",
  ""class"": """",
  ""upload_mode"": ""1"",
  ""toolbar_mode"": ""1"",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
 public AdminController(IErpService erpService)
 {
     recMan          = new RecordManager();
     secMan          = new SecurityManager();
     entMan          = new EntityManager();
     relMan          = new EntityRelationManager();
     this.erpService = erpService;
 }
Exemple #9
0
 public BaseService(DbContext currentContext = null)
 {
     RecMan = new RecordManager(currentContext);
     EntMan = new EntityManager(currentContext);
     SecMan = new SecurityManager(currentContext);
     RelMan = new EntityRelationManager(currentContext);
     Fs     = new DbFileRepository(currentContext);
 }
        public void PostCreateApiHookLogic(string entityName, EntityRecord record)
        {
            Guid?commentCreator = null;

            if (record.Properties.ContainsKey("created_by") && record["created_by"] != null && record["created_by"] is Guid)
            {
                commentCreator = (Guid)record["created_by"];
            }
            if (commentCreator == null)
            {
                return;
            }

            if (!record.Properties.ContainsKey("l_scope") || record["l_scope"] == null || !((string)record["l_scope"]).Contains("projects"))
            {
                return;
            }

            if (record.Properties.ContainsKey("l_related_records") && record["l_related_records"] != null && (string)record["l_related_records"] != "")
            {
                var relatedRecordGuid = JsonConvert.DeserializeObject <List <Guid> >((string)record["l_related_records"]);
                var taskEqlCommand    = "SELECT *,$user_nn_task_watchers.id from task WHERE ";
                var filterStringList  = new List <string>();
                var taskEqlParams     = new List <EqlParameter>();
                var index             = 1;
                foreach (var taskGuid in relatedRecordGuid)
                {
                    var paramName = "taskId" + index;
                    filterStringList.Add($" id = @{paramName} ");
                    taskEqlParams.Add(new EqlParameter(paramName, taskGuid));
                    index++;
                }
                taskEqlCommand += String.Join(" OR ", filterStringList);
                var relatedTaskRecords = new EqlCommand(taskEqlCommand, taskEqlParams).Execute();
                var watchRelation      = new EntityRelationManager().Read("user_nn_task_watchers").Object;
                if (watchRelation == null)
                {
                    throw new Exception("Watch relation not found");
                }

                foreach (var task in relatedTaskRecords)
                {
                    if (task.Properties.ContainsKey("$user_nn_task_watchers") && task["$user_nn_task_watchers"] != null && task["$user_nn_task_watchers"] is List <EntityRecord> )
                    {
                        var watcherIdList = ((List <EntityRecord>)task["$user_nn_task_watchers"]).Select(x => (Guid)x["id"]).ToList();
                        if (!watcherIdList.Contains(commentCreator.Value))
                        {
                            //Create relation
                            var createRelResponse = new RecordManager().CreateRelationManyToManyRecord(watchRelation.Id, commentCreator.Value, (Guid)task["id"]);
                            if (!createRelResponse.Success)
                            {
                                throw new Exception(createRelResponse.Message);
                            }
                        }
                    }
                }
            }
        }
        private static void Patch20190207(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Delete page body node*** Page name: create ID: ecef4b2c-6988-44c1-acea-0e28385ec528 >>
            {
                new WebVella.Erp.Web.Services.PageService().DeletePageBodyNode(new Guid("ecef4b2c-6988-44c1-acea-0e28385ec528"), WebVella.Erp.Database.DbContext.Current.Transaction, cascade: false);
            }
            #endregion

            #region << ***Delete page body node*** Page name: create ID: 884a8db1-aff0-4f86-ab7d-8fb17698fc33 >>
            {
                new WebVella.Erp.Web.Services.PageService().DeletePageBodyNode(new Guid("884a8db1-aff0-4f86-ab7d-8fb17698fc33"), WebVella.Erp.Database.DbContext.Current.Transaction, cascade: false);
            }
            #endregion

            #region << ***Create page body node*** Page name: create  id: d07d36ac-2536-4cf8-9cfc-b07eaa7a1320 >>
            {
                var  id            = new Guid("d07d36ac-2536-4cf8-9cfc-b07eaa7a1320");
                Guid?parentId      = new Guid("a1110167-15bd-46b7-ae3c-cc8ba87be98f");
                Guid?nodeId        = null;
                var  pageId        = new Guid("68100014-1fd7-456c-9b26-27aa9f858287");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldDate";
                var  containerId   = "column2";
                var  options       = @"{
  ""label_text"": """",
  ""label_mode"": ""0"",
  ""value"": ""{\""type\"":\""0\"",\""string\"":\""Record.start_time\"",\""default\"":\""\""}"",
  ""name"": ""start_time"",
  ""mode"": ""0"",
  ""connected_entity_id"": """"
}";
                var  weight        = 10;

                new WebVella.Erp.Web.Services.PageService().CreatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion

            #region << ***Create page body node*** Page name: create  id: db2d036e-df04-4514-9533-2ac31ade4602 >>
            {
                var  id            = new Guid("db2d036e-df04-4514-9533-2ac31ade4602");
                Guid?parentId      = new Guid("a1110167-15bd-46b7-ae3c-cc8ba87be98f");
                Guid?nodeId        = null;
                var  pageId        = new Guid("68100014-1fd7-456c-9b26-27aa9f858287");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldDate";
                var  containerId   = "column2";
                var  options       = @"{
  ""label_text"": """",
  ""label_mode"": ""0"",
  ""value"": ""{\""type\"":\""0\"",\""string\"":\""Record.end_time\"",\""default\"":\""\""}"",
  ""name"": ""end_time"",
  ""mode"": ""0"",
  ""connected_entity_id"": """"
}";
                var  weight        = 11;

                new WebVella.Erp.Web.Services.PageService().CreatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
        public IActionResult OnPost()
        {
            PageInit();
            if (Relation == null)
            {
                return(NotFound());
            }

            try
            {
                var            relMan      = new EntityRelationManager();
                EntityRelation updRelation = new EntityRelation
                {
                    Id               = Relation.Id,
                    Name             = Relation.Name,
                    Label            = Relation.Name,    //Label, Boz: removed for convinience
                    Description      = "",               //Description, Boz: removed for convinience
                    System           = IsSystem,
                    OriginEntityId   = Relation.OriginEntityId,
                    OriginEntityName = Relation.OriginEntityName,
                    OriginFieldId    = Relation.OriginFieldId,
                    OriginFieldName  = Relation.OriginFieldName,
                    TargetEntityId   = Relation.TargetEntityId,
                    TargetEntityName = Relation.TargetEntityName,
                    TargetFieldId    = Relation.TargetFieldId,
                    TargetFieldName  = Relation.TargetFieldName,
                    RelationType     = Relation.RelationType
                };


                var response = relMan.Update(updRelation);
                if (!response.Success)
                {
                    var exception = new ValidationException(response.Message);
                    exception.Errors = response.Errors.MapTo <ValidationError>();
                    throw exception;
                }
                return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/r/{Relation.Id}/"));
            }
            catch (ValidationException ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors  = ex.Errors;
            }
            catch (Exception ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true));
            }

            ErpRequestContext.PageContext = PageContext;

            BeforeRender();
            return(Page());
        }
Exemple #13
0
        private static void Patch20190420(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update page body node*** Page: all_emails ID: 60a62365-f290-421e-af82-30bbd6474ea9 >>
            {
                var  id            = new Guid("60a62365-f290-421e-af82-30bbd6474ea9");
                Guid?parentId      = new Guid("5dfef806-4448-4bce-8a5d-91e8587cbe33");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("3374a8ee-653b-43f6-a4e8-c6db9a4f76d2");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldText";
                var  containerId   = "column3";
                var  options       = @"{
  ""is_visible"": """",
  ""label_mode"": ""3"",
  ""label_text"": """",
  ""mode"": ""4"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\nusing Newtonsoft.Json;\\nusing WebVella.Erp.Plugins.Mail.Api;\\n\\npublic class GetDatasourceValueCodeVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\ttry{\\n\\t\\t\\tconst string DATASOURCE_NAME = \\\""RowRecord\\\"";\\n\\t\\t\\tif (pageModel == null)\\n\\t\\t\\t\\treturn null;\\n\\t\\n\\t\\t\\tvar rowRecord = pageModel.TryGetDataSourceProperty<EntityRecord>(DATASOURCE_NAME);\\n\\t\\t\\tif ( rowRecord  == null)\\n\\t\\t\\t\\treturn null;\\n\\t\\n\\t\\t\\tvar mailAddress = JsonConvert.DeserializeObject<EmailAddress>( (string) rowRecord[\\\""sender\\\""] );\\n\\t\\t\\treturn mailAddress.Address;\\n\\t\\t}\\n\\t\\tcatch(Exception ex)\\n\\t\\t{\\n\\t\\t\\treturn \\\""Error: \\\"" + ex.Message;\\n\\t\\t}\\n\\t}\\n}\\n\"",\""default\"":\""\""}"",
  ""name"": ""sender_email"",
  ""class"": """",
  ""maxlength"": 0,
  ""placeholder"": """",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion

            #region << ***Update page body node*** Page: all_emails ID: 7be29cb8-8449-451a-b6de-3bba406f1b48 >>
            {
                var  id            = new Guid("7be29cb8-8449-451a-b6de-3bba406f1b48");
                Guid?parentId      = new Guid("5dfef806-4448-4bce-8a5d-91e8587cbe33");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("3374a8ee-653b-43f6-a4e8-c6db9a4f76d2");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldText";
                var  containerId   = "column2";
                var  options       = @"{
  ""is_visible"": """",
  ""label_mode"": ""3"",
  ""label_text"": """",
  ""mode"": ""4"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Linq;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\nusing Newtonsoft.Json;\\nusing WebVella.Erp.Plugins.Mail.Api;\\n\\npublic class GetDatasourceValueCodeVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\ttry{\\n\\t\\t\\tconst string DATASOURCE_NAME = \\\""RowRecord\\\"";\\n\\t\\t\\tif (pageModel == null)\\n\\t\\t\\t\\treturn null;\\n\\t\\n\\t\\t\\tvar rowRecord = pageModel.TryGetDataSourceProperty<EntityRecord>(DATASOURCE_NAME);\\n\\t\\t\\tif ( rowRecord  == null)\\n\\t\\t\\t\\treturn null;\\n\\t\\n\\t\\t\\tvar recipients = JsonConvert.DeserializeObject<List<EmailAddress>>( (string) rowRecord[\\\""recipients\\\""] );\\n\\t\\t\\treturn string.Join( \\\"";\\\"", recipients.Select( x=> x.Address ).ToList() );\\n\\t\\t}\\n\\t\\tcatch(Exception ex)\\n\\t\\t{\\n\\t\\t\\treturn \\\""Error: \\\"" + ex.Message;\\n\\t\\t}\\n\\t}\\n}\\n\"",\""default\"":\""\""}"",
  ""name"": ""recipient_email"",
  ""class"": """",
  ""maxlength"": 0,
  ""placeholder"": """",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
Exemple #14
0
        public void PostUpdateApiHookLogic(string entityName, EntityRecord record)
        {
            //Update key and search fields
            Guid   projectId      = Guid.Empty;
            Guid?  projectOwnerId = null;
            string taskSubject    = "";


            var patchRecord    = new TaskService().SetCalculationFields((Guid)record["id"], subject: out taskSubject, projectId: out projectId, projectOwnerId: out projectOwnerId);
            var updateResponse = new RecordManager(executeHooks: false).UpdateRecord("task", patchRecord);

            if (!updateResponse.Success)
            {
                throw new Exception(updateResponse.Message);
            }

            //Check if owner is in watchers list. If not create relation
            if (record.Properties.ContainsKey("owner_id") && record["owner_id"] != null)
            {
                var watchers   = new List <Guid>();
                var eqlCommand = "SELECT id, $user_nn_task_watchers.id FROM task WHERE id = @taskId";
                var eqlParams  = new List <EqlParameter>()
                {
                    new EqlParameter("taskId", (Guid)record["id"])
                };
                var eqlResult = new EqlCommand(eqlCommand, eqlParams).Execute();
                foreach (var relRecord in eqlResult)
                {
                    if (relRecord.Properties.ContainsKey("$user_nn_task_watchers") && relRecord["$user_nn_task_watchers"] is List <EntityRecord> )
                    {
                        var currentWatchers = (List <EntityRecord>)relRecord["$user_nn_task_watchers"];
                        foreach (var watchRecord in currentWatchers)
                        {
                            watchers.Add((Guid)watchRecord["id"]);
                        }
                    }
                }
                if (!watchers.Contains((Guid)record["owner_id"]))
                {
                    var watchRelation = new EntityRelationManager().Read("user_nn_task_watchers").Object;
                    if (watchRelation == null)
                    {
                        throw new Exception("Watch relation not found");
                    }

                    var createRelResponse = new RecordManager().CreateRelationManyToManyRecord(watchRelation.Id, (Guid)record["owner_id"], (Guid)record["id"]);
                    if (!createRelResponse.Success)
                    {
                        throw new Exception(createRelResponse.Message);
                    }
                }
            }
        }
Exemple #15
0
        public void PageInit()
        {
            Init();

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l";
            }

            var entMan       = new EntityManager();
            var relMan       = new EntityRelationManager();
            var allRelations = relMan.Read().Object;

            foreach (var entity in entMan.ReadEntities().Object)
            {
                foreach (var field in entity.Fields)
                {
                    if (field is GuidField)
                    {
                        var sfo = new SelectOption($"{entity.Id}${field.Id}", $"{entity.Name}.{field.Name}");
                        if (field.Unique && field.Required)
                        {
                            OriginOptions.Add(sfo);
                        }

                        if (!allRelations.Any(x => x.TargetFieldId == field.Id && x.RelationType != EntityRelationType.ManyToMany))
                        {
                            TargetOptions.Add(sfo);
                        }
                    }
                }
            }

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            HeaderActions.AddRange(new List <string>()
            {
                PageUtils.GetActionTemplate(PageUtilsActionType.SubmitForm, label: "Create Relation", formId: "CreateRecord"),
                PageUtils.GetActionTemplate(PageUtilsActionType.Cancel, returnUrl: $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l")
            });

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "relations"));

            TypeOptions = ModelExtensions.GetEnumAsSelectOptions <EntityRelationType>().FindAll(x => x.Value != "1").ToList();
        }
Exemple #16
0
        private static void Patch20200611(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update data source*** Name: AllEmails >>
            {
                var id             = new Guid("82f0b63e-3647-4106-839c-4d5adca4f3b1");
                var name           = @"AllEmails";
                var description    = @"records of all emails";
                var eqlText        = @"SELECT * FROM email
WHERE x_search CONTAINS @searchQuery
ORDER BY @sortBy @sortOrder
PAGE @page
PAGESIZE @pageSize";
                var sqlText        = @"SELECT row_to_json( X ) FROM (
SELECT 
	 rec_email.""id"" AS ""id"",
	 rec_email.""subject"" AS ""subject"",
	 rec_email.""content_text"" AS ""content_text"",
	 rec_email.""content_html"" AS ""content_html"",
	 rec_email.""sent_on"" AS ""sent_on"",
	 rec_email.""created_on"" AS ""created_on"",
	 rec_email.""server_error"" AS ""server_error"",
	 rec_email.""retries_count"" AS ""retries_count"",
	 rec_email.""service_id"" AS ""service_id"",
	 rec_email.""priority"" AS ""priority"",
	 rec_email.""reply_to_email"" AS ""reply_to_email"",
	 rec_email.""scheduled_on"" AS ""scheduled_on"",
	 rec_email.""status"" AS ""status"",
	 rec_email.""sender"" AS ""sender"",
	 rec_email.""recipients"" AS ""recipients"",
	 rec_email.""x_search"" AS ""x_search"",
	 rec_email.""attachments"" AS ""attachments"",
	 COUNT(*) OVER() AS ___total_count___
FROM rec_email
WHERE  ( rec_email.""x_search""  ILIKE  CONCAT ( '%' , @searchQuery , '%' ) )
ORDER BY rec_email.""created_on"" DESC
LIMIT 15
OFFSET 0
) X
";
                var parametersJson = @"[{""name"":""sortBy"",""type"":""text"",""value"":""created_on"",""ignore_parse_errors"":false},{""name"":""sortOrder"",""type"":""text"",""value"":""desc"",""ignore_parse_errors"":false},{""name"":""page"",""type"":""int"",""value"":""1"",""ignore_parse_errors"":false},{""name"":""pageSize"",""type"":""int"",""value"":""15"",""ignore_parse_errors"":false},{""name"":""searchQuery"",""type"":""text"",""value"":""string.empty"",""ignore_parse_errors"":false}]";
                var fieldsJson     = @"[{""name"":""id"",""type"":16,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""subject"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""content_text"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""content_html"",""type"":8,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""sent_on"",""type"":5,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""created_on"",""type"":5,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""server_error"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""retries_count"",""type"":12,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""service_id"",""type"":16,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""priority"",""type"":17,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""reply_to_email"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""scheduled_on"",""type"":5,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""status"",""type"":17,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""sender"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""recipients"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""x_search"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]},{""name"":""attachments"",""type"":18,""entity_name"":"""",""relation_name"":null,""children"":[]}]";
                var weight         = 10;
                var entityName     = @"email";

                new WebVella.Erp.Database.DbDataSourceRepository().Update(id, name, description, weight, eqlText, sqlText, parametersJson, fieldsJson, entityName);
            }
            #endregion
        }
Exemple #17
0
        public void PageInit()
        {
            Init();

            #region << Init Entity >>
            var entMan = new EntityManager();
            var relMan = new EntityRelationManager();

            ErpEntity = entMan.ReadEntity(ParentRecordId ?? Guid.Empty).Object;
            if (ErpEntity == null)
            {
                return;
            }

            var entityRelations = relMan.Read().Object.Where(x => x.TargetEntityId == ErpEntity.Id || x.OriginEntityId == ErpEntity.Id).ToList();
            Relation = entityRelations.SingleOrDefault(x => x.Id == RecordId);
            if (Relation == null)
            {
                return;
            }

            #endregion

            if (String.IsNullOrWhiteSpace(ReturnUrl))
            {
                ReturnUrl = $"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l";
            }

            #region << Actions >>

            if (Relation.System)
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.Disabled, label: "Delete locked", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt", titleText: "System objects cannot be deleted"));
            }
            else
            {
                HeaderActions.Add(PageUtils.GetActionTemplate(PageUtilsActionType.ConfirmAndSubmitForm, label: "Delete Relation", formId: "DeleteRecord", btnClass: "btn btn-white btn-sm", iconClass: "fa fa-trash-alt go-red"));
            };

            HeaderActions.Add($"<a href='/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/m/{RecordId}' class='btn btn-white btn-sm'><i class='fa fa-cog go-orange'></i> Manage Relation</a>");

            HeaderToolbar.AddRange(AdminPageUtils.GetEntityAdminSubNav(ErpEntity, "relations"));

            #endregion

            TypeOptions = ModelExtensions.GetEnumAsSelectOptions <EntityRelationType>().FindAll(x => x.Value != "1").ToList();
        }
Exemple #18
0
        public IActionResult OnPost()
        {
            var initResult = Init();

            if (initResult != null)
            {
                return(initResult);
            }

            PageInit();
            if (Relation == null)
            {
                return(NotFound());
            }

            var entMan = new EntityManager();

            try
            {
                var relMan   = new EntityRelationManager();
                var response = relMan.Delete(Relation.Id);
                if (!response.Success)
                {
                    var exception = new ValidationException(response.Message);
                    exception.Errors = response.Errors.MapTo <ValidationError>();
                    throw exception;
                }
                return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l"));
            }
            catch (ValidationException ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors  = ex.Errors;
            }
            catch (Exception ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true));
            }

            ErpRequestContext.PageContext = PageContext;

            BeforeRender();
            return(Page());
        }
        private static void Patch20200610(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update app*** App name: sdk >>
            {
                var id          = new Guid("56a8548a-19d0-497f-8e5b-242abfdc4082");
                var name        = "sdk";
                var label       = "Software Development Kit";
                var description = "SDK & Development Tools";
                var iconClass   = "fa fa-cogs";
                var author      = "<ul class='nav'><li class='nav-item'><a class='nav-link' href='/sdk/objects/page/l'>pages</a></li><li class='nav-item'><a class='nav-link'href='/sdk/objects/entity/l'>entities</a></li><li class='nav-item'><a class='nav-link'href='/sdk/objects/application/l/list'>apps</a></li><li class='nav-item'><a class='nav-link'href='/sdk/access/user/l/list'>users</a></li><li class='nav-item'><a class='nav-link'href='/sdk/server/log/l/list'>logs</a></li><li class='nav-item'><a class='nav-link'href='/sdk/server/job/l/list'>jobs</a></li></ul>";
                var color       = "#dc3545";
                var weight      = 1000;
                var access      = new List <Guid>();
                access.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda"));

                new WebVella.Erp.Web.Services.AppService().UpdateApplication(id, name, label, description, iconClass, author, color, weight, access, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
 private void InitEntitySelectOptions()
 {
     {
         var entities = new EntityManager().ReadEntities().Object;
         entities = entities.OrderBy(x => x.Name).ToList();
         foreach (var entity in entities)
         {
             EntitySelectOptions.Add(new SelectOption(entity.Id.ToString(), entity.Name));
         }
     }
     {
         var relations = new EntityRelationManager().Read().Object;
         relations = relations.FindAll(x => x.RelationType == EntityRelationType.ManyToMany).OrderBy(x => x.Name).ToList();
         foreach (var relation in relations)
         {
             NNRelationsSelectOptions.Add(new SelectOption(relation.Id.ToString(), relation.Name));
         }
     }
 }
Exemple #21
0
        private static void Patch20200610(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update app*** App name: mail >>
            {
                var id          = new Guid("9d3b5497-e136-43b7-ad87-857e615a54c9");
                var name        = "mail";
                var label       = "Mail";
                var description = "Provides services for sending emails.";
                var iconClass   = "far fa-envelope";
                var author      = "WebVella";
                var color       = "#8bc34a";
                var weight      = 100;
                var access      = new List <Guid>();
                access.Add(new Guid("bdc56420-caf0-4030-8a0e-d264938e0cda"));

                new WebVella.Erp.Web.Services.AppService().UpdateApplication(id, name, label, description, iconClass, author, color, weight, access, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
Exemple #22
0
        private static void Patch20210429(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            List <Entity> entities = entMan.ReadEntities().Object;
            List <Field>  fields   = new List <Field>();

            using (NpgsqlConnection con = new NpgsqlConnection(ErpSettings.ConnectionString))
            {
                try
                {
                    con.Open();
                    NpgsqlCommand command = new NpgsqlCommand("SELECT table_name, column_name, column_default FROM information_schema.columns WHERE table_schema = 'public' and column_default = 'now()'", con);
                    DataTable     dt      = new DataTable();
                    new NpgsqlDataAdapter(command).Fill(dt);
                    var records = dt.AsRecordList();
                    foreach (var rec in records)
                    {
                        string entityName = ((string)rec["table_name"]).Substring(4);
                        string fieldName  = (string)rec["column_name"];
                        var    entity     = entities.SingleOrDefault(x => x.Name == entityName);
                        if (entity != null)
                        {
                            fields.Add(entity.Fields.Single(x => x.Name == fieldName));
                        }
                    }
                }
                finally
                {
                    con.Close();
                }
            }


            foreach (Field field in fields)
            {
                bool overrideNulls = field.Required && field.GetFieldDefaultValue() != null;
                DbRepository.SetColumnDefaultValue("rec_" + field.EntityName, field, overrideNulls);
            }
        }
 private static void Patch20201222(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
 {
     #region << ***Update field***  Entity: case Field Name: created_on >>
     {
         var currentEntity = entMan.ReadEntity(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c")).Object;
         InputDateTimeField datetimeField = new InputDateTimeField();
         datetimeField.Id              = currentEntity.Fields.SingleOrDefault(x => x.Name == "created_on").Id;
         datetimeField.Name            = "created_on";
         datetimeField.Label           = "Created on";
         datetimeField.PlaceholderText = null;
         datetimeField.Description     = null;
         datetimeField.HelpText        = null;
         datetimeField.Required        = true;
         datetimeField.Unique          = false;
         datetimeField.Searchable      = false;
         datetimeField.Auditable       = false;
         datetimeField.System          = true;
         datetimeField.DefaultValue    = null;
         datetimeField.Format          = "yyyy-MMM-dd HH:mm";
         datetimeField.UseCurrentTimeAsDefaultValue = true;
         datetimeField.EnableSecurity        = false;
         datetimeField.Permissions           = new FieldPermissions();
         datetimeField.Permissions.CanRead   = new List <Guid>();
         datetimeField.Permissions.CanUpdate = new List <Guid>();
         //READ
         //UPDATE
         {
             var response = entMan.UpdateField(new Guid("0ebb3981-7443-45c8-ab38-db0709daf58c"), datetimeField);
             if (!response.Success)
             {
                 throw new Exception("System error 10060. Entity: case Field: created_on Message:" + response.Message);
             }
         }
     }
     #endregion
 }
Exemple #24
0
        public void PostPreUpdateApiHookLogic(string entityName, EntityRecord record, List <ErrorModel> errors)
        {
            var eqlResult = new EqlCommand("SELECT id,number, $project_nn_task.id, $project_nn_task.abbr, $user_nn_task_watchers.id FROM task WHERE id = @taskId", new EqlParameter("taskId", (Guid)record["id"])).Execute();

            if (eqlResult.Count > 0)
            {
                var  oldRecord         = eqlResult[0];
                Guid?oldProjectId      = null;
                Guid?newProjectId      = null;
                var  taskWatcherIdList = new List <Guid>();
                var  projectAbbr       = "";
                if (oldRecord.Properties.ContainsKey("$project_nn_task") && oldRecord["$project_nn_task"] is List <EntityRecord> )
                {
                    var projectRecords = (List <EntityRecord>)oldRecord["$project_nn_task"];
                    if (projectRecords.Any())
                    {
                        if (projectRecords[0].Properties.ContainsKey("id"))
                        {
                            oldProjectId = (Guid)projectRecords[0]["id"];
                        }
                        if (projectRecords[0].Properties.ContainsKey("abbr"))
                        {
                            projectAbbr = (string)projectRecords[0]["abbr"];
                        }
                    }
                }

                if (record.Properties.ContainsKey("$project_nn_task.id") && record["$project_nn_task.id"] != null)
                {
                    if (record["$project_nn_task.id"] is Guid)
                    {
                        newProjectId = (Guid)record["$project_nn_task.id"];
                    }
                    if (record["$project_nn_task.id"] is string)
                    {
                        newProjectId = new Guid(record["$project_nn_task.id"].ToString());
                    }
                }

                if (oldRecord.Properties.ContainsKey("$user_nn_task_watchers") && oldRecord["$user_nn_task_watchers"] is List <EntityRecord> )
                {
                    var watcherRecords = (List <EntityRecord>)oldRecord["$user_nn_task_watchers"];
                    foreach (var watcherRecord in watcherRecords)
                    {
                        taskWatcherIdList.Add((Guid)watcherRecord["id"]);
                    }
                }


                if (oldProjectId != null && newProjectId != null && oldProjectId != newProjectId)
                {
                    var recMan         = new RecordManager();
                    var relations      = new EntityRelationManager().Read().Object;
                    var projectTaskRel = relations.First(x => x.Name == "project_nn_task");
                    if (projectTaskRel == null)
                    {
                        throw new Exception("project_nn_task relation not found");
                    }

                    //Remove all NN relation
                    var removeRelResponse = recMan.RemoveRelationManyToManyRecord(projectTaskRel.Id, oldProjectId, (Guid)record["id"]);
                    if (!removeRelResponse.Success)
                    {
                        throw new Exception(removeRelResponse.Message);
                    }

                    //Create new NN relation
                    var addRelResponse = recMan.RemoveRelationManyToManyRecord(projectTaskRel.Id, newProjectId, (Guid)record["id"]);
                    if (!addRelResponse.Success)
                    {
                        throw new Exception(addRelResponse.Message);
                    }

                    //change key
                    record["key"] = projectAbbr + "-" + ((decimal)oldRecord["number"]).ToString("N0");

                    var projectEqlResult = new EqlCommand("SELECT id,owner_id FROM project WHERE id = @projectId",
                                                          new EqlParameter("projectId", newProjectId)).Execute();
                    Guid?projectOwnerId = null;
                    if (projectEqlResult != null && ((List <EntityRecord>)projectEqlResult).Any())
                    {
                        var newProjectRecord = ((List <EntityRecord>)projectEqlResult).First();
                        if (newProjectRecord.Properties.ContainsKey("owner_id") && newProjectRecord["owner_id"] != null)
                        {
                            if (newProjectRecord["owner_id"] is Guid)
                            {
                                projectOwnerId = (Guid)newProjectRecord["owner_id"];
                            }
                            if (newProjectRecord["owner_id"] is string)
                            {
                                projectOwnerId = new Guid(newProjectRecord["owner_id"].ToString());
                            }
                        }
                    }
                    //check if the new project owner is in the watcher list and add it if not
                    if (projectOwnerId != null && !taskWatcherIdList.Contains(projectOwnerId.Value))
                    {
                        var watcherTaskRel = relations.First(x => x.Name == "user_nn_task_watchers");
                        if (watcherTaskRel == null)
                        {
                            throw new Exception("user_nn_task_watchers relation not found");
                        }

                        //Create new NN relation
                        var addWatcherRelResponse = recMan.RemoveRelationManyToManyRecord(watcherTaskRel.Id, projectOwnerId, (Guid)record["id"]);
                        if (!addWatcherRelResponse.Success)
                        {
                            throw new Exception(addWatcherRelResponse.Message);
                        }
                    }
                }
            }
        }
Exemple #25
0
        public void PostCreateApiHookLogic(string entityName, EntityRecord record)
        {
            //Update key and search fields
            Guid   projectId      = Guid.Empty;
            Guid?  projectOwnerId = null;
            string taskSubject    = "";
            var    patchRecord    = new TaskService().SetCalculationFields((Guid)record["id"], subject: out taskSubject, projectId: out projectId, projectOwnerId: out projectOwnerId);
            var    updateResponse = new RecordManager(executeHooks: false).UpdateRecord("task", patchRecord);

            if (!updateResponse.Success)
            {
                throw new Exception(updateResponse.Message);
            }

            //Set the initial watchers list - project lead, creator, owner
            var watchers = new List <Guid>();

            {
                var fieldName = "owner_id";
                if (record.Properties.ContainsKey(fieldName) && record[fieldName] != null)
                {
                    var userId = (Guid)record[fieldName];
                    if (!watchers.Contains(userId))
                    {
                        watchers.Add(userId);
                    }
                }
            }
            {
                var fieldName = "created_by";
                if (record.Properties.ContainsKey(fieldName) && record[fieldName] != null)
                {
                    var userId = (Guid)record[fieldName];
                    if (!watchers.Contains(userId))
                    {
                        watchers.Add(userId);
                    }
                }
            }
            if (projectOwnerId != null)
            {
                if (!watchers.Contains(projectOwnerId.Value))
                {
                    watchers.Add(projectOwnerId.Value);
                }
            }

            //Create relations
            var watchRelation = new EntityRelationManager().Read("user_nn_task_watchers").Object;

            if (watchRelation == null)
            {
                throw new Exception("Watch relation not found");
            }

            foreach (var userId in watchers)
            {
                var createRelResponse = new RecordManager().CreateRelationManyToManyRecord(watchRelation.Id, userId, (Guid)record["id"]);
                if (!createRelResponse.Success)
                {
                    throw new Exception(createRelResponse.Message);
                }
            }


            //Add activity log
            var subject        = $"created <a href=\"/projects/tasks/tasks/r/{patchRecord["id"]}/details\">[{patchRecord["key"]}] {taskSubject}</a>";
            var relatedRecords = new List <string>()
            {
                patchRecord["id"].ToString(), projectId.ToString()
            };
            var scope = new List <string>()
            {
                "projects"
            };

            //Add watchers as scope
            foreach (var userId in watchers)
            {
                relatedRecords.Add(userId.ToString());
            }
            var taskSnippet = new Web.Services.RenderService().GetSnippetFromHtml((string)record["body"]);

            new FeedItemService().Create(id: Guid.NewGuid(), createdBy: SecurityContext.CurrentUser.Id, subject: subject,
                                         body: taskSnippet, relatedRecords: relatedRecords, scope: scope, type: "task");
        }
Exemple #26
0
        public dynamic InitPcFieldBaseModel(PageComponentContext context, PcFieldBaseOptions options, out string label, string targetModel = "PcFieldBaseModel")
        {
            label = "";
            var model = new PcFieldBaseModel();

            if (context.Items.ContainsKey(typeof(ValidationException)))
            {
                model.ValidationErrors = ((ValidationException)context.Items[typeof(ValidationException)]).Errors;
            }

            model.LabelRenderModeOptions = ModelExtensions.GetEnumAsSelectOptions <LabelRenderMode>();

            model.FieldRenderModeOptions = ModelExtensions.GetEnumAsSelectOptions <FieldRenderMode>();

            if (context.Mode == ComponentMode.Options)
            {
                model.EntitySelectOptions = new MetaService().GetEntitiesAsSelectOptions();
            }

            var recordId = context.DataModel.GetProperty("RecordId");

            if (recordId != null && recordId is Guid)
            {
                model.RecordId = (Guid)recordId;
            }

            var entity = context.DataModel.GetProperty("Entity");

            if (entity != null && entity is Entity)
            {
                model.EntityName = ((Entity)entity).Name;
                if (!String.IsNullOrWhiteSpace(model.EntityName) && model.RecordId != null)
                {
                    model.ApiUrl = $"/api/v3/en_US/record/{model.EntityName}/{model.RecordId}/";
                }
            }

            Entity mappedEntity = null;

            if (options.ConnectedEntityId != null)
            {
                mappedEntity = new EntityManager().ReadEntity(options.ConnectedEntityId.Value).Object;
            }
            else if (options.ConnectedEntityId == null && entity is Entity)
            {
                mappedEntity = (Entity)entity;
            }

            if (mappedEntity != null)
            {
                var fieldName = options.Name;

                if (fieldName.StartsWith("$"))
                {
                    //Field with relation is set. Mapped entity should be changed
                    var fieldNameArray = fieldName.Replace("$", "").Split(".", StringSplitOptions.RemoveEmptyEntries);
                    if (fieldNameArray.Length == 2)
                    {
                        var relationName = fieldNameArray[0];
                        fieldName = fieldNameArray[1];
                        var relation = new EntityRelationManager().Read(relationName).Object;
                        if (relation != null)
                        {
                            if (relation.OriginEntityId == mappedEntity.Id)
                            {
                                mappedEntity = new EntityManager().ReadEntity(relation.TargetEntityId).Object;
                            }
                            else if (relation.TargetEntityId == mappedEntity.Id)
                            {
                                mappedEntity = new EntityManager().ReadEntity(relation.OriginEntityId).Object;
                            }
                        }
                    }
                }

                var entityField = mappedEntity.Fields.FirstOrDefault(x => x.Name == fieldName);
                if (entityField != null)
                {
                    //Connection success set local options if needed
                    if (String.IsNullOrWhiteSpace(model.Placeholder))
                    {
                        model.Placeholder = entityField.PlaceholderText;
                    }

                    if (String.IsNullOrWhiteSpace(model.Description))
                    {
                        model.Description = entityField.Description;
                    }

                    if (String.IsNullOrWhiteSpace(model.LabelHelpText))
                    {
                        model.LabelHelpText = entityField.HelpText;
                    }

                    if (String.IsNullOrWhiteSpace(label))
                    {
                        label = entityField.Label;
                    }

                    model.Required = entityField.Required;

                    if (entityField.EnableSecurity)
                    {
                        var currentUser = context.DataModel.GetProperty("CurrentUser");
                        if (currentUser != null && currentUser is ErpUser)
                        {
                            var canRead   = false;
                            var canUpdate = false;
                            var user      = (ErpUser)currentUser;
                            foreach (var role in user.Roles)
                            {
                                if (entityField.Permissions.CanRead.Any(x => x == role.Id))
                                {
                                    canRead = true;
                                }
                                if (entityField.Permissions.CanUpdate.Any(x => x == role.Id))
                                {
                                    canUpdate = true;
                                }
                            }
                            if (canUpdate)
                            {
                                model.Access = FieldAccess.Full;
                            }
                            else if (canRead)
                            {
                                model.Access = FieldAccess.ReadOnly;
                            }
                            else
                            {
                                model.Access = FieldAccess.Forbidden;
                            }
                        }
                    }

                    //Specific model properties
                    var fieldOptions = new List <SelectOption>();
                    switch (entityField.GetFieldType())
                    {
                    case FieldType.SelectField:
                        var selectField = ((SelectField)entityField);
                        model.DefaultValue = selectField.DefaultValue;
                        fieldOptions       = selectField.Options;
                        break;

                    case FieldType.MultiSelectField:
                        var multiselectField = ((MultiSelectField)entityField);
                        model.DefaultValue = multiselectField.DefaultValue;
                        fieldOptions       = multiselectField.Options;
                        break;

                    default:
                        break;
                    }
                    switch (targetModel)
                    {
                    case "PcFieldSelectModel":
                        return(PcFieldSelectModel.CopyFromBaseModel(model, fieldOptions));

                    case "PcFieldRadioListModel":
                        return(PcFieldRadioListModel.CopyFromBaseModel(model, fieldOptions));

                    case "PcFieldCheckboxListModel":
                        return(PcFieldCheckboxListModel.CopyFromBaseModel(model, fieldOptions));

                    case "PcFieldMultiSelectModel":
                        return(PcFieldMultiSelectModel.CopyFromBaseModel(model, fieldOptions));

                    case "PcFieldCheckboxGridModel":
                        return(PcFieldCheckboxGridModel.CopyFromBaseModel(model, new List <SelectOption>(), new List <SelectOption>()));

                    default:
                        return(model);
                    }
                }
            }

            switch (targetModel)
            {
            case "PcFieldSelectModel":
                return(PcFieldSelectModel.CopyFromBaseModel(model, new List <SelectOption>()));

            case "PcFieldRadioListModel":
                return(PcFieldRadioListModel.CopyFromBaseModel(model, new List <SelectOption>()));

            case "PcFieldCheckboxListModel":
                return(PcFieldCheckboxListModel.CopyFromBaseModel(model, new List <SelectOption>()));

            case "PcFieldMultiSelectModel":
                return(PcFieldMultiSelectModel.CopyFromBaseModel(model, new List <SelectOption>()));

            case "PcFieldCheckboxGridModel":
                return(PcFieldCheckboxGridModel.CopyFromBaseModel(model, new List <SelectOption>(), new List <SelectOption>()));

            default:
                return(model);
            }
        }
Exemple #27
0
        public PcFieldBaseOptions InitPcFieldBaseOptions(PageComponentContext context)
        {
            var options = new PcFieldBaseOptions();

            //Check if it is defined in form group
            if (context.Items.ContainsKey(typeof(LabelRenderMode)))
            {
                options.LabelMode = (LabelRenderMode)context.Items[typeof(LabelRenderMode)];
            }
            else
            {
                options.LabelMode = LabelRenderMode.Stacked;
            }


            //Check if it is defined in form group
            if (context.Items.ContainsKey(typeof(FieldRenderMode)))
            {
                options.Mode = (FieldRenderMode)context.Items[typeof(FieldRenderMode)];
            }
            else
            {
                options.Mode = FieldRenderMode.Form;
            }

            var baseOptions = JsonConvert.DeserializeObject <PcFieldBaseOptions>(context.Options.ToString());

            Entity mappedEntity = null;
            var    entity       = context.DataModel.GetProperty("Entity");

            if (options.ConnectedEntityId != null)
            {
                mappedEntity = new EntityManager().ReadEntity(options.ConnectedEntityId.Value).Object;
            }
            else if (options.ConnectedEntityId == null && entity is Entity)
            {
                mappedEntity = (Entity)entity;
            }

            if (mappedEntity != null)
            {
                var fieldName = baseOptions.Name;

                EntityRelation relation = null;
                if (fieldName.StartsWith("$"))
                {
                    //Field with relation is set. Mapped entity should be changed
                    var fieldNameArray = fieldName.Replace("$", "").Split(".", StringSplitOptions.RemoveEmptyEntries);
                    if (fieldNameArray.Length == 2)
                    {
                        var relationName = fieldNameArray[0];
                        fieldName = fieldNameArray[1];
                        relation  = new EntityRelationManager().Read(relationName).Object;
                        if (relation != null)
                        {
                            if (relation.OriginEntityId == mappedEntity.Id)
                            {
                                mappedEntity = new EntityManager().ReadEntity(relation.TargetEntityId).Object;
                            }
                            else if (relation.TargetEntityId == mappedEntity.Id)
                            {
                                mappedEntity = new EntityManager().ReadEntity(relation.OriginEntityId).Object;
                            }
                        }
                    }
                }

                var entityField = mappedEntity.Fields.FirstOrDefault(x => x.Name == fieldName);

                //for many to many relation field is always ID and that is not correct
                //so hide this field meta as field is not found
                if (relation != null && relation.RelationType == EntityRelationType.ManyToMany)
                {
                    entityField = null;
                }

                if (entityField != null)
                {
                    switch (entityField.GetFieldType())
                    {
                    case FieldType.AutoNumberField:
                    {
                        var fieldMeta = (AutoNumberField)entityField;
                        options.Template = fieldMeta.DisplayFormat;
                    }
                    break;

                    case FieldType.CurrencyField:
                    {
                        var fieldMeta = (CurrencyField)entityField;
                        options.Min          = fieldMeta.MinValue;
                        options.Min          = fieldMeta.MinValue;
                        options.CurrencyCode = fieldMeta.Currency.Code;
                    }
                    break;

                    case FieldType.EmailField:
                    {
                        var fieldMeta = (EmailField)entityField;
                        options.MaxLength = fieldMeta.MaxLength;
                    }
                    break;

                    case FieldType.NumberField:
                    {
                        var fieldMeta = (NumberField)entityField;
                        options.Min = fieldMeta.MinValue;
                        options.Min = fieldMeta.MinValue;
                        if (fieldMeta.DecimalPlaces != null)
                        {
                            if (int.TryParse(fieldMeta.DecimalPlaces.ToString(), out int outInt))
                            {
                                options.DecimalDigits = outInt;
                            }
                        }
                    }
                    break;

                    case FieldType.PasswordField:
                    {
                        var fieldMeta = (PasswordField)entityField;
                        options.Min = (decimal?)fieldMeta.MinLength;
                        options.Max = (decimal?)fieldMeta.MaxLength;
                    }
                    break;

                    case FieldType.PercentField:
                    {
                        var fieldMeta = (PercentField)entityField;
                        options.Min = fieldMeta.MinValue;
                        options.Min = fieldMeta.MinValue;
                        if (fieldMeta.DecimalPlaces != null)
                        {
                            if (int.TryParse(fieldMeta.DecimalPlaces.ToString(), out int outInt))
                            {
                                options.DecimalDigits = outInt;
                            }
                        }
                    }
                    break;

                    case FieldType.PhoneField:
                    {
                        var fieldMeta = (PhoneField)entityField;
                        options.MaxLength = fieldMeta.MaxLength;
                    }
                    break;

                    case FieldType.TextField:
                    {
                        var fieldMeta = (TextField)entityField;
                        options.MaxLength = fieldMeta.MaxLength;
                    }
                    break;

                    default:
                        break;
                    }
                }
            }

            return(options);
        }
Exemple #28
0
        private static void Patch20190422(EntityManager entMan, EntityRelationManager relMan, RecordManager recMan)
        {
            #region << ***Update page body node*** Page: details ID: 314c56d3-4e85-4e35-8af7-5f909750139e >>
            {
                var  id            = new Guid("314c56d3-4e85-4e35-8af7-5f909750139e");
                Guid?parentId      = new Guid("fb0885f1-9377-437b-8851-3c97c25a9b5b");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("24d7c716-fa27-4ccd-99d1-c7a8813a13f2");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldText";
                var  containerId   = "column1";
                var  options       = @"{
  ""is_visible"": """",
  ""label_mode"": ""0"",
  ""label_text"": ""Service"",
  ""mode"": ""2"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\nusing WebVella.Erp.Plugins.Mail.Api;\\n\\npublic class ViewEmailUrlCodeVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\tif (pageModel == null)\\n\\t\\t\\treturn null;\\n\\n\\t\\tvar serviceId = pageModel.TryGetDataSourceProperty<Guid>(\\\""Record.service_id\\\"");\\n\\n\\t\\tif (serviceId == null)\\n\\t\\t\\treturn \\\""SMTP service not found\\\"";\\n\\t\\t\\t\\n\\t\\tEmailServiceManager serviceManager = new EmailServiceManager();\\n\\t\\tvar smtpService = serviceManager.GetSmtpService(serviceId);\\n\\t\\tif( smtpService == null )\\n\\t\\t    return \\\""SMTP service not found\\\"";\\n\\t\\t    \\n\\t\\treturn smtpService.Name;\\n\\n\\t}\\n}\\n\"",\""default\"":\""\""}"",
  ""name"": ""service_id"",
  ""class"": """",
  ""maxlength"": 0,
  ""placeholder"": """",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion

            #region << ***Update page body node*** Page: details ID: 4deda1c4-e4bd-474b-b9cd-71c7d27f5891 >>
            {
                var  id            = new Guid("4deda1c4-e4bd-474b-b9cd-71c7d27f5891");
                Guid?parentId      = new Guid("e04237dc-3454-4309-b183-09e83f9bd37c");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("24d7c716-fa27-4ccd-99d1-c7a8813a13f2");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldText";
                var  containerId   = "column2";
                var  options       = @"{
  ""is_visible"": """",
  ""label_mode"": ""0"",
  ""label_text"": ""Recipient"",
  ""mode"": ""2"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Linq;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\nusing Newtonsoft.Json;\\nusing WebVella.Erp.Plugins.Mail.Api;\\n\\npublic class CompositeSenderEmailVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\tif (pageModel == null)\\n\\t\\t\\treturn null;\\n\\n\\t\\tvar record = pageModel.TryGetDataSourceProperty<EntityRecord>(\\\""Record\\\"");\\n\\t\\tvar recipients = JsonConvert.DeserializeObject<List<EmailAddress>>( (string) record[\\\""recipients\\\""] );\\n\\t\\treturn string.Join( \\\"";\\\"", recipients.Select( x=> x.Address ).ToList() );\\n\\t}\\n}\"",\""default\"":\""\""}"",
  ""name"": ""recipient_email"",
  ""class"": """",
  ""maxlength"": 0,
  ""placeholder"": """",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion

            #region << ***Update page body node*** Page: details ID: 3b5fcbef-27e3-44c3-ad38-1202cccab408 >>
            {
                var  id            = new Guid("3b5fcbef-27e3-44c3-ad38-1202cccab408");
                Guid?parentId      = new Guid("e04237dc-3454-4309-b183-09e83f9bd37c");
                Guid?nodeId        = null;
                Guid pageId        = new Guid("24d7c716-fa27-4ccd-99d1-c7a8813a13f2");
                var  componentName = "WebVella.Erp.Web.Components.PcFieldText";
                var  containerId   = "column1";
                var  options       = @"{
  ""is_visible"": """",
  ""label_mode"": ""0"",
  ""label_text"": ""Sender"",
  ""mode"": ""2"",
  ""value"": ""{\""type\"":\""1\"",\""string\"":\""using System;\\nusing System.Linq;\\nusing System.Collections.Generic;\\nusing WebVella.Erp.Web.Models;\\nusing WebVella.Erp.Api.Models;\\nusing Newtonsoft.Json;\\nusing WebVella.Erp.Plugins.Mail.Api;\\n\\npublic class CompositeSenderEmailVariable : ICodeVariable\\n{\\n\\tpublic object Evaluate(BaseErpPageModel pageModel)\\n\\t{\\n\\t\\tif (pageModel == null)\\n\\t\\t\\treturn null;\\n\\n\\t\\tvar record = pageModel.TryGetDataSourceProperty<EntityRecord>(\\\""Record\\\"");\\n\\t\\tvar sender = JsonConvert.DeserializeObject<EmailAddress>( (string) record[\\\""sender\\\""] );\\n\\t\\treturn sender.Address;\\n\\t}\\n}\"",\""default\"":\""\""}"",
  ""name"": ""sender_email"",
  ""class"": """",
  ""maxlength"": 0,
  ""placeholder"": """",
  ""connected_entity_id"": """"
}";
                var  weight        = 1;

                new WebVella.Erp.Web.Services.PageService().UpdatePageBodyNode(id, parentId, pageId, nodeId, weight, componentName, containerId, options, WebVella.Erp.Database.DbContext.Current.Transaction);
            }
            #endregion
        }
Exemple #29
0
        public void Start(PluginStartArguments pluginStartArgs)
        {
            //initialize static context
            StaticContext.Initialize(pluginStartArgs.Plugin, pluginStartArgs.ServiceProvider);

            var entMan = new EntityManager();
            var relMan = new EntityRelationManager();
            var recMan = new RecordManager();
            var storeSystemSettings = DbContext.Current.SettingsRepository.Read();
            var systemSettings      = new SystemSettings(storeSystemSettings);

            using (SecurityContext.OpenSystemScope())
            {
                //Create transaction
                using (var connection = DbContext.Current.CreateConnection())
                {
                    try
                    {
                        connection.BeginTransaction();

                        //Here we need to initialize or update the environment based on the plugin requirements.
                        //The default place for the plugin data is the "plugin_data" entity -> the "data" text field, which is used to store stringified JSON
                        //containing the plugin settings or version

                        #region << 1.Get the current ERP database version and checks for other plugin dependencies >>
                        if (systemSettings.Version > 0)
                        {
                            //Do something if database version is not what you expect
                        }

                        //This plugin needs the webvella-crm plugin to be installed, so we will check this here
                        var installedPlugins = new PluginService().Plugins;
                        var crmPluginFound   = false;
                        foreach (var plugin in installedPlugins)
                        {
                            switch (plugin.Name)
                            {
                            case "webvella-crm":
                                crmPluginFound = true;
                                break;

                            default:
                                break;
                            }
                        }

                        if (!crmPluginFound)
                        {
                            throw new Exception("'webvella-crm' plugin is required for the 'webvella-project' to operate");
                        }

                        #endregion

                        #region << 2.Get the current plugin settings from the database >>
                        var         currentPluginSettings   = new PluginSettings();
                        QueryObject pluginDataQueryObject   = EntityQuery.QueryEQ("name", WEBVELLA_PROJECT_PLUGIN_NAME);
                        var         pluginDataQuery         = new EntityQuery("plugin_data", "*", pluginDataQueryObject);
                        var         pluginDataQueryResponse = recMan.Find(pluginDataQuery);
                        if (!pluginDataQueryResponse.Success)
                        {
                            throw new Exception("plugin 'webvella-project' failed to get its settings due to: " + pluginDataQueryResponse.Message);
                        }

                        if (pluginDataQueryResponse.Object == null || !pluginDataQueryResponse.Object.Data.Any() || pluginDataQueryResponse.Object.Data[0]["data"] == DBNull.Value)
                        {
                            //plugin was not installed
                            currentPluginSettings.Version = 20160429;
                            {
                                string json = JsonConvert.SerializeObject(currentPluginSettings);
                                var    settingsEntityRecord = new EntityRecord();
                                settingsEntityRecord["id"]   = WEBVELLA_PROJECT_PLUGIN_ID;
                                settingsEntityRecord["name"] = WEBVELLA_PROJECT_PLUGIN_NAME;
                                settingsEntityRecord["data"] = json;
                                var settingsSaveReponse = recMan.CreateRecord("plugin_data", settingsEntityRecord);
                                if (!settingsSaveReponse.Success)
                                {
                                    throw new Exception("plugin 'webvella-project' failed to save its settings in the database due to: " + pluginDataQueryResponse.Message);
                                }
                            }
                        }
                        else
                        {
                            string json = (string)((List <EntityRecord>)pluginDataQueryResponse.Object.Data)[0]["data"];
                            currentPluginSettings = JsonConvert.DeserializeObject <PluginSettings>(json);
                        }
                        #endregion

                        #region << 3. Run methods based on the current installed version of the plugin >>
                        if (currentPluginSettings.Version < 20160430)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160430;
                                Patch160430(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160610)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160610;
                                Patch160610(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160613)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160613;
                                Patch160613(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160627)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160627;
                                Patch160627(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20160707)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20160707;
                                Patch160707(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20161118)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20161118;
                                Patch161118(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20161119)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20161119;
                                Patch161119(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        if (currentPluginSettings.Version < 20170119)
                        {
                            try
                            {
                                currentPluginSettings.Version = 20170119;
                                Patch170119(entMan, relMan, recMan, createSampleRecords);
                            }
                            catch (Exception ex)
                            {
                                var exception = ex;
                                throw ex;
                            }
                        }

                        #endregion

                        #region << 4. Save needed changes to the plugin setting data >>
                        {
                            string json = JsonConvert.SerializeObject(currentPluginSettings);
                            var    settingsEntityRecord = new EntityRecord();
                            settingsEntityRecord["id"]   = WEBVELLA_PROJECT_PLUGIN_ID;
                            settingsEntityRecord["name"] = WEBVELLA_PROJECT_PLUGIN_NAME;
                            settingsEntityRecord["data"] = json;
                            var settingsUpdateReponse = recMan.UpdateRecord("plugin_data", settingsEntityRecord);
                            if (!settingsUpdateReponse.Success)
                            {
                                throw new Exception("plugin 'webvella-project' failed to update its settings in the database due to: " + pluginDataQueryResponse.Message);
                            }
                        }
                        #endregion


                        connection.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        connection.RollbackTransaction();
                        throw ex;
                    }
                }
            }
        }
Exemple #30
0
        public IActionResult OnPost()
        {
            PageInit();
            if (ErpEntity == null)
            {
                return(NotFound());
            }

            try
            {
                if (String.IsNullOrWhiteSpace(Origin) || !Origin.Contains("$"))
                {
                    throw new ValidationException("Origin field is required!");
                }
                if (String.IsNullOrWhiteSpace(Target) || !Target.Contains("$"))
                {
                    throw new ValidationException("Target field is required!");
                }
                var  originSections = Origin.Split('$');
                Guid originEntityId = new Guid(originSections[0]);
                Guid originFieldId  = new Guid(originSections[1]);

                var  targetSections = Target.Split('$');
                Guid targetEntityId = new Guid(targetSections[0]);
                Guid targetFieldId  = new Guid(targetSections[1]);

                var            relMan      = new EntityRelationManager();
                EntityRelation newRelation = new EntityRelation
                {
                    Id             = Guid.NewGuid(),
                    Name           = Name,
                    Label          = Name,            //Label, Boz: removed for convinience
                    Description    = "",              //Description, Boz: removed for convinience
                    System         = IsSystem,
                    OriginEntityId = originEntityId,
                    OriginFieldId  = originFieldId,
                    TargetEntityId = targetEntityId,
                    TargetFieldId  = targetFieldId,
                    RelationType   = Type
                };


                var response = relMan.Create(newRelation);
                if (!response.Success)
                {
                    var exception = new ValidationException(response.Message);
                    exception.Errors = response.Errors.MapTo <ValidationError>();
                    throw exception;
                }
                return(Redirect($"/sdk/objects/entity/r/{ErpEntity.Id}/rl/relations/l"));
            }
            catch (ValidationException ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors  = ex.Errors;
            }
            catch (Exception ex)
            {
                Validation.Message = ex.Message;
                Validation.Errors.Add(new ValidationError("", ex.Message, isSystem: true));
            }

            ErpRequestContext.PageContext = PageContext;

            BeforeRender();
            return(Page());
        }