Beispiel #1
0
        public CallContext NotificationSave(Notification entity, CallContext resultContext)
        {
            resultContext.securitySettings = ETEMEnums.SecuritySettings.NotificationSave;
            CallContext resContext = new NotificationBL().EntitySave<Notification>(entity, resultContext);

            return resContext;
        }
Beispiel #2
0
        /// <summary>
        /// Метода изпраща съобщение 
        /// </summary>
        /// <param name="idSendFromPerson">Изпратено от</param>
        /// <param name="idSendToPerson">Изпратено до</param>
        /// <param name="idStatus">set- ва се на статус "Изпратено" ( this.AdminClientRef.GetKeyValueIdByIntCode("NotificationStatus", "Submitted") )</param>
        /// <param name="about">Относно</param>
        /// <param name="comment">Коментар</param>
        /// <returns>Връща ID на новото съобщение</returns>
        public int SendNotification(int idSendFromPerson, int idSendToPerson, int idStatus, string about, string comment)
        {
            int result = Constants.INVALID_ID;

            Notification saveEntity = new Notification();

            saveEntity.About = about;
            saveEntity.Comment = comment;
            saveEntity.idSendFrom = idSendFromPerson;
            saveEntity.idSendTo = idSendToPerson;
            saveEntity.idStatus = idStatus;
            saveEntity.LastUpdate = DateTime.Now;
            saveEntity.SendDate = DateTime.Now;

            CallContext resultContext = new CallContext();
            resultContext = NotificationSave(saveEntity, resultContext);

            return result;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //получател
            if (this.ucSendToPerson.SelectedValue == Constants.INVALID_ID_STRING && this.ddlGroup.SelectedValue == Constants.INVALID_ID_STRING && this.gvSendNoticeTo.Rows.Count == 0)
            {
                AddErrorMessage(this.lbResultContext, BaseHelper.GetCaptionString("Notification_SendTo_Mandatory"));
                return;
            }


            if (string.IsNullOrEmpty(this.hdnRowMasterKey.Value) || this.hdnRowMasterKey.Value == Constants.INVALID_ID_STRING)
            {
                this.currentEntity = new Notification();
            }
            else
            {
                this.currentEntity = this.ownerPage.CommonClientRef.GetNotificationByID(this.hdnRowMasterKey.Value);

                if (this.currentEntity == null)
                {
                    this.lbResultContext.Text = String.Format(BaseHelper.GetCaptionString("Entity_Notification_Not_Found_By_ID"), this.hdnRowMasterKey.Value);
                    string falseResult = String.Format(BaseHelper.GetCaptionString("Entity_is_not_update"));

                    this.ownerPage.FormLoad();
                    return;
                }
            }

            DateTimeFormatInfo dtf = new DateTimeFormatInfo();
            dtf.DateSeparator = Constants.DATE_SEPARATOR;
            dtf.ShortDatePattern = Constants.SHORT_DATE_TIME_PATTERN;

            //11.4.2011 г. 16:27:43
            DateTime dtSendDate;
            if (!DateTime.TryParse(this.tbxSendDate.Text, dtf, DateTimeStyles.None, out dtSendDate))
            {
                dtSendDate = DateTime.Now.Date;
            }


            currentEntity.idSendFrom = Convert.ToInt32(this.ownerPage.UserProps.PersonID);
            currentEntity.About = this.tbxAbout.Text;
            currentEntity.Comment = this.tbxComment.Text;
            currentEntity.idStatus = Convert.ToInt32(this.ddlStatus.SelectedValue);
            currentEntity.SendDate = dtSendDate;
            currentEntity.LastUpdate = DateTime.Now;
            currentEntity.isReading = false;

            CallContext resultContext = new CallContext();
            resultContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;

            if (!string.IsNullOrEmpty(this.ucSendToPerson.SelectedValue) && this.ucSendToPerson.SelectedValue != Constants.INVALID_ID_STRING)
            {
                currentEntity.idSendTo = Convert.ToInt32(this.ucSendToPerson.SelectedValue);
                resultContext = this.ownerPage.CommonClientRef.NotificationSave(currentEntity, resultContext);
            }


            if (this.gvSendNoticeTo.Rows.Count > 0)
            {
                HiddenField hdnRowDetailKey;

                int maxIDNotification = this.ownerPage.CommonClientRef.GetMaxNotificationID();

                foreach (GridViewRow row in this.gvSendNoticeTo.Rows)
                {
                    hdnRowDetailKey = row.FindControl("hdnRowDetailKey") as HiddenField;
                    this.currentEntity = new Notification();

                    currentEntity.idSendFrom = Convert.ToInt32(this.ownerPage.UserProps.PersonID);
                    currentEntity.About = this.tbxAbout.Text;
                    currentEntity.Comment = this.tbxComment.Text;
                    currentEntity.idStatus = Convert.ToInt32(this.ddlStatus.SelectedValue);
                    currentEntity.SendDate = dtSendDate;
                    currentEntity.LastUpdate = DateTime.Now;
                    currentEntity.isReading = false;
                    currentEntity.idSendTo = Convert.ToInt32(hdnRowDetailKey.Value);
                    currentEntity.LinkFile = maxIDNotification.ToString();

                    resultContext = new CallContext();
                    resultContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;
                    resultContext = this.ownerPage.CommonClientRef.NotificationSave(currentEntity, resultContext);
                }
            }
            //съобщението се изпраща от студент
            else if (this.ddlGroup.SelectedValue != Constants.INVALID_ID_STRING && string.IsNullOrEmpty(this.hdnRowMasterKey.Value) &&
                 !this.ownerPage.CheckUserActionPermissionByIntCode(ETEMEnums.SecuritySettings.UsingFullFunctionalityNotif))
            {
                int maxIDNotification = this.ownerPage.CommonClientRef.GetMaxNotificationID();
                Group group = this.AdminClientRef.GetGroupByID(this.ddlGroup.SelectedValueINT);
                List<GroupPersonLinkDataView> groupPersonLink = this.AdminClientRef.GetGroupPersonLinkDataViewByGroupID(group.idGroup);

                //записваме 1 главно съобщение, което ще се показв като изходящо съобщение ако е изпратено до група, 
                //а не да се виждат всички изходящи съобщения до всеки член на групата
                this.currentEntity = new Notification();
                currentEntity.idSendFrom = Convert.ToInt32(this.ownerPage.UserProps.PersonID);
                //currentEntity.idSendTo          = Convert.ToInt32(this.ownerPage.UserProps.PersonID);
                currentEntity.About = this.tbxAbout.Text;
                currentEntity.Comment = this.tbxComment.Text;
                currentEntity.idStatus = Convert.ToInt32(this.ddlStatus.SelectedValue);
                currentEntity.SendDate = dtSendDate;
                currentEntity.LastUpdate = DateTime.Now;
                currentEntity.isReading = false;
                //изпратено до - записваме id на групата до която е изпратено съобщението
                currentEntity.idGroup = this.ddlGroup.SelectedValueINT;
                currentEntity.ParentID = Constants.INVALID_ID;
                currentEntity.LinkFile = maxIDNotification.ToString();

                resultContext = new CallContext();
                resultContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;
                string parentID = this.ownerPage.CommonClientRef.NotificationSave(currentEntity, resultContext).EntityID;

                foreach (var item in groupPersonLink)
                {
                    this.currentEntity = new Notification();
                    currentEntity.idSendFrom = Convert.ToInt32(this.ownerPage.UserProps.PersonID);
                    currentEntity.About = this.tbxAbout.Text;
                    currentEntity.Comment = this.tbxComment.Text;
                    currentEntity.idStatus = Convert.ToInt32(this.ddlStatus.SelectedValue);
                    currentEntity.SendDate = dtSendDate;
                    currentEntity.LastUpdate = DateTime.Now;
                    currentEntity.isReading = false;
                    currentEntity.idSendTo = item.idPerson;
                    currentEntity.ParentID = Convert.ToInt32(parentID);
                    currentEntity.LinkFile = maxIDNotification.ToString();

                    resultContext = new CallContext();
                    resultContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;
                    resultContext = this.ownerPage.CommonClientRef.NotificationSave(currentEntity, resultContext);
                }
            }


            if (this.ownerPage.CallContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {
                this.CurrentEntityMasterID = resultContext.EntityID;

                UserControlLoad();

                this.lbResultContext.Text = BaseHelper.GetCaptionString("Message_Sent_Successfully");
            }
            else
            {
                this.lbResultContext.Text = BaseHelper.GetCaptionString("Message_Sent_NOTSuccessfully");
            }


            CheckIfResultIsSuccess(this.lbResultContext);

            //this.ownerPage.FormLoad();

            //this.pnlFormData.Visible = false;
        }
        public override void UserControlLoad()
        {
            if (this.ownerPage == null)
            {
                throw new UMSException("Current Page is null or is not inheritor of BasicPage.");
            }

            loadInitControls();

            this.currentEntity = this.ownerPage.CommonClientRef.GetNotificationByID(this.CurrentEntityMasterID);

            if (currentEntity != null)
            {
                this.lbHeaderText.Text = "Преглед на съобщение";

                //съществуващо съобщение не може да се редактира
                this.btnSave.Enabled = false;
                this.btnAddNoticeTo.Enabled = false;
                this.btnDeleteNoticeTo.Enabled = false;
                this.fuNotificationFile.BtnUploadFileEnabled = true;

                this.ucSendFromPerson.SelectedValue = this.currentEntity.idSendFrom.ToString();
                this.ucSendFromPerson.Text = this.AdminClientRef.GetPersonByPersonID(this.currentEntity.idSendFrom.ToString()).FullName;

                if (this.currentEntity.ParentID == null)
                {
                    this.ucSendToPerson.SelectedValue = this.currentEntity.idSendTo.ToString();
                    this.ucSendToPerson.Text = this.AdminClientRef.GetPersonByPersonID(this.currentEntity.idSendTo.ToString()).FullName;
                }
                else if (this.currentEntity.ParentID == Constants.INVALID_ID)
                {
                    this.ddlGroup.SelectedValue = this.currentEntity.idGroup.ToString();
                    this.ucSendToPerson.SelectedValue = Constants.INVALID_ID_STRING;
                    this.ucSendToPerson.Text = string.Empty;
                }

                this.tbxSendDate.Text = this.currentEntity.SendDate.Value.ToString(Constants.SHORT_DATE_PATTERN);
                this.tbxAbout.Text = this.currentEntity.About;
                this.tbxComment.Text = this.currentEntity.Comment;
                this.ddlStatus.SelectedValue = this.currentEntity.idStatus.ToString();
                this.hdnRowMasterKey.Value = currentEntity.EntityID.ToString();

                //update статуса на съобщението и дата на последна промяна
                this.currentEntity.idStatus = Convert.ToInt32(this.ddlStatus.SelectedValue);
                this.currentEntity.LastUpdate = DateTime.Now;
                //маркираме съобщението като прочетено ако го отвори този, до когото е адресирано съобщението
                if (this.ownerPage.UserProps.PersonID == this.currentEntity.idSendTo.ToString())
                {
                    this.currentEntity.isReading = true;
                    this.fuNotificationFile.BtnUploadFileEnabled = false;
                }
                else
                {
                    this.fuNotificationFile.BtnUploadFileEnabled = true;
                }

                //Прикачени файлове
                //сетваме стойност на полето LinkFile когато изпращаме съобщение до група от хора
                if (currentEntity.LinkFile == null)
                {
                    this.fuNotificationFile.CustomFolder = this.CurrentEntityMasterID + "_" +
                                                           this.currentEntity.SendDate.Value.ToString(Constants.DATE_SHORT_PATTERN_FOR_FILE_SUFFIX) +
                                                           "_Notification";
                }
                else
                {
                    this.fuNotificationFile.CustomFolder = this.currentEntity.LinkFile + "_" +
                                                           this.currentEntity.SendDate.Value.ToString(Constants.DATE_SHORT_PATTERN_FOR_FILE_SUFFIX) +
                                                           "_Notification";
                }

                this.fuNotificationFile.UserControlLoad();

                CallContext resultContext = new CallContext();
                resultContext.CurrentConsumerID = this.ownerPage.UserProps.IdUser;
                resultContext = this.CommonClientRef.NotificationSave(currentEntity, resultContext);

                

                this.lnkBtnPreviewDocument.Visible = true;

                

                this.lbResultContext.Attributes.Remove("class");

                this.ownerPage.FormLoad();
            }
            else
            {
                this.lbHeaderText.Text = "Изпращане на съобщение";

                SetEmptyValues();
            }
        }
 /// <summary>
 /// Create a new Notification object.
 /// </summary>
 /// <param name="idNotification">Initial value of the idNotification property.</param>
 public static Notification CreateNotification(global::System.Int32 idNotification)
 {
     Notification notification = new Notification();
     notification.idNotification = idNotification;
     return notification;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Notifications EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToNotifications(Notification notification)
 {
     base.AddObject("Notifications", notification);
 }