Ejemplo n.º 1
0
 public bool? ExecuteBool(IDataSource dataSource)
 {
     var val = _root.GetValue(dataSource);
     var valType = val.GetValueType();
     if (valType != ValueType.Bool) throw new Exception("Return value is not boolean");
     return val.AsBool();
 }
Ejemplo n.º 2
0
		public virtual object ExecuteScalar(string sql, IDataSource dataSource, IList parameters)
		{
			this.Context.LogManager.Info(this, "Executing scalar sql query", "Sql: " + sql); // do not localize
			IDbConnection connection;
			IDbCommand cmd;
			object result;
			ITransaction transaction;
			SqlExecutorCancelEventArgs e = new SqlExecutorCancelEventArgs(sql, dataSource, parameters);
			this.Context.EventManager.OnExecutingSql(this, e);
			if (e.Cancel)
			{
				this.Context.LogManager.Warn(this, "Executing scalar sql query canceled by observer!", "Sql: " + sql); // do not localize
				return 0;
			}
			sql = e.Sql;
			dataSource = e.DataSource;
			parameters = e.Parameters;
			connection = dataSource.GetConnection();
			cmd = connection.CreateCommand();
			cmd.CommandType = CommandType.Text;
			cmd.CommandText = sql;
			AddParametersToCommand(cmd, parameters);
			transaction = this.Context.GetTransaction(connection);
			if (transaction != null)
			{
				cmd.Transaction = transaction.DbTransaction;
			}
			result = cmd.ExecuteScalar();
			dataSource.ReturnConnection();
			
			SqlExecutorEventArgs e2 = new SqlExecutorEventArgs(sql, dataSource, parameters);

			this.Context.EventManager.OnExecutedSql(this, e2);
			return result;
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Discover at run time the appropriate set of Parameters for a stored procedure
        /// </summary>
		/// <param name="session">An IDalSession object</param>
		/// <param name="spName">Name of the stored procedure.</param>
        /// <param name="includeReturnValueParameter">if set to <c>true</c> [include return value parameter].</param>
        /// <returns>The stored procedure parameters.</returns>
		private IDataParameter[] InternalDiscoverSpParameterSet(
            IDataSource dataSource, 
            string spName, 
            bool includeReturnValueParameter)
		{
            IDbCommand dbCommand = dataSource.DbProvider.CreateCommand();
            dbCommand.CommandType = CommandType.StoredProcedure;

            using (dbCommand)
			{
				cmd.CommandText = spName;

			    // The session connection object is always created but the connection is not alwys open
			    // so we try to open it in case.
				session.OpenConnection();

				DeriveParameters(session.DataSource.DbProvider, cmd);

				if (cmd.Parameters.Count > 0) {
					IDataParameter firstParameter = (IDataParameter)cmd.Parameters[0];
					if (firstParameter.Direction == ParameterDirection.ReturnValue) {
						if (!includeReturnValueParameter) {
							cmd.Parameters.RemoveAt(0);
						}
					}	
				}


				IDataParameter[] discoveredParameters = new IDataParameter[cmd.Parameters.Count];
				cmd.Parameters.CopyTo(discoveredParameters, 0);
				return discoveredParameters;
			}
		}
Ejemplo n.º 4
0
        public HomeController(IDataSource dataSource, IDomainFactory domainFactory)
        {
            Contract.Requires(dataSource != null);
            Contract.Requires(domainFactory != null);

            domain = domainFactory.Create(dataSource);
        }
 private DataSourceView ConnectToDataSourceView()
 {
     if (!this._currentViewValid || base.DesignMode)
     {
         if ((this._currentView != null) && this._currentViewIsFromDataSourceID)
         {
             this._currentView.DataSourceViewChanged -= new EventHandler(this.OnDataSourceViewChanged);
         }
         this._currentDataSource = this.GetDataSource();
         string dataMember = this.DataMember;
         if (this._currentDataSource == null)
         {
             this._currentDataSource = new ReadOnlyDataSource(this.DataSource, dataMember);
         }
         else if (this.DataSource != null)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("DataControl_MultipleDataSources", new object[] { this.ID }));
         }
         this._currentDataSourceValid = true;
         DataSourceView view = this._currentDataSource.GetView(dataMember);
         if (view == null)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("DataControl_ViewNotFound", new object[] { this.ID }));
         }
         this._currentViewIsFromDataSourceID = base.IsBoundUsingDataSourceID;
         this._currentView = view;
         if ((this._currentView != null) && this._currentViewIsFromDataSourceID)
         {
             this._currentView.DataSourceViewChanged += new EventHandler(this.OnDataSourceViewChanged);
         }
         this._currentViewValid = true;
     }
     return this._currentView;
 }
 public static bool ContainsListCollection(IDataSource dataSource) {
     ICollection viewNames = dataSource.GetViewNames();
     if (viewNames != null && viewNames.Count > 0) {
         return true;
     }
     return false;
 }
Ejemplo n.º 7
0
        internal static MetaTable GetTableWithFullFallback(IDataSource dataSource, HttpContextBase context) {
            MetaTable table = GetTableFromMapping(context, dataSource);
            if (table != null) {
                return table;
            }

            IDynamicDataSource dynamicDataSource = dataSource as IDynamicDataSource;
            if (dynamicDataSource != null) {
                table = GetTableFromDynamicDataSource(dynamicDataSource);
                if (table != null) {
                    return table;
                }
            }

            table = DynamicDataRouteHandler.GetRequestMetaTable(context);
            if (table != null) {
                return table;
            }

            Control c = dataSource as Control;
            string id = (c != null ? c.ID : String.Empty);
            throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                DynamicDataResources.MetaTableHelper_CantFindTable,
                id));
        }
 public TransactionEventArgs(ITransaction transaction, IDataSource dataSource, bool autoPersistAllOnCommit)
     : base()
 {
     m_Transaction = transaction;
     m_DataSource = dataSource;
     m_AutoPersistAllOnCommit = autoPersistAllOnCommit;
 }
Ejemplo n.º 9
0
 private void SetDataSource(IDataSource dataSource, ILayer layer)
 {
     this.Clear();
     this.activeDataSources.Add(dataSource);
     this.videoControl.AddLayer(layer);
     dataSource.Start();
 }
 public SqlExecutorEventArgs(string sql, IDataSource ds, IList parameters)
     : base()
 {
     m_Sql = sql;
     m_DataSource = ds;
     m_Parameters = parameters;
 }
        // DEFAULT CONSTRUCTOR
        #region Public Methods and Operators

        /// <summary>
        /// Add data source from <paramref name="datasourceBean"/> to <paramref name="datasourceType"/>
        /// </summary>
        /// <param name="datasourceBean">
        /// The data source SDMX Object.
        /// </param>
        /// <param name="datasourceType">
        /// The data source LINQ2XSD object.
        /// </param>
        public void AddDatasource(IDataSource datasourceBean, DatasourceType datasourceType)
        {
            if (datasourceBean.SimpleDatasource)
            {
                if (datasourceBean.DataUrl != null)
                {
                    datasourceType.SimpleDatasource = datasourceBean.DataUrl;
                }
            }
            else
            {
                var queryableDatasourceType = new QueryableDatasourceType();
                datasourceType.QueryableDatasource = queryableDatasourceType;
                if (datasourceBean.DataUrl != null)
                {
                    queryableDatasourceType.DataUrl = datasourceBean.DataUrl;
                }

                queryableDatasourceType.isRESTDatasource = datasourceBean.RESTDatasource;
                queryableDatasourceType.isWebServiceDatasource = datasourceBean.WebServiceDatasource;
                if (datasourceBean.WsdlUrl != null)
                {
                    queryableDatasourceType.WSDLUrl = datasourceBean.WsdlUrl;
                }
            }
        }
Ejemplo n.º 12
0
 public App(int appId, int zoneId, PortalSettings ownerPS, IDataSource parentSource = null)
 {
     AppId = appId;
     ZoneId = zoneId;
     //InitialSource = parentSource;
     OwnerPS = ownerPS;
 }
Ejemplo n.º 13
0
        public RemoteDataService(IDataSource dataSource, IAppSettings appSettings)
        {
            _appSettings = appSettings;
            _dataSource = dataSource;

            _httpClient = new HttpClient();
        }
 internal void notifyLocalDataSorceSetup(IDataSource localDataSource)
 {
     if (this.LocalDataSourceAdded != null)
     {
         this.LocalDataSourceAdded(this, new LocalDataSourceAddedEventArgs() { dataSource = localDataSource });
     }
 }
Ejemplo n.º 15
0
		public Transaction(IDbTransaction dbTransaction, IDataSource dataSource, IContext ctx) : base(ctx)
		{
			m_DbTransaction = dbTransaction;
			m_DataSource = dataSource;
			m_OriginalKeepOpen = m_DataSource.KeepConnectionOpen;
			m_DataSource.KeepConnectionOpen = true;
		}
Ejemplo n.º 16
0
        private DataParams GetDataParams(DataId dataId, string folder, IDataSource dataSource)
        {
            var fileName = String.Format("{0}{1}.csv", dataId.Symbol, (int) dataId.Period);
            var path = Path.Combine(folder, "Data", dataId.Source, fileName);

            var dataParams = new DataParams
            {
                DataSourceName = dataId.Source,
                Symbol = dataId.Symbol,
                Period = dataId.Period,
                DataId = dataId,
                Path = path,
                StartDate = dataSource.StartDate,
                EndDate = dataSource.EndDate,
                IsUseStartDate = dataSource.IsUseStartDate,
                IsUseEndDate = dataSource.IsUseEndDate,
                MaximumBars = dataSource.MaximumBars,
                MaxIntrabarBars = dataSource.MaxIntrabarBars,
                MinimumBars = dataSource.MinimumBars,
                IsCheckDataAtLoad = dataSource.IsCheckDataAtLoad,
                IsCutOffBadData = dataSource.IsCutOffBadData,
                IsCutOffSatSunData = dataSource.IsCutOffSatSunData,
                IsFillInDataGaps = dataSource.IsFillInDataGaps,
                IsCacheData = dataSource.IsCacheDataFiles,
                IsLongData = false
            };

            return dataParams;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataAccessIntentHandler"/> class.
        /// </summary>
        public DataAccessIntentHandler(IIntentManager intentManager,
            INetworkSearchConfigBuilder networkSearchConfigBuilder,
            IDataSourcesAndSchema dataSourcesAndSchema,
            IExploreConfigBuilder exploreConfigBuilder,
            INotificationService notificationService,
            IExplorationIntentFactory explorationIntentFactory,
            IAcxiomConstants acxiomConstants)
        {
            mIntentManager = intentManager;
            mNetworkSearchConfigBuilder = networkSearchConfigBuilder;
            mDataSourcesAndSchema = dataSourcesAndSchema;
            mExploreConfigBuilder = exploreConfigBuilder;
            mNotificationService = notificationService;
            mExplorationIntentFactory = explorationIntentFactory;
            mAcxiomConstants = acxiomConstants;

            mDataSource = mDataSourcesAndSchema.DataSources.SingleOrDefault(x => x.Id.Equals(mAcxiomConstants.AcxiomDaodExternalContextRoot));

            if (mDataSource == null)
            {
                string extractDataSourceNotFound = string.Format(AcxiomStringResources.ErrorExternalDataSourceNotFound, mAcxiomConstants.AcxiomDaodExternalContextRoot);
                mNotificationService.PresentInformationNotificationWithoutDiagnosticsToTheUser(extractDataSourceNotFound);
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          AcxiomStringResources.ErrorExternalDataSourceNotFound,
                                                          mAcxiomConstants.AcxiomDaodExternalContextRoot));
            }
        }
Ejemplo n.º 18
0
        public void Start(int epoch)
        {
            this.dataSource = new Db(this.dataFileName);

            IEnumerable<Event> events = this.dataSource.ListToRestore(epoch);

            if (!events.Any())
            {
                return;
            }

            foreach (var item in events)
            {
                Console.WriteLine($"File: {item.Name}; Time: {Utils.Epoch2String(item.Date)}");
            }

            Console.WriteLine("Would you like to restore them? Y/N");
            string answer = Console.ReadLine();
            if (!answer.Equals("y", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            Utils.CleanDir(this.sourceDir, this.srcFileTepmlate);

            foreach (var item in events.Where(ev => ev.Change != (int)WatcherChangeTypes.Deleted))
            {
                this.DoRestore(item.Name, item.Guid, item.Version);
                Console.WriteLine($"File: {item.Name} has restored.");
            }
        }
 public TransactionEventArgs(IDataSource dataSource, IsolationLevel isolationLevel, bool autoPersistAllOnCommit)
     : base()
 {
     m_DataSource = dataSource;
     m_IsolationLevel = isolationLevel;
     m_AutoPersistAllOnCommit = autoPersistAllOnCommit;
 }
        public AcquisitionEngine(IDataSource source)
        {
            samplesOverflowSink = new List<float>();

            overviewWfLastCapture = DateTime.Now;
            overviewWf = new Waveform(1, 6000000);

            TriggerSources = new List<ITrigger>();
            TriggerSources.Add(new FreeRunning());
            TriggerSources.Add(new Edge());

            Trigger = new Edge(); // TODO: Temporary trigger

            Source = source;
            Source.Data += ProcessWaveform;
            Source.Data += Source_Data;
            Source.HighresVoltage += Source_HighresVoltage;

            Source.Connect(null);
            var dummyCfg = new NetStreamConfiguration();
            dummyCfg.AdcSpeed = 0;
            dummyCfg.AfeGain = 0;
            dummyCfg.UseFastAdc = false;

            Source.Configure(dummyCfg);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExecutionToken" /> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="operationName">Name of the operation.</param>
 /// <param name="commandText">The command text.</param>
 /// <param name="commandType">Type of the command.</param>
 protected ExecutionToken(IDataSource dataSource, string operationName, string commandText, CommandType commandType)
 {
     DataSource = dataSource;
     OperationName = operationName;
     CommandText = commandText;
     CommandType = commandType;
 }
 public static IList GetList(IDataSource dataSource) {
     ICollection viewNames = dataSource.GetViewNames();
     
     if (viewNames != null && viewNames.Count > 0) {
         return new ListSourceList(dataSource);
     }
     return null;
 }
Ejemplo n.º 23
0
		internal static ITransaction GetTransaction(IDataSource dataSource, IsolationLevel isolationLevel, bool beginTransaction) {
			IDbConnection connection = dataSource.OpenConnection();
			Transaction transaction = new Transaction(connection, isolationLevel);
			if(beginTransaction) {
				transaction.Begin();
			}
			return transaction;
		}
Ejemplo n.º 24
0
        /// <summary>
        /// Creates an instance of <see cref="Bookkeepr.Application.IDomain"/>
        /// </summary>
        /// <param name="dataSource">The datasource that the <see cref="Bookkeepr.Application.IDomain"/> instance will be bound to</param>
        /// <returns>A new instance of <see cref="Bookkeepr.Application.IDomain"/></returns>
        public IDomain Create(IDataSource dataSource)
        {
            var result = container.Resolve<Domain>(new PositionalParameter(0, container), new PositionalParameter(1, dataSource));

            Contract.Assume(result != null);

            return result;
        }
Ejemplo n.º 25
0
        public override Task FinishApplyAsync(IDataSource dataSource, string localPath, bool updateSucceeded, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            return updateSucceeded ?
                Task.Run(() => File.Move(this.RelativePath, this.NewRelativePath)) :
                Task.FromResult(false);
        }
Ejemplo n.º 26
0
			public void SetUp()
			{
				log = Substitute.For<ILog>();
				fileSystem = Substitute.For<IFileSystem>();
				dataSource = Substitute.For<IDataSource>();
				
				createSiteCommand = new CreateSiteCommand(log, fileSystem, dataSource);
			}
Ejemplo n.º 27
0
 // This is only used for expressions
 public NxObjectRef(IDataSource ds, string id)
 {
     m_ref = id;
     m_asm = ds.Assembly;
     m_cls = ds.Class;
     m_runat = RunAt.Both.ToString();
     m_enumerator = ds.GetAttributeEnumerator();
 }
 public SqlExecutorEventArgs(string sql, IDataSource ds, IList parameters, bool postPoned)
     : base()
 {
     m_Sql = sql;
     m_DataSource = ds;
     m_Parameters = parameters;
     m_PostPoned = postPoned;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaterializerCompilerEventArgs" /> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="sql">The SQL.</param>
 /// <param name="code">The code.</param>
 /// <param name="targetType">Type of the target.</param>
 /// <param name="exception">The exception.</param>
 public MaterializerCompilerEventArgs(IDataSource dataSource, string sql, string code, Type targetType, Exception exception = null)
 {
     Exception = exception;
     TargetType = targetType;
     Code = code;
     Sql = sql;
     DataSource = dataSource;
 }
Ejemplo n.º 30
0
 public ControllerDataSourceView(IDataSource owner, string viewName) :
     base(owner, viewName)
 {
     _owner = ((ControllerDataSource)(owner));
 }
Ejemplo n.º 31
0
 public DbEntryDataSourceView(IDataSource owner, string viewName)
     : base(owner, viewName)
 {
     this._owner = (IExcuteableDataSource)owner;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Returns the right IHttpHandler for the current request
        /// </summary>
        /// <param name="context">The current HttpContext</param>
        /// <param name="requestType">The current RequestType (HTTP verb)</param>
        /// <param name="url">The requestes Url</param>
        /// <param name="pathTranslated">The translated physical path</param>
        /// <param name="container">The container.</param>
        /// <returns>The right IHttpHandler instance for the current request</returns>
        protected override IHttpHandler GetHandlerCore(HttpContext context, string requestType, string url, string pathTranslated, IContainer container)
        {
            context        = Enforce.NotNull(context, () => context);
            requestType    = Enforce.NotNullOrEmpty(requestType, () => requestType);
            url            = Enforce.NotNullOrEmpty(url, () => url);
            pathTranslated = Enforce.NotNullOrEmpty(pathTranslated, () => pathTranslated);

            // Get the mapping for the requested name.
            IMapping mapping = null;

            // Try fetch the Mapping with identifier.
            string id = this.Data.Trim('/');

            if (id != null && id.IsGuid())
            {
                mapping =
                    this._mappingService.ReadMapping(
                        SessionFacade.GetSessionValue <IUser>(SessionFacadeKey.CurrentlyLoggedOnUser),
                        id.ToOrDefault <Guid>());

                if (mapping == null)
                {
                    throw new SilkveilException(String.Format(CultureInfo.CurrentCulture,
                                                              "The id '{0}' is invalid.", id));
                }
            }
            else
            {
                // Try fetch the Mapping with name.
                if (!String.IsNullOrEmpty(id))
                {
                    mapping =
                        this._mappingService.ReadMappingByName(
                            SessionFacade.GetSessionValue <IUser>(SessionFacadeKey.CurrentlyLoggedOnUser),
                            id);

                    if (mapping == null)
                    {
                        throw new SilkveilException(String.Format(CultureInfo.CurrentCulture,
                                                                  "The name '{0}' is invalid.", id));
                    }
                }
            }

            // No valid guid or name is provided, fail.
            if (mapping == null)
            {
                throw new MappingNotFoundException(
                          String.Format(
                              CultureInfo.CurrentCulture, "There was no mapping found for ID '{0}'.", id));
            }

            // Get the data source that holds the download and write the download to the output stream.
            IDataSource dataSource = DataSourceFactory.GetMappedDataSource(mapping, container);

            DownloadHandler handler = new DownloadHandler();

            // Grab the right Handler correnspondents to our Mapping, if there any source authentication set
            if (mapping.SourceAuthentication != null)
            {
                switch (mapping.SourceAuthentication.AuthenticationType)
                {
                case AuthenticationType.HttpBasicAuthentication:
                    handler.AuthenticationStrategy = new HttpBasicAuthentication();
                    break;

                case AuthenticationType.HttpDigestAuthentication:
                    handler.AuthenticationStrategy = new HttpDigestAuthentication();
                    break;
                }

                // Set properties needed for the autentication strategy.
                handler.AuthenticationStrategy.Realm    = mapping.Id.ToString();
                handler.AuthenticationStrategy.UserName = mapping.SourceAuthentication.UserName;
                handler.AuthenticationStrategy.Password = mapping.SourceAuthentication.Password;
            }

            // Set Mapping and DataSource to the handlers properties
            handler.Mapping    = mapping;
            handler.DataSource = dataSource;

            return(handler);
        }
Ejemplo n.º 33
0
        public HttpResponseMessage Update(JObject json)
        {
            try
            {
                var    module          = new OpenContentModuleInfo(ActiveModule);
                string editRole        = module.Settings.Template.Manifest.GetEditRole();
                int    createdByUserid = -1;

                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                IDataItem dsItem = null;
                if (module.IsListMode())
                {
                    if (json["id"] != null)
                    {
                        var itemId = json["id"].ToString();
                        dsItem = ds.Get(dsContext, itemId);
                        if (dsItem != null)
                        {
                            createdByUserid = dsItem.CreatedByUserId;
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                    if (dsItem != null)
                    {
                        createdByUserid = dsItem.CreatedByUserId;
                    }
                }

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                if (dsItem == null)
                {
                    ds.Add(dsContext, json["form"] as JObject);
                }
                else
                {
                    ds.Update(dsContext, dsItem, json["form"] as JObject);
                }
                if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String)
                {
                    string moduleTitle = json["form"]["ModuleTitle"].ToString();
                    OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                }
                else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object)
                {
                    if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null)
                    {
                        string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString();
                        OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle);
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Ejemplo n.º 34
0
 public DataSourceView(IDataSource owner)
     : base(owner, DefaultViewName)
 {
 }
Ejemplo n.º 35
0
 public void ClearQuotes(Asset asset, IDataSource source)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 36
0
 /// <summary>
 /// SqlMapSession
 /// </summary>
 /// <param name="sqlMapper"></param>
 public SqlMapSession(ISqlMapper sqlMapper)
 {
     _dataSource = sqlMapper.DataSource;
     _sqlMapper  = sqlMapper;
 }
Ejemplo n.º 37
0
        private void init()
        {
            // 设置RenderControl控件为球

            string tmpTedPath = (strMediaPath + @"\terrain\SingaporeGlobeTerrain.ted");

            wkt = this.axRenderControl1.GetTerrainCrsWKT(tmpTedPath, "");
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", "OpenGL");
            this.axRenderControl1.Initialize2(wkt, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 注册地形
            this.axRenderControl1.Terrain.RegisterTerrain(tmpTedPath, "");
            this.axRenderControl1.Terrain.FlyTo(gviTerrainActionCode.gviFlyToTerrain);

            #region 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            //bool hasfly = false;
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);

                    //if (!hasfly)
                    //{
                    //    IFieldInfoCollection fieldinfos = fc.GetFields();
                    //    IFieldInfo fieldinfo = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                    //    IGeometryDef geometryDef = fieldinfo.GeometryDef;
                    //    IEnvelope env = geometryDef.Envelope;
                    //    if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                    //        env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                    //        continue;
                    //    angle.Set(0, -20, 0);
                    //    point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                    //    point.SpatialCRS = fc.FeatureDataSet.SpatialReference;
                    //    point.SetCoords(env.Center.X, env.Center.Y, env.Center.Z, 0, 0);
                    //    this.axRenderControl1.Camera.LookAt2(point, 500, angle);
                    //}
                    //hasfly = true;
                }
            }
            #endregion
        }
Ejemplo n.º 38
0
        public XggSubfile(IDataSource Source, string Name, string Archive) : base(Source, Name, Archive)
        {
            _name = Name.Replace(".xgg", ".wav");
#warning change to a bitrate scaled estimate
            _size = Source.Size * 30; //fast estimate
        }
Ejemplo n.º 39
0
        public RecipeView(IDataSource dataSource) : base("Recipes")
        {
            _dataSource = dataSource;

            var recipesFrame = new FrameView("Recipe")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Percent(35),
                Height = Dim.Percent(33),
            };

            var usedInFrame = new FrameView("Used In")
            {
                X      = 0,
                Y      = Pos.Bottom(recipesFrame),
                Width  = Dim.Percent(35),
                Height = Dim.Percent(50),
            };

            var upgradeFrame = new FrameView("Upgrade")
            {
                X      = 0,
                Y      = Pos.Bottom(usedInFrame),
                Width  = Dim.Percent(35),
                Height = Dim.Fill(),
            };

            var contentFrame = new FrameView("Content")
            {
                X      = Pos.Right(recipesFrame),
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            var contentView1 = new Label("")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            _recipesView = new RecipesView(new List <string>(), contentView1)
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            _usedInView = new RecipesView(new List <string>(), contentView1)
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            _upgradeView = new RecipesView(new List <string>(), contentView1)
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(),
            };

            recipesFrame.Add(_recipesView);
            usedInFrame.Add(_usedInView);
            upgradeFrame.Add(_upgradeView);

            contentFrame.Add(contentView1);

            base.Add(recipesFrame);
            base.Add(usedInFrame);
            base.Add(upgradeFrame);
            base.Add(contentFrame);
        }
 public static bool ContainsListCollection(IDataSource dataSource)
 {
     return(default(bool));
 }
 /// <summary>
 /// Creates a new instance of a ParticipantController object, and initializes it with the specified properties.
 /// </summary>
 /// <param name="datasource"></param>
 /// <param name="mailClient"></param>
 public ParticipantController(IDataSource datasource, MailClient mailClient)
 {
     _dataSource = datasource;
     _mailClient = mailClient;
 }
Ejemplo n.º 42
0
 protected virtual void OnDataSourceAvailable(IDataSource dataSource)
 {
     this.DataSourceAvailable?.Invoke(this, new DataSourceEventArgs(dataSource));
 }
Ejemplo n.º 43
0
 public ReservationRepository(IDataSource dataSource) : base(dataSource)
 {
     Data = dataSource.LoadReservation();
 }
Ejemplo n.º 44
0
 public bool IsExcluded(IDataSource dataSource)
 {
     return(Settings.ExcludedDataSources.Contains(dataSource.Id));
 }
Ejemplo n.º 45
0
 IStructuralNodeProvider IFormatReader.Read(IDataSource data) => null;
Ejemplo n.º 46
0
 public RobotFactory(IDataSource db)
 {
     this.db = db;
 }
 /// <summary>
 /// Creates a new instance of a ScheduleController object.
 /// </summary>
 /// <param name="dataSource"></param>
 public ScheduleController(IDataSource dataSource)
 {
     _dataSource = dataSource;
 }
 public UnitOfWork(IDataSource data)
 {
     dataSource = data;
 }
Ejemplo n.º 49
0
        public HttpResponseMessage Lookup(LookupRequestDTO req)
        {
            var module = new OpenContentModuleInfo(req.moduleid, req.tabid);

            if (module == null)
            {
                throw new Exception($"Can not find ModuleInfo (tabid:{req.tabid}, moduleid:{req.moduleid})");
            }

            List <LookupResultDTO> res = new List <LookupResultDTO>();

            try
            {
                IDataSource ds        = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID);

                if (module.IsListMode())
                {
                    var items = ds.GetAll(dsContext, null).Items;
                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            var json = item.Data;

                            if (!string.IsNullOrEmpty(req.dataMember) && json[req.dataMember] != null)
                            {
                                json = json[req.dataMember];
                            }

                            var array = json as JArray;
                            if (array != null)
                            {
                                res.AddRange(array.Select(childItem =>
                                                          new LookupResultDTO
                                {
                                    value = string.IsNullOrEmpty(req.valueField) || childItem[req.valueField] == null ? "" : childItem[req.valueField].ToString(),
                                    text  = string.IsNullOrEmpty(req.textField) || childItem[req.textField] == null ? "" : childItem[req.textField].ToString()
                                }
                                                          )
                                             );
                            }
                            else
                            {
                                res.Add(new LookupResultDTO
                                {
                                    value = string.IsNullOrEmpty(req.valueField) || json[req.valueField] == null ? item.Id : json[req.valueField].ToString(),
                                    text  = string.IsNullOrEmpty(req.textField) || json[req.textField] == null ? item.Title : json[req.textField].ToString()
                                });
                            }
                        }
                    }
                }
                else
                {
                    dsContext.Single = true;
                    var struc = ds.Get(dsContext, null);
                    if (struc != null)
                    {
                        JToken json = struc.Data;
                        if (!string.IsNullOrEmpty(req.dataMember))
                        {
                            json = json[req.dataMember];
                            if (json is JArray)
                            {
                                foreach (JToken item in (JArray)json)
                                {
                                    res.Add(new LookupResultDTO()
                                    {
                                        value = item[req.valueField] == null ? "" : item[req.valueField].ToString(),
                                        text  = item[req.textField] == null ? "" : item[req.textField].ToString()
                                    });
                                }
                            }
                        }
                    }
                }
                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
 public T CreateSource <T>(IDataSource inSource = null, ILookUpEngine configurationProvider = null) where T : IDataSource
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 51
0
        public HttpResponseMessage Edit(string id)
        {
            try
            {
                var moduleInfo = new OpenContentModuleInfo(ActiveModule);

                IDataSource ds        = DataSourceManager.GetDataSource(moduleInfo.Settings.Manifest.DataSource);
                var         dsContext = OpenContentUtils.CreateDataContext(moduleInfo);

                IDataItem dsItem = null;
                if (moduleInfo.IsListMode())
                {
                    if (!string.IsNullOrEmpty(id)) // not a new item
                    {
                        dsItem = ds.Get(dsContext, id);
                    }
                }
                else
                {
                    dsContext.Single = true;
                    dsItem           = ds.Get(dsContext, null);
                }
                int createdByUserid = -1;
                var json            = ds.GetAlpaca(dsContext, true, true, true);
                if (dsItem != null)
                {
                    json["data"] = dsItem.Data;
                    if (json["schema"]["properties"]["ModuleTitle"] is JObject)
                    {
                        if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.String)
                        {
                            json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle;
                        }
                        else if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.Object)
                        {
                            json["data"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] = ActiveModule.ModuleTitle;
                        }
                    }
                    var versions = ds.GetVersions(dsContext, dsItem);
                    if (versions != null)
                    {
                        json["versions"] = versions;
                    }
                    createdByUserid = dsItem.CreatedByUserId;
                }

                var context       = new JObject();
                var currentLocale = DnnLanguageUtils.GetCurrentLocale(PortalSettings.PortalId);
                context["culture"]                = currentLocale.Code; //todo why not use  DnnLanguageUtils.GetCurrentCultureCode() ???
                context["defaultCulture"]         = LocaleController.Instance.GetDefaultLocale(PortalSettings.PortalId).Code;
                context["numberDecimalSeparator"] = currentLocale.Culture.NumberFormat.NumberDecimalSeparator;
                context["rootUrl"]                = System.Web.VirtualPathUtility.ToAbsolute(string.Concat(System.Web.HttpRuntime.AppDomainAppVirtualPath, "/"));
                context["alpacaCulture"]          = AlpacaEngine.AlpacaCulture(currentLocale.Code);
                context["bootstrap"]              = OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.GetEditLayout() != AlpacaLayoutEnum.DNN;
                context["horizontal"]             = OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.GetEditLayout() == AlpacaLayoutEnum.BootstrapHorizontal;
                json["context"] = context;

                //todo: can't we do some of these checks at the beginning of this method to fail faster?
                if (!OpenContentUtils.HasEditPermissions(PortalSettings, moduleInfo.ViewModule, moduleInfo.Settings.Manifest.GetEditRole(), createdByUserid))
                {
                    return(Request.CreateResponse(HttpStatusCode.Unauthorized));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, json));
            }
            catch (Exception exc)
            {
                Log.Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Ejemplo n.º 52
0
 public OrderManager(IDataSource dataSource) : base(dataSource)
 {
 }
 public static System.Collections.IList GetList(IDataSource dataSource)
 {
     return(default(System.Collections.IList));
 }
Ejemplo n.º 54
0
 public SingleRowMiniBatch(IDataSource dataSource, IGraphData data, bool isSequential, MiniBatchSequenceType sequenceType, int sequenceIndex)
 {
     CurrentSequence = new Sequence(new[] { data }, this, sequenceType, sequenceIndex);
     DataSource      = dataSource;
     IsSequential    = isSequential;
 }
Ejemplo n.º 55
0
        public static async Task <string> GetLiveId(IDataSource dataSource, string input)
        {
            //LIVE_ID
            //CHANNEL_ID
            //https://www.openrec.tv/live/CHANNEL_ID
            //https://www.openrec.tv/live/LIVE_ID
            //https://www.openrec.tv/user/CHANNEL_ID

            string id;
            var    match = Regex.Match(input, "openrec\\.tv/(?:live|movie|user)/(?<id>[^?/&]+)");

            if (match.Success)
            {
                id = match.Groups[1].Value;
            }
            else
            {
                var match1 = Regex.Match(input, "^([^?/\\.&=]+)$");
                if (match1.Success)
                {
                    id = match1.Groups[1].Value;
                }
                else
                {
                    throw new InvalidInputException();
                }
            }
            try
            {
                var movies = await API.GetChannelMovies(dataSource, id);

                if (movies.Length == 0)
                {
                    return(id);//恐らくLiveId
                }
                var onairMovies = movies.Where(s => s.OnairStatus == 1).ToList();
                var ntk         = onairMovies.Select(k => k.Id).ToList();
                if (ntk.Count == 0)
                {
                    //存在しないか配信中ではない
                    //throw new TestException("入力されたチャンネルIDは存在しないか配信中ではありません。");
                    throw new InvalidInputException();
                }
                else if (ntk.Count > 1)
                {
                    //複数
                    throw new Exception("このチャンネルには配信中の番組が複数あります。");
                }
                else
                {
                    var liveId = ntk[0];
                    return(liveId);
                }
            }
            catch (WebException ex)
            {
            }
            return(id);
            //if (Tools.IsValidUrl(input))
            //{
            //    return Tools.ExtractLiveId(input);
            //}
            //else if (Tools.IsValidChannelUrl(input))
            //{
            //    var channelId = Tools.ExtractChannelId(input);
            //    var movies = await API.GetMovies(_dataSource, channelId);
            //    var onairMovies = movies.Where(s => s.OnairStatus == 1).ToList();
            //    if(onairMovies.Count == 0)
            //    {

            //    }
            //    else if(onairMovies.Count > 1)
            //    {

            //    }
            //    else
            //    {
            //        var liveId = onairMovies[0].Id;
            //        return liveId;
            //    }
            //}
            //else if (Tools.IsValidMovieId(input))
            //{
            //    return input;
            //}
            //else
            //{
            //    throw new InvalidInputException();
            //}
        }
Ejemplo n.º 56
0
 public Poller()
 {
     CList = new CandidateList();
     Data  = new XmlDataSource(CList);
     Calc  = new PollCalculator(CList);
 }
Ejemplo n.º 57
0
        public void Initialize()
        {
            // Initializes the mock RequestListener
            ProducerListenerImpl producerListener = new ProducerListenerImpl(
                (_, __) => { },
                (_, __, ___) => { },
                (_, __, ___) => { },
                (_, __, ___, ____) => { },
                (_, __, ___) => { },
                (_) => { return(false); });

            _requestListener = new RequestListenerImpl(
                producerListener,
                (imageRequest, callerContext, requestId, isPrefetch) =>
            {
                _onRequestStartInvocation = true;
                _internalImageRequest     = imageRequest;
                _internalCallerContext    = callerContext;
                _internalRequestId        = requestId;
                _internalIsPrefetch       = isPrefetch;
            },
                (imageRequest, requestId, isPrefetch) =>
            {
                _onRequestSuccessInvocation = true;
                _internalImageRequest       = imageRequest;
                _internalRequestId          = requestId;
                _internalIsPrefetch         = isPrefetch;
            },
                (imageRequest, requestId, exception, isPrefetch) =>
            {
                _onRequestFailureInvocation = true;
                _internalImageRequest       = imageRequest;
                _internalRequestId          = requestId;
                _internalException          = exception;
                _internalIsPrefetch         = isPrefetch;
            },
                (requestId) =>
            {
                _onRequestCancellationInvocation = true;
                _internalRequestId = requestId;
            });
            _result1 = new object();
            _result2 = new object();
            _result3 = new object();

            _dataSubscriber1 = new MockDataSubscriber <object>();
            _dataSubscriber2 = new MockDataSubscriber <object>();

            _internalIsPrefetch      = true;
            _settableProducerContext = new SettableProducerContext(
                IMAGE_REQUEST,
                REQUEST_ID,
                producerListener,
                CALLER_CONTEXT,
                RequestLevel.FULL_FETCH,
                IS_PREFETCH,
                true,
                Priority.HIGH);
            _producer = new ProducerImpl <object>(
                (consumer, _) =>
            {
                _internalConsumer = consumer;
            });
            _dataSource = ProducerToDataSourceAdapter <object> .Create(
                _producer,
                _settableProducerContext,
                _requestListener);

            Assert.IsTrue(_onRequestStartInvocation);
            Assert.AreSame(_internalImageRequest, IMAGE_REQUEST);
            Assert.AreSame(_internalCallerContext, CALLER_CONTEXT);
            Assert.AreSame(_internalRequestId, REQUEST_ID);
            Assert.IsFalse(_internalIsPrefetch);
            Assert.IsNotNull(_internalConsumer);
            _onRequestStartInvocation = false;

            _dataSource.Subscribe(_dataSubscriber1, CallerThreadExecutor.Instance);
        }
Ejemplo n.º 58
0
 public SearchDataSourceView(IDataSource owner, string viewName) : base(owner, viewName)
 {
     Owner = (SearchDataSource)owner;
 }
Ejemplo n.º 59
0
 public AddEmployeeViewModel(IDataSource <Employee> dataSource)
 {
     _dataSource = dataSource;
     Init();
 }