Exemple #1
0
        public JsonpResult SaveAttribute(string appid, string compid, string attribute)
        {
            string clientid = Request.Params["clientkey"];
            var    apm      = new Tz.App.AppManager(clientid, appid);

            apm.GetComponents();
            var comp = apm.GetComponent(compid);

            Core.ComponentManager mg = new ComponentManager(comp);

            Models.Attribute att = new Models.Attribute();
            att = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Attribute>(attribute);
            //  Core.ComponentManager mg = new ComponentManager(clientid, compid);
            var natt = new ComponentAttribute(clientid)
            {
                AttributeName = att.AttributeName,
                AttributeType = (Core.ComponentAttribute.ComoponentAttributeType)att.AttributeType,
                ClientID      = clientid,
                DefaultValue  = att.DefaultValue,
                FileExtension = att.FileExtension,
                IsAuto        = att.IsAuto,
                IsCore        = att.IsCore,
                IsNullable    = att.IsNullable,
                IsPrimaryKey  = att.IsPrimaryKey,
                IsReadOnly    = att.IsReadOnly,
                IsRequired    = att.IsRequired,
                IsSecured     = att.IsSecured,
                IsUnique      = att.IsUnique,
                LookUpID      = att.LookUpID,
                Length        = att.Length,
                RegExp        = att.RegExp
            };

            return(new JsonpResult(mg.AddAttribute(natt)));
        }
        /// <summary>
        /// /
        /// </summary>
        /// <param name="clientid"></param>
        /// <param name="componentId"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public JsonpResult AddAttribute(string clientid, string componentId, string attribute)
        {
            //  Tz.Net.ClientServer c = new Net.ClientServer(clientid);
            Models.Attribute att = new Models.Attribute();
            att = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Attribute>(attribute);
            Core.ComponentManager mg = new ComponentManager(clientid, componentId);
            var natt = new ComponentAttribute(clientid)
            {
                AttributeName = att.AttributeName,
                AttributeType = (Core.ComponentAttribute.ComoponentAttributeType)att.AttributeType,
                ClientID      = clientid,
                DefaultValue  = att.DefaultValue,
                FileExtension = att.FileExtension,
                IsAuto        = att.IsAuto,
                IsCore        = att.IsCore,
                IsNullable    = att.IsNullable,
                IsPrimaryKey  = att.IsPrimaryKey,
                IsReadOnly    = att.IsReadOnly,
                IsRequired    = att.IsRequired,
                IsSecured     = att.IsSecured,
                IsUnique      = att.IsUnique,
                Length        = att.Length,
                RegExp        = att.RegExp
            };

            natt.setFieldID(att.FieldID);
            if (att.FieldID != "")
            {
                return(new JsonpResult(mg.ChangeAttribute(natt)));
            }
            else
            {
                return(new JsonpResult(mg.AddAttribute(natt)));
            }
        }