Exemplo n.º 1
0
        public IActionResult JsInput()
        {
            JsInput model = new JsInput
            {
                FavoriteColor = null
            };

            return(View(model));
        }
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    return;
                }

                List <InputBase> inputs = new List <InputBase>();

                for (int i = 0; i < args.Length; i++)
                {
                    var filename = args[i];

                    var fileInfo = new FileInfo(filename);
                    var type     = GetInputType(fileInfo);
                    Console.WriteLine($"Converting {fileInfo.FullName}");
                    if (!File.Exists(filename) || type == InputType.none)
                    {
                        Console.WriteLine("No idea what to do with {0}... skipping", fileInfo.Name);
                        continue;
                    }

                    if (!CheckKillExcel(fileInfo))
                    {
                        Console.WriteLine("Can't convert with file open in Excel");
                        continue;
                    }

                    InputBase input = null;
                    switch (type)
                    {
                    case InputType.js:
                        input = new JsInput(fileInfo);
                        break;

                    case InputType.xls:
                        input = new XlsInput(fileInfo);
                        break;

                    case InputType.resx:
                        input = new ResxInput(fileInfo);
                        break;

                    case InputType.none:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    // Shouldn't happen but lets keep re-sharper happy
                    if (input == null)
                    {
                        Console.WriteLine("No idea what to do with {0}... skipping", fileInfo.Name);
                        continue;
                    }

                    inputs.Add(input);
                    var models = input.GetModels();
                    if (models.Count == 0)
                    {
                        continue;
                    }

                    switch (type)
                    {
                    case InputType.js:
                        new XlsOutput(fileInfo).Convert(models);
                        //new ResxOutput(fileInfo).Convert(models);
                        break;

                    case InputType.xls:
                        //new JsOutput(fileInfo).Convert(models);
                        //new ResxOutput(fileInfo).Convert(models);
                        break;

                    case InputType.resx:
                        new XlsOutput(fileInfo).Convert(models);
                        //new JsOutput(fileInfo).Convert(models);
                        break;

                    case InputType.none:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                Console.WriteLine("Done");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
                Console.ReadKey();
            }
        }
Exemplo n.º 3
0
 public IActionResult JsInput(JsInput model)
 {
     return(View(model));
 }