コード例 #1
0
        protected void btnExport_Click(object sender, EventArgs e)
        {
            var document   = new Document();
            var builder    = new DocumentBuilder(document);
            var activities = GetRecentMeetings().OrderByDescending(a => a.DateMeeting).ToList();
            var sales      = activities.Select(x => x.User).Distinct().ToList();

            for (int i = 0; i < sales.Count(); i++)
            {
                var needInsertSalesHeader = true;
                for (int j = 0; j < activities.Count(); j++)
                {
                    var activity        = activities[j] as Activity;
                    var uniqueSales     = sales[i];
                    var salesInActivity = activity.User;
                    if (uniqueSales.Id != salesInActivity.Id)
                    {
                        continue;
                    }
                    var contact         = DashBoardBLL.AgencyContactGetById(activity.ObjectId);
                    var contactName     = contact != null ? contact.Name : "";
                    var contactPosition = contact != null ? contact.Position : "";
                    var dateMeeting     = activity.DateMeeting.ToString("dd/MM/yyyy");
                    var agencyId        = 0;
                    try
                    {
                        agencyId = Int32.Parse(activity.Params);
                    }
                    catch { }
                    var agency     = DashBoardBLL.AgencyGetById(agencyId);
                    var agencyName = agency != null ? agency.Name : "";
                    var note       = activity.Note;
                    var salesName  = uniqueSales.FullName;
                    InsertTableActivityToDocument(builder, needInsertSalesHeader, dateMeeting, salesName, contactName, contactPosition, agencyName, note);
                    needInsertSalesHeader = false;
                }
            }
            Response.Clear();
            Response.Buffer      = true;
            Response.ContentType = "application/ms-word";
            Response.AppendHeader("content-disposition", "attachment; filename=" + string.Format("Meetings.doc"));
            MemoryStream m = new MemoryStream();

            document.Save(m, SaveFormat.Doc);
            Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            m.Close();
            Response.End();
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            var uploadPath  = "";
            var contentType = "";

            if (fuAttachment.HasFile)
            {
                var fileName      = DateTime.Today.Year.ToString() + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + Guid.NewGuid().ToString();
                var fileExtension = new FileInfo(fuAttachment.FileName).Extension;
                var fullFileName  = fileName + fileExtension;
                uploadPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Upload/"), fullFileName);
                fuAttachment.SaveAs(uploadPath);
                contentType = fuAttachment.PostedFile.ContentType;
            }
            var agencyContactId = 0;

            try
            {
                agencyContactId = Int32.Parse(Request.Params["ddlContact"]);
            }
            catch { }
            var agencyContact = DashBoardBLL.AgencyContactGetById(agencyContactId);
            var dateMeeting   = new DateTime();

            try
            {
                dateMeeting = DateTime.ParseExact(txtDateMeeting.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            catch { }
            var    problems = "";
            Cruise cruise   = null;

            if (ddlType.SelectedValue == "Problem Report")
            {
                if (chkBus.Checked)
                {
                    problems += "Bus,";
                }
                if (chkCabin.Checked)
                {
                    problems += "Cabin,";
                }
                if (chkGuide.Checked)
                {
                    problems += "Guide,";
                }
                if (chkFood.Checked)
                {
                    problems += "Food,";
                }
                if (chkOthers.Checked)
                {
                    problems += "Others,";
                }
                problems = problems.TrimEnd(new char[] { ',' });
                var cruiseId = 0;
                try
                {
                    cruiseId = Int32.Parse(ddlCruise.SelectedValue);
                }
                catch { }
                cruise = DashBoardBLL.CruiseGetById(cruiseId);
                if (cruise.Id == 0)
                {
                    cruise = null;
                }
            }

            var activityId = 0;

            try
            {
                activityId = Int32.Parse(hidActivityId.Value);
            }
            catch { }
            var activity = DashBoardBLL.ActivityGetById(activityId);

            if (activity == null || activity.Id == 0)
            {
                activity = new Activity();
            }
            activity.UpdateTime = DateTime.Now;
            activity.Time       = DateTime.Now;
            activity.Params     = agencyContact != null && agencyContact.Agency != null?agencyContact.Agency.Id.ToString() : 0.ToString();

            activity.DateMeeting = dateMeeting;
            activity.Note        = txtNote.Text;
            activity.ObjectType  = "MEETING";
            activity.ObjectId    = agencyContact != null ? agencyContact.Id : 0;
            activity.Url         = "AgencyView.aspx?NodeId=1&SectionId=15&agencyid=" + agencyContact != null && agencyContact.Agency != null?agencyContact.Agency.Id.ToString() : 0.ToString();

            activity.User  = CurrentUser;
            activity.Level = ImportantLevel.Important;
            activity.Type  = ddlType.SelectedValue;
            activity.NeedManagerAttention  = chkNeedManagerAttention.Checked;
            activity.Attachment            = uploadPath == "" ? activity.Attachment : uploadPath;
            activity.AttachmentContentType = contentType == "" ? activity.AttachmentContentType : contentType;
            activity.Problems = problems;
            activity.Cruise   = cruise;
            DashBoardBLL.ActivitySaveOrUpdate(activity);
            Response.Redirect(Request.RawUrl);
        }
コード例 #3
0
 public AgencyContact AgencyContactGetById(int agencyContactId)
 {
     return(DashBoardBLL.AgencyContactGetById(agencyContactId));
 }