コード例 #1
0
        public CommandResult Delete(TASheetGroup info)
        {
            TASheetSearchCondition con = new TASheetSearchCondition();

            con.SheetID = info.SheetID;
            ITASheetProvider provider = ProviderFactory.Create <ITASheetProvider>(_RepoUri);
            IUnitWork        unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);
            List <TASheet>   items    = provider.GetItems(con).QueryObjects;

            foreach (TASheet item in items)
            {
                provider.Delete(item);
            }
            return(unitWork.Commit());
        }
コード例 #2
0
        public CommandResult Save(TASheetGroup info)
        {
            string           id       = null;
            ITASheetProvider provider = ProviderFactory.Create <ITASheetProvider>(_RepoUri);
            IUnitWork        unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            if (!string.IsNullOrEmpty(info.SheetID))
            {
                TASheetSearchCondition con = new TASheetSearchCondition();
                con.SheetID = info.SheetID;
                List <TASheet> items = provider.GetItems(con).QueryObjects;
                foreach (TASheet item in items)
                {
                    provider.Delete(item);
                }
                id = info.SheetID;
            }
            else
            {
                id = ProviderFactory.Create <IStringIDCreater>(_RepoUri).CreateID("SH", 4, "TASheet");
                if (string.IsNullOrEmpty(id))
                {
                    return(new CommandResult(ResultCode.Fail, "创建ID失败"));
                }
                info.SheetID = id;
            }
            if (info.Items != null && info.Items.Count > 0)
            {
                info.Items.ForEach(it => it.SheetID = id);
            }
            List <TASheet> sheets = TASheetGroup.UnGroup(info);

            foreach (TASheet sheet in sheets)
            {
                provider.Insert(sheet, unitWork);
            }
            return(unitWork.Commit());
        }