Esempio n. 1
0
        /// <summary>
        /// Gets the list of member codes
        /// </summary>
        /// <returns></returns>
        private List <string> GetMemberCodes()
        {
            try
            {
                List <string> codesList   = new List <string>();
                IGTKeyObject  gTKeyObject = DataContext.OpenFeature(110, POLE_FID);
                Recordset     rs          = gTKeyObject.Components.GetComponent(1).Recordset;

                IGTGeometry geometry = gTKeyObject.Components.GetComponent(11002).Geometry;
                IGTPoint    point    = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                point.Z = geometry.FirstPoint.Z;
                customBoundaryQuery boundaryQuery = new customBoundaryQuery(point, 235);// County boundary  FNO 235
                Recordset           resultRs1     = boundaryQuery.PerformPointInPolygon();

                if (resultRs1 != null && resultRs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature        = DataContext.OpenFeature(Convert.ToInt16(resultRs1.Fields["G3E_FNO"].Value), Convert.ToInt32(resultRs1.Fields["G3E_FID"].Value));
                    Recordset    boundaryAttributesRs = countyFeature.Components.GetComponent(23501).Recordset; // // County Boundary Attributes
                    if (boundaryAttributesRs != null && boundaryAttributesRs.RecordCount > 0)
                    {
                        boundaryAttributesRs.MoveFirst();
                        if (!string.IsNullOrEmpty(Convert.ToString(boundaryAttributesRs.Fields["ID"].Value)))
                        {
                            string    countyBoundaryId = Convert.ToString(boundaryAttributesRs.Fields["ID"].Value).Replace("TX", string.Empty).Trim();
                            Recordset memberCodeRS     = GetRecordSet(string.Format(@"SELECT NJUNS_MEMBER FROM NJUNS_MEMBER A , NJUNS_CONTACTS B WHERE A.NJUNS_MEMBER_ID = B.NJUNS_MEMBER_ID AND
                                                                        B.COUNTY_N_ID = {0} ", countyBoundaryId));

                            if (memberCodeRS != null && memberCodeRS.RecordCount > 0)
                            {
                                memberCodeRS.MoveFirst();
                                while (!memberCodeRS.EOF)
                                {
                                    codesList.Add(Convert.ToString(memberCodeRS.Fields["NJUNS_MEMBER"].Value));
                                    memberCodeRS.MoveNext();
                                }
                                memberCodeRS.Close();
                                memberCodeRS = null;
                            }
                        }
                    }
                }
                return(codesList);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get the pole attributes and populates Ticket Attributes class
        /// </summary>
        /// <returns>True, if Ticket Attributes are populated successfully. Else returns false</returns>
        private bool GetPoleAttributes()
        {
            string serviceAreaCode        = string.Empty;
            string countyBoundaryId       = string.Empty;
            int    nearestServicePointFid = 0;
            Dictionary <int, double> servicePointsDictionary = null;

            try
            {
                m_TicketAttributes = new TicketAttributes();
                IGTKeyObject gTKeyObject = m_DataContext.OpenFeature(110, m_PoleFid);
                Recordset    rs          = gTKeyObject.Components.GetComponent(1).Recordset;
                if (rs != null && rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    m_TicketAttributes.POLE_FID         = m_PoleFid;
                    m_TicketAttributes.POLE_NUMBER      = Convert.ToString(rs.Fields["STRUCTURE_ID"].Value);
                    m_TicketAttributes.MISCELLANEOUS_ID = m_WrNumber;
                    m_TicketAttributes.LATITUDE         = Convert.ToString(rs.Fields["LATITUDE"].Value);
                    m_TicketAttributes.LONGITUDE        = Convert.ToString(rs.Fields["LONGITUDE"].Value);
                }
                IGTGeometry geometry = gTKeyObject.Components.GetComponent(11002).Geometry;
                IGTPoint    point    = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                point.Z = geometry.FirstPoint.Z;
                customBoundaryQuery boundaryQuery = new customBoundaryQuery(point, 235);// County boundary  FNO 235
                Recordset           resultRs1     = boundaryQuery.PerformPointInPolygon();
                if (resultRs1 != null && resultRs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature        = m_DataContext.OpenFeature(Convert.ToInt16(resultRs1.Fields["G3E_FNO"].Value), Convert.ToInt32(resultRs1.Fields["G3E_FID"].Value));
                    Recordset    boundaryAttributesRs = countyFeature.Components.GetComponent(23501).Recordset; // // County Boundary Attributes
                    if (boundaryAttributesRs != null && boundaryAttributesRs.RecordCount > 0)
                    {
                        boundaryAttributesRs.MoveFirst();
                        m_TicketAttributes.COUNTY = Convert.ToString(boundaryAttributesRs.Fields["NAME"].Value);
                        if (!string.IsNullOrEmpty(Convert.ToString(boundaryAttributesRs.Fields["ID"].Value)))
                        {
                            countyBoundaryId = Convert.ToString(boundaryAttributesRs.Fields["ID"].Value).Replace("TX", string.Empty).Trim();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(countyBoundaryId))
                {
                    int nJunsMemberId = 0;

                    Recordset contactRs = GetRecordSet(string.Format("SELECT NJUNS_MEMBER_ID,CONTACT_NAME,CONTACT_PHONE FROM NJUNS_CONTACTS WHERE COUNTY_N_ID = {0}", countyBoundaryId));
                    if (contactRs != null && contactRs.RecordCount > 0)
                    {
                        contactRs.MoveFirst();
                        m_TicketAttributes.CONTACT_NAME  = Convert.ToString(contactRs.Fields["CONTACT_NAME"].Value);
                        m_TicketAttributes.CONTACT_PHONE = Convert.ToString(contactRs.Fields["CONTACT_PHONE"].Value);
                        // m_TicketAttributes.PLACE = Convert.ToString(contactRs.Fields["NJUNS_PLACE_NAME"].Value);
                        nJunsMemberId = Convert.ToInt32(contactRs.Fields["NJUNS_MEMBER_ID"].Value);
                        contactRs.Close();
                        contactRs = null;
                    }
                    contactRs = GetRecordSet(string.Format("SELECT NJUNS_MEMBER FROM NJUNS_MEMBER WHERE NJUNS_MEMBER_ID = {0}", nJunsMemberId));
                    if (contactRs != null && contactRs.RecordCount > 0)
                    {
                        contactRs.MoveFirst();
                        m_TicketAttributes.CREATED_MEMBER = Convert.ToString(contactRs.Fields["NJUNS_MEMBER"].Value);
                        m_TicketAttributes.POLE_OWNER     = Convert.ToString(contactRs.Fields["NJUNS_MEMBER"].Value);
                    }
                }

                customBufferQuery oCustomBufferQuery = new customBufferQuery(point, m_DistanceFromPoleInFeet, 55); //Closest Premise feature within 300 feet of the Pole. Service point FNO 55
                servicePointsDictionary = oCustomBufferQuery.PerformBufferQuery();
                if (servicePointsDictionary != null && servicePointsDictionary.Count > 0)
                {
                    servicePointsDictionary.OrderBy(key => key.Value);
                    nearestServicePointFid = servicePointsDictionary.First().Key;
                    IGTKeyObject servicePointFeature = m_DataContext.OpenFeature(55, nearestServicePointFid);
                    Recordset    premiseAttributesRs = servicePointFeature.Components.GetComponent(5504).Recordset; // PREMISE_N
                    if (premiseAttributesRs != null && premiseAttributesRs.RecordCount > 0)
                    {
                        premiseAttributesRs.MoveFirst();
                        m_TicketAttributes.HOUSE_NUMBER = Convert.ToString(premiseAttributesRs.Fields["HOUSE_NBR"].Value);
                        m_TicketAttributes.STREET_NAME  = Convert.ToString(premiseAttributesRs.Fields["DIR_LEADING_C"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["STREET_NM"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["STREET_TYPE_C"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["DIR_TRAILING_C"].Value);
                    }
                }

                // Set default vaues
                m_TicketAttributes.TICKET_NUMBER   = string.Empty;
                m_TicketAttributes.TICKET_TYPE     = "Transfer";
                m_TicketAttributes.TICKET_STATUS   = "OPEN";
                m_TicketAttributes.STATE           = "TX";
                m_TicketAttributes.PRIORITY_CODE   = "3";
                m_TicketAttributes.NJUNS_TICKET_ID = -1;
                m_TicketAttributes.DAYS_INTERVAL   = "30";
                m_TicketAttributes.JOB_TYPE        = "Transfer";
                m_TicketAttributes.NUMBER_OF_POLES = "1";
                m_TicketAttributes.REMARKS         = string.Empty;
                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to populate some ticket attributes.", "Custom Create Ticket Error", MessageBoxButtons.OK);
                return(false);
            }
        }
        private void CopyValuesFromBoundaries(Recordset premiseAttributesRs)
        {
            short  fNo              = 0;
            int    fId              = 0;
            string city             = string.Empty;
            string county           = string.Empty;
            string zipCode          = string.Empty;
            string insideCityLimits = string.Empty;
            string tmpQry           = string.Empty;

            try
            {
                short cityFNO   = Convert.ToInt16(m_Arguments.GetArgument(0));
                int   cityANO   = Convert.ToInt32(m_Arguments.GetArgument(1));
                short countyFNO = Convert.ToInt16(m_Arguments.GetArgument(2));
                int   countyANO = Convert.ToInt32(m_Arguments.GetArgument(3));
                short zipFNO    = Convert.ToInt16(m_Arguments.GetArgument(4));
                int   zipANO    = Convert.ToInt32(m_Arguments.GetArgument(5));

                Recordset commonComponentRs = Components.GetComponent(1).Recordset;
                if (commonComponentRs != null && commonComponentRs.RecordCount > 0)
                {
                    commonComponentRs.MoveFirst();
                    fNo = Convert.ToInt16(commonComponentRs.Fields["G3E_FNO"].Value);
                    fId = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value);
                }

                short primaryGraphicCno = GetPrimaryGraphicCno(fNo);
                if (primaryGraphicCno == 0)
                {
                    return;
                }
                IGTKeyObject             servicePointFeature = m_DataContext.OpenFeature(fNo, fId);
                IGTOrientedPointGeometry geometry            = (IGTOrientedPointGeometry)servicePointFeature.Components.GetComponent(primaryGraphicCno).Geometry;
                if (geometry == null)
                {
                    return;
                }
                IGTPoint point = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                // City
                customBoundaryQuery objCustomBoundaryQuery = new customBoundaryQuery(point, cityFNO);
                Recordset           rs = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs != null && rs.RecordCount > 0)
                {
                    IGTKeyObject cityFeature = DataContext.OpenFeature(Convert.ToInt16(rs.Fields["G3E_FNO"].Value), Convert.ToInt32(rs.Fields["G3E_FID"].Value));

                    Recordset tempRs = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + cityANO);
                    if (tempRs != null && tempRs.RecordCount > 0)
                    {
                        tempRs.MoveFirst();
                        string field = Convert.ToString(tempRs.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["CITY_C"].Value))) && cno > 0)
                            {
                                Recordset cityRs = cityFeature.Components.GetComponent(cno).Recordset;
                                if (cityRs != null && cityRs.RecordCount > 0)
                                {
                                    cityRs.MoveFirst();
                                    city = Convert.ToString(cityRs.Fields[field].Value);
                                }
                                if (!string.IsNullOrEmpty(city))
                                {
                                    //premiseAttributesRs.Fields["CITY_C"].Value = city;
                                    m_City = city;
                                    //premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = "Y";
                                    m_CityLimits = "Y";
                                }
                            }
                        }
                    }
                }

                // County
                objCustomBoundaryQuery = new customBoundaryQuery(point, countyFNO);
                Recordset rs1 = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs1 != null && rs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature = DataContext.OpenFeature(Convert.ToInt16(rs1.Fields["G3E_FNO"].Value), Convert.ToInt32(rs1.Fields["G3E_FID"].Value));
                    Recordset    tempRs1       = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + countyANO);
                    if (tempRs1 != null && tempRs1.RecordCount > 0)
                    {
                        tempRs1.MoveFirst();
                        string field = Convert.ToString(tempRs1.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs1.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs1.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["COUNTY_C"].Value))) && cno > 0)
                            {
                                Recordset countyRs = countyFeature.Components.GetComponent(cno).Recordset;
                                if (countyRs != null && countyRs.RecordCount > 0)
                                {
                                    countyRs.MoveFirst();
                                    county = Convert.ToString(countyRs.Fields[field].Value);
                                }

                                if (!string.IsNullOrEmpty(county))
                                {
                                    //premiseAttributesRs.Fields["COUNTY_C"].Value = county;
                                    m_CountyCode = county;
                                }
                            }
                        }
                    }
                }

                // Zip Code
                objCustomBoundaryQuery = new customBoundaryQuery(point, zipFNO);
                Recordset rs2 = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs2 != null && rs2.RecordCount > 0)
                {
                    IGTKeyObject zipCodeFeature = DataContext.OpenFeature(Convert.ToInt16(rs2.Fields["G3E_FNO"].Value), Convert.ToInt32(rs2.Fields["G3E_FID"].Value));
                    Recordset    tempRs2        = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + zipANO);
                    if (tempRs2 != null && tempRs2.RecordCount > 0)
                    {
                        tempRs2.MoveFirst();
                        string field = Convert.ToString(tempRs2.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs2.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs2.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["ZIP_C"].Value))) && cno > 0)
                            {
                                Recordset zipRs = zipCodeFeature.Components.GetComponent(cno).Recordset;
                                if (zipRs != null && zipRs.RecordCount > 0)
                                {
                                    zipRs.MoveFirst();
                                    zipCode = Convert.ToString(zipRs.Fields[field].Value);
                                }
                                if (!string.IsNullOrEmpty(zipCode))
                                {
                                    //premiseAttributesRs.Fields["ZIP_C"].Value = zipCode;
                                    m_ZipCode = zipCode;
                                }
                            }
                        }
                    }

                    try
                    {
                        premiseAttributesRs.Fields["CITY_C"].Value = m_City;
                        premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = m_CityLimits;
                        premiseAttributesRs.Fields["COUNTY_C"].Value = m_CountyCode;
                        premiseAttributesRs.Fields["ZIP_C"].Value    = m_ZipCode;
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Operation was canceled.")
                        {
                            int tmpRecModified = 0;
                            tmpQry = "begin update premise_n set CITY_C = '" + m_City + "', INSIDE_CITY_LIMITS_YN  = '" + m_CityLimits +
                                     "', COUNTY_C = '" + m_CountyCode + "', ZIP_C = '" + m_ZipCode +
                                     "' where g3e_fid = " + premiseAttributesRs.Fields["G3E_FID"].Value.ToString() +
                                     " and g3e_cid = " + premiseAttributesRs.Fields["G3E_CID"].Value.ToString() + "; end;";

                            m_DataContext.Execute(tmpQry, out tmpRecModified, (int)CommandTypeEnum.adCmdText);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }