protected void CreatePackingSlip()
        {
            var cd = Session["CheckOutData"] as CheckOutData;
            //get filename
            string n = DateTime.Now.ToString().Replace("/", "-");

            n = n.Replace(":", "-");
            string info = n + " " + (Session["Ordernumber"] as string);

            info = info.Replace("\\", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace(" ", "_");
            string path = "/Account/PackingLists/" + info + ".pdf";

            PackingSlipLink.Text       = path;
            Session["LastPackingSlip"] = path;
            path = Server.MapPath(path);

            //To
            string to = cd.To.Name + Environment.NewLine;

            foreach (var line in cd.To.AddressLine)
            {
                to += line + Environment.NewLine;
            }
            to += cd.To.City + Environment.NewLine;
            to += cd.To.State + ", " + cd.To.Postal + Environment.NewLine;
            to += cd.To.Country + Environment.NewLine;
            //From
            string from = cd.From.Name + Environment.NewLine;

            foreach (var line in cd.From.AddressLine)
            {
                from += line + Environment.NewLine;
            }
            from += cd.From.City + Environment.NewLine;
            from += cd.From.State + ", " + cd.From.Postal + Environment.NewLine;
            from += cd.From.Country + Environment.NewLine;
            //Define Keys

            var headerKeys = new Dictionary <string, string>()
            {
                { "ShipDate", cd.Pickup.ToShortDateString() },
                { "Tracking", TrackingNumberLabel.Text },
                { "Signature", Session["Shipper"] as string },
                { "Attn", cd.To.AttentionName },
                { "Po", "" },
                { "To", to },
                { "From", from },
                { "Weight", "Weight:" + cd.Package.Weight },
                { "Ordernumber", "Order #:" + Session["Ordernumber"] as string }
            };

            var keys = new Dictionary <string, string>();

            headerKeys.ToList().ForEach(x => keys.Add(x.Key, x.Value));
            int i = 1;

            foreach (var asset in cd.CheckOutItems)
            {
                if (i > 13)
                {
                    //create templated pdf packingslip with default stamping action
                    Pdf.PackingSlip p = new Pdf.PackingSlip(new Templates.StarragPackingSlipTemplate());
                    p.CreateAndFill(path, keys, p.StampAction);
                    //fill new page with new assets
                    keys = new Dictionary <string, string>();
                    headerKeys.ToList().ForEach(x => keys.Add(x.Key, x.Value));
                    i    = 1;
                    path = path.Replace(".pdf", "") + i.ToString() + ".pdf";
                }
                keys.Add("Desc" + i.ToString(), asset.AssetName);
                keys.Add("PartNo" + i.ToString(), asset.AssetNumber);
                keys.Add("Qty" + i.ToString(), "1");
                ++i;
            }

            //create templated pdf packingslip with default stamping action
            Pdf.PackingSlip ps     = new Pdf.PackingSlip(new Templates.StarragPackingSlipTemplate());
            var             result = ps.CreateAndFill(path, keys, ps.StampAction);
            var             bbbb   = false;
        }
Beispiel #2
0
        protected List <string> CreateReceivingReport(List <Asset> assets)
        {
            List <string> filenames = new List <string>();

            try
            {
                //get filename
                string n = DateTime.Now.ToString().Replace("/", "-");
                n = n.Replace(":", "-");
                string info = n + "_" + assets.FirstOrDefault().OrderNumber;
                info = info.Replace("\\", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace(" ", "_");
                string path = "/Account/Receiving/" + info + ".pdf";
                Session["CurrentCheckInOrdernumber"] = assets[0].OrderNumber;
                var ud = Session["SessionUserData"] as Data.UserData;
                ud.Log.Add(new Data.LogEntry("Checked In Order#" + assets[0].OrderNumber, path));
                ReceivingLink.Text = path;
                var checker = Session["CurrentCheckinReport"] as string;
                if (checker == path)
                {
                    path  = path.Replace(".pdf", "");
                    path += filecount.ToString();
                    filecount++;
                    path += ".pdf";
                }
                Session["CurrentCheckinReport"] = path;
                foreach (var ass in assets)
                {
                    ass.ReturnReport = "/Account/Receiving/" + info + ".pdf";
                }
                var path2 = Server.MapPath(path);
                filenames.Add(path2);
                string from         = "";
                string customerattn = assets[0].ShipTo;
                try
                {
                    foreach (var customer in Global.Library.Settings.Customers)
                    {
                        if (customer.CompanyName == assets[0].ShipTo)
                        {
                            from         = customer.CompanyName + Environment.NewLine;
                            from        += customer.Address + Environment.NewLine;
                            from        += customer.Address2 + Environment.NewLine;
                            from        += customer.Address3 + Environment.NewLine;
                            from        += customer.City + Environment.NewLine;
                            from        += customer.State + ", " + customer.Postal + Environment.NewLine;
                            from        += customer.Country + Environment.NewLine;
                            customerattn = customer.Attn;
                        }
                    }
                }
                catch { from += customerattn; }
                //From

                //Define Keys

                var headerKeys = new Dictionary <string, string>()
                {
                    { "ShipDate", assets.FirstOrDefault().DateShippedString },
                    { "Tracking", assets.FirstOrDefault().PersonShipping },
                    { "Signature", customerattn },
                    { "Attn", "" },
                    { "Po", "" },
                    { "To", from },
                    { "From", "" },
                    { "Weight", "Report #::" + info + ".pdf" },
                    { "Ordernumber", "Order #:" + assets.FirstOrDefault().OrderNumber }
                };

                var keys = new Dictionary <string, string>();
                headerKeys.ToList().ForEach(x => keys.Add(x.Key, x.Value));
                int i = 1;
                foreach (var asset in assets)
                {
                    if (i > 13)
                    {
                        //create templated pdf packingslip with default stamping action
                        Pdf.PackingSlip p = new Pdf.PackingSlip(new Templates.StarragReceivingReportTemplate());
                        p.CreateAndFill(path2, keys, p.StampAction);
                        //fill new page with new assets
                        keys = new Dictionary <string, string>();
                        headerKeys.ToList().ForEach(x => keys.Add(x.Key, x.Value));
                        i     = 1;
                        path2 = path2.Replace(".pdf", "") + i.ToString() + ".pdf";
                        filenames.Add(path2);
                    }
                    keys.Add("Desc" + i.ToString(), asset.AssetName);
                    keys.Add("PartNo" + i.ToString(), asset.AssetNumber);
                    keys.Add("Qty" + i.ToString(), "1");

                    ++i;
                }

                //create templated pdf packingslip with default stamping action
                Pdf.PackingSlip ps     = new Pdf.PackingSlip(new Templates.StarragReceivingReportTemplate());
                var             result = ps.CreateAndFill(path2, keys, ps.StampAction);
            }
            catch { }
            return(filenames);
        }