Ejemplo n.º 1
0
        private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            CommunityModel oldModel = latestData.Item3;

            switch (e.PropertyName)
            {
            case nameof(CommunityViewModel.Name):
                string newNamespace = latestData.Item1.Name == "<Root>" ? string.Empty : latestData.Item1.Name;
                OnMessage(new ModificationRequest(
                              latestData.Item2, new Modification(ModificationType.Change,
                                                                 oldModel.GeneratorSettings.PackageNamespace,
                                                                 newNamespace,
                                                                 oldModel.GeneratorSettings,
                                                                 new GeneratorSettingsPackageNamespaceProperty())));
                break;

            case nameof(CommunityViewModel.GenerateAutofacModule):
                OnMessage(new ModificationRequest(
                              latestData.Item2, new Modification(ModificationType.Change,
                                                                 oldModel.GeneratorSettings.GenerateAutofacModule,
                                                                 latestData.Item1.GenerateAutofacModule,
                                                                 oldModel.GeneratorSettings,
                                                                 new GeneratorSettingsGenerateAutofacProperty())));
                break;
            }
        }
Ejemplo n.º 2
0
        private void OnMessagesCollected(MessageCollection <SelectedModelObjectChanged, DeleteItemRequested> set)
        {
            set.MarkAsConsumed(set.Message2);
            CommunityModel    model    = null;
            PropertySpecifier property = null;

            if (set.Message1.SelectedObject is AgentModel agent)
            {
                model    = agent.ContainingPackage;
                property = new PackageAgentsProperty();
            }
            else if (set.Message1.SelectedObject is MessageModel message)
            {
                model    = message.ContainingPackage;
                property = new PackageMessagesProperty();
            }

            if (model != null)
            {
                OnMessage(new ModificationRequest(set, new Modification(ModificationType.Remove,
                                                                        set.Message1.SelectedObject,
                                                                        null,
                                                                        model,
                                                                        property)));
            }
        }
Ejemplo n.º 3
0
        protected override void ExecuteCore(Message messageData)
        {
            ModifyModel modifyModel = messageData.Get <ModifyModel>(); if (modifyModel.Modification.Target is not CommunityModel)
            {
                return;
            }

            CommunityModel model = modifyModel.CurrentVersion;

            CommunityModel updatedModel;

            switch (modifyModel.Modification.Property)
            {
            case PackageMessagesProperty _:
                updatedModel = UpdateMessage(modifyModel.Modification.OldValue.AssertTypeOf <MessageModel>(),
                                             modifyModel.Modification.NewValue.AssertTypeOf <MessageModel>(),
                                             modifyModel.Modification.ModificationType,
                                             model);
                break;

            case PackageAgentsProperty _:
                updatedModel = UpdateAgent(modifyModel.Modification.OldValue.AssertTypeOf <AgentModel>(),
                                           modifyModel.Modification.NewValue.AssertTypeOf <AgentModel>(),
                                           modifyModel.Modification.ModificationType,
                                           model);
                break;

            default:
                throw new InvalidOperationException($"Property {modifyModel.Modification.Property} unknown for model.");
            }
            OnMessage(new ModificationResult(updatedModel, messageData));
        }
Ejemplo n.º 4
0
        public Task DeleteCommunity(CommunityModel communityDel)
        {
            string sql = @"delete from CommunityTable where Id = @Id ;";

            //string sql = @"delete from dbo.CommunityTable where Id = @Id ;";
            return(_db.SaveData(sql, communityDel));
        }
Ejemplo n.º 5
0
        public Task UpdateCommunity(CommunityModel communityUp)
        {
            string sql = @"Update CommunityTable set Title=@Title, Text=@Text, EmailAddress=@EmailAddress where Id = @Id ;";

            //string sql = @"Update dbo.CommunityTable set Title = @Title, Text =@Text, EmailAddress = @EmailAddress where Id = @Id ;";
            return(_db.SaveData(sql, communityUp));
        }
Ejemplo n.º 6
0
 public ModifyModel(Message predecessorMessage, Modification modification, bool isLast,
                    CommunityModel currentVersion)
     : base(predecessorMessage)
 {
     Modification   = modification;
     IsLast         = isLast;
     CurrentVersion = currentVersion;
 }
        public async Task <ActionResult> Post([FromBody] CommunityModel board)
        {
            board.reg_dt = DateTime.Now;
            board.upd_dt = DateTime.Now;
            await _community.Add(board);

            return(Ok());
        }
Ejemplo n.º 8
0
 public ModifyModel(IEnumerable <Message> predecessorMessages, Modification modification, bool isLast,
                    CommunityModel currentVersion)
     : base(predecessorMessages)
 {
     Modification   = modification;
     IsLast         = isLast;
     CurrentVersion = currentVersion;
 }
        public async Task <ActionResult> Put(int seq, [FromBody] CommunityModel board)
        {
            board.upd_dt    = DateTime.Now;
            board.board_seq = seq;
            await _community.Update(board);

            return(Ok());
        }
Ejemplo n.º 10
0
        public Task InsertCommunity(CommunityModel community)
        {
            string sql = @"insert into CommunityTable (Name, Title, Text, EmailAddress)
values (@Name, @Title, @Text, @EmailAddress);";

            //string sql = @"insert into dbo.CommunityTable (Name, Title, Text, EmailAddress)
//values (@Name, @Title, @Text, @EmailAddress);";
            return(_db.SaveData(sql, community));
        }
 public async Task Update(CommunityModel communityModel)
 {
     _context.Entry(communityModel).Property(x => x.category).IsModified = true;
     _context.Entry(communityModel).Property(x => x.title).IsModified    = true;
     _context.Entry(communityModel).Property(x => x.content).IsModified  = true;
     _context.Entry(communityModel).Property(x => x.upd_dt).IsModified   = true;
     _context.Entry(communityModel).Property(x => x.upd_user).IsModified = true;
     await _context.SaveChangesAsync();
 }
        public async Task <ActionResult> Delete(int seq)
        {
            CommunityModel board = new CommunityModel
            {
                board_seq = seq
            };
            await _community.Delete(board);

            return(Ok());
        }
Ejemplo n.º 13
0
        public CommunityModelSerializer()
        {
            Directory.CreateDirectory(dir + "/data");
            Directory.CreateDirectory(dir + "/data/communityposts");
            Directory.CreateDirectory(dir + "/data/userposts");

            model       = CommunityModel.GetInstance();
            Users       = new HashMap <string, User>();
            Communities = new HashMap <string, Community>();
            Posts       = new HashMap <int, UserPost>();
        }
Ejemplo n.º 14
0
 public bool editCommunity(CommunityModel obj)
 {
     try
     {
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Create a community
        /// </summary>
        /// <param name="communityName">Community name</param>
        /// <param name="communityShortName">Short name of the community</param>
        /// <param name="description">Description of the community</param>
        /// <param name="tagList">Tags of the community</param>
        /// <param name="type">Type of the community</param>
        /// <param name="accessType">Access type of the community</param>
        /// <param name="parentCommunityShortName">Parent community short name of the community</param>
        /// <param name="administratorUserId">Admin ID of the community</param>
        /// <param name="organizationShortName">Admin organization short name of the community</param>
        /// <param name="logo">Logo of the community</param>
        public void CreateCommunity(string communityName, string communityShortName, string description, List <string> tagList, short type, short accessType, string parentCommunityShortName, Guid administratorUserId, string organizationShortName, byte[] logo = null)
        {
            string tags = StringHelper.UrlEncoderUTF8(string.Join(",", tagList));

            CommunityModel community = new CommunityModel()
            {
                community_name = communityName, community_short_name = communityShortName, description = description, tags = tags, type = type, access_type = accessType, parent_community_short_name = parentCommunityShortName, admin_id = administratorUserId, organization_short_name = organizationShortName, logo = logo
            };

            CreateCommunity(community);
        }
Ejemplo n.º 16
0
        public static string GetUrlLogout(this HtmlHelper helper)
        {
            CommunityModel comunidad       = helper.GetComunidad();
            string         linkDesconectar = string.Concat(comunidad.Url, "/", helper.GetUtilIdiomas().GetText("URLSEM", "DESCONECTAR"));

            if (comunidad != null)//todo
            {
                linkDesconectar += "/redirect/" + helper.GetUtilIdiomas().GetText("URLSEM", "COMUNIDAD") + "/" + comunidad.ShortName;
            }

            return(linkDesconectar);
        }
        protected override void ExecuteCore(Message messageData)
        {
            ModifyModel    modifyModel = messageData.Get <ModifyModel>();
            CommunityModel model       = modifyModel.CurrentVersion;

            if (modifyModel.Modification.Target is not MessageModel messageModel)
            {
                return;
            }

            MessageModel updatedModel;

            switch (modifyModel.Modification.Property)
            {
            case MessageNameProperty _:
                updatedModel = messageModel.Clone(name: modifyModel.Modification.NewValue.AssertTypeOf <string>());
                break;

            case MessageNamespaceProperty _:
                updatedModel = messageModel.Clone(@namespace: modifyModel.Modification.NewValue.AssertTypeOf <string>());
                break;

            case MessageDecoratorDecoratedMessageProperty _:
                MessageDecoratorModel decoratorModel = (MessageDecoratorModel)messageModel;
                updatedModel = decoratorModel.Clone(modifyModel.Modification.NewValue.AssertTypeOf <Guid>());
                break;

            default:
                throw new InvalidOperationException($"Property {modifyModel.Modification.Property} unknown for agent model.");
            }

            CommunityModel updatedCommunity = new(model.GeneratorSettings,
                                                  model.Agents,
                                                  ReplaceMessage());

            OnMessage(new ModificationResult(updatedCommunity, messageData));

            MessageModel[] ReplaceMessage()
            {
                MessageModel[] messages = new MessageModel[model.Messages.Length];
                Array.Copy(model.Messages, messages, messages.Length);
                int messageIndex = Array.IndexOf(messages, messageModel);

                if (messageIndex < 0)
                {
                    throw new InvalidOperationException("Could not find agent model in community.");
                }

                messages[messageIndex] = updatedModel;
                return(messages);
            }
        }
Ejemplo n.º 18
0
 public IActionResult addComms(CommunityModel obj)
 {
     try
     {
         _commRes.addCommunity(obj);
         _commRes.saveCommunity();
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
Ejemplo n.º 19
0
        //입력
        public CommunityModel Add(CommunityModel community)
        {
            var sql = @"
                Insert Into Communities(CommunityName, CommunityDescription, MeaderHtnl, FooterHtnl) Values(@CommunityName, @CommunityDescription, @MeaderHtnl, @FooterHtnl);
                Select Cast(SCOPE_IDENTITY() As Int);
            ";

            var id = ctx.Query <int>(sql, community).Single();

            community.CommunityId = id;

            return(community);
        }
Ejemplo n.º 20
0
        private void OnMessagesCollected(MessageCollection <ModelLoaded, TreeViewModelCreated> set)
        {
            TreeViewModel      viewModel    = set.Message2.ViewModel;
            CommunityViewModel newCommunity = GenerateCommunityViewModel();

            viewModel.Community = newCommunity;
            OnMessage(new TreeViewModelUpdated(set));

            CommunityViewModel GenerateCommunityViewModel()
            {
                CommunityModel     model         = set.Message1.Model;
                string             rootNamespace = model.GeneratorSettings.PackageNamespace;
                CommunityViewModel root          = new()
                {
                    Name = string.IsNullOrEmpty(rootNamespace)?"<Root>":rootNamespace,
                    GenerateAutofacModule = model.GeneratorSettings.GenerateAutofacModule
                };

                if (!string.IsNullOrEmpty(rootNamespace))
                {
                    FolderViewModel folder = new()
                    {
                        Name           = rootNamespace,
                        IsRelativeRoot = true
                    };
                    root.Items.Add(folder);
                }

                AvailableItemsViewModel availableViewModel = new();

                foreach (MessageModel message in model.Messages)
                {
                    MessageViewModel messageViewModel = message.CreateViewModel(availableViewModel);
                    root.AddItem(messageViewModel);
                    availableViewModel.AvailableMessages.Add(messageViewModel);
                }

                foreach (AgentModel agent in model.Agents)
                {
                    AgentViewModel agentViewModel = agent.CreateViewModel(availableViewModel);
                    root.AddItem(agentViewModel);
                    availableViewModel.AvailableAgents.Add(agentViewModel);
                }

                return(root);
            }
        }

        protected override void ExecuteCore(Message messageData)
Ejemplo n.º 21
0
        public static string ObtenerUrlDeDoc(this HtmlHelper helper, Guid idDocumento, string pNombreDocumento)
        {
            CommunityModel   Comunidad = helper.ViewBag.Comunidad;
            UserProfileModel Perfil    = helper.ViewBag.Perfil;
            string           urlPerfil = null;

            if (Perfil != null)
            {
                urlPerfil = Perfil.Url;
            }

            //return GnossUrlsSemanticas.GetURLBaseRecursosFichaConIDs(helper.ViewBag.BaseUrlIdioma, helper.ViewBag.UtilIdiomas, Comunidad.ShortName, urlPerfil, Es.Riam.Util.UtilCadenas.EliminarCaracteresUrlSem(pNombreDocumento), idDocumento, null, false);
            return(pNombreDocumento);
            //todo juan
        }
Ejemplo n.º 22
0
        //수정
        public CommunityModel Update(CommunityModel community)
        {
            var sql = @"
                Update Communities
                Set
                   CommunityName = @CommunityName,
                   CommunityDescription = @CommunityDescription,
                   MeaderHtnl = @MeaderHtnl,
                   FooterHtnl = @FooterHtnl
               Where
                   CommunityId = @CommunityId;
               ";

            this.ctx.Execute(sql, community);

            return(community);
        }
Ejemplo n.º 23
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //커뮤니티 개체 가져오기
            var community = new CommunityModel();

            // Prouctivity Power Tools 2017 설치 후 Ctrl + Alt + ]
            community.CommunityName        = txtCommunityName.Value;
            community.CommunityDescription = txtCommunityDescription.Value;
            community.MeaderHtnl           = txtMeaderHtnl.Value;
            community.FooterHtnl           = txtFooterHtnl.Value;

            //저장소 클래스 가져오기
            var addRepo = new CommnityRepository();

            community = addRepo.Add(community);

            lblDisplay.Text = String.Format("{0}번 글이 저장되었습니다.", community.CommunityId);
        }
Ejemplo n.º 24
0
        protected override InterceptionAction InterceptCore(Message messageData)
        {
            CommunityModel model = messageData.TryGet(out ModificationResult result)
                                       ? result.Model
                                       : messageData.Get <ModelLoaded>().Model;

            foreach (AgentModel agent in model.Agents)
            {
                agent.ContainingPackage = model;
            }

            foreach (MessageModel message in model.Messages)
            {
                message.ContainingPackage = model;
            }

            return(InterceptionAction.Continue);
        }
Ejemplo n.º 25
0
 public bool EditCommunity(CommunityModel resource)
 {
     try {
         var oldresource = new Community {
             Name        = resource.Name,
             Description = resource.Description,
             URL         = resource.URL,
             ImageURL    = resource.ImageURL
         };
         _communityRepo.Update(oldresource);
         _logger.LogInformation("Updating community -  {}", resource.Name);
         return(true);
     } catch (System.Exception) {
         // TODO: Error
         _logger.LogWarning("Unable to update {}. ", resource.Name);
         return(false);
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Create a community
        /// </summary>
        /// <param name="communityModel">Community model</param>
        public void CreateCommunity(CommunityModel communityModel)
        {
            string json = null;

            try
            {
                string url = $"{ApiUrl}/community/create-community";

                WebRequestPostWithJsonObject(url, communityModel);

                Log.Debug($"Community created {json}");
            }
            catch (Exception ex)
            {
                Log.Error($"Error creating community {json}: \r\n{ex.Message}");
                throw;
            }
        }
Ejemplo n.º 27
0
 public bool AddCommunity(CommunityModel resource)
 {
     try {
         var newresource = new Community {
             Id          = resource.Id,
             Name        = resource.Name,
             Description = resource.Description,
             URL         = resource.URL,
             ImageURL    = resource.ImageURL
         };
         _logger.LogInformation("Inserting new community -  {}", resource.Name);
         _communityRepo.Insert(newresource);
         return(true);
     } catch (System.Exception) {
         // TODO : Log error
         _logger.LogWarning("Unable to insert {}. ", resource.Name);
         return(false);
     }
 }
Ejemplo n.º 28
0
        public static MvcHtmlString PartialView(this HtmlHelper htmlHelper, string partialViewName, object model, ViewDataDictionary diccionario)
        {
            MvcHtmlString resultado = null;

            UtilTrazas.AgregarEntrada("HtmlHelpers.PartialView 3");
            CommunityModel Comunidad = htmlHelper.ViewBag.Comunidad;

            string rutaVistasPersonalizadas = htmlHelper.ViewBag.rutaVistasPersonalizadas;

            if (!System.IO.File.Exists(AppContext.BaseDirectory + partialViewName.Replace("~/", "")))
            {
                partialViewName = partialViewName.Replace($"/{rutaVistasPersonalizadas}/", "/GenericViews/");
            }
            // todo
            resultado = System.Web.Mvc.Html.PartialExtensions.Partial(htmlHelper, partialViewName, model, diccionario);

            UtilTrazas.AgregarEntrada("Fin HtmlHelpers.PartialView 3");
            return(resultado);
        }
        private void OnMessagesCollected(MessageCollection <TreeViewModelCreated, ModificationResult> set)
        {
            set.MarkAsConsumed(set.Message2);
            CommunityModel oldModel = Interlocked.Exchange(ref lastModel, set.Message2.Model);

            if (oldModel == null)
            {
                return;
            }

            AgentModel[]   newAgents   = set.Message2.Model.Agents.Except(oldModel.Agents).ToArray();
            MessageModel[] newMessages = set.Message2.Model.Messages.Except(oldModel.Messages).ToArray();

            Stack <TreeViewItem> unvisited = new Stack <TreeViewItem>(new [] { set.Message1.ViewModel.Community });

            while (unvisited.Any())
            {
                TreeViewItem item = unvisited.Pop();
                if (item is AgentViewModel agentViewModel &&
                    agentViewModel.ModelId == default)
                {
                    agentViewModel.ModelId =
                        newAgents.FirstOrDefault(a => a.FullName() == agentViewModel.FullName)
                        ?.Id ?? default;
                }
                if (item is MessageViewModel messageViewModel &&
                    messageViewModel.ModelId == default)
                {
                    messageViewModel.ModelId =
                        newMessages.FirstOrDefault(a => a.FullName() == messageViewModel.FullName)
                        ?.Id ?? default;
                }

                foreach (TreeViewItem child in item.Items)
                {
                    unvisited.Push(child);
                }
            }
        }
Ejemplo n.º 30
0
 public bool addCommunity(CommunityModel obj)
 {
     try
     {
         var o = new Community
         {
             Id          = obj.Id, // modify this later to adding new id in sql server
             user_code   = obj.user_code,
             image       = obj.image,
             title       = obj.title,
             desc        = obj.desc,
             url         = obj.url,
             enabled_flg = obj.enabled_flg
         };
         _communityRepo.insert(o);
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }