Example #1
0
        private void loadThongTinHocTap()
        {
            if (ControlUtil.IsEditValueNull(cmbLop) || ControlUtil.IsEditValueNull(cmbNam) || ControlUtil.IsEditValueNull(cmbThang))
            {
                return;
            }

            int      lopId = (int)cmbLop.EditValue;
            int      nam   = (int)cmbNam.EditValue;
            int      thang = IntUtil.StringToInt((string)cmbThang.EditValue).Value;
            DateTime ngay  = new DateTime(nam, thang, DateTime.DaysInMonth(nam, thang));

            this.viewHocTapRowBindingSource.DataSource = this.viewHocTapTableAdapter.GetDataByLopAndNgay(lopId, ngay);
            this.DataTable = this.viewHocTapRowBindingSource.DataSource as DataTable;

            foreach (QLMamNon.Dao.QLMamNonDs.ViewHocTapRow row in (this.DataTable as QLMamNon.Dao.QLMamNonDs.ViewHocTapDataTable))
            {
                if (row.IsNgayTinhNull())
                {
                    row.NgayTinh = new MySql.Data.Types.MySqlDateTime(nam, thang, DateTime.DaysInMonth(nam, thang), 0, 0, 0, 0);
                }

                if (row.IsSoNgayNghiThangNull())
                {
                    row.SoNgayNghiThang = 0;
                }
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <param name="dbFields"></param>
        /// <returns></returns>
        protected virtual bool setDBSegmentAttribute(DBSegment dbSegment, string attribute, string valueStr, List <DBField> dbFields)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dbSegment.Flags = tmp;
                break;

            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbSegment.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_FLD_ISN:
                int fldIsn;
                IntUtil.TryParse(valueStr, out fldIsn);
                dbSegment.Field = dbFields.Find(x => x.Isn == fldIsn);
                break;

            default:
                return(false);
            }
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setAttribute(DatabaseDefinition databaseDefinition, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_DATABASE_NAME:
                databaseDefinition.Name = valueStr;
                break;

            case ConstInterface.MG_ATTR_DATABASE_LOCATION:
            {
                string localDatabaseLocation = String.Empty;
                databaseDefinition.Location = valueStr;
            }
            break;

            case ConstInterface.MG_ATTR_DATABASE_TYPE:
                IntUtil.TryParse(valueStr, out tmp);
                databaseDefinition.DatabaseType = tmp;
                break;

            case ConstInterface.MG_ATTR_DATABASE_USER_PASSWORD:
            {
                databaseDefinition.UserPassword = valueStr;
            }
            break;

            default:
                return(false);
            }
            return(true);
        }
Example #4
0
        internal Publication(ClientConductor clientConductor, string channel, int streamId, int sessionId, IReadablePosition positionLimit, LogBuffers logBuffers, long registrationId)
        {
            var buffers           = logBuffers.AtomicBuffers();
            var logMetaDataBuffer = buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX];

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new TermAppender(buffers[i], buffers[i + LogBufferDescriptor.PARTITION_COUNT]);
            }

            var termLength = logBuffers.TermLength();

            _maxPayloadLength    = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
            MaxMessageLength     = FrameDescriptor.ComputeMaxMessageLength(termLength);
            _clientConductor     = clientConductor;
            Channel              = channel;
            StreamId             = streamId;
            SessionId            = sessionId;
            InitialTermId        = LogBufferDescriptor.InitialTermId(logMetaDataBuffer);
            _logMetaDataBuffer   = logMetaDataBuffer;
            RegistrationId       = registrationId;
            _positionLimit       = positionLimit;
            _logBuffers          = logBuffers;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _headerWriter        = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(logMetaDataBuffer));
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setDBKeyAttribute(DBKey dbKey, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_KEY_DB_NAME:
                dbKey.KeyDBName = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbKey.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dbKey.Flags = tmp;
                break;

            default:
                return(false);
            }
            return(true);
        }
Example #6
0
    /* Properties Setup */
    public void SetMountainProperties()
    {
        this.startPosition = AppController.LastEnd;

        this.actualHeight = IntUtil.Random(heightRange[0], heightRange[1]);
        this.actualWidth  = IntUtil.Random(widthRange[0], widthRange[1]);

        this.topWidth   = IntUtil.Random(1, this.actualWidth + 1);
        this.exitWidth  = IntUtil.Random(0, this.actualWidth - this.topWidth + 1);
        this.entryWidth = this.actualWidth - this.topWidth - this.exitWidth;

        if (this.entryWidth != 0)
        {
            this.entryHeight = IntUtil.Random(heightRange[0], this.actualHeight);
            this.topHeight   = this.entryHeight;
        }
        if (this.exitWidth != 0)
        {
            this.exitHeight = IntUtil.Random(heightRange[0], this.actualHeight);
        }

        if (topWidth > Valley.width[0])
        {
            topIsValley = true;
            valley      = new Valley();
        }
    }
Example #7
0
 public void ToggleElement(int index)
 {
     if (IntUtil.InRange(index, toggleButtons.Length))
     {
         toggleButtons[index].Toggle();
     }
 }
Example #8
0
        void SpawnLootBox(BasePlayer player, Vector3 hitloc)
        {
            var randomlootprefab = randomlootprefab1;
            var rlroll           = IntUtil.Random(1, 6);

            if (rlroll == 1)
            {
                randomlootprefab = randomlootprefab1;
            }
            if (rlroll == 2)
            {
                randomlootprefab = randomlootprefab2;
            }
            if (rlroll == 3)
            {
                randomlootprefab = randomlootprefab3;
            }
            if (rlroll == 4)
            {
                randomlootprefab = randomlootprefab4;
            }
            if (rlroll == 5)
            {
                randomlootprefab = randomlootprefab5;
            }

            var        createdPrefab = GameManager.server.CreateEntity(randomlootprefab, hitloc);
            BaseEntity treasurebox   = createdPrefab?.GetComponent <BaseEntity>();

            treasurebox.enableSaving = false;
            treasurebox?.Spawn();
            timer.Once(treasureDespawn, () => CheckTreasureDespawn(treasurebox));
        }
Example #9
0
        public Boolean ReLogin(string tsHashCode)
        {
            if (tsHashCode == "")
            {
                return(false);
            }
            string lsSql = @"select b.* from t_S_OnLine_Employee a inner join t_S_Employee b on a.Employee_Id=b.Employee_Id
                           where a.HashCode='" + tsHashCode + "'";

            DataTable lodtEmployee = new DataTable();

            DAL.DBA.FillDataTable(lodtEmployee, lsSql);

            if (lodtEmployee.Rows.Count == 1)
            {
                this.loUserInfo     = new UserInfo();
                loUserInfo.UserId   = Convert.ToInt32(lodtEmployee.Rows[0]["Employee_ID"].ToString());
                loUserInfo.UserName = lodtEmployee.Rows[0]["Employee_Name"].ToString();
                loUserInfo.DeptId   = Convert.ToInt32(lodtEmployee.Rows[0]["Dept_ID"].ToString());
                loUserInfo.Is_Employee_Pwd_Reset = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Employee_Pwd_Reset"]));
                loUserInfo.Employee_Status       = (EnumDef.EStatus)IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"].ToString());
                loUserInfo.Login_ID           = lodtEmployee.Rows[0]["Employee_Login_ID"].ToString();
                loUserInfo.Is_Admin           = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Admin"]));
                loUserInfo.Password           = lodtEmployee.Rows[0]["employee_login_pwd"].ToString();
                loUserInfo.PositionID         = IntUtil.SafeCIntNullable(lodtEmployee.Rows[0]["Position_ID"]);
                this.moSession["UserSession"] = this;
                this.InitMenu();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
        //
        //
        //
        private void cloudy()
        {
            while (!stopThread)
            {
                try
                {
                    for (int i = 0; i < 5; i++)
                    {
                        // if we returned after a pause here level will be remembered
                        _fixtureController.setWallLevelByPanel(level, i);
                        level = (ushort)IntUtil.Random(1, 100);

                        //this.Invoke((MethodInvoker)delegate
                        //{
                        //    label7.Text = level.ToString() + "%";
                        //});
                    }
                    //System.Threading.Thread.Sleep(delay);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(@"problem during transmission of command to lutron panel/area: " + ex.ToString());
                    //break;
                }
                finally
                {
                    // update progress graphic?
                }
            }
            #region old clouds based upon schedules
            //_fixtureController.turnOffWall();

            //var panels = _fixtureController.getAreas().ToArray();
            //var area1 = panels[0];
            //var area2 = panels[1];
            //var area3 = panels[2];
            //var area4 = panels[3];

            //var fixtures1 = _fixtureController.getFixturesForArea(area1).OrderBy(f => f.IntegrationId).Skip(4);
            //var fixtures2 = _fixtureController.getFixturesForArea(area2).OrderBy(f => f.IntegrationId);
            //var fixtures3 = _fixtureController.getFixturesForArea(area3).OrderBy(f => f.IntegrationId);
            //var fixtures4 = _fixtureController.getFixturesForArea(area4).OrderBy(f => f.IntegrationId).Take(20);

            //var levels = new List<int>();
            //levels.AddRange(new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
            //levels.AddRange(new List<int> { 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100 });
            //levels.AddRange(new List<int> { 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5 });

            //var schedules = new List<FixtureSchedule>();

            //schedules.AddRange(MakeRotatingLevel(fixtures1, levels));
            //schedules.AddRange(MakeRotatingLevel(fixtures2, levels));
            //schedules.AddRange(MakeRotatingLevel(fixtures3, levels));
            //schedules.AddRange(MakeRotatingLevel(fixtures4, levels));

            //_skywallFadeWorker = new SkyWallFadeWorker(schedules, _fixtureController);
            //_skywallFadeWorker.StartSkyWall();
            #endregion
        }
Example #11
0
        private DateTime GetNgayTinh()
        {
            if (!ControlUtil.IsEditValueNull(this.cmbNam) && !ControlUtil.IsEditValueNull(this.cmbThang))
            {
                Int32    nam      = (Int32)cmbNam.EditValue;
                int      thang    = IntUtil.StringToInt((string)cmbThang.EditValue).Value;
                int      ngay     = DateTime.DaysInMonth(nam, thang);
                DateTime ngayTinh = new DateTime(nam, thang, ngay);
                return(ngayTinh);
            }

            return(DateTime.MinValue);
        }
Example #12
0
        private void GenerateRandomActor()
        {
            int randomActor;

            for (int i = 0; i < 4; i++)
            {
                do
                {
                    randomActor = IntUtil.Random(1, 11);
                }while(actorIds.Contains(randomActor));
                actorIds.Add(randomActor);
            }
        }
Example #13
0
    List <Dog> getAdoptedDogsForPage(int pageIndex)
    {
        int startIndex = getStartIndex(pageIndex);

        if (IntUtil.InRange(startIndex, dogCollection.Count))
        {
            int endIndex = Mathf.Clamp(startIndex + dogsPerPage, 0, dogCollection.Count);
            return(dogCollection.GetRange(startIndex, endIndex - startIndex));
        }
        else
        {
            return(new List <Dog>());
        }
    }
Example #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="elementName"></param>
        /// <param name="elementValue"></param>
        /// <param name="attributes"></param>
        public void endElement(string elementName, string elementValue, NameValueCollection attributes)
        {
            switch (elementName)
            {
            case ConstInterface.MG_TAG_KEYS:
            case ConstInterface.MG_TAG_SEGS:
            case ConstInterface.MG_TAG_FLDS:
                // closing collection - do nothing
                return;

            case ConstInterface.MG_TAG_DBH:
            case ConstInterface.MG_TAG_DBH_DATA_ID:
                // set the attributes
                dataSourceBuilder.SetAttributes(dataSourceDefinition, attributes);
                break;

            case ConstInterface.MG_TAG_FLD:
                // create the field and add it to the DataSourceDefinition
                DBField field = new DBField();
                dataSourceBuilder.SetDBFieldAttributes(field, attributes);
                dataSourceBuilder.AddField(dataSourceDefinition, field);
                break;

            case ConstInterface.MG_TAG_KEY:
                // create the key and add it to the DataSourceDefinition
                DBKey key = new DBKey();
                dataSourceBuilder.SetDBKeyAttributes(key, attributes);
                // Add the segments collection and reset the local one
                key.Segments = segments;
                segments     = new List <DBSegment>();
                dataSourceBuilder.AddKey(dataSourceDefinition, key);
                break;

            case ConstInterface.MG_TAG_SEG:
                // create the segment and add it to the DataSourceDefinition
                DBSegment segment = new DBSegment();
                dataSourceBuilder.SetDBSegmentAttributes(segment, attributes, dataSourceDefinition.Fields);
                dataSourceBuilder.AddSegment(dataSourceDefinition, segment);
                break;

            case ConstInterface.MG_TAG_SEGMENT:
                // Get the segment's isn and add the segment to the local segment collection. This way it will be added
                // later to the right key
                int isn;
                IntUtil.TryParse((string)attributes.GetValues(0)[0], out isn);
                segments.Add(dataSourceDefinition.Segments.Find(x => x.Isn == isn));
                break;
            }
        }
        internal ExclusivePublication(
            ClientConductor clientConductor,
            string channel,
            int streamId,
            int sessionId,
            IReadablePosition positionLimit,
            LogBuffers logBuffers,
            long originalRegistrationId,
            long registrationId)
        {
            var buffers           = logBuffers.TermBuffers();
            var logMetaDataBuffer = logBuffers.MetaDataBuffer();

            for (var i = 0; i < LogBufferDescriptor.PARTITION_COUNT; i++)
            {
                _termAppenders[i] = new ExclusiveTermAppender(buffers[i], logMetaDataBuffer, i);
            }

            var termLength = logBuffers.TermLength();

            _termBufferLength    = termLength;
            MaxPayloadLength     = LogBufferDescriptor.MtuLength(logMetaDataBuffer) - DataHeaderFlyweight.HEADER_LENGTH;
            MaxMessageLength     = FrameDescriptor.ComputeExclusiveMaxMessageLength(termLength);
            _maxPossiblePosition = termLength * (1L << 31);
            _conductor           = clientConductor;
            Channel   = channel;
            StreamId  = streamId;
            SessionId = sessionId;

            _logMetaDataBuffer      = logMetaDataBuffer;
            _originalRegistrationId = originalRegistrationId;
            RegistrationId          = registrationId;
            _positionLimit          = positionLimit;
            _logBuffers             = logBuffers;
            _positionBitsToShift    = IntUtil.NumberOfTrailingZeros(termLength);
            _headerWriter           = new HeaderWriter(LogBufferDescriptor.DefaultFrameHeader(logMetaDataBuffer));
            InitialTermId           = LogBufferDescriptor.InitialTermId(logMetaDataBuffer);

            var activeIndex = LogBufferDescriptor.ActivePartitionIndex(logMetaDataBuffer);

            _activePartitionIndex = activeIndex;

            long rawTail = LogBufferDescriptor.RawTail(_logMetaDataBuffer, activeIndex);

            _termId            = LogBufferDescriptor.TermId(rawTail);
            _termOffset        = LogBufferDescriptor.TermOffset(rawTail, termLength);
            _termBeginPosition =
                LogBufferDescriptor.ComputeTermBeginPosition(_termId, _positionBitsToShift, InitialTermId);
        }
Example #16
0
        /// <summary>
        ///  Sets the Data Source Definition
        /// </summary>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        private void SetDataSourceDefinitionAttribute(string valueStr)
        {
            int ctlIdx;
            int tableIsn;

            String[] data = StrUtil.tokenize(valueStr, ",");
            Debug.Assert(data.Length > 1);
            IntUtil.TryParse(data[0], out ctlIdx);
            IntUtil.TryParse(data[1], out tableIsn);
            DataSourceId id = new DataSourceId();

            id.CtlIdx            = ctlIdx;
            id.Isn               = tableIsn;
            DataSourceDefinition = ClientManager.Instance.LocalManager.ApplicationDefinitions.DataSourceDefinitionManager.GetDataSourceDefinition(id);
        }
Example #17
0
        void FishTypeRoll(BasePlayer player, Vector3 hitloc)
        {
            int totalfishtypechance = rarecatchchance + uncommoncatchchance + common1catchchance + common2catchchance;
            var fishtyperoll        = IntUtil.Random(1, totalfishtypechance + 1);

            if (allowrandomitemchance)
            {
                if (fishtyperoll < randomitemchance)
                {
                    catchFishCui(player, randomitemiconurl);
                    SendReply(player, msg("randomitem", player.UserIDString));
                    SpawnLootBox(player, hitloc);
                    return;
                }
            }
            if (fishtyperoll < rarecatchchance)
            {
                catchFishCui(player, rareiconurl);
                SendReply(player, msg("rarefish1", player.UserIDString));
                player.inventory.GiveItem(ItemManager.CreateByItemID(rarecatchitemid, rarecatchamount));
                player.Command("note.inv", rarecatchitemid, rarecatchamount);
                return;
            }
            if (fishtyperoll < rarecatchchance + uncommoncatchchance)
            {
                catchFishCui(player, uncommoniconurl);
                SendReply(player, msg("uncommonfish1", player.UserIDString));
                player.inventory.GiveItem(ItemManager.CreateByItemID(uncommoncatchitemid, uncommoncatchamount));
                player.Command("note.inv", uncommoncatchitemid, uncommoncatchamount);
                return;
            }
            if (fishtyperoll < rarecatchchance + uncommoncatchchance + common2catchchance)
            {
                catchFishCui(player, common2iconurl);
                SendReply(player, msg("commonfish2", player.UserIDString));
                player.inventory.GiveItem(ItemManager.CreateByItemID(common2catchitemid, common2catchamount));
                player.Command("note.inv", common2catchitemid, common2catchamount);
                return;
            }
            if (fishtyperoll < rarecatchchance + uncommoncatchchance + common2catchchance + common1catchchance)
            {
                catchFishCui(player, common1iconurl);
                SendReply(player, msg("commonfish1", player.UserIDString));
                player.inventory.GiveItem(ItemManager.CreateByItemID(common1catchitemid, common1catchamount));
                player.Command("note.inv", common1catchitemid, common1catchamount);
                return;
            }
        }
Example #18
0
        void FishChanceRoll(BasePlayer player, Vector3 hitloc)
        {
            int roll        = IntUtil.Random(1, 101);
            int totatchance = CatchFishModifier(player);

            if (roll < totatchance)
            {
                FishTypeRoll(player, hitloc);
                return;
            }
            else
            {
                SendReply(player, msg("missedfish", player.UserIDString));
            }
            return;
        }
Example #19
0
        // King 47.798666, -122.409016 to 47.463651, -121.799275

        // pierce 47.303719, -122.521626 to 46.890506, -121.274678

        // snohomish 47.809735, -122.398030 to 48.309042, -121.101643

        public Person()
        {
            HairColor    = RandomValueOfArray(_hairColors);
            EyeColor     = RandomValueOfArray(_eyeColors);
            Sex          = RandomValueOfArray(_sex);
            YearOfBirth  = IntUtil.Random(1940, 2005);
            SearchAction = "mergeOrUpload";
            Region       = RandomValueOfArray(_regions);
            switch (Region)
            {
            case "King":
                City = RandomValueOfArray(_kingCities);
                //var kingLatitude = 47.463651 + ((double) IntUtil.Random(0, 335015)/1000000);
                //var kingLongitude = -121.799275 + ((double)IntUtil.Random(0, 609741) / 1000000);

                var kingLatitude  = 47.49 + ((double)IntUtil.Random(0, 200) / 1000);
                var kingLongitude = -122.4 + ((double)IntUtil.Random(0, 400) / 1000);
                //47.615330, -122.146812

                HomeLocation = new GeoPoint(kingLatitude, kingLongitude);
                break;

            case "Snohomish":
                City = RandomValueOfArray(_snohomishCities);
                //var snoLatitude = 47.809735 + ((double)IntUtil.Random(0, 499307) / 1000000);
                //var snoLongitude = -122.398030 + ((double)IntUtil.Random(0, 1296387) / 10000000);

                var snoLatitude  = 47.7 + ((double)IntUtil.Random(0, 500) / 1000);
                var snoLongitude = -122.3 + ((double)IntUtil.Random(0, 500) / 1000);
                //47.916760, -122.102074
                HomeLocation = new GeoPoint(snoLatitude, snoLongitude);
                break;

            case "Pierce":
                City = RandomValueOfArray(_pierceCities);
                //var pierceLatitude = 46.890506 + ((double)IntUtil.Random(0, 413213) / 10000000);
                //var pierceLongitude = -121.274678 + ((double)IntUtil.Random(0, 1246948) / 10000000);
                var pierceLatitude  = 46.93 + ((double)IntUtil.Random(0, 400) / 1000);
                var pierceLongitude = -122.6 + ((double)IntUtil.Random(0, 500) / 1000);
                //47.218698, -122.416958
                HomeLocation = new GeoPoint(pierceLatitude, pierceLongitude);
                break;
            }
            State = "WA";
        }
Example #20
0
        /// <summary>
        /// Construct a new image over a log to represent a stream of messages from a <seealso cref="Publication"/>.
        /// </summary>
        /// <param name="subscription">       to which this <seealso cref="Image"/> belongs. </param>
        /// <param name="sessionId">          of the stream of messages. </param>
        /// <param name="subscriberPosition"> for indicating the position of the subscriber in the stream. </param>
        /// <param name="logBuffers">         containing the stream of messages. </param>
        /// <param name="errorHandler">       to be called if an error occurs when polling for messages. </param>
        /// <param name="sourceIdentity">     of the source sending the stream of messages. </param>
        /// <param name="correlationId">      of the request to the media driver. </param>
        public Image(Subscription subscription, int sessionId, IPosition subscriberPosition, LogBuffers logBuffers, ErrorHandler errorHandler, string sourceIdentity, long correlationId)
        {
            Subscription        = subscription;
            SessionId           = sessionId;
            _subscriberPosition = subscriberPosition;
            _logBuffers         = logBuffers;
            _errorHandler       = errorHandler;
            SourceIdentity      = sourceIdentity;
            CorrelationId       = correlationId;

            _termBuffers = logBuffers.TermBuffers();

            var termLength = logBuffers.TermLength();

            _termLengthMask      = termLength - 1;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _header = new Header(LogBufferDescriptor.InitialTermId(logBuffers.MetaDataBuffer()), _positionBitsToShift);
        }
Example #21
0
        /// <summary>
        /// Construct a new image over a log to represent a stream of messages from a <seealso cref="Publication"/>.
        /// </summary>
        /// <param name="subscription">       to which this <seealso cref="Image"/> belongs. </param>
        /// <param name="sessionId">          of the stream of messages. </param>
        /// <param name="subscriberPosition"> for indicating the position of the subscriber in the stream. </param>
        /// <param name="logBuffers">         containing the stream of messages. </param>
        /// <param name="errorHandler">       to be called if an error occurs when polling for messages. </param>
        /// <param name="sourceIdentity">     of the source sending the stream of messages. </param>
        /// <param name="correlationId">      of the request to the media driver. </param>
        public Image(Subscription subscription, int sessionId, IPosition subscriberPosition, LogBuffers logBuffers, ErrorHandler errorHandler, string sourceIdentity, long correlationId)
        {
            Subscription        = subscription;
            SessionId           = sessionId;
            _subscriberPosition = subscriberPosition;
            _logBuffers         = logBuffers;
            _errorHandler       = errorHandler;
            SourceIdentity      = sourceIdentity;
            CorrelationId       = correlationId;

            var buffers = logBuffers.AtomicBuffers();

            Array.Copy(buffers, 0, _termBuffers, 0, LogBufferDescriptor.PARTITION_COUNT);

            var termLength = logBuffers.TermLength();

            _termLengthMask      = termLength - 1;
            _positionBitsToShift = IntUtil.NumberOfTrailingZeros(termLength);
            _header = new Header(LogBufferDescriptor.InitialTermId(buffers[LogBufferDescriptor.LOG_META_DATA_SECTION_INDEX]), _positionBitsToShift);
        }
Example #22
0
        internal int SelectBucketIndex(int bufferSize)
        {
            Debug.Assert(bufferSize >= 0);

            var intUtil = Math.Max(0, (32 - IntUtil.NumberOfLeadingZeros(bufferSize - 1)) - _minBufferLengthPow2);

#if DEBUG
            // TODO remove this check after some usage, see if this is not the same on some edge case

            // bufferSize of 0 will underflow here, causing a huge
            // index which the caller will discard because it is not
            // within the bounds of the bucket array.
            uint bitsRemaining = ((uint)bufferSize - 1) >> _minBufferLengthPow2;

            int poolIndex = 0;
            if (bitsRemaining > 0xFFFF)
            {
                bitsRemaining >>= 16; poolIndex = 16;
            }
            if (bitsRemaining > 0xFF)
            {
                bitsRemaining >>= 8; poolIndex += 8;
            }
            if (bitsRemaining > 0xF)
            {
                bitsRemaining >>= 4; poolIndex += 4;
            }
            if (bitsRemaining > 0x3)
            {
                bitsRemaining >>= 2; poolIndex += 2;
            }
            if (bitsRemaining > 0x1)
            {
                bitsRemaining >>= 1; poolIndex += 1;
            }
            var manual = poolIndex + (int)bitsRemaining;

            Debug.Assert(manual == intUtil);
#endif
            return(intUtil);
        }
        public List <xyPairs> generateArray()
        {
            int xPairsParam = 0;
            int yPairsParam = 0;

            for (int i = 0; i < testPointsNum * 2; i++)
            {
                if (i % 2 == 0)
                {
                    xPairsParam = IntUtil.Random(1, 1000);
                }
                else
                {
                    yPairsParam = IntUtil.Random(1, 1000);
                    //Console.WriteLine("({0}, {1})", xPairsParam, yPairsParam);
                    xyPairs xyStruct = new xyPairs();
                    xyStruct.x = xPairsParam;
                    xyStruct.y = yPairsParam;
                    PointsLi.Add(xyStruct);
                }
            }
            return(this.PointsLi);
        }
Example #24
0
        //判断是否有某个页面的权限
        public static Boolean ValidatePageRight(int tnEmployeeId, int tnPageId)
        {
            string lsSql = @" select c.Page_Id from t_S_Employee_Role a 
                     inner join t_S_Role b on a.ROLE_ID=b.Role_ID
                     inner join t_S_Role_Page c on b.Role_ID=c.Role_ID
                     where a.Valid_Date<Sysdate and a.Invalid_Date>Sysdate and a.Employee_ID=" + tnEmployeeId + @" and Page_Id=" + tnPageId + @"
                      union 
                     select Page_ID from t_S_Employee_Module_Add d
                     where d.Valid_Date<Sysdate and d.Invalid_Date>Sysdate and d.Employee_ID=" + tnEmployeeId + @" and Page_Id=" + tnPageId;

            DataTable lodtpage = new DataTable();

            int lnPageid = IntUtil.SafeCInt(DAL.DBA.ExecuteScalar(lsSql));

            if (lnPageid == tnPageId)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #25
0
        /// <summary>
        ///  Sets the value of specific attribute (according the data from parser)
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr">value of attribute</param>
        /// <returns></returns>
        protected virtual bool setAttribute(string attribute, string valueStr)
        {
            int num;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_TASK_TABLE_NAME_EXP:
                IntUtil.TryParse(valueStr, out num);
                NameExpression = num;
                break;

            case ConstInterface.MG_ATTR_TASK_TABLE_ACCESS:
                Access = (Access)valueStr[0];
                break;

            case ConstInterface.MG_ATTR_TASK_TABLE_IDENTIFIER:
                SetDataSourceDefinitionAttribute(valueStr);
                break;

            default:
                return(false);
            }
            return(true);
        }
Example #26
0
        private async void button1_Click(object sender, EventArgs e)
        {
            //checking if textbox value is int
            int  n;
            bool isNumeric = int.TryParse(textBox1.Text, out n);

            if (isNumeric == true)
            {
                bet         = n;
                label2.Text = "Bet: " + bet.ToString();

                if (credits == 0)
                {
                    MessageBox.Show("Sorry, you're out of credits!");
                    this.Close();
                }
                else if (credits < bet)
                {
                    MessageBox.Show("Bet must be equal to or lower than Credit balance!");
                }

                else if (credits >= bet)
                {
                    credits     = credits - bet;
                    label1.Text = "Credits: " + credits.ToString();

                    for (var i = 0; i < 10; i++)
                    {
                        p1 = IntUtil.Random(1, 5);
                        p2 = IntUtil.Random(1, 5);
                        p3 = IntUtil.Random(1, 5);

                        if (pictureBox1.Image != null)
                        {
                            pictureBox1.Image.Dispose();
                        }
                        pictureBox1.Image = Image.FromFile(p1.ToString() + ".png");

                        if (pictureBox2.Image != null)
                        {
                            pictureBox2.Image.Dispose();
                        }
                        pictureBox2.Image = Image.FromFile(p2.ToString() + ".png");

                        if (pictureBox3.Image != null)
                        {
                            pictureBox3.Image.Dispose();
                        }
                        pictureBox3.Image = Image.FromFile(p3.ToString() + ".png");

                        await Task.Delay(50);
                    }



                    total = 0;

                    //Three of a kind combos
                    if (p1 == 3 & p2 == 3 & p3 == 3)
                    {
                        total = total + (bet * 3);
                    }
                    else if (p1 == 1 & p2 == 1 & p3 == 1)
                    {
                        total = total + (bet * 3);
                    }
                    else if (p1 == 2 & p2 == 2 & p3 == 2)
                    {
                        total = total + (bet * 5);
                    }

                    else if ((p1 == 3 & p2 == 3) || (p1 == 3 & p3 == 3) || (p2 == 3 & p3 == 3))
                    {
                        total = total + (bet * 2);
                    }
                    else if ((p1 == 1 & p2 == 1) || (p1 == 1 & p3 == 1) || (p2 == 1 & p3 == 1))
                    {
                        total = total + (bet * 2);
                    }
                    else if ((p1 == 2 & p2 == 2) || (p1 == 2 & p3 == 2) || (p2 == 2 & p3 == 2))
                    {
                        total = total + (bet * 2);
                    }

                    credits     = credits + total;
                    label3.Text = "Win: " + total.ToString();
                    label1.Text = "Credits: " + credits.ToString();
                }
            }

            else
            {
                MessageBox.Show("Please enter a number value with no decimals!");
            }
        }
Example #27
0
        public string Login(string tsUserAccount, string tsPassword, ref string tsUserHash, bool lsBool)
        {
            string lsMessage = "";

            string lsSql = "Select * from t_S_Employee where Employee_Login_ID='" + tsUserAccount + "'";

            DataTable lodtEmployee = new DataTable();

            DAL.DBA.FillDataTable(lodtEmployee, lsSql);
            if (lodtEmployee.Rows.Count >= 1)
            {
                try
                {
                    this.loUserInfo     = new UserInfo();
                    loUserInfo.UserId   = Convert.ToInt32(lodtEmployee.Rows[0]["Employee_ID"].ToString());
                    loUserInfo.UserName = lodtEmployee.Rows[0]["Employee_Name"].ToString();
                    loUserInfo.DeptId   = Convert.ToInt32(lodtEmployee.Rows[0]["Dept_ID"].ToString());
                    loUserInfo.Is_Employee_Pwd_Reset = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Employee_Pwd_Reset"]));
                    loUserInfo.Employee_Status       = (EnumDef.EStatus)IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"].ToString());
                    loUserInfo.Login_ID   = lodtEmployee.Rows[0]["Employee_Login_ID"].ToString();
                    loUserInfo.Is_Admin   = Convert.ToBoolean(IntUtil.SafeCInt(lodtEmployee.Rows[0]["Is_Admin"]));
                    loUserInfo.Password   = lodtEmployee.Rows[0]["employee_login_pwd"].ToString();
                    loUserInfo.PositionID = IntUtil.SafeCIntNullable(lodtEmployee.Rows[0]["Position_ID"]);
                    if (IntUtil.SafeCInt(lodtEmployee.Rows[0]["Employee_Status"]) != 1)
                    {
                        lsMessage = "此用户处于未激活状态!";
                        return(lsMessage);
                    }
                    //密码不正确
                    if (loUserInfo.Password != CommonFunction.GetCode(tsPassword))
                    {
                        lsMessage = "登录密码错误,请重新输入!";
                        return(lsMessage);
                    }
                    if (!lsBool)
                    {
                        if (StrUtil.SafeCString(lodtEmployee.Rows[0]["Is_Out_Accesss"]) != "1")
                        {
                            lsMessage = "此用户无权登录!";
                            return(lsMessage);
                        }
                    }
                    #region 添加在线用户表记录
                    string lsSQL      = "select HashCode from t_S_OnLine_Employee where Employee_ID=" + loUserInfo.UserId + " and rownum =1";
                    object loUserHash = DAL.DBA.ExecuteScalar(lsSQL);
                    if (loUserHash != null && loUserHash != DBNull.Value)
                    {
                        tsUserHash = loUserHash.ToString();
                    }
                    else
                    {
                        tsUserHash = CommonFunction.GetCode(loUserInfo.Login_ID + loUserInfo.Password);
                        int lnOnlineID = Convert.ToInt32(CommonDBFunction.GenerateSEQIdentity("t_S_OnLine_Employee"));
                        lsSQL = @"insert into t_S_OnLine_Employee(OnLine_Employee_id,Employee_ID,Status,HashCode,LoginTime) values(" + lnOnlineID.ToString() + "," + loUserInfo.UserId.ToString() + ",1,'" + tsUserHash + "',to_date('" + DateTime.Now + "','yyyy-MM-dd HH24:MI:SS'))";
                        DAL.DBA.ExecSQL("userlogin", lsSQL, ref lsMessage);
                    }
                    #endregion

                    this.moSession["UserSession"] = this;
                    this.InitMenu();


                    return(lsMessage);
                }
                catch (Exception ex)
                {
                    lsMessage = "登陆失败!\r\n" + ex.Message;
                    return(lsMessage);
                }
            }
            else
            {
                lsMessage = "用户“" + tsUserAccount + "”不存在!";
                return(lsMessage);
            }
        }
Example #28
0
 public static int FindNextPositivePowerOfTwo(int value)
 {
     return(1 << (32 - IntUtil.NumberOfLeadingZeros(value - 1)));
 }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setAttribute(DataSourceDefinition dataSourceDefinition, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Id.Isn = tmp;
                break;

            case XMLConstants.MG_ATTR_CTL_IDX:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Id.CtlIdx = tmp;
                break;

            case ConstInterface.MG_ATTR_NAME:
                dataSourceDefinition.Name = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_FLAGS:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.Flags = tmp;
                break;

            case ConstInterface.MG_ATTR_DBASE_NAME:
                dataSourceDefinition.DBaseName = valueStr == null ? null : valueStr.ToUpper();
                break;

            case ConstInterface.MG_ATTR_POSITION_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.PositionIsn = tmp;
                break;

            case ConstInterface.MG_ATTR_ARRAY_SIZE:
                IntUtil.TryParse(valueStr, out tmp);
                dataSourceDefinition.ArraySize = tmp;
                break;

            case ConstInterface.MG_ATTR_ROW_IDENTIFIER:
                dataSourceDefinition.RowIdentifier = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_CHECK_EXIST:
                dataSourceDefinition.CheckExist = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DEL_UPD_MODE:
                dataSourceDefinition.DelUpdMode = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DBH_DATA_URL:
                dataSourceDefinition.FileUrl = XmlParser.unescape(valueStr);

                Debug.Assert(DataSourceReader != null);
                byte[] buf = DataSourceReader(dataSourceDefinition.FileUrl);
                new DataSourceDefinitionSaxHandler(dataSourceDefinition, this, buf);
                break;

            default:
                return(false);
            }
            return(true);
        }
Example #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setDBFieldAttribute(DBField dbField, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_ATTR:
                dbField.Attr = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_ALLOW_NULL:
                dbField.AllowNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_DEFAULT_NULL:
                dbField.DefaultNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_STORAGE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Storage = (FldStorage)tmp;
                break;

            case ConstInterface.MG_ATTR_LENGTH:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Length = tmp;
                break;

            case ConstInterface.MG_ATTR_DATASOURCE_DEFINITION:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.DataSourceDefinition = (DatabaseDefinitionType)tmp;
                break;

            case ConstInterface.MG_ATTR_DIFF_UPDATE:
                dbField.DiffUpdate = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DEC:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Dec = tmp;
                break;

            case ConstInterface.MG_ATTR_WHOLE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Whole = tmp;
                break;

            case ConstInterface.MG_ATTR_PART_OF_DATETIME:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.PartOfDateTime = tmp;
                break;

            case ConstInterface.MG_ATTR_DEFAULT_STORAGE:
                dbField.DefaultStorage = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_CONTENT:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.BlobContent = (BlobContent)BlobType.ParseContentType(tmp);
                break;

            case ConstInterface.MG_ATTR_PICTURE:
                dbField.Picture = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_DEFAULT_VALUE:
                dbField.DbDefaultValue = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_FLD_DB_INFO:
                dbField.DbInfo = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_NAME:
                dbField.DbName = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_TYPE:
                dbField.DbType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_USER_TYPE:
                dbField.UserType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_NULL_DISPLAY:
                dbField.NullDisplay = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_DEFAULTVALUE:
                dbField.DefaultValue = valueStr;
                if (dbField.Attr == (char)StorageAttribute.ALPHA || dbField.Attr == (char)StorageAttribute.UNICODE)
                {
                    dbField.DefaultValue = XmlParser.unescape(valueStr);
                    dbField.DefaultValue = StrUtil.padStr(dbField.DefaultValue, dbField.Length);
                }
                else if (dbField.DefaultValue.Length == 0 && dbField.Attr != (char)StorageAttribute.BLOB &&
                         dbField.Attr != (char)StorageAttribute.BLOB_VECTOR)
                {
                    dbField.DefaultValue = null;
                }
                else if (dbField.Attr == (char)StorageAttribute.BLOB)
                {
                    dbField.DefaultValue = BlobType.createFromString(dbField.DefaultValue, (char)dbField.BlobContent);
                }
                break;

            case ConstInterface.MG_ATTR_FIELD_NAME:
                dbField.Name = XmlParser.unescape(valueStr);
                break;

            default:
                return(false);
            }
            return(true);
        }