Пример #1
0
 public void DeleteProperty(GxProperty gxProperty)
 {
     //GxProperty which is used can't be deleted.
     if (gxDb.Template_Properties.Any(u => u.GxPropertyId == gxProperty.Id))
     {
         return;
     }
     gxDb.GxProperties.Remove(gxProperty);
     gxDb.SaveChanges();
 }
Пример #2
0
        public void JsonTest()
        {
            var p = new GxProperty()
            {
                Name         = "附属物",
                Label        = "Feature",
                DataType     = DataTypeEnum.String,
                DefaultValue = string.Empty,
                MainType     = MainType.ALL
            };

            p.AlternativeValues.AddRange(new string[] { "检查井", "手孔" });

            string jsonstr = JsonConvert.SerializeObject(p);

            output.WriteLine(jsonstr);
            GxProperty pd = JsonConvert.DeserializeObject <GxProperty>(jsonstr);

            Assert.NotNull(pd);
            Assert.Equal("Feature", pd.Label);
        }
Пример #3
0
        /// <summary>
        /// 从Excel读取模版文件
        /// </summary>
        /// <param name="path"></param>
        /// <returns>属性列表</returns>
        public static List <GxProperty> ReadDefaultTemplate(string path = @"i:\VSProject\DiboPipeLine\DiboWeb\wwwroot\PropertyTemplate\defaultTemplate.xlsx")
        {
            //string path = @"i:\VSProject\DiboPipeLine\DiboWeb\wwwroot\defaultTemplate.xlsx";
            FileInfo fileInfo = new FileInfo(path);

            if (!fileInfo.Exists)
            {
                throw new FileNotFoundException(path + " does not exist!");
            }

            var gxProperties = new List <GxProperty>(64);

            using (var exfile = new ExcelPackage(fileInfo))
            {
                ExcelWorksheet worksheet = exfile.Workbook.Worksheets[0];
                int            row       = 2;
                while (worksheet.Cells[row, 1].GetValue <int?>() != null)
                {
                    var property = new GxProperty
                    {
                        Sequence          = worksheet.Cells[row, 1].GetValue <int>(),
                        Label             = worksheet.Cells[row, 3].GetValue <string>(),
                        Name              = worksheet.Cells[row, 4].GetValue <string>(),
                        AlternativeString = worksheet.Cells[row, 7].GetValue <string>(),
                        MainType          = GetMainType(worksheet.Cells[row, 8].GetValue <string>()),
                        GeometryType      = GetGeometryType(worksheet.Cells[row, 9].GetValue <string>()),
                        Required          = worksheet.Cells[row, 10].GetValue <bool?>() ?? false
                    };

                    gxProperties.Add(property);
                    row++;
                }
            }

            return(gxProperties);
        }
Пример #4
0
 public void  AddProperty(GxProperty gxProperty)
 {
     gxDb.GxProperties.Add(gxProperty);
     gxDb.SaveChanges();
 }