Ejemplo n.º 1
0
        public void EventLogHelper_WriteEntry_NoException()
        {
            string    message = "Test message";
            Exception ex      = null;

            EventLogHelper.WriteEntry(message, ex);
        }
Ejemplo n.º 2
0
        public void RunDebtSms()
        {
            if (!Check())
            {
                return;
            }


            using (var ctx = new DBEntities())
            {
                var result = ctx.SP_Debt_GetForSend().ToList();
                Ping();
                EventLogHelper.WriteEntry($"Debt SMS {result.Count} Started");
                var count = 0;
                foreach (var item in result)
                {
                    var url      = string.Empty;
                    var response = string.Empty;
                    var statusID = SMSStatus.None;
                    try
                    {
                        switch (MobileProvider.ToLowerInvariant())
                        {
                        case "magti":
                            url      = MagtiHttpToSMS.GetFormatedURL(MagtiUserName, MagtiPassword, MagtiClientID, item.Mobile, item.Message);
                            response = HttpToSMSBase.SendWebRequest(url);
                            if (response.StartsWith(MagtiHttpToSMS.SmscReturnCodes.Successfull))
                            {
                                count++;
                                statusID = SMSStatus.Sent;
                            }
                            else
                            {
                                statusID = SMSStatus.Error;
                            }

                            ctx.SP_Debt_Save(item.ID, item.MobileID, (byte)statusID);
                            ctx.SP_T_DebtDetailLog_Save(item.ID, item.MobileID, url, response.SafeSubstring(0, 25), string.Empty);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (statusID == SMSStatus.None)//თუ მანამდე მოხდა შეცდომა ვიდრე ჩაწერდა ლოგს ასეთ შემთხვევაში უნდა გაიზარდოს +1 -ით
                        {
                            ctx.SP_Debt_Save(item.ID, item.MobileID, (byte)SMSStatus.Error);
                        }
                        ctx.SP_T_DebtDetailLog_Save(item.ID, item.MobileID, url, response.SafeSubstring(0, 25), ex.ToString());
                    }
                }
                EventLogHelper.WriteEntry($"Debt SMS {count}/{result.Count} Completed");
            }
        }
Ejemplo n.º 3
0
        public void EventLogHelper_WriteEntry_WithException()
        {
            string message = "Test message";

            try
            {
                ThrowException1();
            }
            catch (Exception ex)
            {
                EventLogHelper.WriteEntry(message, ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Startet den Ablauf
        /// </summary>
        /// <param name="args">Data passed by the start command.</param>
        protected override void OnStart(string[] args)
        {
            // Debugger.Launch();

            //if (string.IsNullOrEmpty(this.ServiceName))
            //{
            //    this.ServiceName = GetServiceName();
            //}

            try
            {
                this.dataBridge = new DataBridge();
                this.dataBridge.Load(this.dataBridge.GetConfigFileName());
                this.dataBridge.Start();
            }
            catch (Exception ex)
            {
                EventLogHelper.WriteEntry(Program.EventLogName, "Failed to start: " + ex.Message);
                throw;
            }
        }
Ejemplo n.º 5
0
        public DataBridgeService(string[] args)
        {
            try
            {
                // Debugger.Launch();

                if (args.Length > 0)
                {
                    this.ServiceName = args[0];
                }

                this.InitializeComponent();

                Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            }
            catch (Exception ex)
            {
                EventLogHelper.WriteEntry(Program.EventLogName, "Failed to start: " + ex.Message);

                throw new Exception("Error in Constructor, Service could not be started.\n", ex);
            }
        }