Пример #1
0
        protected override void DoRun(IShellContext context)
        {
            if (Value != null && Expression != null)
            {
                throw new Exception("DBSH-00006 Both Value and Expression is set");
            }

            if (Value != null)
            {
                if (Value is string)
                {
                    context.SetVariable(context.Replace(Name), context.Replace(Value.ToString()));
                }
                else
                {
                    context.SetVariable(context.Replace(Name), Value);
                }
            }

            if (Expression != null)
            {
                context.SetVariable(context.Replace(Name), context.Evaluate(Expression));
            }

            if (Expression == null && Value == null)
            {
                context.SetVariable(context.Replace(Name), null);
            }
        }
Пример #2
0
 protected override void DoRun(IShellContext context)
 {
     var dbs = GetDatabaseStructure(context);
     var model = new DataSetModel(dbs, context, GetConnectionProvider(context).Factory);
     model.KeepUndefinedReferences = KeepUndefinedReferences;
     context.SetVariable(GetDataSetVariableName(context), model);
 }
Пример #3
0
 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Input);
     var model = ExcelModel.OpenFile(file);
     model.DataFormat = DataFormat;
     context.SetVariable(GetExcelVariableName(context), model);
 }
Пример #4
0
 protected override void DoRun(IShellContext context)
 {
     context.OutputMessage("Opening MS Excel");
     var model = ExcelModel.CreateNewWindow();
     model.DataFormat = DataFormat;
     context.SetVariable(GetExcelVariableName(context), model);
 }
Пример #5
0
        protected override void DoRun(IShellContext context)
        {
            DateTime?maxDate = null;
            string   maxFile = null;

            string path   = Path.GetDirectoryName(Filter);
            string filter = Path.GetFileName(Filter);

            foreach (string file in Directory.GetFiles(path, filter))
            {
                if (!String.IsNullOrEmpty(FilenameRegex))
                {
                    if (!Regex.Match(file, FilenameRegex).Success)
                    {
                        continue;
                    }
                }

                var lastWrite = System.IO.File.GetLastWriteTime(file);

                if (maxDate == null || lastWrite > maxDate.Value)
                {
                    maxDate = lastWrite;
                    maxFile = file;
                }
            }

            context.SetVariable(context.Replace(Variable), maxFile);
        }
Пример #6
0
 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Input);
     var model = ShapeFileModel.OpenFile(file, SpatialTool.GetProjection(Projection, context));
     model.DataFormat = DataFormat;
     model.AddFileIdentifier = AddFileIdentifier;
     context.SetVariable(GetShpVariableName(context), model);
 }
Пример #7
0
        protected override void DoRun(IShellContext context)
        {
            string file  = context.ResolveFile(context.Replace(File), ResolveFileMode.Input);
            var    model = ExcelModel.OpenFile(file);

            model.DataFormat = DataFormat;
            context.SetVariable(GetExcelVariableName(context), model);
        }
Пример #8
0
 protected override void DoRun(IShellContext context)
 {
     string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
     context.OutputMessage("Writing file " + Path.GetFullPath(file));
     var model = ExcelModel.CreateFile(file);
     model.DataFormat = DataFormat;
     context.SetVariable(GetExcelVariableName(context), model);
 }
Пример #9
0
 protected override void DoRun(IShellContext context)
 {
     string file = Path.GetTempFileName();
     context.SetVariable(context.Replace(Variable), file);
     context.AddDisposableItem(new TempFileHolder
     {
         File = file,
     });
 }
Пример #10
0
        protected override void DoRun(IShellContext context)
        {
            string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);

            context.Info("Writing file " + Path.GetFullPath(file));
            var writer = XmlWriter.CreateWriter(file);

            context.SetVariable(GetXmlVariableName(context), writer);
        }
Пример #11
0
        protected override void DoRun(IShellContext context)
        {
            string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);

            context.Info("Writing file " + Path.GetFullPath(file));
            var model = ExcelModel.CreateFile(file);

            model.DataFormat = DataFormat;
            context.SetVariable(GetExcelVariableName(context), model);
        }
Пример #12
0
 protected override void DoRun(IShellContext context)
 {
     using (var conn = GetConnectionProvider(context).Connect())
     {
         var cmd = conn.CreateCommand();
         cmd.CommandText = context.Replace(Text);
         object value = cmd.ExecuteScalar();
         context.SetVariable(context.Replace(Name), value);
     }
 }
Пример #13
0
 protected override void DoRun(IShellContext context)
 {
     using (var conn = GetConnectionProvider(context).Connect())
     {
         var cmd = conn.CreateCommand();
         cmd.CommandText = context.Replace(Text);
         object value = cmd.ExecuteScalar();
         context.SetVariable(context.Replace(Name), value);
     }
 }
Пример #14
0
 private void CreateColumnValues(ICdlRecord record, IShellContext context)
 {
     if (NeedColumnValues)
     {
         context.CreateScope();
         for (int i = 0; i < record.FieldCount; i++)
         {
             context.SetVariable(record.GetName(i), record.GetValue(i));
         }
     }
 }
Пример #15
0
 private void CreateColumnValues(ICdlRecord record, IShellContext context)
 {
     if (NeedColumnValues)
     {
         context.CreateScope();
         for (int i = 0; i < record.FieldCount; i++)
         {
             context.SetVariable(record.GetName(i), record.GetValue(i));
         }
     }
 }
Пример #16
0
        protected override void DoRun(IShellContext context)
        {
            string file = Path.GetTempFileName();

            context.SetVariable(context.Replace(Variable), file);
            context.AddDisposableItem(new TempFileHolder
            {
                File    = file,
                Context = context,
            });
        }
Пример #17
0
 protected override void DoRun(IShellContext context)
 {
     if (Value != null && Expression != null) throw new Exception("DBSH-00006 Both Value and Expression is set");
     if (Value != null)
     {
         if (Value is string)
         {
             context.SetVariable(context.Replace(Name), context.Replace(Value.ToString()));
         }
         else
         {
             context.SetVariable(context.Replace(Name), Value);
         }
     }
     if (Expression != null)
     {
         context.SetVariable(context.Replace(Name), context.Evaluate(Expression));
     }
     if (Expression == null && Value == null)
     {
         context.SetVariable(context.Replace(Name), null);
     }
 }
Пример #18
0
 protected override void DoRun(IShellContext context)
 {
     context.SetVariable(GetSyncModelVariableName(context), this);
 }