ICdlWriter ITabularDataTarget.CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat) { string file = GetName(context); file = context.ResolveFile(file, ResolveFileMode.Output); context.OutputMessage("Writing file " + Path.GetFullPath(file)); return new CdlFileWriter(file, rowFormat); }
public ICdlWriter CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat) { string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output); var fw = new StreamWriter(file); var provider = GetConnectionProvider(context); return new SqlFileWriter(fw, provider.Factory); }
//public override void EnumChildren(Action<IShellElement> enumFunc) //{ // base.EnumChildren(enumFunc); // foreach (var item in Commands) YieldChild(enumFunc, item); //} protected void RunContainer(IShellContext context) { foreach(var item in Commands) { item.Run(context); } }
ICdlReader ITabularDataSource.CreateReader(IShellContext context) { TableInfo table; BinaryReader br; OpenRead(out table, out br, context); return new CdlFileReader(table, br); }
private SocialExplorer.IO.FastDBF.DbfFile OpenDbfRead(IShellContext context) { var dbf = new SocialExplorer.IO.FastDBF.DbfFile(Encoding); var name = context.ResolveFile(context.Replace(Name), ResolveFileMode.Input); dbf.Open(name, System.IO.FileMode.Open); return dbf; }
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); }
protected override void DoRun(IShellContext context) { GetModel(context).LoadReference( new NameWithSchema(context.Replace(Schema), context.Replace(Table)), context.Replace(Column), new NameWithSchema(context.Replace(RefSchema), context.Replace(RefTable))); }
protected override void DoRun(IShellContext context) { var db = GetDatabaseStructure(context); if (Table != null && Tables != null) throw new Exception("DBSH-00085 SetTableProperty: both of Table and tables attribute is set"); if (Table == null && Tables == null) throw new Exception("DBSH-00086 SetTableProperty: none of Table and tables attribute is set"); string value = context.Replace(Value); if (Table != null) { var table = db.FindTableLike(Table); if (table != null) { table.Properties[Name] = value; } } if (Tables != null) { foreach (var table in db.Tables) { if (Regex.Match(table.Name, Tables).Success) { table.Properties[Name] = value; } } } }
protected override void DoRun(IShellContext context) { context.OutputMessage("Opening MS Excel"); var model = ExcelModel.CreateNewWindow(); model.DataFormat = DataFormat; context.SetVariable(GetExcelVariableName(context), model); }
protected override void DoRun(IShellContext context) { using (var conn = GetConnectionProvider(context).Connect()) { GetModel(context).Prepare(conn); } }
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); }
public DataSetModel(DatabaseInfo targetDatabase, IShellContext context, IDatabaseFactory factory) { _targetDatabase = targetDatabase; _context = context; _factory = factory; _dda = _factory.CreateDataAdapter(); }
protected override void DoRun(IShellContext context) { string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output); if (Expression != null && Value != null) throw new Exception("DBSH-00078 SaveToFile: both Expression and Value is set"); if (Expression == null && Value == null) throw new Exception("DBSH-00079 SaveToFile: none of Expression and Value is set"); if (Expression != null) { object obj = context.Evaluate(Expression); if (obj is byte[]) { var bytes = (byte[]) obj; using (var fw = System.IO.File.OpenWrite(file)) { fw.Write(bytes, 0, bytes.Length); } } else { using (var fw = new StreamWriter(file, false, Encoding)) { fw.Write(obj.ToString()); } } } if (Value!=null) { string val = context.Replace(Value); using (var fw = new StreamWriter(file, false, Encoding)) { fw.Write(val); } } }
DataFormatSettings ITabularDataSource.GetSourceFormat(IShellContext context) { using (var childCtx = context.CreateChildContext()) { childCtx.SetVariable(context.Replace(PropertyName), context.Replace(PrimaryFile)); return SourceTemplate.GetSourceFormat(childCtx); } }
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); }
private ITabularDataSource CreateSource(IShellContext context) { string name = GetName(context); if (name.ToLower().EndsWith(".cdl")) return new CdlFile {Connection = Connection, Name = name}; if (name.ToLower().EndsWith(".csv")) return new CsvFile { Connection = Connection, Name = name }; if (name.ToLower().EndsWith(".xml")) return new XmlReader { Connection = Connection, File = name, AnalyseColumns = true }; throw new Exception("DBSH-00002 Unknown soruce file type:" + name); }
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); }
public ColumnMapperReader(ICdlReader source, TableInfo outputFormat, List<IColumnMapping> columnMap, List<int> counts, IShellContext context ) : base(outputFormat) { _source = source; _columnMap = columnMap; _counts = counts; _context = context; }
public TargetEntitySqlModel(DataSyncSqlModel dataSyncSqlModel, Target dbsh, IShellContext context) { this._dataSyncSqlModel = dataSyncSqlModel; this._dbsh = dbsh; TargetTable = new NameWithSchema(context.Replace(dbsh.TableSchema), context.Replace(dbsh.TableName)); string findSchema = dbsh.TableSchema; if (findSchema != null && findSchema.StartsWith(NameWithSchema.NoQuotePrefix)) findSchema = null; Structure = dataSyncSqlModel.TargetStructure.FindTableLike(findSchema, TargetTable.Name); SqlAlias = _dbsh.Alias ?? "dst_" + _dataSyncSqlModel.Entities.Count; foreach (var col in dbsh.Columns) { var targetCol = new TargetNoRefColumnSqlModel(col, FindColumnInfo(col.Name)); TargetColumns.Add(targetCol); foreach (string alias in ExtractColumnSources(col)) { SourceColumnSqlModel source = null; if (dataSyncSqlModel.SourceGraphModel == null) { // flat sync if (!String.IsNullOrEmpty(dbsh.PrimarySource)) { var tableSource = DataSync.FlatSources.FirstOrDefault(x => x.Match(Dbsh.PrimarySource)); if (tableSource != null) { source = tableSource.Columns.FirstOrDefault(x => x.Alias == alias); } } } else { source = dataSyncSqlModel.SourceGraphModel[alias]; //targetCol.Sources.Add(source); } RequiredSourceColumns.Add(source); if (col.IsKey) KeySourceColumns.Add(source); } } if (!String.IsNullOrEmpty(_dbsh.Connection)) { var ctxConn = new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = context.GetDefaultConnection() }); var tableConn = new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = context.Replace(_dbsh.Connection), LinkedInfo = _dbsh.LinkedInfo }); if (ctxConn != tableConn) { if (ctxConn.ServerConnectionString == tableConn.ServerConnectionString) { TargetLinkedInfo = tableConn.GetLinkedInfo(); } else { throw new IncorrectRdsDefinitionException($"DBSH-00000 RDS target must be reachable by database or linked server: ({TargetTable})"); } } } }
protected override void DoRun(IShellContext context) { context.OutputMessage("DBSH-00152 Importing dataset"); using (var conn = GetConnectionProvider(context).Connect()) { GetModel(context).ImportIntoDatabase(conn); } }
public DirectoryTabularDataReader(IShellContext context, ITabularDataSource source, string propertyName, string[] files) { this._context = context; this._source = source; this._propertyName = propertyName; this._files = files; NextRefReader(); }
protected override void DoRun(IShellContext context) { string file = Path.GetTempFileName(); context.SetVariable(context.Replace(Variable), file); context.AddDisposableItem(new TempFileHolder { File = file, }); }
protected override void DoRun(IShellContext context) { string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output); context.OutputMessage("DBSH-00118 Exporting SQL file Writing " + file); using (var fw = new StreamWriter(file)) { GetModel(context).WriteSql(fw); } }
public string GetProviderString(IShellContext context) { string providerString = Connection ?? context.GetDefaultConnection(); if (providerString == null) { throw new Exception("DBSH-00151 Connection is not set, element=" + GetType().FullName); } return providerString; }
private Dictionary<string, string> GetParameterValues(IShellContext context) { var res = new Dictionary<string, string>(); foreach(var par in Parameters) { res[context.Replace(par.Name)] = context.Replace(par.Value); } return res; }
public abstract void PutLogMessage( ISqlDumper dmp, string operationExpr, string targetEntityExpr, string messageExpr, string durationExpr, string procedureExpr, string rowsExpr, IShellContext context);
protected override void DoRun(IShellContext context) { string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output); string url = context.Replace(Url); context.OutputMessage("Downloading from URL " + url); using (var client = new WebClient()) { client.DownloadFile(url, file); } }
IEnumerable IListProvider.GetList(IShellContext context) { using (var reader = ((ITabularDataSource)this).CreateReader(context)) { while (reader.Read()) { yield return reader; } } }
public NormalizedDatabaseConnectionInfo GetNormalizedConnectionInfo(IShellContext context) { return new NormalizedDatabaseConnectionInfo(new DatabaseConnectionInfoHolder { ProviderString = GetProviderString(context), LinkedDatabaseName = LinkedDatabaseName, LinkedServerName = LinkedServerName, ExplicitDatabaseName = ExplicitDatabaseName, }); }
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); } }
public ShellItemRenderer(IShellContext shellContext) : base(shellContext) { }
void IColumnMapping.ProcessMapping(int column, int rowNumber, ICdlRecord record, ICdlValueWriter writer, IShellContext context) { writer.SetInt32(StartFrom + rowNumber); }
public void AttachFlyout(IShellContext context, UIViewController content) { }
protected virtual IShellSectionRootHeader CreateShellSectionRootHeader(IShellContext shellContext) { return(new ShellSectionRootHeader(shellContext)); }
public ShellWithCustomRendererDisabledAnimationsShellItemRenderer(IShellContext shellContext) : base(shellContext) { }
protected virtual void LoadView(IShellContext shellContext) { Profile.FrameBegin(); var context = shellContext.AndroidContext; // Android designer can't load fragments or resources from layouts if (context.IsDesignerContext()) { _rootView = new FrameLayout(context); return; } var coordinator = LayoutInflater.FromContext(context).Inflate(Resource.Layout.FlyoutContent, null); Profile.FramePartition("Find Recycler"); var recycler = coordinator.FindViewById <RecyclerView>(Resource.Id.flyoutcontent_recycler); Profile.FramePartition("Find AppBar"); var appBar = coordinator.FindViewById <AppBarLayout>(Resource.Id.flyoutcontent_appbar); _rootView = coordinator as ViewGroup; Profile.FramePartition("Add Listener"); appBar.AddOnOffsetChangedListener(this); Profile.FramePartition("Add HeaderView"); _actionBarHeight = (int)context.ToPixels(56); _flyoutHeader = ((IShellController)shellContext.Shell).FlyoutHeader; if (_flyoutHeader != null) { _flyoutHeader.MeasureInvalidated += OnFlyoutHeaderMeasureInvalidated; } _headerView = new HeaderContainer(context, _flyoutHeader) { MatchWidth = true }; _headerView.SetMinimumHeight(_actionBarHeight); _headerView.LayoutParameters = new AppBarLayout.LayoutParams(LP.MatchParent, LP.WrapContent) { ScrollFlags = AppBarLayout.LayoutParams.ScrollFlagScroll }; appBar.AddView(_headerView); Profile.FramePartition("Recycler.SetAdapter"); var adapter = new ShellFlyoutRecyclerAdapter(shellContext, OnElementSelected); recycler.SetPadding(0, (int)context.ToPixels(20), 0, 0); recycler.SetClipToPadding(false); recycler.SetLayoutManager(new LinearLayoutManager(context, (int)Orientation.Vertical, false)); recycler.SetAdapter(adapter); Profile.FramePartition("Initialize BgImage"); var metrics = context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); using (TypedValue tv = new TypedValue()) { if (context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { _actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= _actionBarHeight; coordinator.LayoutParameters = new LP(width, LP.MatchParent); _bgImage = new ImageView(context) { LayoutParameters = new LP(coordinator.LayoutParameters) }; Profile.FramePartition("UpdateFlyoutHeaderBehavior"); UpdateFlyoutHeaderBehavior(); _shellContext.Shell.PropertyChanged += OnShellPropertyChanged; Profile.FramePartition("UpdateFlyoutBackground"); UpdateFlyoutBackground(); Profile.FrameEnd(); }
public ShellPageRendererTracker(IShellContext context) { _context = context; }
void IShellFlyoutRenderer.AttachFlyout(IShellContext context, AView content) { AttachFlyout(context, content); }
public ShellSearchResultsRenderer(IShellContext context) { _context = context; }
public ShellFlyoutTemplatedContentRenderer(IShellContext shellContext) { _shellContext = shellContext; LoadView(shellContext); }
public ShellFlyoutRenderer(IShellContext shellContext, Context context) : base(context) { _shellContext = shellContext; Shell.PropertyChanged += OnShellPropertyChanged; }
public ShellContentFragment(IShellContext shellContext, Page page) { _shellContext = shellContext; _page = page; }
public ShellContentFragment(IShellContext shellContext, ShellContent shellContent) { _shellContext = shellContext; _shellContent = shellContent; }
public ShellSectionRootRenderer(ShellSection shellSection, IShellContext shellContext) { ShellSection = shellSection ?? throw new ArgumentNullException(nameof(shellSection)); _shellContext = shellContext; }
public ShellPageRendererTracker(IShellContext context) { _context = context; _nSCache = new NSCache(); }
public ShellToolbarAppearanceTracker(IShellContext shellContext) { _shellContext = shellContext; }
public ShellSectionRootHeader(IShellContext shellContext) : base(new UICollectionViewFlowLayout()) { _shellContext = shellContext; }
public ShellPageRendererTracker(IShellContext context) { _context = context; _nSCache = new NSCache(); _context.Shell.PropertyChanged += HandleShellPropertyChanged; }
public static ILogger <T> GetLogger <T>(this IShellContext context) { return(context.ServiceProvider.GetService <ILogger <T> >()); }
private void RunScript(TextReader reader, DbConnection conn, DbTransaction tran, bool replace, bool logEachQuery, bool logCount, IShellContext context) { int count = 0; foreach (string item in GoSplitter.GoSplit(reader)) { string sql = item; if (replace) { sql = context.Replace(sql, ReplacePattern); } var cmd = conn.CreateCommand(); cmd.CommandText = sql; cmd.CommandTimeout = Timeout; cmd.Transaction = tran; try { if (logEachQuery) { context.GetLogger <Script>().LogInformation("DBSH-00064 Executing SQL command {sql}", sql); } cmd.ExecuteNonQuery(); } catch (Exception err) { context.GetLogger <Script>().LogError(0, err, "DBSH-00065 Error when executing script {1}", sql); throw; } count++; } if (logCount) { context.GetLogger <Script>().LogInformation("DBSH-00073 Executed {0} commands", count); } }
public ShellBottomNavViewAppearanceTracker(IShellContext shellContext, ShellItem shellItem) { _shellItem = shellItem; _shellContext = shellContext; }
protected virtual void AttachFlyout(IShellContext context, AView content) { Profile.FrameBegin(); _content = content; Profile.FramePartition("Create ContentRenderer"); _flyoutContent = context.CreateShellFlyoutContentRenderer(); // Depending on what you read the right edge of the drawer should be Max(56dp, actionBarSize) // from the right edge of the screen. Fine. Well except that doesn't account // for landscape devices, in which case its still, according to design // documents from google 56dp, except google doesn't do that with their own apps. // So we are just going to go ahead and do what google does here even though // this isn't what DrawerLayout does by default. // Oh then there is this rule about how wide it should be at most. It should not // at least according to docs be more than 6 * actionBarSize wide. Again non of // this is about landscape devices and google does not perfectly follow these // rules... so we'll kind of just... do our best. Profile.FramePartition("Fudge Width"); var metrics = Context.Resources.DisplayMetrics; var width = Math.Min(metrics.WidthPixels, metrics.HeightPixels); var actionBarHeight = (int)Context.ToPixels(56); using (var tv = new TypedValue()) { if (Context.Theme.ResolveAttribute(global::Android.Resource.Attribute.ActionBarSize, tv, true)) { actionBarHeight = TypedValue.ComplexToDimensionPixelSize(tv.Data, metrics); } } width -= actionBarHeight; var maxWidth = actionBarHeight * 6; width = Math.Min(width, maxWidth); _flyoutWidth = width; _flyoutContent.AndroidView.LayoutParameters = new LayoutParams(width, LP.MatchParent) { Gravity = (int)GravityFlags.Start }; Profile.FramePartition("AddView Content"); AddView(content); Profile.FramePartition("AddView Flyout"); AddView(_flyoutContent.AndroidView); Profile.FramePartition("Add DrawerListener"); AddDrawerListener(this); Profile.FramePartition("Add BehaviorObserver"); ((IShellController)context.Shell).AddFlyoutBehaviorObserver(this); Profile.FrameEnd(); }
protected override void DoRun(IShellContext context) { if (File != null && Command != null) { throw new Exception("DBSH-00060 Both Script.File and Script.Command properties are set"); } if (File == null && Command == null && Files == null) { throw new Exception("DBSH-00061 None of Script.File and Script.Command and Script.Files properties are set"); } var connection = GetConnectionProvider(context); using (var conn = connection.Connect()) { DbTransaction tran = null; try { if (UseTransactions) { context.Info("Opening transaction"); tran = conn.BeginTransaction(); } // execute inline command if (Command != null) { RunScript(new StringReader(Command), conn, tran, UseReplacements == null || UseReplacements == true, true, false, context); } // execute linked file if (File != null) { string fn = context.ResolveFile(File, ResolveFileMode.Input); using (var reader = new StreamReader(System.IO.File.OpenRead(fn), FileEncoding)) { //context.GetLogger<Script>().LogInformation("DBSH-00067 Executing SQL file {file}", fn); context.Info(String.Format("Executing SQL file {0}", fn)); RunScript(reader, conn, tran, UseReplacements == true, false, true, context); } } if (Files != null) { foreach (string file in Files) { string fn = context.ResolveFile(file, ResolveFileMode.Input); using (var reader = new StreamReader(System.IO.File.OpenRead(fn), FileEncoding)) { context.Info(String.Format("Executing SQL file {0}", fn)); RunScript(reader, conn, tran, UseReplacements == true, false, true, context); } } } if (tran != null) { context.Info("Commiting transaction"); tran.Commit(); } } catch { if (tran != null) { context.Info("Rollbacking transaction"); tran.Rollback(); } throw; } finally { if (tran != null) { tran.Dispose(); } } } }
public ShellSectionRenderer(IShellContext shellContext) { _shellContext = shellContext; }
public TableInfo GetRowFormat(IShellContext context) { return(null); }
public ICdlWriter CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat) { string file = context.ResolveFile(context.Replace(File), ResolveFileMode.Output); var fw = new StreamWriter(System.IO.File.OpenWrite(file)); var provider = GetConnectionProvider(context); return(new SqlFileWriter(fw, provider.Factory, InsertSeparatorAfterRows)); }
public ShellFlyoutLayoutManager(IShellContext context) { _context = context; _context.Shell.PropertyChanged += OnShellPropertyChanged; ShellController.StructureChanged += OnStructureChanged; }
public bool IsAvailableRowFormat(IShellContext context) { return(false); }
protected ExcelModel GetModel(IShellContext context) { return((ExcelModel)context.GetVariable(GetExcelVariableName(context))); }
public ShellTableViewSource(IShellContext context, Action <Element> onElementSelected) { _context = context; _onElementSelected = onElementSelected; }