コード例 #1
0
ファイル: Facade.cs プロジェクト: vlong638/VL.Business
        public static BLLResult CreateDetail(TList list, TDetail detail, List <TNode> nodes)
        {
            var result = new BLLResult();

            using (var connection = SQLiteHelper.Connect())
            {
                connection.Open();
                var transaction = connection.BeginTransaction();
                try
                {
                    list.DataCount = (short)list.Datas.Count;
                    if (!list.DbInsertOrReplace(connection))
                    {
                        throw new NotImplementedException("List数据未按预期存储");
                    }
                    if (!detail.DbInsert(connection))
                    {
                        throw new NotImplementedException("Detail数据未按预期存储");
                    }
                    //nodes.DbDeleteByDetailKey(connection);//由于提交时,Nodes数量发生了变更,这里省略对原有Nodes数量删除的监测
                    if (!nodes.DbInsert(connection))
                    {
                        throw new NotImplementedException("Nodes数据未按预期存储");
                    }
                    //0711TODO KO 更新TNodeElement
                    if (!nodes.Select(c => new TNodeElement(c.Segregation, c.NodeCode)
                    {
                        ElementIds = c.GetElementIds()
                    }).DbInsertOrReplace(connection))
                    {
                        throw new NotImplementedException("NodeElements数据未按预期存储");
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    list.DataCount--;
                    transaction.Rollback();
                    result.IsSuccess = false;
                    result.Message   = ex.ToString();
                    if (result.Message.Contains("constraint failed") && result.Message.Contains("TNode"))
                    {
                        result.Message = "导入的内容存在冲突,存在重复的测点";
                    }
                }
                connection.Close();
            }
            return(result);
        }
コード例 #2
0
        public static BLLResult CreateDetail(TList list, TDetail detail, List <TDepthNode> nodes)
        {
            var result = new BLLResult();

            using (var connection = SQLiteHelper.Connect())
            {
                connection.Open();
                var transaction = connection.BeginTransaction();
                try
                {
                    list.DataCount = (short)list.Datas.Count;
                    if (!list.DbInsertOrReplace(connection))
                    {
                        throw new NotImplementedException("List数据未按预期存储");
                    }
                    if (!detail.DbInsert(connection))
                    {
                        throw new NotImplementedException("Detail数据未按预期存储");
                    }
                    //nodes.DbDeleteByDetailKey(connection);//由于提交时,Nodes数量发生了变更,这里省略对原有Nodes数量删除的监测
                    if (!nodes.DbInsert(connection))
                    {
                        throw new NotImplementedException("Nodes数据未按预期存储");
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    result.IsSuccess = false;
                    result.Message   = ex.ToString();
                }
                connection.Close();
            }
            return(result);
        }