コード例 #1
0
 /// <summary>
 /// Create a new FaultLog object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="faultID">Initial value of the FaultID property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="dateOfReport">Initial value of the DateOfReport property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static FaultLog CreateFaultLog(global::System.Int32 id, global::System.Int32 faultID, global::System.String description, global::System.DateTime dateOfReport, global::System.String status)
 {
     FaultLog faultLog = new FaultLog();
     faultLog.ID = id;
     faultLog.FaultID = faultID;
     faultLog.Description = description;
     faultLog.DateOfReport = dateOfReport;
     faultLog.Status = status;
     return faultLog;
 }
コード例 #2
0
        public ActionResult ReportFault(GenerateFaultModel model, int pID)
        {
            try
            {
                if (Session["accountID"] != null)
                {
                    int ticketNumber;
                    bool available = false;

                    do
                    {
                        ticketNumber = new FaultClient().GenerateRandomNumber();
                        if (new FaultClient().GetFaultByTicketNumber(ticketNumber) != null)
                        {
                            ticketNumber = new FaultClient().GenerateRandomNumber();
                            available = false;
                        }
                        else
                        {
                            available = true;
                        }
                    }
                    while (!available);

                    BarCodeData barCodeData = new BarCodeData();
                    barCodeData.Height = 125;
                    barCodeData.Width = 225;
                    barCodeData.Angle = 0;
                    barCodeData.Ratio = 5;
                    barCodeData.Module = 0;
                    barCodeData.Left = 25;
                    barCodeData.Top = 0;
                    barCodeData.CheckSum = false;
                    barCodeData.FontName = "Arial";
                    barCodeData.BarColor = "Black";
                    barCodeData.BGColor = "White";
                    barCodeData.FontSize = 10.0f;
                    barCodeData.barcodeOption = BarcodeOption.Both;
                    barCodeData.barcodeType = BarcodeType.Code_2_5_interleaved;
                    barCodeData.checkSumMethod = CheckSumMethod.None;
                    barCodeData.showTextPosition = ShowTextPosition.BottomCenter;
                    barCodeData.BarCodeImageFormat = ImageFormats.PNG;

                    Byte[] imgBarcode = new BarCodeSoapClient().GenerateBarCode(barCodeData, randomNum.ToString());

                    MemoryStream memStream = new MemoryStream(imgBarcode);
                    Bitmap bm = new Bitmap(memStream);
                    bm.Save(HttpContext.Response.OutputStream, ImageFormat.Jpeg);

                    System.Drawing.Image image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(imgBarcode));

                    Fault fault = new Fault();
                    fault.TicketNumber = ticketNumber;
                    fault.ProductID = pID;
                    fault.AccountID = (int)Session["accountID"];
                    fault.Barcode = imgBarcode;

                    new FaultClient().AddFault(fault);

                    FaultLog faultLog = new FaultLog();
                    faultLog.FaultID = new FaultClient().GetFaultByTicketNumber(ticketNumber).ID;
                    faultLog.Description = model.Description;
                    faultLog.DateOfReport = DateTime.Today;
                    faultLog.Status = "Reported";

                    new FaultClient().AddFaultLog(faultLog);
                    User user = new UserAccountClient().GetUserByAccountID((int)Session["accountID"]);

                    memStream.Position = 0;
                    string body = string.Format(@"Dear " + user.Name + " " + user.Surname + ",<br /><br />A new fault report has been made."+
                            "Please find attached your barcode image. <br />Ticket Number: " + ticketNumber + "<br /><br />Regards,<br />Electros Ltd. Staff");

                    //SEND EMAIL HERE
                    MailMessage newMessage = new MailMessage();

                    newMessage.From = new MailAddress("*****@*****.**");
                    newMessage.To.Add(new MailAddress(user.Email));
                    newMessage.Subject = "Fault Report";
                    newMessage.Attachments.Add(new Attachment(memStream, "Barcodeimg.jpg", "image/jpg"));
                    newMessage.IsBodyHtml = true;
                    newMessage.Body = body;
                    SmtpClient smtpClient = new SmtpClient("smtp.go.net.mt");
                    smtpClient.Send(newMessage);

                    return RedirectToAction("Index", "GenerateFault");
                }
                else
                {
                    return RedirectToAction("Login", "Login");
                }
            }
            catch (Exception e)
            {
                ViewBag.Error = "An error has occured.";
                return RedirectToAction("Index", "GenerateFault");
            }
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the FaultLog EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFaultLog(FaultLog faultLog)
 {
     base.AddObject("FaultLog", faultLog);
 }
コード例 #4
0
        public ActionResult ShowReport(int pID, int oID)
        {
            try
            {
                PrintStatementModel model = new PrintStatementModel();
                Order o = new OrderClient().GetOrderByID(oID);
                model.myOrder = o;

                ProductOrder po = new OrderClient().GetProductOrderByOrderIDAndProductID(o.ID, pID);
                model.myProductOrder = po;

                List<FaultLog> fl = new List<FaultLog>();

                Product p = new ProductClient().GetProductByID(pID);
                model.myProduct = p;

                List<Fault> f = new FaultClient().GetFaultsByAccountIDandProductID((int)Session["accountID"], pID).ToList();
                model.myFaultList = f;

                Common.FaultLog faultLog = new Common.FaultLog();
                List<Common.FaultLog> faultLogList = new List<Common.FaultLog>();
                List<Common.Fault> flist = new List<Common.Fault>();

                flist = new DSA_Assignment1_Sit1.FaultServ.FaultClient().GetFaultsByAccountIDandProductID((int)Session["accountID"], pID).ToList();

                foreach (Common.Fault fa in flist)
                {
                    List<Common.FaultLog> flTemp = new DSA_Assignment1_Sit1.FaultServ.FaultClient().GetAllFaultLogsByFaultID(fa.ID).ToList();

                    model.myFaultLog = flTemp;
                }

                if (model.myFaultLog == null)
                {
                    List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList();

                    foreach (Order or in orderList)
                    {
                        List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(or.ID).ToList();

                        foreach (ProductOrder por in productOrderlist)
                        {
                            allPO.Add(por);
                        }
                    }

                    ViewBag.Error = "No fault logs recorded.";
                    return RedirectToAction("PurchaseHistory", allPO);
                }
                //SEND EMAIL

                //get user email
                User user = new UserAccountClient().GetUserByAccountID((int)Session["accountID"]);

                //Render email

                Document document = new Document();
                MemoryStream memoryStream = new MemoryStream();
                PdfWriter writer = PdfWriter.GetInstance(document, memoryStream);

                document.Open();
                document.Add(new Paragraph("Electros Ltd."));
                document.Add(new Paragraph());
                document.Add(new Paragraph("Item: "));
                document.Add(new Paragraph("Product ID          " + "Name                    " + "Price          " + "Date Of Purchase         " + "Warranty Expiry"));
                document.Add(new Paragraph(model.myProduct.ID + "                    " + model.myProduct.Name + "          " + model.myProduct.Price + "          " + model.myOrder.DateOfOrder.ToShortDateString() + "             " + model.myProductOrder.WarrantyExpiry.ToShortDateString()));
                document.Add(new Paragraph());
                document.Add(new Paragraph("Faults: "));
                document.Add(new Paragraph("Fault ID          Date          Fault Details                              Status"));
                foreach (FaultLog flo in model.myFaultLog)
                {
                    document.Add(new Paragraph(flo.FaultID + "          " + flo.DateOfReport.ToShortDateString() + "          " + flo.Description + "                              " + flo.Status));
                }
                writer.CloseStream = false;
                document.Close();
                memoryStream.Position = 0;

                MailMessage newMessage = new MailMessage();
                newMessage.From = new MailAddress("*****@*****.**");
                newMessage.To.Add(new MailAddress(user.Email));
                newMessage.Subject = "Print Statement";
                newMessage.Body = "Dear " + user.Name + " " + user.Surname + ",  please find attached details of the product's faults.";
                Attachment attachment = new Attachment(memoryStream, "ReportStatement.pdf");
                newMessage.Attachments.Add(attachment);
                SmtpClient smtpClient = new SmtpClient("smtp.go.net.mt");
                smtpClient.Send(newMessage);

                return new RazorPDF.PdfResult(model, "ShowReport");
            }
            catch (Exception e)
            {
                List<Order> orderList = new OrderClient().GetBoughtOrdersByAccountID((int)Session["accountID"]).ToList();

                foreach (Order o in orderList)
                {
                    List<ProductOrder> productOrderlist = new OrderClient().GetProductOrderByOrderID(o.ID).ToList();

                    foreach (ProductOrder po in productOrderlist)
                    {
                        allPO.Add(po);
                    }
                }
                ViewBag.Error = "An error has occured.";
                return RedirectToAction("PurchaseHistory" , allPO);
            }
        }
コード例 #5
0
ファイル: Fault.svc (2).cs プロジェクト: ClaireG90/DSA
 /// <summary>
 /// Adds a fault log to the database
 /// </summary>
 /// <param name="faultLog">The fault log to add</param>
 public void AddFaultLog(FaultLog faultLog)
 {
     new DAFaultLog().AddFaultLog(faultLog);
 }
コード例 #6
0
        public ActionResult Update(GenerateFaultModel model, int faultID)
        {
            FaultLog faultLog = new FaultLog();
            faultLog.Status = model.Status;
            faultLog.Description = model.Description;
            faultLog.FaultID = faultID;
            faultLog.DateOfReport = DateTime.Today;

            new FaultClient().AddFaultLog(faultLog);
            faultLogs.Add(faultLog);

            Fault f = new FaultClient().GetFaultByID(faultID);

            User u = new UserAccountClient().GetUserByAccountID(f.AccountID);

            MailMessage newMessage = new MailMessage();
            newMessage.From = new MailAddress("*****@*****.**");
            newMessage.To.Add(new MailAddress(u.Email));
            newMessage.Subject = "Fault Report";
            newMessage.Body = "One of our representatives just updated your product with the latest service.  Please check our website for the update details.";
            SmtpClient smtpClient = new SmtpClient("smtp.go.net.mt");
            smtpClient.Send(newMessage);

            return View("Index", faultLogs);
        }
コード例 #7
0
        public ActionResult Update(GenerateFaultModel model, int faultID)
        {
            try
            {
                if (Session["accountID"] != null)
                {
                    FaultLog faultLog = new FaultLog();

                    //faultLog.Status = model.Status;

                    int statusID = Convert.ToInt32(model.Status);
                    switch (statusID)
                    {
                        case 1:
                            faultLog.Status = "Reported";
                            sendSMS("Reported");
                            break;
                        case 2:
                            faultLog.Status = "Picked up - Transit to main office";
                            sendSMS("Picked up - Transit to main office");
                            break;
                        case 3:
                            faultLog.Status = "Service in progress";
                            sendSMS("Service in progress");
                            break;
                        case 4:
                            faultLog.Status = "Service completed - Ready for delivery";
                            sendSMS("Service completed - Ready for delivery");
                            break;
                        case 5:
                            faultLog.Status = "Picked up - Transit to customer";
                            sendSMS("Picked up - Transit to customer");
                            break;
                        case 6:
                            faultLog.Status = "Fault Completed";
                            sendSMS("Fault Completed");
                            break;
                        default:
                            faultLog.Status = "Reported";
                            sendSMS("Reported");
                            break;
                    }

                    faultLog.Description = model.Description;
                    faultLog.FaultID = faultID;
                    faultLog.DateOfReport = DateTime.Today;

                    new FaultClient().AddFaultLog(faultLog);
                    faultLogs.Add(faultLog);

                    Fault f = new FaultClient().GetFaultByID(faultID);

                    User u = new UserAccountClient().GetUserByAccountID(f.AccountID);

                    MailMessage newMessage = new MailMessage();
                    newMessage.From = new MailAddress("*****@*****.**");
                    newMessage.To.Add(new MailAddress(u.Email));
                    newMessage.Subject = "Fault Report";
                    newMessage.Body = "One of our representatives just updated your product with the latest service.  Please check our website for the update details.";
                    SmtpClient smtpClient = new SmtpClient("smtp.go.net.mt");
                    smtpClient.Send(newMessage);

                    return View("Index", faultLogs);
                }
                else
                {
                    return RedirectToAction("Login", "Login");
                }
            }
            catch (Exception e)
            {
                TempData["Error"] = "An error has occured.";
                return RedirectToAction("Index", faultLogs);
            }
        }
コード例 #8
0
ファイル: DAFaultLog (2).cs プロジェクト: ClaireG90/DSA
 public void AddFaultLog(FaultLog faultLog)
 {
     entities.FaultLog.AddObject(faultLog);
     entities.SaveChanges();
 }