Example #1
0
        public void ValidateCondition_Valida_Argumento_Nome()
        {
            //Iniciar o monitoramento das mensagens, normalmente ficara em um base da controller da api
            NotificationManager.Start();

            //Validacoes que irao ocorrer em várias camadas do sistema
            string nome  = string.Empty;
            int    idade = 35;

            //Camada de serviços de aplicacao
            AddNotification.IfEmpty(nome, "Nome é obrigatório", "Metodo personalizado que chamou");

            //Camada de serviços (Dominio)
            AddNotification.IfNotGreaterThan(idade, 100, "Valor dever se maior que o segundo valor");

            //Camada de infra
            TesteNomeDoMetodoQueFezSolicitacao();

            //Verifica se todas as validações estão de válidas
            bool valid = NotificationManager.IsValid();

            //Obtém a lista de mensagens para apresentar para o usuário
            var lista = NotificationManager.GetNotifications();

            //Limpa lista de notificações
            NotificationManager.End();


            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(valid, "O argumento nao é verdadeiro");
        }
        public DataSet InsertUpdate_Notification(AddNotification obj)
        {
            using (SqlCommand sqlCommand = new SqlCommand())
            {
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = Procedures.Notification_AddUpdate;
                sqlCommand.Parameters.AddWithValue("@UserId", obj.UserId);
                sqlCommand.Parameters.AddWithValue("@NotificationId", obj.NotificationId);
                sqlCommand.Parameters.AddWithValue("@NotificationType", obj.NotificationType);
                sqlCommand.Parameters.AddWithValue("@NotificationNumber", obj.NotificationNumber);
                sqlCommand.Parameters.AddWithValue("@NotificationStatus", obj.NotificationStatus);
                sqlCommand.Parameters.AddWithValue("@DateOfNotification", obj.DateofNotification);
                sqlCommand.Parameters.AddWithValue("@DateOfComments", obj.FinalDateOfComments);
                sqlCommand.Parameters.AddWithValue("@SendResponseBy", obj.SendResponseBy);
                sqlCommand.Parameters.AddWithValue("@CountryId", obj.CountryId);
                sqlCommand.Parameters.AddWithValue("@Title", obj.Title);
                sqlCommand.Parameters.AddWithValue("@ResponsibleAgency", obj.ResponsibleAgency);
                sqlCommand.Parameters.AddWithValue("@UnderArticle", obj.UnderArticle);
                sqlCommand.Parameters.AddWithValue("@ProductsCovered", obj.ProductsCovered);
                sqlCommand.Parameters.AddWithValue("@HSCodes", obj.HSCodes);
                sqlCommand.Parameters.AddWithValue("@Description", obj.Description);
                sqlCommand.Parameters.AddWithValue("@EnquiryEmail", obj.EnquiryEmail);
                sqlCommand.Parameters.AddWithValue("@DoesHaveDetails", obj.DoesHaveDetails);

                if (obj.NotificationAttachment != null)
                {
                    sqlCommand.Parameters.AddWithValue("@NotificationAttachment", obj.NotificationAttachment.FileName);
                }

                if (obj.NotificationDoc != null && obj.NotificationDoc.Count > 0)
                {
                    sqlCommand.Parameters.AddWithValue("@NotificationDocument", obj.NotificationDocXML);
                }

                sqlCommand.Parameters.AddWithValue("@ObtainDocBy", obj.ObtainDocBy);
                sqlCommand.Parameters.AddWithValue("@TranslationReminder", obj.TranslationReminder);
                sqlCommand.Parameters.AddWithValue("@TranslationDueBy", obj.TranslationDueDate);
                sqlCommand.Parameters.AddWithValue("@StakeholderResponseDueBy", obj.StakeholderResponseDueBy);

                if (obj.TranslatedDoc != null && obj.TranslatedDoc.Count > 0)
                {
                    sqlCommand.Parameters.AddWithValue("@TranslatedDocument", obj.TranslatedDocXML);
                }

                sqlCommand.Parameters.AddWithValue("@Role", obj.Role);
                sqlCommand.Parameters.AddWithValue("@SkippedToDiscussion", obj.SkippedToDiscussion);
                sqlCommand.Parameters.AddWithValue("@RetainedForNextDiscussion", obj.RetainedforNextDiscussion);
                sqlCommand.Parameters.AddWithValue("@DocumentTypeId", obj.DocumentTypeId);
                return(DAL.GetDataSet(ConfigurationHelper.connectionString, sqlCommand));
            }
        }
Example #3
0
        private void HandleChannelSubscriber_NotifyAdd(RPCContext context)
        {
            AddNotification addNotification = AddNotification.ParseFrom(context.Payload);

            ChannelAPI.ChannelReferenceObject channelReferenceObject = this.GetChannelReferenceObject(context.Header.ObjectId);
            if (channelReferenceObject == null)
            {
                base.ApiLog.LogError("HandleChannelSubscriber_NotifyAdd had unexpected traffic for objectId : " + context.Header.ObjectId);
                return;
            }
            base.ApiLog.LogDebug("HandleChannelSubscriber_NotifyAdd: " + addNotification);
            ChannelAPI.ChannelType channelType = channelReferenceObject.m_channelData.m_channelType;
            switch (channelType)
            {
            case ChannelAPI.ChannelType.PRESENCE_CHANNEL:
                if (addNotification.ChannelState.HasPresence)
                {
                    bnet.protocol.presence.ChannelState presence = addNotification.ChannelState.Presence;
                    this.m_battleNet.Presence.HandlePresenceUpdates(presence, channelReferenceObject);
                }
                goto IL_16E;
            }
            ChannelAPI.ChannelData channelData = (ChannelAPI.ChannelData)channelReferenceObject.m_channelData;
            if (channelData != null)
            {
                channelData.m_channelState = addNotification.ChannelState;
                using (List <Member> .Enumerator enumerator = addNotification.MemberList.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Member   current       = enumerator.get_Current();
                        EntityId gameAccountId = current.Identity.GameAccountId;
                        channelData.m_members.Add(gameAccountId, current);
                        if (!this.m_battleNet.GameAccountId.Equals(gameAccountId))
                        {
                            this.m_battleNet.Presence.PresenceSubscribe(current.Identity.GameAccountId);
                        }
                    }
                }
            }
IL_16E:
            if (channelType == ChannelAPI.ChannelType.PARTY_CHANNEL)
            {
                this.m_battleNet.Party.PartyJoined(channelReferenceObject, addNotification);
            }
        }
        public async void AddNotification()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            if (string.IsNullOrEmpty(Message))
            {
                Value = true;
                return;
            }
            var _notification = new AddNotification
            {
                message           = Message,
                endValidationDate = EndValidationDate.ToString("yyyy-MM-dd")
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Save <AddNotification>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/notification/save",
                res,
                _notification);

            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Notification Added");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }
        public async Task <NotificationResult> AddNotification(AddNotification model)
        {
            try
            {
                var notification = new Notification
                {
                    UserId           = model.UserId,
                    SourceId         = model.SourceId,
                    NotificationType = model.NotificationType,
                    Message          = model.Message,
                    CreateDate       = DateTime.Now
                };
                db.Notifications.Add(notification);
                await db.SaveChangesAsync();

                var followers = await db.Followers.Where(f => f.UserId == notification.UserId).Select(f => f.FollowedUserId).ToListAsync();

                foreach (var followerId in followers)
                {
                    db.UsersNotifications.Add(new UsersNotification {
                        UserId = followerId, NotificationId = notification.NotificationId, IsChecked = false
                    });
                }
                await db.SaveChangesAsync();

                var notificationResult = new NotificationResult {
                    Notification = notification, Followers = followers, OperationCompleted = true
                };
                await hubContext.Clients.All.SendAsync(Notification, notificationResult);

                return(notificationResult);
            }
            catch (Exception ex)
            {
                return(new NotificationResult {
                    OperationCompleted = false, ErrorMessage = ex.Message
                });
            }
        }
Example #6
0
        public ActionResult Generar()
        {
            int d = -3;

            try
            {
                ReclamosTemp t = new ReclamosTemp();
                //t.NombreCliente = "Alina María Ortiz";
                t.Fecha       = DateTime.Today.ToString("dd/MM/yyyy");
                t.Lugar       = "Managua, Nicaragua";
                t.Comentarios = "Ejecutando prueba";
                t.UsuarioId   = 1;
                t.Tipo        = "1";
                t.Visto       = false;
                dbs.ReclamosTemps.Add(t);
                d = dbs.SaveChanges();
                AddNotification.AppendNotify(t);
            }
            catch (Exception)
            {
                d = -1;
            }
            return(Json(new { d }, JsonRequestBehavior.AllowGet));
        }
Example #7
0
		public override void NotifyAdd(Google.ProtocolBuffers.IRpcController controller, AddNotification request, Action<bnet.protocol.NO_RESPONSE> done) {
			throw new NotImplementedException();
		}
        public async Task HandleAsync(ReportAddedToIncident e)
        {
            var assemblyName = GetVersionAssemblyName(e.Incident.ApplicationId);

            if (assemblyName == null)
            {
                var notice = new AddNotification(CoderrClaims.RoleSysAdmin,
                                                 "There is no version assembly configured for " + e.Incident.ApplicationName +
                                                 ". Go to 'System Settings'/Versions and configure one")
                {
                    HoldbackInterval = TimeSpan.FromDays(3),
                    NotificationType = NotifyNoVersion
                };
                await _commandBus.ExecuteAsync(notice);

                return;
            }

            var collection = Enumerable.FirstOrDefault(e.Report.ContextCollections, x => x.Name == "Assemblies");

            if (collection == null)
            {
                return;
            }

            if (!collection.Properties.TryGetValue(assemblyName, out string version))
            {
                var notice = new AddNotification(CoderrClaims.RoleSysAdmin,
                                                 "Assembly " + assemblyName + " is configured for application " + e.Incident.ApplicationName +
                                                 ". It do however not exist. Configure a new one at 'System Settings'/Versions.")
                {
                    HoldbackInterval = TimeSpan.FromDays(3),
                    NotificationType = NotifyNotRecognizedVersion
                };
                await _commandBus.ExecuteAsync(notice);

                return;
            }

            var isNewIncident = e.Incident.ReportCount <= 1;
            var versionEntity = await _repository.FindVersionAsync(e.Incident.ApplicationId, version)
                                ?? new ApplicationVersion(e.Incident.ApplicationId, e.Incident.ApplicationName,
                                                          version);

            if (versionEntity.Version != version)
            {
                versionEntity = new ApplicationVersion(e.Incident.ApplicationId, e.Incident.ApplicationName, version);
            }
            versionEntity.UpdateReportDate();

            if (versionEntity.Id == 0)
            {
                await _repository.CreateAsync(versionEntity);
            }
            else
            {
                await _repository.UpdateAsync(versionEntity);
            }

            await IncreaseReportCounter(versionEntity.Id, isNewIncident);
        }
Example #9
0
        private void TesteNomeDoMetodoQueFezSolicitacao()
        {
            string variavel = "123455";

            AddNotification.IfNotGuid(variavel, "Nao é um guid valido");
        }
Example #10
0
 void OnDisable()
 {
     OnKill -= CreateKillNotification;
     KillNotification.OnRemoveFromList -= RemoveFromList;
 }
Example #11
0
 void OnEnable()
 {
     OnKill += CreateKillNotification;
     KillNotification.OnRemoveFromList += RemoveFromList;
 }
Example #12
0
 public override void NotifyAdd(Google.ProtocolBuffers.IRpcController controller, AddNotification request, Action <bnet.protocol.NO_RESPONSE> done)
 {
     throw new NotImplementedException();
 }