示例#1
0
        private void renderTemplate()
        {
            SimpleTemplate t1 = TemplateFactory.GetTemplate <SimpleTemplate>("controller1");

            tp_controller1.Text = args["modelName"] + "Controller";
            src_c1.Text         = t1.Render(args);

            SimpleTemplate t2 = TemplateFactory.GetTemplate <SimpleTemplate>("controller2");

            tp_controller2.Text = args["modelName"] + "QueryController";
            src_c2.Text         = t2.Render(args);

            SimpleTemplate t3 = TemplateFactory.GetTemplate <SimpleTemplate>("service");

            tp_service1.Text = args["modelName"] + "Service";
            src_s1.Text      = t2.Render(args);

            SimpleTemplate t4 = TemplateFactory.GetTemplate <SimpleTemplate>("query");

            tp_service2.Text = args["modelName"] + "Query";
            src_s2.Text      = t2.Render(args);

            LoopTemplate lt = TemplateFactory.GetTemplate <LoopTemplate>("domain");

            tp_domain.Text = args["modelName"] + "";
            src_do.Text    = lt.Render(args);
        }
示例#2
0
        public void Start(HttpServer server, SimpleJsonListener json, SimpleTemplate templateDemo)
        {
            _ws           = server;
            _json         = json;
            _templateDemo = templateDemo;

            _ws.AddPath("/demoLED.html", ProcessDemoLED);

            _LEDControl.LoadString(_ws.HttpRootManager.ReadToByte(_privatePath + "/templateLED.html"));
            _LEDControl["ledOn"] = new TemplateAction()
            {
                Pattern = "LEDON"
            };
            _LEDControl["ledOff"] = new TemplateAction()
            {
                Pattern = "LEDOFF"
            };

            _templateDemo["maualLed"] = new TemplateAction()
            {
                Pattern = "MANUALLED", Data = "Off"
            };

            _ws.HttpRootManager.AddExtensionTemplateData("shtml", "manualLed", new TemplateAction()
            {
                Pattern = "MANUALLED", Data = "Off"
            });

            _json.AddData("MaualLed", "Off");

            //_ports._debug = true;
        }
示例#3
0
        /// <summary>
        /// Binds the template.
        /// </summary>
        /// <param name="grid">The grid.</param>
        /// <param name="module">The module.</param>
        /// <param name="column">The column.</param>
        private void BindTemplate(Grid grid, ModuleConfig module, ViewColumn column)
        {
            if (column.Template == null)
            {
                return;
            }

            // Remove any template with the same name
            //foreach (GridServerTemplate existingTemplate in grid.ServerTemplates)
            for (int index = 0; index < grid.ServerTemplates.Count; index++)
            {
                if (String.Compare(grid.ServerTemplates[index].ID, column.Template.TemplateId, true) == 0)
                {
                    grid.ServerTemplates.RemoveAt(index);
                }
            }

            string    url      = String.Empty;
            ITemplate template = new SimpleTemplate((UserControl)grid.Parent, module.Name, column.Template);

            // Add server template to grid
            ComponentArt.Web.UI.GridServerTemplate gst = new ComponentArt.Web.UI.GridServerTemplate();
            gst.Template = (ITemplate)template;

            gst.ID = column.Template.TemplateId;

            BindColumnTemplateProperties(gst.Template, column.Template);
            grid.ServerTemplates.Add(gst);
            grid.Controls.Add(gst);
        }
示例#4
0
        public IActionResult Post([FromBody] Configuration config)
        {
            var template = new SimpleTemplate(config.Body, config.HttpCode);

            _router.AddTemplate(config.Path, config.Method, template, config.SequenceSuccessor);

            return(Ok());
        }
示例#5
0
        protected SimpleTemplate GetTemplate(string content, string className)
        {
            var conventions = Options.Do.Conventions;
            var template    = new SimpleTemplate(content);

            template["opt"]         = Options.Do;
            template["classname"]   = className;
            template["classname_2"] = conventions.Pluralize(className);
            return(template);
        }
示例#6
0
 public void Start(HttpServer server, SimpleTemplate template)
 {
     _ws           = server;
     _templateDemo = template;
     _ws.AddPath("/template.html", VrniTemplate);
     _templateDemo.LoadString(_ws.HttpRootManager.ReadToByte(_privatePath + "/templateDemo.html"));
     _templateDemo["userName"] = new TemplateAction()
     {
         Pattern = "USERNAME"
     };
 }
示例#7
0
        public TemplateListPage()
        {
            this.Title = "Workout Creator";
			_viewModel = new SimpleTemplate ();
			//Sync templates with the server
			Manager.Instance.WorkoutTemplate.LoadTemplates (App.WorkoutCreatorContext.StaffMember.GymID);

			var templatesTask = _viewModel.GetSimpleTemplateGroups (App.WorkoutCreatorContext.StaffMember.GymID);

			ListView listView = new ListView
			{
				ItemTemplate = new DataTemplate(typeof(CustomViewCellTwoTextTwoButton)),
				VerticalOptions = LayoutOptions.FillAndExpand,
				RowHeight = 110,
				HasUnevenRows = true
			};
					
			Action<Task> action = (actionResult) =>
				Device.BeginInvokeOnMainThread (() => {


					listView.ItemsSource = _viewModel.SimpleTemplateGroups;
			});

			templatesTask.ContinueWith (action);


           
			listView.ItemTemplate.SetBinding(CustomViewCellTwoTextTwoButton.SimpleTemplateProperty, ".");
			listView.IsGroupingEnabled = true;
			listView.GroupDisplayBinding = new Binding ("Key");
			listView.GroupShortNameBinding = new Binding("Key");
			listView.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell)); 



            listView.ItemSelected += (sender, args) =>
                {
                    if (args.SelectedItem != null)
                    {
                        listView.SelectedItem = null;

                        SimpleTemplate template = (SimpleTemplate)args.SelectedItem;
                        this.Navigation.PushModalAsync(new ModalAssignMemberWorkoutPage(template));
                    }
                };

           

            this.Content = listView;
        }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                String file = openFileDialog1.FileName;
                textBox1.Text = file;
                SimpleTemplate template          = new SimpleTemplate(file, Encoding.UTF8);
                Dictionary <String, Object> args = new Dictionary <String, Object>();
                args.Add("variname", "ab");
                scintilla1.Text = template.Render(args);
            }
        }
示例#9
0
        public void Run()
        {
            var types = GetTypes();

            using (var project = Options.Do.Model.Project)
            {
                foreach (var type in types)
                {
                    var template = new SimpleTemplate(Templates.AutoService);
                    template["interface"] = "I" + type.Type.GetRealClassName();
                    template["service"]   = type;
                    template["opt"]       = Options.Do;

                    project.AddNewCompile(FilePath(type.Type.GetRealClassName()), template.ToString());
                }
            }
        }
示例#10
0
        public void Run()
        {
            var types = GetTypes();

            using (var project = Options.Do.Model.Project)
            {
                foreach (var type in types)
                {
                    var entity   = type.Type.GetTypeArgumentsFor(typeof(IEntityService <>)).FirstOrDefault();
                    var template = new SimpleTemplate(Templates.AutoDomain);
                    template["entity"]  = entity;
                    template["service"] = type;
                    template["opt"]     = Options.Do;

                    project.AddNewCompile(FilePath(entity.Name), template.ToString());
                }
            }
        }
示例#11
0
        public void Start(HttpServer server, SimpleJsonListener json, SimpleTemplate templateDemo)
        {
            _ws           = server;
            _json         = json;
            _templateDemo = templateDemo;

            _ws.AddPath("/demoTimer.html", ProcessTimer);

            _timerControl.LoadString(_ws.HttpRootManager.ReadToByte(_privatePath + "/templateTimer.html"));
            _timerControl["timerOn"] = new TemplateAction()
            {
                Pattern = "TIMERON"
            };
            _timerControl["timerOff"] = new TemplateAction()
            {
                Pattern = "TIMEROFF"
            };

            _templateDemo["led"] = new TemplateAction()
            {
                Pattern = "LED", Data = "Off"
            };
            _templateDemo["timer"] = new TemplateAction()
            {
                Pattern = "TIMER", Data = "Off"
            };

            _json.AddData("Timer", "Off");
            _json.AddData("Led", "Off");

            _ws.HttpRootManager.AddExtensionTemplateData("shtml", "led", new TemplateAction()
            {
                Pattern = "LED", Data = "Off"
            });
            _ws.HttpRootManager.AddExtensionTemplateData("shtml", "timer", new TemplateAction()
            {
                Pattern = "TIMER", Data = "Off"
            });

            _ws.AddTimer("TestTimer", 10000, TimerEvent);

            //_ports._debug = true;
        }
示例#12
0
        public void Execute()
        {
            var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
            var filename  = string.Format("{0}_{1}.cs", timestamp, Name ?? "Untitled");

            var template = new SimpleTemplate(Templates.NewMigration);

            template["timestamp"] = timestamp;
            template["opt"]       = Options.Do;

            using (var project = Options.Do.Database.Project)
            {
                project.AddNewCompile(filename, template.ToString());

                if (OpenIt)
                {
                    Process.Start(project.GetFullPath(filename));
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        public void Listen(HttpRequest request, HttpResponse response)
        {
            try
            {
                // Ali je pot v registriranem listenerju in kliči listener ter return ;
                if (IsRegisteredExtension(request.RequestPath.ToLower()))
                {
                    string[] _tmp = request.RequestPath.ToLower().Split(new char[] { '.' });
                    if (_tmp.Length > 0)
                    {
                        ProcessExtensionListener(request, response, _tmp[_tmp.Length - 1]);
                        return;
                    }
                    else
                    {
                        throw new InvalidDataException("Cannot determine extension from " + request.RequestPath);
                    }
                }

                if (request.RequestPath.EndsWith("/"))
                {
                    // Preverimo, ali je v folderju index file.
                    foreach (string file in _serverRootFile)
                    {
                        if (Containes(_serverRootFolder + request.RequestPath + file))
                        {
                            response.Write(ReadToByte(_serverRootFolder + request.RequestPath + file), _server.GetMimeType.GetMimeFromFile(request.RequestPath + file));
                            return;
                        }
                    }
                    // Ni index fajla,  izpišemo folder.

                    /*
                     * 1) Skopiramo vse poti v začasno datoteko
                     * 2) vse poti, ki ustrezajo ustrezni mapi, skopiramo in pripravimo za izpis
                     * 3) če ne najdemo, je treba izpisat 404.
                     */
                    List <string> _ustreznePoti = new List <string>();

                    foreach (string _pot in GetNames())
                    {
                        if (_pot.ToLower().Contains((_serverRootFolder + request.RequestPath).ToLower().Replace('/', '.')))
                        {
                            // Dodamo samo pravilne url-je za trenutno mapo, brez polne poti in v pravilni obliki.
                            int    cut      = _pot.ToLower().Split(new string[] { _serverRootFolder.ToLower() + request.RequestPath.ToLower().Replace('/', '.') }, StringSplitOptions.None)[1].Length;
                            string _tmpPath = _pot.Replace('.', '/');
                            int    Place    = _tmpPath.LastIndexOf("/");
                            _tmpPath = _tmpPath.Remove(Place, 1).Insert(Place, ".");
                            if (!_tmpPath.Substring(_tmpPath.Length - cut).Contains("/"))
                            {
                                _ustreznePoti.Add(_tmpPath.Substring(_tmpPath.Length - cut));
                            }
                        }
                    }
                    if (_ustreznePoti.Count > 0)
                    {
                        SimpleTemplate _template = new SimpleTemplate();
                        _template.LoadString(ReadToByte("SystemHtml/templateFolderListing.html"));
                        _template.SafeMode = false;

                        StringBuilder rezultat = new StringBuilder();
                        foreach (string _pot in _ustreznePoti)
                        {
                            rezultat.Append("<a href=\"" + _pot + "\">" + _pot + "</a><br>\n");
                        }

                        _template["path"] = new TemplateAction()
                        {
                            Pattern = "PATH", Data = request.RequestPath
                        };
                        _template["content"] = new TemplateAction()
                        {
                            Pattern = "CONTENT", Data = rezultat.ToString()
                        };
                        _template.ProcessAction();
                        response.Write(_template.GetByte(), "text/html");
                        return;
                    }
                    else
                    {
                        ReturnErrorMessage(request, response, "404");
                        return;
                    }
                }
                else
                {
                    /*
                     * Ni folder, izpišemo zahtevano datoteko.
                     */
                    if (Containes(_serverRootFolder + request.RequestPath))
                    {
                        response.Write(ReadToByte(_serverRootFolder + request.RequestPath), _server.GetMimeType.GetMimeFromFile(request.RequestPath));
                        return;
                    }
                    else
                    {
                        ReturnErrorMessage(request, response, "404");
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                response.Write(e);
            }
        }
        public ModalAssignMemberWorkoutPage(SimpleTemplate template)
        {
            this.template = template;

            Label textLabel = new Label
            {
                Text = template.TemplateName,
				FontSize = 45
            };
           
            Label editorLabel = new Label
            {
                Text = template.TemplateDescription,
				FontSize = 35
            };
          

            Label addMemberLabel = new Label
            {
				Text = "Add Member"
            };

            
            addMemberEntry = new CustomEntry
            {
                Placeholder = "Search Member",
                HeightRequest = 35,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            StackLayout addMemberEntryLayout = new StackLayout
            {
                Children =
                {
                    addMemberEntry
                },
            };

            ListView listView = new ListView
            {
                ItemTemplate = new DataTemplate(typeof(CustomViewThreeTextCell)),
                IsVisible = false
            };
            listView.ItemSelected += listView_ItemSelected;

            submitButton = new Button
            {
				Image = "assign_green_button.png",
				HeightRequest = 35,
				WidthRequest = 100
            };

          

            cancel2Button = new Button
            {
				Image = "cancel_button.png",
				HeightRequest = 35,
				WidthRequest = 100
            };

			activityIndicator = new ActivityIndicator {
				IsRunning = false,
				Color = Color.Red
			};

           

            cancel2Button.Clicked += async (sender2, args2) =>
            {
				submitButton.IsEnabled = true;
				activityIndicator.IsRunning = false;
                await Navigation.PopModalAsync();
            };
            submitButton.Clicked += async (sender2, args2) =>
            {

                if ((addMemberEntry.Text != null && addMemberEntry.Text != "") && selectedUser == null)
                {
                    await this.DisplayAlert("Validation", "Select another member. This member is not recognized.", "OK");
                }
                else
                {
                    if (selectedUser != null)
                    {
                        String[] nameArray = addMemberEntry.Text.Split(' ');
                        if (nameArray.Count() > 0)
                        {
                            if (!(selectedUser.FirstName == nameArray[0] && selectedUser.LastName == nameArray[1]))
                            {
                                await this.DisplayAlert("Validation", "Select another member or delete the member entirely.", "OK");
                            }
                            else
                            {
                                await WriteToRepository();
                            }

                        }
                    }
                    else
                    {
                        await this.DisplayAlert("Validation", "Select another member. This member is not recognized.", "OK");
                    }
                }

            };
            StackLayout buttonStack = new StackLayout
            {
                Children =
                        {
                            submitButton, cancel2Button
                        },
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding = new Thickness(20)
            };
            StackLayout modalStack = new StackLayout
            {
                Children =
                        {
                           // pageTitle,
                            textLabel,
                            editorLabel,
                            addMemberLabel,
                            addMemberEntryLayout,
                            listView,
                            buttonStack
                        },
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding = new Thickness(20)
            };

            addMemberEntry.TextChanged += async (sender, args) => 
            {
				var searchResults = await Manager.Instance.User.UserSeach(addMemberEntry.Text, App.WorkoutCreatorContext.StaffMember.GymID);
                    listView.ItemsSource = searchResults;
                    var rowHeight = 40;
                    listView.RowHeight = rowHeight;
                    listView.HeightRequest = (rowHeight * searchResults.Count());
                    modalStack.WidthRequest = this.Width * .7;
                    listView.VerticalOptions = LayoutOptions.StartAndExpand;
                    listView.HorizontalOptions = LayoutOptions.StartAndExpand;
                    listView.IsVisible = true;
                    
            };

            //this.BackgroundColor = Color.FromRgb(135, 206, 250);
            this.Content = modalStack;
           
        }