示例#1
0
        /// <summary>
        /// Validates the data object while executing DeleteFromStore.
        /// </summary>
        /// <returns>
        /// A collection of validation results.
        /// </returns>
        protected override IEnumerable <ValidationResult> ValidateForDelete()
        {
            // Validate Trajectory uid property
            if (string.IsNullOrWhiteSpace(DataObject.UidWell) || string.IsNullOrWhiteSpace(DataObject.UidWellbore) || string.IsNullOrWhiteSpace(DataObject.Uid))
            {
                yield return(new ValidationResult(ErrorCodes.DataObjectUidMissing.ToString(), new[] { "Uid", "UidWell", "UidWellbore" }));
            }
            else
            {
                var uri      = DataObject.GetUri();
                var stations = DataObject.TrajectoryStation;
                if (stations != null)
                {
                    foreach (var validationResult in ValidateTrajectoryStations(stations))
                    {
                        yield return(validationResult);
                    }
                }

                var current = DataAdapter.Get(uri);

                // Validate Trajectory does not exist
                if (current == null)
                {
                    yield return(new ValidationResult(ErrorCodes.DataObjectNotExist.ToString(), new[] { "Uid", "UidWell", "UidWellbore" }));
                }
            }
        }
示例#2
0
 /// <summary>
 /// Bindet die CheckBox an eine Datenquelle
 /// </summary>
 /// <param name="Adapter">Datenquelle</param>
 /// <param name="BitPosition">Bit Position die verwendet werden soll</param>
 public void Bind(DataAdapter <byte> Adapter, int BitPosition)
 {
     this.Adapter         = Adapter;
     this.BitPosition     = BitPosition;
     Adapter.DataChanged += Adapter_DataChanged;
     Adapter_DataChanged(Adapter.Value, null);
 }
        public virtual bool DeleteStudy(IStudyId study)
        {
            long studyKey = GetStudyKey(DataAdapter, study);


            return(DataAdapter.CreateDeleteStudyCommand(studyKey).Execute( ));
        }
示例#4
0
        public Order GetByName(string OrderNumber)
        {
            Order order = null;

            Con             = CreateConnection();
            Query           = "SelectOrder";
            Com.CommandText = Query;
            Com.Connection  = Con;
            Com.CommandType = CommandType.StoredProcedure;

            Com.Parameters.Clear();

            Com.Parameters.Add(new SqlParameter("@OrderNumber", OrderNumber));

            DataAdapter.SelectCommand = Com;

            DataTable dataTable = new DataTable();

            DataAdapter.Fill(dataTable);

            foreach (DataRow row in dataTable.Rows)
            {
                order = new Order.Builder()
                        .setCustomerNumber(row["customerID"].ToString())
                        .setOrderNumber(row["ordernumber"].ToString())
                        .setDate(Convert.ToDateTime(row["datecreated"].ToString()))
                        .Build();

                GetItemsAsync(OrderNumber).Result.ForEach(i => order.Products.Add(i));
            }

            return(order);
        }
        public virtual bool DeleteSeries(ISeriesId series)
        {
            long seriesKey = GetSeriesKey(DataAdapter, series);


            return(DataAdapter.CreateDeleteSeriesCommand(seriesKey).Execute( ));
        }
        public static DataSet Query(string commandText, IDictionary <string, object> parameters)
        {
            DbConnection connection = null;
            DbCommand    command    = DbProviderFactory.CreateCommand();

            try
            {
                command.CommandText = commandText;
                parameters          = parameters ?? new Dictionary <string, object>();
                foreach (var item in parameters)
                {
                    command.Parameters.Add(BuildDbParameter(item.Key, item.Value));
                }
                connection = DbProviderFactory.CreateConnection();
                connection.ConnectionString = ConnectionString;
                command.Connection          = connection;
                connection.Open();
                DataAdapter adapter = DbProviderFactory.CreateDataAdapter();
                DataSet     ds      = new DataSet();
                adapter.Fill(ds);
                return(ds);
            }
            catch (SqlException e)
            {
                throw e;
            }
            finally
            {
                connection.Close();
                connection.Dispose();
            }
        }
示例#7
0
        /// <summary>
        /// Validates the data object while executing UpdateInStore.
        /// </summary>
        /// <returns>
        /// A collection of validation results.
        /// </returns>
        protected override IEnumerable <ValidationResult> ValidateForUpdate()
        {
            // Validate MudLog uid property
            if (string.IsNullOrWhiteSpace(DataObject.UidWell) || string.IsNullOrWhiteSpace(DataObject.UidWellbore) || string.IsNullOrWhiteSpace(DataObject.Uid))
            {
                yield return(new ValidationResult(ErrorCodes.DataObjectUidMissing.ToString(), new[] { "Uid", "UidWell", "UidWellbore" }));
            }
            else
            {
                var uri = DataObject.GetUri();
                var geologyIntervals = DataObject.GeologyInterval;
                if (geologyIntervals != null)
                {
                    foreach (var validationResult in ValidateMudlogGeologyIntervals(geologyIntervals))
                    {
                        yield return(validationResult);
                    }
                }

                var current = DataAdapter.Get(uri);

                // Validate MudLog does not exist
                if (current == null)
                {
                    yield return(new ValidationResult(ErrorCodes.DataObjectNotExist.ToString(), new[] { "Uid", "UidWell", "UidWellbore" }));
                }
            }
        }
        public RegisterFileMap()
        {
            Data = new DataAdapter<byte>[RegisterConstants.REGISTER_FILE_MAP_SIZE];  // Data[256] <= Working Register
            for (int X = 0; X < Data.Length; X++)
            {
                Data[X] = new DataAdapter<byte>();
            }

            // I/O Ports as IOAdapter
            Data[RegisterConstants.PORTA_ADDRESS] = new IOAdapter(this, RegisterConstants.PORTA_ADDRESS);
            Data[RegisterConstants.PORTB_ADDRESS] = new IOAdapter(this, RegisterConstants.PORTB_ADDRESS);

            // link mirrored registers
            Data[RegisterConstants.INDF_BANK1_ADDRESS] = Data[RegisterConstants.INDF_ADDRESS];
            Data[RegisterConstants.PCL_BANK1_ADDRESS] = Data[RegisterConstants.PCL_ADDRESS];
            Data[RegisterConstants.STATUS_BANK1_ADDRESS] = Data[RegisterConstants.STATUS_ADDRESS];
            Data[RegisterConstants.FSR_BANK1_ADDRESS] = Data[RegisterConstants.FSR_ADDRESS];
            Data[RegisterConstants.PCLATH_BANK1_ADDRESS] = Data[RegisterConstants.PCLATH_ADDRESS];
            Data[RegisterConstants.INTCON_BANK1_ADDRESS] = Data[RegisterConstants.INTCON_ADDRESS];

            for (int X = 0; X < Data.Length; X++)
            {
                Data[X].Value = 0;
            }

            initializeValues();
        }
示例#9
0
        private bool Insert(string area, string name, string color, string position, int quantity, string userName, string memo)
        {
            DataAdapter da     = new DataAdapter();
            var         result = da.Insert(area, name, color, position, quantity, userName, memo);

            return(result == 1);
        }
示例#10
0
        /// <summary>
        /// Disable EWS Server functions that aren't needed in this solution and enable those that are.
        /// </summary>
        private void EnsureSupportedMethods()
        {
            CheckCancellationToken();

            DataAdapter.ModifyServerSupportedMethods(new EwsServerMethods
            {
                AcknowledgeAlarmEvents = false,
                ForceValues            = false,
                GetAlarmEventTypes     = false,
                GetAlarmEvents         = false,
                GetAlarmHistory        = false,
                GetEnums = false,
                GetHierarchicalInformation = false,
                GetUpdatedAlarmEvents      = false,
                UnforceValues = false,

                GetContainerItems        = true,
                GetHistory               = true,
                GetItems                 = true,
                GetNotification          = true,
                GetValues                = true,
                GetWebServiceInformation = true,
                Renew       = true,
                SetValues   = true,
                Subscribe   = true,
                Unsubscribe = true
            });
        }
示例#11
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Product   product = dbc.GetRandomProduct();
                DataTable table   = new DataTable();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { product.ProductId });

                DataAdapter.Fill(table);

                if (table.Columns.Count != (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                                            + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                {
                    Fail("Number of returned columns is incorrect");
                }

                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
示例#12
0
        protected override IEnumerable <Prompt> Execute_Subclass()
        {
            // Make sure we can connect to an EWS Server
            if (!IsConnected)
            {
                return new List <Prompt> {
                           CreateCannotConnectPrompt()
                }
            }
            ;

            // If the server isn't running, start it now.
            if (!DataAdapter.Server.IsRunning)
            {
                DataAdapter.StartServer();
            }

            // Confirm that the server settings are how we want them be.
            EnsureServerParameters();

            // Add the fields a client can use to "set" the location
            AddUserInputFields();

            // Add the folders and data points where we'll write the current weather conditions (in UpdateProcessor)
            AddCurrentConditionPlaceHolders();

            // Add the folders and data points where we'll write the forecast (in UpdateProcessor)
            AddForecastPlaceHolders();

            // Return any issues
            return(new List <Prompt>());
        }
示例#13
0
        private async Task DeleteById(MessageEvent mev, string[] messageSpilt)
        {
            int id;

            if (messageSpilt.Count() != 2)
            {
                await messagingClient.ReplyMessageAsync(mev.ReplyToken, new List <ISendMessage> {
                    new TextMessage("更新指令錯誤!!\n - [編號]")
                });

                return;
            }
            if (!int.TryParse(messageSpilt[1], out id))
            {
                await messagingClient.ReplyMessageAsync(mev.ReplyToken, new List <ISendMessage> {
                    new TextMessage("參數錯誤!\n輸入的編號不是數字!")
                });

                return;
            }
            DataAdapter da           = new DataAdapter();
            var         result       = da.DelectByID(id);
            var         replyMessage = "刪除失敗";

            if (result == 1)
            {
                replyMessage = "刪除成功";
            }
            await messagingClient.ReplyMessageAsync(mev.ReplyToken, new List <ISendMessage> {
                new TextMessage(replyMessage)
            });
        }
示例#14
0
 public void Execute(string dbName, string sqlStr)
 {
     using (CJia.DataAdapter ada = new DataAdapter(dbName))
     {
         ada.Execute(sqlStr);
     }
 }
示例#15
0
        public S_FileInfo(string ID, S_DOC_Space space)
        {
            this._initEntity();
            if (space == null)
            {
                throw new Formula.Exceptions.BusinessException("档案配置对象未空,无法实例化编目节点对象");
            }
            this.Space      = space;
            this.InstanceDB = SQLHelper.CreateSqlHelper(this.Space.SpaceKey, this.Space.ConnectString);
            string sql = String.Format("select * from {0} where ID='{1}' ", TableName, ID);
            var    dt  = this.InstanceDB.ExecuteDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                var row = dt.Rows[0];
                _validateColumns(row);
                DataAdapter.DataRowToHashTable(row, this.DataEntity);
                this.ConfigInfo = this.Space.S_DOC_File.FirstOrDefault(d => d.ID == this.DataEntity["ConfigID"].ToString());
                if (this.ConfigInfo == null)
                {
                    throw new Formula.Exceptions.BusinessException("未找到ID为【" + this.DataEntity["ConfigID"].ToString() + "】编目定义对象,无法实例化编目节点对象");
                }
            }
            else
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + ID + "】的编目节点");
            }
        }
示例#16
0
        private void LoadDistressMapping()
        {
            string query = "SELECT * FROM PCI_DISTRESS";

            if (pciDistressMapAdapter != null)
            {
                pciDistressMapAdapter.Dispose();                                           // Free up the resources
            }
            if (binding != null)
            {
                binding.Dispose();
            }
            if (table != null)
            {
                table.Dispose();
            }

            pciDistressMapAdapter = new DataAdapter(query);

            // Populate a new data table and bind it to the BindingSource.
            table        = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            pciDistressMapAdapter.Fill(table);
            binding                       = new BindingSource();
            binding.DataSource            = table;
            dgvDistressMapping.DataSource = binding;
        }
示例#17
0
        /// <summary>
        /// Execute the SQL Query and return in DataTable, then Close the connection automatically
        /// </summary>
        /// <param name="sql">SQL Query</param>
        /// <returns>Data Table</returns>
        public DataTable Read(string sql)
        {
            DataTable dt = null;

            try
            {
                dt                      = new DataTable();
                _connection             = new OleDbConnection(this.ConnectionString);
                _command                = new OleDbCommand(sql);
                _command.CommandTimeout = this.m_time_out;
                _command.Connection     = _connection;
                _connection.Open();
                DataAdapter.SelectCommand = _command;
                DataAdapter.Fill(dt);
            }
            catch (Exception e)
            {
                throw new Exception("Err in Read():" + e.Message);
            }
            finally
            {
                this.Close();
            }
            return(dt);
        }
示例#18
0
        public virtual bool DeleteInstance(IObjectId instance)
        {
            long instanceKey = GetInstanceKey(DataAdapter, instance);


            return(DataAdapter.CreateDeleteInstancCommand(instanceKey).Execute( ));
        }
示例#19
0
        public decimal CalculateCostIndex(DateTime date, DateTime toDate, uint supplierId, ulong regionId, Hashtable quantities)
        {
            decimal result = 0;

            var command = DataAdapter.SelectCommand;

            command.CommandText = @"
select a.ProductId, a.ProducerId, a.Cost
from Reports.AverageCosts a
join Reports.AverageCosts a1 on a.SupplierId = a1.SupplierId and a.RegionId = a1.RegionId
and a.ProductId = a1.ProductId and a.ProducerId = a1.ProducerId and a1.Date = ?toDate
where a.SupplierId = ?supplierId
and a.RegionId = ?regionId
and a.Date = ?date
";
            command.Parameters.Clear();
            command.Parameters.AddWithValue("supplierId", supplierId);
            command.Parameters.AddWithValue("regionId", regionId);
            command.Parameters.AddWithValue("date", date);
            command.Parameters.AddWithValue("toDate", toDate);
            var table = new DataTable();

            DataAdapter.Fill(table);
            foreach (DataRow row in table.Rows)
            {
                var quantiry = quantities[row["ProductId"] + "|" + row["ProducerId"]];
                if (quantiry == null)
                {
                    continue;
                }
                result += Convert.ToDecimal(row["Cost"]) * Convert.ToDecimal(quantiry);
            }
            return(result);
        }
示例#20
0
        public DataTable ExecuteSelectQuery(string _query, SqlParameter[] parameters)
        {
            SqlCommand command   = new SqlCommand();
            DataTable  dataTable = null;
            DataSet    ds        = new DataSet();

            try
            {
                command.Connection  = open();
                command.CommandText = _query;
                command.Parameters.AddRange(parameters);
                command.ExecuteNonQuery();
                DataAdapter.SelectCommand = command;
                DataAdapter.Fill(ds);
                dataTable = ds.Tables[0];
            }
            catch (Exception ex)
            {
                writeError($"Requête : {_query} \nSqlException : {ex.StackTrace.ToString()}");
            }
            finally
            {
                Connection.Close();
            }

            return(dataTable);
        }
示例#21
0
        public static TransactionModel[] GetByMonth(int month, int year)
        {
            using (OleDbConnection conn = DatabaseManager.GetConnection())
            {
                OleDbCommand cmd = conn.CreateCommand();

                cmd.CommandText = string.Format(
                    @"SELECT [transac.codeTransaction]  AS codeTransaction,
                         [transac.dateTransaction]  AS dateTransaction, 
                         [transac.description]      AS description,
                         [transac.montant]          AS montant,
                         [transac.recetteON]        AS recetteON,
                         [transac.percuON]          AS percuON,
                         [transac.type]             AS [type],
                         [typeTransac.libType]      AS typeTransaction_s

                      FROM [{0}] transac, [{1}] typeTransac

                      WHERE Month(dateTransaction) = {2}
                              AND Year(dateTransaction) = {3}
                              AND typeTransac.codeType = transac.type",

                    TABLE_NAME, TypeTransactionRepository.TABLE_NAME, month, year
                    );

                conn.Open();
                return(DataAdapter.OleDbDataReaderToStruct <TransactionRepository.TransactionModel>(cmd.ExecuteReader()).ToArray());
            }
        }
示例#22
0
        private Hashtable GetQuantities()
        {
            var begin = date.AddMonths(-1);
            var end   = date;

            //join Catalogs.Catalog c on c.Id = p.CatalogId вроде бы не нужен
            //но без него оптимизатор строит неправильный план
            command.CommandText = String.Format(@"
select ol.ProductId, ol.CodeFirmCr as ProducerId, sum(ol.Quantity) as quantity
from {0}.OrdersHead oh
join {0}.OrdersList ol on oh.RowId = ol.OrderId
join Catalogs.Products p on p.Id = ol.ProductId
join Catalogs.Catalog c on c.Id = p.CatalogId
join Catalogs.Assortment a on a.CatalogId = c.Id and a.ProducerId = ol.CodeFirmCr
join usersettings.pricesdata pd on pd.PriceCode = oh.PriceCode
where oh.WriteTime >= ?begin and oh.WriteTime <= ?end and pd.IsLocal = 0
group by a.Id", OrdersSchema);
            command.Parameters.Clear();
            command.Parameters.AddWithValue("begin", begin);
            command.Parameters.AddWithValue("end", end);
            var quantityTable = new DataTable();

            DataAdapter.Fill(quantityTable);
            var quantities = new Hashtable();

            foreach (DataRow row in quantityTable.Rows)
            {
                quantities.Add(row["ProductId"] + "|" + row["ProducerId"], Convert.ToDecimal(row["quantity"]));
            }
            return(quantities);
        }
示例#23
0
        public void LoadLocation(int locationId)
        {
            LauncherErrorManager.Instance.Hide();
            Contexts.sharedInstance.game.DestroyAllEntities();
            _isConnecting = true;

            if (LoaderAnime != null)
            {
                LoaderAnime.StartLoaderAnimation();
            }


            LogFeedback(LanguageManager.Instance.GetTextValue("SCENE_LOADING"));

            LoaderSystems loaderSystems = new LoaderSystems(Contexts.sharedInstance);

            loaderSystems.Initialize();
            WorldDataListener.OnUpdate = () => loaderSystems.Execute();
            DataAdapter.LoadObjects();

            SceneLoaderSystem
                sceneLoader =
                new SceneLoaderSystem(Contexts.sharedInstance,
                                      null,
                                      locationId);

            sceneLoader.Initialize();
        }
示例#24
0
        public int Insert()
        {
            DataAdapter da     = new DataAdapter();
            var         result = da.Insert("A", "CVC", "color", "11區", 132, "U206d25c2ea6bd87c17655609a1c37cb8", "備註");

            return(result);
        }
示例#25
0
        private IEnumerable <TextileStore> TextileStoreList(string area)
        {
            DataAdapter da     = new DataAdapter();
            var         result = da.SearchArea(area);

            return(result);
        }
示例#26
0
        /// <summary>
        /// 通过Sql参数查询返回DataTable
        /// </summary>
        /// <param name="sql">Sql语句</param>
        /// <param name="parameters">查询参数</param>
        /// <returns></returns>
        public DataTable GetDataTableWithSql(string sql, List <DbParameter> parameters)
        {
            DbConnection conn = DbFactory.GetDbConnection(_dbType);

            conn.ConnectionString = db.Database.Connection.ConnectionString;
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }
            DbCommand cmd = DbFactory.GetDbCommand(_dbType);

            cmd.Connection  = conn;
            cmd.CommandText = sql;

            if (parameters != null && parameters.Count > 0)
            {
                foreach (var item in parameters)
                {
                    cmd.Parameters.Add(item);
                }
            }

            DataAdapter adapter = DbFactory.GetDataAdapter(_dbType, cmd);
            DataSet     table   = new DataSet();

            adapter.Fill(table);
            cmd.Parameters.Clear();
            conn.Close();//连接需要关闭
            conn.Dispose();
            return(table.Tables[0]);
        }
示例#27
0
        public virtual void StoreInstance
        (
            IObjectId objectId,
            IEnumerable <IDicomDataParameter> parameters,
            InstanceMetadata data = null
        )
        {
            //TODO: use transation
            //dbAdapter.CreateTransation ( )

            var cmd = DataAdapter.CreateInsertCommand(objectId, parameters, data);

            cmd.Connection.Open( );

            try
            {
                int rowsInserted = cmd.ExecuteNonQuery( );

                if (rowsInserted <= 0)
                {
                    //return duplicate instance?!!!
                }

                if (null != data)
                {
                    StoreInstanceMetadata(objectId, data);
                }
            }
            finally
            {
                cmd.Connection.Close( );
            }
        }
示例#28
0
        private ITableDataSet GetTableDataSet()
        {
            var tableDataSet = DataAdapter?.GetTableDataSet(conf =>
            {
                conf.LazyLoadingOptions       = LazyLoadingOptions;
                conf.PageableOptions.PageSize = PageSize;
                conf.GridViewEvents           = new GridViewEvents
                {
                    SaveOperationFinished   = this.SaveOperationFinished,
                    DeleteOperationFinished = this.DeleteOperationFinished,
                    NewItemCreated          = this.NewItemCreated,
                    OnItemClicked           = this.OnItemClicked
                };
            });

            if (tableDataSet is null)
            {
                return(new TableDataSet <EmptyDataSetItem>(Enumerable.Empty <EmptyDataSetItem>().AsQueryable()));
            }

            tableDataSet = MasterDetailTableDataSetFactory.ConvertToMasterTableIfIsRequired(tableDataSet);


            return(tableDataSet);
        }
        static void init()
        {
            if (string.IsNullOrEmpty(rootPath))
            {
                return;
            }

            matchRules = MatchRules();

            TempImpl tempImpl = new TempImpl();

            tempImpl.SetRootPath(rootPath);
            tempImpl.IsShowCodeOfDataResourceDLL = dbInfo.IsShowCode;

            DataAdapter.SetConfig(dbInfo.ConnectionString, dbInfo.DatabaseType);

            assemblies = DJTools.GetAssemblyCollection(rootPath);
            AutoCall.AssemblyCollection = assemblies;
            AutoCall.SetDataProviderAssemble(dbInfo.SqlProviderRelativePathOfDll);
            AutoCall.RootPath = rootPath;
            AutoCall.GetDllAbsolutePathByRelativePath = GetDllAbsolutePathByRelativePath;

            DbList <Data.Common.DbParameter> .dataServerProvider = dataServerProvider;

            if (null != DbHelper)
            {
                DbHelper.connectString        = dbInfo.ConnectionString;
                DbHelper.optByBatchMaxNumber  = dbInfo.optByBatchMaxNumber;
                DbHelper.optByBatchWaitSecond = dbInfo.optByBatchWaitSecond;
                DbHelper.sqlMaxLengthForBatch = dbInfo.sqlMaxLengthForBatch;
                DbHelper.disposableAndClose   = dbInfo.close;
            }
        }
    protected void LogIn(object sender, EventArgs e)
    {
        if (IsValid)
        {
            // Validate the user password
            //var manager = new UserManager();
            //ApplicationUser user = manager.Find(UserName.Text, Password.Text);
            //if (user != null)
            //{
            //    IdentityHelper.SignIn(manager, user, RememberMe.Checked);
            //    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            //}
            
            if (UserName.Text != null)
            {
                DataAdapter da = new DataAdapter();
                DataSet userSet=da.ExecuteSelectQuery("Select * from Users where UserArchived=0 and UserToken='"+UserName.Text.Replace("'","''")+"'");
                if(userSet!=null && userSet.Tables.Count>0 && userSet.Tables[0].Rows.Count > 0)
                {
                    da.ExecuteUpdateQuery("Update Users set UserLastLoggedIn=GETDATE() where UserToken='" + UserName.Text.Replace("'", "''") + "'");
                    DataTable userTable = userSet.Tables[0];
                    Session["UserToken"]=userTable.Rows[0]["UserId"];
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                }

            }
            else
            {
                FailureText.Text = "Invalid code";
                ErrorMessage.Visible = true;
            }
        }
    }
示例#31
0
        private bool DeleteById(int id)
        {
            DataAdapter da     = new DataAdapter();
            var         result = da.DelectByID(id);

            return(result == 1);
        }
示例#32
0
		private DataAdapter LoadAdapter(ref InstrumentDataRequest dataRequest, bool useCache = true) {
			InstrumentDataRequest cRequest = dataRequest;
			cRequest.Resolution = Resolution.GetBaseValue(dataRequest.Resolution);
			DataAdapter cAdapter = new DataAdapter(cRequest);

			InstrumentDataRequest cDataRequest = cAdapter.Series.DataRequest;
			dataRequest.Range.Count = cDataRequest.Range.Count;  //將正確的請求歷史資料數量傳入至結構

			if (useCache) {  //使用快取(true=建立完 DataAdapter 之後,將其保存至快取內以方便後續請求時使用)
				if (!cDataRequest.Range.IsAlreadyRequestAllData) {
					cAdapter.onCompleted += DataAdapter_onCompleted;

					string sLSymbolId = dataRequest.Symbol.ToLower();
					int iTotalSeconds = cDataRequest.Resolution.TotalSeconds;
					if (iTotalSeconds < Resolution.MAX_BASE_TOTALSECONDS) {
						lock (__cMinBases) {
							if (!__cMinBases.ContainsKey(sLSymbolId)) {
								__cMinBases.Add(sLSymbolId, cAdapter);
							}
						}
					} else {
						lock (__cDayBases) {
							if (!__cDayBases.ContainsKey(sLSymbolId)) {
								__cDayBases.Add(sLSymbolId, cAdapter);
							}
						}
					}
				}
			}
			return cAdapter;
		}
 public EEPROMMemory()
 {
     eeprom = new DataAdapter<byte>[EEPROM_MEMORY_SIZE];
     for (int i = 0; i < EEPROM_MEMORY_SIZE; i++)
     {
         eeprom[i] = new DataAdapter<byte>();
     }
 }
示例#34
0
		async void LoadAccounts ()
		{
			var results = await Client.QueryAsync ("SELECT Id, Name, AccountNumber, Phone, Website, Industry FROM Account");
			var resultRecords = results.Select (s => s.As<AccountObject> ()).ToList ();

			System.Diagnostics.Debug.WriteLine ("records: {0}", resultRecords.Count);
			ListAdapter = new DataAdapter (this, resultRecords);
		}
 private void GetArtifactList()
 {
     DataAdapter dataAdapter = new DataAdapter();
     DataSet ds = new DataSet();
     //ds=dataAdapter.ExecuteSelectQuery("Select * from Artifact where  Datalength(ArtifactText) <> 0 and ArtifactText like '%Wikipedia%' order by ArtifactId desc ");
     ds = dataAdapter.ExecuteStoredProcedure("usp_getArtifactsWithTopReviews",new System.Data.SqlClient.SqlParameter[] { });
     gv_SurveyMaster.DataSource = ds.Tables[0];
     gv_SurveyMaster.DataBind();
 }
    private DataTable getReviews(long reviewRefId)
    {
        DataAdapter dataAdapter = new DataAdapter();

        SqlParameter[] parameters = new SqlParameter[1];
        parameters[0]=new SqlParameter("@reviewRefId", reviewRefId);
        DataSet ds = dataAdapter.ExecuteStoredProcedure("sp_GetReviewDetails", parameters);
        return ds.Tables[0];
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DataAdapter da = new DataAdapter();
        long artifactId = 0;
        //todo  this should be converted into a stored procedure. Check if review is already done by the user.
        if (Session["UserToken"] != null && Session["ReviewRefId"]!=null)
        {
            long surveyId = 0;
            DataSet ds = da.ExecuteSelectQuery("SELECT top 1 surveyId FROM SURVEYMASTER WHERE ReviewId=" + Session["ReviewRefId"] + "and UserId=" + Session["UserToken"]);
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count>0)
            {
                surveyId = Convert.ToInt64(ds.Tables[0].Rows[0][0]);
            }
            if (surveyId == 0)
            {
                //new survey
                String query="insert into SurveyMaster values("+Session["ReviewRefId"]+","+Session["UserToken"]+",getdate())";
                da.ExecuteInsertQuery(query);
                //read the latest input query.
                surveyId = Convert.ToInt64(da.ExecuteSelectQuery("SELECT top 1 surveyId FROM SURVEYMASTER WHERE ReviewId=" + Session["ReviewRefId"] + "and UserId=" + Session["UserToken"]).Tables[0].Rows[0][0]);
                DataTable datatable = getQuestions();

                if (r_SurveyQuestions.Controls.Count > 0)
                {
                    List<RepeaterItem> listItem = r_SurveyQuestions.Controls.OfType<RepeaterItem>().ToList();
                    for (int i = 0; i < listItem.Count(); i++)
                    {
                        RadioButtonList rbl = listItem[i].Controls.OfType<RadioButtonList>().ToList()[0];
                        //DropDownList ddl = listItem[i].Controls.OfType<DropDownList>().ToList()[0];
                        long answerId = Convert.ToInt64(rbl.SelectedValue);
                        long questionId = Convert.ToInt64(datatable.Rows[i]["QuestionId"]);
                        artifactId = Convert.ToInt64(datatable.Rows[i]["ArtifactId"]);
                        DataTable dt = da.ExecuteSelectQuery("select * from SURVEYANSWER where questionId=" + questionId + " and surveyId= " + surveyId).Tables[0];
                        if (dt == null || dt.Rows.Count == 0)
                        {
                            da.ExecuteInsertQuery("INSERT INTO SURVEYANSWER VALUES(" + questionId + "," + surveyId + "," + answerId + ",'',getdate())");
                        }

                    }
                }
            }
            else
            {
                //existing survey
                //to-do
            }
           
            Session["ReviewRefId"] = null;
            ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close();", true);
        }
        //else
        //Response.Redirect("surveyMaster");



    }
        public OperationStack()
        {
            this.stack = new DataAdapter<short>[STACK_SIZE];
            for (int i = 0; i< STACK_SIZE; i++)
            {
                this.stack[i] = new DataAdapter<short>();
            }

            initializeValues();
        }
示例#39
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            var objectKey = Intent.GetStringExtra ("objectKey");
            var target = GetKeyedObject (objectKey);

            var data = new ObjectInspectorData (target);

            ListAdapter = new DataAdapter (data, this);

            Title = data.Title;
        }
        public ProgamMemory()
        {
            programMemory = new DataAdapter<short>[ProgamMemoryConstants.SIZE_OF_PROGRAM_MEMORY];
            breakpoints = new bool[ProgamMemoryConstants.SIZE_OF_PROGRAM_MEMORY];

            for (int x = 0; x < ProgamMemoryConstants.SIZE_OF_PROGRAM_MEMORY; x++)
            {
                programMemory[x] = new DataAdapter<short>();
                programMemory[x].Value = 0;
                breakpoints[x] = false;
            }
        }
示例#41
0
        public IOForm(RegisterFileMap _registerFileMap)
        {
            this.registerFileMap = _registerFileMap;

            // Listener fuer GUI-Aktualisierung
            this.portAListener = new DataAdapter<byte>.OnDataChanged(onPortAChange);
            this.portBListener = new DataAdapter<byte>.OnDataChanged(onPortBChange);
            this.trisAListener = new DataAdapter<byte>.OnDataChanged(onTrisAChange);
            this.trisBListener = new DataAdapter<byte>.OnDataChanged(onTrisBChange);

            registerFileMap.registerDataListener(portAListener, RegisterConstants.PORTA_ADDRESS);
            registerFileMap.registerDataListener(portBListener, RegisterConstants.PORTB_ADDRESS);
            registerFileMap.registerDataListener(trisAListener, RegisterConstants.TRISA_BANK1_ADDRESS);
            registerFileMap.registerDataListener(trisBListener, RegisterConstants.TRISB_BANK1_ADDRESS);

            Disposed += delegate { registerFileMap.unregisterDataListener(portAListener, RegisterConstants.PORTA_ADDRESS); };
            Disposed += delegate { registerFileMap.unregisterDataListener(portBListener, RegisterConstants.PORTB_ADDRESS); };
            Disposed += delegate { registerFileMap.unregisterDataListener(trisAListener, RegisterConstants.TRISA_BANK1_ADDRESS); };
            Disposed += delegate { registerFileMap.unregisterDataListener(trisBListener, RegisterConstants.TRISB_BANK1_ADDRESS); };
            int i = 0;
            // PORT-Checkboxes dynamisch erstellen
            for (i = 0; i < 8; i++)
            {
                PortA[i] = new CheckBox();
                PortA[i].Location = new Point(58 + i * 21, 50);
                PortA[i].MouseClick += new MouseEventHandler(CheckboxChanged);
                PortA[i].Name = "checkBoxBitA" + (7 - i).ToString();
                PortA[i].Width = 15;
                PortA[i].Height = 15;

                PortB[i] = new CheckBox();
                PortB[i].Location = new Point(58 + i * 21, 96);
                PortB[i].MouseClick += new MouseEventHandler(CheckboxChanged);
                PortB[i].Name = "checkBoxBitB" + (7 - i).ToString();
                PortB[i].Width = 15;
                PortB[i].Height = 15;
            }

            HexBoxPortA = new RegisterItem(registerFileMap.getAdapter(RegisterConstants.PORTA_ADDRESS), 58 + i * 21, 50, this);
            HexBoxPortB = new RegisterItem(registerFileMap.getAdapter(RegisterConstants.PORTB_ADDRESS), 58 + i * 21, 96, this);

            this.Controls.AddRange(PortA);
            this.Controls.AddRange(PortB);
            this.Controls.Add(HexBoxPortA);

            InitializeComponent();

            updateTrisA(registerFileMap.Get(RegisterConstants.TRISA_BANK1_ADDRESS));
            updateTrisB(registerFileMap.Get(RegisterConstants.TRISB_BANK1_ADDRESS));
            updatePortA(registerFileMap.Get(RegisterConstants.PORTA_ADDRESS));
            updatePortB(registerFileMap.Get(RegisterConstants.PORTB_ADDRESS));
        }
    private DataTable getQuestions()
    {
        DataAdapter da = new DataAdapter();
        try
        {
            SqlParameter[] sqlParameter = new SqlParameter[1];
            sqlParameter[0] = new SqlParameter("@reviewId", Convert.ToInt64(Session["ReviewRefId"]));
            DataSet ds = da.ExecuteStoredProcedure("sp_GetSurveyQuestions", sqlParameter);
            if (ds.Tables.Count > 0)
                return ds.Tables[0];
        }
        catch
        {

        }
        return new DataTable();
    }
    /// <summary>
    /// get all the reviews for artifact
    /// </summary>
    /// <param name="id"></param>
    private DataTable getReviewStatus(long id)
    {
        DataTable dt = new DataTable();

        try
        {
            DataAdapter dataAdapter = new DataAdapter();
            SqlParameter[] sqlParameter = new SqlParameter[1];
            //sqlParameter[0] = new SqlParameter("@userId", Session["UserToken"]);
            sqlParameter[0] = new SqlParameter("@artifactId", id);
            DataSet ds = dataAdapter.ExecuteStoredProcedure("usp_getTopRatedReviews", sqlParameter);
            dt = ds.Tables[0];
        }
        catch (Exception ex)
        {

        }
        return dt;
    }
        public RegisterItem(DataAdapter<byte> _dataAdapter, int _positionX, int _positionY, System.Windows.Forms.Control _parent)
        {
            Parent = _parent;
            // this.BackColor = backColor;
            // this.ForeColor = foreColor;

            this.Text = _dataAdapter.Value.ToString("X2");
            this.dataAdapter = _dataAdapter;
            this.value = dataAdapter.Value;
            // onChange listener
            dataAdapter.DataChanged += onValueChange;
            Disposed += delegate { dataAdapter.DataChanged -= onValueChange; };
            // set default values
            this.SetBounds(_positionX, _positionY, WIDTH, HEIGHT);
            this.ReadOnly = true;
            this.MouseEnter += showTooltip;
            this.MouseLeave += hideTooltip;
            this.DoubleClick += createNewHexBox;
            this.Show();
            this.updateTimer = new Helpers.UpdateTimer(ACTIVE_DURATION, new System.Timers.ElapsedEventHandler(onTimerExpiredHandler));
        }
 private DataTable readArtifact(long id)
 {
     DataAdapter dataAdapter = new DataAdapter();
     DataSet ds = dataAdapter.ExecuteSelectQuery("SELECT ArtifactText, ArtifactHeader FROM ARTIFACT WHERE ARTIFACTID=" + id);
     return ds.Tables[0];
 }
示例#46
0
    public void Mode_EditBroadcast(WebModuleParams wmp)
    {
        Int32 castid = Int32.Parse(wmp["editbroadcast"]);

        Controls.AddLiteral("<div class=\"toolbar\">");
        Controls.AddLiteral("<a href=\"", this.ModuleRoot, "\" title=\"", Lang["navbar.root.title"], "\">", Lang["navbar.root"], "</a>");
        Controls.AddLiteral(" | <a href=\"", this.ModuleRoot, "/cast/", castid, "\" title=\"", Lang["navbar.view.title"], "\">", Lang["navbar.view"], "</a>");
        Controls.AddLiteral("</div>");

        String name = new DataAdapter().Select("NAME").From("BROADCASTING").JoinExt("TEXT").Where("ID = @castid")
            .AddParametr("@castid", castid)
            .GetDataScalar() as String ?? "noname";
        Controls.AddLiteral("<h1>", name, "</h1>");

        Controls.AddLiteral("<div id=\"Sites_video_broadcasting_chanel_tabs\" style=\"display:none;\">");
        Controls.AddLiteral("<ul>");
        Controls.AddLiteral("<li><a href=\"#tab-1\">", Lang["tab.common"], "</a></li>");
        Controls.AddLiteral("<li><a href=\"#tab-2\">", Lang["tab.streams"], "</a></li>");
        Controls.AddLiteral("<li><a href=\"#tab-3\">", Lang["tab.conversation"], "</a></li>");
        Controls.AddLiteral("</ul>");

        Controls.AddLiteral("<div id=\"tab-1\">");
        ExFormDataAdapter form = new ExFormDataAdapter(Lang["form.title"], "BROADCASTING", "media");
        form.AddField("ExFieldLanguageString", "NAME", Lang["form.name"], DBUtils.ValueTrue, "TEXT")
            .AddField("ExFieldDateTime", "START_DATE", Lang["form.start"], DBUtils.ValueTrue)
            .AddField("ExFieldDateTime", "END_DATE", Lang["form.end"], DBUtils.ValueTrue)
            .AddField("ExFieldLanguageHtmlText", "DESCRIPTION", Lang["form.description"], DBUtils.ValueFalse, "TEXT");
        form.RecordID = castid;
        form.Initialise();
        form.DataForm.SubmitText = Lang["form.submit"];
        Controls.Add(form);
        Controls.AddLiteral("</div>");

        // потоки
        Controls.AddLiteral("<div id=\"tab-2\">");
        Controls.AddLiteral("<table id=\"stream-list\"><tr><td/></tr></table>");
        Controls.AddLiteral("<div id=\"stream-list-pager\"></div>");
        Controls.AddLiteral("</div>");

        // чат
        Controls.AddLiteral("<div id=\"tab-3\" class=\"ExForm\">");
        Controls.AddLiteral("<fieldset>");
        Controls.AddLiteral("<legend>", Lang["conversation.form.title"], "</legend>");
        Controls.AddLiteral("<div><input type=\"checkbox\" name=\"stream-conversation-enable\" id=\"stream-conversation-enable\" /> <label for=\"stream-conversation-enable\">", Lang["conversation.form.contol"], "</label></div>");
        Controls.AddLiteral("<div class=\"optional\">");
        Controls.AddLiteral("<div><input type=\"checkbox\" name=\"stream-conversation-allow\" id=\"stream-conversation-allow\" /> <label for=\"stream-conversation-allow\">", Lang["conversation.form.enable"], "</label></div>");
        Controls.AddLiteral("<table>");
        Controls.AddLiteral("<tr>");
        Controls.AddLiteral("<td>", Lang["conversation.form.header"], "</td>");
        Controls.AddLiteral("<td class=\"Multilang\">");
        Controls.AddLiteral("<label><span class=\"langname\">ru:</span><input type=\"text\" name=\"stream-conversation-h1-ru\" id=\"stream-conversation-h1-ru\" /></label>");
        Controls.AddLiteral("<label><span class=\"langname\">en:</span><input type=\"text\" name=\"stream-conversation-h1-en\" id=\"stream-conversation-h1-en\" /></label>");
        Controls.AddLiteral("</td>");
        Controls.AddLiteral("</tr>");
        Controls.AddLiteral("<tr>");
        Controls.AddLiteral("<td>", Lang["conversation.form.description"], "</td>");
        Controls.AddLiteral("<td class=\"Multilang\">");
        Controls.AddLiteral("<label><span class=\"langname\">ru:</span><input type=\"text\" name=\"stream-conversation-h2-ru\" id=\"stream-conversation-h2-ru\" /></label>");
        Controls.AddLiteral("<label><span class=\"langname\">en:</span><input type=\"text\" name=\"stream-conversation-h2-en\" id=\"stream-conversation-h2-en\" /></label>");
        Controls.AddLiteral("</td>");
        Controls.AddLiteral("</tr>");
        Controls.AddLiteral("</table>");
        Controls.AddLiteral("<div class=\"button-place\"><input type=\"button\" name=\"stream-conversation-save\" id=\"stream-conversation-save\" value=\"", Lang["form.submit"], "\" /></div>");
        Controls.AddLiteral("</div>");
        Controls.AddLiteral("</fieldset>");
        Controls.AddLiteral("</div>");

        Controls.AddLiteral("</div>");

        scripts.Add("/tools/JavaScript/jquery.js");
        scripts.Add("/tools/JavaScript/jquery-ui.js");
        scripts.Add(String.Concat("/tools/JavaScript/jquery-jqGrid-i18n/grid.locale-", Lang["lang"], ".js"));
        scripts.Add("/tools/JavaScript/jquery.jqGrid.js");
        scripts.Add("/tools/JavaScript/rpc.js");
        scripts.Add("/sites/video.mineralogy.ru/broadcasing-editor.js");

        ScriptControlDescriptor sd = new ScriptControlDescriptor("IWCtrls.BroadcasctingEditor", "Sites_video_broadcasting_chanel_tabs");
        sd.AddProperty("BroadcastingId", castid);
        sd.AddProperty("xlang", Lang.SerialiseJson());
        sdescriptions.Add(sd);
    }
示例#47
0
 public void Mode_Show()
 {
     using(DataTable items = new DataAdapter().Select("ID", "START_DATE", "END_DATE", "NAME", "DESCRIPTION")
         .From("BROADCASTING").JoinExt("TEXT")
         .OrderBy("START_DATE", true)
         .GetData())
     {
         TemplateView template = new TemplateView("broadcasting_list");
         template.Items.Add("datatable", items);
         template.Items.Add("moduleroot", this.ModuleRoot);
         template.Items.Add("isadmin", WebUser.Current.IsInRole(EditorRole));
         template.Items.Add("lang", Lang);
         Controls.Add(template);
     }
 }
示例#48
0
    public void Mode_Cast(WebModuleParams wmp)
    {
        Int32 castid = Int32.Parse(wmp["cast"]);

        Controls.AddLiteral("<div class=\"toolbar\">");
        Controls.AddLiteral("<a href=\"", this.ModuleRoot, "\" title=\"", Lang["navbar.root"], "\">", Lang["navbar.root"], "</a>");
        if (WebUser.Current.IsInRole(this.EditorRole))
        {
            Controls.AddLiteral(" | <a href=\"", this.ModuleRoot, "/editbroadcast/", castid, "\" title=\"", Lang["navbar_edit_title"], "\">",Lang["navbar_edit"],"</a>");
        }
        Controls.AddLiteral("</div>");

        using (DataTable itable = new DataAdapter().Select("NAME", "DESCRIPTION", "ALLOW_CHAT")
            .From("BROADCASTING").JoinExt("TEXT", true)
            .Where("ID = @castid")
            .AddParametr("@castid", castid)
            .GetData())
        {
            if (itable.Rows.Count > 0)
            {
                Controls.AddLiteral("<h1>", itable.Rows[0]["NAME"], "</h1>");
                Controls.AddLiteral("<div class=\"cast-description\">", itable.Rows[0]["DESCRIPTION"], "</div>");
                if (itable.Rows[0]["ALLOW_CHAT"].Equals(DBUtils.ValueTrue))
                {
                    ChatRoom chr = new ChatRoom();
                    chr.ChatRoomKey = String.Concat("video_cast_", castid);
                    chr.UserIsModerator = WebUser.Current.IsInRole(EditorRole);
                    Controls.Add(chr);
                }
            }
        }

        Controls.AddLiteral("<div id=\"Sites_video_broadcasting\">");

        using (DataTable table = new DataAdapter()
                .Select("NAME", "Description",  "ID", "WIDTH", "HEIGHT")
                .From("BROADCASTING_STREAMS")
                .JoinExt("TEXT", true)
                .Where("BROADCASTING_ID = @castid")
                .AddParametr("@castid", castid)
                .GetData())
        {
            foreach (DataRow item in table.Rows)
            {
                Controls.AddLiteral("<div class=\"stream\" style=\"width:", item["width"], "px;\" id=\"", item["ID"], "\" title=\"", item["NAME"], "\">");
                Controls.AddLiteral("<div class=\"cast-head\"><span>", item["description"], "</span><h2>", item["name"], "</h2></div>");
                Controls.AddLiteral("<div class=\"player-holder\" style=\"width:", item["width"], "px;height:", item["height"], "px;\" ><div class=\"player-holder\" id=\"castplayer_", item["ID"], "\"></div></div>");
                Controls.AddLiteral("<div class=\"cast-tools\"></div>");
                Controls.AddLiteral("</div>");
            }
        }

        scripts.Add("/tools/JavaScript/jquery.js");
        scripts.Add("/tools/JavaScript/jquery-ui.js");
        scripts.Add("/tools/JavaScript/UmediaFlashPlayer/umsplayer.js");
        scripts.Add("/sites/video.mineralogy.ru/broadcasing-viewer.js");

        ScriptControlDescriptor sd = new ScriptControlDescriptor("IWCtrls.BroadcasctingViewer", "Sites_video_broadcasting");
        sd.AddProperty("BroadcastingId", castid);
        sd.AddProperty("xlang", Lang.SerialiseJson());
        sdescriptions.Add(sd);
    }
 /// <summary>
 /// Unregister a listener with the DataAdapter of the corresponding address
 /// </summary>
 /// <param name="listener"></param>
 /// <param name="address"></param>
 public void unregisterDataListener(DataAdapter<byte>.OnDataChanged listener, short address)
 {
     Data[address].DataChanged -= listener;
 }