예제 #1
0
        /// <returns></returns>
        private async Task <ProcessResult <DeliveryModel> > DeliveryNotificationsAsync(long deliveryKey)
        {
            ProcessResult <DeliveryModel> retVal;

            try
            {
                DeliveryModel dmodel = await _deliveryQueries.GetDeliveryAsync(deliveryKey);

                var aps = new Aps(dmodel.Notification.Title, dmodel.Notification.Message, string.Empty,
                                  new List <string> {
                    dmodel.Notification.NotificationId.ToString()
                });
                ProcessResult result = await _pushService.SendAsync(dmodel.Subscription.DeviceToken, aps);

                retVal = new ProcessResult <DeliveryModel>(dmodel);
                retVal.PopulateErrorFromResult(result);
            }
            catch (Exception ex)
            {
                retVal = new ProcessResult <DeliveryModel>();
                retVal.SetErrorInfo($"DeliveryNotification Error: {ex.Message}");
            }

            return(retVal);
        }
예제 #2
0
        /// <param name="deviceToken"></param>
        /// <param name="notification"></param>
        /// <param name="topic"></param>
        /// <param name="ttl"></param>
        /// <param name="messageUuid"></param>
        /// <param name="lowPrioriry"></param>
        /// <returns></returns>
        public async Task SendAsync(string deviceToken, Aps aps, string topic = null, TimeSpan?ttl = null,
                                    string messageUuid = null, bool lowPrioriry = false)
        {
            DateTimeOffset expiration = DateTimeOffset.UtcNow.Add(ttl ?? _defaultNotificationTTL);
            string         payload    = JsonConvert.SerializeObject(new { aps = aps });

            await SendAsync(deviceToken, payload, expiration, topic, messageUuid, lowPrioriry);
        }
예제 #3
0
 public ApsPayload(string title, string body, bool contentAvailable)
 {
     Aps = new Aps
     {
         Alert = new ApsAlert
         {
             Title = string.IsNullOrWhiteSpace(title) ? null : title,
             Body  = string.IsNullOrWhiteSpace(body) ? null : body
         },
         ContentAvailable = contentAvailable ? 1 : 0
     };
 }
예제 #4
0
        /// <param name="deviceToken"></param>
        /// <param name="notification"></param>
        /// <returns></returns>
        public async Task <ProcessResult> SendAsync(string deviceToken, Aps aps)
        {
            ProcessResult retVal = new ProcessResult();

            try
            {
                IApplePNConnection connection = _client.GetConnection();
                await connection.SendAsync(deviceToken, aps);
            }
            catch (ApplePushException ex)
            {
                retVal.SetErrorInfo(ex.Message, (int)ex.StatusCode);
            }
            catch (HttpRequestException ex)
            {
                retVal.SetErrorInfo(ex.Message);
            }

            return(retVal);
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string valorParametro = Request.QueryString["objeto"];
            string _id            = null;
            string id_usuario     = null;

            try
            {
                id_usuario = Session["id_usuario"].ToString();
                _id        = Request.QueryString["id"];
            }
            catch
            {
            }

            var jsonSerialiser = new JavaScriptSerializer();


            if (valorParametro == "motivo_cli")
            {
                ObjetoTransferencia.Motivo objeto = new Motivo();
                using (DataTable dt = objeto.consultadt("usp_manutencao_motivo", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "tipo_cli")
            {
                ObjetoTransferencia.TipoCli objeto = new TipoCli();
                using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_cli", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "situacao_benficio_cli")
            {
                ObjetoTransferencia.SituacaoBeneficio objeto = new SituacaoBeneficio();
                using (DataTable dt = objeto.consultadt("usp_manutencao_situacao_beneficio", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "status_cli")
            {
                ObjetoTransferencia.Status objeto = new Status();
                using (DataTable dt = objeto.consultadt("usp_manutencao_status", "consultar"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "status_pasta")
            {
                ObjetoTransferencia.StatusPasta objeto = new StatusPasta();
                using (DataTable dt = objeto.consultadt("usp_manutencao_status_pasta", "consultar"))
                {
                    jresponse(dt);
                }
            }



            else if (valorParametro == "aps_origem")
            {
                ObjetoTransferencia.Aps objeto = new Aps();
                using (DataTable dt = objeto.consultadt("usp_manutencao_aps", "consultar"))
                {
                    jresponse(dt);
                }
            }

            //tipo_doc

            else if (valorParametro == "tipo_doc")
            {
                ObjetoTransferencia.TipoDoc objeto = new TipoDoc();
                using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_doc", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "documento")
            {
                ObjetoTransferencia.Documento objeto = new Documento();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_documento", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "documento_id")
            {
                ObjetoTransferencia.Documento objeto = new Documento();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_documento", "consultar_id"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "tipo_comp")
            {
                ObjetoTransferencia.TipoCompromisso objeto = new TipoCompromisso();
                using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_compromisso", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "compromisso")
            {
                ObjetoTransferencia.Compromisso objeto = new Compromisso();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_compromisso", "consultar"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "compromisso_id")
            {
                ObjetoTransferencia.Compromisso objeto = new Compromisso();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_compromisso", "consultar_id"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "tipo_mov")
            {
                ObjetoTransferencia.TipoMovimentacao objeto = new TipoMovimentacao();
                using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_movimentcao", "consultar"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "user")
            {
                ObjetoTransferencia.Responsavel objeto = new Responsavel();
                using (DataTable dt = objeto.consultadt("usp_manutencao_responsavel", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "cli")
            {
                ObjetoTransferencia.Cliente objeto = new Cliente();
                objeto.id_responsavel = Convert.ToInt32(id_usuario);
                using (DataTable dt = objeto.consultadt("usp_manutencao_cliente", "user_consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "cli_id")
            {
                ObjetoTransferencia.Cliente objeto = new Cliente();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_cliente", "consultar"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "cli_id_codigos")
            {
                ObjetoTransferencia.Cliente objeto = new Cliente();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;
                using (DataTable dt = objeto.consultadt("usp_manutencao_cliente", "consultar_codigos"))
                {
                    jresponse(dt);
                }
            }



            else if (valorParametro == "especie")
            {
                ObjetoTransferencia.Especie objeto = new Especie();
                using (DataTable dt = objeto.consultadt("usp_manutencao_especie", "consultar"))
                {
                    jresponse(dt);
                }
            }

            // endereco
            else if (valorParametro == "cidade")
            {
                ObjetoTransferencia.Comarca objeto = new Comarca();
                using (DataTable dt = objeto.consultadt("usp_manutencao_comarca", "consultar"))
                {
                    jresponse(dt);
                }
            }
            else if (valorParametro == "uf")
            {
                ObjetoTransferencia.UF objeto = new UF();
                using (DataTable dt = objeto.consultadt("usp_manutencao_uf", "consultar"))
                {
                    jresponse(dt);
                }
            }
            else if (valorParametro == "endereco")
            {
                ObjetoTransferencia.Endereco objeto = new Endereco();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_endereco", "consultar_id_cliente"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "endereco_id")
            {
                ObjetoTransferencia.Endereco objeto = new Endereco();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_endereco", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "contato")
            {
                ObjetoTransferencia.Contato objeto = new Contato();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_contato", "consultar_id_cliente"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "contato_id")
            {
                ObjetoTransferencia.Contato objeto = new Contato();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_contato", "consultar"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "especie_id")
            {
                ObjetoTransferencia.Especie objeto = new Especie();
                objeto.id = Convert.ToInt32(_id);
                using (DataTable dt = objeto.consultar_cod_esp("usp_manutencao_especie", "consultar_cod_esp"))
                {
                    jresponse(dt);
                }
            }

            else if (valorParametro == "movimentacao")
            {
                ObjetoTransferencia.Movimentacao objeto = new Movimentacao();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_movimentacao", "consultar_id_cliente"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "movimentacao_id")
            {
                ObjetoTransferencia.Movimentacao objeto = new Movimentacao();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_movimentacao", "consultar"))
                {
                    jresponse(dt);
                }
            }


            else if (valorParametro == "obs_contato")
            {
                ObjetoTransferencia.Obs objeto = new Obs();
                objeto.id      = Convert.ToInt32(_id);
                objeto.apagado = 0;

                using (DataTable dt = objeto.consultadt("usp_manutencao_obs_contato", "consultar"))
                {
                    jresponse(dt);
                }
            }
        }
예제 #6
0
 public ApsPayload(Aps aps)
 {
     Aps = aps;
 }
예제 #7
0
        public void consulta()
        {
            string retorno = "";

            if (acao == "Editar")
            {
                if (item == "motivo_cli")
                {
                    ObjetoTransferencia.Motivo objeto = new Motivo();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_motivo", "consultar"))
                    {
                        //retorno = JsonConvert.SerializeObject(dt);

                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "tipo_cli")
                {
                    ObjetoTransferencia.TipoCli objeto = new TipoCli();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_cli", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "situacao_benficio_cli")
                {
                    ObjetoTransferencia.SituacaoBeneficio objeto = new SituacaoBeneficio();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_situacao_beneficio", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "status_cli")
                {
                    ObjetoTransferencia.Status objeto = new Status();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_status", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }


                else if (item == "status_cli")
                {
                    ObjetoTransferencia.SituacaoBeneficio objeto = new SituacaoBeneficio();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_status", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "aps_origem")
                {
                    ObjetoTransferencia.Aps objeto = new Aps();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_aps", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                //tipo_doc

                else if (item == "tipo_doc")
                {
                    ObjetoTransferencia.TipoDoc objeto = new TipoDoc();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_doc", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "tipo_comp")
                {
                    ObjetoTransferencia.TipoCompromisso objeto = new TipoCompromisso();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_compromisso", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }


                else if (item == "tipo_mov")
                {
                    ObjetoTransferencia.TipoMovimentacao objeto = new TipoMovimentacao();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_tipo_movimentcao", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "especie")
                {
                    ObjetoTransferencia.Especie objeto = new Especie();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_especie", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "status_pasta")
                {
                    ObjetoTransferencia.StatusPasta objeto = new StatusPasta();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_status_pasta", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }

                else if (item == "obs_contato")
                {
                    ObjetoTransferencia.Obs objeto = new Obs();
                    objeto.id = id;
                    using (DataTable dt = objeto.consultadt("usp_manutencao_obs_contato", "consultar"))
                    {
                        valor.Value = dt.Rows[0][1].ToString();
                    }
                }
            }
            else if (acao == "Excluir")
            {
            }
        }
예제 #8
0
        public static string excluir(int id, string item)
        {
            string retorno = "Exclusão efetuada com sucesso!";

            if (item == "motivo_cli")
            {
                try
                {
                    Motivo objeto = new Motivo();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_motivo", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "tipo_cli")
            {
                try
                {
                    TipoCli objeto = new TipoCli();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_tipo_cli", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "situacao_benficio_cli")
            {
                try
                {
                    SituacaoBeneficio objeto = new SituacaoBeneficio();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_situacao_beneficio", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "status_cli")
            {
                try
                {
                    Status objeto = new Status();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_status", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }


            else if (item == "status_pasta")
            {
                try
                {
                    StatusPasta objeto = new StatusPasta();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_status_pasta", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "aps_origem")
            {
                try
                {
                    Aps objeto = new Aps();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_aps", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            //tipo_doc

            else if (item == "tipo_doc")
            {
                try
                {
                    ObjetoTransferencia.TipoDoc objeto = new TipoDoc();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_tipo_doc", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "tipo_comp")
            {
                try
                {
                    ObjetoTransferencia.TipoCompromisso objeto = new TipoCompromisso();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_tipo_compromisso", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }


            else if (item == "tipo_mov")
            {
                try
                {
                    TipoMovimentacao objeto = new TipoMovimentacao();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_tipo_movimentcao", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "especie")
            {
                try
                {
                    Especie objeto = new Especie();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_especie", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }


            else if (item == "status_pasta")
            {
                try
                {
                    StatusPasta objeto = new StatusPasta();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_status_pasta", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }

            else if (item == "obs_contato")
            {
                try
                {
                    Obs objeto = new Obs();
                    objeto.id      = id;
                    objeto.apagado = 1;
                    objeto.manutencao("usp_manutencao_obs_contato", "alterar");
                }
                catch (Exception ex)
                {
                    retorno = "Falha, motivo: " + ex.ToString();
                }
            }


            return(retorno);
        }
예제 #9
0
        public void insertTaskMember(List <TaskMemberDataEntity> ents, string bid)
        {
            LogApp logApp = new LogApp();

            foreach (var ent in ents)
            {
                rep.Insert(ent);
            }

            /*logApp.WriteDbLog(new LogEntity()
             * {
             *  F_Account = "",
             *  F_CreatorTime = System.DateTime.Now,
             *  F_Date = System.DateTime.Now,
             *  F_CreatorUserId = "",
             *  F_Description = "StartSend",
             *  F_Id = System.Guid.NewGuid().ToString(),
             *  F_ModuleId = "SendMessage",
             *  F_ModuleName = "SendMessage",
             *
             *
             * });
             */
            try
            {
                var shops = ents.GroupBy(p => p.shopCode);
                foreach (var shop in shops)
                {
                    string ShopCode = shop.Key;


                    var salesApp = new marketSalesApp();
                    var users    = salesApp.getGuidManByShop(ShopCode);
                    foreach (var user in users)
                    {
                        var            userinfo = salesApp.getUserInfoBySalesNo(user.sales_No);
                        string         taskId   = System.Guid.NewGuid().ToString();
                        TaskMastEntity ent      = new TaskMastEntity()
                        {
                            id                      = taskId,
                            alertType               = 1,
                            createdTime             = System.DateTime.Now,
                            createdUserId           = userinfo.id,
                            MESSAGE_BILL_NO         = bid,
                            MESSAGE_SUB_NO          = 0,
                            MESSAGE_REPLY_TYPE_CODE = "001",
                            MESSAGE_REPLY_TYPE_NAME = "不需回复",
                            RECEIVE_EMPLOYEE_CODE   = user.sales_No,
                            RECEIVE_EMPLOYEE_NAME   = user.sales_Name,
                            desc                    = "有会员进店,请接待",
                            freqType                = 1,
                            taskName                = "有会员进店,请接待",
                            starTime                = System.DateTime.Now,
                            endTime                 = System.DateTime.Now.AddMinutes(5),
                            importantType           = 1,
                            isAll                   = 1,
                            isRead                  = 0,
                            isReply                 = 0,

                            taskType          = "009",
                            taskTypeName      = "会员到店通知",
                            URGENCY_TYPE_CODE = "002",
                            URGENCY_TYPE_NAME = "紧急",
                            taskSource        = "系统",
                            isDelete          = 0,
                            taskUrl           = "{'shopCode':'" + ShopCode + "','bid':'" + bid + "'}"
                        };
                        taskRep.Insert(ent);

                        TaskPopApp popApp = new TaskPopApp();
                        popApp.createTaskPop(new TaskPopEntity()
                        {
                            id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = userinfo.id, userType = 1
                        });


                        string AndroIdDevice = getDeviceTokens(userinfo.id, "Android");
                        if (AndroIdDevice.Length > 0)
                        {
                            AndroidPostJson postJson = new AndroidPostJson();
                            var             payload  = new AndroidPayload();
                            postJson.type          = CastType.listcast;
                            postJson.device_tokens = AndroIdDevice;

                            payload.display_type      = "notification";
                            payload.body              = new ContentBody();
                            payload.body.ticker       = ent.taskName;
                            payload.body.title        = ent.taskName;
                            payload.body.icon         = "appicon";
                            payload.body.play_lights  = "true";
                            payload.body.play_sound   = "true";
                            payload.body.play_vibrate = "true";
                            payload.body.text         = ent.taskName;
                            payload.body.after_open   = AfterOpenAction.go_app;
                            //payload.body.custom = "comment-notify";
                            var dic = new Dictionary <string, string>();
                            dic.Add("messageId", System.Guid.NewGuid().ToString());

                            payload.extra        = dic;
                            postJson.payload     = payload;
                            postJson.description = ent.taskName;
                            UMengMessagePush <AndroidPostJson> uMAndroidPush = new UMengMessagePush <AndroidPostJson>("59550725677baa17ce0003fe", "grpqx0ayqc1ovn45iqczlrovqrdtvujf");
                            ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                            foreach (var memberEnt in ents)
                            {
                                postJson               = new AndroidPostJson();
                                payload                = new AndroidPayload();
                                postJson.type          = CastType.unicast;
                                postJson.device_tokens = AndroIdDevice;

                                payload.display_type      = "notification";
                                payload.body              = new ContentBody();
                                payload.body.ticker       = ent.taskName;
                                payload.body.title        = ent.taskName;
                                payload.body.icon         = "appicon";
                                payload.body.play_lights  = "true";
                                payload.body.play_sound   = "true";
                                payload.body.play_vibrate = "true";
                                payload.body.text         = ent.taskName;
                                payload.body.after_open   = AfterOpenAction.go_app;
                                dic = new Dictionary <string, string>();
                                dic.Add("messageId", System.Guid.NewGuid().ToString());
                                dic.Add("mfMemberId", memberEnt.mfMemberId);
                                dic.Add("bid", bid);

                                payload.extra               = dic;
                                postJson.payload            = payload;
                                postJson.policy             = new AndroidPolicy();
                                postJson.policy.expire_time = DateTime.Now.AddMinutes(5).ToString("yyyy-MM-dd HH:mm:ss");
                                UMengMessagePush <AndroidPostJson> uMAndroidPush2 = new UMengMessagePush <AndroidPostJson>("5b3ae2eaf43e4808f6000112", "gljoyn3tebkcchaeyvksvp0itjagynqr");
                                ReturnJsonClass resu2 = uMAndroidPush2.SendMessage(postJson);

                                /*logApp.WriteDbLog(new LogEntity()
                                 * {
                                 *  F_Account = user.sales_No,
                                 *  F_CreatorTime = System.DateTime.Now,
                                 *  F_Date = System.DateTime.Now,
                                 *  F_CreatorUserId = user.sales_No,
                                 *  F_Description = resu2.ret,
                                 *  F_Id = System.Guid.NewGuid().ToString(),
                                 *  F_ModuleId = "SendMessage",
                                 *  F_ModuleName = "SendMessage",
                                 *
                                 * });*/
                            }

                            System.Console.WriteLine(resu.ret);
                        }
                        string IOSDevice = getDeviceTokens(userinfo.id, "IOS");
                        if (IOSDevice.Length > 0)
                        {
                            IOSPostJson postJson = new IOSPostJson();
                            postJson.type = CastType.unicast;
                            var aps = new Aps()
                            {
                                alert = "msg",
                                sound = "default"
                            };
                            var     payload = new IOSPayload(aps);
                            JObject jo      = JObject.FromObject(payload);
                            var     extra   = new Dictionary <string, string>();
                            //用户自定义内容,"d","p"为友盟保留字段,key不可以是"d","p"
                            extra.Add("open", "list");
                            extra.ToList().ForEach(x => jo.Add(x.Key, x.Value));

                            postJson.payload         = jo;
                            postJson.description     = ent.taskName;
                            postJson.device_tokens   = IOSDevice;
                            postJson.production_mode = "true";

                            UMengMessagePush <IOSPostJson> uMAndroidPush = new UMengMessagePush <IOSPostJson>("596791cbb27b0a673700001f", "siy2v7u9uzishzimgnslzdukyqkeofhp");
                            ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                            System.Console.WriteLine(resu.ret);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logApp.WriteDbLog(new LogEntity()
                {
                    F_Account       = "",
                    F_CreatorTime   = System.DateTime.Now,
                    F_Date          = System.DateTime.Now,
                    F_CreatorUserId = "",
                    F_Description   = ex.Message,
                    F_Id            = System.Guid.NewGuid().ToString(),
                    F_ModuleId      = "SendMessage",
                    F_ModuleName    = "SendMessage",
                });
            }
        }
예제 #10
0
        public salesActualChangeRes leave(user_leaveEntity entity)
        {
            if (getLeaveByDate2(entity.userid, entity.StartDateTime.Value.ToString("yyyy-MM-dd"), entity.EndDateTime.Value.ToString("yyyy-MM-dd")).Count > 0)
            {
                return(new salesActualChangeRes()
                {
                    errorCode = "101", errorMessage = "请假失败,日期范围内请假记录已经存在!", isOk = false
                });
            }
            var    res   = service.leave(entity);
            string auser = null;

            if (res.isOk)
            {
                var shopApp = new marketShopApp();
                var shops   = shopApp.getShopByUserId(entity.userid);
                foreach (var shop in shops)
                {
                    //发送签核消息
                    var salesapp = new marketSalesApp();
                    var user     = salesapp.getAdminExecutiveById(shop.ORG_ID);
                    var userinfo = salesapp.GetUserInfo(entity.userid);



                    var ApUsers = salesapp.getPOrgUserInfo(userinfo.SalesNo);

                    var ApUserinfo = salesapp.getUserInfoBySalesNo(user.EMPLOYEE_CODE);

                    auser = ApUserinfo.id;

                    string         taskId = System.Guid.NewGuid().ToString();
                    TaskMastEntity ent    = new TaskMastEntity()
                    {
                        id                      = taskId,
                        alertType               = 1,
                        createdTime             = System.DateTime.Now,
                        createdUserId           = ApUserinfo.id,
                        MESSAGE_BILL_NO         = entity.id,
                        MESSAGE_SUB_NO          = 0,
                        MESSAGE_REPLY_TYPE_CODE = "001",
                        MESSAGE_REPLY_TYPE_NAME = "不需回复",
                        RECEIVE_EMPLOYEE_CODE   = ApUserinfo.SalesNo,
                        RECEIVE_EMPLOYEE_NAME   = ApUserinfo.Name,
                        desc                    = userinfo.Name + "的请假签核",
                        freqType                = 1,
                        taskName                = userinfo.Name + "的请假签核",
                        starTime                = System.DateTime.Now,
                        endTime                 = System.DateTime.Now.AddMinutes(5),
                        importantType           = 1,
                        isAll                   = 1,
                        isRead                  = 0,
                        isReply                 = 0,

                        taskType          = "001",
                        taskTypeName      = "一般通知",
                        URGENCY_TYPE_CODE = "002",
                        URGENCY_TYPE_NAME = "紧急",
                        taskSource        = "系统",
                        isDelete          = 0,
                        taskUrl           = "https://iretailerapp.flnet.com/QJ/QJAllowIndex?id=" + entity.id + "&userId=" + ApUserinfo.id
                    };
                    taskRep.Insert(ent);
                    TaskPopApp popApp = new TaskPopApp();
                    popApp.createTaskPop(new TaskPopEntity()
                    {
                        id = System.Guid.NewGuid().ToString(), status = 2, taskId = taskId, UserId = ApUserinfo.id, userType = 1
                    });
                    string AndroIdDevice = getDeviceTokens(ApUserinfo.id, "Android");
                    if (AndroIdDevice.Length > 0)
                    {
                        AndroidPostJson postJson = new AndroidPostJson();
                        var             payload  = new AndroidPayload();
                        postJson.type          = CastType.listcast;
                        postJson.device_tokens = AndroIdDevice;

                        payload.display_type      = "notification";
                        payload.body              = new ContentBody();
                        payload.body.ticker       = ent.taskName;
                        payload.body.title        = ent.taskName;
                        payload.body.icon         = "appicon";
                        payload.body.play_lights  = "true";
                        payload.body.play_sound   = "true";
                        payload.body.play_vibrate = "true";
                        payload.body.text         = ent.taskName;
                        payload.body.after_open   = AfterOpenAction.go_app;
                        //payload.body.custom = "comment-notify";
                        var dic = new Dictionary <string, string>();
                        dic.Add("messageId", System.Guid.NewGuid().ToString());
                        payload.extra        = dic;
                        postJson.payload     = payload;
                        postJson.description = ent.taskName;
                        UMengMessagePush <AndroidPostJson> uMAndroidPush = new UMengMessagePush <AndroidPostJson>("59550725677baa17ce0003fe", "grpqx0ayqc1ovn45iqczlrovqrdtvujf");
                        ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                        System.Console.WriteLine(resu.ret);
                    }
                    string IOSDevice = getDeviceTokens(ApUserinfo.id, "IOS");
                    if (IOSDevice.Length > 0)
                    {
                        IOSPostJson postJson = new IOSPostJson();
                        postJson.type = CastType.unicast;
                        var aps = new Aps()
                        {
                            alert = "msg",
                            sound = "default"
                        };
                        var     payload = new IOSPayload(aps);
                        JObject jo      = JObject.FromObject(payload);
                        var     extra   = new Dictionary <string, string>();
                        //用户自定义内容,"d","p"为友盟保留字段,key不可以是"d","p"
                        extra.Add("open", "list");
                        extra.ToList().ForEach(x => jo.Add(x.Key, x.Value));

                        postJson.payload         = jo;
                        postJson.description     = ent.taskName;
                        postJson.device_tokens   = IOSDevice;
                        postJson.production_mode = "true";

                        UMengMessagePush <IOSPostJson> uMAndroidPush = new UMengMessagePush <IOSPostJson>("596791cbb27b0a673700001f", "siy2v7u9uzishzimgnslzdukyqkeofhp");
                        ReturnJsonClass resu = uMAndroidPush.SendMessage(postJson);
                        System.Console.WriteLine(resu.ret);
                    }
                }
                //var ApUserinfo = salesapp.GetUserInfo(entity.userid);
            }

            var ent2 = service.FindEntity(entity.id);

            ent2.auser = auser;
            service.Update(ent2);
            return(res);


            //DateTime startTime = System.Convert.ToDateTime(entity.day.Value.ToString("yyyy-MM-dd 00:00:00"));
            //DateTime EndTime = System.Convert.ToDateTime(entity.day.Value.ToString("yyyy-MM-dd 23:59:59"));

            //entity.id = Common.GuId();
            //service.Insert(entity);
            //if (entity.day_type.Equals("1"))
            //{
            //    if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("2") || p.day_type.Equals("3"))) == null)
            //    {
            //        entity.id = Common.GuId();
            //        service.Insert(entity);
            //    }
            //    else
            //    {
            //        throw new Exception("请假记录已存在!");
            //    }
            //}
            //else if (entity.day_type.Equals("2"))
            //{
            //    if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("2"))) == null)
            //    {
            //        entity.id = Common.GuId();
            //        service.Insert(entity);
            //    }
            //    else
            //    {
            //        throw new Exception("请假记录已存在!");
            //    }
            //}
            //else if (entity.day_type.Equals("3"))
            //{
            //    if (service.FindEntity(p => p.day >= startTime && p.day <= EndTime && (p.day_type.Equals("1") || p.day_type.Equals("3"))) == null)
            //    {
            //        entity.id = Common.GuId();
            //        service.Insert(entity);
            //    }
            //    else
            //    {
            //        throw new Exception("请假记录已存在!");
            //    }
            //}
            //else
            //{
            //    throw new Exception("时间范围错误!");
            //}
        }