示例#1
0
        // POST: odata/SaveTables
        public IHttpActionResult Post(SaveTable saveTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SaveTables.Add(saveTable);
            db.SaveChanges();

            return(Created(saveTable));
        }
示例#2
0
 private void MetroButton6_Click(object sender, EventArgs e)
 {
     try
     {
         BinaryFormatter formatter = new BinaryFormatter();
         using (FileStream fs = new FileStream("My_table.txt", FileMode.OpenOrCreate, FileAccess.Read))
         {
             SaveTable newTable = (SaveTable)formatter.Deserialize(fs);
             flowLayoutPanel1 = newTable.Temp_panel;
         }
     }
     catch (Exception) {}
 }
示例#3
0
 private void MetroButton5_Click(object sender, EventArgs e)
 {
     try
     {
         SaveTable       person    = new SaveTable(flowLayoutPanel1);
         BinaryFormatter binFormat = new BinaryFormatter();
         using (Stream fStream = new FileStream("My_table.txt", FileMode.Create, FileAccess.Write, FileShare.None))
         {
             binFormat.Serialize(fStream, person);
         }
     }
     catch (Exception) {}
 }
示例#4
0
        // DELETE: odata/SaveTables(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            SaveTable saveTable = db.SaveTables.Find(key);

            if (saveTable == null)
            {
                return(NotFound());
            }

            db.SaveTables.Remove(saveTable);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#5
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <SaveTable> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SaveTable saveTable = db.SaveTables.Find(key);

            if (saveTable == null)
            {
                return(NotFound());
            }

            patch.Patch(saveTable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SaveTableExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(saveTable));
        }
示例#6
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            code.AppendLine($@"['ColumnIndexStart'] ={ColumnIndexStart},");

            code.AppendLine($@"['IsUniqueUnion'] ={(IsUniqueUnion.ToString().ToLower())},");

            if (PrimaryColumn != null)
            {
                code.AppendLine($@"['PrimaryColumn'] = {PrimaryColumn.GetLuaStruct()},");
            }

            if (!string.IsNullOrWhiteSpace(PrimaryField))
            {
                code.AppendLine($@"['PrimaryField'] = '{PrimaryField.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PrimaryField'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(RedisKey))
            {
                code.AppendLine($@"['RedisKey'] = '{RedisKey.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['RedisKey'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ModelInclude))
            {
                code.AppendLine($@"['ModelInclude'] = '{ModelInclude.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ModelInclude'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ModelBase))
            {
                code.AppendLine($@"['ModelBase'] = '{ModelBase.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ModelBase'] = nil,");
            }

            code.AppendLine($@"['DataVersion'] ={DataVersion},");

            code.AppendLine($@"['IsInternal'] ={(IsInternal.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Name))
            {
                code.AppendLine($@"['Name'] = '{Name.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Name'] = nil,");
            }

            code.AppendLine($@"['IsClass'] ={(IsClass.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Interfaces))
            {
                code.AppendLine($@"['Interfaces'] = '{Interfaces.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Interfaces'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Project))
            {
                code.AppendLine($@"['Project'] = '{Project.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Project'] = nil,");
            }

            code.AppendLine($@"['MaxIdentity'] ={MaxIdentity},");

            idx = 0;
            code.AppendLine("['Properties'] ={");
            foreach (var val in Properties)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['LastProperties'] ={");
            //foreach (var val in LastProperties)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            idx = 0;
            code.AppendLine("['Commands'] ={");
            foreach (var val in Commands)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            idx = 0;
            code.AppendLine("['Releations'] ={");
            foreach (var val in Releations)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            code.AppendLine($@"['MaxForm'] ={(MaxForm.ToString().ToLower())},");

            code.AppendLine($@"['ListDetails'] ={(ListDetails.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ReadTableName))
            {
                code.AppendLine($@"['TableName'] = '{ReadTableName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['TableName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(SaveTableName))
            {
                code.AppendLine($@"['SaveTableName'] = '{SaveTableName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['SaveTableName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(SaveTable))
            {
                code.AppendLine($@"['SaveTable'] = '{SaveTable.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['SaveTable'] = nil,");
            }

            code.AppendLine($@"['DbIndex'] ={DbIndex},");

            code.AppendLine($@"['UpdateByModified'] ={(UpdateByModified.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(CppName))
            {
                code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DisplayName))
            {
                code.AppendLine($@"['DisplayName'] = '{DisplayName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DisplayName'] = nil,");
            }

            //idx = 0;
            //code.AppendLine("['PublishProperty'] ={");
            //foreach (var val in PublishProperty)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['CppProperty'] ={");
            //foreach (var val in CppProperty)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['ClientProperty'] ={");
            //foreach (var val in ClientProperty)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['UserProperty'] ={");
            //foreach (var val in UserProperty)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['PublishDbFields'] ={");
            //foreach (var val in PublishDbFields)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['DbFields'] ={");
            //foreach (var val in DbFields)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");

            //idx = 0;
            //code.AppendLine("['ReadCoreCodes'] ={");
            //foreach (var val in ReadCoreCodes.Values)
            //{
            //    if (idx++ > 0)
            //        code.Append(',');
            //    code.AppendLine($@"{val.GetLuaStruct()}");
            //}
            //code.AppendLine("},");
        }