예제 #1
0
        public List <VD_Category> getListCategory()
        {
            List <VD_Category> lst = new List <VD_Category>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GETLIST_CATEGORY");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lst.Add(new VD_Category
                        {
                            CategoryID      = Convert.ToString(row["CategoryID"]),
                            CategoryName    = Convert.ToString(row["CategoryName"]),
                            MetaDescription = Convert.ToString(row["MetaDescription"]),
                            MetaKeywords    = Convert.ToString(row["MetaKeywords"]),
                            MetaTitle       = Convert.ToString(row["MetaTitle"]),
                            IsActive        = Convert.ToBoolean(row["IsActive"]),
                            zIndex          = Convert.ToInt32(row["zIndex"]),
                            IsHomeIndex     = Convert.ToBoolean(row["IsHomeIndex"])
                        });
                    }
                }
            }

            return(lst);
        }
예제 #2
0
        /// <summary>
        /// Takes in the ParsedMessage and makes appropriate calls before responding to user
        /// </summary>
        /// <param name="message">Message containing information</param>
        /// <param name="service">Service to send/recieve messages through</param>
        /// <param name="controller">Database to pull from</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msg = new Message();
            StringBuilder fullMsg = new StringBuilder();

            // Only reply to the user if it is valid.  Else, they can abuse the system
            if (message.Arguments.Count > 0
                // Also make sure they are not trying to bypass us by not going to the verification page
                && !message.Arguments[0].Equals("-1"))
            {
                try
                {
                    UserDAO user = controller.GetUserByVerificationCode(message.Arguments[0]);
                    if (user != null)
                    {
                        // Set their wanted phone email
                        user.PhoneEmail = message.Sender.PhoneEmail;
                        // Update our user
                        controller.UpdateUser(user);
                        // Reset verification to nothing
                        controller.SetVerificationCodeForUser(null, user);
                        fullMsg.Append("You have successfully registered with Text2Share. Thank you!");
                    }
                }
                catch (Exception ex)
                {
                    return;
                }
            }

            msg.FullMessage = fullMsg.ToString();
            msg.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msg);
        }
예제 #3
0
        /// <summary>
        /// Takes in the ParsedMessage and sends a message back to the sender with a message 
        /// listing the enabled plugins for the group
        /// </summary>
        /// <param name="message">Message in error to be handled</param>
        /// <param name="service">Service to send/recieve messages through</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msg = new Message();
            StringBuilder fullMsg = new StringBuilder();
            bool isModerator = message.Group.Moderators.Contains(message.Sender);
            bool isOwner = message.Group.Owner.Equals(message.Sender);

            // Put the group tag for
            fullMsg.Append(message.Group.GroupTag);
            fullMsg.Append(": \n");

            bool first = true;
            foreach (PluginDAO d in message.Group.EnabledPlugins)
            {
                if (d.Access == PluginAccess.STANDARD ||
                    (d.Access == PluginAccess.MODERATOR && (isModerator || isOwner)))
                {
                    if (!d.Name.Equals("error", StringComparison.OrdinalIgnoreCase))
                    {
                        if (!first)
                            fullMsg.Append(", ");
                        // Make it look pretty
                        fullMsg.Append(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(d.Name.ToLower()));
                        first = false;
                    }
                }
            }
            msg.FullMessage = fullMsg.ToString();
            msg.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msg);
        }
예제 #4
0
        /// <summary>
        /// Takes in the ParsedMessage and sends a message back to the sender with a message containing the description for the specified plugin
        /// </summary>
        /// <param name="message">Message containing information</param>
        /// <param name="service">Service to send/recieve messages through</param>
        /// <param name="controller">Database to pull from</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msg = new Message();
            StringBuilder fullMsg = new StringBuilder();
            if (message.Arguments.Count <= 0)
            {
                fullMsg.Append("Please specify which plugin you would like information about.");
            }
            else
            {
                try
                {
                    PluginDAO plugin = controller.RetrievePlugin(message.Arguments[0]);
                    if ((controller.GetAllEnabledGroupPlugins(message.Group.GroupID)).Contains(plugin))
                    {
                        fullMsg.Append(plugin.Name);
                        fullMsg.Append(": ");
                        fullMsg.Append(plugin.Description);
                    }
                    else
                    {
                        fullMsg.Append("This plugin is not enabled for this group.");
                    }
                }
                catch (CouldNotFindException)
                {
                    fullMsg.Append("Can not find plugin ");
                    fullMsg.Append(message.Arguments[0]);
                }
            }

            msg.FullMessage = fullMsg.ToString();
            msg.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msg);
        }
예제 #5
0
        public List <VD_COURSE> getListCourse()
        {
            List <VD_COURSE> lstCourse = new List <VD_COURSE>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GETLIST_COURSE");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lstCourse.Add(new VD_COURSE
                        {
                            ID             = Convert.ToInt64(row["ID"]),
                            Name           = Convert.ToString(row["Name"]),
                            Descriptions   = Convert.ToString(row["Descriptions"]),
                            CourseType     = Convert.ToInt32(row["CourseType"]),
                            CourseTypeName = Convert.ToString(row["CourseTypeName"]),
                            FromDate       = Convert.ToDateTime(row["FromDate"]),
                            ToDate         = Convert.ToDateTime(row["ToDate"]),
                            IsActive       = Convert.ToBoolean(row["IsActive"]),
                            zIndex         = Convert.ToInt32(row["zIndex"])
                        });
                    }
                }
            }

            return(lstCourse);
        }
예제 #6
0
        public VD_About getDetailsAbout(string ID)
        {
            VD_About info = new VD_About();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_ABOUT", ID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.ID               = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    info.Name             = Convert.ToString(ds.Tables[0].Rows[0]["Name"]);
                    info.URL              = Convert.ToString(ds.Tables[0].Rows[0]["URL"]);
                    info.ShortDescription = Convert.ToString(ds.Tables[0].Rows[0]["ShortDescription"]);
                    info.MetaDescription  = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);
                    info.MetaKeywords     = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                    info.MetaTitle        = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitle"]);
                    info.IsActive         = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    info.CreatedDate      = Convert.ToDateTime(ds.Tables[0].Rows[0]["CreatedDate"]);
                }
            }

            return(info);
        }
예제 #7
0
        public VD_SubMenu getDetailsSubMenu(string _mainMenuID, string _subID)
        {
            VD_SubMenu info = new VD_SubMenu();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.getMainMenuDetails("WEB_VD_GET_DETAILS_SUBMENU", _mainMenuID, _subID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.MainMenuID        = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuID"]);
                    info.MainMenuName      = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuName"]);
                    info.SubMenuID         = Convert.ToString(ds.Tables[0].Rows[0]["SubMenuID"]);
                    info.SubMenuName       = Convert.ToString(ds.Tables[0].Rows[0]["SubMenuName"]);
                    info.MetaTitleMainMenu = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitleMainMenu"]);
                    info.MetaDescription   = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);
                    info.MetaKeywords      = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                    info.MetaTitle         = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitle"]);
                    info.IsActive          = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    info.zIndex            = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                }
            }

            return(info);
        }
예제 #8
0
        public VD_COURSE getDetailsCourse(string CourseID)
        {
            VD_COURSE course = new VD_COURSE();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_COURSE", CourseID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    course.ID             = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    course.Name           = Convert.ToString(ds.Tables[0].Rows[0]["Name"]);
                    course.Descriptions   = Convert.ToString(ds.Tables[0].Rows[0]["Descriptions"]);
                    course.CourseType     = Convert.ToInt32(ds.Tables[0].Rows[0]["CourseType"]);
                    course.CourseTypeName = Convert.ToString(ds.Tables[0].Rows[0]["CourseTypeName"]);
                    course.FromDate       = Convert.ToDateTime(ds.Tables[0].Rows[0]["FromDate"]);
                    course.ToDate         = Convert.ToDateTime(ds.Tables[0].Rows[0]["ToDate"]);
                    course.IsActive       = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    course.zIndex         = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                }
            }

            return(course);
        }
예제 #9
0
        public List <VD_About> getListAbout()
        {
            List <VD_About> lst = new List <VD_About>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GET_LIST_ABOUT");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lst.Add(new VD_About
                        {
                            ID               = Convert.ToInt64(row["ID"]),
                            Name             = Convert.ToString(row["Name"]),
                            URL              = Convert.ToString(row["URL"]),
                            ShortDescription = Convert.ToString(row["ShortDescription"]),
                            MetaDescription  = Convert.ToString(row["MetaDescription"]),
                            MetaKeywords     = Convert.ToString(row["MetaKeywords"]),
                            MetaTitle        = Convert.ToString(row["MetaTitle"]),
                            IsActive         = Convert.ToBoolean(row["IsActive"]),
                            CreatedDate      = Convert.ToDateTime(row["CreatedDate"])
                        });
                    }
                }
            }

            return(lst);
        }
예제 #10
0
        public List <VD_AREAS> getListAreas()
        {
            List <VD_AREAS> lstAreas = new List <VD_AREAS>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GETLIST_AREAS");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lstAreas.Add(new VD_AREAS
                        {
                            ID             = Convert.ToInt64(row["ID"]),
                            Name           = Convert.ToString(row["Name"]),
                            Descriptions   = Convert.ToString(row["Descriptions"]),
                            Quantity       = Convert.ToInt32(row["Quantity"]),
                            PersonRegister = _DBAccess.countPersonOnAreas("WEB_VD_COUNT_PERSON_AREAS", Convert.ToInt64(row["ID"])),
                            IsActive       = Convert.ToBoolean(row["IsActive"]),
                            zIndex         = Convert.ToInt32(row["zIndex"])
                        });
                    }
                }
            }

            return(lstAreas);
        }
예제 #11
0
 /// <summary>
 /// Takes in the info from the moderator/owner and removes a user from the group
 /// </summary>
 /// <param name="message">Message to be handled</param>
 /// <param name="service">Service to send/recieve messages through</param>
 public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
 {
     Message msgSender = new Message();
     msgSender.Reciever.Add(message.Sender.PhoneEmail);
     Message msgRemovedUser = new Message();
     try
     {
         UserDAO userToBeRemoved = controller.RetrieveUserByUserName(message.ContentMessage);
         if (userToBeRemoved == null || !message.Group.Users.Contains(userToBeRemoved))
         {
             msgSender.FullMessage = "Failed to remove " + message.Arguments[0] + " from the group "
                 + message.Group.GroupID + ". Please check user/group and try again.";
         }
         else
         {
             msgRemovedUser.Reciever.Add(userToBeRemoved.PhoneEmail);
             controller.RemoveMemberFromGroup(message.Group.GroupID, userToBeRemoved.UserID);
             msgSender.FullMessage = "Successfully removed " + message.ContentMessage + " from the group "
                 + message.Group.Name + ".";
             msgRemovedUser.FullMessage = "You have been removed from group " + message.Group.Name + ".";
             service.SendMessage(msgRemovedUser);
         }
     }
     catch (Exception)
     {
         msgSender.FullMessage = "Failed to remove " + message.ContentMessage + " from the group "
             + message.Group.GroupID + ". Please check user/group and try again.";
     }
     msgSender.Reciever.Add(message.Sender.PhoneEmail);
     service.SendMessage(msgSender);
 }
예제 #12
0
        public List <VD_MainMenu> getListMainMenu()
        {
            List <VD_MainMenu> lst = new List <VD_MainMenu>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GETLIST_MAINMENU");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lst.Add(new VD_MainMenu
                        {
                            MainMenuID      = Convert.ToString(row["MainMenuID"]),
                            MainMenuName    = Convert.ToString(row["MainMenuName"]),
                            MetaDescription = Convert.ToString(row["MetaDescription"]),
                            MetaKeywords    = Convert.ToString(row["MetaKeywords"]),
                            MetaTitle       = Convert.ToString(row["MetaTitle"]),
                            IsActive        = Convert.ToBoolean(row["IsActive"]),
                            zIndex          = Convert.ToInt32(row["zIndex"]),
                            lstSubMenu      = getDetailsMainMenu(row["MainMenuID"].ToString()).lstSubMenu
                        });
                    }
                }
            }

            return(lst);
        }
예제 #13
0
        public ResultResponse insertUpdateHocVien(VD_HOCVIEN _tusinh)
        {
            string _Msg        = string.Empty;
            long   _Result     = 0;
            string _XMLContent = string.Empty;

            _XMLContent  = "<root>";
            _XMLContent += "<HOCVIEN>";
            _XMLContent += "<ID>" + _tusinh.ID + "</ID>";
            _XMLContent += "<FullName>" + _tusinh.FullName + "</FullName>";
            _XMLContent += "<CMND>" + _tusinh.CMND + "</CMND>";
            _XMLContent += "<PhapDanh>" + _tusinh.PhapDanh + "</PhapDanh>";
            _XMLContent += "<Birthday>" + _tusinh.Birthday + "</Birthday>";
            _XMLContent += "<Phone1>" + _tusinh.Phone1 + "</Phone1>";
            _XMLContent += "<Phone2>" + _tusinh.Phone2 + "</Phone2>";
            _XMLContent += "<Address>" + _tusinh.Address + "</Address>";
            _XMLContent += "<zIndex>" + _tusinh.zIndex + "</zIndex>";
            _XMLContent += "<AreasID>" + _tusinh.AreasID + "</AreasID>";
            _XMLContent += "<CourseID>" + _tusinh.CourseID + "</CourseID>";
            _XMLContent += "<UserTypeID>" + _tusinh.UserTypeID + "</UserTypeID>";
            _XMLContent += "<IsApproval>" + _tusinh.IsApproval + "</IsApproval>";
            _XMLContent += "</HOCVIEN>";
            _XMLContent += "</root>";


            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.Insert("WEB_VD_INSERT_HOCVIEN", _XMLContent, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #14
0
        public VD_HOCVIEN getDetailsHocVien(string ID)
        {
            VD_HOCVIEN info = new VD_HOCVIEN();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_HOCVIEN", ID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.ID           = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    info.FullName     = Convert.ToString(ds.Tables[0].Rows[0]["FullName"]);
                    info.CMND         = Convert.ToString(ds.Tables[0].Rows[0]["CMND"]);
                    info.PhapDanh     = Convert.ToString(ds.Tables[0].Rows[0]["PhapDanh"]);
                    info.Birthday     = Convert.ToDateTime(ds.Tables[0].Rows[0]["Birthday"]);
                    info.Phone1       = Convert.ToString(ds.Tables[0].Rows[0]["Phone1"]);
                    info.Phone2       = Convert.ToString(ds.Tables[0].Rows[0]["Phone2"]);
                    info.Address      = Convert.ToString(ds.Tables[0].Rows[0]["Address"]);
                    info.zIndex       = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                    info.AreasID      = Convert.ToInt64(ds.Tables[0].Rows[0]["AreasID"]);
                    info.AreasName    = Convert.ToString(ds.Tables[0].Rows[0]["AreasName"]);
                    info.CourseID     = Convert.ToInt64(ds.Tables[0].Rows[0]["CourseID"]);
                    info.CourseName   = Convert.ToString(ds.Tables[0].Rows[0]["CourseName"]);
                    info.UserTypeID   = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeID"]);
                    info.UserTypeName = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeName"]);
                    info.CreatedDate  = Convert.ToDateTime(ds.Tables[0].Rows[0]["CreatedDate"]);
                    info.IsApproval   = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsApproval"]);
                }
            }

            return(info);
        }
예제 #15
0
        public VD_Category getDetailsCategory(string ID)
        {
            VD_Category info = new VD_Category();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_CATEGORY", ID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.CategoryID      = Convert.ToString(ds.Tables[0].Rows[0]["CategoryID"]);
                    info.CategoryName    = Convert.ToString(ds.Tables[0].Rows[0]["CategoryName"]);
                    info.MetaDescription = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);
                    info.MetaKeywords    = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                    info.MetaTitle       = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitle"]);
                    info.IsActive        = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    info.zIndex          = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                    info.IsHomeIndex     = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsHomeIndex"]);
                }
            }

            return(info);
        }
예제 #16
0
 /// <summary>
 /// Takes in the ParsedMessage and sends a message back to the sender with a specified detailed message about the error
 /// </summary>
 /// <param name="message">Message in error to be handled</param>
 /// <param name="service">Service to send/recieve messages through</param>
 public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
 {
     Message msg = new Message();
     msg.FullMessage = message.ContentMessage;
     msg.Reciever.Add(message.Sender.PhoneEmail);
     service.SendMessage(msg);
 }
예제 #17
0
        public MessageController(AWatcherService Watcher, IDBController Controller)
        {
            this.queue = new BlockingQueue<ParsedMessage>();
            this.watcher = Watcher;
            this.controller = Controller;

            this.watcher.RecievedMessage += Watcher_RecievedMessage;
        }
예제 #18
0
 internal static void setController(PersistanceTypes persistance)
 {
     switch (persistance)
     {
     case PersistanceTypes.Persistance1:
         idbc = new DBC();
         break;
     }
 }
예제 #19
0
 internal static void setController(PersistanceTypes persistance)
 {
     switch (persistance)
     {
         case PersistanceTypes.Persistance1:
             idbc = new DBC();
             break;
     }
 }
예제 #20
0
        public long CountPostInCategory(string CategoryID)
        {
            _DBAccess = new DBController();

            long QtyPost = 0;

            _DBAccess.CountPostInCategory("VD_CHECK_POSTS_IN_CATEGORY", CategoryID, ref QtyPost);

            return(QtyPost);
        }
예제 #21
0
        /// <summary>
        /// Takes in a message content to send to a specified user and replies to sender with confirmation
        /// </summary>
        /// <param name="message">Message to be handled</param>
        /// <param name="service">Service to send/recieve messages through</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msgReceiver = new Message();
            String msgToSend = "";
            for (int i = 1; i < message.Arguments.Count; i++)
            {
                msgToSend += message.Arguments[i];
            }
            msgReceiver.FullMessage = msgToSend;

            Message msgSender = new Message();
            msgSender.Reciever.Add(message.Sender.PhoneEmail);

            UserDAO receiver = null;
            try
            {
                receiver = controller.RetrieveUserByUserName(message.Arguments[0]);
            }
            catch (CouldNotFindException)
            {
                msgSender.FullMessage = "Not a valid user. Please check their username and retry.";
                service.SendMessage(msgSender);
            }

            List<UserDAO> listPeeps = new List<UserDAO>();
            listPeeps.AddRange(message.Group.Users);
            listPeeps.AddRange(message.Group.Moderators);
            listPeeps.Add(message.Group.Owner);

            if (!listPeeps.Contains(receiver) || receiver == null || receiver.IsBanned)
            {
                msgSender.FullMessage = "Not a valid user. Please check their username and retry.";
                service.SendMessage(msgSender);
            }
            else if(receiver.IsSuppressed)
            {
                msgSender.FullMessage = "User has suppressed messages.";
                service.SendMessage(msgSender);
            }
            else
            {
                msgReceiver.Reciever.Add(receiver.PhoneEmail);
                bool sent = service.SendMessage(msgReceiver);
                if (sent)
                {
                    msgSender.FullMessage = "Message sent successfully.";
                }
                else
                {
                    msgSender.FullMessage = "Message was unable to send to user.";
                }
                service.SendMessage(msgSender);
            }
        }
예제 #22
0
        public ResultResponse insertUpdateCourseType(VD_COURSE_TYPE _course)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.insertUpdateCourseType("WEB_VD_INSERT_UPDATE_COURSE_TYPE", _course, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #23
0
        public ResultResponse insertUpdatePost(VD_POST _post)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.InsertPost("WEB_VD_INSERT_POST", _post, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #24
0
        public ResultResponse deleteCategory(string ID)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.Delete("WEB_VD_DELETE_CATEGORY", ID, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #25
0
        public ResultResponse insertUpdateCategory(VD_Category _category)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.insertUpdateCategory("WEB_VD_INSERT_UPDATE_CATEGORY", _category, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #26
0
        public ResultResponse deleteCourseType(string ID)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.Delete("WEB_VD_DELETE_COURSE_TYPE", ID, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #27
0
        public ResultResponse deleteMainMenu(string ID)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.Delete("WEB_VD_DELETE_MAINMENU", ID, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #28
0
        public ResultResponse insertUpdateAreas(VD_AREAS _areas)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.insertUpdateAreas("WEB_VD_INSERT_UPDATE_AREAS", _areas, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #29
0
        public ResultResponse insertUpdateMainMenu(VD_MainMenu _mainMenu)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.insertUpdateMainMenu("WEB_VD_INSERT_UPDATE_MAINMENU", _mainMenu, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #30
0
        public ResultResponse insertUpdateAbout(VD_About _about)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.insertUpdateAbout("WEB_VD_INSERT_UPDATE_ABOUT", _about, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #31
0
        public ResultResponse deleteHocVien(string ID)
        {
            string _Msg    = string.Empty;
            long   _Result = 0;

            _rr       = new ResultResponse();
            _DBAccess = new DBController();
            _DBAccess.Delete("WEB_VD_DELETE_HOCVIEN", ID, ref _Msg, ref _Result);
            _rr.Msg    = _Msg;
            _rr.Result = _Result;

            return(_rr);
        }
예제 #32
0
        public List <VD_POST> getListPostByDate(DateTime fromDate, DateTime toDate, string categoryID)
        {
            List <VD_POST> lst = new List <VD_POST>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetListPostByDate("WEB_VD_GETLIST_POST_BY_CATEGORY_BY_DATE", fromDate, toDate, categoryID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lst.Add(new VD_POST
                        {
                            ID                = Convert.ToInt64(row["ID"]),
                            CategoryID        = Convert.ToString(row["CategoryID"]),
                            CategoryName      = Convert.ToString(row["CategoryName"]),
                            MetaTitleCategory = Convert.ToString(row["MetaTitleCategory"]),
                            MainMenuID        = Convert.ToString(row["MainMenuID"]),
                            MainMenuName      = Convert.ToString(row["MainMenuName"]),
                            MetaTitleMainMenu = Convert.ToString(row["MetaTitleMainMenu"]),
                            SubMenuID         = Convert.ToString(row["SubMenuID"]),
                            SubMenuName       = Convert.ToString(row["SubMenuName"]),
                            MetaTitleSubMenu  = Convert.ToString(row["MetaTitleSubMenu"]),
                            TitlePost         = Convert.ToString(row["TitlePost"]),
                            ContentPost       = Convert.ToString(row["ContentPost"]),
                            CreatedBy         = Convert.ToString(row["CreatedBy"]),
                            CreatedDate       = Convert.ToDateTime(row["CreatedDate"]),
                            ChangeBy          = Convert.ToString(row["ChangeBy"]),
                            ChangeDate        = Convert.ToDateTime(row["ChangeDate"]),
                            IsPublish         = Convert.ToBoolean(row["IsPublish"]),
                            IsSlide           = Convert.ToBoolean(row["IsSlide"]),
                            IsHome            = Convert.ToBoolean(row["IsHome"]),
                            IsActive          = Convert.ToBoolean(row["IsActive"]),
                            Comment           = Convert.ToString(row["Comment"]),
                            ImagesDisplay     = Convert.ToString(row["ImagesDisplay"]),
                            ShortDescription  = Convert.ToString(row["ShortDescription"]),
                            MetaDescription   = Convert.ToString(row["MetaDescription"]),
                            MetaKeywords      = Convert.ToString(row["MetaKeywords"]),
                            MetaTitle         = Convert.ToString(row["MetaTitle"]),
                            AdminComment      = Convert.ToString(row["AdminComment"])
                        });
                    }
                }
            }

            return(lst);
        }
예제 #33
0
        public VD_MainMenu getDetailsMainMenu(string ID)
        {
            VD_MainMenu       info   = new VD_MainMenu();
            List <VD_SubMenu> lstSub = new List <VD_SubMenu>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_MAINMENU", ID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.MainMenuID      = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuID"]);
                    info.MainMenuName    = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuName"]);
                    info.MetaDescription = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);
                    info.MetaKeywords    = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                    info.MetaTitle       = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitle"]);
                    info.IsActive        = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    info.zIndex          = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                }
                if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        lstSub.Add(new VD_SubMenu
                        {
                            ID                = Convert.ToInt64(row["ID"]),
                            MainMenuID        = Convert.ToString(row["MainMenuID"]),
                            MainMenuName      = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuName"]),
                            SubMenuID         = Convert.ToString(row["SubMenuID"]),
                            SubMenuName       = Convert.ToString(row["SubMenuName"]),
                            MetaTitleMainMenu = Convert.ToString(row["MetaTitleMainMenu"]),
                            MetaDescription   = Convert.ToString(row["MetaDescription"]),
                            MetaKeywords      = Convert.ToString(row["MetaKeywords"]),
                            MetaTitle         = Convert.ToString(row["MetaTitle"]),
                            IsActive          = Convert.ToBoolean(row["IsActive"]),
                            zIndex            = Convert.ToInt32(row["zIndex"])
                        });
                    }
                }
            }

            info.lstSubMenu = lstSub;

            return(info);
        }
예제 #34
0
        /// <summary>
        /// Takes in the info from the moderator/owner and removes a user from the group
        /// </summary>
        /// <param name="message">Message in error to be handled</param>
        /// <param name="service">Service to send/recieve messages through</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msgSender = new Message();

            if (message.Arguments.Count > 0 && message.Arguments[0].Substring(0, 3).ToUpper().Equals("OFF"))
            {
                controller.UnsuppressUser(message.Sender);
                msgSender.FullMessage = "You have been unsuppressed and can now receive messages. To suppress yourself, please reply SUPPRESS to disable messages.";
            }
            else
            {
                controller.SuppressUser(message.Sender);
                msgSender.FullMessage = "You have been suppressed. If you would like to unsuppress yourself, please reply SUPPRESS OFF to remove.";
            }
            msgSender.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msgSender);
        }
예제 #35
0
        /// <summary>
        /// Takes in the info from the moderator/owner and removes a user from the group
        /// </summary>
        /// <param name="message">Message to be handled</param>
        /// <param name="service">Service to send/recieve messages through</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msgSender = new Message();

            if (message.Arguments.Count > 0 && message.Arguments[0].Substring(0, 3).ToUpper().Equals("YES"))
            {
                controller.DeleteUser(message.Sender);
                msgSender.FullMessage = "You have been removed from our system. Thank you for using our services.";
            }
            else
            {
                controller.SuppressUser(message.Sender);
                msgSender.FullMessage = "To remove yourself from Text2Share, please respond with STOP YES. Please keep in mind that this also deletes any groups you own and any plugins you have developed.";
            }
            msgSender.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msgSender);
        }
예제 #36
0
        public VD_POST getPostIndexByCategory(string CateID)
        {
            VD_POST info = new VD_POST();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_POST_INDEX_BY_CATEGORY", CateID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.ID                = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    info.CategoryID        = Convert.ToString(ds.Tables[0].Rows[0]["CategoryID"]);
                    info.CategoryName      = Convert.ToString(ds.Tables[0].Rows[0]["CategoryName"]);
                    info.MetaTitleCategory = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitleCategory"]);
                    info.MainMenuID        = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuID"]);
                    info.MainMenuName      = Convert.ToString(ds.Tables[0].Rows[0]["MainMenuName"]);
                    info.MetaTitleMainMenu = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitleMainMenu"]);
                    info.SubMenuID         = Convert.ToString(ds.Tables[0].Rows[0]["SubMenuID"]);
                    info.SubMenuName       = Convert.ToString(ds.Tables[0].Rows[0]["SubMenuName"]);
                    info.MetaTitleSubMenu  = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitleSubMenu"]);
                    info.TitlePost         = Convert.ToString(ds.Tables[0].Rows[0]["TitlePost"]);
                    info.ContentPost       = Convert.ToString(ds.Tables[0].Rows[0]["ContentPost"]);
                    info.CreatedBy         = Convert.ToString(ds.Tables[0].Rows[0]["CreatedBy"]);
                    info.CreatedDate       = Convert.ToDateTime(ds.Tables[0].Rows[0]["CreatedDate"]);
                    info.ChangeBy          = Convert.ToString(ds.Tables[0].Rows[0]["ChangeBy"]);
                    info.ChangeDate        = Convert.ToDateTime(ds.Tables[0].Rows[0]["ChangeDate"]);
                    info.IsPublish         = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsPublish"]);
                    info.IsSlide           = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsSlide"]);
                    info.IsHome            = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsHome"]);
                    info.IsActive          = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    info.Comment           = Convert.ToString(ds.Tables[0].Rows[0]["Comment"]);
                    info.ImagesDisplay     = Convert.ToString(ds.Tables[0].Rows[0]["ImagesDisplay"]);
                    info.ShortDescription  = Convert.ToString(ds.Tables[0].Rows[0]["ShortDescription"]);
                    info.MetaDescription   = Convert.ToString(ds.Tables[0].Rows[0]["MetaDescription"]);
                    info.MetaKeywords      = Convert.ToString(ds.Tables[0].Rows[0]["MetaKeywords"]);
                    info.MetaTitle         = Convert.ToString(ds.Tables[0].Rows[0]["MetaTitle"]);
                    info.AdminComment      = Convert.ToString(ds.Tables[0].Rows[0]["AdminComment"]);
                }
            }

            return(info);
        }
예제 #37
0
        public List <VD_HOCVIEN> getListHocVien()
        {
            List <VD_HOCVIEN> lst = new List <VD_HOCVIEN>();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityList("WEB_VD_GETLIST_HOCVIEN");
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        lst.Add(new VD_HOCVIEN
                        {
                            ID           = Convert.ToInt64(row["ID"]),
                            FullName     = Convert.ToString(row["FullName"]),
                            CMND         = Convert.ToString(row["CMND"]),
                            PhapDanh     = Convert.ToString(row["PhapDanh"]),
                            Birthday     = Convert.ToDateTime(row["Birthday"]),
                            Phone1       = Convert.ToString(row["Phone1"]),
                            Phone2       = Convert.ToString(row["Phone2"]),
                            Address      = Convert.ToString(row["Address"]),
                            zIndex       = Convert.ToInt32(row["zIndex"]),
                            AreasID      = Convert.ToInt64(row["AreasID"]),
                            AreasName    = Convert.ToString(row["AreasName"]),
                            CourseID     = Convert.ToInt64(row["CourseID"]),
                            CourseName   = Convert.ToString(row["CourseName"]),
                            UserTypeID   = Convert.ToString(row["UserTypeID"]),
                            UserTypeName = Convert.ToString(row["UserTypeName"]),
                            CreatedDate  = Convert.ToDateTime(row["CreatedDate"]),
                            IsApproval   = Convert.ToBoolean(row["IsApproval"])
                        });
                    }
                }
            }

            return(lst);
        }
예제 #38
0
        public VD_USERS Login(string UserName, string Password)
        {
            VD_USERS info = new VD_USERS();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.Login("WEB_VD_LOGIN", UserName, Password);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    info.ID           = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    info.UserName     = Convert.ToString(ds.Tables[0].Rows[0]["UserName"]);
                    info.Password     = Convert.ToString(ds.Tables[0].Rows[0]["Password"]);
                    info.UserTypeID   = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeID"]);
                    info.UserTypeName = Convert.ToString(ds.Tables[0].Rows[0]["UserTypeName"]);
                }
            }

            return(info);
        }
예제 #39
0
        /// <summary>
        /// Takes in a message content to send to all users in group (excluding sender) and replies to sender with confirmation
        /// </summary>
        /// <param name="message">Message to be handled</param>
        /// <param name="service">Service to send/recieve messages through</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msg = new Message();
            msg.FullMessage = message.Group.GroupTag + ": " + message.ContentMessage;
            Message msgSender = new Message();
            msgSender.Reciever.Add(message.Sender.PhoneEmail);
            List<UserDAO> listPeeps = new List<UserDAO>();

            listPeeps.Add(message.Group.Owner);
            listPeeps.AddRange(message.Group.Users);
            listPeeps.AddRange(message.Group.Moderators);

            foreach(UserDAO u in listPeeps)
            {
                if(!u.Equals(message.Sender)&&!u.IsBanned&&!u.IsSuppressed)
                {
                    msg.Reciever.Add(u.PhoneEmail);
                }
            }
            msgSender.FullMessage = "Message sent successfully.";
            service.SendMessage(msgSender);
            service.SendMessage(msg);
        }
예제 #40
0
        public VD_AREAS getDetailsAreas(string AreasID)
        {
            VD_AREAS areas = new VD_AREAS();

            _DBAccess = new DBController();
            DataSet ds = new DataSet();

            ds = _DBAccess.GetEntityDetails("WEB_VD_GET_DETAILS_AREAS", AreasID);
            if (ds != null && ds.Tables.Count > 0)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    areas.ID             = Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]);
                    areas.Name           = Convert.ToString(ds.Tables[0].Rows[0]["Name"]);
                    areas.Descriptions   = Convert.ToString(ds.Tables[0].Rows[0]["Descriptions"]);
                    areas.Quantity       = Convert.ToInt32(ds.Tables[0].Rows[0]["Quantity"]);
                    areas.PersonRegister = _DBAccess.countPersonOnAreas("WEB_VD_COUNT_PERSON_AREAS", Convert.ToInt64(ds.Tables[0].Rows[0]["ID"]));
                    areas.IsActive       = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsActive"]);
                    areas.zIndex         = Convert.ToInt32(ds.Tables[0].Rows[0]["zIndex"]);
                }
            }

            return(areas);
        }
예제 #41
0
 private static void TryFindSender(ParsedMessage parsed, Message message, IDBController controller)
 {
     try
     {
         parsed.Sender = controller.RetrieveUserByPhoneEmail(message.Sender);
     }
     catch (Exception ex)
     {
         if (ex is ArgumentNullException ||
             ex is CouldNotFindException)
         {
             parsed.Sender = null;
         }
         else
         {
             // Not an exception we deal with, throw so we don't hide bugs
             throw;
         }
     }
 }
예제 #42
0
        private static String FindCommand(String message, IDBController controller)
        {
            // Try and find our plugin at the start
            List<PluginDAO> plugins = controller.RetrieveEnabledPlugins();
            foreach (PluginDAO plugin in plugins)
            {
                if (message.StartsWith(plugin.Name, StringComparison.OrdinalIgnoreCase))
                {
                    return plugin.Name;
                }
            }

            // Get our best guess by seeing if there is the first delimeter
            int delimiter1Index = message.IndexOf(MessageParser.delimiter);
            if (delimiter1Index < 0)
            {
                // No group specified, so take up until second delimeter
                int delimiter2Index = message.IndexOf(MessageParser.secondDelimiter);
                if (delimiter2Index < 0)
                {
                    // No group stuff so just return the whole message
                    return message;
                }
                else
                {
                    return message.Substring(0, delimiter2Index).Trim();
                }
            }
            else
            {
                // Do we have spaces? (Plugins shouldn't have spaces)
                string pluginMaybe = message.Substring(0, delimiter1Index).Trim();

                if (pluginMaybe.Contains(' '))
                {
                    return "";
                }
                else
                {
                    // We found an plugin! (Hopefully)
                    return pluginMaybe.Trim();
                }
            }
        }
 public MessageControllerOverride(AWatcherService Watcher, IDBController Controller)
     : base(Watcher, Controller)
 {
 }
예제 #44
0
 private static String FindGroup(String message, IDBController controller)
 {
     Tuple<int, int> indexes = MessageParser.FindGroupRange(message, controller);
     if (indexes == null)
     {
         return "";
     }
     else
     {
         if (indexes.Item2 <= indexes.Item1)
         {
             return "";
         }
         message = message.Substring(indexes.Item1, indexes.Item2 - indexes.Item1 + 1).Trim();
         return message;
     }
 }
예제 #45
0
 /// <summary>
 /// Constructs a list of plug-ins and initializes the library
 /// </summary>
 public PluginLibrary(MessageController messageController, AWatcherService Service, IDBController idbController)
 {
     this.messageController = messageController;
     this.service = Service;
     this.idbController = idbController;
 }
예제 #46
0
        private static Tuple<int, int> FindGroupRange(String message, IDBController controller)
        {
            // Look for our first delimiter
            int firstDelimiterIndex = message.IndexOf(MessageParser.delimiter);
            if (firstDelimiterIndex < 0)
            {
                return null;
            }
            firstDelimiterIndex++;
            // Return if the delimiter is the last character
            if (firstDelimiterIndex >= message.Length)
            {
                return null;
            }
            else
            {
                message = message.Substring(firstDelimiterIndex);
                int secondDelimiterIndex = message.IndexOf(MessageParser.secondDelimiter);
                if (secondDelimiterIndex < 0)
                {
                    return new Tuple<int, int>(firstDelimiterIndex, firstDelimiterIndex + message.Length - 1);
                }

                // Grab that section
                return new Tuple<int, int>(firstDelimiterIndex, firstDelimiterIndex + secondDelimiterIndex);
            }
        }
 public BootstrapController(IDBController db)
 {
     this.db = db;
 }
예제 #48
0
 private static void TryFindGroup(ParsedMessage parsed, String groupId, IDBController controller)
 {
     try
     {
         parsed.Group = controller.RetrieveGroup(groupId);
     }
     catch (Exception ex)
     {
         if (ex is ArgumentNullException ||
             ex is CouldNotFindException)
         {
             parsed.Group = null;
         }
         else
         {
             // Not an exception we deal with, throw so we don't hide bugs
             throw;
         }
     }
 }
예제 #49
0
        /// <summary>
        /// takes a Message and create a ParsedMessage from it and adds it to the queue
        /// </summary>
        /// <param name="message"></param>
        public static ParsedMessage Parse(Message message, IDBController controller)
        {
            // Fix up the string a little
            message.FullMessage = message.FullMessage.Trim();

            ParsedMessage parsed = new ParsedMessage();
            TryFindSender(parsed, message, controller);

            parsed.Command = FindCommand(message.FullMessage, controller);
            parsed.ContentMessage = FindArguments(message.FullMessage, controller);
            if (!parsed.ContentMessage.Trim().Equals(String.Empty))
            {
                parsed.Arguments.AddRange(parsed.ContentMessage.Split(' '));
            }

            String groupId = FindGroup(message.FullMessage, controller);

            //Strip out any leading, trailing delimiters
            groupId = groupId.TrimStart(new char[] { MessageParser.delimiter });
            groupId = groupId.TrimEnd(new char[] { MessageParser.secondDelimiter });

            TryFindGroup(parsed, groupId, controller);

            // Set our type flag (by importance)
            if (parsed.Command.Equals("stop", StringComparison.OrdinalIgnoreCase)) {
                parsed.Type = ParsedMessage.ContentMessageType.STOP;
            }
            else if (parsed.Sender != null &&
                parsed.Sender.IsBanned)
            {
                parsed.Type = ParsedMessage.ContentMessageType.BAN;
            }
            else if (parsed.Command.Equals("register", StringComparison.OrdinalIgnoreCase))
            {
                // Since they are not in the database,
                // we need to make a temp UserDAO as the sender
                // and populate their phone email for the Register plugin
                parsed.Sender = new UserDAO();
                parsed.Sender.PhoneEmail = message.Sender;
                parsed.Type = ParsedMessage.ContentMessageType.REGISTER;
            }
            else if (parsed.Sender != null &&
                parsed.Sender.IsSuppressed)
            {
                parsed.Type = ParsedMessage.ContentMessageType.SUPPRESS;
            }
            else if (parsed.Sender == null)
            {
                parsed.Type = ParsedMessage.ContentMessageType.NO_SENDER;
            }
            else if (parsed.Command.Equals(String.Empty))
            {
                parsed.Type = ParsedMessage.ContentMessageType.NO_COMMAND;
            }
            else if (parsed.Group == null)
            {
                parsed.Type = ParsedMessage.ContentMessageType.NO_GROUP;
            }
            else
            {
                parsed.Type = ParsedMessage.ContentMessageType.VALID;
            }

            return parsed;
        }
예제 #50
0
 private static String FindArguments(String message, IDBController controller)
 {
     // Find the arguments right after the group ID
     Tuple<int, int> indexes = MessageParser.FindGroupRange(message, controller);
     if (indexes == null)
     {
         // Try and find the second delimeter
         int secondIndex = message.IndexOf(MessageParser.secondDelimiter);
         if (secondIndex < 0)
         {
             return "";
         }
         else
         {
             if (secondIndex + 1 < message.Length)
             {
                 return message.Substring(secondIndex + 1, message.Length - (secondIndex + 1));
             }
             else
             {
                 return "";
             }
         }
     }
     else
     {
         // Don't include last character
         int argStartIndex = indexes.Item2 + 1;
         if (argStartIndex >= message.Length)
         {
             return "";
         }
         else
         {
             message = message.Substring(argStartIndex).Trim();
             return message;
         }
     }
 }