Пример #1
0
 public string getAirport(int IdAirport)
 {
     try
     {
         string                 IATACODE         = "";
         ClientInfoHeader       clientInfoHeader = new ClientInfoHeader();
         APIAccessRequestHeader aPIAccessRequest = new APIAccessRequestHeader();
         clientInfoHeader.AppID = "Query Example";
         String queryString = "SELECT LookupName FROM CO.Airports WHERE ID =" + IdAirport;
         clientRN.QueryCSV(clientInfoHeader, aPIAccessRequest, queryString, 10000, "|", false, false, out CSVTableSet queryCSV, out byte[] FileData);
         foreach (CSVTable table in queryCSV.CSVTables)
         {
             String[] rowData = table.Rows;
             foreach (String data in rowData)
             {
                 IATACODE = data;
             }
         }
         return(IATACODE);
     }
     catch (Exception ex)
     {
         MessageBox.Show("getAirport: " + ex.Message + "Det" + ex.StackTrace);
         return("");
     }
 }
        /// <summary>
        /// Return individual fields as per query
        /// </summary>
        /// <param name="ApplicationID"></param>
        /// <param name="Query"></param>
        /// <returns> array of string delimited by '~'</returns>
        private string[] GetRNData(string ApplicationID, string Query)
        {
            string[]         rnData = null;
            ClientInfoHeader hdr    = new ClientInfoHeader()
            {
                AppID = ApplicationID
            };

            byte[]      output = null;
            CSVTableSet data   = null;

            try
            {
                data = _rightNowClient.QueryCSV(hdr, Query, 1000, "~", false, false, out output);
                string dataRow = String.Empty;
                if (data != null && data.CSVTables.Length > 0 && data.CSVTables[0].Rows.Length > 0)
                {
                    return(data.CSVTables[0].Rows);
                }
            }
            catch (Exception ex)
            {
                WorkspaceAddIn.InfoLog(ex.Message);
            }
            return(rnData);
        }
        private bool Allday(int Airport)
        {
            bool                   all = true;
            ClientInfoHeader       clientInfoHeader = new ClientInfoHeader();
            APIAccessRequestHeader aPIAccessRequest = new APIAccessRequestHeader();

            clientInfoHeader.AppID = "Query Example";
            String queryString = "SELECT HoursOpen24 FROM  CO.Airports WHERE ID=" + Airport;

            clientRN.QueryCSV(clientInfoHeader, aPIAccessRequest, queryString, 10000, "|", false, false, out CSVTableSet queryCSV, out byte[] FileData);
            foreach (CSVTable table in queryCSV.CSVTables)
            {
                String[] rowData = table.Rows;
                foreach (String data in rowData)
                {
                    all = Convert.ToInt32(data) == 0 ? false : true;
                }
            }
            return(all);
        }
Пример #4
0
        /// <summary>
        /// Get config verb value
        /// </summary>
        /// <param name="configVerbName"></param>
        /// <returns></returns>
        public string GetRightNowConfigVerbValue(string configVerbName)
        {
            //Prepare session
            IOTClouddAutoClientAddIn.GlobalContext.PrepareConnectSession(_rightNowClient.ChannelFactory);

            Debug("RightNowConnectService - GetRightNowConfigVerbValue() - Enter");
            string configVerbValue = String.Empty;

            try
            {
                // Set up query and set request
                ClientInfoHeader cih = new ClientInfoHeader();
                cih.AppID = OracleRightNowIOTAddInNames.ORACLE_RIGHTNOW_IOT_CLIENT;

                byte[] outByte = new byte[1000];
                string query   = RightNowQueries.GET_CONFIG_VERB_QUERY + "'" + configVerbName + "'";
                Notice("Sending query to fetch " + configVerbName + " Config verb value");
                CSVTableSet tableSet  = _rightNowClient.QueryCSV(cih, query, 100, ",", false, false, out outByte);
                CSVTable[]  csvTables = tableSet.CSVTables;
                CSVTable    table     = csvTables[0];
                string[]    rowData   = table.Rows;

                // Check whether configuration is set
                if (rowData.Length == 0)
                {
                    return(String.Empty);
                }

                // Get configuration value
                Notice("Returning Config verb '" + configVerbName + "' value: " + rowData[0]);
                configVerbValue = rowData[0];
            }
            catch (Exception e)
            {
                Debug("RightNowConnectService - GetRightNowConfigVerbValue() - Error while fetching config verb" + e.Message);
                Error("RightNowConnectService - GetRightNowConfigVerbValue() - Error while fetching config verb", e.StackTrace);
                MessageBox.Show("RightNowConnectService - Error while fetching config verb", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Debug("RightNowConnectService - GetRightNowConfigVerbValue() - Exit");
            return(configVerbValue);
        }
Пример #5
0
        public string getIsoCode(int Country)
        {
            string                 iSO = "";
            ClientInfoHeader       clientInfoHeader = new ClientInfoHeader();
            APIAccessRequestHeader aPIAccessRequest = new APIAccessRequestHeader();

            clientInfoHeader.AppID = "Query Example";
            String queryString = "SELECT ISOCode FROM Country  WHERE ID = " + Country;

            clientRN.QueryCSV(clientInfoHeader, aPIAccessRequest, queryString, 10000, "|", false, false, out CSVTableSet queryCSV, out byte[] FileData);
            foreach (CSVTable table in queryCSV.CSVTables)
            {
                String[] rowData = table.Rows;
                foreach (String data in rowData)
                {
                    iSO = data;
                }
            }

            return(iSO);
        }
Пример #6
0
        public string[] queryData(string queryString)
        {
            byte[] outByte = new byte[1000];

            CSVTableSet tableSet = _rnowClient.QueryCSV(_rnowClientInfoHeader, queryString, 100, ",", false, false, out outByte);

            CSVTable[] csvTables = tableSet.CSVTables;
            CSVTable   table     = csvTables[0];

            string[] rowData = table.Rows;

            return(rowData);
        }
        internal CSVQueryResponse QueryCSV(string queryString, string delimiter, int pageSize)
        {
            bool mustRetry  = false;    // used to determine if we should retry a failed job
            int  retryTimes = 0;        // we don't want to endlessly retry, so we only will retry 3 times

            do
            {
                try
                {
                    CSVTableSet result = null;

                    byte[] byteArray;
                    result = _client.QueryCSV(_clientInfoHeader, queryString, pageSize, delimiter, false, true, out byteArray);

                    return(new CSVQueryResponse
                    {
                        TableSet = result,
                        Successful = true,
                        SuccessfulSet = true
                    });
                }
                catch (Exception ex)
                {
                    GlobalContext.Log(string.Format("Failed QueryCSV: Retry {0}: {1}", retryTimes, ex.Message), true);
                    GlobalContext.Log(string.Format("Failed QueryCSV: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false);

                    if (retryTimes < 3)
                    {
                        // if we haven't retried 3 times then we retry the load again
                        mustRetry = true;
                        retryTimes++;
                    }
                    else
                    {
                        // don't retry for 3rd retry
                        return(new CSVQueryResponse
                        {
                            TableSet = null,
                            Successful = false,
                            SuccessfulSet = true,
                            Details = ex.Message
                        });
                    }
                }
                GlobalContext.Log(string.Format("QueryCSV Must Retry {0}", mustRetry), false);
            } while (mustRetry);
            GlobalContext.Log("QueryCSV End: This code should never be hit.", false);
            return(null);        // this code should never be hit
        }
Пример #8
0
        /// <summary>
        /// Return individual fields as per query
        /// </summary>
        /// <param name="ApplicationID"></param>
        /// <param name="Query"></param>
        /// <returns> array of string delimited by '|'</returns>
        private string[] GetRNData(string ApplicationID, string Query)
        {
            Debug("RightNowConnectService - GetRNData() - Entry");

            string[] rn_data = null;

            OutOfOfficeClientAddIn.GlobalContext.PrepareConnectSession(_rightNowClient.ChannelFactory);

            ClientInfoHeader hdr = new ClientInfoHeader()
            {
                AppID = ApplicationID
            };

            byte[]      output = null;
            CSVTableSet data   = null;

            try
            {
                data = _rightNowClient.QueryCSV(hdr, Query, 50, "|", false, false, out output);

                string data_row = String.Empty;

                if (data != null && data.CSVTables.Length > 0 && data.CSVTables[0].Rows.Length > 0)
                {
                    return(data.CSVTables[0].Rows);
                }
            }
            catch (Exception ex)
            {
                Error(ex.Message, ex.StackTrace);
                throw ex;
            }

            Debug("RightNowConnectService - GetRNData() - Exit");
            return(rn_data);
        }