I am trying to make an web based "configuration" tool that will contain a lot of Cisco configuration templates for switches and routers.
But since I am new to C# I have some questions. Just so you know I am already familiar with basic strings etc... and I also have VS 2013 up and running.
This is not so relevant in this question, but just so I have mentioned it, I am using ASP.NET MVC (with C# as prog. language) and I am quite familiar with ASP.NET MVC.
Now here is the question, lets say this is anCisco` switch template config:
interface eth102/1/1
description test-server
switchport mode trunk
switchport trunk allowed vlan 100, 200
no shut
So what I am trying to do is to give the users an option to add following
text fields:
ALLOWED VLAN: xxx
DESCRIPTION: xxx
Which means user types in VLAN ID and description for example, and then when he click on "submit" button or "get config" button name, then the user should get the complete template config listed somewhere on the page..
including the VLAN id and description that user typed in.
My question is, is it better to hard code template configurations or use an SQL DB?
As a rule of thumb: hard coding is never a good stategy unless you are very certain, that the hard coded text is correct and will never change. If you have to change it you will have to recompile your app.
If you don't want to use a db that at least read your text from file. That way you can change or extend your text easily. Maybe consider implementing text tokens, that will be replaced by your app. That way you are more flexible because you won't have to rely on keywords in the text...
Related
My approach is to save all the label names, content, language and the page name on the database and retrieve it before every page load. Is this the right approach or can I do something more efficient. Assume I already have all the translated label names.
-- There would be frequent changes on the translations, so I prefer not to deploy the code all the time. So, resource file would be my last choice. (My understanding is that we would have to recompile the code everytime we change the .resx file, please correct me if im wrong)
you should look at globalization & localization in ASP.NET; see below links :
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-2.2
https://afana.me/archive/2011/01/14/aspnet-mvc-internationalization.aspx/
http://www.ziyad.info/en/articles/10-Developing_Multicultural_Web_Application
you can use Resource Files concept For Changing Label text
http://www.codedigest.com/posts/53/create-multi-language-website-in-aspnet-mvc---localization
I have strings that admin user can input into database.
User can select language, I want to localize this text according to it.
I do not want translate strings as I want to keep semantics same.
Also I have researched but I have found examples for only static strings.
Below question is relevant but I do not know string at compile time.
User can insert any string.
Relevant stackoverflow question
If I understand your question correctly, there is no easy way to do this.
All UI localization tools are concerned with localizing texts stored in your application, like the text on a button, or an error message.
If your application shows texts from a database, this a completely different problem.
Normally, you would have to allow for a multilingual text in your database schema and give your admin user a way to enter a localized text. Probably, you would have to define a translations table with
the original text (or a text ID)
a language ID
the localized text
In your application you would have to fetch the localized text from translations table.
If you use the original text as the key into the translations table, you will not have to modify the original table. If you use an ID, you would need to store this ID in the original table. Both have pros and cons.
If you are not too worried about the quality and consistency of the translations, you could use an online translation service. There are APIs for both the Google and Bing translator. Technically they are both paid services, but - at least with Bing - I think you have to pass a monthly threshold before they actually charge you anything.
I am currently in the process of re-creating our schools website, as it's predecessor was quite painful to navigate / maintain.
We currently have an MS SQL Server with all of the data needed for the dynamic stuff.
My main issue is that ALL the website text needs to be editable by management, but in the middle of the text there may be a custom control (or dynamic data but that is not my issue). I was originally thinking of allowing a place holder and then having the server scan the text and replacing it with a web user control, however this has proved to be very difficult and probably bad practice.
I have spent almost a day searching Google attempting to find a solution but have had no luck with anything I have found.
One idea is to solve it with place holder syntax where you define a placeholder in the content that you can replace on the server.
One option is nustache https://github.com/jdiamond/Nustache
It will let you specify place holders like this: {{FirstName}}
I'm trying to help save time at work with for a lot of tedious copy/paste tasks we have.
So, we have a propitiatory CRM (with proper HTML ID's, etc for accessing elements) and I'd like to copy those vales from the CRM to textboxes on other web pages (outside of the CRM, so sites like Twitter, Facebook, Google, etc)
I'm aware browsers limit this for security and I'm open to anything, it can be a C#/C++ application, Adobe AIR, etc. We only use Firefox at work so even an extension would work. (We do have GreaseMonkey installed so if that's usable too, sweet).
So, any ideas on how to copy values from one web page to another? Ideally, I'm looking to click a button and have it auto-populate fields. If that button has to launch the web pages that need to be copied over to, that's fine.
Example: Copy customers Username from our CRM, paste it in Facebook's Username field when creating a new account.
UPDATE: To answer a user below, the HTML elements on each domain have specific HTML ID's. The data won't need to be manipulated or cleaned up, just a simple copy from ourCRM.com to facebook.com / twitter.com
Ruby Mechanize is a good bet for scraping the data. Then you can store it and post it however you please.
First, I'd suggest that you more clearly define exactly what it is you're looking to do. I read this as you're trying to take some unstructured data from Point A and copy it to Point B. Do the names of these fields remain constant every time you do the operation? Do you need to simply pull any textbox elements from the page and copy them all over? Do some sort of filtering of this data before writing it over?
Once you've got a clear idea of the requirements, if you go the C# route, I'd use something like SimpleBrowser. Judging by the example on their Github page, you could give it the URL of the page you're looking to copy, then name each of the fields you're looking to obtain the value of, perhaps store these in an IDictionary, then open a new URL and copy those values back into the page (and submit the form).
Alternatively, if you don't know the names of the fields, perhaps there's a provided function in that or a similar project that will allow you to simply enumerate all the text fields on the page and retrieve the values for all of them. Then you'd simply apply some logic of your own to filter those options down to whatever is on the destination form.
SO we thought of an easier way to do this (in case anyone else runs into this issue).
1) From our CRM, we added a "Sign up for Facebook" button
2) The button opens a new window with GET variables in the URL
3) Use a greasemonkey script to read those GET variables and fill in textbox values
4) SUCCESS!
Simple, took about 10 minutes to get working. Thanks for you suggestions.
Feature explained below is available in Microsoft Dynamics AX (formerly known as Axapta), an ERP application. However, my question is related to Visual Studio 2010 and MVC 3 application. Please find my questions after this feature explanation.
Screenshot #1 shows a method written in X++ (language used in Microsoft Dynamics AX) using the MorphX editor. If I select a text within double quotes and right-click on them, I will get the options as shown in the screenshot. This is true if the text begins with an # character and is a valid id found in the label file.
If I click on the option Lookup Properties/Methods, a tool tip will appear showing the actual text associated with the selected label id. Here in this case the label id is #SYS67 and its associated label text is Transaction date. Refer screenshot #2.
If I click on the option Lookup Label/Text, the label editor will appear with the label id pre-filtered along with other languages of choice at the bottom section of the editor. I can change the translation text in different languages using the editor. Refer screenshot #3.
In Dynamics AX, the label texts are stored in text files with label id and separated by a tab. Label ids always begin with # symbol. Here in the example shown #SYS is the group prefix and the given number is a sequential index. Refer screenshot #4 that displays text found in an en-us label file.
I understand that this is similar to Resource editor in Visual Studio where the translation text are stored in .resx files for each language. I would like to do something similar for an ASP.NET MVC 3 application using SQL Server database as the data store for the translation text.
Here are my questions:
What would I need to create in Visual Studio 2010 to achieve this functionality so I can invoke the translation editor in the IDE? Would that be a plugin or extension?
Would a similar resource provider be possible to do in an ASP.NET MVC application, where I can just specify the label id within double quotes and have provider model fetch the data from database during runtime? Is the syntax Resources.MyResource.GetLabel("#SYS67"); the only available option in ASP.NET? Sorry, if the resources syntax is wrong.
Are there any similar tool set (plugin/extension) already available for Visual Studio?
I believe that one of the terms to do translation in ASP.NET application is making use of Resource Provider Model. Are there any other terms? I am interested to know the term of what I am trying to achieve so I can search on the web to read more about it.
Any inputs will be really appreciated.
Thanks in advance.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
I'm going to jump in here and give you what I know. I apologize if it doesn't completely answer your question but I don't want to stray too far from what I am familiar with and thus give you bad advice.
From the way you describe your issue, it seems that you could use the resource files (RESX) for translations, the issue is more that you want to know how to edit them in a manner that is user friendly. Further, some users may want to edit the translations on the web.
To answer this part of your question, I would recommend that you look at this article:
http://blog.lavablast.com/post/2008/02/07/RESX-file-Web-Editor.aspx
The author seems to have a similar issue as you and the conclusion the author arrived at was similar to what you are thinking about. The source code is provided so you could get a head-start if you wanted to pursue this method.
If you are going to pursue rolling your own editor, I would suggest that you choose one interface and stick with it. Otherwise you will be increasing your development time on something that isn't your actual product. Since you want the web for some users, I would suggest you would stick with the web for everyone. However, if you really want to pursue an plugin for Visual Studio, I would recommend that you put as much code into a central business logic layer as possible so that your presentation layers don't take up much of your time.
As for currently-available options, I don't think any of the following are Visual Studio plugins, but they all do a good job at working with localization:
http://www.redpin.eu/index.html
http://www.lingobit.com/products/index.html
http://www.sdl.com/en/language-technology/products/software-localization/sdl-passolo.asp
If you want to learn more about the terminology and practices of localization, I would recommend the following site:
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/localization/localization.aspx
If you want to store information in a database instead of a .resx file, here is a resource that will show you how to do it:
http://msdn.microsoft.com/en-us/library/aa905797.aspx