Exemple #1
0
        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            if (Case == null)
            {
                throw new NullReferenceException("Case must not be null. Update failed.");
            }

            Case.Adx_ModifiedByUsername  = Contact.FullName;
            Case.Adx_ModifiedByIPAddress = Request.UserHostAddress;

            XrmContext.Attach(Case);
            XrmContext.UpdateObject(Case);
            XrmContext.SaveChanges();
            XrmContext.Detach(Case);

            var contactName = Contact.FullName;
            var noteSubject = "Note created on " + DateTime.Now + " by " + contactName;

            if (!string.IsNullOrEmpty(NewNote.Text) || (Attachment.PostedFile != null && Attachment.PostedFile.ContentLength > 0))
            {
                XrmContext.AddNoteAndSave(Case, noteSubject, "*WEB* " + NewNote.Text, Attachment.PostedFile);
            }

            if (System.Web.SiteMap.CurrentNode == null)
            {
                return;
            }

            Response.Redirect(Request.RawUrl);
        }
Exemple #2
0
        protected void ReopenButton_Click(object sender, EventArgs e)
        {
            XrmContext.SetCaseStatusAndSave(Case, "Active", null);

            XrmContext.Detach(Case);

            Response.Redirect(Request.RawUrl);
        }
Exemple #3
0
        protected void ResolveButton_Click(object sender, EventArgs e)
        {
            EditPanel.Enabled = false;

            CloseRelatedActivities();

            Case.CustomerSatisfactionCode = int.Parse(Satisfaction.SelectedValue);

            XrmContext.Attach(Case);
            XrmContext.UpdateObject(Case);
            XrmContext.SaveChanges();
            XrmContext.SetCaseStatusAndSave(Case, "Resolved", Resolution.Text);
            XrmContext.Detach(Case);

            Response.Redirect(Request.RawUrl);
        }
Exemple #4
0
 protected void SubmitButton_Click(object sender, EventArgs e)
 {
     if (userName == passwordTextBox.Text)
     {
         Message1.Visible = true;
         Message1.Text    = "Old password and new password must be different.  Please try again.";
     }
     else
     {
         Message1.Visible          = false;
         LoginContact.Adx_password = passwordTextBox.Text;
         LoginContact.Adx_changepasswordatnextlogon = false;
         XrmContext.Attach(LoginContact);
         XrmContext.UpdateObject(LoginContact);
         XrmContext.SaveChanges();
         XrmContext.Detach(LoginContact);
         Response.Redirect("login", true);
     }
 }
Exemple #5
0
        protected void Login1_Authenticate(object sender, System.Web.UI.WebControls.AuthenticateEventArgs e)
        {
            if (LoginContact == null)
            {
                e.Authenticated = false;
            }
            else
            {
                if (LoginContact.Adx_username == Login1.UserName)
                {
                    if (LoginContact.Adx_changepasswordatnextlogon.Value)
                    {
                        var portal  = PortalCrmConfigurationManager.CreatePortalContext();
                        var website = (Adx_website)portal.Website;
                        var page    = (Adx_webpage)portal.ServiceContext.GetPageBySiteMarkerName(portal.Website, "ChangePassword");

                        string redirectURL = page.Adx_PartialUrl + "?UserName="******"&Password=" + Server.UrlEncode(Login1.Password);
                        Response.Redirect(redirectURL);
                    }
                    else
                    {
                        LoginContact.Adx_LastSuccessfulLogon = DateTime.Now;

                        XrmContext.Attach(LoginContact);
                        XrmContext.UpdateObject(LoginContact);
                        XrmContext.SaveChanges();
                        XrmContext.Detach(LoginContact);

                        e.Authenticated = true;
                        FormsAuthentication.RedirectFromLoginPage(Login1.UserName, true);
                    }
                }
                else
                {
                    e.Authenticated = false;
                }
            }
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //RedirectToLoginIfAnonymous();

            if (IsPostBack)
            {
                return;
            }

            var parameter = new Parameter("Filter", DbType.String, WebAnnotationPrefix);

            CrmNoteSource.WhereParameters.Add(parameter);

            if (Case == null)
            {
                actionResultMessage.Text   = "Case not found";
                CaseInfoPanel.Visible      = false;
                CaseInfoPanelNotes.Visible = false;
                EditPanel.Visible          = false;
                return;
            }

            TitleLabel.Text        = Case.Title;
            CaseNumberLabel.Text   = " Case Number: " + Case.TicketNumber;
            StatusReasonLabel.Text = Enum.GetName(typeof(Enums.IncidentState), Case.StateCode.GetValueOrDefault());
            string Description = Case.Description;

            if (Description != null)
            {
                Description = Description.TrimStart(); Description = Description.TrimEnd();
                if (Description.Length > 1000)
                {
                    Description += Description.Substring(1, 999);
                }

                descriptionTextBox.Text = Description;
            }
            XrmContext.Attach(Case);

            if (Case.subject_incidents != null)
            {
                SubjectLabel.Text = "| Subject: " + Case.subject_incidents.Title;
            }

            XrmContext.Detach(Case);
            CaseTypeLabel.Text  = "| Case Type: " + GetCaseTypeCodeOptionLabelByValue(Case.CaseTypeCode.GetValueOrDefault());
            CreatedOn.Text      = Case.CreatedOn.GetValueOrDefault().ToLocalTime().ToString();
            LastModifiedOn.Text = Case.ModifiedOn.GetValueOrDefault().ToLocalTime().ToString();

            if (Case.KbArticleId != null)
            {
                KB.Text = "Please see the following KB article: <a href=\"/kb/kb-article?id=" + Case.KbArticleId + "\">" + Case.kbarticle_incidents.Title + "</a><br/>";
            }

            var access = ServiceContext.GetCaseAccessByContact(Contact) as Adx_caseaccess;

            if (access == null || !access.Adx_Write.GetValueOrDefault())
            {
                UpdateFields.Visible = false;
                UpdateButton.Visible = false;
            }

            if (Case.StateCode != (int)Enums.IncidentState.Active)
            {
                EditPanel.Enabled        = false;
                UpdateButton.Visible     = false;
                CancelCaseButton.Visible = false;
                CloseCasePanel.Visible   = false;
                ReopenCase.Visible       = true;
            }

            ////Get Activities for cases.
            var result = new List <Entity>();

            var activityPointer =
                from c in XrmContext.CreateQuery("activitypointer")
                where c.GetAttributeValue <Guid?>("regardingobjectid") == Case.Id
                select c;

            result.AddRange(activityPointer);
            if (result.Count > 0)
            {
                foreach (Entity ent in result)
                {
                    if (!ent.Contains("actualdurationminutes"))
                    {
                        ent.Attributes.Add("actualdurationminutes", "0");
                    }

                    if (ent.Attributes["activitytypecode"].ToString().Trim() == "email")
                    {
                        if (ent.Contains("description"))
                        {
                            string emailDescription = ent.Attributes["description"].ToString();
                            emailDescription = StripHtml(emailDescription);

                            if (emailDescription.Length > 1000)
                            {
                                emailDescription = emailDescription.Substring(0, 1999);
                            }
                            ent.Attributes["description"] = emailDescription;
                        }
                    }
                    if (!ent.Contains("description"))
                    {
                        ent.Attributes.Add("description", "");
                    }
                }
                ActivityList.DataKeyNames = new[] { "activityid" };
                ActivityList.DataSource   = result.ToDataTable(XrmContext);
                //ActivityList.ColumnsGenerator = new CrmSavedQueryColumnsGenerator("Activities Web View");
                ActivityList.DataBind();
            }
        }
Exemple #7
0
        protected void CloseRelatedActivities()
        {
            XrmContext.Attach(Case);
            var activities = Case.Incident_ActivityPointers;

            XrmContext.Detach(Case);

            if (activities == null)
            {
                return;
            }

            foreach (ActivityPointer a in activities)
            {
                if (a.StateCode == (int)Enums.ActivityPointerState.Open || a.StateCode == (int)Enums.ActivityPointerState.Scheduled)
                {
                    var activityGuid     = a.ActivityId;
                    var activityTypeCode = a.ActivityTypeCode;

                    switch (activityTypeCode)
                    {
                    case "phonecall":
                        var phonecall = XrmContext.PhoneCallSet.Where(pc => pc.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(phonecall);
                        break;

                    case "task":
                        var task = XrmContext.TaskSet.Where(t => t.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(task);
                        break;

                    case "fax":
                        var fax = XrmContext.FaxSet.Where(f => f.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(fax);
                        break;

                    case "email":
                        var email = XrmContext.EmailSet.Where(e => e.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(email);
                        break;

                    case "letter":
                        var letter = XrmContext.LetterSet.Where(l => l.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(letter);
                        break;

                    case "appointment":
                        var appointment = XrmContext.AppointmentSet.Where(ap => ap.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(appointment);
                        break;

                    case "serviceappointment":
                        var serviceAct = XrmContext.ServiceAppointmentSet.Where(s => s.ActivityId == activityGuid).FirstOrDefault();
                        SetStateCanceled(serviceAct);
                        break;

                    default:
                        break;
                    }
                }
            }

            return;
        }