Exemplo n.º 1
0
 /// <summary>
 /// 更新应用按钮
 /// </summary>
 /// <param name="appLibraryButton">应用按钮实体</param>
 public int Update(Model.AppLibraryButton appLibraryButton)
 {
     ClearCache();
     using (var db = new DataContext())
     {
         db.Update(appLibraryButton);
         return(db.SaveChanges());
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 发布一个程序设计
        /// </summary>
        /// <param name="id"></param>
        /// <param name="localizer">语言包</param>
        /// <returns></returns>
        public string Publish(Guid id, IStringLocalizer localizer = null)
        {
            string key = "ProgramRun_" + id.ToString("N");

            Cache.IO.Remove(key);
            Model.Program programModel = Get(id);
            if (null == programModel)
            {
                return(localizer == null ? "没有找到要发布的程序!" : localizer["NotFoundModel"]);
            }
            //更新状态
            programModel.Status = 1;
            Update(programModel);

            Model.ProgramRun programRunModel = GetRunModel(id);
            if (null == programRunModel)
            {
                return(localizer == null ? "没有找到要发布的程序!" : localizer["NotFoundModel"]);
            }

            #region 加入应用程序库
            AppLibrary appLibrary = new AppLibrary();
            var        appModel   = appLibrary.GetByCode(id.ToString());
            bool       isAdd      = false;
            if (null == appModel)
            {
                isAdd    = true;
                appModel = new Model.AppLibrary
                {
                    Id   = Guid.NewGuid(),
                    Code = id.ToString()
                };
            }
            appModel.Address  = "/RoadFlowCore/ProgramDesigner/Run?programid=" + id.ToString();
            appModel.OpenMode = 0;
            appModel.Title    = programRunModel.Name;
            appModel.Type     = programRunModel.Type;

            //多语言要写入不同语言的标题,这里只写一种
            appModel.Title_en = programRunModel.Name;
            appModel.Title_zh = programRunModel.Name;

            if (isAdd)
            {
                appLibrary.Add(appModel);
            }
            else
            {
                appLibrary.Update(appModel);
            }
            #endregion

            #region 加按钮到应用程序库
            AppLibraryButton appLibraryButton = new AppLibraryButton();
            var buttons        = appLibraryButton.GetListByApplibraryId(appModel.Id);
            var programButtons = new ProgramButton().GetAll(id);
            foreach (var button in programButtons)
            {
                var  model       = buttons.Find(p => p.Id == button.Id);
                bool isAddButton = false;
                if (null == model)
                {
                    isAddButton = true;
                    model       = new Model.AppLibraryButton
                    {
                        Id = button.Id
                    };
                }
                model.AppLibraryId   = appModel.Id;
                model.ButtonId       = button.ButtonId;
                model.Events         = button.ClientScript;
                model.Ico            = button.Ico;
                model.IsValidateShow = button.IsValidateShow;
                model.Name           = button.ButtonName;
                model.ShowType       = button.ShowType;
                model.Sort           = button.Sort;
                if (isAddButton)
                {
                    appLibraryButton.Add(model);
                }
                else
                {
                    appLibraryButton.Update(model);
                }
            }
            foreach (var button in buttons)
            {
                if (!programButtons.Exists(p => p.Id == button.Id))
                {
                    appLibraryButton.Delete(button.Id);
                }
            }
            #endregion
            return("1");
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新一个按钮
 /// </summary>
 /// <param name="appLibraryButton"></param>
 /// <returns></returns>
 public int Update(Model.AppLibraryButton appLibraryButton)
 {
     return(appLibraryButtonData.Update(appLibraryButton));
 }
Exemplo n.º 4
0
        public string SaveButton()
        {
            string buttonindex = Request.Forms("buttonindex");
            string id          = Request.Querys("id");

            Business.AppLibraryButton appLibraryButton = new Business.AppLibraryButton();
            var buttons = appLibraryButton.GetListByApplibraryId(id.ToGuid());
            List <Tuple <Model.AppLibraryButton, int> > tuples = new List <Tuple <Model.AppLibraryButton, int> >();

            foreach (var button in buttons)
            {
                if (!buttonindex.ContainsIgnoreCase(button.Id.ToString()))
                {
                    tuples.Add(new Tuple <Model.AppLibraryButton, int>(button, 0));
                }
            }

            foreach (string index in buttonindex.Split(','))
            {
                string button_       = Request.Forms("button_" + index);
                string buttonname_   = Request.Forms("buttonname_" + index);
                string buttonevents_ = Request.Forms("buttonevents_" + index);
                string buttonico_    = Request.Forms("buttonico_" + index);
                string showtype_     = Request.Forms("showtype_" + index);
                string buttonsort_   = Request.Forms("buttonsort_" + index);
                if (buttonname_.IsNullOrEmpty())
                {
                    continue;
                }
                if (index.IsGuid(out Guid indexId))
                {
                    var button = buttons.Find(p => p.Id == indexId);
                    if (null != button)
                    {
                        button.ButtonId       = button_.ToGuid();
                        button.AppLibraryId   = id.ToGuid();
                        button.Events         = buttonevents_;
                        button.Ico            = buttonico_;
                        button.IsValidateShow = 1;
                        button.Name           = buttonname_;
                        button.ShowType       = showtype_.ToInt(0);
                        button.Sort           = buttonsort_.ToInt(0);
                        tuples.Add(new Tuple <Model.AppLibraryButton, int>(button, 1));
                        continue;
                    }
                }

                var buttonModel = new Model.AppLibraryButton
                {
                    Id             = Guid.NewGuid(),
                    ButtonId       = button_.ToGuid(),
                    AppLibraryId   = id.ToGuid(),
                    Events         = buttonevents_,
                    Ico            = buttonico_,
                    IsValidateShow = 1,
                    Name           = buttonname_,
                    ShowType       = showtype_.ToInt(0),
                    Sort           = buttonsort_.ToInt(0)
                };
                tuples.Add(new Tuple <Model.AppLibraryButton, int>(buttonModel, 2));
            }
            int i = appLibraryButton.Update(tuples);

            Business.Log.Add("保存了应用程序库按钮-影响行数-" + i, Newtonsoft.Json.JsonConvert.SerializeObject(tuples), Business.Log.Type.系统管理);
            return("保存成功!");
        }
Exemplo n.º 5
0
 /// <summary>
 /// 添加一个程序按钮
 /// </summary>
 /// <param name="appLibraryButton"></param>
 /// <returns></returns>
 public int Add(Model.AppLibraryButton appLibraryButton)
 {
     return(appLibraryButtonData.Add(appLibraryButton));
 }