Beispiel #1
0
        public bool Publish(Guid id, bool isMvc = false)
        {
            RoadFlow.Data.Model.ProgramBuilder model1 = this.Get(id);
            if (model1 == null || model1.Name.IsNullOrEmpty() || model1.SQL.IsNullOrEmpty())
            {
                return(false);
            }
            AppLibrary appLibrary = new AppLibrary();

            RoadFlow.Data.Model.AppLibrary model2 = appLibrary.GetByCode(id.ToString(), true);
            bool flag1 = false;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                if (model2 == null)
                {
                    flag1     = true;
                    model2    = new RoadFlow.Data.Model.AppLibrary();
                    model2.ID = Guid.NewGuid();
                }
                model2.Address  = !isMvc ? "/Platform/ProgramBuilder/Run.aspx?programid=" + id.ToString() : "/ProgramBuilder/Run?programid=" + id.ToString();
                model2.Code     = id.ToString();
                model2.OpenMode = 0;
                model2.Title    = model1.Name;
                model2.Type     = model1.Type;
                if (flag1)
                {
                    appLibrary.Add(model2);
                }
                else
                {
                    appLibrary.Update(model2);
                }
                model1.Status = 1;
                this.Update(model1);
                List <RoadFlow.Data.Model.ProgramBuilderButtons> all = new ProgramBuilderButtons().GetAll(model1.ID);
                AppLibraryButtons1 appLibraryButtons1_1 = new AppLibraryButtons1();
                List <RoadFlow.Data.Model.AppLibraryButtons1> allByAppId             = appLibraryButtons1_1.GetAllByAppID(model2.ID);
                List <RoadFlow.Data.Model.AppLibraryButtons1> appLibraryButtons1List = new List <RoadFlow.Data.Model.AppLibraryButtons1>();
                foreach (RoadFlow.Data.Model.ProgramBuilderButtons programBuilderButtons in all)
                {
                    RoadFlow.Data.Model.ProgramBuilderButtons button = programBuilderButtons;
                    RoadFlow.Data.Model.AppLibraryButtons1    model3 = allByAppId.Find((Predicate <RoadFlow.Data.Model.AppLibraryButtons1>)(p => p.ID == button.ID));
                    bool flag2 = false;
                    if (model3 == null)
                    {
                        model3 = new RoadFlow.Data.Model.AppLibraryButtons1();
                        flag2  = true;
                    }
                    model3.AppLibraryID   = model2.ID;
                    model3.ButtonID       = button.ButtonID;
                    model3.Events         = button.ClientScript;
                    model3.Ico            = button.Ico ?? "";
                    model3.ID             = button.ID;
                    model3.Name           = button.ButtonName;
                    model3.ShowType       = button.ShowType;
                    model3.Sort           = button.Sort;
                    model3.Type           = 0;
                    model3.IsValidateShow = button.IsValidateShow;
                    if (flag2)
                    {
                        appLibraryButtons1_1.Add(model3);
                    }
                    else
                    {
                        appLibraryButtons1_1.Update(model3);
                    }
                    appLibraryButtons1List.Add(model3);
                }
                foreach (RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons1_2 in allByAppId)
                {
                    RoadFlow.Data.Model.AppLibraryButtons1 button = appLibraryButtons1_2;
                    if (appLibraryButtons1List.Find((Predicate <RoadFlow.Data.Model.AppLibraryButtons1>)(p => p.ID == button.ID)) == null)
                    {
                        appLibraryButtons1_1.Delete(button.ID);
                    }
                }
                transactionScope.Complete();
            }
            new AppLibrary().ClearCache();
            new Menu().ClearAllDataTableCache();
            new AppLibraryButtons1().ClearCache();
            new AppLibrarySubPages().ClearCache();
            this.AddToCache(new ProgramBuilderCache()
            {
                Program   = model1,
                Fields    = new ProgramBuilderFields().GetAll(model1.ID).OrderBy <RoadFlow.Data.Model.ProgramBuilderFields, int>((Func <RoadFlow.Data.Model.ProgramBuilderFields, int>)(p => p.Sort)).ToList <RoadFlow.Data.Model.ProgramBuilderFields>(),
                Querys    = new ProgramBuilderQuerys().GetAll(model1.ID).OrderBy <RoadFlow.Data.Model.ProgramBuilderQuerys, int>((Func <RoadFlow.Data.Model.ProgramBuilderQuerys, int>)(p => p.Sort)).ToList <RoadFlow.Data.Model.ProgramBuilderQuerys>(),
                Buttons   = new ProgramBuilderButtons().GetAll(id).OrderBy <RoadFlow.Data.Model.ProgramBuilderButtons, int>((Func <RoadFlow.Data.Model.ProgramBuilderButtons, int>)(p => p.Sort)).ToList <RoadFlow.Data.Model.ProgramBuilderButtons>(),
                Validates = new ProgramBuilderValidates().GetAll(id),
                Export    = new ProgramBuilderExport().GetAll(id).OrderBy <RoadFlow.Data.Model.ProgramBuilderExport, int>((Func <RoadFlow.Data.Model.ProgramBuilderExport, int>)(p => p.Sort)).ToList <RoadFlow.Data.Model.ProgramBuilderExport>()
            });
            return(true);
        }
Beispiel #2
0
        public bool Publish(Guid id, bool isMvc = false)
        {
            RoadFlow.Data.Model.ProgramBuilder programBuilder = Get(id);
            if (programBuilder == null || programBuilder.Name.IsNullOrEmpty() || programBuilder.SQL.IsNullOrEmpty())
            {
                return(false);
            }
            AppLibrary appLibrary = new AppLibrary();

            RoadFlow.Data.Model.AppLibrary appLibrary2 = appLibrary.GetByCode(id.ToString());
            bool flag = false;

            using (TransactionScope transactionScope = new TransactionScope())
            {
                if (appLibrary2 == null)
                {
                    flag           = true;
                    appLibrary2    = new RoadFlow.Data.Model.AppLibrary();
                    appLibrary2.ID = Guid.NewGuid();
                }
                appLibrary2.Address  = ((!isMvc) ? ("/Platform/ProgramBuilder/Run.aspx?programid=" + id.ToString()) : ("/ProgramBuilder/Run?programid=" + id.ToString()));
                appLibrary2.Code     = id.ToString();
                appLibrary2.OpenMode = 0;
                appLibrary2.Title    = programBuilder.Name;
                appLibrary2.Type     = programBuilder.Type;
                if (flag)
                {
                    appLibrary.Add(appLibrary2);
                }
                else
                {
                    appLibrary.Update(appLibrary2);
                }
                programBuilder.Status = 1;
                Update(programBuilder);
                List <RoadFlow.Data.Model.ProgramBuilderButtons> all = new ProgramBuilderButtons().GetAll(programBuilder.ID);
                AppLibraryButtons1 appLibraryButtons = new AppLibraryButtons1();
                List <RoadFlow.Data.Model.AppLibraryButtons1> allByAppID = appLibraryButtons.GetAllByAppID(appLibrary2.ID);
                List <RoadFlow.Data.Model.AppLibraryButtons1> list       = new List <RoadFlow.Data.Model.AppLibraryButtons1>();
                foreach (RoadFlow.Data.Model.ProgramBuilderButtons item in all)
                {
                    RoadFlow.Data.Model.AppLibraryButtons1 appLibraryButtons2 = allByAppID.Find((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.ID == item.ID);
                    bool flag2 = false;
                    if (appLibraryButtons2 == null)
                    {
                        appLibraryButtons2 = new RoadFlow.Data.Model.AppLibraryButtons1();
                        flag2 = true;
                    }
                    appLibraryButtons2.AppLibraryID   = appLibrary2.ID;
                    appLibraryButtons2.ButtonID       = item.ButtonID;
                    appLibraryButtons2.Events         = item.ClientScript;
                    appLibraryButtons2.Ico            = (item.Ico ?? "");
                    appLibraryButtons2.ID             = item.ID;
                    appLibraryButtons2.Name           = item.ButtonName;
                    appLibraryButtons2.ShowType       = item.ShowType;
                    appLibraryButtons2.Sort           = item.Sort;
                    appLibraryButtons2.Type           = 0;
                    appLibraryButtons2.IsValidateShow = item.IsValidateShow;
                    if (flag2)
                    {
                        appLibraryButtons.Add(appLibraryButtons2);
                    }
                    else
                    {
                        appLibraryButtons.Update(appLibraryButtons2);
                    }
                    list.Add(appLibraryButtons2);
                }
                foreach (RoadFlow.Data.Model.AppLibraryButtons1 item2 in allByAppID)
                {
                    if (list.Find((RoadFlow.Data.Model.AppLibraryButtons1 p) => p.ID == item2.ID) == null)
                    {
                        appLibraryButtons.Delete(item2.ID);
                    }
                }
                transactionScope.Complete();
            }
            new AppLibrary().ClearCache();
            new Menu().ClearAllDataTableCache();
            new AppLibraryButtons1().ClearCache();
            new AppLibrarySubPages().ClearCache();
            ProgramBuilderCache programBuilderCache = new ProgramBuilderCache();

            programBuilderCache.Program = programBuilder;
            programBuilderCache.Fields  = (from p in new ProgramBuilderFields().GetAll(programBuilder.ID)
                                           orderby p.Sort
                                           select p).ToList();
            programBuilderCache.Querys = (from p in new ProgramBuilderQuerys().GetAll(programBuilder.ID)
                                          orderby p.Sort
                                          select p).ToList();
            programBuilderCache.Buttons = (from p in new ProgramBuilderButtons().GetAll(id)
                                           orderby p.Sort
                                           select p).ToList();
            programBuilderCache.Validates = new ProgramBuilderValidates().GetAll(id);
            programBuilderCache.Export    = (from p in new ProgramBuilderExport().GetAll(id)
                                             orderby p.Sort
                                             select p).ToList();
            AddToCache(programBuilderCache);
            return(true);
        }