Пример #1
0
        /// <summary>
        /// Creates the call routing record from call record.
        /// </summary>
        /// <param name="call">The call.</param>
        /// <param name="finalStatus">The final status.</param>
        /// <returns></returns>
        static public bool CreateCallRoutingRecordFromCallRecord(CallRecord call, string finalStatus)
        {
            var results = false;

            try
            {
                if (string.IsNullOrEmpty(finalStatus) ||
                    !IsValidCallStatus(finalStatus))
                {
                    throw new ApplicationException("Empty or Invalid status");
                }

                var record = new CallRoutingRecord
                {
                    CallId          = call.CallId,
                    Instance        = call.Instance,
                    FinalSaveStatus = finalStatus,
                    RoutingStatus   = "UNPROCESSED",
                    UserId          = call.UserId,
                    ServerName      = Environment.MachineName
                };
                results = record.Insert();
            }
            catch (Exception ex)
            {
                GeneralUtility.LogError(ex.Message, "CreateCallRoutingRecordFromCallRecord");
            }
            return(results);
        }
Пример #2
0
        private bool ExecuteReader(Database db)
        {
            bool results;

            try
            {
                _records.Clear();
                AddQueryParameters();

                using (var reader = ExecuteReader(db, Query))
                {
                    while (reader.Read())
                    {
                        _records.Add(ActiveRecordFactoryMethod(reader, _activeRecordType, _dbInstance));
                    }
                    reader.Close();
                }
                _current = -1;
                results  = _records.Count > 0;
            }
            catch (Exception ex)
            {
                results           = false;
                _lastErrorMessage = ex.Message;
                GeneralUtility.LogError(_lastErrorMessage, _activeRecordType);
            }

            ResetParameters();
            return(results);
        }
Пример #3
0
        /// <summary>
        /// Executes the non query.
        /// </summary>
        /// <param name="db">The db.</param>
        /// <param name="commandText">The command text.</param>
        /// <returns></returns>
        protected override bool ExecuteNonQuery(Database db, string commandText)
        {
            bool results;

            try
            {
                var cmd = db.GetSqlStringCommand(commandText);
                if (cmd != null)
                {
                    db.AddInParameter(cmd, "call_xml", DbType.AnsiString, CallXml);
                    var records = db.ExecuteNonQuery(cmd);
                    results = records == 1;
                }
                else
                {
                    results          = false;
                    lastErrorMessage = "Unable to create COMMAND object";
                }
            }
            catch (Exception ex)
            {
                results          = false;
                lastErrorMessage = ex.Message;
                GeneralUtility.LogError(lastErrorMessage, Name);
            }
            return(results);
        }
Пример #4
0
 /// <summary>
 /// Determines whether [has call XML] [the specified call id].
 /// </summary>
 /// <param name="callId">The call id.</param>
 /// <param name="instance">The instance.</param>
 /// <returns>
 ///     <c>true</c> if [has call XML] [the specified call id]; otherwise, <c>false</c>.
 /// </returns>
 static public bool HasCallXml(string callId, string instance)
 {
     try
     {
         var record = new CallXmlRecord {
             CallId = callId, Instance = instance
         };
         return(record.Execute());
     }
     catch (Exception ex)
     {
         GeneralUtility.LogError(ex.Message, "CallXmlRecord.GetCallXml");
         return(false);
     }
 }
Пример #5
0
        /// <summary>
        /// Updates the call XML.
        /// </summary>
        /// <param name="callId">The call id.</param>
        /// <param name="callXml">The call XML.</param>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        static public bool UpdateCallXml(string callId, string callXml, string instance)
        {
            var results = false;

            try
            {
                var record = new CallXmlRecord {
                    CallId = callId, CallXml = callXml, Instance = instance
                };
                results = record.Update();
            }
            catch (Exception ex)
            {
                GeneralUtility.LogError(ex.Message, "CallXmlRecord.InsertCallXml");
            }
            return(results);
        }
Пример #6
0
 /// <summary>
 /// Loads the specified results.
 /// </summary>
 public bool Load(out byte[] buffer)
 {
     try
     {
         if (Execute())
         {
             buffer = Data;
             return(true);
         }
     }
     catch (Exception ex)
     {
         GeneralUtility.LogError(ex.Message, Name);
     }
     buffer = new byte[0];
     return(false);
 }
Пример #7
0
 /// <summary>
 /// Gets the call XML.
 /// </summary>
 /// <param name="callId">The call id.</param>
 /// <param name="instance">The instance.</param>
 /// <returns></returns>
 static public string GetCallXml(string callId, string instance)
 {
     try
     {
         var record = new CallXmlRecord {
             CallId = callId, Instance = instance
         };
         if (record.Execute())
         {
             return(record.CallXml);
         }
     }
     catch (Exception ex)
     {
         GeneralUtility.LogError(ex.Message, "CallXmlRecord.GetCallXml");
     }
     return("");
 }
Пример #8
0
        /// <summary>
        /// Creates or updates the blob
        /// Set CallId required before calling this method.
        /// </summary>
        public bool Save(int length, [MarshalAs(UnmanagedType.SafeArray)] byte[] buffer)
        {
            bool results = false;

            try
            {
                if (CallId > 0)
                {
                    Data    = buffer;
                    results = CallIdExists(CallId, Instance, Name) ? Update() : Insert();
                }
            }
            catch (Exception ex)
            {
                GeneralUtility.LogError(ex.Message, Name);
            }
            return(results);
        }
Пример #9
0
 private static string InstanceFromRegistry(bool useCache)
 {
     GeneralUtility.DebugLog("InstanceFromRegistry entered.", "DatabaseInstance");
     if (useCache && !string.IsNullOrEmpty(_instanceFromRegistry))
     {
         return(_instanceFromRegistry);
     }
     using (var rkFns = Registry.LocalMachine.OpenSubKey("Software\\Edgewater\\FNS\\"))
     {
         lock (SynchLock)
         {
             OdbcDsn dsn = null;
             if (rkFns == null)
             {
                 return(string.Empty);
             }
             var results = rkFns.GetValue("ConnectString").ToString();
             GeneralUtility.DebugLog("results = " + results, "DatabaseInstance");
             try
             {
                 dsn = OdbcDsn.CreateFromEncypted(results);
             }
             catch (Exception ex)
             {
                 GeneralUtility.DebugLog("Error: " + ex.Message, "InstanceFromRegistry");
             }
             if (dsn == null)
             {
                 GeneralUtility.LogError(string.Format("Error decrypting registry value={0}", results),
                                         "InstanceFromRegistry");
                 return(results.Length == 0
       ? results
       : new OdbcDsn(results).Server);
             }
             GeneralUtility.DebugLog("Decrypted results = " + dsn.ToDisplayString(), "DatabaseInstance");
             var instance = dsn.Server;
             if (useCache)
             {
                 _instanceFromRegistry = instance;
             }
             return(instance);
         }
     }
 }
Пример #10
0
 public static string GetCallClaimIdFromCallId(string callId, string instance)
 {
     try
     {
         var records = new ActiveRecordSet
         {
             Instance = instance,
             Query    = string.Format("select call_claim_id from call_claim where call_id = {0}", callId)
         };
         if (records.Execute() && records.MoveNext())
         {
             return(records[0].ToString());
         }
     }
     catch (Exception ex)
     {
         GeneralUtility.LogError(ex.Message, "GetCallClaimIdFromCallId");
     }
     return(string.Empty);
 }
Пример #11
0
        /// <summary>
        /// Commits the updated.
        /// </summary>
        protected virtual bool CommitUpdated(Database db)
        {
            bool results = true;

            try
            {
                foreach (IActiveRecord rec in UpdateList)
                {
                    if (!rec.Update(db))
                    {
                        throw new ApplicationException(rec.LastError);
                    }
                }
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
                GeneralUtility.LogError(LastError, ToString());
                results = false;
            }
            return(results);
        }
Пример #12
0
        /// <summary>
        /// Executes this instance.
        /// </summary>
        /// <returns></returns>
        public bool Execute()
        {
            try
            {
                _records.Clear();
                if (_dbInstance.Length == 0)
                {
                    _dbInstance = ApplicationConfiguration.Instance.DefaultInstance;
                }

                GeneralUtility.DebugLog("Execute entered", _activeRecordType);
                var db = new OracleDatabase(GeneralUtility.GetConnectStringFromInstance(_dbInstance));

                GeneralUtility.DebugLog("Database created", _activeRecordType);
                return(ExecuteReader(db));
            }
            catch (Exception ex)
            {
                _lastErrorMessage = ex.Message;
                GeneralUtility.LogError(_lastErrorMessage, _activeRecordType);
            }
            return(false);
        }
Пример #13
0
        /// <summary>
        /// Commits this instance.
        /// </summary>
        /// <returns></returns>
        public virtual bool Commit()
        {
            bool results;

            try
            {
                GeneralUtility.DebugLog("Transaction started", ToString());
                using (var oTranScope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    if (DbInstance.Length == 0)
                    {
                        DbInstance = ApplicationConfiguration.Instance.DefaultInstance;
                    }
                    GeneralUtility.DebugLog("Execute entered", ToString());
                    var db = new Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase(GeneralUtility.GetConnectStringFromInstance(DbInstance));
                    GeneralUtility.DebugLog("Database created", ToString());

                    results = CommitInserted(db);
                    if (results)
                    {
                        if (CommitUpdated(db))
                        {
                            oTranScope.Complete();
                            GeneralUtility.DebugLog("Transaction complete ", ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LastError = ex.Message;
                GeneralUtility.LogError(LastError, ToString());
                results = false;
            }
            ClearAll();
            return(results);
        }
Пример #14
0
        /// <summary>
        /// Generates the insert SQL.
        /// </summary>
        /// <returns></returns>
        //protected override string GenerateInsertSql()
        //{
        //  var sql = new StringBuilder("INSERT INTO CALL (CALL_ID, ACCNT_HRCY_STEP_ID, ENTRY_POINT_HRCY_STEP_ID, LOB_CD, ");
        //  sql.Append("CLIENT_HRCY_STEP_ID, CALL_START_TIME, STATUS,USER_ID, ");
        //  sql.Append("INPUT_SYSTEM_NAME, CALLER_INFO, ORGINAL_CALL_ID, SERVER_NAME) VALUES(");
        //  sql.AppendFormat("{0}, {1}, {2}, '{3}', {4}, sysdate, 'INPROC', {5}, 'FNS NET', '{6}', {7}, '{8}')",
        //    CallId, AccntHrcyStepId, ClientHrcyStepId, LobCd, ClientHrcyStepId, UserId, CallerInfo, (OrginalCallId.Length > 0 ? OrginalCallId : "NULL"),ServerName );
        //  return sql.ToString();
        //}

        /// <summary>
        /// Gets the ahs id from call id.
        /// </summary>
        /// <param name="callId">The call id.</param>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static string GetAhsIdFromCallId(string callId, string instance)
        {
            var results = string.Empty;

            try
            {
                var record = new CallRecord {
                    Instance = instance, CallId = callId
                };
                if (record.Execute())
                {
                    results = record.AccntHrcyStepId;
                }
                else
                {
                    throw new ApplicationException(record.LastError);
                }
            }
            catch (Exception ex)
            {
                GeneralUtility.LogError(ex.Message, "GetAhsIdFromCallId");
            }
            return(results);
        }