public string PermanentlyDeleteMessage(Stream message)
        {
            try
            {

                MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
                if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
                {
                    return "Invalid PIN";
                }
                if (objInput.Pin != null && objInput.Pin.Length > 0)
                {
                    MessageBox obj2 = new MessageBox();
                    List<MessageInfo> objcol = new List<MessageInfo>();
                    MessageInfo obj = new MessageInfo();
                    MessageBLL objbll = new MessageBLL();

                    obj.MessageComposeId = objInput.MessageComposeId;
                    obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                    int i = objbll.DeleteMessages_DeletedItems(obj);
                    if (i > 0)
                        return "Delete sucessful";
                    else
                        return "Delete Unsucessful";
                }
                else
                {
                    return "Pin is a required field";
                }
            }
            catch (Exception ex)
            {
                return "Unable to delete. Please try again later";
            }
        }
Exemplo n.º 2
0
        public IHttpActionResult AddAlarmMessageInside(GetMessageInfoParameter parm)
        {
            MessageBLL msg = new MessageBLL();
            var        get = msg.AddAlarmMessageInside(parm);

            return(InspurJson <string>(get, true));
        }
Exemplo n.º 3
0
        public IHttpActionResult GetInfoByUser(MessageInfoModel paramter)
        {
            MessageBLL user = new MessageBLL();
            var        add  = user.GetInfo(paramter);

            return(InspurJson <RetMessageInfo>(add));
        }
Exemplo n.º 4
0
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            T_Message  messageModel = new T_Message();
            MessageBLL messageBLL   = new MessageBLL();

            messageModel.NickName = txb_NickName.Text.ToString().Trim();
            messageModel.Grade    = txb_Grade.Text.ToString().Trim();
            messageModel.Sex      = rbl_Sex.SelectedValue.ToString().Trim();
            messageModel.Email    = txb_Email.Text.ToString().Trim();
            //messageModel.TeacherName = txb_TeacherName.Text.ToString().Trim();
            //if(ddl_TeacherName.SelectedValue)

            messageModel.TeacherName    = ddl_TeacherName.SelectedValue.ToString().Trim();
            messageModel.BriefQuestion  = txb_BriefQuestion.Text.ToString().Trim();
            messageModel.DetailQuestion = txb_DetailQuestion.Text.ToString().Trim();
            messageModel.Reply          = "";
            messageModel.QuestionTime   = DateTime.Now;
            messageModel.ReplyTime      = DateTime.Now;
            messageModel.Category       = 0;                                                        // 0为未分类
            messageModel.Status         = int.Parse(rbl_Reference.SelectedValue.ToString().Trim()); // 获取是否愿意展示给其他人

            int insertResult = messageBLL.Insert(messageModel);

            if (insertResult > 0)
            {
                Response.Write("<script>alert('提问成功,请等待邮件回复');location.href='qaonline.aspx'</script>");
                //Response.Redirect("qaonline.aspx");
            }
            else
            {
                Response.Write("<script>alert('出了点问题请稍后再试');location.href=qaonline.aspx</script>");
                //Response.Redirect("qaonline.aspx");
            }
        }
Exemplo n.º 5
0
        private void btnSendMessage_Click(object sender, RoutedEventArgs e) //发送消息
        {
            if (sendmsg.Text == string.Empty)
            {
                MessageBox.Show("消息不能为空");
                return;
            }
            Message message = new Message();

            message.Content    = sendmsg.Text;
            message.Userid     = msgsender.Id;
            message.Receiverid = msgreceiver.Id;
            message.Sendtype   = 1;
            message.Sendtime   = DateTime.Now;
            message.Sendfile   = null;
            MessageBLL bLL = new MessageBLL();

            if (!bLL.SendMessage(message))
            {
                MessageBox.Show("服务器异常");
            }
            else
            {
                string msg = "\n" + msgsender.Name + "    " + message.Sendtime.ToString() + "\n" + message.Content + "\n";
                ShowMessage.AppendText(msg);
                sendmsg.Text = "";
                ShowMessage.ScrollToEnd();
                msgscroll.ScrollToEnd();
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 康巴什发送短消息
 /// </summary>
 /// <param name="accounts"></param>
 /// <param name="name"></param>
 /// <param name="code"></param>
 /// <param name="title"></param>
 /// <param name="Category"></param>
 /// <param name="Content"></param>
 /// <returns></returns>
 public static bool KbsPushMeassge(string accounts, string name, string title, string Category, string Content)
 {
     try
     {
         MessageEntity msg = new MessageEntity
         {
             Title        = title,
             Category     = Category,
             Content      = Content,
             UserId       = accounts,
             UserName     = name,
             Status       = "",
             Url          = "",
             SendUser     = "******",
             SendUserName = "******",
             RecId        = ""
         };
         var flag = new MessageBLL().SaveForm("", msg);
         return(flag);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        public IHttpActionResult GetAllMessageInfo(MessageInfoModel model)
        {
            MessageBLL msg = new MessageBLL();
            var        get = msg.GetAllMessageInfo(model);

            return(InspurJson <List <RetMessageInfo> >(get));
        }
Exemplo n.º 8
0
        public ActionResult GetFileList(int id)
        {
            var             data     = MessageBLL.Get(id);
            List <FileInfo> fileList = new List <FileInfo>();

            if (string.IsNullOrWhiteSpace(data.PHOTO))
            {
            }
            else
            {
                var files = data.PHOTO.Split('|');
                foreach (var file in files)
                {
                    FileInfo info = new FileInfo();
                    info.FileName = file.Substring(0, file.LastIndexOf("."));
                    info.FileUrl  = ConfigurationManager.AppSettings["FileUrl"] + file;
                    fileList.Add(info);
                }
            }

            //修改消息为已读
            data.ISREAD_PLATFORM = 1;
            MessageBLL.Update(data);
            return(new JsonResult
            {
                Data = fileList
            });
        }
Exemplo n.º 9
0
        public async Task <ActionResult> send_message()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <JGN_Messages_Recipents>(json);

            var _message = await MessageBLL.sendMessage(_context, data);

            // receiver message info
            var info = await SiteConfig.userManager.FindByIdAsync(data.to_uid);

            if (info != null)
            {
                // await _emailSender.SendMessage(_context, model.ContactEmail, model);
            }

            // generate and push notification
            var notif = new JGN_Notifications()
            {
                sender_id         = data.message.from_uid,
                notification_type = (byte)NotificationTypes.Message,
                title             = "New Message Received",
                body         = data.message.subject,
                href         = Config.GetUrl(SystemDirectoryPaths.MessageUrl),
                recipient_id = data.to_uid
            };
            await NotificationBLL.postNotification(_context, notif);

            return(Ok(new { status = "success", message = "Message Sent", record = _message }));
        }
Exemplo n.º 10
0
 public UnitOfWork(IDbConnection connection)
 {
     Message  = new MessageBLL(connection);
     News     = new NewsBLL(connection);
     Services = new ServiceBLL(connection);
     Projects = new ProjectBLL(connection);
 }
Exemplo n.º 11
0
        public IHttpActionResult GetAllMessageToUser(UserMessageRelModel model)
        {
            UserApi    api       = new UserApi();
            var        userApi   = api.GetUserInfoByToken();
            string     GetUserID = userApi.Data.UserId;
            MessageBLL msg       = new MessageBLL();
            var        get       = msg.GetAllMessageToUser(model, GetUserID);

            return(InspurJson <List <RetUserMessageRel> >(get));
        }
Exemplo n.º 12
0
        public ActionResult SaveForm(string keyValue, SafetydayEntity entity)
        {
            safetydaybll.SaveForm(keyValue, entity, Server.MapPath("~"));

            var messagebll = new MessageBLL();

            messagebll.SendMessage("活动材料下发", keyValue);

            return(Success("操作成功。"));
        }
Exemplo n.º 13
0
        private void LoadData()
        {
            var recordCount = 0;
            var stTime      = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00");
            var endTime     = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
            var data        = MessageBLL.GetList("", "", stTime, endTime, 1, 20, out recordCount);

            ViewBag.Grid1RecordCount = recordCount;
            ViewBag.Grid1DataSource  = data;
        }
Exemplo n.º 14
0
        /// <summary>
        /// 判断是否已经发送短消息,避免重复发送相同的短消息。
        /// </summary>
        /// <param name="msgRemark">重复消息条件</param>
        /// <returns>结果(true:有,false:无)</returns>
        private bool ExistMsg(string msgRemark)
        {
            var r = false;

            var count = new MessageBLL().GetList(string.Format(" and Remark='{0}'", msgRemark)).Count();

            r = count > 0;

            return(r);
        }
Exemplo n.º 15
0
        public IHttpActionResult UpdateMessageInfo(List <MessageInfoModel> model)
        {
            UserApi    api     = new UserApi();
            var        userApi = api.GetUserInfoByToken();
            string     userid  = userApi.Data.UserId;
            MessageBLL msg     = new MessageBLL();
            var        get     = msg.UpdateMessageInfo(model, userid);

            return(InspurJson <RetMessageInfo>(get));
        }
Exemplo n.º 16
0
        public IHttpActionResult AddMessage(MessageInfoModel model)
        {
            UserApi api     = new UserApi();
            var     userApi = api.GetUserInfoByToken();

            model.CreateUserID = Convert.ToInt32(userApi.Data.UserId);
            MessageBLL msg = new MessageBLL();
            var        get = msg.AddMessage(model);

            return(InspurJson <RetMessageInfo>(get));
        }
Exemplo n.º 17
0
        private void LoadData_UserMessage(string phone)
        {
            var recordCount = 0;
            //近一个星期数据
            var stTime  = DateTime.Parse(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + " 00:00:00");
            var endTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59");
            var data    = MessageBLL.GetList_Map(phone, "", 0, stTime, endTime, 1, 20, out recordCount);

            ViewBag.UserMessageRecordCount = recordCount;
            ViewBag.UserMessageDataSource  = data;
        }
Exemplo n.º 18
0
        public async Task <ActionResult> marked_as_read()
        {
            var json     = new StreamReader(Request.Body).ReadToEnd();
            var messages = JsonConvert.DeserializeObject <List <JGN_Messages_Recipents> >(json);

            foreach (var message in messages)
            {
                await MessageBLL.ReadMessage(_context, message.messageid);
            }
            return(Ok(new { status = "success" }));
        }
Exemplo n.º 19
0
        private void PageInit()
        {
            MessageBLL  bll  = new MessageBLL();
            MessageInfo item = bll.GetItem(Id);

            if (item != null)
            {
                this.Subject = item.MsgContent;
                bll.UpdateItem(Id);
            }
        }
Exemplo n.º 20
0
        public string DelMsg(string id)
        {
            global::J6.Cms.Models.Member m = UserState.Member.Current;
            if (m == null)
            {
                return("请先登录");
            }
            int  msgID  = int.Parse(id);
            bool result = new MessageBLL().Delete(m.ID, msgID);

            return(result?"":"你没有权限删除本信息!");
        }
Exemplo n.º 21
0
    private void GetTotalRecords()
    {
        string where = "Owner=N'{0}'";
        where        = string.Format(where, CurrentUser.UserName);
        if (this.WildCard != "")
        {
            where = where + string.Format(" And (Title like N'%{0}%' or Body like N'%{0}%' or Sender  like N'%{0}%')", WildCard);
        }
        TotalRecords = MessageBLL.GetReceivedMessageTotalItems(where).ToString();

        PagingControl1.TotalRecords = int.Parse(TotalRecords);
    }
Exemplo n.º 22
0
        public ActionResult btnSearch_Click(JArray MessageGrid_fields, string username, string title, DateTime startTime, DateTime endTime, int MessageGrid_pageIndex, int MessageGrid_pageSize)
        {
            var grid1       = UIHelper.Grid("MessageGrid");
            var recordCount = 0;
            var stTime      = DateTime.Parse(startTime.ToString("yyyy-MM-dd") + " 00:00:00");
            var edTime      = DateTime.Parse(endTime.ToString("yyyy-MM-dd") + " 23:59:59");
            var data        = MessageBLL.GetList(username, title, stTime, edTime, MessageGrid_pageIndex + 1, MessageGrid_pageSize, out recordCount);

            grid1.RecordCount(recordCount);
            grid1.DataSource(data, MessageGrid_fields);

            return(UIHelper.Result());
        }
        protected void btn_send_Click(object sender, EventArgs e)
        {
            string msg = txt_send.Text;

            MembershipUser CurrentUser = Membership.GetUser();
            Guid           senderId    = (Guid)CurrentUser.ProviderUserKey;
            Guid           receiverId  = new Guid(ddl_users.SelectedValue);
            string         message     = txt_send.Text;
            string         date        = DateTime.Now.ToString("yyyy-MM-dd");

            MessageBLL.AddMsg(senderId, receiverId, message, date);
            Response.Redirect($"~/Pages/Users/Message.aspx?messaging={receiverId}");
        }
Exemplo n.º 24
0
        public ActionResult btnUserMessageSearch_Click(JArray UserMessageGrid_fields, string phone, int type, DateTime startTime, DateTime endTime, int UserMessageGrid_pageIndex, int UserMessageGrid_pageSize)
        {
            var grid1       = UIHelper.Grid("UserMessageGrid");
            var recordCount = 0;
            var stTime      = DateTime.Parse(startTime.ToString("yyyy-MM-dd") + " 00:00:00");
            var edTime      = DateTime.Parse(endTime.ToString("yyyy-MM-dd") + " 23:59:59");
            var data        = MessageBLL.GetList_Map(phone, "", type, stTime, edTime, UserMessageGrid_pageIndex + 1, UserMessageGrid_pageSize, out recordCount);

            grid1.RecordCount(recordCount);
            grid1.DataSource(data, UserMessageGrid_fields);

            return(UIHelper.Result());
        }
Exemplo n.º 25
0
    private DataSet GetDataGridSource()
    {
        string where = "Owner=N'{0}'";
        where        = string.Format(where, CurrentUser.UserName);
        if (this.WildCard != "")
        {
            where = where + string.Format(" And (Title like N'%{0}%' or Body like N'%{0}%' or Sender  like N'%{0}%')", WildCard);
        }

        DataSet ds = MessageBLL.GetReceivedMessagePagingitems(this.PagingControl1.ListRecordNumPerPage, this.PagingControl1.CurrentPage, where);

        return(ds);
    }
        protected void btn_users_Click(object sender, EventArgs e)
        {
            MembershipUser CurrentUser = Membership.GetUser();
            Guid           UserId      = (Guid)CurrentUser.ProviderUserKey;
            Guid           otherId     = new Guid(ddl_users.SelectedValue);
            DataTable      dtt         = MessageBLL.GetAllMsgBw(UserId, otherId);

            gv_message.DataSource = dtt;
            //gv_message.DataKeyNames = new string[] { "Fk_FromId", "FK_ToId" };
            gv_message.DataBind();

            //dtt.PrimaryKey = new DataColumn[] { dtt.Columns["MessageId"], dtt.Columns["FK_FromId"] };
            //ViewState["Message"] = dtt;
        }
Exemplo n.º 27
0
        public void SendMessageCanFail()
        {
            //Mock up an iprincipal
            SetupMessageGateway("testtest", false);

            var success = MessageBLL.SendMessage("from", "to", "subject", "body");

            Assert.IsFalse(success);

            //Now let's see if there was a tracking message inserted

            //There shouldn't be a messagetracking associated with the to address
            Assert.AreEqual(0, MessageTrackingBLL.EntitySet.Where(m => m.To == "to").Count());
        }
Exemplo n.º 28
0
        /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="add"></param>
        /// <param name="update"></param>
        /// <param name="del"></param>
        /// <param name="audit"></param>
        public void Operation(SevenSOfficeEntity add, SevenSOfficeEntity update, string del, SevenSOfficeAuditEntity audit, SevenSOfficeAuditEntity auditupdate)
        {
            try
            {
                if (audit != null)
                {
                    if (add != null)
                    {
                        if (string.IsNullOrEmpty(add.aduitstate))
                        {
                            add.aduitstate = "待审核";
                        }
                        audit.officeid = add.id;
                    }

                    audit.auditid = Guid.NewGuid().ToString();
                    var list = getAuditByid(audit.officeid);
                    audit.sort = list.Count() + 1;
                }
                service.Operation(add, update, del, audit, auditupdate);
                #region 消息推送
                MessageBLL messagebll = new MessageBLL();
                if (add != null)
                {
                    //待办通知
                    messagebll.SendMessage("待审核7S创新提案", add.id);
                }
                if (auditupdate != null)
                {
                    //修改时无新增
                    if (audit == null && update == null)
                    {
                        if (auditupdate.state == "审核通过")
                        {
                            messagebll.SendMessage("7S创新提案审批通过", auditupdate.officeid);
                        }
                        else
                        {
                            messagebll.SendMessage("7S创新提案审批不通过", auditupdate.officeid);
                        }
                    }
                }
                #endregion
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 29
0
        public async Task <ActionResult> load()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <MessageEntity>(json);

            var _posts = await MessageBLL.LoadItems(_context, data);

            foreach (var item in _posts)
            {
                item.user.img_url         = UserUrlConfig.ProfilePhoto(item.user.Id, item.user.picturename, 0);
                item.message.user.img_url = UserUrlConfig.ProfilePhoto(item.message.user.Id, item.message.user.picturename, 0);
            }

            return(Ok(new { posts = _posts }));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 保存评价
        /// </summary>
        /// <returns></returns>
        public void SaveEvaluation(string keyValue, string evaluation, string user)
        {
            var messagebll = new MessageBLL();

            try
            {
                service.SaveEvaluation(keyValue, evaluation, user);

                messagebll.SendMessage("7S照片评价", keyValue);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 31
0
        public async Task <ActionResult> check_notifs()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var data = JsonConvert.DeserializeObject <NotificationEntity>(json);

            var check_unread_notifications = await NotificationBLL.Count(_context, data);

            var check_unread_messages = await MessageBLL.Count(_context, new MessageEntity()
            {
                isRead    = false,
                To        = data.RecipentID,
                loadReply = false
            });

            return(Ok(new { notifs = check_unread_notifications, message_notifs = check_unread_messages }));
        }
Exemplo n.º 32
0
        public MessageBox[] GetAttachment(Stream message)
        {
            MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "Invalid PIN";
                obj2.MessengerMessage = "Invalid PIN";
                objArray[0] = obj2;
                return objArray;
            }
            if (objInput.Pin != null && objInput.Pin.Length > 0)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "No messages found";
                obj2.MessengerMessage = "No messages found";
                List<MessageInfo> objcol = new List<MessageInfo>();
                MessageInfo obj = new MessageInfo();
                MessageBLL objbll = new MessageBLL();
                obj.MessageId = objInput.MessageId;
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.GetAttachmentByMesageId(obj);
                if (objcol.Count() > 0)
                {
                    var objBox = new MessageBox[objcol.Count()];
                    for (int i = 0; i < objcol.Count(); i++)
                    {
                        MessageBox objR = new MessageBox();
                        if (objcol[i].Attachment != null && objcol[i].Attachment.Length > 0)
                        {
                            string[] filenames = objcol[i].Attachment.Split(',');
                            string[] filecont = new string[1];
                            string[] fileext = new string[1];
                            for (int icnt = 0; icnt <= filenames.GetUpperBound(0); icnt++)
                            {
                                if (icnt == objInput.AttachmentIndex)
                                {
                                    byte[] filecontent = File.ReadAllBytes(filenames[icnt]);
                                    FileInfo fi = new FileInfo(filenames[icnt]);
                                    filecont[0] = Convert.ToBase64String(filecontent);
                                    fileext[0] = fi.Name.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[1];
                                    objR.Attachment = filecont;
                                    objR.AttachmentExtension = fileext;
                                    break;
                                }

                            }

                        }
                        objBox[i] = objR;
                    }
                    return objBox;
                }
                objArray[0] = obj2;
                return objArray;
            }
            else
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "PIN is a required field";
                obj2.MessengerMessage = "Pin is a required field";
                objArray[0] = obj2;
                return objArray;
            }
        }
Exemplo n.º 33
0
        public string SendMessage()
        {
            HttpRequest request=HttpContext.Current.Request;

            int uid=int.Parse(request["uid"]);
            string subject=request["subject"];
            string content=request["msgcontent"];
            if (subject.Length < 6 || subject.Length > 50)
                return "<script>window.parent.op.tip('主题长度应为6-50个字符或3-25个汉字!')</script>";
            else if(content.Length<10||content.Length>150)
                return "<script>window.parent.op.tip('内容长度应为10-120个字符!')</script>";

            global::Ops.Cms.Models.Member m = UserState.Member.Current;
            MessageBLL bll = new MessageBLL();
            bll.SendMessage(m.ID, uid, subject, content);

            return "<script>window.parent.location.href='message?module=sendbox';</script>";
        }
Exemplo n.º 34
0
        public string DelMsg(string id)
        {
            global::Ops.Cms.Models.Member m = UserState.Member.Current;
            if (m == null) return "请先登录";
            int msgID = int.Parse(id);
            bool result=new MessageBLL().Delete(m.ID, msgID);

            return result?"":"你没有权限删除本信息!";
        }
Exemplo n.º 35
0
        public string UpdateMessage(Stream message)
        {
            try
            {
                MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
                if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
                {
                    return "Invalid PIN";
                }
                if (objInput.Pin != null && objInput.Pin.Length > 0)
                {
                    MessageInfo obj = new MessageInfo();
                    MessageBLL objbll = new MessageBLL();

                    obj.MessageId = objInput.MessageId;
                    obj.IsMessageRead = objInput.IsMessageRead;

                    obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();



                    int i = objbll.updatemessage(obj);

                    return "Updated successfully";

                }
                else
                {
                    return "Pin is a required field";
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Exemplo n.º 36
0
        public MessageBox[] DeletedMessages(Stream message)
        {
            MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "Invalid PIN";
                obj2.MessengerMessage = "Invalid PIN";
                objArray[0] = obj2;
                return objArray;
            }
            if (objInput.Pin != null && objInput.Pin.Length > 0)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "No messages found";
                obj2.MessengerMessage = "No messages found";
                List<MessageInfo> objcol = new List<MessageInfo>();
                MessageInfo obj = new MessageInfo();
                MessageBLL objbll = new MessageBLL();
                obj.ToId = objInput.ToId;
                obj.ToType = objInput.ToType;
                obj.Getattachment = objInput.GetAttachment;
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.BindDeleteMessages(obj);
                if (objcol.Count() > 0)
                {
                    var objBox = new MessageBox[objcol.Count()];
                    for (int i = 0; i < objcol.Count(); i++)
                    {
                        MessageBox objR = new MessageBox();
                        objR.MessageComposeId = objcol[i].MessageComposeId;
                        objR.MessageId = objcol[i].MessageId;
                        objR.FromId = objcol[i].FromId;
                        objR.ToId = objcol[i].ToId;
                        objR.FromEmailId = objcol[i].FromEmailId;
                        objR.ToEmailId = objcol[i].ToEmailId;
                        objR.MessageId = objcol[i].MessageId;
                        objR.Subject = objcol[i].Subject;
                        objR.Message = objcol[i].Message;
                        if (objcol[i].Attachment != null && objcol[i].Attachment.Length > 0)
                        {
                            ////byte[] filecontent = File.ReadAllBytes(objcol[i].Attachment);
                            //FileInfo fi = new FileInfo(objcol[i].Attachment);
                            ////objR.Attachment = Convert.ToBase64String(filecontent);
                            //string extension = fi.Name.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[1];
                            //objR.AttachmentExtension = extension.Split(',');

                            string[] files = objcol[i].Attachment.Split(',');
                            string[] filextensions = new string[files.Count()];

                            for (int icnt = 0; icnt <= files.GetUpperBound(0); icnt++)
                            {
                                string[] filecomps = files[icnt].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                                if (filecomps.GetUpperBound(0) >= 1)
                                {
                                    filextensions[icnt] = filecomps[1];
                                }
                            }


                            objR.AttachmentExtension = filextensions;
                        }
                        objR.LocationCoordinates = objcol[i].LocationCoordinates;
                        objR.FromType = objcol[i].FromType;
                        objR.ToType = objcol[i].ToType;
                        objR.Status = objcol[i].Status;
                        objR.ProcessDate = objcol[i].ProcessDate;
                        objR.FromName = objcol[i].FromName;
                        objR.userType = objcol[i].userType;
                        objR.physicianId = objcol[i].physicianId;
                        objR.MessageRepliedTo = objcol[i].MessageRepliedTo;
                        objR.IsMessageRead = objcol[i].IsMessageRead;
                        objR.MessageSignatureId = objcol[i].MessageSignatureId;
                        objR.MessageSignatureName = objcol[i].MessageSignatureName;
                        objR.MessageSignatureOffcName = objcol[i].MessageSignatureOffcName;
                        objBox[i] = objR;
                    }
                    return objBox;
                }
                objArray[0] = obj2;
                return objArray;
            }
            else
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "No messages found";
                obj2.MessengerMessage = "No messages found";
                objArray[0] = obj2;
                return objArray;
            }
        }
Exemplo n.º 37
0
        public string ComposeReply(Stream message)
        {
            try
            {
                ComposeMessage objInput = JSonHelper.JsonDeserialize<ComposeMessage>(new StreamReader(message).ReadToEnd());
                if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
                {

                    return "Invalid PIN";
                }
                if (objInput.Pin != null && objInput.Pin.Length > 0)
                {
                    MessageInfo obj = new MessageInfo();
                    MessageBLL objbll = new MessageBLL();
                    string filepath = "";
                    if (objInput.Attachment != null && objInput.Attachment.GetUpperBound(0) >= 0)
                    {
                        for (int ictr = 0; ictr <= objInput.Attachment.GetUpperBound(0); ictr++)
                        {
                            if (filepath.Length <= 0)
                            {
                                filepath = System.Configuration.ConfigurationManager.AppSettings["messageattachmentfolder"].ToString() + "\\" + Guid.NewGuid().ToString() + "." + objInput.Attachmentextension[ictr];

                                File.WriteAllBytes(filepath, Convert.FromBase64String(objInput.Attachment[ictr]));
                            }
                            else
                            {
                                string filepath1 = System.Configuration.ConfigurationManager.AppSettings["messageattachmentfolder"].ToString() + "\\" + Guid.NewGuid().ToString() + "." + objInput.Attachmentextension[ictr];

                                File.WriteAllBytes(filepath1, Convert.FromBase64String(objInput.Attachment[ictr]));

                                filepath = filepath + "," + filepath1;
                            }
                        }
                    }
                    obj.MessageSignatureId = objInput.MessageSignatureId;
                    obj.FromId = objInput.FromId;
                    obj.FromType = objInput.FromType;

                    obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();

                    PhysicianInfo objinfo = new PhysicianInfo();
                    PhysicianBLL objphy = new PhysicianBLL();
                    int PhysicianId = objInput.PhysicianId;
                    objinfo = objphy.GetPhysicianInfoByPatientId(PhysicianId, obj.Pin);
                    if (objinfo.UserType == 24)
                    {
                        obj.ToId = objInput.ToId;//Convert.ToInt32(dd_To.SelectedValue.ToString());
                        obj.ToType = objInput.ToType;
                    }
                    else if (objinfo.UserType == 23)
                    {
                        obj.ToId = objInput.ToId;//Convert.ToInt32(dd_To.SelectedValue.ToString());
                        obj.ToType = 23;
                    }
                    else
                    {
                        obj.ToId = objInput.ToId;//Convert.ToInt32(dd_To.SelectedValue.ToString());
                        obj.ToType = objInput.ToType;
                    }

                    obj.ToEmailId = objInput.ToEmailId;
                    obj.Subject = objInput.Subject;
                    obj.Message = objInput.Message;
                    if (objInput.Status != null && objInput.Status.Length > 0)
                    {
                        obj.Status = objInput.Status;  // R for reply message "O";
                        if (obj.Status == "R")
                        {
                            obj.MessageRepliedTo = objInput.MessageRepliedTo;
                        }
                    }
                    else
                    {
                        obj.Status = "R";
                    }
                    obj.LocationCoordinates = objInput.LocationCoordinates;
                    if (objInput.MessageId != 0)
                        obj.MessageId = objInput.MessageId;
                    else
                        obj.MessageId = 0;
                    if (filepath != null && filepath.Length > 0)
                        obj.Attachment = filepath;
                    int i = objbll.insertmessage(obj);
                    if (i > 0)
                        return "message sent successfully";
                    else
                        return "message not sent";
                }
                else
                {
                    return "Pin is a required field";
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
Exemplo n.º 38
0
        public ToFields[] GetToField(Stream message)
        {

            ToFields objInput = JSonHelper.JsonDeserialize<ToFields>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray1 = new ToFields[1];
                ToFields otoField = new ToFields();
                otoField.ToId = "0";
                otoField.Name = "";
                otoField.UserType = "0";
                otoField.MessengerMessage = "Invalid PIN";
                objArray1[0] = otoField;
                return objArray1;
            }
            if (objInput.Pin != null && objInput.Pin.Length > 0)
            {
                List<MessageInfo> objcol = new List<MessageInfo>();
                MessageInfo obj = new MessageInfo();
                MessageBLL objbll = new MessageBLL();
                obj.ToId = Convert.ToInt32(objInput.ToId);
                obj.userType = Convert.ToInt32(objInput.UserType);
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.GetToFieldAutopopup(obj, objInput.Name);
                var objArray = new ToFields[objcol.Count];
                var autoPopUpdata = new List<string>(objcol.Count);
                if (objcol.Count > 0)
                {

                    for (var i = 0; i < objcol.Count; i++)
                    {
                        //var elementAtOrDefault = objcol.ElementAtOrDefault(i);
                        //if (elementAtOrDefault != null)
                        //    autoPopUpdata.Add(string.Format("{0}-{1}-{2}", elementAtOrDefault.FromName,
                        //                                    elementAtOrDefault.ToId,
                        //                                    elementAtOrDefault.userType));

                        ToFields otoField = new ToFields();
                        MessageInfo msginfo = objcol[i];
                        otoField.ToId = msginfo.ToId.ToString();
                        otoField.Name = msginfo.FromName;
                        otoField.ToEmail = msginfo.ToEmailId;
                        otoField.UserType = msginfo.ToType.ToString();
                        objArray[i] = otoField;
                    }
                }
                return objArray;
            }
            else
            {
                var objArray1 = new ToFields[1];
                ToFields otoField = new ToFields();
                otoField.ToId = "0";
                otoField.Name = "";
                otoField.UserType = "0";
                otoField.MessengerMessage = "Pin is a required field";
                objArray1[0] = otoField;
                return objArray1;
            }
        }