private void Button_Save(object sender, RoutedEventArgs e)
        {
            BotTemplate.containerID = this.SelectedInv.definition;
            BotTemplate.robotID     = this.SelectedBot.definition;
            BotTemplate.chassisID   = this.SelectedChassis.definition;
            BotTemplate.headID      = this.SelectedHead.definition;
            BotTemplate.legID       = this.SelectedLeg.definition;

            RTemplate.description = BotTemplate.ToGenXY();
            try
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(RTemplate.SaveNewBotTemplate());
                File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\" + RTemplate.name + Utilities.timestamp() + ".sql", sb.ToString());
                MessageBox.Show("New RobotTemplate Saved!!", "Info", 0, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Saving!" + ex.Message, "Error", 0, MessageBoxImage.Error);
                return;
            }

            this.DialogResult = true;
            this.Hide();
        }
예제 #2
0
 public Template(RTemplate rTemplate)
 {
     Id             = rTemplate.Id;
     TemplateName   = rTemplate.TemplateName;
     Thumbnail      = rTemplate.Thumbnail;
     Structure      = rTemplate.Structure;
     PathToView     = rTemplate.PathToView;
     Status         = rTemplate.Status;
     Code           = rTemplate.Code;
     PageType       = rTemplate.PageType;
     PageParameters = rTemplate.PageParameters;
     UpdatedDateUtc = rTemplate.UpdatedDateUtc;
     CreatedDateUtc = rTemplate.CreatedDateUtc;
     CreatedUid     = rTemplate.CreatedUid;
     UpdatedUid     = rTemplate.UpdatedUid;
 }
예제 #3
0
        public async Task <ICommandResult> Handle(TemplateConfigRemoveCommand message)
        {
            try
            {
                ICommandResult result;
                RTemplate      rTemplate = await _templateService.GetById(message.TemplateId);

                if (rTemplate == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Template not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Template_NotFound
                    };
                    return(result);
                }
                RTemplateConfig[] rTemplateConfigs = await _templateService.GetTemplateConfigByTemplateId(rTemplate.Id);

                Template       template       = new Template(rTemplate, rTemplateConfigs);
                TemplateConfig templateConfig = template.RemoveTemplateconfig(message);
                await _templateService.ChangeTemplateConfigStatus(templateConfig.Id, templateConfig.UpdatedUid,
                                                                  templateConfig.UpdatedDateUtc, templateConfig.Status);

                await _eventSender.Notify(template.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = rTemplate.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = message;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
예제 #4
0
        public async Task <ICommandResult> Handle(TemplateRemoveCommand message)
        {
            try
            {
                ICommandResult result;
                RTemplate      rTemplate = await _templateService.GetById(message.Id);

                if (rTemplate == null)
                {
                    result = new CommandResult()
                    {
                        Message      = "Template not found",
                        ObjectId     = "",
                        Status       = CommandResult.StatusEnum.Fail,
                        ResourceName = ResourceKey.Template_NotFound
                    };
                    return(result);
                }
                Template template = new Template(rTemplate);
                template.ChangeStatus(EnumDefine.CommonStatusEnum.Deleted, message.CreatedDateUtc, message.UserId);
                await _templateService.ChangeTemplateStatus(message.Id, message.UserId, message.CreatedDateUtc, EnumDefine.CommonStatusEnum.Deleted);

                await _eventSender.Notify(template.Events);

                result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = rTemplate.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = message;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
예제 #5
0
 public static TemplateViewModel ToModel(this RTemplate request)
 {
     if (request == null)
     {
         return(null);
     }
     return(new TemplateViewModel()
     {
         Id = request.Id,
         Code = request.Code,
         TemplateName = request.TemplateName,
         Thumbnail = string.Format("{0}{1}", ConfigSettingEnum.CdnDomain.GetConfig(), request.Thumbnail),
         PathToView = request.PathToView,
         Status = request.Status,
         Structure = request.Structure,
         PageType = request.PageType,
         PageParameters = request.PageParameters,
         Version = request.Version,
     });
 }
예제 #6
0
 public Template(RTemplate rTemplate, IList <RTemplateConfig> rTemplateConfigs) : this(rTemplate)
 {
     TemplateConfigs = rTemplateConfigs?.Select(p => new TemplateConfig(p)).ToList();
 }