static void AlarmFormatter(Ram_Info ws1)
        {
            DirectoryInfo dInfo = new DirectoryInfo(ws1.AlarmTxtPath);
            if (!dInfo.Parent.Exists)
            {
                dInfo.Parent.Create();

            }

            StreamWriter sw = File.CreateText(AlarmFilePath);
            sw.WriteLine("%a");
            sw.WriteLine("-ObjectOfReference=SubNetwork=ONRM_RootMo,SubNetwork=TEXT");
            sw.WriteLine("-RecordType=1");
            sw.WriteLine("-EventTime=" + DateTime.Now.ToString("yyyyMMddHHmmss"));
            if (AlarmStatus == Convert.ToInt32(AlarmSignal.AlarmEnd))
            {
                sw.WriteLine("-PerceivedSeverity=" + ws1.AlarmEndSeverity.ToString());
            }
            else
            {
                sw.WriteLine("-PerceivedSeverity=" + ws1.AlarmStartSeverity.ToString());
            }
            sw.WriteLine("-SpecificProblem=" + ws1.AlarmCode);
            sw.WriteLine("-ManagedElement=mores");
            sw.WriteLine("%A");
            sw.Close();
        }
        static Ram_Info readXmlToObj()
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(AlarmFilePath);
                XmlElement root = doc.DocumentElement;
                XmlNodeList nodes = root.SelectNodes("/Settings/RAM");

                Ram_Info _objRamInfo = new Ram_Info();

                foreach (XmlNode node in nodes)
                {

                    _objRamInfo.SleepTime = Convert.ToInt32(node["CheckPeriodInSeconds"].InnerText);
                    _objRamInfo.ServiceCode = node["ServiceCode"].InnerText;
                    _objRamInfo.SmsList = node["SmsTo"].InnerText;
                    _objRamInfo.MessageStarted = node["MessageStarted"].InnerText;
                    _objRamInfo.MessageStopped = node["MessageStopped"].InnerText;
                    _objRamInfo.ClubName = node["ProjectName"].InnerText;

                    _objRamInfo.isMailSendEnable = CommonFunctions.toBool(node["EmailEnabled"].InnerText);
                    _objRamInfo.isSmsSendEnable = CommonFunctions.toBool(node["SmsEnabled"].InnerText);
                    _objRamInfo.isFtpUploadEnable = CommonFunctions.toBool(node["FtpEnabled"].InnerText);
                    _objRamInfo.AlarmTxtPath = node["AlarmFilePath"].InnerText;

                    _objRamInfo.Name = node["Name"].InnerText;
                    _objRamInfo.AlarmStartSeverity = Convert.ToInt32(node["AlarmStartSeverity"].InnerText);
                    _objRamInfo.AlarmEndSeverity = Convert.ToInt32(node["AlarmEndSeverity"].InnerText);
                    _objRamInfo.AlarmValue = Convert.ToInt32(node["AlarmValue"].InnerText);
                    _objRamInfo.AlarmCode = Convert.ToInt32(node["AlarmCode"].InnerText);
                    _objRamInfo.AlarmFilePath = node["AlarmFilePath"].InnerText;
                    _objRamInfo.AlarmStatus = 0;
                    _objRamInfo.AlarmCount = 0;
                    _objRamInfo.FtpFileName = node["FtpFileName"].InnerText;
                    _objRamInfo.EmailSubject = node["EmailSubject"].InnerText;
                    _objRamInfo.EmailBody = node["EmailBody"].InnerText;
                    _objRamInfo.ReceiverList = node["EmailTo"].InnerText;
                    _objRamInfo.AlarmPercentage = Convert.ToSingle(node["AlarmPercentage"].InnerText);

                }

                return _objRamInfo;

            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(LogLevel.ERROR, String.Format("MESSAGE: {0} *** STACK TRACE: {1}", ex.Message, ex.StackTrace));

                return null;
            }
        }
        static void AlarmChecker(Ram_Info ws1)
        {
            try
            {

                if (AlarmCount > ws1.AlarmValue && AlarmStatus == 0)
                {

                    try
                    {
                        AlarmFormatter(ws1);
                    }
                    catch (Exception ex)
                    {

                        LogUtil.WriteLog(LogLevel.ERROR, ex.Message + " " + ex.StackTrace + Environment.NewLine + "**** " + "Date:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }

                    if (ws1.isFtpUploadEnable)
                    {
                        FTPHandler ftpUploader = new FTPHandler();
                        ftpUploader.Upload(ws1.AlarmFilePath, ws1.FtpFileName);
                    }

                    if (ws1.isMailSendEnable)
                    {
                        string[] mailingList1 = ws1.ReceiverList.Split('#');
                        foreach (string mailAdress in mailingList1)
                        {
                            Mailer cs = new Mailer();
                            cs.EmailSubject = String.Format(ws1.ClubName + "/" + ws1.Name, ws1.ClubName);
                            cs.EmailBody = "Server-IP: " + ws1.ServerIpAddress + "\n" + "Project Name:  " + ws1.ClubName + "\n" + ws1.MessageStopped + "%" + ws1.AlarmPercentage + "\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            cs.IsHtmlMail = false;
                            cs.EmailTo = mailAdress;
                            cs.SmtpServerPort = SMTP_PORT;
                            cs.SenderEmailAddress = SMTP_USER;
                            cs.SenderEmailPassword = SMTP_PASS;
                            cs.EnableSsl = true;
                            cs.SmtpServerName = SMTP_HOST;
                            Mailer.SendSingleEmail(cs);
                            cs = null;

                        }

                    }

                    if (ws1.isSmsSendEnable)
                    {

                        try
                        {

                            string[] arrSmsList = ws1.SmsList.Split('#');
                            foreach (string Msisdn in arrSmsList)
                            {
                                DataAccessLayer _objDataAccessLayer = new DataAccessLayer();
                                _objDataAccessLayer.SendMessage(ws1.ServiceCode, Msisdn, String.Format("{0} - {1}", ws1.ClubName, ws1.MessageStopped + "\n" + "Server-IP: " + ws1.ServerIpAddress + "\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                            }
                        }
                        catch (Exception exSms)
                        {
                            LogUtil.WriteLog(LogLevel.ERROR, exSms.Message + " " + exSms.StackTrace + Environment.NewLine + "**** " + "Date:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }
                    AlarmStatus = 1;

                }

                else if (AlarmCount == 0 && AlarmStatus == 1)
                {

                    AlarmStatus = 0;
                    AlarmCount = 0;

                    try
                    {
                        AlarmFormatter(ws1);
                    }
                    catch (Exception ex)
                    {

                        LogUtil.WriteLog(LogLevel.ERROR, ex.Message + " " + ex.StackTrace + Environment.NewLine + "**** " + "Date:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }

                    if (ws1.isFtpUploadEnable)
                    {
                        FTPHandler ftpUploader = new FTPHandler();
                        ftpUploader.Upload(ws1.AlarmFilePath, ws1.FtpFileName);
                    }

                    if (ws1.isSmsSendEnable)
                    {

                        try
                        {

                            string[] arrSmsList = ws1.SmsList.Split('#');
                            foreach (string Msisdn in arrSmsList)
                            {
                                DataAccessLayer _objDataAccessLayer = new DataAccessLayer();
                                _objDataAccessLayer.SendMessage(ws1.ServiceCode, Msisdn, String.Format("{0} - {1}", ws1.ClubName, ws1.MessageStarted + "\n" + "Server-IP: " + ws1.ServerIpAddress + "\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                            }
                        }
                        catch (Exception exSms)
                        {
                            LogUtil.WriteLog(LogLevel.ERROR, exSms.Message + " " + exSms.StackTrace + Environment.NewLine + "**** " + "Date:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                    }

                    if (ws1.isMailSendEnable)
                    {
                        string[] mailingList = ws1.ReceiverList.Split('#');
                        foreach (string mailAdress in mailingList)
                        {
                            Mailer cs = new Mailer();
                            cs.EmailSubject = String.Format(ws1.ClubName + "/" + ws1.Name, ws1.ClubName);
                            cs.EmailBody = "Server-IP: " + ws1.ServerIpAddress + "\n" + "Project Name:  " + ws1.ClubName + "\n" + ws1.MessageStarted + "%" + ws1.AlarmPercentage + "\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            cs.IsHtmlMail = false;
                            cs.EmailTo = mailAdress;
                            cs.SmtpServerPort = SMTP_PORT;
                            cs.SenderEmailAddress = SMTP_USER;
                            cs.SenderEmailPassword = SMTP_PASS;
                            cs.EnableSsl = true;
                            cs.SmtpServerName = SMTP_HOST;
                            Mailer.SendSingleEmail(cs);
                            cs = null;
                        }

                    }
                }
                else
                {
                    Console.WriteLine("Normal");
                }
            }

            catch (Exception ex)
            {

                LogUtil.WriteLog(LogLevel.ERROR, ex.Message + " " + ex.StackTrace + Environment.NewLine + "**** " + "Date:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
        }