/// <summary>
        ///   Bulks the load.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="dt">Data table with values.</param>
        /// <param name="colMapping">The column mapping with insert table.</param>
        public void BulkLoad(string tableName, DataTable dt, Dictionary <string, string> colMapping)
        {
            DataTraceLogger.Log("Method Start bulkLoad", tableName);
            DbConnection con = GetDatabase().CreateConnection();

            try
            {
                SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)con, SqlBulkCopyOptions.KeepIdentity, null);
                foreach (var item in colMapping)
                {
                    bulkCopy.ColumnMappings.Add(item.Key, item.Value);
                }

                bulkCopy.DestinationTableName = tableName;
                con.Open();
                bulkCopy.WriteToServer(dt);
                DataTraceLogger.Log("Method Finish bulkLoad");
            }
            catch (Exception ex)
            {
                MTSExceptionHandler.HandleException(ref ex);
            }
            finally
            {
                con.Close();
            }
        }
예제 #2
0
 private void SendErrorMail(int smtpId, string fromAddress, string toAddress, string error)
 {
     try
     {
         DataSet stmpDetails = this.dataaccess.GetSTMPDetails();
         if (stmpDetails == null || stmpDetails.Tables.Count == 0)
         {
             return;
         }
         MailMessage message = new MailMessage();
         message.To.Add(toAddress.ToString());
         message.Subject    = emailSubject;
         message.From       = new System.Net.Mail.MailAddress(fromAddress); //to avoid name collision
         message.Body       = $"Hello {fromAddress}, \n Your Request for project creation has been failed \n Error details - {error} \n Thank you!";
         message.IsBodyHtml = true;
         DataRow[] dataRowArray = stmpDetails.Tables[0].Select("SmtpId='" + smtpId + "'");
         new SmtpClient(dataRowArray[0]["SMTPCLIENTHOST"].ToString(), Convert.ToInt32(dataRowArray[0]["SMTPCLIENTPORT"]))
         {
             EnableSsl             = Convert.ToBoolean(dataRowArray[0]["ENABLESSL"]),
             Timeout               = Convert.ToInt32(dataRowArray[0]["TIMEOUT"]),
             DeliveryMethod        = ((SmtpDeliveryMethod)Convert.ToInt32(dataRowArray[0]["SMTPDELIVERYMETHOD"])),
             UseDefaultCredentials = Convert.ToBoolean(dataRowArray[0]["USEDEFAULTCREDENTIALS"]),
             Credentials           = ((ICredentialsByHost) new NetworkCredential(dataRowArray[0]["USERNAME"].ToString(), dataRowArray[0]["PASSWORD"].ToString(), dataRowArray[0]["DOMAIN"].ToString()))
         }.Send(message);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
     }
 }
예제 #3
0
        private void DoTaskForService(string param = "")
        {
            workevent.Reset();
            try
            {
                bool HasReachedMaxRetryCnt = false;

                LogMessage("Service Execution Started");
                LogDebugMessage("DoTask Method Call Started");

                object Status = new object();

                if (string.IsNullOrEmpty(param))
                {
                    Status = ServiceBaseType.InvokeMember("DoTask", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, objService, null);
                }
                else
                {
                    Status = ServiceBaseType.InvokeMember("DoTask", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, objService, new object[] { param });
                }

                LogDebugMessage("Status" + Status.ToString());
                LogMessage("Service Execution End Status:" + Status.ToString());
                LogDebugMessage("DoTask Method Call End");
                if (!Convert.ToBoolean(Status))
                {
                    if (CurrentMaxErrorsCnt == MaxErrorsCount)
                    {
                        this.Stop();
                        return;
                    }
                    if (CurrentRetryCnt == Retrycount)
                    {
                        ++CurrentMaxErrorsCnt;
                        HasReachedMaxRetryCnt = true;
                    }
                    if (!HasReachedMaxRetryCnt)
                    {
                        ++CurrentRetryCnt;
                        DoTaskForService(param);
                    }
                }
                CurrentRetryCnt = 0;
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
                LogDebugMessage(ex.Message);
                LogDebugMessage(ex.StackTrace);
                MTSExceptionHandler.HandleException(ref ex);
                ++CurrentRetryCnt;
            }
            finally
            {
                workevent.Set();
            }
        }
예제 #4
0
 public bool DoTask()
 {
     try
     {
         this.ReadProjectEmails();
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
     }
     return(true);
 }
 /// <summary>
 ///   Executes the non query for delete the image - input parameter is image doc id
 /// </summary>
 /// <param name="imagedocid">The image doc id.</param>
 /// <returns></returns>
 public static void DeleteImage(Int64 imagedocid)
 {
     try
     {
         Database db = GetDatabase();
         db.ExecuteNonQuery(GetCmd(db, "CUS_DELETEIMAGE", imagedocid));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
     }
 }
 public bool DoTask()
 {
     try
     {
         this.SendEmail();
         return(true);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(false);
     }
 }
 /// <summary>
 ///   Gets the image.
 /// </summary>
 /// <param name="imagedocid">The image doc id for input of Store procedure.</param>
 /// <returns>
 ///   data reader with image
 /// </returns>
 public static IDataReader GetImages(Int64 imagedocid)
 {
     try
     {
         Database db = GetDatabase();
         return(db.ExecuteReader(GetCmd(db, "CUS_GETIMAGE", imagedocid)));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
예제 #8
0
        private void SetTimers()
        {
            try
            {
                double ServiceTimerInterval = 300000;
                int    ServiceInvokeType    = Convert.ToInt32(dtServiceSchedule.Rows[0]["SERVICEINVOKETYPE"]);

                if (ServiceInvokeType == 0)
                {
                    LogMessage("Service Invoke Type Polling");

                    ServiceTimerInterval = TimeSpan.FromMinutes(Convert.ToDouble(dtServiceSchedule.Rows[0]["Time"])).TotalMilliseconds;
                    LogMessage("Service will run every " + TimeSpan.FromMinutes(Convert.ToDouble(dtServiceSchedule.Rows[0]["Time"])).TotalMinutes.ToString() + " minutes");
                    ServiceTimer          = new System.Timers.Timer(ServiceTimerInterval);
                    ServiceTimer.Elapsed += new ElapsedEventHandler(InvokeImmediateTimer);
                    ServiceTimer.Enabled  = true;
                }
                else if (ServiceInvokeType == 1)
                {
                    LogMessage("Service Invoke Type Timed");
                    lstAlaram = new List <string>();
                    string timeDetails = (string)dtServiceSchedule.Rows[0]["Time"];
                    foreach (string time in timeDetails.Split(','))
                    {
                        LogMessage("Service Will run at " + time);
                        lstAlaram.Add(time);
                    }
                    TimerAlaram          = new System.Timers.Timer(60000);
                    TimerAlaram.Elapsed += new ElapsedEventHandler(CheckTimeForLoadingAlarmList);
                    TimerAlaram.Enabled  = true;
                }
                else if (ServiceInvokeType == 2)
                {
                    LogMessage("Service Invoke Type Tenant Specific");
                    CreateTenantSpecificTasks();
                    TimerAlaram          = new System.Timers.Timer(60000);
                    TimerAlaram.Elapsed += new ElapsedEventHandler(InitTenantSpecificTimedService);
                    TimerAlaram.Enabled  = true;
                }
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
                LogDebugMessage(ex.Message);
                LogDebugMessage(ex.StackTrace);
                MTSExceptionHandler.HandleException(ref ex);
                workevent.Set();
            }
        }
예제 #9
0
 private object UpdateCloseProject(Dictionary <string, string> mailContent)
 {
     try
     {
         return(DataAccess.ExecuteScalar("MTS_CLOSEPROJECT", new object[1]
         {
             (object)mailContent["Description"],
         }));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(-1);
     }
 }
 /// <summary>
 ///   Executes the scalar.
 /// </summary>
 /// <param name="SPName">Name of the SP</param>
 /// <param name="parameterValues">parameter values in order of creation</param>
 /// <returns></returns>
 public object ExecuteScalar(string SPName, params object[] parameterValues)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteScalar", SPName, parameterValues);
         Database db     = GetDatabase();
         object   result = db.ExecuteScalar(GetCmd(db, SPName, parameterValues));
         DataTraceLogger.Log("Method Finish ExecuteScalar");
         return(result);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
 /// <summary>
 ///   Executes the non query.
 /// </summary>
 /// <param name="SPName">Name of the SP</param>
 /// <param name="parameterValues">parameter values in order of creation</param>
 /// <returns></returns>
 public int ExecuteNonQuery(string SPName, params object[] parameterValues)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteNonQuery", SPName, parameterValues);
         Database db     = GetDatabase();
         int      result = db.ExecuteNonQuery(GetCmd(db, SPName, parameterValues));
         DataTraceLogger.Log("Method Finish ExecuteNonQuery");
         return(result);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(-999);
     }
 }
 /// <summary>
 ///   Executes the command text.
 /// </summary>
 /// <param name="commandText">The command text.</param>
 /// <returns></returns>
 public IDataReader ExecuteCommandText(string commandText)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteCommandText", commandText);
         Database    db      = GetDatabase();
         IDataReader _reader = db.ExecuteReader(CommandType.Text, commandText);
         DataTraceLogger.Log("Method Finish ExecuteCommandText");
         return(_reader);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
 /// <summary>
 ///   Gets the data table with image.
 /// </summary>
 /// <param name="ImageDocId">The image doc id for input of Store procedure.</param>
 /// <returns>data table with image</returns>
 public static DataTable GetImage(Int64 ImageDocId)
 {
     try
     {
         Database  db  = GetDatabase();
         DbCommand cmd = GetCmd(db, "CUS_GETIMAGE", ImageDocId);
         DataSet   ds  = db.ExecuteDataSet(cmd);
         DataTable dt  = ds.Tables[0];
         return(dt);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
 /// <summary>
 ///   Puts the image.
 /// </summary>
 /// <param name="frontimage">The front image.</param>
 /// <param name="rearimage">The rear image.</param>
 /// <returns></returns>
 public static Int64 PutImage(byte[] frontimage, byte[] rearimage)
 {
     try
     {
         Database  db  = GetDatabase();
         DbCommand cmd = null;
         cmd = GetCmd(db, "CUS_PUTIMAGE", frontimage, rearimage);
         db.ExecuteNonQuery(cmd);
         return(Convert.ToInt64(cmd.Parameters["@RETURN_VALUE"].Value));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(-999);
     }
 }
 public static int Checkimageexist(Int64 imagedocid)
 {
     try
     {
         Database  db  = GetDatabase();
         DbCommand cmd = null;
         cmd = GetCmd(db, "CUS_CHECKIMAGEEXIST", imagedocid);
         db.ExecuteNonQuery(cmd);
         return(Convert.ToInt32(cmd.Parameters["@RETURN_VALUE"].Value));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(-999);
     }
 }
예제 #16
0
        private void CheckTimeForLoadingAlarmList(object sender, ElapsedEventArgs e)
        {
            TimerAlaram.Enabled = false;
            workevent.Reset();
            List <string> lstRemove = new List <string>();

            try
            {
                string currenttime = DateTime.Now.ToString("HH:mm");

                if (currenttime == "00:00") // Load alarmlist everyday at 12'O clock midnight
                {
                    LogMessage("Service Alarm List Refreshed");
                    lstAlaram = null;
                    SetTimers();
                }
                else
                {
                    foreach (var lsttime in lstAlaram)
                    {
                        if (currenttime == lsttime.ToString())
                        {
                            DoTaskForService();
                            lstRemove.Add(lsttime);
                        }
                    }
                    foreach (var remove in lstRemove)
                    {
                        lstAlaram.Remove(remove);
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
                LogDebugMessage(ex.Message);
                LogDebugMessage(ex.StackTrace);
                MTSExceptionHandler.HandleException(ref ex);
            }
            finally
            {
                workevent.Set();
                TimerAlaram.Enabled = true;
                lstRemove           = null;
            }
        }
 /// <summary>
 /// </summary>
 /// <param name="sql">Full Query String</param>
 /// <returns></returns>
 public static DataSet ExecuteSQLDataSet(string sql)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteSQLDataSet", sql);
         Database  db  = GetDatabase();
         DbCommand cmd = db.GetSqlStringCommand(sql);
         DataSet   ds  = db.ExecuteDataSet(cmd);
         DataTraceLogger.Log("Method Finish ExecuteSQLDataSet");
         return(ds);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
예제 #18
0
        protected override void OnStart(string[] args)
        {
            // System.Diagnostics.Debugger.Launch();
            LogDebugMessage("OnStart Started");
            try
            {
                SName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
                bool IsExecuteOnce = false;

                LogDebugMessage("SName " + SName);
                if (args.Length > 0)
                {
                    IsExecuteOnce = Convert.ToBoolean(args[0].Trim());
                }

                LoadServiceSchedule();
                LoadService();

                if (bool.Parse(ConfigurationManager.AppSettings["IsDebug"]) || IsExecuteOnce)
                {
                    LogDebugMessage("Debug Condition");
                    LogMessage("Run Once Start");

                    DoTaskForService();

                    LogMessage("Run Once End");
                }
                else
                {
                    LogDebugMessage("Timer Condition");
                    LogMessage("Start Service Start");
                    SetTimers();
                    UpdateServiceStatus(SName, 1);
                    LogMessage("Start Service End");
                }
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
                LogDebugMessage(ex.Message);
                LogDebugMessage(ex.StackTrace);
                MTSExceptionHandler.HandleException(ref ex);
                workevent.Set();
            }
        }
예제 #19
0
 private object UpdateCreateProject(Dictionary <string, string> mailContent)
 {
     try
     {
         return(DataAccess.ExecuteScalar("MTS_PROJECTCREATOR", new object[4]
         {
             (object)mailContent["Customer Name"],
             (object)mailContent["Description"],
             (object)Convert.ToDouble(mailContent["Quote Amount"].Substring(1, mailContent["Quote Amount"].Length - 1)),
             (object)Regex.Replace(mailContent["TECH"], @"\s+", "")
         }));
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(-99);
     }
 }
 /// <summary>
 /// </summary>
 /// <param name="ConnectionString">DataBase Connection String</param>
 /// <param name="sql">Full Query String</param>
 /// <returns></returns>
 public static DataTable ExecuteSQLDataTable(string ConnectionString, string sql)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteSQLDataTable", sql);
         Database  db  = GetSQLDatabase(ConnectionString);
         DbCommand cmd = db.GetSqlStringCommand(sql);
         DataSet   ds  = db.ExecuteDataSet(cmd);
         DataTable dt  = ds.Tables[0];
         DataTraceLogger.Log("Method Finish ExecuteSQLDataTable");
         return(dt);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
 /// <summary>
 ///   Gets the data table.
 /// </summary>
 /// <param name="spName">Name of the store procedure.</param>
 /// <param name="parameters">The parameters of store procedure</param>
 /// <returns></returns>
 public DataTable GetDataTable(string SPName, params object[] parameterValues)
 {
     try
     {
         DataTraceLogger.Log("Method Start GetDataTable", SPName, parameterValues);
         Database  db  = GetDatabase();
         DbCommand cmd = GetCmd(db, SPName, parameterValues);
         DataSet   ds  = db.ExecuteDataSet(cmd);
         DataTable dt  = ds.Tables[0];
         DataTraceLogger.Log("Method Finish GetDataTable");
         return(dt);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
 /// <summary>
 ///   This method used where output parameters are required.
 /// </summary>
 /// <param name="SPName"> Name of the SP</param>
 /// <param name="parameterValues">parameter values in order of creation</param>
 /// <returns></returns>
 public DbCommand ExecuteNonQueryCMD(string SPName, params object[] parameterValues)
 {
     try
     {
         DataTraceLogger.Log("Method Start ExecuteNonQueryCMD", SPName, parameterValues);
         Database  db  = GetDatabase();
         DbCommand cmd = null;
         cmd = GetCmd(db, SPName, parameterValues);
         db.ExecuteNonQuery(cmd);
         DataTraceLogger.Log("Method Finish ExecuteNonQueryCMD");
         return(cmd);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(null);
     }
 }
예제 #23
0
        private void LoadService()
        {
            try
            {
                string DLLName = dtServiceSchedule.Rows[0]["DLLName"].ToString();
                LogDebugMessage("Dllname - " + DLLName);
                string ServiceParams = dtServiceSchedule.Rows[0]["ServiceParams"].ToString();
                LogDebugMessage("Params - " + ServiceParams);
                Retrycount     = Convert.ToInt16(dtServiceSchedule.Rows[0]["RetryCount"]);
                MaxErrorsCount = Convert.ToInt16(dtServiceSchedule.Rows[0]["MaxErrors"]);

                Assembly ServiceDll = Assembly.LoadFile(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\" + DLLName);

                LogDebugMessage("DLLLoad Path -" + Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + @"\" + DLLName);
                foreach (Type type in ServiceDll.GetTypes())
                {
                    if (typeof(IMTSServiceBase).IsAssignableFrom(type))
                    {
                        ServiceBaseType = type;
                        break;
                    }
                }

                LogDebugMessage("Instance Creation Started");
                objService = Activator.CreateInstance(ServiceBaseType);
                LogDebugMessage("Instance Creation Ended");

                LogDebugMessage("OnStart Method Invoke Started");
                MethodInfo method = ServiceBaseType.GetMethod("OnStart");
                method.Invoke(objService, new object[] { ServiceParams });
                LogDebugMessage("OnStart Method Invoke End");
            }
            catch (Exception ex)
            {
                LogMessage(ex.Message);
                LogMessage(ex.StackTrace);
                LogDebugMessage(ex.Message);
                LogDebugMessage(ex.StackTrace);
                MTSExceptionHandler.HandleException(ref ex);
                workevent.Set();
            }
        }
 private void DoEmailProcess(string TemplateId)
 {
     foreach (DataRow dataRow in this.dsEmailMaster.Tables[0].Select("TemplateId=" + TemplateId))
     {
         int Status = 1;
         try
         {
             if (!this.SendMail(new EmailTemplate().CreateEmailTemplateAndProcess(this.dsEmailTemplates.Tables[0].Select("TemplateId=" + dataRow[nameof(TemplateId)].ToString())[0]["HTMLPAGE"].ToString(), dataRow["EmailSP"].ToString()), this.dsEmailTemplates.Tables[0].Select("TemplateId=" + dataRow[nameof(TemplateId)].ToString())[0]["SMTPID"].ToString()))
             {
                 Status = 2;
             }
         }
         catch (Exception ex)
         {
             Status = 2;
             MTSExceptionHandler.HandleException(ref ex);
         }
         this.UpdateEmailStatus((int)dataRow["ID"], Status);
     }
 }
        /// <summary>
        /// </summary>
        /// <param name="SPName"></param>
        /// <param name="recordcount"></param>
        /// <param name="parameterValues"></param>
        /// <returns></returns>
        public IDataReader ExecuteReader(string SPName, out Int64 recordcount, params object[] parameterValues)
        {
            DataTraceLogger.Log("Method Start ExecuteReader", SPName, parameterValues);
            recordcount = 0;
            IDataReader IdataReader;

            try
            {
                Database  db  = GetDatabase();
                DbCommand cmd = GetCmd(db, SPName, parameterValues);
                IdataReader = db.ExecuteReader(cmd);
                recordcount = Convert.ToInt64(cmd.Parameters["@Return_Value"].Value);
                DataTraceLogger.Log("Method Finish DataTraceLogger");
                return(IdataReader);
            }
            catch (Exception ex)
            {
                MTSExceptionHandler.HandleException(ref ex);
                return(null);
            }
        }
 private bool SendMail(Template email, string smtpId)
 {
     try
     {
         DataSet stmpDetails = this.dataaccess.GetSTMPDetails();
         if (stmpDetails == null || stmpDetails.Tables.Count == 0)
         {
             return(false);
         }
         MailMessage message = new MailMessage();
         message.To.Add(email.To);
         if (!string.IsNullOrEmpty(email.Cc))
         {
             message.To.Add(email.Cc);
         }
         if (!string.IsNullOrEmpty(email.BCc))
         {
             message.To.Add(email.BCc);
         }
         message.Subject    = email.Subject;
         message.From       = new MailAddress(email.From);
         message.Body       = email.Body.Replace("\n", "");
         message.IsBodyHtml = true;
         DataRow[] dataRowArray = stmpDetails.Tables[0].Select("SmtpId='" + smtpId + "'");
         new SmtpClient(dataRowArray[0]["SMTPCLIENTHOST"].ToString(), Convert.ToInt32(dataRowArray[0]["SMTPCLIENTPORT"]))
         {
             EnableSsl             = Convert.ToBoolean(dataRowArray[0]["ENABLESSL"]),
             Timeout               = Convert.ToInt32(dataRowArray[0]["TIMEOUT"]),
             DeliveryMethod        = ((SmtpDeliveryMethod)Convert.ToInt32(dataRowArray[0]["SMTPDELIVERYMETHOD"])),
             UseDefaultCredentials = Convert.ToBoolean(dataRowArray[0]["USEDEFAULTCREDENTIALS"]),
             Credentials           = ((ICredentialsByHost) new NetworkCredential(dataRowArray[0]["USERNAME"].ToString(), dataRowArray[0]["PASSWORD"].ToString(), dataRowArray[0]["DOMAIN"].ToString()))
         }.Send(message);
     }
     catch (Exception ex)
     {
         MTSExceptionHandler.HandleException(ref ex);
         return(false);
     }
     return(true);
 }
예제 #27
0
 private bool LoadServiceSchedule()
 {
     while (true)
     {
         try
         {
             dtServiceSchedule = null;
             dtServiceSchedule = ServiceLoaderDataAccess.GetServiceServiceConfig(SName);
             if (dtServiceSchedule.Rows.Count == 0)
             {
                 return(false);
             }
             return(true);
         }
         catch (Exception ex)
         {
             Thread.Sleep(10000);
             Exception exnew = new Exception("Exception while getting service schedule for the service.Will Retry after 10 sec", ex);
             MTSExceptionHandler.HandleException(ref exnew);
         }
     }
 }
        /// <summary>
        ///   This method is used in GetCmdParameters method, send the command from GetCmdParameters
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        //private int ExecuteNonQuery(Database db, DbCommand cmd)
        //{
        //    try
        //    {
        //        return db.ExecuteNonQuery(cmd);
        //    }
        //    catch (Exception ex)
        //    {
        //        MTSExceptionHandler.HandleException(ref ex);

        //        return -999;
        //    }
        //}

        /// <summary>
        ///   This method gets all stored procedure parameter and fill in the Command as out parameter
        /// </summary>
        /// <param name="SPName"> Name of the SP</param>
        /// <returns>DbCommand</returns>
        //private DbCommand GetCmdParameters(string SPName)
        //{
        //    try
        //    {
        //        Database db = GetDatabase();
        //        DbCommand cmd = GetCmd(db, SPName);
        //        db.DiscoverParameters(cmd);
        //        return cmd;
        //    }
        //    catch (Exception ex)
        //    {
        //        MTSExceptionHandler.HandleException(ref ex);
        //        return null;
        //    }
        //}

        /// <summary>
        ///   This is private helper method
        /// </summary>
        /// <param name="SPName"> Name of the Store procedure</param>
        /// <param name="parameterValues">parameter values for input of store procedure</param>
        /// <returns>DbCommand</returns>
        private DbCommand GetCmd(Database db, string SPName, params object[] parameterValues)
        {
            try
            {
                DbCommand cmd = null;
                if (parameterValues == null)
                {
                    cmd = db.GetStoredProcCommand(SPName);
                }
                else
                {
                    cmd = db.GetStoredProcCommand(SPName, parameterValues);
                }
                cmd.CommandTimeout = Convert.ToInt32(string.IsNullOrEmpty(_CommandTimeOut) ? "30" : _CommandTimeOut);
                return(cmd);
            }
            catch (Exception ex)
            {
                MTSExceptionHandler.HandleException(ref ex);
                return(null);
            }
        }
예제 #29
0
        private Dictionary <string, string> StringfyContent(string body)
        {
            Dictionary <string, string> pairs = new Dictionary <string, string>();

            try
            {
                string[] lines = body.Split('\n');
                foreach (string line in lines)
                {
                    if (!line.Trim().Equals(""))
                    {
                        pairs.Add(line.Substring(line.IndexOf(".") + 1,
                                                 line.IndexOf("=") - line.IndexOf(".") - 2).Trim(),
                                  line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1).Trim());
                    }
                }
            }
            catch (Exception ex)
            {
                MTSExceptionHandler.HandleException(ref ex);
            }
            return(pairs);
        }
        protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();

            MTSExceptionHandler.HandleException(ref ex);
        }