Example #1
0
            internal JObject ToJson()
            {
                var obj = new JObject();

                if (BlockId != null)
                {
                    obj.Add("Height", Height);
                    obj.Add("BlockId", BlockId.ToString());
                    obj.Add("Proof", Encoders.Hex.EncodeData(this.Proof.ToBytes()));
                }
                obj.Add("AddedDate", AddedDate);
                obj.Add("UnconfirmedSeen", UnconfirmedSeen);
                obj.Add("Transaction", Encoders.Hex.EncodeData(this.Transaction.ToBytes()));
                if (this.ReceivedCoins != null)
                {
                    obj.Add("ReceivedCoins", new JArray(ReceivedCoins.Select(c => ToJson(c))));
                }
                if (this.SpentCoins != null)
                {
                    obj.Add("SpentCoins", new JArray(SpentCoins.Select(c => ToJson(c))));
                }
                return(obj);
            }
Example #2
0
        private void ProcessBlock(PeerConnection peer, BlockCapsule block)
        {
            BlockId block_id = block.Id;

            if (!Manager.Instance.NetDelegate.ContainBlock(block.ParentId))
            {
                Logger.Warning(
                    string.Format("Get unlink block {0} from {1}, head is {2}.",
                                  block.Id.GetString(),
                                  peer.Address.ToString(),
                                  Manager.Instance.NetDelegate.HeadBlockId.GetString()));

                Manager.Instance.SyncService.StartSync(peer);
                return;
            }

            if (Args.Instance.IsFastForward && Manager.Instance.NetDelegate.ValidBlock(block))
            {
                Manager.Instance.AdvanceService.Broadcast(new BlockMessage(block));
            }

            Manager.Instance.NetDelegate.ProcessBlock(block);
            Manager.Instance.WitnessBlockService.ValidWitnessProductTwoBlock(block);
            Manager.Instance.NetDelegate.ActivePeers.ForEach(p =>
            {
                if (p.GetInventoryReceive(new Item(block.Id, InventoryType.Block)) != null)
                {
                    p.BlockBothHave = block.Id;
                }
            });

            if (!Args.Instance.IsFastForward)
            {
                Manager.Instance.AdvanceService.Broadcast(new BlockMessage(block));
            }
        }
        private string GetPageFile(string fileName)
        {
            string lessLocation = "~/Themes/" + base.RockPage.Site.Theme + "/Styles/";

            Environment.CurrentDirectory = Server.MapPath(lessLocation);

            string blockId = BlockId.ToString();
            string path    = blockId + "/";

            if (File.Exists(path + fileName))
            {
                using (var fs = File.OpenText(path + fileName))
                {
                    return(fs.ReadToEnd());
                }
            }
            else
            {
                using (var fs = File.OpenText(fileName))
                {
                    return(fs.ReadToEnd());
                }
            }
        }
Example #4
0
        public void SetBlock(int x, int y, int z, BlockId block)
        {
            Chunk chunk = GetChunk(x, y, z);

            if (chunk == null)
            {
                chunk = CreateChunk(x, y, z);
            }

            data.SetBlock(x, y, z, block);
            chunk.Render();

            var xx  = x - chunk.pos.x;
            var yy  = y - chunk.pos.y;
            var zz  = z - chunk.pos.z;
            var cs1 = MapConstants.ChunkSize - 1;

            UpdateIfEqual(xx, 0, new WorldPos(x - 1, y + 0, z + 0));
            UpdateIfEqual(xx, cs1, new WorldPos(x + 1, y + 0, z + 0));
            UpdateIfEqual(yy, 0, new WorldPos(x + 0, y - 1, z + 0));
            UpdateIfEqual(yy, cs1, new WorldPos(x + 0, y + 1, z + 0));
            UpdateIfEqual(zz, 0, new WorldPos(x + 0, y + 0, z - 1));
            UpdateIfEqual(zz, cs1, new WorldPos(x + 0, y + 0, z + 1));
        }
 protected override Block.Builder CreateBlockBuilder(BlockId id)
 {
     return(new Block.Builder(id));
 }
Example #6
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            rblMaritalStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS)));
            rblStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)));
            ddlRecordStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS)));
            ddlReason.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON)), true);

            ddlGivingGroup.Items.Clear();
            ddlGivingGroup.Items.Add(new ListItem(None.Text, None.IdValue));
            if (Person != null)
            {
                var personService = new PersonService(new RockContext());
                foreach (var family in personService.GetFamilies(Person.Id))
                {
                    ddlGivingGroup.Items.Add(new ListItem(family.Name, family.Id.ToString()));
                }
            }

            DateTime?gradeTransitionDate = GlobalAttributesCache.Read().GetValue("GradeTransitionDate").AsDateTime();

            if (gradeTransitionDate.HasValue)
            {
                _gradeTransitionDate = gradeTransitionDate.Value;
            }

            ddlGrade.Items.Clear();
            ddlGrade.Items.Add(new ListItem("", ""));
            ddlGrade.Items.Add(new ListItem("K", "0"));
            ddlGrade.Items.Add(new ListItem("1st", "1"));
            ddlGrade.Items.Add(new ListItem("2nd", "2"));
            ddlGrade.Items.Add(new ListItem("3rd", "3"));
            ddlGrade.Items.Add(new ListItem("4th", "4"));
            ddlGrade.Items.Add(new ListItem("5th", "5"));
            ddlGrade.Items.Add(new ListItem("6th", "6"));
            ddlGrade.Items.Add(new ListItem("7th", "7"));
            ddlGrade.Items.Add(new ListItem("8th", "8"));
            ddlGrade.Items.Add(new ListItem("9th", "9"));
            ddlGrade.Items.Add(new ListItem("10th", "10"));
            ddlGrade.Items.Add(new ListItem("11th", "11"));
            ddlGrade.Items.Add(new ListItem("12th", "12"));

            int gradeFactorReactor = (RockDateTime.Now < _gradeTransitionDate) ? 12 : 13;

            string script = string.Format(@"
    $('#{0}').change(function(){{
        if ($(this).val() != '') {{
            $('#{1}').val( {2} + ( {3} - parseInt( $(this).val() ) ) );
    
        }}
    }});

    $('#{1}').change(function(){{
        if ($(this).val() == '') {{
            $('#{0}').val('');
        }} else {{
            var grade = {3} - ( parseInt( $(this).val() ) - {4} );
            if (grade >= 0 && grade <= 12) {{
                $('#{0}').val(grade.toString());
            }} else {{
                $('#{0}').val('');
            }}
        }}
    }});

", ddlGrade.ClientID, ypGraduation.ClientID, _gradeTransitionDate.Year, gradeFactorReactor, RockDateTime.Now.Year);

            ScriptManager.RegisterStartupScript(ddlGrade, ddlGrade.GetType(), "grade-selection-" + BlockId.ToString(), script, true);

            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);
        }
Example #7
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            ddlMaritalStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_MARITAL_STATUS)), true);
            ddlConnectionStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_CONNECTION_STATUS)), true);
            ddlRecordStatus.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS)));
            ddlReason.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_RECORD_STATUS_REASON)), true);

            ddlGivingGroup.Items.Clear();
            ddlGivingGroup.Items.Add(new ListItem(None.Text, None.IdValue));
            if (Person != null)
            {
                var personService = new PersonService(new RockContext());
                foreach (var family in personService.GetFamilies(Person.Id).Select(a => new { a.Name, a.Id, a.Members }))
                {
                    string familyNameWithFirstNames = GetFamilyNameWithFirstNames(family.Name, family.Members);
                    ddlGivingGroup.Items.Add(new ListItem(familyNameWithFirstNames, family.Id.ToString()));
                }
            }

            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);

            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            btnSave.Visible = IsUserAuthorized(Rock.Security.Authorization.EDIT);

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);

            grdPreviousNames.Actions.ShowAdd   = true;
            grdPreviousNames.Actions.AddClick += grdPreviousNames_AddClick;
        }
Example #8
0
        private void DisplayForm(Person person)
        {
            pnlMain.Visible = true;

            ddlTitle.SetValue(person.TitleValueId);
            iuPhoto.BinaryFileId = person.PhotoId;
            tbNickName.Text      = person.NickName;
            tbFirstName.Text     = person.FirstName;
            tbMiddleName.Text    = person.MiddleName;
            tbLastName.Text      = person.LastName;
            ddlSuffix.SetValue(person.SuffixValueId);

            var families = person.GetFamilies();

            //If there is more than one family don't show family role
            if (families.Count() > 1)
            {
                ddlFamilyRole.Visible = false;
            }
            else
            {
                ddlFamilyRole.SelectedValue = person.GetFamilyRole().Guid == Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ? "A" : "C";

                var familyMemberRole = person.GetFamilyMembers(true)
                                       .Where(m => person.Id == m.PersonId)
                                       .Select(m => m.GroupRole)
                                       .FirstOrDefault();

                if (familyMemberRole != null)
                {
                    ddlFamilyRole.SelectedValue = familyMemberRole.Guid == Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_ADULT.AsGuid() ? "A" : "C";
                }
            }


            //PhoneNumber
            var mobilePhoneType = DefinedValueCache.Get(new Guid(Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE));

            var phoneNumbers     = new List <PhoneNumber>();
            var phoneNumberTypes = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_PHONE_TYPE));

            if (phoneNumberTypes.DefinedValues.Any())
            {
                foreach (var phoneNumberType in phoneNumberTypes.DefinedValues)
                {
                    var phoneNumber = person.PhoneNumbers.FirstOrDefault(n => n.NumberTypeValueId == phoneNumberType.Id);
                    if (phoneNumber == null)
                    {
                        var numberType = new DefinedValue();
                        numberType.Id    = phoneNumberType.Id;
                        numberType.Value = phoneNumberType.Value;

                        phoneNumber = new PhoneNumber {
                            NumberTypeValueId = numberType.Id, NumberTypeValue = numberType
                        };
                        phoneNumber.IsMessagingEnabled = mobilePhoneType != null && phoneNumberType.Id == mobilePhoneType.Id;
                    }
                    else
                    {
                        // Update number format, just in case it wasn't saved correctly
                        phoneNumber.NumberFormatted = PhoneNumber.FormattedNumber(phoneNumber.CountryCode, phoneNumber.Number);
                    }

                    phoneNumbers.Add(phoneNumber);
                }
            }
            rContactInfo.DataSource = phoneNumbers;
            rContactInfo.DataBind();


            //email
            tbEmail.Text            = person.Email;
            cbIsEmailActive.Checked = person.IsEmailActive;

            rblEmailPreference.SetValue(person.EmailPreference.ConvertToString(false));
            rblCommunicationPreference.SetValue(person.CommunicationPreference == CommunicationType.SMS ? "2" : "1");

            //demographics
            bpBirthday.SelectedDate = person.BirthDate;
            ddlGender.SetValue(person.Gender.ConvertToInt());
            ddlMaritalStatus.SetValue(person.MaritalStatusValueId);
            dpAnniversaryDate.SelectedDate = person.AnniversaryDate;

            if (!person.HasGraduated ?? false)
            {
                int gradeOffset    = person.GradeOffset.Value;
                var maxGradeOffset = ddlGradePicker.MaxGradeOffset;

                // keep trying until we find a Grade that has a gradeOffset that that includes the Person's gradeOffset (for example, there might be combined grades)
                while (!ddlGradePicker.Items.OfType <ListItem>().Any(a => a.Value.AsInteger() == gradeOffset) && gradeOffset <= maxGradeOffset)
                {
                    gradeOffset++;
                }

                ddlGradePicker.SetValue(gradeOffset);
                ypGraduation.SelectedYear = person.GraduationYear;
            }
            else
            {
                ddlGradePicker.SelectedIndex = 0;
                ypGraduation.SelectedYear    = person.GraduationYear;
            }
            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);

            //Family Info
            var location = person.GetHomeLocation();

            acAddress.SetValues(location);
            ddlCampus.SetValue(person.GetCampus());
        }
Example #9
0
 /// <summary>
 /// Returns a value indicating whether the block ID has frames.
 /// </summary>
 /// <param name="id">The block ID.</param>
 /// <returns><see langword="true"/> if the block ID has frames; otherwise, <see langword="false"/>.</returns>
 public static bool HasFrames(this BlockId id) => _frames.Contains(id);
Example #10
0
 public BlockModifierKey(BlockId block, MyStringHash attachmentPoint)
 {
     Block           = block;
     AttachmentPoint = attachmentPoint;
 }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ScriptManager.RegisterStartupScript(ddlGradePicker, ddlGradePicker.GetType(), "grade-selection-" + BlockId.ToString(), ddlGradePicker.GetJavascriptForYearPicker(ypGraduation), true);
            ddlTitle.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)).Id;
            ddlTitle.Items.Insert(0, new ListItem());
            ddlSuffix.DefinedTypeId = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)).Id;
            ddlSuffix.Items.Insert(0, new ListItem());
            RockPage.AddCSSLink(ResolveRockUrl("~/Styles/fluidbox.css"));
            RockPage.AddScriptLink(ResolveRockUrl("~/Scripts/imagesloaded.min.js"));
            RockPage.AddScriptLink(ResolveRockUrl("~/Scripts/jquery.fluidbox.min.js"));

            if (!string.IsNullOrWhiteSpace(GetAttributeValue("RequiredAdultPhoneTypes")))
            {
                _RequiredPhoneNumberGuids = GetAttributeValue("RequiredAdultPhoneTypes").Split(',').Select(Guid.Parse).ToList();
            }
            rContactInfo.ItemDataBound += rContactInfo_ItemDataBound;
        }
Example #12
0
 public ItemHandlerAttribute(BlockId itemId, uint metaValue)
 {
     Item = new ItemState {
         Id = (uint)itemId, MetaValue = metaValue
     };
 }
Example #13
0
 public BlockHandler(BlockId blockId)
 {
     BlockId = blockId;
 }
Example #14
0
 public BlockHandlerAttribute(BlockId blockId)
 {
     BlockId = blockId;
 }
Example #15
0
 protected override Graph.Block ToBlock(
     BlockId id, ImmutableSortedSet <BlockId> predecssors, ImmutableSortedSet <BlockId> successors)
 {
     return(new Block(id, predecssors, successors, _statements.ToImmutable()));
 }
Example #16
0
 public Builder(BlockId id) : base(id)
 {
     _statements = ImmutableList.CreateBuilder <AstStatement>();
 }
 public WoodPlanksBlockHandler(BlockId blockId)
     : base(blockId)
 {
 }
Example #18
0
 public override int GetHashCode()
 {
     return(BlockId.GetHashCode());
 }
Example #19
0
 public CraftingTableBlockHandler(BlockId blockId)
     : base(blockId)
 {
 }
Example #20
0
 public GrassBlockHandler(BlockId blockId)
     : base(blockId)
 {
 }
Example #21
0
 /// <summary>
 /// String representation of the block
 /// </summary>
 public override string ToString()
 {
     return(BlockId.ToString() + (BlockMeta != 0 ? ":" + BlockMeta.ToString() : ""));
 }
Example #22
0
 public void Put(BlockId id)
 {
     Put(BitConverter.GetBytes(id.Num), new BytesCapsule(id.Hash));
 }
Example #23
0
 public ChestBlockHandler(BlockId blockId)
     : base(blockId)
 {
 }
Example #24
0
 public override int GetHashCode()
 {
     return((BlockId.GetHashCode()) ^
            (ClassScope.GetHashCode()) ^
            (FunctionIndex.GetHashCode()));
 }
Example #25
0
 public int CompareTo(CommandNumber other)
 {
     return(BlockId == other.BlockId ?
            CommandId.CompareTo(other.CommandId) : BlockId.CompareTo(other.BlockId));
 }
Example #26
0
 public void SetBlock(int x, int y, int z, BlockId blockId)
 {
     this.blocks[x, y, z] = blockId;
 }
Example #27
0
 public ItemHandlerAttribute(BlockId itemId)
 {
     ItemId = (uint)itemId;
 }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            ddlTitle.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_TITLE)), true);
            ddlSuffix.BindToDefinedType(DefinedTypeCache.Read(new Guid(Rock.SystemGuid.DefinedType.PERSON_SUFFIX)), true);
            string smsScript = @"
    $('.js-sms-number').click(function () {
        if ($(this).is(':checked')) {
            $('.js-sms-number').not($(this)).prop('checked', false);
        }
    });
";

            ScriptManager.RegisterStartupScript(rContactInfo, rContactInfo.GetType(), "sms-number-" + BlockId.ToString(), smsScript, true);
        }
Example #29
0
 public BlockEntityAttribute(BlockId blockId)
 {
     BlockId = blockId;
 }
Example #30
0
        public uint Evaluate(Function function)
        {
            var cfg    = ControlFlowGraph.Compute(function.Body);
            var block  = cfg.GetBlock(cfg.EntryBlock.Successors[0]);
            var result = 0u;

            while (!block.IsExit)
            {
                var nextBlockId = block.ID.GetNext();

                foreach (var statement in block.Statements)
                {
                    var jump = false;

                    // First, handle any control flow statements

                    void HandleReturnStatement(AstReturnStatement returnStatement)
                    {
                        result      = Evaluate(returnStatement.Expression);
                        nextBlockId = BlockId.Exit;
                        jump        = true;
                    }

                    void HandleJumpStatement(AstJumpStatement jumpStatement)
                    {
                        nextBlockId = new BlockId(jumpStatement.Label.Index);
                        jump        = true;
                    }

                    switch (statement.Kind)
                    {
                    case AstNodeKind.ReturnStatement:
                        HandleReturnStatement((AstReturnStatement)statement);
                        break;

                    case AstNodeKind.JumpStatement:
                        HandleJumpStatement((AstJumpStatement)statement);
                        break;

                    case AstNodeKind.BranchStatement:
                    {
                        var branchStatement = (AstBranchStatement)statement;
                        var condition       = Evaluate(branchStatement.Condition);
                        if (condition == 1)
                        {
                            switch (branchStatement.Statement.Kind)
                            {
                            case AstNodeKind.ReturnStatement:
                                HandleReturnStatement((AstReturnStatement)branchStatement.Statement);
                                break;

                            case AstNodeKind.JumpStatement:
                                HandleJumpStatement((AstJumpStatement)branchStatement.Statement);
                                break;

                            default:
                                throw new InvalidOperationException($"Invalid statement kind for branch: {branchStatement.Statement.Kind}");
                            }
                        }

                        continue;
                    }
                    }

                    if (jump)
                    {
                        break;
                    }

                    Evaluate(statement);
                }

                block = cfg.GetBlock(nextBlockId);
            }

            return(result);
        }