public void TestCleanup()
        {
            _sendNotifications = null;

            _updatePackageMock = null;
            _notificationReceiverMock = null;
        }
        public void SendNotificationsTest_NotificationGetsSent_ResultIsTrue()
        {
            _notificationReceiverMock.SendNotification = true;

            _sendNotifications = new SendNotifications(new[] { _notificationReceiverMock }, false, false, _updatePackageMock, _nowGetterMock, _blackboardMock.Object);

            var actual = _sendNotifications.Do();
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.Errors.Count() == 0);
            Assert.AreEqual(1, _notificationReceiverMock.SendNotificationCalled);
            Assert.IsTrue(actual.Successful);
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            if (tbBody.Text.Length == 0 || tbSubj.Text.Length == 0)
            {
                return;
            }

            //send emails
            int groupId = int.Parse(ddlGroups.SelectedValue);

            SendNotifications.SendEmailToUserGroup(groupId, tbSubj.Text, tbBody.Text, rbPM.Checked);

            lblOK.Visible = true;
        }
        public void SendNotificationsTest_NotificationSentFails_ResultIsFalse_ErrorIsReturned()
        {
            _notificationReceiverMock.SendNotification = false;
            var exceptionToThrow = new NotificationSentException("Fehler");
            _notificationReceiverMock.SendNotificationThrowThisException = exceptionToThrow;

            _sendNotifications = new SendNotifications(new[] { _notificationReceiverMock }, false, false, _updatePackageMock, _nowGetterMock, _blackboardMock.Object);

            var actual = _sendNotifications.Do();
            Assert.IsNotNull(actual);
            Assert.AreEqual(1, actual.Errors.Count());
            Assert.AreEqual(actual.Errors.First().Exception, exceptionToThrow);
            Assert.AreEqual(1, _notificationReceiverMock.SendNotificationCalled);
            Assert.IsFalse(actual.Successful);
        }
Пример #5
0
        //application-global error handler
        void ApplicationInstance_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();

            //now here's a tricky part
            //pay attention
            //if its a TypeInitializationException it means that there was an error in some static constructor
            //which means that most likely user has forgot to run the database upgrade script or wrong connection string or smth similar
            //but even if he runs it afterwards, the exception will still "stay" there,
            //because TypeInitializationException is thrown only once. By the runtime.
            //So, let's unload/restart our app, so next time when it will be accessed -
            //it will RE-RUN static conctructors
            if (ex is TypeInitializationException)
            {
                HttpRuntime.UnloadAppDomain();
                return;
            }

            if (ex == null)
            {
                return;
            }
            if (ex is ViewStateException || ex.InnerException is ViewStateException)
            {
                return;
            }

            //send error report
            try
            {
                string errorDescr = ex.ToString();

                if (HttpContext.Current != null && HttpContext.Current.Request != null)
                {
                    errorDescr = HttpContext.Current.Request.Url + "\n\n" + errorDescr + "\n\n" + HttpContext.Current.Request.UserAgent + "\n" + HttpContext.Current.Request.UserHostAddress;
                }

                SendNotifications.SendEmail(!string.IsNullOrEmpty(Settings.SendErrorReportsTo) ? Settings.SendErrorReportsTo.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries) : new string[] { null },
                                            "error in the Forum application", errorDescr, async: true);
            }
            catch { }             //do nothing, we failed to send an error report
        }
Пример #6
0
        static void Main(string[] args)
        {
            SendNotifications obj = new SendNotifications();

            obj.SendEmail();
        }
Пример #7
0
        private string CreateContract(string CustomerNo, string NationalityId, string HourlyPricingId, string CityId, bool Shift, string DistrictId, string SelectedDays, string ContractStartDate, string lat, string lang, string MonthsCount, int VisitCount, string TotalPrice, int HoursCount, string Discount, string MonthelyPrice, int who = 1)
        {
            //Random generator = new Random();
            String r = new Random().Next(0, 1000000).ToString("D6");


            ContractStartDate = ContractStartDate.Replace('/', '-');



            Entity contract = new Entity("new_hindvcontract");

            contract["new_hindivclintname"] = new EntityReference("contact", new Guid(CustomerNo.ToString()));
            contract["new_nationality"]     = new EntityReference("new_country", new Guid(NationalityId));
            contract["new_houlrypricing"]   = new EntityReference("new_hourlypricing", new Guid(HourlyPricingId));
            Entity hourlyPricing = GlobalCode.Service.Retrieve("new_hourlypricing", new Guid(HourlyPricingId), new ColumnSet(true));

            contract["new_visitprice_def"]  = int.Parse(MathNumber.RoundDeciamlToInt(hourlyPricing["new_hourprice"].ToString())) * HoursCount;
            contract["new_visittotalprice"] = Decimal.Parse(hourlyPricing["new_hourprice"].ToString()) * HoursCount;
            int months = int.Parse(MonthsCount);

            contract["new_visitcount_def"] = SelectedDays.Split(',').Count();

            contract["new_monthvisits_def"] = VisitCount;
            if (months != 0)
            {
                contract["new_monthvisits_def"] = (VisitCount * 4);
            }



            if (months != 0)
            {
                contract["new_contractmonth"] = months;
            }
            //else
            // contract["new_contractmonth"] = 13;
            contract["new_totalvisits_def"] = VisitCount;
            if (months != 0)
            {
                contract["new_totalvisits_def"] = VisitCount * 4 * months;
            }
            //hourlyPricing["new_totalvisits"];
            if (who == 1)
            {
                contract["new_contractsource"] = new OptionSetValue(who);
            }
            else
            {
                contract["new_contractsource"] = new OptionSetValue(2);
            }


            contract["new_hindivcount"] = HoursCount;

            contract["new_contractmonth"] = new OptionSetValue(months);


            contract["new_weeklyvisits"] = new OptionSetValue(VisitCount);

            contract["new_discount_def"] = decimal.Parse(Discount);
            // Math.Round((decimal.Parse(a.TotalbeforeDiscount) - (decimal.Parse(a.TotalbeforeDiscount) * decimal.Parse(Discount) / 100)), 2, MidpointRounding.AwayFromZero).ToString().Replace(".00", "");

            contract["new_totalprice_def"]   = int.Parse(Math.Round(decimal.Parse(TotalPrice), 0, MidpointRounding.AwayFromZero).ToString());
            contract["new_new_contractdate"] = DateTime.Now;
            contract["new_city"]             = new EntityReference("new_city", new Guid(CityId));
            contract["new_district"]         = new EntityReference("new_district", new Guid(DistrictId));
            contract["new_shift"]            = Shift == true ? false : true;
            contract["new_contractconfirm"]  = false;
            contract["statuscode"]           = new OptionSetValue(100000004);



            contract["new_contractstartdate"] = DateTime.ParseExact(ContractStartDate, "dd-MM-yyyy", CultureInfo.InvariantCulture);
            contract["new_customerdays"]      = SelectedDays;
            //  contract["new_selecteddays"] = SelectedDays;
            contract["new_latitude"]    = lat;
            contract["new_longitude"]   = lang;
            contract["new_paymentcode"] = r;
            contract["new_mapurl"]      = "http://maps.google.com/maps?q=" + lat + "," + lang + "&z=15";


            Guid contractId = GlobalCode.Service.Create(contract);



            if (!string.IsNullOrEmpty(contractId.ToString()))
            {
                //Send SMS To confirm

                try
                {
                    string contsql = @"
select new_HIndvContract.new_ContractNumber ,Contact.FirstName from new_HIndvContract,Contact
 where Contact.ContactId =new_HIndvContract.new_HIndivClintname and 
 new_HIndvContract.new_HIndvContractId='@id'";
                    contsql = contsql.Replace("@id", contractId.ToString());
                    System.Data.DataTable dtcontract = CRMAccessDB.SelectQ(contsql).Tables[0];


                    string Sql = @"select    MobilePhone,new_deviceid from Contact where  ContactId='@id'  ";

                    Sql = Sql.Replace("@id", CustomerNo);
                    System.Data.DataTable dt = CRMAccessDB.SelectQ(Sql).Tables[0];


                    //send Notification

                    string result = SendNotifications.SendNotify("," + CustomerNo, "عزيزى العميل /" + dtcontract.Rows[0]["FirstName"].ToString() + "   " + "شكرا لاختياركم شركة ناس سيتم التواصل معكم قريبا لتاكيد الموعد للعقد رقم " + dtcontract.Rows[0]["new_ContractNumber"].ToString());

                    string body = "عزيزى العميل /" + dtcontract.Rows[0]["FirstName"].ToString() + "   " + "شكرا لاختياركم شركة ناس سيتم التواصل معكم قريبا لتاكيد الموعد للعقد رقم " + dtcontract.Rows[0]["new_ContractNumber"].ToString();
                    AppleNotifications.SendPushNotification(dt.Rows[0]["new_deviceid"].ToString(), body, "شركة ناس للاستقدام");


                    //Send To SMS

                    /*  Entity SMS = new Entity("new_smsns");
                     * string UserName = ConfigurationManager.AppSettings["SMSUserName"];
                     * string SMSPassword = ConfigurationManager.AppSettings["SMSPassword"];
                     * string TagName = ConfigurationManager.AppSettings["TagName"];
                     * SMSRef.SMSServiceSoapClient sms = new SMSRef.SMSServiceSoapClient();
                     * string MobileNumber = dt.Rows[0][0].ToString();
                     * string Message = "https://nasmanpower.com/HourlyServiceContract/Maps.aspx?id=" + contractId + "  برجاء تاكيد الموقع باستخدام الرابط المرسل . شكرا لاستخدامكم شركة ناس   ";
                     * string res = sms.SendBulkSMS(UserName, SMSPassword, TagName, MobileNumber, Message);*/
                }
                catch (Exception)
                {
                    return(contractId.ToString());
                }
            }

            return(contractId.ToString());
        }
Пример #8
0
 public JsonResult GetNotification()
 {
     return(Json(SendNotifications.GetNotification(), JsonRequestBehavior.AllowGet));
 }
Пример #9
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>parses the inner state of the element</summary>
        /// <param name="e">evennt arguments</param>
        /// <param name="parser">the atomFeedParser that called this</param>
        //////////////////////////////////////////////////////////////////////
        public override void Parse(ExtensionElementEventArgs e, AtomFeedParser parser)
        {
            XmlNode eventNode = e.ExtensionElement;

            // Parse a Reminder Element - recurrence event, g:reminder is in top level
            // reminders are already changed to IExtensionElementFactory, so call base
            // see addEventEntryExtensions()
            base.Parse(e, parser);

            if (String.Compare(eventNode.NamespaceURI, BaseNameTable.gNamespace, true) == 0)
            {
                // Parse a Status Element
                if (eventNode.LocalName == GDataParserNameTable.XmlEventStatusElement)
                {
                    this.Status = EventStatus.parse(eventNode);
                    e.DiscardEntry = true;
                }
                // Parse a Visibility Element
                else if (eventNode.LocalName == GDataParserNameTable.XmlVisibilityElement)
                {
                    this.EventVisibility = Visibility.parse(eventNode);
                    e.DiscardEntry = true;
                }
                // Parse a Transparency Element
                else if (eventNode.LocalName == GDataParserNameTable.XmlTransparencyElement)
                {
                    this.EventTransparency = Transparency.parse(eventNode);
                    e.DiscardEntry = true;
                }
                // Parse a Recurrence Element
                else if (eventNode.LocalName == GDataParserNameTable.XmlRecurrenceElement)
                {
                    this.Recurrence = Recurrence.ParseRecurrence(eventNode);
                    e.DiscardEntry = true;
                }
                else if (eventNode.LocalName == GDataParserNameTable.XmlRecurrenceExceptionElement)
                {
                    this.RecurrenceException = RecurrenceException.ParseRecurrenceException(eventNode, parser);
                    e.DiscardEntry = true;
                }
                // Parse a Comments Element
                else if (eventNode.LocalName == GDataParserNameTable.XmlCommentsElement)
                {
                    this.Comments = Comments.ParseComments(eventNode);
                    e.DiscardEntry = true;
                } else if (eventNode.LocalName == GDataParserNameTable.XmlExtendedPropertyElement)
                {
                    ExtendedProperty p = ExtendedProperty.Parse(eventNode); 
                    if (p != null)
                    {
                        e.DiscardEntry = true;
                        this.ExtensionElements.Add(p);
                    }
                }
            }
            else if (String.Compare(eventNode.NamespaceURI, GDataParserNameTable.NSGCal, true) == 0)
            {
                // parse the eventnotification element
                Tracing.TraceMsg("Parsing in the gCal Namespace");
                if (eventNode.LocalName == GDataParserNameTable.XmlSendNotificationsElement)
                {
                    this.sendNotifications = SendNotifications.parse(eventNode);
                    e.DiscardEntry = true;
                }
            }
        }
Пример #10
0
 /// <summary>
 ///  parse method is called from the atom parser to populate an Transparency node
 /// </summary>
 /// <param name="node">the xmlnode to parser</param>
 /// <returns>Notifications object</returns>
 public static SendNotifications parse(XmlNode node)
 {
     SendNotifications notify = null;
     Tracing.TraceMsg("Parsing a gCal:SendNotifications");
     if (String.Compare(node.NamespaceURI, GDataParserNameTable.NSGCal, true) == 0)
     {
         notify = new SendNotifications();
         if (node.Attributes != null)
         {
             notify.Value = node.Attributes["value"].Value;
             Tracing.TraceMsg("Notification parsed, value = " + notify.Value);
         }
     }
     return notify;
 }
Пример #11
0
 protected override void OnStart(string[] args)
 {
     var send = new SendNotifications();
 }
Пример #12
0
        public void TestMail()
        {
            SendNotifications obj = new SendNotifications();

            obj.SendEmail();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            var popup = new PopupNotifier();

            popup.Image     = Properties.Resources.email;
            popup.TitleText = "Email Notification";
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                var r = MetroMessageBox.Show(this, @"Are you sure you want to SUBMIT?", @"eVoting System",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (r == DialogResult.Yes)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    using (_cnn = new SqlConnection(Properties.Settings.Default.DbConn))
                    {
                        _cnn.Open();
                        if (CheckVoter())
                        {
                            var k = Verify(_mRegMin1, _mRegMin2, _mRegMin3);
                            if (k == -1)
                            {
                                using (_cmd = new SqlCommand("spAddVoter", _cnn))
                                {
                                    _cmd.CommandType = CommandType.StoredProcedure;
                                    _cmd.Parameters.AddWithValue("@voterPin", voterPin);
                                    _cmd.Parameters.AddWithValue("@firstName", txtFirstname.Text);
                                    _cmd.Parameters.AddWithValue("@lastName", txtLastname.Text);
                                    _cmd.Parameters.AddWithValue("@gender", cmbGender.Text);
                                    _cmd.Parameters.AddWithValue("@phoneNumber", txtPhoneNumber.Text);
                                    _cmd.Parameters.AddWithValue("@email", txtEmail.Text);
                                    _cmd.Parameters.AddWithValue("m_reg1", _mRegMin1);
                                    _cmd.Parameters.AddWithValue("m_reg2", _mRegMin2);
                                    _cmd.Parameters.AddWithValue("m_reg3", _mRegMin3);

                                    var outParameter = new SqlParameter();
                                    outParameter.ParameterName = "@voterId";
                                    outParameter.SqlDbType     = SqlDbType.UniqueIdentifier;
                                    outParameter.Direction     = ParameterDirection.Output;
                                    _cmd.Parameters.Add(outParameter);

                                    var ms = new MemoryStream();
                                    picImage.Image.Save(ms, ImageFormat.Bmp);
                                    byte[] data = ms.ToArray();
                                    _cmd.Parameters.AddWithValue("@pic", data);

                                    try
                                    {
                                        _cmd.ExecuteNonQuery();
                                        voterId = outParameter.Value.ToString();
                                        var body =
                                            string.Format(
                                                "Hi, you are registered successfully. " + Environment.NewLine +
                                                "Your Security Key is {0}. Your Voter ID is {1}", voterId, voterPin);
                                        var emailReply = SendNotifications.SendEmail(txtEmail.Text, body);
                                        if (emailReply != null)
                                        {
                                            popup.ContentText = emailReply;
                                        }
                                        MetroMessageBox.Show(this, @"Data Submitted Successfully!", @"eVoting System",
                                                             MessageBoxButtons.OK,
                                                             MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                        ClearAll();
                                        popup.Popup();
                                    }
                                    catch (SqlException ex)
                                    {
                                        MetroMessageBox.Show(this, @"Data unable to save due to " + ex.Message);
                                    }
                                }
                            }
                            else
                            {
                                MetroMessageBox.Show(this, @"You have registered before", @"eVoting System", MessageBoxButtons.OK,
                                                     MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                _mFpm.EnableAutoOnEvent(false, 0);
                            }
                        }
                        else
                        {
                            MetroMessageBox.Show(this, @"Fingerprint does no match", @"eVoting System", MessageBoxButtons.OK,
                                                 MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        }
                    }
                    Cursor.Current = Cursors.Default;
                }
            }
        }