Ejemplo n.º 1
0
    public static object InsertBuildingPermit(List <BuildingPDirty> insertParams)
    {
        try
        {
            int rowsInserted = 0;

            Validator validator = new Validator(insertParams[0]);

            if (validator.AllAreValid)
            {
                BuildingPDirty buildingPDirty = insertParams[0];
                buildingPDirty.PassedValidation = true;

                BuildingP           buildingP           = new BuildingP(insertParams[0]);
                BuildingPCollection buildingPCollection = new BuildingPCollection();
                buildingPCollection.BuildingPList.Add(buildingP);

                DataA dataA = new DataA();
                rowsInserted = dataA.InsertPermitData(buildingPCollection);
            }
            else
            {
                return("inputsInvalid");
            }

            return(rowsInserted);
        }
        catch (Exception)
        {
            return("serverError");
        }
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取
 /// </summary>
 /// <param name="keyA"></param>
 /// <returns></returns>
 public Dictionary <TKeyB, TValue> Get(TKeyA keyA)
 {
     if (DataA.ContainsKey(keyA))
     {
         return(DataA[keyA]);
     }
     return(new Dictionary <TKeyB, TValue>());
 }
Ejemplo n.º 3
0
        public void FsTrim()
        {
            int blockCount = (int)(DataA.GetSize() / BlockSize);

            for (int i = 0; i < blockCount; i++)
            {
                IStorage dataToClear = Bitmap.Bitmap[i] ? DataA : DataB;

                dataToClear.Slice(i * BlockSize, BlockSize).Fill(SaveDataFileSystem.TrimFillValue);
            }
        }
Ejemplo n.º 4
0
 /// <exception cref="System.Exception"></exception>
 protected override void Store()
 {
     var objectA = new DataA();
     var objectB = new DataB();
     objectA._val = objectB;
     objectB._val = objectA;
     Store(objectB);
     // just to show that the descend to "_val" actually is
     // recognized - this one doesn't show up in the result
     Store(new DataC());
 }
        protected void SubmitButtonClick(object sender, EventArgs e)
        {
            try
            {
                BuildingPDirty buildingPDirty = new BuildingPDirty(
                    tbxApplicantFirstName.Value,
                    tbxApplicantLastName.Value,
                    tbxSquareFeet.Value,
                    tbxHeightInFeet.Value,
                    tbxStartDate.Value,
                    tbxEstimatedEndDate.Value,
                    tbxAddress.Value,
                    tbxCity.Value,
                    tbxZip.Value,
                    ddlRemodelOrNewConstruction.SelectedValue);

                Validator validatorSubmission = new Validator(buildingPDirty);

                if (!validatorSubmission.AllAreValid)
                {
                    buildingPDirty.PassedValidation = false;
                    ToggleInputValidationMessages(validatorSubmission);
                }
                else
                {
                    buildingPDirty.PassedValidation = true;

                    BuildingP buildingP = new BuildingP(buildingPDirty);
                    ToggleInputValidationMessages(validatorSubmission);

                    BuildPCollection buildingPCollection = new BuildPCollection();
                    buildingPCollection.BuildingPList.Add(buildingP);

                    DataA dataA = new DataA();

                    if (dataA.InsertPermitData(buildingPCollection) == 1)
                    {
                        insertFeedback.InnerHtml =
                            "<span style='color:green;font-weight:bold;'>Application submitted</span>";
                    }
                    else
                    {
                        insertFeedback.InnerHtml =
                            "<span style='color:red;font-weight:bold;'>Application submission failed. Please try again.</span>";
                    }

                    LoadPermits();
                }
            }
            catch (Exception ex)
            {
                this.ReportExceptions(ex, "Error while saving new permit. ", "");
            }
        }
Ejemplo n.º 6
0
        /// <exception cref="System.Exception"></exception>
        protected override void Store()
        {
            var objectA = new DataA();
            var objectB = new DataB();

            objectA._val = objectB;
            objectB._val = objectA;
            Store(objectB);
            // just to show that the descend to "_val" actually is
            // recognized - this one doesn't show up in the result
            Store(new DataC());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 添加,如果已有则覆盖。
        /// </summary>
        /// <param name="keyA"></param>
        /// <param name="keyB"></param>
        /// <param name="val"></param>
        public void Add(TKeyA keyA, TKeyB keyB, TValue val)
        {
            if (!DataA.ContainsKey(keyA))
            {
                DataA[keyA] = new Dictionary <TKeyB, TValue>();
            }
            if (!DataB.ContainsKey(keyB))
            {
                DataB[keyB] = new Dictionary <TKeyA, TValue>();
            }

            DataA[keyA][keyB] = val;
            DataB[keyB][keyA] = val;
        }
        public void DeleteRows(object sender, EventArgs e)
        {
            try
            {
                bool       atLeastOneCheckboxedChecked = false;
                List <int> permitIdList = new List <int>();

                DataGrid DgPermits = dgPermits;

                foreach (DataGridItem row in DgPermits.Items)
                {
                    var cbx = row.FindControl("CheckBox1");

                    if (cbx is CheckBox)
                    {
                        CheckBox c = (CheckBox)cbx;
                        if (c.Checked)
                        {
                            TableCell tbc = row.Cells[1];

                            foreach (var tbx in tbc.Controls)
                            {
                                if (tbx is TextBox)
                                {
                                    TextBox tb = (TextBox)tbx;

                                    int permitIdInt = int.Parse(tb.Text);
                                    permitIdList.Add(permitIdInt);
                                    atLeastOneCheckboxedChecked = true;
                                }
                            }
                        }
                    }
                }

                if (atLeastOneCheckboxedChecked)
                {
                    DataA dataA = new DataA();

                    dataA.DeletePermits(permitIdList);

                    LoadPermits();
                }
            }
            catch (Exception ex)
            {
                this.ReportExceptions(ex, "Error deleting permit(s). ", "");
            }
        }
Ejemplo n.º 9
0
    public static object DeleteLinkedBuildingPermits(List <BuildingPDirty> deleteParams)
    {
        string permitId = deleteParams[0].PermitId;

        try
        {
            DataA dataA       = new DataA();
            int   rowsDeleted = dataA.DeleteBuildingPermits(permitId);

            return(rowsDeleted);
        }
        catch (Exception)
        {
            return("serverError");
        }
    }
Ejemplo n.º 10
0
        private void Calculate()
        {
            if (DiffValueTextBlock == null)
            {
                return;
            }
            DiffValueStatus = DataB > DataA ? CompareValueType.Up : DataB < DataA ? CompareValueType.Down : CompareValueType.NoChange;

            double c = DataB - DataA;

            if (c != 0)
            {
                DiffValue = Math.Round(c / DataA * 100, 1);
                if (DataA == 0)
                {
                    DiffValue = 100;
                }
            }

            switch (DiffValueStatus)
            {
            case CompareValueType.Up:
                DiffValueTextBlock.Foreground = UPColor;
                break;

            case CompareValueType.Down:
                DiffValueTextBlock.Foreground = DownColor;
                break;

            case CompareValueType.NoChange:
                DiffValueTextBlock.Foreground = NoChangeColor;
                break;
            }
            string popupText = PopupText;

            popupText = popupText.Replace("{a}", $"{DataA.ToString()}");
            popupText = popupText.Replace("{b}", $"{DataB.ToString()}");

            string diffvalueText = DiffValue > 0 ? $"+{DiffValue.ToString()}%" : DiffValue == 0 ? $"{Application.Current.Resources["Lang_Nochange"]}" : $"{DiffValue.ToString()}%";

            if (DataA == DataB)
            {
                diffvalueText = $"{Application.Current.Resources["Lang_Nochange"]}";
            }
            popupText           = popupText.Replace("{diffvalue}", diffvalueText);
            PopupTextBlock.Text = popupText;
        }
Ejemplo n.º 11
0
	public static int Main ()
	{
		DataA[] d1 = new DataA[] { new DataA () { Key = 1, Text = "Foo" }};
		DataB[] d2 = new DataB[] { new DataB () { Key = 2, Value = "Second" }};
		
		var e = from a in d1
			join b in d2 on a.Key equals b.Key into ab
			from x in ab.DefaultIfEmpty ()
			select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };

		var res = e.ToList ();
		if (res.Count != 1)
			return 1;
		
		if (res [0].a != "<empty>")
			return 2;
			
		if (res [0].b != "Foo")
			return 3;
			
		// Explicitly typed
		e = from a in d1
			join DataB b in d2 on a.Key equals b.Key into ab
			from x in ab.DefaultIfEmpty ()
			select new { a = x == default (DataB) ? "<empty>" : x.Value, b = a.Text };
			
		foreach (var o in e)
			Console.WriteLine (o);
			
		res = e.ToList ();
		if (res.Count != 1)
			return 10;
		
		if (res [0].a != "<empty>")
			return 11;
			
		if (res [0].b != "Foo")
			return 12;
			
		// FIXME: Used same name
		//var e2 = from a in d1
		//	join a in d2 on a.Key equals a.Key into ab
		//	select a;
		
		Console.WriteLine ("OK");
		return 0;
	}
        protected int LoadPermits()
        {
            int rowsReturned = 0;

            try
            {
                DataA dataA = new DataA();

                string firstNameWhereStr = "";
                string lastNameWhereStr  = "";

                if (rbtByNames.Checked)
                {
                    firstNameWhereStr = tbxFirstNameSearch.Value;
                    lastNameWhereStr  = tbxLastNameSearch.Value;
                }

                DataTable dtPermits = dataA.SearchBuildingPermits(firstNameWhereStr, lastNameWhereStr);

                rowsReturned = dtPermits.Rows.Count;

                if (rowsReturned > 0)
                {
                    dgPermits.DataSource = dtPermits;
                }
                else
                {
                    dgPermits.DataSource = null;
                }
                dgPermits.DataBind();
                ToggleDeleteAndEditButtons();
            }
            catch (Exception ex)
            {
                this.ReportExceptions(ex, "Error while loading permits. ", "");
            }
            return(rowsReturned);
        }
Ejemplo n.º 13
0
        protected override Result DoFlush()
        {
            Result rc = BitmapStorage.Flush();

            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = DataA.Flush();
            if (rc.IsFailure())
            {
                return(rc);
            }

            rc = DataB.Flush();
            if (rc.IsFailure())
            {
                return(rc);
            }

            return(Result.Success);
        }
 public void Visit(DataA data)
 {
     Console.WriteLine("A" + data);
 }
Ejemplo n.º 15
0
 public override void Flush()
 {
     BitmapStorage?.Flush();
     DataA?.Flush();
     DataB?.Flush();
 }
Ejemplo n.º 16
0
    public static int Main()
    {
        DataA[] d1 = new DataA[] { new DataA()
                                   {
                                       Key = 1, Text = "Foo"
                                   } };
        DataB[] d2 = new DataB[] { new DataB()
                                   {
                                       Key = 2, Value = "Second"
                                   } };

        var e = from a in d1
                join b in d2 on a.Key equals b.Key into ab
                from x in ab.DefaultIfEmpty()
                select new { a = x == default(DataB) ? "<empty>" : x.Value, b = a.Text };

        var res = e.ToList();

        if (res.Count != 1)
        {
            return(1);
        }

        if (res [0].a != "<empty>")
        {
            return(2);
        }

        if (res [0].b != "Foo")
        {
            return(3);
        }

        // Explicitly typed
        e = from a in d1
            join DataB b in d2 on a.Key equals b.Key into ab
            from x in ab.DefaultIfEmpty()
            select new { a = x == default(DataB) ? "<empty>" : x.Value, b = a.Text };

        foreach (var o in e)
        {
            Console.WriteLine(o);
        }

        res = e.ToList();
        if (res.Count != 1)
        {
            return(10);
        }

        if (res [0].a != "<empty>")
        {
            return(11);
        }

        if (res [0].b != "Foo")
        {
            return(12);
        }

        var e2 = from a in d1
                 join a in d2 on a.Key equals a.Key into ab
                 select a;

        Console.WriteLine("OK");
        return(0);
    }
Ejemplo n.º 17
0
 internal static void GetData(Action <string> callback)
 {
     callback?.Invoke(DataA.GetData());
 }
Ejemplo n.º 18
0
    public static object SearchLinkedBuildingPermits(List <BuildingPDirty> searchParams)
    {
        string firstName = searchParams[0].ApplicantFirstName;
        string lastName  = searchParams[0].ApplicantLastName;

        try
        {
            //BuildingPCollection linkedBuildingPermitsCollection = new BuildingPCollection();
            BuildingPDirtyCollection linkedBuildingPermitsCollection = new BuildingPDirtyCollection();

            if (firstName.Length < 41 && lastName.Length < 41)
            {
                DataA     dataA = new DataA();
                DataTable linkedBuildingPermits = dataA.SearchBuildingPermits(firstName, lastName);

                if (linkedBuildingPermits.Rows.Count > 0)
                {
                    foreach (DataRow r in linkedBuildingPermits.Rows)
                    {
                        BuildingPDirty buildingPDirty = new BuildingPDirty();
                        buildingPDirty.ApplicantFirstName    = r["ApplicantFirstName"].ToString();
                        buildingPDirty.ApplicantLastName     = r["ApplicantLastName"].ToString();
                        buildingPDirty.SquareFeet            = r["SquareFeet"].ToString();
                        buildingPDirty.Height                = r["Height"].ToString();
                        buildingPDirty.ConstructionStartDate = r["StartDate"].ToString();
                        if (r["EndDate"].ToString() == DateTime.MaxValue.ToString())
                        {
                            buildingPDirty.EstimatedCompletionDate = "";
                        }
                        else
                        {
                            //DateTime endDateLong = DateTime.Parse(r["EndDate"].ToString());
                            buildingPDirty.EstimatedCompletionDate = r["EndDate"].ToString();
                        }
                        buildingPDirty.Address = r["Address"].ToString();
                        buildingPDirty.City    = r["City"].ToString();
                        buildingPDirty.Zip     = r["Zip"].ToString();
                        buildingPDirty.RemodelOrNewConstruction = r["RemodelOrNewConstruction"].ToString();
                        buildingPDirty.PermitId = r["PermitID"].ToString();
                        //buildingPDirty.PassedValidation = true;
                        //BuildingP buildingP = new BuildingP(buildingPDirty);
                        linkedBuildingPermitsCollection.BuildingPDirtyList.Add(buildingPDirty);
                    }
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return("firstNameOrLastNameTooLong");
            }

            return(linkedBuildingPermitsCollection);
        }
        catch (Exception)
        {
            return("serverError");
        }
    }
Ejemplo n.º 19
0
 public override void Flush()
 {
     BitmapStream?.Flush();
     DataA?.Flush();
     DataB?.Flush();
 }
        public void SaveOrEditRows(object sender, EventArgs e)
        {
            try
            {
                if (dgPermits.Items.Count > 0)
                {
                    Button btn         = (Button)sender;
                    string senderValue = btn.Text;

                    if (senderValue == "Edit")
                    {
                        cancelButton.Enabled = true;
                        saveButton.Enabled   = true;
                    }

                    BuildingPDirtyCollection buildingPDirtyCollection = new BuildingPDirtyCollection();

                    foreach (DataGridItem row in dgPermits.Items)
                    {
                        var cbx = row.FindControl("CheckBox1");

                        if (cbx is CheckBox)
                        {
                            CheckBox cb = (CheckBox)cbx;
                            if (cb.Checked)
                            {
                                BuildingPDirty buildingPDirtySave = new BuildingPDirty();

                                foreach (var c in row.Cells)
                                {
                                    if (c is TableCell)
                                    {
                                        TableCell t = (TableCell)c;

                                        foreach (var ctl in t.Controls)
                                        {
                                            if (ctl is TextBox)
                                            {
                                                TextBox tb = (TextBox)ctl;

                                                if (senderValue == "Edit")
                                                {
                                                    tb.Enabled = true;
                                                }
                                                else if (senderValue == "Save")
                                                {
                                                    string tbId = tb.ID;

                                                    switch (tbId)
                                                    {
                                                    case "PermitIDCell":
                                                        buildingPDirtySave.PermitIdStr = tb.Text;
                                                        break;

                                                    case "FirstNameCell":
                                                        buildingPDirtySave.ApplicantFirstNameStr = tb.Text;
                                                        break;

                                                    case "LastNameCell":
                                                        buildingPDirtySave.ApplicantLastNameStr = tb.Text;
                                                        break;

                                                    //case "RemodelOrNewCell":
                                                    //    buildingPDirtySave.RemodelOrNewConstructionStr = tb.Text;
                                                    //    break;
                                                    case "AddressCell":
                                                        buildingPDirtySave.AddressStr = tb.Text;
                                                        break;

                                                    case "CityCell":
                                                        buildingPDirtySave.CityStr = tb.Text;
                                                        break;

                                                    case "ZIPCell":
                                                        buildingPDirtySave.ZipStr = tb.Text;
                                                        break;

                                                    case "SquareFeetCell":
                                                        buildingPDirtySave.SquareFeetStr = tb.Text;
                                                        break;

                                                    case "HeightCell":
                                                        buildingPDirtySave.HeightInFeetStr = tb.Text;
                                                        break;

                                                    case "StartDateCell":
                                                        buildingPDirtySave.StartDateStr = tb.Text;
                                                        break;

                                                    case "EndDateCell":
                                                        buildingPDirtySave.EstimatedEndDateStr = tb.Text;
                                                        break;
                                                    }
                                                }
                                            }
                                            else if (ctl is DropDownList)
                                            {
                                                DropDownList ddl = (DropDownList)ctl;
                                                if (senderValue == "Edit")
                                                {
                                                    ddl.Enabled = true;
                                                }
                                                else if (senderValue == "Save")
                                                {
                                                    if (ddl.ID == "RemodelOrNewCell")
                                                    {
                                                        buildingPDirtySave.RemodelOrNewConstructionStr = ddl.SelectedValue;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                if (senderValue == "Save")
                                {
                                    buildingPDirtyCollection.BuildingPDirtyList.Add(buildingPDirtySave);
                                }
                            }
                        }
                    }

                    if (senderValue == "Save")
                    {
                        BuildPCollection buildPCollection = new BuildPCollection();

                        foreach (BuildingPDirty buildingPDirty in buildingPDirtyCollection.BuildingPDirtyList)
                        {
                            Validator validatorSave = new Validator(buildingPDirty);
                            if (validatorSave.AllAreValid)
                            {
                                buildingPDirty.PassedValidation = true;
                                BuildingP buildingP = new BuildingP(buildingPDirty);
                                buildPCollection.BuildingPList.Add(buildingP);
                            }
                        }

                        DataA dataA = new DataA();

                        if (dataA.UpdatePermitData(buildPCollection) > 0)
                        {
                            insertFeedback.InnerHtml = "<span style='color:green;font-weight:bold;'>Changes Saved</span>";
                        }
                        else
                        {
                            insertFeedback.InnerHtml =
                                "<span style='color:red;font-weight:bold;'>Errors while saving. Please try again.</span>";
                        }

                        LoadPermits();
                    }
                }
            }
            catch (Exception ex)
            {
                this.ReportExceptions(ex, "Error while saving or editing permit(s). ", "");
            }
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 是否包含键值A,且A集合中也包含B
 /// </summary>
 /// <param name="keyA"></param>
 /// <param name="keyB"></param>
 /// <returns></returns>
 public bool ContainsKeyAB(TKeyA keyA, TKeyB keyB)
 {
     return(DataA.ContainsKey(keyA) && DataA[keyA].ContainsKey(keyB));
 }
Ejemplo n.º 22
0
 public ProxyA(DataA dataA)
 {
 }