コード例 #1
0
        public void Execute()
        {
            short  fNo = 0;
            string attributeValue;

            try
            {
                IGTComponent    component   = Components[ComponentName];
                ADODB.Recordset componentRs = component.Recordset;

                if (componentRs.RecordCount > 0)
                {
                    componentRs.MoveFirst();

                    if (componentRs.Fields["G3E_FNO"].Value == null)
                    {
                        return;
                    }

                    fNo = Convert.ToInt16(componentRs.Fields["G3E_FNO"].Value);
                    CheckForActiveFnoInValueMap(fNo, out attributeValue);
                    if (!String.IsNullOrEmpty(attributeValue))
                    {
                        componentRs.Fields["ORIENTATION_C"].Value = attributeValue;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during Set Attributes By FeatureClass execution. " + ex.Message, "G/Technology");
            }
        }
コード例 #2
0
        /// <summary>
        /// Mcheck Selected features are Valid for Merge
        /// </summary>
        /// <param name="g3eFno_trg"></param>
        /// <param name="g3eFid_trg"></param>
        /// <param name="g3eFno_src"></param>
        /// <param name="g3eFid_src"></param>
        /// <returns></returns>
        private bool CheckFeaturesAreValidForMerge(int g3eFno_trg, int g3eFid_trg, int g3eFno_src, int g3eFid_src)
        {
            ADODB.Recordset rs          = null;
            bool            flag        = false;
            string          sqlStmt     = "SELECT LBM_UTL.FeaturesAreValidForMerge({0},{1},{2},{3}) FROM DUAL";
            string          mergeStatus = string.Empty;

            try
            {
                rs = Execute(string.Format(sqlStmt, g3eFno_trg, g3eFid_trg, g3eFno_src, g3eFid_src));
                if (rs != null)
                {
                    rs.MoveFirst();
                    mergeStatus = Convert.ToString(rs.Fields[0].Value.ToString());
                    if (mergeStatus == "TRUE")
                    {
                        flag = true;
                    }
                    else
                    {
                        flag = false;
                    }
                }

                if (!flag)
                {
                    MessageBox.Show(mergeStatus, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(flag);
        }
コード例 #3
0
ファイル: fiLocationAttributes.cs プロジェクト: git786hub/DLL
        /// <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;
            }
        }
コード例 #4
0
ファイル: CommandUtilities.cs プロジェクト: git786hub/DLL
        public static List <AssetHistory> GetAssetHistoryByFID(IGTDataContext _odc, int _fid, GTDiagnostics _odiag)
        {
            List <AssetHistory> assetlist = null;

            try
            {
                string sSQL = string.Empty;


                sSQL = "SELECT G3E_IDENTIFIER, G3E_FNO, G3E_FID, G3E_ANO, G3E_CNO, G3E_CID, CHANGE_OPERATION, STRUCTURE_ID_1, OGG_X_1, OGG_Y_1, OGG_Z_1, CHANGE_DATE, VALUE_OLD, VALUE_NEW FROM ASSET_HISTORY WHERE STRUCTURE_ID_1 = " + _fid + " ORDER BY G3E_FID, CHANGE_DATE ASC";


                ADODB.Recordset oRS = null;

                oRS = ExecuteQuery(_odc, sSQL, _odiag);

                if (oRS == null)
                {
                    return(null);
                }
                if (oRS.RecordCount == 0)
                {
                    return(null);
                }

                if ((oRS.EOF) && (oRS.BOF))
                {
                    return(null);
                }

                oRS.MoveFirst();

                assetlist = ProcessAssetHistoryRS(oRS, _odiag);

                if (assetlist == null)
                {
                    return(null);
                }

                if (assetlist.Count == 0)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                LogException(_odiag, "GetAllAssetHistory", ex);
                throw ex;
            }

            return(assetlist);
        }
コード例 #5
0
        /// <summary>
        /// Method to get X and Y offset for the WP creation
        /// </summary>
        /// <param name="p_offsetX"></param>
        /// <param name="p_offsetY"></param>
        private void GetWorkPointOffset(ref int p_offsetX, ref int p_offsetY)
        {
            ADODB.Recordset rs = m_dataContext.OpenRecordset("Select PARAM_VALUE from SYS_GENERALPARAMETER where PARAM_NAME = 'WP_OFFSET_X' AND SUBSYSTEM_NAME = 'WorkPointCreation'", CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, new object[1]);
            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    p_offsetX = Convert.ToInt32(rs.Fields[0].Value);
                }
            }

            rs = m_dataContext.OpenRecordset("Select PARAM_VALUE from SYS_GENERALPARAMETER where PARAM_NAME = 'WP_OFFSET_Y' AND SUBSYSTEM_NAME = 'WorkPointCreation'", CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, new object[1]);
            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    p_offsetY = Convert.ToInt32(rs.Fields[0].Value);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Method to get first field of the first recordset in string format
        /// </summary>
        /// <param name="p_sql"> SQL string to process </param>
        /// <returns></returns>
        public string GetFirstFieldValueFromRecordset(string p_sql)
        {
            ADODB.Recordset rs = GetRecordSet(p_sql);
            string          sReturnFirstField = string.Empty;

            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    sReturnFirstField = Convert.ToString(rs.Fields[0].Value);
                }
            }
            return(sReturnFirstField);
        }
コード例 #7
0
        private void ProcessSumAndUpdateRs()
        {
            short     cNo               = 0;
            string    field             = string.Empty;
            int       attributeValueSum = 0;
            Recordset bankAttributesRs  = null;

            try
            {
                //Calculate attribute value sum
                IGTComponent    component    = Components[ComponentName];
                ADODB.Recordset kvaResultsRs = component.Recordset;
                if (kvaResultsRs.RecordCount > 0)
                {
                    int deletetedValue = string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value);
                    kvaResultsRs.MoveFirst();
                    while (!kvaResultsRs.EOF)
                    {
                        attributeValueSum = attributeValueSum + (string.IsNullOrEmpty(Convert.ToString(kvaResultsRs.Fields["KVA_Q"].Value)) ? 0 : Convert.ToInt32(kvaResultsRs.Fields["KVA_Q"].Value));
                        kvaResultsRs.MoveNext();
                    }
                    if (m_isDelete)
                    {
                        attributeValueSum = attributeValueSum - deletetedValue;
                    }
                }

                //Get the attribute to be updated and update the attribute sum to this attribute

                string          sqlString = string.Format("select g3e_field FIELD, g3e_cno CNO from G3E_ATTRIBUTEINFO_OPTABLE where g3e_ano = {0} ", Convert.ToInt32(m_Arguments.GetArgument(0)));
                ADODB.Recordset results   = GetRecordSet(sqlString);

                if (results.RecordCount > 0)
                {
                    results.MoveFirst();
                    cNo   = Convert.ToInt16(results.Fields["CNO"].Value);
                    field = Convert.ToString(results.Fields["FIELD"].Value);
                }

                bankAttributesRs = Components.GetComponent(cNo).Recordset;
                bankAttributesRs.MoveFirst();
                bankAttributesRs.Fields[field].Value = attributeValueSum;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #8
0
            public FeatureInfo(ADODB.Recordset p_rs)
            {
                this.IsValid = false;
                if (p_rs == null || (p_rs.BOF && p_rs.EOF))
                {
                    return;
                }

                p_rs.MoveFirst();

                this.FID          = Convert.ToInt32(p_rs.Fields["G3E_FID"].Value);;
                this.FNO          = Convert.ToInt16(p_rs.Fields["G3E_FNO"].Value);
                this.FeatureState = p_rs.Fields["FEATURE_STATE_C"].Value.ToString();

                this.IsValid = true;
            }
コード例 #9
0
ファイル: fiESILocationUpdate.cs プロジェクト: git786hub/DLL
 // Need to reset the recordset position before doing any updates.
 // The position changes from the starting postion due to looping
 // through the recordset and possibly through other interfaces
 // that get called.
 private void ResetRecordPosition(ref ADODB.Recordset componentRS)
 {
     // Reset the recordset position
     if (m_RecordPosition != (int)componentRS.AbsolutePosition)
     {
         componentRS.MoveFirst();
         while (!componentRS.EOF)
         {
             if (m_RecordPosition == (int)componentRS.AbsolutePosition)
             {
                 break;
             }
             componentRS.MoveNext();
         }
     }
 }
コード例 #10
0
        public void InsertAdo()
        {
            var con = new Connection();

            con.Open("Provider='sqloledb';Data Source='(local)';Initial Catalog='Proba';Integrated Security='SSPI';");

            var rec = new Recordset();

            rec.Open("SELECT s1, s2 FROM Tabl1", con, CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockOptimistic, 0);
            rec.MoveFirst();
            rec.Fields["s1"].Value = "s";
            rec.Fields["s2"].Value = "s";
            rec.Update("s1", rec.Fields["s1"].Value);
            rec.Close();
            con.Close();
        }
コード例 #11
0
        private string GetJobType()
        {
            string sReturn = string.Empty;

            ADODB.Recordset rs = m_dataContext.OpenRecordset("select G3E_JOBSTATUS from g3e_job where G3E_IDENTIFIER = ?", CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)(ADODB.CommandTypeEnum.adCmdText), m_dataContext.ActiveJob);

            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    sReturn = Convert.ToString(rs.Fields["G3E_JOBSTATUS"].Value);
                }
            }
            return(sReturn);
        }
コード例 #12
0
ファイル: GTFkqCUSelection.cs プロジェクト: git786hub/DLL
        private bool ReplacewithSameCU(string strCucode, string strCategory)
        {
            ADODB.Recordset rs             = null;
            string[]        sArrCategories = null;
            string          sSql           = "";

            try
            {
                if (!string.IsNullOrEmpty(strCategory))
                {
                    sArrCategories = strCategory.Split(',');
                }

                sSql = "select count(*) from CULIB_UNIT  where CU_ID ='" + strCucode + "' and  category_c in (";

                for (int i = 0; i < sArrCategories.Length; i++)
                {
                    if (i != sArrCategories.Length - 1)
                    {
                        sSql = sSql + "'" + sArrCategories[i] + "'" + ",";
                    }
                    else
                    {
                        sSql = sSql + "'" + sArrCategories[i] + "'" + ")";
                    }
                }

                rs = m_oDataContext.OpenRecordset(sSql, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, (int)0);

                rs.MoveFirst();
                if (Convert.ToString(rs.Fields[0].Value).Equals("0"))
                {
                    return(false);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                rs.Close();
                rs = null;
            }

            return(true);
        }
コード例 #13
0
        private bool IsRepeatingComponent(int p_CNO)
        {
            bool bReturn = false;

            ADODB.Recordset rs = m_oApp.DataContext.MetadataRecordset("G3E_FEATURECOMPS_OPTABLE", "g3e_cno = " + p_CNO);
            // rs.Filter = "g3e_cno = " + p_CNO;

            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    bReturn = Convert.ToInt32(rs.Fields["G3E_REPEATING"].Value) == 1;
                }
            }
            return(bReturn);
        }
コード例 #14
0
ファイル: fiESILocationUpdate.cs プロジェクト: git786hub/DLL
        // Loop through the current Premise records on the active Service Point feature
        // and validate that the entered ESI Location on the current Premise record
        // does not exist on another Premise record for the active Service Point.
        private bool ValidateDuplicateOnExistingFID(string esiLocation, ADODB.Recordset componentRS)
        {
            bool returnValue = true;

            try
            {
                componentRS.MoveFirst();

                int    currentRecordPosition = 0;
                string currentESILocation    = "";

                while (!componentRS.EOF)
                {
                    currentRecordPosition = (int)componentRS.AbsolutePosition;

                    if (currentRecordPosition != m_RecordPosition)
                    {
                        if (!Convert.IsDBNull(componentRS.Fields[FIELD_PREMISE_ESI_LOCATION].Value))
                        {
                            currentESILocation = componentRS.Fields[FIELD_PREMISE_ESI_LOCATION].Value.ToString();

                            if (esiLocation == currentESILocation)
                            {
                                if (m_InteractiveMode)
                                {
                                    MessageBox.Show(ERROR_DUPLICATE_ESILOCATION_SRVCPT, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                returnValue = false;
                                break;
                            }
                        }
                    }
                    componentRS.MoveNext();
                }
            }
            catch (Exception ex)
            {
                if (m_InteractiveMode)
                {
                    MessageBox.Show("Error in fiESILocationUpdate:ValidateDuplicateOnExistingFID - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                returnValue = false;
            }

            return(returnValue);
        }
コード例 #15
0
ファイル: GTFkqCUSelection.cs プロジェクト: git786hub/DLL
        private string GetComponentName(int p_ANO)
        {
            string sComponentName = string.Empty;

            ADODB.Recordset rs = m_oApp.DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE");
            rs.Filter = "g3e_ano = " + p_ANO;

            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    sComponentName = Convert.ToString(rs.Fields["G3E_NAME"].Value);
                }
            }
            return(sComponentName);
        }
コード例 #16
0
    } // end function;

    public string get_gen_t2()
    {
        ADODB.Recordset reccust = null;
        string          retval;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();

        retval = Convert.ToString((float)reccust.Fields["rtu1c"].Value);


        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return(retval); //exit  Function;
    } // end function;
コード例 #17
0
ファイル: CommandUtilities.cs プロジェクト: git786hub/DLL
        public static string GetCommonNStructureID(IGTKeyObject _ko, GTDiagnostics _odiag)
        {
            string osid = string.Empty;

            try
            {
                IGTComponent    commonN = _ko.Components["COMMON_N"];
                ADODB.Recordset oRS     = commonN.Recordset;

                if (oRS == null)
                {
                    return(osid);
                }

                if (oRS.RecordCount == 0)
                {
                    return(osid);
                }

                oRS.MoveFirst();


                if ((!oRS.EOF) && (!oRS.BOF))
                {
                    osid = oRS.Fields["STRUCTURE_ID"].Value.ToString().Trim();
                    if (!string.IsNullOrEmpty(osid))
                    {
                        return(osid);
                    }
                    else
                    {
                        LogMessage(_odiag, "GetCommonN", "COMMON_N", "FID = " + _ko.FID.ToString() + " has no structure_id.");
                        return(osid);
                    }
                }
            }
            catch (Exception ex)
            {
                LogException(_odiag, "GetCommonN", ex);
                throw ex;
            }

            return(osid);
        }
コード例 #18
0
ファイル: fiLocationAttributes.cs プロジェクト: git786hub/DLL
        /// <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 = 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;
            }
        }
コード例 #19
0
ファイル: fiSetSubstationCode.cs プロジェクト: git786hub/DLL
        public void Execute()
        {
            short     fNo = 0;
            Recordset connectivityComponentRs = null;
            string    feederId       = string.Empty;
            string    subStationCode = string.Empty;

            try
            {
                IGTComponent component = Components.GetComponent(11);
                connectivityComponentRs = component.Recordset;
                if (connectivityComponentRs.RecordCount > 0)
                {
                    connectivityComponentRs.MoveFirst();
                    fNo = Convert.ToInt16(connectivityComponentRs.Fields["G3E_FNO"].Value);
                }
                if (fNo == 16)                  // If affected feature is substation breaker then do nothing
                {
                    return;
                }
                feederId = Convert.ToString(connectivityComponentRs.Fields["FEEDER_1_ID"].Value);
                ADODB.Command command    = null;
                int           outRecords = 0;
                string        sqlString  = string.Format("select distinct ssta_c SSCODE from CONNECTIVITY_N where g3e_fno = 16 and feeder_1_id = '{0}' ", feederId);

                command             = new ADODB.Command();
                command.CommandText = sqlString;
                ADODB.Recordset results = DataContext.ExecuteCommand(command, out outRecords);
                if (results.RecordCount > 0)
                {
                    results.MoveFirst();
                    subStationCode = Convert.ToString(results.Fields["SSCODE"].Value);
                }

                connectivityComponentRs.Fields["SSTA_C"].Value = subStationCode;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error during Set Substation Code execution. " + ex.Message, "G/Technology");
            }
        }
コード例 #20
0
ファイル: MoreInfoForms.cs プロジェクト: git786hub/DLL
        public string GetPreferredCuFilterString(ADODB.Recordset p_PreferredCuRecords)
        {
            List <string> sPreferredCuList = new List <string>();
            string        sReturnFilter    = string.Empty;

            if (p_PreferredCuRecords != null)
            {
                if (p_PreferredCuRecords.RecordCount > 0)
                {
                    p_PreferredCuRecords.MoveFirst();
                    while (p_PreferredCuRecords.EOF == false)
                    {
                        sPreferredCuList.Add("'" + Convert.ToString(p_PreferredCuRecords.Fields["CU_CODE"].Value) + "'");
                        p_PreferredCuRecords.MoveNext();
                    }
                    sReturnFilter = string.Join(",", sPreferredCuList.ToArray());
                }
            }

            return(sReturnFilter);
        }
コード例 #21
0
    } // end sub;

    public string get_op_time_unit()
    {
        //on error GoTo err_op_name;

        ADODB.Recordset reccust = null;
        string          retval;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();

        retval = (string)reccust.Fields["TUProd"].Value;

        //exit_op_name:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return(retval); //exit  Function;
        //err_op_name:
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_op_name;
    } // end function;
コード例 #22
0
    } // end function;

    int get_gen_id()
    {
        //on error GoTo err_genid;

        ADODB.Recordset reccust = null;
        int             retval;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();

        retval = (int)reccust.Fields["generalid"].Value;

        //exit_genid:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return(retval); //exit  Function;
        //err_genid:
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_genid;
    } // end function;
コード例 #23
0
        private void UpdateADODBRecordset_from_ADODataTable(DataTable inTable, ref ADODB.Recordset adoRs)
        {
            ADODB.Fields adoFields = adoRs.Fields;
            System.Data.DataColumnCollection inColumns = inTable.Columns;
            //Delete
            if (adoRs.RecordCount > 0)
            {
                adoRs.MoveFirst();
            }
            while (!adoRs.EOF)
            {
                adoRs.Delete();
                adoRs.MoveNext();
            }
            //Add
            foreach (DataRow dr in inTable.Rows)
            {
                // Proceso las que no estan borradas
                if (dr.RowState != DataRowState.Deleted)
                {
                    adoRs.AddNew(System.Reflection.Missing.Value,
                                 System.Reflection.Missing.Value);

                    for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
                    {
                        ADODB.Field field = adoFields[columnIndex];
                        try
                        {
                            adoFields[columnIndex].Value = dr[columnIndex];
                        }
                        catch (Exception ex)
                        {
                            string message = string.Format("Error al actualizar la columna {0}.{1}: {2}", inTable.TableName, field.Name, ex.Message);
                            throw new XTangoException(message);
                        }
                    }
                }
            }
        }
コード例 #24
0
    } // end function;

    public string get_utlimit()
    {
        //on error GoTo err_utlimit;

        ADODB.Recordset reccust = null;
        string          retval;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();

        retval = Convert.ToString((float)reccust.Fields["utlimit"].Value);

        //exit_utlimit:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return(retval); //exit  Function;
        //err_utlimit:
        // msgbox(ErrorToString(), 0, appl_name);
        // resume  exit_utlimit;
    } // end function;
コード例 #25
0
    } // end sub;

    void set_utlimit(float x1)
    {
        //on error GoTo err_setlimit;

        ADODB.Recordset reccust = null;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();
        //'reccust.edit;
        reccust.Fields["utlimit"].Value = x1;
        reccust.Update();


        //exit_setlimit:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return; //exit  Sub;
        //err_setlimit:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end sub;
コード例 #26
0
    } // end sub;

    void set_modified_date()
    {
        //on error GoTo err_setdate;

        ADODB.Recordset reccust = null;

        //Set Database variable;
        DbUse.open_ado_rec(globaldb, ref reccust, "tblgeneral");

        reccust.MoveFirst();
        //'reccust.edit;
        reccust.Fields["DateM"].Value = System.DateTime.Now;
        reccust.Update();



        //exit_setdate:
        DbUse.CloseAdoRec(reccust);
        reccust = null;
        return; //exit  Sub;
        //err_setdate:
        // msgbox(ErrorToString(), 0, appl_name);
        //RESUME NEXT
    } // end sub;
コード例 #27
0
ファイル: CommandUtilities.cs プロジェクト: git786hub/DLL
        public static ADODB.Recordset OpenCommonRecordset(IGTDataContext _odc, int _fid, short _fno, GTDiagnostics _odiag)
        {
            ADODB.Recordset oRS = null;

            try
            {
                string sSQL = "SELECT G3E_FID, G3E_FNO, STRUCTURE_ID FROM COMMON_N WHERE G3E_FNO = '" + _fno + "'" + " AND G3E_FID = '" + _fid + "'";
                oRS = ExecuteQuery(_odc, sSQL, _odiag);

                if (oRS.RecordCount == 0)
                {
                    return(null);
                }

                if ((oRS.EOF) && (oRS.BOF))
                {
                    return(null);
                }

                oRS.MoveFirst();


                while ((!oRS.EOF) && (!oRS.BOF))
                {
                    //obj.G3E_FNO = Convert.ToInt16(oRS.Fields["G3E_FNO"].Value.ToString().Trim());
                    //obj.G3E_FID = Convert.ToInt32(oRS.Fields["G3E_FID"].Value.ToString().Trim());
                }
            }
            catch (Exception ex)
            {
                LogException(_odiag, "OpencommonRecordset", ex);
                throw ex;
            }

            return(oRS);
        }
コード例 #28
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));
            }
        }
コード例 #29
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;
            }
        }
コード例 #30
0
        public bool ValidateWorkPoints()
        {
            bool   bReturn = true;
            string sSql    = "";

            ADODB.Recordset rs   = null;
            ADODB.Recordset rsWP = null;

            sSql = @"select g3e_fno, g3e_fid,wpCUs.STRUCTURE_ID, count(g3e_fid)
                    from (
                      select 
                        COALESCE(comm.STRUCTURE_ID, owner.STRUCTURE_ID) as STRUCTURE_ID
                      , cu.G3E_FID, cu.CU_C, cu.ACTIVITY_C, cu.g3e_fno g3e_fno
                      , count(*) as cuCount
                      from      COMP_UNIT_N cu
                      join      COMMON_N    comm  on cu.G3E_FID = comm.G3E_FID
                      left join COMMON_N    owner on (COALESCE(comm.OWNER1_ID,comm.OWNER2_ID) = owner.G3E_ID)
                      where (cu.WR_ID = ? OR cu.WR_EDITED =?) and (owner.g3e_fno<>19 or owner.g3e_fno is null)
                      group by COALESCE(comm.STRUCTURE_ID, owner.STRUCTURE_ID), cu.G3E_FID, cu.CU_C, cu.ACTIVITY_C, cu.g3e_fno
                      ) CUs
                    left join (
                      select 
                        wp.STRUCTURE_ID
                      , wcu.ASSOC_FID, wcu.CU_C, wcu.ACTIVITY_C, wp.g3e_fno WPfno
                      , count(*) as cuCount
                      from WORKPOINT_N    wp
                      join WORKPOINT_CU_N wcu on wp.G3E_FID = wcu.G3E_FID
                      where wp.WR_NBR = ?
                      group by wp.STRUCTURE_ID, wcu.ASSOC_FID, wcu.CU_C, wcu.ACTIVITY_C, wp.g3e_fno
                      ) wpCUs on (    CUs.G3E_FID = wpCUs.ASSOC_FID 
                                  and CUs.STRUCTURE_ID = wpCUs.STRUCTURE_ID 
                                  and CUs.CU_C = wpCUs.CU_C) group by wpCUs.STRUCTURE_ID, g3e_fid,g3e_fno";

            Dictionary <int, Int16> FIDs = new Dictionary <int, Int16>();
            Dictionary <int, Int16> MissingWPFeatures    = new Dictionary <int, short>();
            Dictionary <int, Int16> MissingWPCUsFeatures = new Dictionary <int, short>();
            IGTApplication          m_oApp = GTClassFactory.Create <IGTApplication>();

            rs   = m_oApp.DataContext.OpenRecordset(sSql, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, m_oApp.DataContext.ActiveJob, m_oApp.DataContext.ActiveJob, m_oApp.DataContext.ActiveJob);
            rsWP = m_oApp.DataContext.OpenRecordset("select g3e_fid,STRUCTURE_ID from WORKPOINT_N where WR_NBR = ?", CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, m_oApp.DataContext.ActiveJob);
            DataTable dtWP = GetDataTable(m_oApp.DataContext, rsWP);

            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    DataTable dt = GetDataTable(m_oApp.DataContext, rs);
                    if (dt != null)
                    {
                        DataRow[] rowsWithNull = dt.Select("STRUCTURE_ID is null");
                        if (rowsWithNull.Count <DataRow>() > 0)
                        {
                            foreach (var item in rowsWithNull)
                            {
                                if (!FIDs.ContainsKey(Convert.ToInt32(item["g3e_fid"])))
                                {
                                    FIDs.Add(Convert.ToInt32(item["g3e_fid"]), Convert.ToInt16(item["g3e_fno"]));
                                }
                            }
                        }

                        foreach (KeyValuePair <int, Int16> item in FIDs)
                        {
                            DataRow[] rows = dt.Select("g3e_fid = " + item.Key + " and STRUCTURE_ID is not null");

                            if (rows != null && rows.Count <DataRow>() > 0)
                            {
                                if (!MissingWPCUsFeatures.ContainsKey(Convert.ToInt32(rows[0]["G3E_FID"])))
                                {
                                    string iWPFID = Convert.ToString(dtWP.Select("STRUCTURE_ID = '" + Convert.ToString(rows[0]["STRUCTURE_ID"]) + "'")[0]["G3E_FID"]);

                                    MissingWPCUsFeatures.Add(Convert.ToInt32(iWPFID), 191);
                                }
                            }
                            else
                            {
                                if (!MissingWPFeatures.ContainsKey(item.Key))
                                {
                                    MissingWPFeatures.Add(item.Key, item.Value);
                                }
                            }
                        }
                    }
                }
            }

            if (MissingWPCUsFeatures.Count > 0)
            {
                bReturn = false;

                foreach (KeyValuePair <int, Int16> item in MissingWPCUsFeatures)
                {
                    m_oApp.SelectedObjects.Clear();
                    IGTDDCKeyObjects oDDCs = m_oApp.DataContext.GetDDCKeyObjects(item.Value, item.Key, GTComponentGeometryConstants.gtddcgAllGeographic);

                    foreach (IGTDDCKeyObject item1 in oDDCs)
                    {
                        m_oApp.SelectedObjects.Add(GTSelectModeConstants.gtsosmAllComponentsInActiveLegend, item1);
                    }
                }

                MessageBox.Show("Unable to write to WMIS; highlighted Work Points do not reflect all CU activity.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(bReturn);
            }
            if (MissingWPFeatures.Count > 0)
            {
                m_oApp.SelectedObjects.Clear();
                bReturn = false;
                foreach (KeyValuePair <int, Int16> item in MissingWPFeatures)
                {
                    IGTDDCKeyObjects oDDCs = m_oApp.DataContext.GetDDCKeyObjects(item.Value, item.Key, GTComponentGeometryConstants.gtddcgAllGeographic);

                    foreach (IGTDDCKeyObject item1 in oDDCs)
                    {
                        m_oApp.SelectedObjects.Add(GTSelectModeConstants.gtsosmAllComponentsInActiveLegend, item1);
                    }
                }
                MessageBox.Show("Unable to write to WMIS; highlighted features have no Work Point.”", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(bReturn);
            }

            string sDiscardedCUs = @"select  g3e_fid,wpCUs.STRUCTURE_ID, count(g3e_fid)
                    from (
                      select 
                        COALESCE(comm.STRUCTURE_ID, owner.STRUCTURE_ID) as STRUCTURE_ID
                      , cu.G3E_FID, cu.CU_C, cu.ACTIVITY_C, cu.g3e_fno g3e_fno
                      , count(*) as cuCount
                      from      COMP_UNIT_N cu
                      join      COMMON_N    comm  on cu.G3E_FID = comm.G3E_FID
                      left join COMMON_N    owner on  (COALESCE(comm.OWNER1_ID,comm.OWNER2_ID) = owner.G3E_ID)
                      where (cu.WR_ID = ? OR cu.WR_EDITED =?) 
                      group by COALESCE(comm.STRUCTURE_ID, owner.STRUCTURE_ID), cu.G3E_FID, cu.CU_C, cu.ACTIVITY_C, cu.g3e_fno
                      ) CUs
                    right join (
                      select 
                        wp.STRUCTURE_ID
                      , wcu.ASSOC_FID, wcu.CU_C, wcu.ACTIVITY_C, wp.g3e_fno WPfno
                      , count(*) as cuCount
                      from WORKPOINT_N    wp
                      join WORKPOINT_CU_N wcu on wp.G3E_FID = wcu.G3E_FID
                      where wp.WR_NBR = ?
                      group by wp.STRUCTURE_ID, wcu.ASSOC_FID, wcu.CU_C, wcu.ACTIVITY_C, wp.g3e_fno
                      ) wpCUs on (    CUs.G3E_FID = wpCUs.ASSOC_FID 
                                  and CUs.STRUCTURE_ID = wpCUs.STRUCTURE_ID 
                                  and CUs.CU_C = wpCUs.CU_C) group by wpCUs.STRUCTURE_ID, g3e_fid having count(g3e_fid) = 0 and g3e_fid is null";

            rs = m_oApp.DataContext.OpenRecordset(sDiscardedCUs, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, m_oApp.DataContext.ActiveJob, m_oApp.DataContext.ActiveJob, m_oApp.DataContext.ActiveJob);
            if (rs != null)
            {
                if (rs.RecordCount > 0)
                {
                    bReturn = false;
                    MessageBox.Show("Work Point(s) are out of synchronization", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(bReturn);
                }
            }
            return(bReturn);
        }