示例#1
0
 public bool Check()
 {
     try
     {
         if (dataSet != null)
         {
             StageDef domain = standardDef.StageContainer.Find(x => x.Code == dataSet.DataSetName);
             foreach (DataTable table in dataSet.Tables)
             {
                 DGObjectDef objectDef = domain.DGObjectContainer.Find(x => x.LangStr == table.TableName);
                 CheckRows(table, objectDef);
             }
         }
         else if (dataTable != null)
         {
             DGObjectDef objectDef = standardDef.GetDGObjectDefByName(dataTable.TableName);
             CheckRows(dataTable, objectDef);
         }
         return(true);
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(e.Message);
         return(false);
     }
 }
示例#2
0
        /// <param name="domain"></param>
        public void GenerateClass(StageDef domain)
        {
            try
            {
                Dictionary <string, string> Types = new DataType().Gettype;
                foreach (DGObjectDef dGObject in domain.DGObjectContainer)
                {
                    string newClass = "using System; \nusing System.ComponentModel.DataAnnotations.Schema;\n";
                    newClass += "using iS3.Core.Model;\n";
                    newClass += "\nnamespace " + "iS3." + standard.Code + ".Model\n { \n \t";
                    newClass += "///<summary>///" + (dGObject.LangStr ?? dGObject.Code) + "///</summary>\n";
                    newClass += "\t[Table(\"" + standard.Code + "_" + dGObject.Code + "\")]\n";
                    newClass += "\tpublic class " + dGObject.Code + ":DGObject\n \t{ \n";
                    foreach (PropertyMeta meta in dGObject.PropertyContainer)
                    {
                        newClass += "\t\t/// <summary>\n\t\t///" + meta.LangStr + " \n\t\t///</summary>\n";
                        if (meta.Nullable == false)
                        {
                            if (Types[meta.DataType] != "string")
                            {
                                newClass += "\t\tpublic " + Types[meta.DataType] + "  " + meta.PropertyName + " {get;set;}\n";
                            }
                            else
                            {
                                newClass += "\t\tpublic " + Types[meta.DataType] + " " + meta.PropertyName + " {get;set;}\n";
                            }
                        }
                        else
                        {
                            if (Types[meta.DataType] != "string")
                            {
                                newClass += "\t\tpublic Nullable<" + Types[meta.DataType] + "> " + meta.PropertyName + " {get;set;}\n";
                            }
                            else
                            {
                                newClass += "\t\tpublic " + Types[meta.DataType] + " " + meta.PropertyName + " {get;set;}\n";
                            }
                        }
                    }

                    newClass += "\t}\n}";
                    string       path = AppDomain.CurrentDomain.BaseDirectory + @"..\..\ObjectModels\" + dGObject.Code + ".cs";
                    FileStream   fs   = new FileStream(path, FileMode.Create, FileAccess.Write);
                    StreamWriter sw   = new StreamWriter(fs);
                    sw.Write(newClass);
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                }
                System.Windows.MessageBox.Show("Gengerated Successfully!");
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.ToString());
            }
        }
示例#3
0
 void Awake()
 {
     if (CurrentStage < stage.Length)
     {
         StageDef s = stage[CurrentStage];
         bg.sprite          = s.bg;
         stageNameText.text = s.stageName;
     }
     else
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene("Clear");
     }
 }
示例#4
0
        public DataSet LoadData(string StageName)
        {
            StageDef stage = standard.StageContainer.Find(x => x.Code == StageName);

            if (stage != null)
            {
                return(ReadJson(stage));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        private DataSet ReadJson(StageDef stage)
        {
            path = localPath.Parent.Parent.FullName + "\\Data\\Temp\\Data_" + stage.Code + ".json";
            FileStream   fs           = new FileStream(path, FileMode.Open, FileAccess.Read);
            StreamReader streamReader = new StreamReader(fs, Encoding.UTF8);
            string       json         = streamReader.ReadToEnd();

            fs.Close();
            streamReader.Close();
            DataSet data = JsonConvert.DeserializeObject <DataSet>(json);

            data.DataSetName = stage.Code;
            return(data);
        }
示例#6
0
        private void Filter2Standard(Category category, ref StandardDef standardDef, StandardDef dataStandard)
        {
            StageDef domain = new StageDef()
            {
                Code    = category.CategoryName,
                LangStr = category.LangStr
            };

            foreach (string obj in category.objList)
            {
                DGObjectDef objectDef = dataStandard.GetDGObjectDefByCode(obj);
                domain.DGObjectContainer.Add(objectDef);
            }
            standardDef.StageContainer.Add(domain);
        }
示例#7
0
 private void Watchnewdata_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TreeNode node = LYTunnelTreeview.SelectedItem as TreeNode;
         if ((node == null) || (node.Level != 2))
         {
             return;
         }
         DataImporter_Excel dataImporter  = new DataImporter_Excel();
         string             path          = Runtime.dataPath + "\\ProjectData\\LYTunnel.xls";
         DataTable          _newdatatable = dataImporter.Import(path, LYTunnelStandard, node.Context);
         if (_newdatatable.Columns.Count == 0)
         {
             StageDef    stage    = LYTunnelStandard.StageContainer.Find(x => x.Code == node.Parent);
             DGObjectDef dGObject = stage.DGObjectContainer.Find(x => x.Code == node.Code);
             if (dGObject != null)
             {
                 foreach (PropertyMeta meta in dGObject.PropertyContainer)
                 {
                     _newdatatable.Columns.Add(meta.LangStr);
                 }
             }
         }
         string[] distinctcols = new string[(_newdatatable.Columns.Count)];
         foreach (DataColumn dataColumn in _newdatatable.Columns)
         {
             distinctcols[dataColumn.Ordinal] = dataColumn.ColumnName;
         }
         DataView mydataview = new DataView(_newdatatable);
         _newdatatable = mydataview.ToTable(true, distinctcols); //去重复
         datatable_clean(_newdatatable);                         //去空白行
         Comparetables(currenttable, _newdatatable);
         DataView view = new DataView(_newdatatable);
         DataDG.ItemsSource = view;
         ChangeStyle style = new ChangeStyle(_newdatatable, ref DataDG, LYTunnelStandard);
         style.RefreshStyle();
         DataDG.ScrollIntoView(DataDG.Items[0]);
         DataDG.UpdateLayout();
         Statelabel.Content = "校核结果如上,如无误则点击“上传新数据”按钮";
         newdatatable       = _newdatatable;
     }
     catch (Exception ex)
     {
         MessageBox.Show("请保存Excel模板文件,并关闭它!");
     }
 }
示例#8
0
        /// <summary>
        /// import Data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private async void DataTemplateTreeview_SelectedItemChanged(object sender, RoutedEventArgs e)
        {
            try
            {
                TreeNode node = LYTunnelTreeview.SelectedItem as TreeNode;
                if ((node == null) || (node.Level != 2))
                {
                    return;
                }
                StageDef    stage    = LYTunnelStandard.StageContainer.Find(x => x.Code == node.Parent);
                DGObjectDef dGObject = stage.DGObjectContainer.Find(x => x.Code == node.Code);
                Project     _prj     = Globals.project;
                Domain      _domain  = _prj.getDomain(stage.Code);
                DGObjects   objs     = _domain.DGObjectsList.Where(x => x.definition.Type == dGObject.Code).FirstOrDefault();
                await GetData(objs);

                if (currenttable.Columns.Count == 0)
                {
                    if (dGObject != null)
                    {
                        foreach (PropertyMeta meta in dGObject.PropertyContainer)
                        {
                            currenttable.Columns.Add(meta.LangStr);
                        }
                    }
                }

                DataView view = new DataView(currenttable);
                DataDG.ItemsSource = view;
                DataDG.UpdateLayout();
                ChangeStyle style = new ChangeStyle(currenttable, ref DataDG, LYTunnelStandard);
                style.IDindex = currenttable_IDindex;
                style.Addattachment();
                DataDG.UpdateLayout();
                DataDG.ScrollIntoView(DataDG.Items[0]);
                DataDG.UpdateLayout();


                Statelabel.Content = "请查看" + currenttable.TableName + "的所有数据!";
            }
            catch (Exception ex)
            {
                MessageBox.Show("读取云端数据发生意外,读取失败!");
            }
        }
        bool write2Exl(StageDef domain, IWorkbook workbook)
        {
            foreach (DGObjectDef item in domain.DGObjectContainer)
            {
                HSSFCellStyle cellStyle1 = (HSSFCellStyle)workbook.CreateCellStyle();
                HSSFCellStyle cellStyle2 = (HSSFCellStyle)workbook.CreateCellStyle();
                cellStyle1.FillForegroundColor = HSSFColor.SkyBlue.Index;
                cellStyle1.FillPattern         = FillPattern.SolidForeground;
                cellStyle1.FillBackgroundColor = HSSFColor.Yellow.Index;
                cellStyle1.FillPattern         = FillPattern.SolidForeground;
                cellStyle2 = cellStyle1;

                ISheet sheet = workbook.CreateSheet(item.LangStr ?? item.Code);
                writeDescription(sheet, item);
                wrtieTitle(sheet, item, cellStyle1, cellStyle2);
            }
            return(true);
        }
        public bool Export(StageDef domain, string path = null)
        {
            this.domain = domain;
            if (path != null)
            {
                this.path = path;
            }
            bool succeed = Export();

            if (succeed)
            {
                System.Windows.MessageBox.Show("数据模板已保存至桌面");         //The Exl templete generated successfully at Destop!
            }
            else
            {
                System.Windows.MessageBox.Show("错误,请重新尝试"); //Someting getting wrong during generating,Please try again!
            }
            return(succeed);
        }
示例#11
0
    public void NotifyClicked(Clickable c)
    {
        Debug.Log("note " + c.name + " stage=" + stage);
        if (binocular.gameObject.activeSelf)
        {
            return;
        }

        if (stage >= stages.Count)
        {
            return;
        }

        if (c.GetComponent <ShovelClickable>())
        {
            Destroy(c.gameObject);
            shovel.SetActive(true);
            return;
        }

        if (c.GetComponent <DigClickable>())
        {
            if (shovel.activeSelf)
            {
                c.GetComponent <DigClickable>().Dig(mainChar.transform.position.x);
            }
            return;
        }

        if (Time.time - lastClickTime < 0.5f)
        {
            return;
        }
        lastClickTime = Time.time;

        StageDef sdef = stages[stage];

        sdef.NotifyClicked(c);
        if (sdef.IsDone() && wonStages <= stage)
        {
            WinStage();
        }
    }
 /// <summary>
 /// export standard to excel for data input
 /// </summary>
 /// <param name="standard"></param>
 /// <param name="path">the path where excel will generate at</param>
 /// <returns></returns>
 public bool Export(StandardDef standard, string path = null)
 {
     this.standard = standard;
     this.path     = path ?? this.path;
     try
     {
         foreach (StageDef domain in standard.StageContainer)
         {
             this.domain = domain;
             Export();
         }
     }
     catch (Exception e)
     {
         System.Windows.MessageBox.Show(e.Message);
         return(false);
     }
     return(true);
 }
示例#13
0
        public DataSet UpdateDataSet(DataSet oldSet, DataSet newDataSet, StageDef stage)
        {
            this.stage = stage;
            path       = localPath + @"\Data\Template\" + stage.Code + ".xls";
            BackupExcel(path);
            RebuildTemplate();

            DataSet addedDataSet = new DataSet()
            {
                DataSetName = oldSet.DataSetName
            };
            int count = newDataSet.Tables.Count;

            if (count > 5)
            {
                foreach (DataTable newTable in newDataSet.Tables)
                {
                    if (newTable.Rows.Count < 1)
                    {
                        continue;
                    }
                    DataTable       oldTable   = oldSet.Tables[newTable.TableName];
                    DGObjectDef     dG         = stage.DGObjectContainer.Find(x => (x.LangStr == newTable.TableName || x.Code == newTable.TableName));
                    TableComparator comparator = new TableComparator(oldTable, newTable, dG);
                    comparator.Compare();
                    DataTable UpdatedTable = comparator.updatedTable;
                    updatedDataSet = newDataSet.Clone();
                    updatedDataSet.Tables.Remove(UpdatedTable.TableName);
                    updatedDataSet.Tables.Add(UpdatedTable);

                    foreach (DataRow row in UpdatedTable.Rows)
                    {
                        oldTable.ImportRow(row);
                    }
                    oldSet.Tables.Remove(oldTable.TableName);
                    oldSet.Tables.Add(oldTable);
                }
            }

            return(oldSet);
        }
 bool write2Exl(StageDef domain, IWorkbook workbook)
 {
     foreach (DGObjectDef objectDef in domain.DGObjectContainer)
     {
         XSSFCellStyle cellStyle1 = (XSSFCellStyle)workbook.CreateCellStyle();
         XSSFCellStyle cellStyle2 = (XSSFCellStyle)workbook.CreateCellStyle();
         XSSFColor     color1     = new XSSFColor();
         XSSFColor     color2     = new XSSFColor();
         //根据自己需要设置RGB
         byte[] colorRgb1 = { (byte)214, (byte)220, (byte)228 };
         byte[] colorRgb2 = { (byte)221, (byte)235, (byte)247 };
         color1.SetRgb(colorRgb1);
         color2.SetRgb(colorRgb2);
         cellStyle1.FillForegroundColorColor = color1;
         cellStyle1.FillPattern = FillPattern.SolidForeground;
         cellStyle2.FillBackgroundColorColor = color2;
         cellStyle2.FillPattern = FillPattern.SolidForeground;
         string sheetName = objectDef.LangStr ?? objectDef.Code;
         ISheet sheet     = workbook.CreateSheet(sheetName);
         writeDescription(sheet, objectDef);
         wrtieTitle(sheet, objectDef, cellStyle1, cellStyle2);
     }
     return(true);
 }
示例#15
0
        private void Row2Object(IRow row)
        {
            //try
            //{
            string domainName    = row.GetCell(0).ToString();
            string domainDes     = row.GetCell(1)?.ToString();
            string domainlangStr = row.GetCell(2)?.ToString();
            string objectName    = row.GetCell(3)?.ToString();
            string objDescrip    = row.GetCell(4)?.ToString();
            string objLangStr    = row.GetCell(5)?.ToString();
            string propertyName  = row.GetCell(6).ToString();
            bool   IsKey         = row.GetCell(7)?.ToString() == null ? false : row.GetCell(7).ToString() == "TRUE";
            string dataType      = row.GetCell(8)?.ToString().Replace(" ", "");
            bool   Nullable      = row.GetCell(9)?.ToString() == null ? true : row.GetCell(9).ToString() != "FALSE";
            string unit          = row.GetCell(10)?.ToString();
            string regularExp    = row.GetCell(11)?.ToString();
            string proLanStr     = row.GetCell(12)?.ToString();
            string proDes        = row.GetCell(13)?.ToString();


            StageDef     domain;
            DGObjectDef  objectDef;
            PropertyMeta property = new PropertyMeta
            {
                PropertyName = propertyName,
                IsKey        = IsKey,
                Nullable     = Nullable,
                DataType     = dataType,
                Unit         = unit,
                Description  = proDes,
                RegularExp   = regularExp,
                LangStr      = proLanStr
            };

            if (this.standardDef.StageContainer.Exists(x => x.Code == domainName))
            {
                domain = this.standardDef.StageContainer.Find(x => x.Code == domainName);

                if (domain.DGObjectContainer.Exists(x => x.Code == objectName))
                {
                    objectDef = domain.DGObjectContainer.Find(x => x.Code == objectName);
                    if (!objectDef.PropertyContainer.Exists(x => x.PropertyName == property.PropertyName))
                    {
                        objectDef.PropertyContainer.Add(property);
                    }
                }
                else
                {
                    objectDef = new DGObjectDef
                    {
                        Code        = objectName,
                        Desctiption = objDescrip,
                        LangStr     = objLangStr
                    };
                    objectDef.PropertyContainer.Add(property);
                    domain.DGObjectContainer.Add(objectDef);
                }
            }
            else
            {
                domain = new StageDef
                {
                    Code       = domainName,
                    Desciption = domainDes,
                    LangStr    = domainlangStr
                };
                objectDef = new DGObjectDef
                {
                    Code        = objectName,
                    Desctiption = objDescrip,
                    LangStr     = objLangStr
                };
                objectDef.PropertyContainer.Add(property);
                domain.DGObjectContainer.Add(objectDef);
                this.standardDef.StageContainer.Add(domain);
            }
            //}
            //catch (Exception e)
            //{
            //    //throw e;
            //    System.Windows.MessageBox.Show(e.Message);
            //}
        }
示例#16
0
        private async void SaveChangeBT_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TreeNode node = LYTunnelTreeview.SelectedItem as TreeNode;
                if ((node == null) || (node.Level != 2))
                {
                    return;
                }
                if (newdatatable == null)
                {
                    return;
                }


                DGObjectDef objectDef = LYTunnelStandard.GetDGObjectDefByName(newdatatable.TableName);
                StageDef    _domain   = LYTunnelStandard.GetStageDefByName(newdatatable.TableName);
                if ((objectDef == null) || (_domain == null))
                {
                    MessageBox.Show("检查数据标准表!");
                    return;
                }

                var                         obj            = iS3Property.GetInstance(_domain.Code, objectDef.Code);
                Type                        _type          = iS3Property.GetType(_domain.Code, objectDef.Code);
                MethodInfo                  mi             = typeof(iS3Property).GetMethod("GetProperty").MakeGenericMethod(_type);
                List <PropertyDef>          _propertyDefs  = mi.Invoke(new iS3Property(), new object[] { Activator.CreateInstance(_type) }) as List <PropertyDef>;
                Dictionary <string, object> Property2Value = new Dictionary <string, object>();

                foreach (DataRow row in newdatatable.Rows)
                {
                    foreach (PropertyMeta meta in objectDef.PropertyContainer)
                    {
                        Property2Value[meta.PropertyName] = row[meta.LangStr];
                        if (Property2Value[meta.PropertyName].ToString() == "")
                        {
                            Property2Value[meta.PropertyName] = null;
                        }
                    }
                    foreach (PropertyDef def in _propertyDefs)
                    {
                        PropertyInfo info = _type.GetProperty(def.key); //获取指定名称的属性
                        if (Property2Value.ContainsKey(def.key))
                        {
                            var value = Property2Value[def.key];
                            if (!info.PropertyType.IsGenericType)
                            {
                                //非泛型
                                info.SetValue(obj, (value != null) ? Convert.ChangeType(value, info.PropertyType) : null);
                            }
                            else
                            {
                                //泛型Nullable<>
                                Type genericTypeDefinition = info.PropertyType.GetGenericTypeDefinition();
                                if (genericTypeDefinition == typeof(Nullable <>))
                                {
                                    info.SetValue(obj, (value != null) ? Convert.ChangeType(value, Nullable.GetUnderlyingType(info.PropertyType)) : null);
                                }
                            }
                        }
                    }
                    DGObject _obj = await RepositoryForClient.Create(obj as DGObject, _domain.Code, objectDef.Code);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            System.Windows.MessageBox.Show("数据已存储至数据库"); //Data has been stored to DataBase!
            DataTemplateTreeview_SelectedItemChanged(this, new RoutedEventArgs());
            newdatatable = null;
        }
示例#17
0
        DataTable ReadFromDgobjects(List <DGObject> objList)
        {
            if (objList.Count == 0)
            {
                return(null);
            }
            StageDef    _domain   = LYTunnelStandard.StageContainer.Find(x => x.Code == objList[0].parent.definition.Domain);
            DGObjectDef objectDef = _domain.DGObjectContainer.Find(x => x.Code == objList[0].parent.definition.Type);
            DataTable   dt        = new DataTable()
            {
                TableName = objectDef.LangStr
            };

            Type                        _type          = iS3Property.GetType(_domain.Code, objectDef.Code);
            MethodInfo                  mi             = typeof(iS3Property).GetMethod("GetProperty").MakeGenericMethod(_type);
            List <PropertyDef>          _propertyDefs  = mi.Invoke(new iS3Property(), new object[] { Activator.CreateInstance(_type) }) as List <PropertyDef>;
            Dictionary <string, object> Property2Value = new Dictionary <string, object>();

            foreach (PropertyMeta meta in objectDef.PropertyContainer)
            {
                dt.Columns.Add(meta.LangStr);
            }

            currenttable_IDindex = new List <int>();
            for (int i = 0; i < objList.Count; i++)
            {
                DGObject _obj = objList[i];
                DataRow  dr   = dt.NewRow();
                //将obj数据读取出来放进词典中
                try
                {
                    foreach (PropertyDef def in _propertyDefs)
                    {
                        PropertyInfo info = _type.GetProperty(def.key); //获取指定名称的属性

                        Property2Value[def.key] = info.GetValue(_obj, null);
                        if (def.type == typeof(Nullable <DateTime>) && (Property2Value[def.key] != null))
                        {
                            DateTime temp = (DateTime)Property2Value[def.key];
                            Property2Value[def.key] = temp.ToShortDateString();
                        }
                        if ((Property2Value[def.key] != null) && (Property2Value[def.key].ToString() == ""))
                        {
                            Property2Value[def.key] = null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                bool flag = true;
                //给row的元素赋值
                foreach (PropertyMeta meta in objectDef.PropertyContainer)
                {
                    if (Property2Value.ContainsKey(meta.PropertyName))
                    {
                        dr[meta.LangStr] = Property2Value[meta.PropertyName];
                    }

                    if (meta.LangStr.Contains("标段"))
                    {
                        if (Runtime.filtercontent != "All")
                        {
                            if (Runtime.filtercontent != dr[meta.LangStr].ToString())
                            {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag)
                {
                    dt.Rows.Add(dr);
                    currenttable_IDindex.Add((int)Property2Value["ID"]);
                }
            }
            return(dt);
        }
 public bool Export(StageDef domain, string path = null)
 {
     this.domain = domain;
     this.path   = path ?? this.path;
     return(Export());
 }
示例#19
0
 public bool Export(StageDef domain, string path = null)
 {
     throw new NotImplementedException();
 }
示例#20
0
        //主要功能是实现数据的比对、数据文件的备份、新的数据模板的生成
        //manin function is to compare data and select the new data
        public DataSet UpdateData(StageDef stage)
        {
            TableComparator comparator = new TableComparator(null, null, null);

            return(null);
        }