コード例 #1
0
        public void UpdateProjectInfoTreeLocation(ProjectInfoTreeLocation updatedProjectInfoTreeLocation)
        {
            // Validate Parameters
            if (updatedProjectInfoTreeLocation == null)
            {
                throw (new ArgumentNullException("updatedProjectInfoTreeLocation"));
            }

            // Validate Primary key value
            if (updatedProjectInfoTreeLocation.ProjectInfoTreeLocationID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ProjectInfoTreeLocationID");
            }

            // Apply business rules
            OnProjectInfoTreeLocationSaving(updatedProjectInfoTreeLocation);
            OnProjectInfoTreeLocationUpdating(updatedProjectInfoTreeLocation);

            //attaching and making ready for parsistance
            if (updatedProjectInfoTreeLocation.EntityState == EntityState.Detached)
            {
                _DatabaseContext.ProjectInfoTreeLocations.Attach(updatedProjectInfoTreeLocation);
            }
            _DatabaseContext.ObjectStateManager.ChangeObjectState(updatedProjectInfoTreeLocation, System.Data.EntityState.Modified);            //this line makes the code un-testable!
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No projectInfoTreeLocation updated!");
            }

            //Apply business workflow
            OnProjectInfoTreeLocationUpdated(updatedProjectInfoTreeLocation);
            OnProjectInfoTreeLocationSaved(updatedProjectInfoTreeLocation);
        }
コード例 #2
0
        public void DeleteProjectInfoTreeLocation(ProjectInfoTreeLocation projectInfoTreeLocationToBeDeleted)
        {
            //Validate Input
            if (projectInfoTreeLocationToBeDeleted == null)
            {
                throw (new ArgumentNullException("projectInfoTreeLocationToBeDeleted"));
            }

            // Validate Primary key value
            if (projectInfoTreeLocationToBeDeleted.ProjectInfoTreeLocationID.IsInvalidKey())
            {
                BusinessLayerHelper.ThrowErrorForInvalidDataKey("ProjectInfoTreeLocationID");
            }

            OnProjectInfoTreeLocationSaving(projectInfoTreeLocationToBeDeleted);
            OnProjectInfoTreeLocationDeleting(projectInfoTreeLocationToBeDeleted);

            if (projectInfoTreeLocationToBeDeleted.EntityState == EntityState.Detached)
            {
                _DatabaseContext.ProjectInfoTreeLocations.Attach(projectInfoTreeLocationToBeDeleted);
            }
            _DatabaseContext.ProjectInfoTreeLocations.DeleteObject(projectInfoTreeLocationToBeDeleted);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No ProjectInfoTreeLocation deleted!");
            }

            OnProjectInfoTreeLocationDeleted(projectInfoTreeLocationToBeDeleted);
            OnProjectInfoTreeLocationSaved(projectInfoTreeLocationToBeDeleted);
        }
コード例 #3
0
        public virtual int CreateNewProjectInfoTreeLocation(ProjectInfoTreeLocation newProjectInfoTreeLocation)
        {
            // Validate Parameters
            if (newProjectInfoTreeLocation == null)
            {
                throw (new ArgumentNullException("newProjectInfoTreeLocation"));
            }

            // Apply business rules
            OnProjectInfoTreeLocationSaving(newProjectInfoTreeLocation);
            OnProjectInfoTreeLocationCreating(newProjectInfoTreeLocation);

            _DatabaseContext.ProjectInfoTreeLocations.AddObject(newProjectInfoTreeLocation);
            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows == 0)
            {
                throw new DataNotUpdatedException("No projectInfoTreeLocation created!");
            }

            // Apply business workflow
            OnProjectInfoTreeLocationCreated(newProjectInfoTreeLocation);
            OnProjectInfoTreeLocationSaved(newProjectInfoTreeLocation);

            return(newProjectInfoTreeLocation.ProjectInfoTreeLocationID);
        }
コード例 #4
0
        public void DeleteProjectInfoTreeLocations(List <int> projectInfoTreeLocationIDsToDelete)
        {
            //Validate Input
            foreach (int projectInfoTreeLocationID in projectInfoTreeLocationIDsToDelete)
            {
                if (projectInfoTreeLocationID.IsInvalidKey())
                {
                    BusinessLayerHelper.ThrowErrorForInvalidDataKey("ProjectInfoTreeLocationID");
                }
            }

            List <ProjectInfoTreeLocation> projectInfoTreeLocationsToBeDeleted = new List <ProjectInfoTreeLocation>();

            foreach (int projectInfoTreeLocationID in projectInfoTreeLocationIDsToDelete)
            {
                ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocation {
                    ProjectInfoTreeLocationID = projectInfoTreeLocationID
                };
                _DatabaseContext.ProjectInfoTreeLocations.Attach(projectInfoTreeLocation);
                _DatabaseContext.ProjectInfoTreeLocations.DeleteObject(projectInfoTreeLocation);
                projectInfoTreeLocationsToBeDeleted.Add(projectInfoTreeLocation);
                OnProjectInfoTreeLocationDeleting(projectInfoTreeLocation);
            }

            int numberOfAffectedRows = _DatabaseContext.SaveChanges();

            if (numberOfAffectedRows != projectInfoTreeLocationIDsToDelete.Count)
            {
                throw new DataNotUpdatedException("One or more projectInfoTreeLocation records have not been deleted.");
            }
            foreach (ProjectInfoTreeLocation projectInfoTreeLocationToBeDeleted in projectInfoTreeLocationsToBeDeleted)
            {
                OnProjectInfoTreeLocationDeleted(projectInfoTreeLocationToBeDeleted);
            }
        }
コード例 #5
0
        public static string GetMitigacion(ProjectInfoTreeLocation _projectInfoTreeLocation)
        {
            if (_projectInfoTreeLocation == null)
            {
                return("");
            }

            switch (_projectInfoTreeLocation.Mitigation)
            {
            case 0:
            case 1:
                return("Mitigación por solares");

            case 2:
            case 3:
                if (_projectInfoTreeLocation.PreviouslyImpacted.HasValue)
                {
                    if ((bool)_projectInfoTreeLocation.PreviouslyImpacted)
                    {
                        return("No requerirá mitigación (Previamente Impactado)");
                    }
                }
                if (_projectInfoTreeLocation.Acres.HasValue)
                {
                    if ((decimal)_projectInfoTreeLocation.Acres < 1)
                    {
                        return("No requerirá mitigación (Total de Cuerdas en el Proyecto menor de uno)");
                    }
                }
                return("Mitigación por perímetro");

            default:
                return("");
            }
        }
コード例 #6
0
    protected string getProjectDetails()
    {
        Project project = new ProjectBLL().GetProjectByProjectID(Convert.ToInt32(RouteData.Values["project_id"]));

        ProjectInfoTreeLocation projectInfoTreeLocation = project.ProjectInfoTreeLocations.FirstOrDefault();
        ProjectInfo             projectInfo             = project.ProjectInfoes.FirstOrDefault();

        if (projectInfoTreeLocation == null)
        {
            projectInfoTreeLocation = new ProjectInfoTreeLocation();

            projectInfoTreeLocation.X                    = 0;
            projectInfoTreeLocation.Y                    = 0;
            projectInfoTreeLocation.Lat                  = 0;
            projectInfoTreeLocation.Lon                  = 0;
            projectInfoTreeLocation.Acres                = 0;
            projectInfoTreeLocation.Lots1                = 0;
            projectInfoTreeLocation.Parkings             = 0;
            projectInfoTreeLocation.DistanceBetweenTrees = 10;

            projectInfoTreeLocation.ProjectID = project.ProjectID;
            projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

            new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);
        }

        var proj = new
        {
            projectInfo.ProjectName,
            projectInfoTreeLocation.ProjectID,
            projectInfoTreeLocation.Acres,
            projectInfoTreeLocation.DistanceBetweenTrees,
            projectInfoTreeLocation.Lat,
            projectInfoTreeLocation.Lon,
            projectInfoTreeLocation.Parkings,
            projectInfoTreeLocation.X,
            projectInfoTreeLocation.Y,
            projectInfo.City.CityName,
            projectInfo.City.CityID,
            CityX   = projectInfo.City.X,
            CityY   = projectInfo.City.Y,
            CityLat = projectInfo.City.Lat,
            CityLon = projectInfo.City.Lon,
            projectInfo.ZipCode
        };

        return(new JavaScriptSerializer().Serialize(proj));
    }
コード例 #7
0
    public static void EditProjectCenter(string projectID, string JStr)
    {
        Project project = new ProjectBLL().GetProjectByProjectId2(Convert.ToInt32(projectID));

        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            var nList = new JavaScriptSerializer().Deserialize <Object>(JStr);

            ProjectInfoTreeLocation projectInfoTreeLocation = project.ProjectInfoTreeLocations.Count == 0 ? new ProjectInfoTreeLocation() : _DatabaseContext.ProjectInfoTreeLocations.First(instance => instance.ProjectID == project.ProjectID);

            ProjectInfo projectInfo = project.ProjectInfoes.Count == 0 ? new ProjectInfo() : _DatabaseContext.ProjectInfoes.First(instance => instance.ProjectID == project.ProjectID);

            projectInfo.ProjectName                      = ((Dictionary <string, object>)nList).ContainsKey("ProjectName") ? Convert.ToInt32(((Dictionary <string, object>)nList)["ProjectName"]).ToString() : projectInfo.ProjectName;
            projectInfoTreeLocation.ProjectID            = ((Dictionary <string, object>)nList).ContainsKey("ProjectID") ? Convert.ToInt32(((Dictionary <string, object>)nList)["ProjectID"]) : projectInfoTreeLocation.ProjectID;
            projectInfoTreeLocation.X                    = ((Dictionary <string, object>)nList).ContainsKey("X") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["X"]) : projectInfoTreeLocation.X;
            projectInfoTreeLocation.Y                    = ((Dictionary <string, object>)nList).ContainsKey("Y") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["Y"]) : projectInfoTreeLocation.Y;
            projectInfoTreeLocation.Lat                  = ((Dictionary <string, object>)nList).ContainsKey("Lat") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["Lat"]) : projectInfoTreeLocation.Lat;
            projectInfoTreeLocation.Lon                  = ((Dictionary <string, object>)nList).ContainsKey("Lon") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["Lon"]) : projectInfoTreeLocation.Lon;
            projectInfoTreeLocation.Acres                = ((Dictionary <string, object>)nList).ContainsKey("Acres") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["Acres"]) : projectInfoTreeLocation.Acres;
            projectInfoTreeLocation.Lots0                = ((Dictionary <string, object>)nList).ContainsKey("Lots0") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Lots0"]) : projectInfoTreeLocation.Lots0;
            projectInfoTreeLocation.Lots1                = ((Dictionary <string, object>)nList).ContainsKey("Lots1") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Lots1"]) : projectInfoTreeLocation.Lots1;
            projectInfoTreeLocation.Lots2                = ((Dictionary <string, object>)nList).ContainsKey("Lots2") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Lots2"]) : projectInfoTreeLocation.Lots2;
            projectInfoTreeLocation.Lots3                = ((Dictionary <string, object>)nList).ContainsKey("Lots3") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Lots3"]) : projectInfoTreeLocation.Lots3;
            projectInfoTreeLocation.Mitigation           = ((Dictionary <string, object>)nList).ContainsKey("Mitigation") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Mitigation"]) : projectInfoTreeLocation.Mitigation;
            projectInfoTreeLocation.SocialInterest       = ((Dictionary <string, object>)nList).ContainsKey("SocialInterest") ? Convert.ToBoolean(((Dictionary <string, object>)nList)["SocialInterest"]) : projectInfoTreeLocation.SocialInterest;
            projectInfoTreeLocation.PreviouslyImpacted   = ((Dictionary <string, object>)nList).ContainsKey("PreviouslyImpacted") ? Convert.ToBoolean(((Dictionary <string, object>)nList)["PreviouslyImpacted"]) : projectInfoTreeLocation.PreviouslyImpacted;
            projectInfoTreeLocation.Parkings             = ((Dictionary <string, object>)nList).ContainsKey("Parkings") ? Convert.ToInt32(((Dictionary <string, object>)nList)["Parkings"]) : projectInfoTreeLocation.Parkings;
            projectInfoTreeLocation.DistanceBetweenTrees = ((Dictionary <string, object>)nList).ContainsKey("DistanceBetweenTrees") ? Convert.ToInt32(((Dictionary <string, object>)nList)["DistanceBetweenTrees"]) : projectInfoTreeLocation.DistanceBetweenTrees;
            projectInfo.ZipCode = ((Dictionary <string, object>)nList).ContainsKey("ZipCode") ? (((Dictionary <string, object>)nList)["ZipCode"]).ToString() : projectInfo.ZipCode;
            projectInfo.CityID  = ((Dictionary <string, object>)nList).ContainsKey("City") ? Convert.ToInt32(((Dictionary <string, object>)nList)["City"]) : projectInfo.City.CityID;

            projectInfoTreeLocation.ProjectID = project.ProjectID;
            projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

            projectInfo.ProjectID = project.ProjectID;
            projectInfo.ProjectReference.EntityKey = project.EntityKey;

            if (project.ProjectInfoTreeLocations.Count == 0)
            {
                new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);
            }

            _DatabaseContext.SaveChanges();
        }
    }
コード例 #8
0
    protected void FormViewTlProject_DataBinding(object sender, EventArgs e)
    {
        string projectID = Page.RouteData.Values["project_id"] as string;

        if (projectID != null && projectID != "0")
        {
            Project project = new ProjectBLL().GetProjectByProjectID(Convert.ToInt32(projectID));
            this.editor  = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(project.EditorUserID);
            this.creator = new Eisk.BusinessLogicLayer.UserBLL().GetUserByUserID(project.CreatorUserID);

            if (project.ProjectInfoTreeLocations.Count > 0)
            {
                this.projectInfoTreeLocation = project.ProjectInfoTreeLocations.First();
            }

            if (project.ProjectInfoes.Count > 0)
            {
                this.projectInfo = project.ProjectInfoes.First();
            }
        }
    }
コード例 #9
0
    protected void FormViewTlProject_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        Project project = new ProjectBLL().GetProjectByProjectId2((int)e.Keys["ProjectId"]);

        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            // ProjectInfoTreeLocation
            TextBox txtX = (TextBox)formViewTlProject.FindControl("txtX");
            TextBox txtY = (TextBox)formViewTlProject.FindControl("txtY");

            TextBox txtLat = (TextBox)formViewTlProject.FindControl("txtLat");
            TextBox txtLon = (TextBox)formViewTlProject.FindControl("txtLon");

            TextBox         txtParkings             = (TextBox)formViewTlProject.FindControl("txtParkings");
            RadioButtonList rblCalc                 = (RadioButtonList)formViewTlProject.FindControl("rblCalc");
            TextBox         txtAcres                = (TextBox)formViewTlProject.FindControl("txtAcres");
            DropDownList    ddlDistanceBetweenTrees = (DropDownList)formViewTlProject.FindControl("ddlDistanceBetweenTrees");
            TextBox         txtLots0                = (TextBox)formViewTlProject.FindControl("txtLots0");
            TextBox         txtLots1                = (TextBox)formViewTlProject.FindControl("txtLots1");
            TextBox         txtLots2                = (TextBox)formViewTlProject.FindControl("txtLots2");
            TextBox         txtLots3                = (TextBox)formViewTlProject.FindControl("txtLots3");
            RadioButtonList rblSocialInterest       = (RadioButtonList)formViewTlProject.FindControl("rblSocialInterest");
            RadioButtonList rblPreviouslyImpacted   = (RadioButtonList)formViewTlProject.FindControl("rblPreviouslyImpacted");

            ProjectInfoTreeLocation projectInfoTreeLocation = project.ProjectInfoTreeLocations.Count == 0 ? new ProjectInfoTreeLocation() : _DatabaseContext.ProjectInfoTreeLocations.First(instance => instance.ProjectID == project.ProjectID);

            decimal dec;
            int     integer;

            RadioButtonList rblPosition = (RadioButtonList)formViewTlProject.FindControl("rblPosition");

            if (rblPosition.SelectedValue == "0") // Nad83
            {
                projectInfoTreeLocation.X = decimal.TryParse(txtX.Text, out dec) ? Convert.ToDecimal(txtX.Text) : 0;
                projectInfoTreeLocation.Y = decimal.TryParse(txtY.Text, out dec) ? Convert.ToDecimal(txtY.Text) : 0;

                if (projectInfoTreeLocation.X != 0 && projectInfoTreeLocation.Y != 0)
                {
                    Dictionary <string, object> anewpointObj = Utility.ConvertToLatLng(projectInfoTreeLocation.X.ToString(), projectInfoTreeLocation.Y.ToString(), @"~/App_Resources/client-scripts/tl/");

                    projectInfoTreeLocation.Lat = Convert.ToDecimal(anewpointObj["y"]);
                    txtLat.Text = projectInfoTreeLocation.Lat.ToString();
                    projectInfoTreeLocation.Lon = Convert.ToDecimal(anewpointObj["x"]);
                    txtLon.Text = projectInfoTreeLocation.Lon.ToString();
                }
                else
                {
                    projectInfoTreeLocation.Lat = 0;
                    projectInfoTreeLocation.Lon = 0;
                }
            }
            else // StatePlanes
            {
                projectInfoTreeLocation.Lat = decimal.TryParse(txtLat.Text, out dec) ? Convert.ToDecimal(txtLat.Text) : 0;
                projectInfoTreeLocation.Lon = decimal.TryParse(txtLon.Text, out dec) ? Convert.ToDecimal(txtLon.Text) : 0;

                if (projectInfoTreeLocation.Lat != 0 && projectInfoTreeLocation.Lon != 0)
                {
                    Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(projectInfoTreeLocation.Lon.ToString(), projectInfoTreeLocation.Lat.ToString(), @"~/App_Resources/client-scripts/tl/");

                    projectInfoTreeLocation.X = Convert.ToDecimal(anewpointObj["x"]);
                    txtX.Text = projectInfoTreeLocation.X.ToString();
                    projectInfoTreeLocation.Y = Convert.ToDecimal(anewpointObj["y"]);
                    txtY.Text = projectInfoTreeLocation.Y.ToString();
                }
                else
                {
                    projectInfoTreeLocation.X = 0;
                    projectInfoTreeLocation.Y = 0;
                }
            }

            projectInfoTreeLocation.Parkings             = Int32.TryParse(txtParkings.Text, out integer) ? Convert.ToInt32(txtParkings.Text) : 0;
            projectInfoTreeLocation.Acres                = decimal.TryParse(txtAcres.Text, out dec) ? Convert.ToDecimal(txtAcres.Text) : 0;
            projectInfoTreeLocation.DistanceBetweenTrees = null;
            projectInfoTreeLocation.PreviouslyImpacted   = null;

            projectInfoTreeLocation.Mitigation = Convert.ToInt32(rblCalc.SelectedValue);
            if (Convert.ToInt32(rblCalc.SelectedValue) > 1)
            {                                                   // Cálculo por perímetro
                projectInfoTreeLocation.Lots0 = projectInfoTreeLocation.Lots1 = projectInfoTreeLocation.Lots2 = projectInfoTreeLocation.Lots3 = 0;
                if (rblPreviouslyImpacted.SelectedValue == "0") // Previamente impactado = No
                {
                    projectInfoTreeLocation.DistanceBetweenTrees = Int32.TryParse(ddlDistanceBetweenTrees.SelectedValue, out integer) ? Convert.ToInt32(ddlDistanceBetweenTrees.SelectedValue) : 0;
                }
                projectInfoTreeLocation.PreviouslyImpacted = rblPreviouslyImpacted.SelectedValue == "1";
            }
            else
            {// Cálculo por solares
                projectInfoTreeLocation.Lots0 = Int32.TryParse(txtLots0.Text, out integer) ? integer : 0;
                projectInfoTreeLocation.Lots1 = Int32.TryParse(txtLots1.Text, out integer) ? integer : 0;
                projectInfoTreeLocation.Lots2 = Int32.TryParse(txtLots2.Text, out integer) ? integer : 0;
                projectInfoTreeLocation.Lots3 = Int32.TryParse(txtLots3.Text, out integer) ? integer : 0;
                projectInfoTreeLocation.DistanceBetweenTrees = null;
            }

            projectInfoTreeLocation.SocialInterest = rblSocialInterest.SelectedValue == "1";

            projectInfoTreeLocation.ProjectID = project.ProjectID;
            projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

            if (project.ProjectInfoTreeLocations.Count == 0)
            {
                new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);
            }
            else
            {
                _DatabaseContext.SaveChanges();
            }
            //
        }

        Type myType = (typeof(Project));

        PropertyInfo[] props = myType.GetProperties();

        string[] arrNewValues = new string[e.NewValues.Keys.Count];
        e.NewValues.Keys.CopyTo(arrNewValues, 0);

        foreach (var prop in props)
        {
            if (("System.String,System.Int,System.DateTime,System.Guid").IndexOf((prop.PropertyType).FullName) >= 0) // Si la propiedad es de tipo Guid, String, Int o DateTime
            {
                if (!arrNewValues.Contains(prop.Name))
                {
                    e.NewValues[prop.Name] = prop.GetValue(project, null);
                }
            }
        }

        User editor = new UserBLL().GetUserByUserName((HttpContext.Current.User.Identity).Name);

        e.NewValues["EditorUserId"] = editor.UserID.ToString();
        e.NewValues["EditedDate"]   = DateTime.Now;
        //}
        //else
        //{
        //    ltlMessage.Text = MessageFormatter.GetFormattedErrorMessage(GetErrorMessage(status));
        //    e.Cancel = true;
        //}
    }
コード例 #10
0
    protected void OdsProject_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
    {
        int integer;
        int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat);

        if (result != 0)
        {
            Project project = new ProjectBLL().GetProjectByProjectID(result);

            UserBLL userBLL = new UserBLL();
            Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name);

            if (user != null)
            {
                // ProjectInfoTreeLocation
                TextBox         txtX       = (TextBox)formViewTlProject.FindControl("txtX");
                TextBox         txtY       = (TextBox)formViewTlProject.FindControl("txtY");
                TextBox         txtLat     = (TextBox)formViewTlProject.FindControl("txtLat");
                TextBox         txtLon     = (TextBox)formViewTlProject.FindControl("txtLon");
                TextBox         txtParking = (TextBox)formViewTlProject.FindControl("txtParking");
                RadioButtonList rblCalc    = (RadioButtonList)formViewTlProject.FindControl("rblCalc");
                TextBox         txtAcres   = (TextBox)formViewTlProject.FindControl("txtAcres");
                DropDownList    ddlDistanceBetweenTrees = (DropDownList)formViewTlProject.FindControl("ddlDistanceBetweenTrees");
                TextBox         txtLots0              = (TextBox)formViewTlProject.FindControl("txtLots0");
                TextBox         txtLots1              = (TextBox)formViewTlProject.FindControl("txtLots1");
                TextBox         txtLots2              = (TextBox)formViewTlProject.FindControl("txtLots2");
                TextBox         txtLots3              = (TextBox)formViewTlProject.FindControl("txtLots3");
                RadioButtonList rblSocialInterest     = (RadioButtonList)formViewTlProject.FindControl("rblSocialInterest");
                RadioButtonList rblPreviouslyImpacted = (RadioButtonList)formViewTlProject.FindControl("rblPreviouslyImpacted");

                ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocation();
                projectInfoTreeLocation.X                  = Convert.ToDecimal(txtX.Text);
                projectInfoTreeLocation.Y                  = Convert.ToDecimal(txtY.Text);
                projectInfoTreeLocation.Lat                = Convert.ToDecimal(txtLat.Text);
                projectInfoTreeLocation.Lon                = Convert.ToDecimal(txtLon.Text);
                projectInfoTreeLocation.Parkings           = Convert.ToInt32(txtParking.Text);
                projectInfoTreeLocation.Acres              = Convert.ToDecimal(txtAcres.Text);
                projectInfoTreeLocation.SocialInterest     = rblSocialInterest.SelectedValue == "1";
                projectInfoTreeLocation.PreviouslyImpacted = rblPreviouslyImpacted.SelectedValue == "1";

                projectInfoTreeLocation.Mitigation = Convert.ToInt32(rblCalc.SelectedValue);
                if (rblCalc.SelectedValue == "0")
                {
                    projectInfoTreeLocation.Lots0 = projectInfoTreeLocation.Lots1 = projectInfoTreeLocation.Lots2 = projectInfoTreeLocation.Lots3 = 0;
                }
                else
                {
                    projectInfoTreeLocation.Lots0 = Int32.TryParse(txtLots0.Text, out integer) ? integer : 0;
                    projectInfoTreeLocation.Lots1 = Int32.TryParse(txtLots1.Text, out integer) ? integer : 0;
                    projectInfoTreeLocation.Lots2 = Int32.TryParse(txtLots2.Text, out integer) ? integer : 0;
                    projectInfoTreeLocation.Lots3 = Int32.TryParse(txtLots3.Text, out integer) ? integer : 0;
                    projectInfoTreeLocation.DistanceBetweenTrees = null;
                }

                projectInfoTreeLocation.ProjectID = project.ProjectID;
                projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

                new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);
                //
            }

            Response.RedirectToRoute(new { edit_mode = "edit", Project_id = result.ToString() });
        }
    }
コード例 #11
0
 partial void OnProjectInfoTreeLocationDeleted(ProjectInfoTreeLocation projectInfoTreeLocation);
コード例 #12
0
 partial void OnProjectInfoTreeLocationSaved(ProjectInfoTreeLocation projectInfoTreeLocation);
コード例 #13
0
 partial void OnProjectInfoTreeLocationUpdated(ProjectInfoTreeLocation projectInfoTreeLocation);
コード例 #14
0
 partial void OnProjectInfoTreeLocationCreating(ProjectInfoTreeLocation projectInfoTreeLocation);
コード例 #15
0
ファイル: ProjectController.cs プロジェクト: galdo06/Apicem
        public object Post([FromBody] ProjectModel newProject)
        {
            User         user   = (User)HttpContext.Current.Items["user"];
            City         city   = (City)HttpContext.Current.Items["city"];
            List <Group> groups = (List <Group>)HttpContext.Current.Items["groups"];

            Project project = new Project();

            project.CreatedDate   = DateTime.Now;
            project.CreatorUserID = user.UserID;
            project.EditedDate    = DateTime.Now;
            project.EditorUserID  = user.UserID;

            new ProjectBLL().CreateNewProject(project);

            ProjectInfo projectInfo = new ProjectInfo();

            projectInfo.ProjectName             = newProject.ProjectName;
            projectInfo.Client                  = newProject.Client;
            projectInfo.Address1                = newProject.Address1;
            projectInfo.Address2                = newProject.Address2;
            projectInfo.CityID                  = newProject.CityID;
            projectInfo.CityReference.EntityKey = city.EntityKey;
            projectInfo.State   = newProject.State;
            projectInfo.ZipCode = newProject.ZipCode != null?newProject.ZipCode.Replace("-", "") : "";

            projectInfo.Description = newProject.Description != null?newProject.Description.Substring(0, Math.Min(newProject.Description.Length, 5000)) : "";

            projectInfo.Comments = newProject.Comments != null?newProject.Comments.Substring(0, Math.Min(newProject.Comments.Length, 5000)) : "";

            projectInfo.ProjectID = project.ProjectID;
            projectInfo.ProjectReference.EntityKey = project.EntityKey;

            new ProjectInfoBLL().CreateNewProjectInfo(projectInfo);

            ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocation();

            projectInfoTreeLocation.Acres = newProject.Acres;
            projectInfoTreeLocation.DistanceBetweenTrees = newProject.DistanceBetweenTrees;
            projectInfoTreeLocation.Lots1    = newProject.Lots;
            projectInfoTreeLocation.Parkings = newProject.Parkings;

            if ((newProject.Lat == null || newProject.Lat == 0) || (newProject.Lon == null || newProject.Lon == 0))
            {
                newProject.Lat = city.Lat;
                newProject.Lon = city.Lon;
            }

            projectInfoTreeLocation.Lat = newProject.Lat;
            projectInfoTreeLocation.Lon = newProject.Lon;

            Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(projectInfoTreeLocation.Lon.ToString(), projectInfoTreeLocation.Lat.ToString(), @"~/Javascript/");

            projectInfoTreeLocation.X = Convert.ToDecimal(anewpointObj["x"]);
            projectInfoTreeLocation.Y = Convert.ToDecimal(anewpointObj["y"]);

            projectInfoTreeLocation.ProjectID = project.ProjectID;
            projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

            new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);

            // Group_Projects
            Group group = groups[0];

            Group_Projects group_Projects = new Eisk.BusinessEntities.Group_Projects();

            group_Projects.GroupID = group.GroupID;
            group_Projects.GroupReference.EntityKey = group.EntityKey;

            group_Projects.ProjectID = project.ProjectID;
            group_Projects.ProjectReference.EntityKey = project.EntityKey;

            new Group_ProjectsBLL().CreateNewGroup_Projects(group_Projects);
            //

            //   Project project = new ProjectBLL().CreateNewProject(newProject.ProjectName, user, city, groups);

            return(ProjectModel.GetProjectObject(project));
        }
コード例 #16
0
    public static object SetPerimeterFromSIP(string projectID, string JStr, string userID)
    {
        Project project = new ProjectBLL().GetProjectByProjectId2(Convert.ToInt32(projectID));

        using (DatabaseContext _DatabaseContext = new DatabaseContext())
        {
            var nList = new JavaScriptSerializer().Deserialize <Object>(JStr);

            ProjectInfoTreeLocation projectInfoTreeLocation = project.ProjectInfoTreeLocations.Count == 0 ? new ProjectInfoTreeLocation() : _DatabaseContext.ProjectInfoTreeLocations.First(instance => instance.ProjectID == project.ProjectID);
            projectInfoTreeLocation.X = ((Dictionary <string, object>)nList).ContainsKey("X") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["X"]) : projectInfoTreeLocation.X;
            projectInfoTreeLocation.Y = ((Dictionary <string, object>)nList).ContainsKey("Y") ? Convert.ToDecimal(((Dictionary <string, object>)nList)["Y"]) : projectInfoTreeLocation.Y;

            string url =
                "http://www.gis.sip.pr.gov/ArcGIS/rest/services/Tools/Localizdor_JS8/MapServer/identify?f=json&geometry=%7B%22" +
                "x%22%3A" + miX + "%2C%22" +
                "y%22%3A" + miY + "%2C%22" +
                "spatialReference%22%3A%7B%22wkid%22%3A32161%7D%7D&tolerance=1&returnGeometry=true&mapExtent=%7B%22" +
                "xmin%22%3A" + miX + "%2C%22" +
                "ymin%22%3A" + miY + "%2C%22" +
                "xmax%22%3A" + miX + "%2C%22" +
                "ymax%22%3A" + miY + "%2C%22" +
                "spatialReference%22%3A%7B%22wkid%22%3A32161%7D%7D&imageDisplay=1920%2C304%2C96&geometryType=esriGeometryPoint&sr=32161&layers=all%3A0&callback=dojo.io.script.jsonp_dojoIoScript6._jsonpCallback";

            var json = new WebClient().DownloadString(url);

            var points = new JavaScriptSerializer().Deserialize <Object>(json.Replace("dojo.io.script.jsonp_dojoIoScript6._jsonpCallback(", "").Replace(");", ""));

            JObject j      = JObject.FromObject(points);
            JArray  jArray = GetRings(j);

            Perimeter mainPerimeter = _DatabaseContext.Perimeters.FirstOrDefault(instance => instance.IsMainPerimeter);
            if (mainPerimeter != null)
            {
                mainPerimeter.IsMainPerimeter = false;
                mainPerimeter.PerimeterName   = "Perímetro";

                // Foreign Key Color
                Color blue = _DatabaseContext.Colors.First(instance => instance.ColorID == 1);
                mainPerimeter.ColorID = blue.ColorID;
                mainPerimeter.ColorReference.EntityKey = blue.EntityKey;
                //
            }

            Perimeter newPerimeter = new Perimeter();

            List <PerimeterPoint> perimeterPoints        = new List <PerimeterPoint>();
            List <object>         perimeterPointsObjects = new List <object>();

            // Initialize a context
            using (JavascriptContext context = new JavascriptContext())
            {
                System.Collections.Generic.Dictionary <string, object> anewpointObj = new Dictionary <string, object>();
                using (var streamReader = new StreamReader(new Page().Server.MapPath(@"~/App_Resources\client-scripts\tl\proj4js-compressed.js")))
                {
                    context.Run(streamReader.ReadToEnd() + ScriptFileSeparator);
                }

                foreach (JToken JToken1 in jArray)
                {
                    foreach (JToken JToken2 in JToken1)
                    {
                        // Script
                        string script = @"
                                            function ConvertToLatLng(x, y) {
                                                Proj4js.defs[""EPSG:32161""] = ""+proj=lcc +lat_1=18.43333333333333 +lat_2=18.03333333333333 +lat_0=17.83333333333333 +lon_0=-66.43333333333334 +x_0=200000 +y_0=200000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"";
                                                Proj4js.defs[""EPSG:4326""] = ""+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"";
                                                var source = new Proj4js.Proj('EPSG:32161');
                                                var dest = new Proj4js.Proj('EPSG:4326');
                                                var anewpoint = new Proj4js.Point(x, y);
                                                Proj4js.transform(source, dest, anewpoint);
                                                return anewpoint;
                                            }

                                           var anewpoint = ConvertToLatLng(parseFloat('" + ((JValue)(JToken2[0])).Value.ToString() + "'),parseFloat('" + ((JValue)(JToken2[1])).Value.ToString() + "')); ";

                        // Running the script
                        context.Run(script);

                        // Getting a parameter
                        anewpointObj = (System.Collections.Generic.Dictionary <string, object>)context.GetParameter("anewpoint");

                        PerimeterPoint perimeterPoint = new PerimeterPoint();

                        perimeterPoint.Y = Convert.ToDecimal(anewpointObj["y"]);
                        perimeterPoint.X = Convert.ToDecimal(anewpointObj["x"]);

                        perimeterPoint.PerimeterID = newPerimeter.PerimeterID;
                        perimeterPoint.PerimeterReference.EntityKey = newPerimeter.EntityKey;

                        newPerimeter.PerimeterPoints.Add(perimeterPoint);

                        var perimeterPointObject = new
                        {
                            perimeterPoint.PerimeterID,
                            perimeterPoint.PerimeterPointID,
                            perimeterPoint.X,
                            perimeterPoint.Y
                        };
                        perimeterPointsObjects.Add(perimeterPointObject);
                    }
                }
            }

            newPerimeter.IsMainPerimeter = true;
            newPerimeter.PerimeterName   = "Perímetro Principal";

            newPerimeter.CreatedDate   = DateTime.Now;
            newPerimeter.CreatorUserID = new Guid(userID);
            newPerimeter.EditedDate    = DateTime.Now;
            newPerimeter.EditorUserID  = new Guid(userID);


            // Foreign Key Project
            newPerimeter.ProjectID = project.ProjectID;
            newPerimeter.ProjectReference.EntityKey = project.EntityKey;
            //

            // Foreign Key Color
            Color red = _DatabaseContext.Colors.First(instance => instance.ColorID == 2);
            newPerimeter.ColorID = red.ColorID;
            newPerimeter.ColorReference.EntityKey = red.EntityKey;
            //

            _DatabaseContext.Perimeters.AddObject(newPerimeter);

            _DatabaseContext.SaveChanges();

            var perimeterObject = new
            {
                newPerimeter.ColorID,
                newPerimeter.Color.Code,
                newPerimeter.Color.ColorDesc,
                newPerimeter.IsMainPerimeter,
                newPerimeter.PerimeterID,
                newPerimeter.PerimeterName,
                PerimeterPoints = perimeterPointsObjects,
                newPerimeter.ProjectID
            };

            return(perimeterObject);
        }
    }
コード例 #17
0
ファイル: ProjectModel.cs プロジェクト: galdo06/Apicem
        public static object GetProjectObject(Project project)
        {
            ProjectInfoTreeLocation projectInfoTreeLocation = project.ProjectInfoTreeLocations.FirstOrDefault();
            ProjectInfo             projectInfo             = project.ProjectInfoes.FirstOrDefault();

            if (projectInfoTreeLocation == null)
            {
                projectInfoTreeLocation = new ProjectInfoTreeLocation();

                projectInfoTreeLocation.X                    = 0;
                projectInfoTreeLocation.Y                    = 0;
                projectInfoTreeLocation.Lat                  = 0;
                projectInfoTreeLocation.Lon                  = 0;
                projectInfoTreeLocation.Acres                = 0;
                projectInfoTreeLocation.Lots1                = 0;
                projectInfoTreeLocation.Parkings             = 0;
                projectInfoTreeLocation.DistanceBetweenTrees = 10;

                projectInfoTreeLocation.ProjectID = project.ProjectID;
                projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey;

                new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation);
            }

            string zipCode = null;

            if (string.IsNullOrWhiteSpace(projectInfo.ZipCode))
            {
            }
            else if (projectInfo.ZipCode.Length == 5)
            {
                zipCode = projectInfo.ZipCode;
            }
            else if (projectInfo.ZipCode.Length == 9)
            {
                zipCode = projectInfo.ZipCode.Substring(0, 5) + "-" + projectInfo.ZipCode.Substring(5, 4);
            }

            return(new
            {
                projectInfo.ProjectName,
                projectInfoTreeLocation.ProjectID,
                Acres = projectInfoTreeLocation.Acres.ToString(),
                DistanceBetweenTrees = projectInfoTreeLocation.DistanceBetweenTrees.ToString(),
                projectInfoTreeLocation.Lat,
                projectInfoTreeLocation.Lon,
                Lots = projectInfoTreeLocation.Lots1.ToString(),
                Parkings = projectInfoTreeLocation.Parkings.ToString(),
                projectInfoTreeLocation.X,
                projectInfoTreeLocation.Y,
                projectInfo.City.CityName,
                projectInfo.City.CityID,
                projectInfo.Client,
                CityX = projectInfo.City.X,
                CityY = projectInfo.City.Y,
                CityLat = projectInfo.City.Lat,
                CityLon = projectInfo.City.Lon,
                ZipCode = zipCode,
                projectInfo.Comments,
                projectInfo.Description,
                projectInfo.Address1,
                projectInfo.Address2,
                projectInfo.State,
                Perimeters = project.Perimeters.Select(i => new
                {
                    PerimeterID = i.PerimeterID,
                    ColorID = i.ColorID,
                    Code = i.Color.Code,
                    ColorDesc = i.Color.ColorDesc,
                    PerimeterName = i.PerimeterName,
                    PerimeterPoints = i.PerimeterPoints.Select(e => new
                    {
                        PerimeterPointID = e.PerimeterPointID,
                        X = e.X,
                        Y = e.Y
                    })
                }),
                Trees = project.Project_Organisms.Select(i =>
                                                         ProjectOrganismModel.GetProjectOrganismObject(i.TreeDetails.First())
                                                         //     i.TreeDetails.First().ActionProposed.ActionProposedDesc,
                                                         //     i.TreeDetails.First().ActionProposed.ActionProposedID,
                                                         //     i.TreeDetails.First().ActionProposed.Color.ColorDesc,
                                                         //     i.TreeDetails.First().ActionProposed.Color.ColorID,
                                                         //     i.TreeDetails.First().ActionProposed.Color.Code,
                                                         //     i.TreeDetails.First().Commentary,
                                                         //     i.TreeDetails.First().Condition.ConditionDesc,
                                                         //     i.TreeDetails.First().Condition.ConditionID,
                                                         //     i.TreeDetails.First().CreatedDate,
                                                         //     i.TreeDetails.First().CreatorUserID,
                                                         //     i.TreeDetails.First().Dap,
                                                         //     i.TreeDetails.First().Dap_Counter,
                                                         //// Daps,//jsonSerialiser.Serialize(treeDetail.Daps.ToList()),
                                                         //     i.TreeDetails.First().EditedDate,
                                                         //     i.TreeDetails.First().EditorUserID,
                                                         //     i.TreeDetails.First().Height,
                                                         //     i.TreeDetails.First().Lat,
                                                         //     i.TreeDetails.First().Lon,
                                                         //     i.TreeDetails.First().X,
                                                         //     i.TreeDetails.First().Y,
                                                         //     i.TreeDetails.First().Number,
                                                         //     i.TreeDetails.First().ProjectOrganismID,
                                                         //     i.TreeDetails.First().Project_Organisms.ProjectID,
                                                         //     i.TreeDetails.First().Project_Organisms.OrganismID,
                                                         //     i.TreeDetails.First().Project_Organisms.Organism.CommonName.CommonNameDesc,
                                                         //     i.TreeDetails.First().Project_Organisms.Organism.CommonName.CommonNameID,
                                                         //     i.TreeDetails.First().Project_Organisms.Organism.ScientificName.ScientificNameDesc,
                                                         //     i.TreeDetails.First().Project_Organisms.Organism.ScientificName.ScientificNameID,
                                                         //     i.TreeDetails.First().TreeDetailsID,
                                                         //     i.TreeDetails.First().Varas
                                                         // }
                                                         )
            });
        }
コード例 #18
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProjectInfoTreeLocations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjectInfoTreeLocations(ProjectInfoTreeLocation projectInfoTreeLocation)
 {
     base.AddObject("ProjectInfoTreeLocations", projectInfoTreeLocation);
 }
コード例 #19
0
ファイル: ProjectController.cs プロジェクト: galdo06/Apicem
        public object Update([FromBody] ProjectModel_Update projectUpdate)
        {
            User         user   = (User)HttpContext.Current.Items["user"];
            City         city   = (City)HttpContext.Current.Items["city"];
            List <Group> groups = (List <Group>)HttpContext.Current.Items["groups"];

            var project = (Project)HttpContext.Current.Items["project"];

            using (DatabaseContext _DatabaseContext = new DatabaseContext())
            {
                // ProjectInfo
                ProjectInfo projectInfo = _DatabaseContext.ProjectInfoes.First(instance => instance.ProjectID == projectUpdate.ProjectID);

                projectInfo.ProjectName = projectUpdate.ProjectName;
                projectInfo.Client      = projectUpdate.Client;
                projectInfo.Address1    = projectUpdate.Address1;
                projectInfo.Address2    = projectUpdate.Address2;
                projectInfo.CityID      = projectUpdate.CityID;
                projectInfo.State       = projectUpdate.State;
                projectInfo.ZipCode     = !string.IsNullOrWhiteSpace(projectUpdate.ZipCode) ? projectUpdate.ZipCode.Replace("-", "") : null;
                projectInfo.Description = projectUpdate.Description;
                projectInfo.Comments    = projectUpdate.Comments;

                projectInfo.EditedDate = DateTime.Now;
                //

                // ProjectInfoTreeLocation
                ProjectInfoTreeLocation projectInfoTreeLocation = _DatabaseContext.ProjectInfoTreeLocations.First(instance => instance.ProjectID == projectUpdate.ProjectID);
                projectInfoTreeLocation.Acres = projectUpdate.Acres;
                projectInfoTreeLocation.DistanceBetweenTrees = projectUpdate.DistanceBetweenTrees;
                projectInfoTreeLocation.Lots1    = projectUpdate.Lots;
                projectInfoTreeLocation.Parkings = projectUpdate.Parkings;

                if ((projectUpdate.Lat == null || projectUpdate.Lat == 0) || (projectUpdate.Lon == null || projectUpdate.Lon == 0))
                {
                    projectUpdate.Lat = city.Lat;
                    projectUpdate.Lon = city.Lon;
                }

                projectInfoTreeLocation.Lat = projectUpdate.Lat;
                projectInfoTreeLocation.Lon = projectUpdate.Lon;

                Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(projectInfoTreeLocation.Lon.ToString(), projectInfoTreeLocation.Lat.ToString(), @"~/Javascript/");
                projectInfoTreeLocation.X = Convert.ToDecimal(anewpointObj["x"]);
                projectInfoTreeLocation.Y = Convert.ToDecimal(anewpointObj["y"]);
                //

                // Project
                project = _DatabaseContext.Projects.First(instance => instance.ProjectID == project.ProjectID);

                project.EditedDate   = DateTime.Now;
                project.EditorUserID = user.UserID;
                //

                _DatabaseContext.SaveChanges();
            }

            project = new ProjectBLL().GetProjectByProjectID(project.ProjectID);

            return(ProjectModel.GetProjectObject(project));
        }