Ejemplo n.º 1
0
        /// <summary>
        /// Updates a given field in the G3E_JOB table.
        /// </summary>
        /// <param name="jobID">Job ID (G3E_IDENTIFIER)</param>
        /// <param name="fieldName">Field to update</param>
        /// <param name="fieldValue">Value to assign to field</param>
        /// <returns>Contains exception message string.</returns>
        public string UpdateJobField(string jobID, string fieldName, string fieldValue)
        {
            string SQL = string.Format("update g3e_job set {0}=? where g3e_identifier=?", fieldName);

            dc.Execute(SQL, out int outRecs, (int)CommandTypeEnum.adCmdText + (int)ExecuteOptionEnum.adExecuteNoRecords, fieldValue, jobID);

            string exception = string.Empty;

            switch (outRecs)
            {
            case 0:
                exception = string.Format("Unable to locate job record for job: {0}.", ActiveJob);
                break;

            case 1:
                break;

            default:
                dc.Execute("rollback", out outRecs, (int)CommandTypeEnum.adCmdText);
                exception = string.Format("More than one job record found for job: {0}.  Update rolled back.", ActiveJob);
                break;
            }

            return(exception);
        }
Ejemplo n.º 2
0
        // Call the GISPKG_CCB_ESILOCATION.ValidatePremise database function to validate
        // that a record exists in CC&B with the ESI_LOCATION value matching the user entered ESI Location.
        private bool ExistsInCCB(string esiLocation)
        {
            bool returnValue = true;

            try
            {
                string sql = "select GISPKG_CCB_ESILOCATION.ValidatePremise(?) as Status from dual";

                int recordsAffected = 0;

                Recordset spRS = m_DataContext.Execute(sql, out recordsAffected, (int)CommandTypeEnum.adCmdText, esiLocation);

                if (!Convert.ToBoolean(spRS.Fields["Status"].Value))
                {
                    if (m_InteractiveMode)
                    {
                        MessageBox.Show(ERROR_INVALID_ESILOCATION, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    returnValue = false;
                }
            }
            catch (Exception ex)
            {
                if (m_InteractiveMode)
                {
                    MessageBox.Show("Error in fiESILocationUpdate:ExistsInCCB - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                returnValue = false;
            }

            return(returnValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get DesignAreaKeyObject of current Job.
        /// </summary>
        /// <returns></returns>
        public IGTKeyObject GetDesignAreaKeyObject()
        {
            string    sql          = "SELECT G3E_FID FROM DESIGNAREA_P WHERE JOB_ID=:1";
            int       outRecords   = 0;
            Recordset rsDesignArea = null;

            try
            {
                rsDesignArea = m_gTDataContext.Execute(sql, out outRecords, (int)CommandTypeEnum.adCmdText, ActiveWorkRequest);

                if (rsDesignArea.RecordCount > 0)
                {
                    rsDesignArea.MoveFirst();
                    return(m_gTDataContext.OpenFeature(8100, Convert.ToInt32(rsDesignArea.Fields[0].Value)));
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                rsDesignArea.Close();
                rsDesignArea = null;
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Execute SQL Statement
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sqlStmt"></param>
        /// <returns></returns>
        public static List <T> Execute <T>(string sqlStmt)
        {
            int recordsAffected;

            ADODB.Recordset rs = null;
            rs = _gtDataContext.Execute(sqlStmt, out recordsAffected, (int)ADODB.CommandTypeEnum.adCmdText);
            return(ConvertRSToEntity <T>(rs));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute SQL statement
        /// </summary>
        /// <param name="sqlStmt"></param>
        /// <returns></returns>
        public static Recordset Execute(string sqlStmt)
        {
            int recordsAffected;

            ADODB.Recordset rs = null;
            rs = _gtDataContext.Execute(sqlStmt, out recordsAffected, (int)ADODB.CommandTypeEnum.adCmdText);
            return(rs);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Method to convert storage coordinates to Latitude and Longitude
        /// </summary>
        /// <param name="dXoord">X location</param>
        /// <param name="dYoord">Y location</param>
        /// <param name="dZoord">Z location (0)</param>
        private void ConvertToLatitudeAndLongitude(ref double dXoord, ref double dYoord, ref double dZoord)
        {
            try
            {
                Intergraph.CoordSystems.Interop.CoordSystemClass coords = new CoordSystemClass();
                int             outrec = 0;
                ADODB.Recordset rs     = DataContext.Execute("select c.*  from g3e_dataconnection_optable d , gcoordsystemtable  c where " +
                                                             " d.g3e_username ='******' and d.g3e_csname=c.name", out outrec, (int)ADODB.CommandTypeEnum.adCmdText, new object[0]);

                rs.MoveFirst();
                object[] rowformat = new object[rs.Fields.Count];
                for (int ifld = 0; ifld < rs.Fields.Count; ifld++)
                {
                    rowformat[ifld] = rs.Fields[ifld].Value;
                }
                coords.LoadFromGCoordSystemTableRowFormat(rowformat);

                coords.TransformPoint(Intergraph.CoordSystems.Interop.CSPointConstants.cspUOR, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation,
                                      Intergraph.CoordSystems.Interop.CSPointConstants.cspLLO, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation,
                                      ref dXoord, ref dYoord, ref dZoord);

                dXoord = dXoord * 180 / (4 * Math.Atan(1));
                dYoord = dYoord * 180 / (4 * Math.Atan(1));
            }
            catch (Exception)
            {
                throw;
            }
        }
 public bool DisplayBoundaryErrorExecute(Recordset RS)
 {
     if (m_Components[ComponentName].Recordset.EOF)
     {
         m_Components[ComponentName].Recordset.MoveFirst();
     }
     if (!(RS.RecordCount > 0) && jobManager.JobStatus.ToUpper() == "NON-WR") //if job status is non-wr, then value is reset and a slightly different error message is displayed.
     {
         app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "GRAPHIC EDIT REJECTED: Street Light is located outside the associated Street Light Account boundary.");
         //reset g3e_geometry field to value before change
         string fno = m_Components[m_ComponentName].Recordset.Fields["G3E_FNO"].Value.ToString();
         string fid = m_Components[m_ComponentName].Recordset.Fields["G3E_FID"].Value.ToString();
         gTransMgr.Begin("Resetting Geometry Value");
         string SQL = "update B$STREETLIGHT_T set G3E_GEOMETRY = ? where G3E_FNO = ? and G3E_FID = ?";
         m_DataContext.Execute(SQL, out int RecordsAffected, (int)ADODB.CommandTypeEnum.adCmdText, FieldValueBeforeChange, fno, fid);
         gTransMgr.Commit();
         return(true);
     }
     else if (!(RS.RecordCount > 0))
     {
         app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "ACCOUNT # CONFLICT: Street Light is located outside the associated Street Light Account boundary.");
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Method to create validation log entry in table VALIDATION_LOG
        /// </summary>
        /// <param name="p_LogType"></param>
        /// <param name="p_LogCode"></param>
        /// <param name="p_LogMsg"></param>
        /// <param name="p_LogContext"></param>
        /// <param name="p_ErrorPriority"></param>
        /// <returns></returns>
        public bool LogEntry(string p_LogType, string p_LogCode, string p_LogMsg, string p_LogContext, string p_ErrorPriority)
        {
            IGTApplication tmpApp     = GTClassFactory.Create <IGTApplication>();
            IGTDataContext tmpDatCont = tmpApp.DataContext;

            // Build the data insert script.
            string tmpInsertStr =
                @"begin insert into VALIDATION_LOG columns(VALIDATION_IFACE_TYPE,VALIDATION_NAME,JOB_ID,ACTIVE_FID,
                  ACTIVE_COMP_NAME,ACTIVE_FIELD_NAME, ACTIVE_FIELD_VALUE,RELATED_FID, RELATED_COMP_NAME, RELATED_FIELD_NAME,
                    RELATED_FIELD_VALUE,LOG_CODE,LOG_MSG,LOG_CONTEXT,ERROR_PRIORITY,LOG_TYPE) values";

            bool tmpReturn = true;
            // get the values list.
            string tmpValues = BuildValuesList(p_LogType, p_LogCode, p_LogMsg, p_LogContext, p_ErrorPriority, tmpDatCont);

            if (string.IsNullOrEmpty(tmpValues))
            {
                //The buildValuesList function generated an error and a empty string was returned.
                tmpReturn = false;
            }
            else
            {
                try
                {
                    // The buildValuesList function succeeded.
                    // Complete the insert script.
                    tmpInsertStr = string.Format("{0} {1};commit;end;", tmpInsertStr, tmpValues);
                    // Execute the insert script
                    tmpDatCont.Execute(tmpInsertStr, out int tmpRecUpdated, (int)CommandTypeEnum.adCmdText);
                }
                catch (Exception ex)
                {
                    tmpReturn = false;

                    // If the error is due to privileges (resulting in a "table or view does not exist"), then only write
                    // the exception message to the event log.  Otherwise, write the error to the command log.
                    if (ex.Message.Contains("ORA-00942"))
                    {
                        // Log an error to the Applcation Error Event Log.
                        if (EventLog.SourceExists("Application Error"))
                        {
                            EventLog.WriteEntry("Application Error", "Error in G/Technology Custom Command Logger - gtCommandLogger.logEntry: " + ex.Message);
                        }
                    }
                    else
                    {
                        // This may risk infinite recursion, but since the error is not due to table access,
                        // then merely logging the error message should not produce an exception and when this call returns,
                        // then this "catch" should fall through and exit.
                        this.LogEntry(null, null, ex.Message, null, null);
                    }
                }
            }

            return(tmpReturn);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// If the triggering component is Ancillary CU Attributes,If the Unit CNO, Unit CID, and Ancillary Attribute attributes are populated.
        /// Find the corresponding attribute on the active feature,If found, set the attribute to null.
        /// </summary>
        public void SetAncillaryAttribute()
        {
            int       ancillaryAno       = 0;
            string    sql                = "";
            Recordset rsAncillaryFeature = null;
            Recordset rsAncillaryAno     = null;
            int       count              = 0;
            short     cno                = 0;
            string    strField           = "";

            try
            {
                Recordset rsAncillary = m_gTActiveComponent.Recordset;
                if (!string.IsNullOrEmpty(Convert.ToString(rsAncillary.Fields["UNIT_CNO"].Value)) && Convert.ToInt16(rsAncillary.Fields["UNIT_CNO"].Value) > 0)
                {
                    if (!string.IsNullOrEmpty(Convert.ToString(rsAncillary.Fields["UNIT_CID"].Value)) && Convert.ToInt16(rsAncillary.Fields["UNIT_CID"].Value) > 0)
                    {
                        if (!string.IsNullOrEmpty(Convert.ToString(rsAncillary.Fields["ACU_ANO"].Value)) && Convert.ToInt32(rsAncillary.Fields["ACU_ANO"].Value) > 0)
                        {
                            ancillaryAno       = Convert.ToInt32(rsAncillary.Fields["ACU_ANO"].Value);
                            sql                = "select g3e_cno,g3e_field from G3E_ATTRIBUTEINFO_OPTABLE where g3e_ano=:1 and g3e_cno in (select distinct g3e_cno from G3E_FEATURECOMPS_OPTABLE where g3e_fno=:2)";
                            rsAncillaryFeature = m_gTDataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, ancillaryAno, m_ActiveKeyObject.FNO);

                            if (rsAncillaryFeature != null && rsAncillaryFeature.RecordCount > 0)
                            {
                                rsAncillaryFeature.MoveFirst();
                                cno      = Convert.ToInt16(rsAncillaryFeature.Fields[0].Value);
                                strField = Convert.ToString(rsAncillaryFeature.Fields[1].Value);

                                rsAncillaryAno = m_ActiveKeyObject.Components.GetComponent(cno).Recordset;
                                if (rsAncillaryAno != null)
                                {
                                    rsAncillaryAno.MoveFirst();
                                    while (!rsAncillaryAno.EOF)
                                    {
                                        if (Convert.ToInt16(rsAncillaryAno.Fields["G3E_CNO"].Value) == Convert.ToInt16(rsAncillary.Fields["UNIT_CNO"].Value) &&
                                            Convert.ToInt32(rsAncillaryAno.Fields["G3E_CID"].Value) == Convert.ToInt32(rsAncillary.Fields["UNIT_CID"].Value))
                                        {
                                            rsAncillaryAno.Fields[strField].Value = "";
                                            rsAncillaryAno.Update();
                                        }
                                        rsAncillaryAno.MoveNext();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Method to save the preferred CUs to cuselect_userpref table.
 /// </summary>
 internal void SaveToPreferredCUs(Dictionary <string, string> deltaPreferred)
 {
     try
     {
         StringBuilder insertQuery = new StringBuilder();
         insertQuery.AppendFormat(" BEGIN ");
         foreach (KeyValuePair <string, string> preferredCU in deltaPreferred)
         {
             string[] splitCU = SplitSelectedItem(preferredCU.Key);
             insertQuery.AppendFormat("insert into cuselect_userpref(PREF_UID,CU_CODE, CU_CATEGORY_CODE) values( '{0}','{1}','{2}') ; ", DataContext.DatabaseUserName, splitCU[0].Trim(), preferredCU.Value);
         }
         string sql = insertQuery.ToString() + " commit;";
         sql = sql + " END ;";
         int iRecordsAffected = 0;
         DataContext.Execute(sql, out iRecordsAffected, (int)CommandTypeEnum.adCmdText);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// simple function that executes an SQL query
        /// </summary>
        /// <param name="DataContext">IGTDataContext</param>
        /// <param name="SQL_String">String</param>
        /// <returns></returns>
        public static Recordset ExecuteQuery(IGTDataContext DataContext, String SQL_String)
        {
            Recordset oRS       = null;
            int       rEffected = -1;

            try
            {
                oRS = DataContext.Execute(SQL_String, out rEffected, (int)CommandTypeEnum.adCmdText, null);
            }
            catch (Exception e)
            {
                MessageBox.Show(gApp.ApplicationWindow, "ExecuteQuery: " + e.Message, "Import Attachments - Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(oRS);
        }
Ejemplo n.º 12
0
        public static Recordset ExecuteQuery(IGTDataContext _dc, String sSql, GTDiagnostics _diag)
        {
            Recordset _rs = null;

            try
            {
                int rEffected = -1;
                _rs = _dc.Execute(sSql, out rEffected, (int)CommandTypeEnum.adCmdText, null);
            }
            catch (Exception ex)
            {
                if (_diag.IsEnabled(GTDiagCat.EE))
                {
                    _diag.LogException("CommandUtilities.ExecuteQuery", ex);
                }
            }

            return(_rs);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Method to update the Structure Id of associated work points for a structure
        /// </summary>
        /// <param name="fno"></param>
        /// <param name="fid"></param>
        /// <param name="newStructureId"></param>
        private void UpdateAssociatedWorkPointsStructureId(short fno, int fid, string newStructureId)
        {
            List <int> workPointFidList = null;

            try
            {
                int             recordsAffected = 0;
                ADODB.Recordset rs = m_dataContext.Execute("select g3e_fid WPFID from workpoint_cu_n where assoc_fid = " + fid + " and assoc_fno =" + fno, out recordsAffected, (int)ADODB.CommandTypeEnum.adCmdText, new int[0]);
                if (rs != null && rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    workPointFidList = new List <int>();
                    while (!rs.EOF)
                    {
                        workPointFidList.Add(Convert.ToInt32(rs.Fields["WPFID"].Value));
                        rs.MoveNext();
                    }
                }

                if (workPointFidList != null)
                {
                    foreach (int wpFid in workPointFidList)
                    {
                        IGTKeyObject workPointFeature = m_dataContext.OpenFeature(191, wpFid);
                        if (workPointFeature != null)
                        {
                            Recordset workPointFeatureRs = workPointFeature.Components.GetComponent(19101).Recordset;
                            if (workPointFeatureRs != null && workPointFeatureRs.RecordCount > 0)
                            {
                                workPointFeatureRs.MoveFirst();
                                workPointFeatureRs.Fields["STRUCTURE_ID"].Value = newStructureId;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 14
0
        public bool InsertStepRecords()
        {
            int iRecordsAffected = 0;

            try
            {
                StringBuilder insertQuery = new StringBuilder();
                insertQuery.AppendFormat(" BEGIN ");
                insertQuery.AppendFormat(@"INSERT INTO NJUNS_STEP(
                                                     GIS_NJUNS_TICKET_ID,
                                                     NJUNS_TICKET_ID,
                                                     JOB_TYPE,
                                                     NUMBER_POLES,
                                                     DAYS_INTERVAL,
                                                     REMARKS
                                                     )
                                                     VALUES({0},{1},'{2}','{3}','{4}','{5}');",
                                         GIS_NJUNS_TICKET_ID,
                                         NJUNS_TICKET_ID,
                                         JOB_TYPE,
                                         NUMBER_POLES,
                                         DAYS_INTERVAL,
                                         REMARKS
                                         );
                insertQuery.AppendFormat(" COMMIT ; ");
                insertQuery.AppendFormat("  END ; ");
                string insertSql = insertQuery.ToString();
                DataContext.Execute(insertSql, out iRecordsAffected, (int)CommandTypeEnum.adCmdText);
                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to insert step record", "Custom Create Ticket Error", MessageBoxButtons.OK);
                return(false);
            }
        }
Ejemplo n.º 15
0
        public void AfterEstablish()
        {
            short        iFNOActive  = 0;
            short        iFNORelated = 0;
            List <short> featureList = new List <short>();

            ADODB.Recordset rs;
            int             cnt = 0;

            try
            {
                if (m_oActiveComponents[m_sActiveComponentName].Recordset != null)
                {
                    if (!(m_oActiveComponents[m_sActiveComponentName].Recordset.EOF && m_oActiveComponents[m_sActiveComponentName].Recordset.BOF))
                    {
                        m_oActiveComponents[m_sActiveComponentName].Recordset.MoveFirst();
                        iFNOActive = Convert.ToInt16(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["g3e_fno"].Value);
                    }
                }

                if (m_oRelatedComponents[m_sRelatedComponentName].Recordset != null)
                {
                    if (!(m_oRelatedComponents[m_sRelatedComponentName].Recordset.EOF && m_oRelatedComponents[m_sRelatedComponentName].Recordset.BOF))
                    {
                        m_oRelatedComponents[m_sRelatedComponentName].Recordset.MoveFirst();
                        iFNORelated = Convert.ToInt16(m_oRelatedComponents[m_sRelatedComponentName].Recordset.Fields["g3e_fno"].Value);
                    }
                }

                string sql = @"select g3e_fno from g3e_featurecomps_optable where g3e_fno in 
								(SELECT f.g3e_fno FROM g3e_features_optable f,  g3e_featurecomps_optable C 
								WHERE c.g3e_cno=F.G3e_Primarygeographiccno and c.g3e_type=16)
								and g3e_cno=1"                                ;

                rs = m_oDataContext.Execute(sql, out cnt, (int)ADODB.CommandTypeEnum.adCmdText);
                if (rs != null)
                {
                    if (!(rs.EOF && rs.BOF))
                    {
                        rs.MoveFirst();
                        for (int i = 0; i < rs.RecordCount; i++)
                        {
                            featureList.Add(Convert.ToInt16(rs.Fields["g3e_fno"].Value));
                            rs.MoveNext();
                        }
                    }
                }
                if (featureList.Contains(iFNOActive))
                {
                    if (m_oRelatedComponents[m_OwnerComponent].Recordset != null)
                    {
                        if (!(m_oRelatedComponents[m_OwnerComponent].Recordset.EOF && m_oRelatedComponents[m_OwnerComponent].Recordset.BOF))
                        {
                            m_oRelatedComponents[m_OwnerComponent].Recordset.MoveFirst();
                            if (m_oActiveComponents[m_sActiveComponentName].Recordset != null)
                            {
                                if (!(m_oActiveComponents[m_sActiveComponentName].Recordset.EOF && m_oActiveComponents[m_sActiveComponentName].Recordset.BOF))
                                {
                                    m_oActiveComponents[m_OwnerComponent].Recordset.MoveFirst();
                                    m_oActiveComponents[m_OwnerComponent].Recordset.Fields["STRUCTURE_ID"].Value = m_oRelatedComponents[m_OwnerComponent].Recordset.Fields["STRUCTURE_ID"].Value;
                                    m_oActiveComponents[m_OwnerComponent].Recordset.Fields["LATITUDE"].Value     = m_oRelatedComponents[m_OwnerComponent].Recordset.Fields["LATITUDE"].Value;
                                    m_oActiveComponents[m_OwnerComponent].Recordset.Fields["LONGITUDE"].Value    = m_oRelatedComponents[m_OwnerComponent].Recordset.Fields["LONGITUDE"].Value;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Owner Location Relationship Attribute Interface \n" + ex.Message, "G/Technology");
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Locate the associated Work Point feature (if it exists) for the active WR job.
        /// </summary>
        /// <param name="gTCommonComponent">Common component</param>
        /// <returns></returns>
        private IGTKeyObjects FindWorkpointsOfFeature(IGTComponent gTCommonComponent)
        {
            string        strStructureId      = null;
            string        sql                 = "";
            Recordset     rsWorkpoints        = null;
            int           count               = 0;
            IGTKeyObjects workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>();

            try
            {
                if (gTCommonComponent != null && gTCommonComponent.Recordset.RecordCount > 0)
                {
                    gTCommonComponent.Recordset.MoveFirst();
                    strStructureId = Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value);
                }

                if (!string.IsNullOrEmpty(strStructureId))
                {
                    sql          = string.Format("select G3E_FID,G3E_FNO from WORKPOINT_N where STRUCTURE_ID = '{0}' and WR_NBR = '{1}'", strStructureId, m_dataContext.ActiveJob);
                    rsWorkpoints = m_dataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, null);

                    if (rsWorkpoints != null && rsWorkpoints.RecordCount > 0)
                    {
                        workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>();
                        rsWorkpoints.MoveFirst();
                        while (!rsWorkpoints.EOF)
                        {
                            IGTKeyObject workPoint = m_dataContext.OpenFeature(Convert.ToInt16(rsWorkpoints.Fields["G3E_FNO"].Value), Convert.ToInt32(rsWorkpoints.Fields["G3E_FID"].Value));
                            workPointKeyObjects.Add(workPoint);
                            rsWorkpoints.MoveNext();
                        }
                    }
                    else if (m_NewWorkpointFidList.Count > 0)
                    {
                        foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList)
                        {
                            if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value))
                            {
                                IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value);
                                workPointKeyObjects.Add(workPoint);
                            }
                        }
                    }
                }
                else if (m_NewWorkpointFidList.Count > 0)
                {
                    foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList)
                    {
                        if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value))
                        {
                            IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value);
                            workPointKeyObjects.Add(workPoint);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }

            return(workPointKeyObjects);
        }
Ejemplo n.º 17
0
        public void Execute()
        {
            string city             = string.Empty;
            string county           = string.Empty;
            string zipCode          = string.Empty;
            string insideCityLimits = string.Empty;


            try
            {
                Recordset premiseAttributesRs = Components[ComponentName].Recordset;
                if (premiseAttributesRs != null && premiseAttributesRs.RecordCount > 0)
                {
                    premiseAttributesRs.MoveFirst();
                }

                while (!premiseAttributesRs.EOF)
                {
                    city             = Convert.ToString(premiseAttributesRs.Fields["CITY_C"].Value);
                    county           = Convert.ToString(premiseAttributesRs.Fields["COUNTY_C"].Value);
                    zipCode          = Convert.ToString(premiseAttributesRs.Fields["ZIP_C"].Value);
                    insideCityLimits = Convert.ToString(premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value);

                    if (Convert.ToInt16(premiseAttributesRs.Fields["G3E_CID"].Value) == 1)
                    {
                        if (string.IsNullOrEmpty(city) && string.IsNullOrEmpty(county) && string.IsNullOrEmpty(zipCode) && string.IsNullOrEmpty(insideCityLimits))
                        {
                            CopyValuesFromBoundaries(premiseAttributesRs);
                        }
                        if (!string.IsNullOrEmpty(city) || !string.IsNullOrEmpty(county) || !string.IsNullOrEmpty(zipCode) || !string.IsNullOrEmpty(insideCityLimits))
                        {
                            m_City       = city;
                            m_CountyCode = county;
                            m_ZipCode    = zipCode;
                            m_CityLimits = insideCityLimits;
                        }
                        premiseAttributesRs.MoveNext();
                    }

                    else
                    {
                        if (!string.IsNullOrEmpty(city) || !string.IsNullOrEmpty(county) || !string.IsNullOrEmpty(zipCode) || !string.IsNullOrEmpty(insideCityLimits))
                        {
                            m_City       = city;
                            m_CountyCode = county;
                            m_ZipCode    = zipCode;
                            m_CityLimits = insideCityLimits;
                        }

                        if (string.IsNullOrEmpty(city) && string.IsNullOrEmpty(county) && string.IsNullOrEmpty(zipCode) && string.IsNullOrEmpty(insideCityLimits))
                        {
                            premiseAttributesRs.Fields["CITY_C"].Value   = m_City;
                            premiseAttributesRs.Fields["COUNTY_C"].Value = m_CountyCode;
                            premiseAttributesRs.Fields["ZIP_C"].Value    = m_ZipCode;
                            premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = m_CityLimits;
                        }
                        premiseAttributesRs.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                GUIMode guiMode = new GUIMode();
                if (guiMode.InteractiveMode)
                {
                    MessageBox.Show("Error during execution of Set Premise Location By Boundary FI. " + ex.Message, "G/Technology");
                }
                else
                {
                    int    tmpRecModified = 0;
                    string tmpQry         = string.Empty;
                    tmpQry = "begin insert into gis_stg.interface_log " +
                             "(SUB_INTERFACE_NAME,INTERFACE_NAME,COMPONENT_NAME,CORRELATION_ID,LOG_DETAIL) " +
                             "values ('ccGISAutomationBroker','ccGISAutomationBroker','fiSetPremiseLocationByBoundary',0," +
                             "'Error during execution of Set Premise Location By Boundary FI. " + ex.Message +
                             "'); end;";

                    m_DataContext.Execute(tmpQry, out tmpRecModified, (int)CommandTypeEnum.adCmdText);
                }
            }
        }
Ejemplo n.º 18
0
        public void Execute()
        {
            double           dXoord         = 0.0;
            double           dYoord         = 0.0;
            double           dZoord         = 0.0;
            IGTGeometry      geometry       = null;
            IGTDDCKeyObjects oDDCKeyObjects = default(IGTDDCKeyObjects);

            IGTApplication igtApp = GTClassFactory.Create <IGTApplication>();

            oDDCKeyObjects = igtApp.SelectedObjects.GetObjects();

            foreach (IGTDDCKeyObject item in oDDCKeyObjects)
            {
                geometry = item.Geometry;
            }

            if (geometry != null)
            {
                dXoord = ((IGTPointGeometry)geometry).FirstPoint.X;
                dYoord = ((IGTPointGeometry)geometry).FirstPoint.Y;


                IGTPoint point = GTClassFactory.Create <IGTPoint>();
                point.X = dXoord;
                point.Y = dYoord;
                point.Z = 0.0;

                IGTComponent commonComponent = Components.GetComponent(1);
                if (commonComponent != null)
                {
                    if (commonComponent.Recordset.RecordCount > 0)
                    {
                        commonComponent.Recordset.MoveFirst();
                        commonComponent.Recordset.Fields["OGGX_H"].Value = point.X;
                        commonComponent.Recordset.Fields["OGGY_H"].Value = point.Y;
                    }
                }
                //ICoordSystemsMgr oCoordSystemsMgr;
                //oCoordSystemsMgr = (ICoordSystemsMgr)m_oDataContext.CoordSystemsMgr;
                //ICoordSystem oCoordSystem;
                //oCoordSystem = oCoordSystemsMgr.BaseCoordSystem;
                //double dMeters2Database = 1.0 / oCoordSystem.StorageToProjectionScale;



                //string strCurrDir = System.IO.Directory.GetCurrentDirectory();
                //ICoordSystemsMgr iCSM = new Intergraph.CoordSystems.CoordSystemsMgr();
                //ICoordSystem iCS = iCSM.BaseCoordSystem;
                //iCS.LoadFromFile(strCurrDir + "\\StatePlane.csf");

                //ICoordSystem iTargCS = new Intergraph.CoordSystems.CoordSystem();

                //	//iTargCS.LoadFromFile(strCurrDir + "\\EPSG4326.csf");
                //iTargCS.LoadFromFile(strCurrDir + "\\0061_WGS84.csf");
                //IAltCoordSystemPath iACSP = iCSM.CreateNamedPath("CSFFileConvert");
                //ILinkableTransformation iLink = iACSP.CreateLinkableTransformation("CSFFileConvert", Intergraph.CoordSystems.CSTransformLinkConstants.cstlCoordinateSystem);
                //ICoordSystem altCS = (ICoordSystem)iLink;
                //((ICopyable<ICoordSystem>)iTargCS).CopyInto(altCS);
                //iACSP.AddChainLink(iLink, true, Intergraph.CoordSystems.CSTransDirectionConstants.cstdForward);
                //ILinkableTransformation iTrans = (ILinkableTransformation)iACSP;
                //iTrans.TransformPoint(Intergraph.CoordSystems.CSPointConstants.cspENU, 1, Intergraph.CoordSystems.CSPointConstants.cspLLG, 2, ref dXoord, ref dYoord, ref dZoord);
                //MessageBox.Show(dXoord + "   " + dYoord);

                //---------------------------------------------------------------------------------------------------------------------------

                Intergraph.CoordSystems.Interop.CoordSystemClass coords = new CoordSystemClass();
                int             outrec = 0;
                ADODB.Recordset rs     = DataContext.Execute("select c.*  from g3e_dataconnection_optable d , gcoordsystemtable  c where " +
                                                             " d.g3e_username ='******' and d.g3e_csname=c.name", out outrec, (int)ADODB.CommandTypeEnum.adCmdText, new object[0]);
                rs.MoveFirst();
                object[] rowformat = new object[rs.Fields.Count];
                for (int ifld = 0; ifld < rs.Fields.Count; ifld++)
                {
                    rowformat[ifld] = rs.Fields[ifld].Value;
                }
                coords.LoadFromGCoordSystemTableRowFormat(rowformat);


                coords.TransformPoint(Intergraph.CoordSystems.Interop.CSPointConstants.cspUOR, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation,
                                      Intergraph.CoordSystems.Interop.CSPointConstants.cspLLO, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation,
                                      ref dXoord, ref dYoord, ref dZoord);

                dXoord = dXoord * 180 / (4 * Math.Atan(1));
                dYoord = dYoord * 180 / (4 * Math.Atan(1));
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// logEntry function logs an entry in the Command_Log table. It uses the
        ///  properties in the class to generate the log entry.
        /// </summary>
        /// <returns>true if it succeeds and false if it fails.</returns>
        public bool logEntry()
        {
            bool   tmpReturn    = true;
            string tmpInsertStr = string.Empty;

            try
            {
                // Get the GTech datacontext.
                IGTApplication tmpApp     = GTClassFactory.Create <IGTApplication>();
                IGTDataContext tmpDatCont = tmpApp.DataContext;

                // Build the data insert script.
                tmpInsertStr = "begin insert into COMMAND_LOG columns(COMMAND_NBR,COMMAND_NAME,LOG_TYPE,LOG_CODE,LOG_MSG,LOG_CONTEXT) values";

                // get the values list.
                string tmpValues = buildValuesList();

                if (string.IsNullOrEmpty(tmpValues))
                {
                    //The buildValuesList function generated an error and a empty string was returned.
                    tmpReturn = false;
                }
                else
                {
                    // The buildValuesList function succeeded.
                    // Complete the insert script.
                    tmpInsertStr = string.Format("{0} {1};commit;end;", tmpInsertStr, tmpValues);
                    // Execute the insert script
                    tmpDatCont.Execute(tmpInsertStr, out int tmpRecUpdated, (int)CommandTypeEnum.adCmdText);
                }
            }
            catch (Exception e)
            {
                if (isInteractive)
                {
                    // if in an interactive GTech Session, Show errors in a message box.
                    MessageBox.Show("Error: " + e.Message, "Error: gtCommandLogger.logEntry", MessageBoxButtons.OK);
                    tmpReturn = false;
                }
                else
                {
                    // If the error is due to privileges (resulting in a "table or view does not exist"), then only write
                    // the exception message to the event log.  Otherwise, write the error to the command log.
                    if (e.Message.Contains("ORA-00942"))
                    {
                        // Log an error to the Applcation Error Event Log.
                        if (EventLog.SourceExists("Application Error"))
                        {
                            EventLog.WriteEntry("Application Error", "Error in G/Technology Custom Command Logger - gtCommandLogger.logEntry: " + e.Message);
                        }
                    }
                    else
                    {
                        // This may risk infinite recursion, but since the error is not due to table access,
                        // then merely logging the error message should not produce an exception and when this call returns,
                        // then this "catch" should fall through and exit.
                        this.logMsg = e.Message;
                        this.logEntry();
                    }
                }
            }

            return(tmpReturn);
        }
Ejemplo n.º 20
0
        public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray)
        {
            if (_fieldName == "PHASE_POS_C")
            {
                ADODB.Recordset rs     = null;
                ADODB.Recordset rsTemp = null;
                int             record = 0;
                //string phasePosition = "";
                ErrorPriorityArray = null;
                ErrorMessageArray  = null;
                string sqlStmt = "Select {0},count({0}) from {1} where g3e_fid={2} and g3e_fno={3} GROUP BY {0} having count({0})>1";
                //string sqlQuery = "Select listagg(a.{0},',') within group (order by a.PHASE_POS_C) as PhasePosition from {1} a where g3e_fid={2} and not exists (Select  vl_key from VL_PHASE_POSITION p where p.vl_key=a.{0})";
                List <string> errorMsg      = new List <string>();
                List <string> errorPriority = new List <string>();
                try
                {
                    IGTComponent gtComponent = _components[_componentName];
                    if (gtComponent != null)
                    {
                        rs = gtComponent.Recordset;
                        if (rs != null && rs.RecordCount > 0)
                        {
                            if (Convert.ToInt32(rs.Fields["G3e_CID"].Value) == 1)
                            {
                                //JIRA 195- check Duplicate Phase Position
                                rsTemp = _dataContext.Execute(string.Format(sqlStmt, _fieldName, _componentName, rs.Fields["G3e_FID"].Value, rs.Fields["G3e_FNO"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null);
                                if (rsTemp != null && rsTemp.RecordCount > 0)
                                {
                                    errorMsg.Add("Feature having duplicate Phase Position. Phase Position should be unique across all the wires within same conductor.");
                                    errorPriority.Add("P1");
                                }

                                /*
                                 * Commneted this code as per Shubham suggestion
                                 *
                                 *                              // As per the JIRA 476 - Business Rule Validate Unknown Values in Phase Position
                                 *                              rsTemp = _dataContext.Execute(string.Format(sqlQuery, _fieldName, _componentName, rs.Fields["G3e_FID"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null);
                                 *                              if (rsTemp != null && rsTemp.RecordCount > 0)
                                 *                              {
                                 *                                      rsTemp.MoveFirst();
                                 *                                      phasePosition = Convert.ToString(rsTemp.Fields[0].Value);
                                 *                                      if (!string.IsNullOrEmpty(phasePosition))
                                 *                                      {
                                 *                                              errorMsg.Add("Phase Position " + rsTemp.Fields[0].Value + " are unknown Values");
                                 *                                              errorPriority.Add("P2");
                                 *                                      }
                                 *                              }
                                 */
                            }
                        }
                    }
                    if (errorMsg.Count > 0)
                    {
                        ErrorPriorityArray = errorPriority.ToArray();
                        ErrorMessageArray  = errorMsg.ToArray();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Caption);
                }
                finally
                {
                    rsTemp = null;
                }
            }
            else
            {
                ErrorPriorityArray = null;
                ErrorMessageArray  = null;
            }
        }
Ejemplo n.º 21
0
        // Return TRUE if attribute can be edited
        public bool IsAttributeEditable(int ANO)
        {
            bool bEditControl = true;

            try
            {
                // If the Component Name isn't passed in to this interface then skip processing.
                // This occurs when a field with a picklist is selected.
                if (m_ComponentName is null)
                {
                    return(bEditControl);
                }

                object propertyValue;

                // If G/Tech is not running in interactive mode, skip message boxes.
                GUIMode guiMode = new GUIMode();
                m_InteractiveMode = guiMode.InteractiveMode;

                // Skip processing if M_PROP_SKIP_AECEDITIFNOTPOSTED properties exists.
                // This flag is needed to let this attribute edit control
                // know that the passed in attribute is being set by an interface
                // such as a functional interface and that the processing
                // in this attribute edit control interface should be skipped.
                if (CheckIfPropertyExists(M_PROP_SKIP_AECEDITIFNOTPOSTED, out propertyValue))
                {
                    return(bEditControl);
                }

                Recordset componentRS = m_GTComponents[m_ComponentName].Recordset;

                if (componentRS.RecordCount > 0)
                {
                    if (!Convert.IsDBNull(componentRS.Fields["g3e_id"].Value))
                    {
                        int g3eID = Convert.ToInt32(componentRS.Fields["g3e_id"].Value);

                        // Only check if m_FieldCheck is populated.
                        // If m_FieldCheck is not populated then allow the attribute to be editable.
                        if (componentRS.Fields[m_FieldCheck].Value.ToString().Length > 0)
                        {
                            // Call the CheckIfPopulatedAndPosted database function to determine if a master record exists with the m_FieldCheck populated.
                            string sql = string.Format("select GISPKG_CCB_ESILOCATION.CheckIfPopulatedAndPosted('{0}','{1}',{2}) STATUS from dual", m_TableCheck, m_FieldCheck, g3eID);

                            int affectedRows = 0;

                            Recordset premiseRS = m_DataContext.Execute(sql, out affectedRows, (int)ADODB.CommandTypeEnum.adCmdText);

                            if (premiseRS.RecordCount > 0)
                            {
                                premiseRS.MoveFirst();
                                if (!Convert.IsDBNull(premiseRS.Fields["STATUS"].Value))
                                {
                                    int status = Convert.ToInt32(premiseRS.Fields["STATUS"].Value);
                                    // If CheckIfPopulatedAndPosted returns a zero then allow the attribute to be editable.
                                    // Otherwise, make the attribute read-only.
                                    if (status > 0)
                                    {
                                        bEditControl = false;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (m_InteractiveMode)
                {
                    MessageBox.Show("Error in aecEditIfNotPosted:IsAttributeEditable - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                bEditControl = false;
            }

            return(bEditControl);
        }
Ejemplo n.º 22
0
        public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray)
        {
            ADODB.Recordset rs     = null;
            ADODB.Recordset rsTemp = null;
            int             record = 0;
            bool            hasPhaseAndPosition     = true;
            bool            hasUnknownPhasePosition = false;

            ErrorPriorityArray = null;
            ErrorMessageArray  = null;

            GTValidationLogger gTValidationLogger = null;
            IGTComponent       comp = Components[ComponentName];
            int FID = 0;

            string fieldValue = string.Empty;

            if (comp != null && comp.Recordset != null && comp.Recordset.RecordCount > 0)
            {
                FID        = int.Parse(comp.Recordset.Fields["G3E_FID"].Value.ToString());
                fieldValue = Convert.ToString(comp.Recordset.Fields[FieldName].Value);
            }

            if (new gtLogHelper().CheckIfLoggingIsEnabled())
            {
                LogEntries logEntries = new LogEntries
                {
                    ActiveComponentName = ComponentName,
                    ActiveFID           = FID,
                    ActiveFieldName     = FieldName,
                    ActiveFieldValue    = fieldValue,
                    JobID = DataContext.ActiveJob,
                    RelatedComponentName    = "N/A",
                    RelatedFID              = 0,
                    RelatedFieldName        = "N/A",
                    RelatedFieldValue       = "N/A",
                    ValidationInterfaceName = "Phase Position",
                    ValidationInterfaceType = "FI"
                };
                gTValidationLogger = new GTValidationLogger(logEntries);

                gTValidationLogger.LogEntry("TIMING", "START", "Phase Position Entry", "N/A", "");
            }


            try
            {
                List <string>         errorMsg      = new List <string>();
                List <string>         errorPriority = new List <string>();
                string                priority      = Convert.ToString(_arguments.GetArgument(0));
                ValidationRuleManager validateMsg   = new ValidationRuleManager();
                IGTApplication        gTApplication = GTClassFactory.Create <IGTApplication>();

                Recordset commonComponentRs = Components.GetComponent(1).Recordset;
                commonComponentRs.MoveFirst();
                string orientation        = Convert.ToString(commonComponentRs.Fields["ORIENTATION_C"].Value);
                int    fNo                = Convert.ToInt32(commonComponentRs.Fields["G3E_FNO"].Value);
                string featureName        = Convert.ToString(GetRecordSet(string.Format("select g3e_username NAME from g3e_features_optable where g3e_fno = {0}", fNo)).Fields["NAME"].Value);
                int    fId                = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value);
                bool   isFeatureConnected = CheckFeatureConnectivity(fId);

                ValidatePhaseAndPhasePosition(out hasPhaseAndPosition, out hasUnknownPhasePosition);
                if (orientation == "OH" && featureName.ToUpper().Contains("PRIMARY") && isFeatureConnected && hasUnknownPhasePosition)
                {
                    validateMsg.Rule_Id = "PHPS01";
                    validateMsg.BuildRuleMessage(gTApplication, null);

                    errorPriority.Add(priority);
                    errorMsg.Add(validateMsg.Rule_MSG);

                    //errorMsg.Add("Overhead feature is missing phase position values.");
                }

                if (ValidatePhasePositionWithSets())
                {
                    validateMsg.Rule_Id = "PHPS02";
                    validateMsg.BuildRuleMessage(gTApplication, null);

                    errorPriority.Add(priority);
                    errorMsg.Add(validateMsg.Rule_MSG);

                    //errorMsg.Add("Phase Position attributes are not consistent with respect to one another.");
                }

                if (_fieldName == "PHASE_POS_C")
                {
                    string       sqlStmt     = "Select {0},count({0}) from {1} where g3e_fid={2} and g3e_fno={3} GROUP BY {0} having count({0})>1";
                    IGTComponent gtComponent = _components[_componentName];
                    if (gtComponent != null)
                    {
                        rs = gtComponent.Recordset;
                        if (rs != null && rs.RecordCount > 0)
                        {
                            rs.MoveFirst();
                            if (Convert.ToInt32(rs.Fields["G3e_CID"].Value) == 1)
                            {
                                //JIRA 195- check Duplicate Phase Position
                                rsTemp = _dataContext.Execute(string.Format(sqlStmt, _fieldName, _componentName, rs.Fields["G3e_FID"].Value, rs.Fields["G3e_FNO"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null);
                                if (rsTemp != null && rsTemp.RecordCount > 0)
                                {
                                    validateMsg.Rule_Id = "PHPS02";
                                    validateMsg.BuildRuleMessage(gTApplication, null);

                                    errorMsg.Add(validateMsg.Rule_MSG);
                                    //errorMsg.Add("Feature has duplicate Phase Positions. Phase Position should be unique across all the wires within same conductor.");
                                    errorPriority.Add(priority);
                                }
                            }
                        }
                    }
                    if (errorMsg.Count > 0)
                    {
                        ErrorPriorityArray = errorPriority.ToArray();
                        ErrorMessageArray  = errorMsg.ToArray();
                    }
                }

                if (gTValidationLogger != null)
                {
                    gTValidationLogger.LogEntry("TIMING", "END", "Phase Position Exit", "N/A", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during Phase position validation FI. " + ex.Message, Caption);
            }
            finally
            {
                rsTemp = null;
            }
        }
Ejemplo n.º 23
0
        public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray)
        {
            ADODB.Recordset rs            = null;
            ADODB.Recordset rsTemp        = null;
            int             record        = 0;
            bool            isPhaseExists = false;

            ErrorPriorityArray = null;
            ErrorMessageArray  = null;

            try
            {
                List <string> errorMsg      = new List <string>();
                List <string> errorPriority = new List <string>();
                string        priority      = Convert.ToString(_arguments.GetArgument(0));

                Recordset commonComponentRs = Components.GetComponent(1).Recordset;
                commonComponentRs.MoveFirst();
                string orientation        = Convert.ToString(commonComponentRs.Fields["ORIENTATION_C"].Value);
                int    fNo                = Convert.ToInt32(commonComponentRs.Fields["G3E_FNO"].Value);
                string featureName        = Convert.ToString(GetRecordSet(string.Format("select g3e_username NAME from g3e_feature where g3e_fno = {0}", fNo)).Fields["NAME"].Value);
                int    fId                = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value);
                bool   isFeatureConnected = CheckFeatureConnectivity(fId);

                if (orientation == "OH" && featureName.ToUpper().Contains("PRIMARY") && isFeatureConnected && !CheckPhaseAndPhasePosition(out isPhaseExists))
                {
                    errorPriority.Add(priority);
                    errorMsg.Add("Overhead feature is missing phase position values.");
                }

                if (CheckPhaseAndPhasePosition(out isPhaseExists))
                {
                    if (!isPhaseExists)
                    {
                        errorPriority.Add(priority);
                        errorMsg.Add("Phase Position attributes do not match specified phase.");
                    }
                }
                if (ValidatePhasePositionWithSets())
                {
                    errorPriority.Add(priority);
                    errorMsg.Add("Phase Position attributes are not consistent with respect to one another.");
                }

                if (_fieldName == "PHASE_POS_C")
                {
                    string sqlStmt = "Select {0},count({0}) from {1} where g3e_fid={2} and g3e_fno={3} GROUP BY {0} having count({0})>1";
                    //string sqlQuery = "Select listagg(a.{0},',') within group (order by a.PHASE_POS_C) as PhasePosition from {1} a where g3e_fid={2} and not exists (Select  vl_key from VL_PHASE_POSITION p where p.vl_key=a.{0})";


                    IGTComponent gtComponent = _components[_componentName];
                    if (gtComponent != null)
                    {
                        rs = gtComponent.Recordset;
                        if (rs != null && rs.RecordCount > 0)
                        {
                            rs.MoveFirst();
                            if (Convert.ToInt32(rs.Fields["G3e_CID"].Value) == 1)
                            {
                                //JIRA 195- check Duplicate Phase Position
                                rsTemp = _dataContext.Execute(string.Format(sqlStmt, _fieldName, _componentName, rs.Fields["G3e_FID"].Value, rs.Fields["G3e_FNO"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null);
                                if (rsTemp != null && rsTemp.RecordCount > 0)
                                {
                                    errorMsg.Add("Feature having duplicate Phase Position. Phase Position should be unique across all the wires within same conductor.");
                                    errorPriority.Add(priority);
                                }

                                /*
                                 * Commneted this code as per Shubham suggestion
                                 *
                                 * // As per the JIRA 476 - Business Rule Validate Unknown Values in Phase Position
                                 * rsTemp = _dataContext.Execute(string.Format(sqlQuery, _fieldName, _componentName, rs.Fields["G3e_FID"].Value), out record, (int)ADODB.CommandTypeEnum.adCmdText, null);
                                 * if (rsTemp != null && rsTemp.RecordCount > 0)
                                 * {
                                 *      rsTemp.MoveFirst();
                                 *      phasePosition = Convert.ToString(rsTemp.Fields[0].Value);
                                 *      if (!string.IsNullOrEmpty(phasePosition))
                                 *      {
                                 *              errorMsg.Add("Phase Position " + rsTemp.Fields[0].Value + " are unknown Values");
                                 *              errorPriority.Add("P2");
                                 *      }
                                 * }
                                 */
                            }
                        }
                    }
                    if (errorMsg.Count > 0)
                    {
                        ErrorPriorityArray = errorPriority.ToArray();
                        ErrorMessageArray  = errorMsg.ToArray();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Caption);
            }
            finally
            {
                rsTemp = null;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Log an entry into the GIS_STG.Interface_log table
        /// </summary>
        /// <returns>Returns 'true' if successfull and 'false' if it fails.</returns>
        public bool logEntry()
        {
            bool tmpReturn = true;
            //Recordset tmpRS = null;
            string tmpQry        = string.Empty;
            int    tmpRecUpdated = 0;
            long   tmpLogId      = 0;
            string tmpColumns    = string.Empty;
            string tmpColValues  = string.Empty;

            //int tmpRecChanged = 0;

            try
            {
                // Set datacontext if it is not set.
                if (dataContext == null)
                {
                    GetDataContext();
                }

                // Get the log id
                tmpLogId = GetNextIdVal();


                tmpColumns = GetLogEntryColumns();
                if (tmpColumns == string.Empty)
                {
                    return(false);
                }

                tmpColValues = GetLogEntryValues(tmpLogId);
                if (tmpColValues == string.Empty)
                {
                    return(false);
                }

                tmpQry = "begin INSERT INTO gis_stg.interface_log " + tmpColumns
                         + " VALUES " + tmpColValues + "; commit; end;";

                dataContext.Execute(tmpQry, out tmpRecUpdated, (int)CommandTypeEnum.adCmdText);

                if (xmlMessage != string.Empty)
                {
                    AddXMLDataLog(tmpLogId);
                }
            }
            catch (Exception e)
            {
                tmpReturn = false;
                if (Interactive)
                {
                    MessageBox.Show("SendReceiveMessageLogger.logEntry: + e.Message", "Error: SendReceiveMessageLogger.logEntry", MessageBoxButtons.OK);
                }
                else
                {
                    if (EventLog.SourceExists("Application Error"))
                    {
                        EventLog.WriteEntry("Application Error", "Error in G/Technology Custom Logger - SendReceiveMessageLogger.logEntry: " + e.Message);
                    }
                }
            }
            return(tmpReturn);
        }
Ejemplo n.º 25
0
        private bool InsertNewTicketRecord()
        {
            int iRecordsAffected = 0;

            try
            {
                StringBuilder insertQuery = new StringBuilder();
                insertQuery.AppendFormat(" BEGIN ");
                insertQuery.AppendFormat(@"INSERT INTO NJUNS_TICKET(
                                                     NJUNS_TICKET_ID,
                                                     TICKET_NUMBER,
                                                     TICKET_TYPE,
                                                     TICKET_STATUS,
                                                     POLE_FID,
                                                     POLE_NUMBER,
                                                     MISCELLANEOUS_ID,
                                                     CREATED_MEMBER,
                                                     POLE_OWNER,
                                                     CONTACT_NAME,
                                                     CONTACT_PHONE,
                                                     STATE,
                                                     COUNTY,
                                                     PLACE,
                                                     LATITUDE,
                                                     LONGITUDE,
                                                     HOUSE_NUMBER,
                                                     STREET_NAME,
                                                     PRIORITY_CODE,
                                                     JOB_TYPE,
                                                     REMARKS,
                                                     NUMBER_OF_POLES,
                                                     DAYS_INTERVAL
                                                     )
                                                     VALUES({0},'{1}','{2}','{3}',{4},'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}');",
                                         NJUNS_TICKET_ID,
                                         TICKET_NUMBER,
                                         TICKET_TYPE,
                                         TICKET_STATUS,
                                         POLE_FID,
                                         POLE_NUMBER,
                                         MISCELLANEOUS_ID,
                                         CREATED_MEMBER,
                                         POLE_OWNER,
                                         CONTACT_NAME,
                                         CONTACT_PHONE,
                                         STATE,
                                         COUNTY,
                                         PLACE,
                                         LATITUDE,
                                         LONGITUDE,
                                         HOUSE_NUMBER,
                                         STREET_NAME,
                                         PRIORITY_CODE,
                                         JOB_TYPE,
                                         REMARKS,
                                         NUMBER_OF_POLES,
                                         DAYS_INTERVAL
                                         );
                //insertQuery.AppendFormat(" COMMIT ; ");  // COMMIT AFTER SUCCESSFUL STEP CREATION
                insertQuery.AppendFormat("  END ; ");
                string insertSql = insertQuery.ToString();
                DataContext.Execute(insertSql, out iRecordsAffected, (int)CommandTypeEnum.adCmdText);
                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to insert ticket record", "Custom Create Ticket Error", MessageBoxButtons.OK);
                return(false);
            }
        }