Beispiel #1
0
        private void remove_calender_user(Guid calenderId, Guid userId, ref string responseText)
        {
            if (!paramsContainer.GBEdit)
            {
                return;
            }

            bool calenderDeleted = false;
            bool result          = EventsController.remove_related_user(paramsContainer.Tenant.Id,
                                                                        calenderId, userId, ref calenderDeleted);

            responseText = result ? "{\"Succeed\":\"" + Messages.OperationCompletedSuccessfully + "\"}" :
                           "{\"ErrorText\":\"" + Messages.OperationFailed + "\"}";

            if (!result)
            {
                return;
            }

            List <Guid> relatedUserIds = EventsController.get_related_user_ids(paramsContainer.Tenant.Id, calenderId);
            Event       _event         = EventsController.get_event(paramsContainer.Tenant.Id, calenderId, true);

            if (userId == _event.CreatorUserID)
            {
                relatedUserIds.Remove(userId);

                DateTime NowDT = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                if (_event.BeginDate.Value > NowDT)
                {
                    string strType    = _event.EventType;
                    string strMessage = strType + " " + "\" " + _event.Title + " \"" + " در تاریخ " + "\" " +
                                        PublicMethods.get_local_date(_event.BeginDate.Value) + " \"" + " لغو گردید";
                    string strTitle = "لغو " + strType;
                    MSGController.bulk_send_message(paramsContainer.Tenant.Id,
                                                    userId, relatedUserIds, strTitle, strMessage);
                }
            }
            else
            {
                if (!relatedUserIds.Any(u => u == _event.CreatorUserID.Value))
                {
                    relatedUserIds.Add(_event.CreatorUserID.Value);
                }

                string strMessage = "حذف رویداد از نوع " + _event.EventType + " و با عنوان: " + _event.Title;
                MSGController.bulk_send_message(paramsContainer.Tenant.Id,
                                                userId, relatedUserIds, string.Empty, strMessage);
            }

            //Save Log
            if (result)
            {
                LogController.save_log(paramsContainer.Tenant.Id, new Log()
                {
                    UserID           = paramsContainer.CurrentUserID,
                    Date             = DateTime.Now,
                    HostAddress      = PublicMethods.get_client_ip(HttpContext.Current),
                    HostName         = PublicMethods.get_client_host_name(HttpContext.Current),
                    Action           = Modules.Log.Action.RemoveEventUser,
                    SubjectID        = calenderId,
                    SecondSubjectID  = userId,
                    ModuleIdentifier = ModuleIdentifier.EVT
                });
            }
            //end of Save Log
        }
Beispiel #2
0
        public void SendMessage(ref Event Calendar, ref List <Guid> relatedUserIds, string type, bool isRegisterMode, ref string message)
        {
            try
            {
                if (relatedUserIds != null && relatedUserIds.Count > 1)
                {
                    string strRenderedKnowledgeDomains = "";

                    List <Modules.CoreNetwork.Node> CalenNodesKnowledgeDomains =
                        EventsController.get_related_nodes(paramsContainer.Tenant.Id, Calendar.EventID.Value);

                    if (CalenNodesKnowledgeDomains != null && CalenNodesKnowledgeDomains.Count() != 0)
                    {
                        int Counter = 0;
                        foreach (Modules.CoreNetwork.Node CalenNode in CalenNodesKnowledgeDomains)
                        {
                            Counter++;
                            if (Counter != 1)
                            {
                                strRenderedKnowledgeDomains += " ، ";
                            }

                            System.Web.UI.HtmlControls.HtmlAnchor a = new System.Web.UI.HtmlControls.HtmlAnchor();
                            a.InnerText = CalenNode.Name;
                            a.Target    = "_blank";
                            a.HRef      = PublicConsts.get_client_url(PublicConsts.NodePage) + "/" + CalenNode.NodeID.ToString();

                            StringBuilder  SB = new StringBuilder();
                            HtmlTextWriter TW = new HtmlTextWriter(new StringWriter(SB));
                            a.RenderControl(TW);

                            strRenderedKnowledgeDomains += SB.ToString();
                        }
                    }

                    relatedUserIds.Remove(paramsContainer.CurrentUserID.Value);

                    string strTitle = "";
                    string PostFix  = "";
                    if (isRegisterMode)
                    {
                        strTitle = "ثبت " + type;
                        PostFix  = " ثبت شد";
                    }
                    else
                    {
                        strTitle = "ویرایش " + type;
                        PostFix  = " ویرایش شد ، به تغییرات اعمال شده دقت فرمایید";
                    }

                    string strMessage = "رویدادی از نوع " + "\" " + type + " \" با عنوان " + "\" " + Calendar.Title + " \"" +
                                        " برای تاریخ " + "\" " + PublicMethods.get_local_date(Calendar.BeginDate.Value) + " \"" +
                                        " شامل موضوعات : " + strRenderedKnowledgeDomains + PostFix;
                    if (string.IsNullOrEmpty(strRenderedKnowledgeDomains))
                    {
                        strMessage = "رویدادی از نوع " + "\" " + type + " \" با عنوان " + "\" " + Calendar.Title + " \"" +
                                     " برای تاریخ " + "\" " + PublicMethods.get_local_date(Calendar.BeginDate.Value) + " \"" + PostFix;
                    }
                    else
                    {
                        strMessage = "رویدادی از نوع " + "\" " + type + " \" با عنوان " + "\" " + Calendar.Title + " \"" +
                                     " برای تاریخ " + "\" " + PublicMethods.get_local_date(Calendar.BeginDate.Value) + " \"" +
                                     " شامل موضوعات : " + strRenderedKnowledgeDomains + PostFix;
                    }


                    bool result = MSGController.bulk_send_message(paramsContainer.Tenant.Id,
                                                                  paramsContainer.CurrentUserID.Value, relatedUserIds, strTitle, strMessage);
                    if (!result)
                    {
                        message = "خطا در ارسال پیام به کاربران انتخاب شده";
                    }
                }
            }
            catch (Exception ex) { message = "خطا در ارسال پیام به کاربران انتخاب شده"; }
        }