Ejemplo n.º 1
0
        public void SaveAttribute(FormAttributeEditDto dto)
        {
            var entity = new FormAttribute()
            {
                Id           = dto.Id,
                Name         = dto.Name,
                Required     = dto.Required,
                TenantId     = dto.TenantId,
                ControlType  = dto.ControlType,
                DisplayOrder = dto.DisplayOrder
            };

            foreach (var i in dto.FormAttributeValueEditDtos)
            {
                entity.FormAttributeValues.Add(new FormAttributeValue()
                {
                    DisplayOrder = i.DisplayOrder, Id = i.Id, Name = i.Name
                });
            }

            if (entity.Id != 0)
            {
                var remove = dbContext.Set <FormAttributeValue>().Where(s => s.FormAttribute.Id == entity.Id).AsNoTracking().ToList().Where(s => !dto.FormAttributeValueEditDtos.Any(v => v.Id == s.Id));
                dbContext.RemoveRange(remove);
            }

            dbContext.Update(entity);
            dbContext.SaveChanges();
        }
Ejemplo n.º 2
0
        private void LoadAssemblyFormResource(Assembly asm, FormAttribute addInAttribute)
        {
            if (string.IsNullOrWhiteSpace(addInAttribute.Resource) || asm.IsDynamic)
            {
                return;
            }

            using (var resource = asm.GetManifestResourceStream(addInAttribute.Resource))
            {
                if (resource != null)
                {
                    var doc = XDocument.Load(resource);
                    var key = asm.GetName().FullName;
                    Dictionary <string, XDocument> formDictionary;
                    if (!formSRFResource.ContainsKey(key))
                    {
                        formDictionary = new Dictionary <string, XDocument>();
                        formSRFResource.Add(key, formDictionary);
                    }
                    else
                    {
                        formDictionary = formSRFResource[key];
                    }
                    if (!formDictionary.ContainsKey(addInAttribute.Resource))
                    {
                        formDictionary.Add(addInAttribute.Resource, doc);
                    }
                    else
                    {
                        formDictionary[addInAttribute.Resource] = doc; // override b1s form. srf have higher priority.
                    }
                }
            }
        }
Ejemplo n.º 3
0
        internal void Initialize()
        {
            if (!initialized)
            {
                try
                {
                    initialized = true;
                    this.UIAPIRawForm.Freeze(true);

                    FormAttribute formAttribute = (FormAttribute)(from attribute in this.GetType().GetCustomAttributes(true)
                                                                  where attribute is FormAttribute
                                                                  select attribute).First();
                    var asmName = this.GetType().BaseType.Assembly.GetName().FullName;

                    XDocument doc = resourceManager.GetSystemFormXDoc(asmName, formAttribute.Resource, formUID);
                    if (doc != null) // i18n stuff.
                    {
                        string xml   = ChangeMethodForUpdate(doc);
                        string title = GetFormTitle(doc);

                        if (!string.IsNullOrEmpty(xml))
                        {
                            b1UIDAO.LoadBatchAction(xml);
                            this.UIAPIRawForm.Title = title;
                        }
                    }
                    this.OnInitializeComponent(); // UI elements displayed only after form creation.
                }
                finally                           // prevent loop on exceptions.
                {
                    initialized = true;
                    this.UIAPIRawForm.Freeze(false);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            FormAttribute attributeTable = new FormAttribute(m_mapControl);

            attributeTable.CreateAttributeTable(m_pLayer);
            attributeTable.ShowDialog();
        }
Ejemplo n.º 5
0
        public override void OnClick()
        {
            // TODO: Add OpenAttribute.OnClick implementation


            FormAttribute attributeTable = new FormAttribute(m_mapControl, _MapControl);

            attributeTable.CreateAttributeTable(m_pLayer);
            attributeTable.ShowDialog();
        }
Ejemplo n.º 6
0
        private void UpdateSystemForm()
        {
            FormAttribute formAttribute = (FormAttribute)(from attribute in this.GetType().GetCustomAttributes(true)
                                                          where attribute is FormAttribute
                                                          select attribute).First();
            var asmName = this.GetType().BaseType.Assembly.GetName().FullName;

            string xml = resourceManager.GetSystemFormXML(asmName, formAttribute.Resource, formUID);

            b1UIDAO.LoadBatchAction(xml);
            formEventHandler.RegisterForm(formUID, this);
            this.OnInitializeComponent();
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 初始化
 /// </summary>
 public FormBuilder()
 {
     Attribute = new FormAttribute(null);
     Fields    = new List <FormField>();
     if (Attribute.EnableCsrfToken)
     {
         // 获取客户端传入的csrf校验值,不存在时设置
         var context = HttpManager.CurrentContext;
         CsrfToken = context.GetCookie(CsrfTokenKey);
         if (string.IsNullOrEmpty(CsrfToken))
         {
             CsrfToken = RandomUtils.SystemRandomBytes(20).ToHex();
             context.PutCookie(CsrfTokenKey, CsrfToken);
         }
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 初始化
 /// </summary>
 public FormBuilder()
 {
     Attribute = new FormAttribute(null);
     Fields    = new List <FormField>();
     if (Attribute.EnableCsrfToken)
     {
         // 获取客户端传入的csrf校验值,不存在时设置
         var csrfTokenStore = Application.Ioc.Resolve <ICsrfTokenStore>();
         CsrfToken = csrfTokenStore.GetCsrfToken();
         if (string.IsNullOrEmpty(CsrfToken))
         {
             CsrfToken = RandomUtils.SystemRandomBytes(20).ToHex();
             csrfTokenStore.SetCsrfToken(CsrfToken);
         }
     }
 }
Ejemplo n.º 9
0
        public DoverUserFormBase()
        {
            var resourceManager  = ContainerManager.Container.Resolve <B1SResourceManager>();
            var b1UIDAO          = ContainerManager.Container.Resolve <BusinessOneUIDAO>();
            var formEventHandler = ContainerManager.Container.Resolve <IFormEventHandler>();

            FormAttribute formAttribute = (FormAttribute)(from attribute in this.GetType().GetCustomAttributes(true)
                                                          where attribute is FormAttribute
                                                          select attribute).First();
            var asmName = this.GetType().BaseType.Assembly.GetName().FullName;

            formEventHandler.RegisterFormLoadBefore(formAttribute.FormType, this);
            string xml = resourceManager.GetFormXML(asmName, formAttribute.Resource);

            this.UIAPIRawForm = b1UIDAO.LoadFormBatchAction(xml, formAttribute.FormType);
            if (this.UIAPIRawForm != null)
            {
                formEventHandler.RegisterForm(this.UIAPIRawForm.UniqueID, this);
                this.OnInitializeComponent();
            }
        }
Ejemplo n.º 10
0
        protected FormBase()
        {
            formUid = new List <string>();
            FormAttribute attribute = null;
            int           index     = 0;

            foreach (object obj2 in base.GetType().GetCustomAttributes(false))
            {
                if (obj2 is FormAttribute)
                {
                    attribute = obj2 as FormAttribute;

                    if (!string.IsNullOrEmpty(attribute.formUid))
                    {
                        string form = attribute.formUid;
                        this.formUid.Add(form.Substring(0, 1) == "@" ? form.Replace("@", "UDO_FT_") : form);
                    }

                    string formulario = this.formUid.SingleOrDefault(e => e == attribute.formUid);

                    if (!string.IsNullOrEmpty(formulario))
                    {
                        B1AppDomain.RegisterFormByType(formulario, this);
                    }



                    index++;
                }
            }
            if (attribute == null)
            {
                B1Exception.writeLog("Falha ao indexar Form. Por favor checar os atributos informados");
            }


            this.OnInitializeFormEvents();
        }
Ejemplo n.º 11
0
 protected IHtmlContent GenerateContent(ModelExpression f, FormAttribute fa) =>
 fa?.Type switch
 {
Ejemplo n.º 12
0
        private void LoadAssemblyFormResource(Assembly asm, FormAttribute addInAttribute)
        {
            if (string.IsNullOrWhiteSpace(addInAttribute.Resource) || asm.IsDynamic)
                return;

            using (var resource = asm.GetManifestResourceStream(addInAttribute.Resource))
            {
                if (resource != null)
                {
                    var doc = XDocument.Load(resource);
                    var key = asm.GetName().FullName;
                    Dictionary<string, XDocument> formDictionary;
                    if (!formSRFResource.ContainsKey(key))
                    {
                        formDictionary = new Dictionary<string, XDocument>();
                        formSRFResource.Add(key, formDictionary);
                    }
                    else
                    {
                        formDictionary = formSRFResource[key];
                    }
                    if (!formDictionary.ContainsKey(addInAttribute.Resource))
                    {
                        formDictionary.Add(addInAttribute.Resource, doc);
                    }
                    else
                    {
                        formDictionary[addInAttribute.Resource] = doc; // override b1s form. srf have higher priority.
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public override void OnClick()
        {
            FormAttribute formtable = new FormAttribute(_MapControl, m_mapControl);

            formtable.Show();
        }
Ejemplo n.º 14
0
 public bool IsAttributeSet(FormAttribute paAttribute)
 {
     return(ActiveRow.FormAttribute.Contains("#" + paAttribute.ToString().ToUpper()));
 }