예제 #1
0
        public JsonResult AddFault(string details, int code, Guid category, Guid productID)
        {
            try
               {
               Fault f = new Fault();
               f.ID = Guid.NewGuid();
               f.ProductID = productID;
               f.Username = User.Identity.Name;
               f.Barcode = code;
               f.Details = details;
               f.CategoryID = category;

               new FaultServ.WCFFaultClient().AddFault(f);

               Log l = new Log();
               l.ID = Guid.NewGuid();
               l.FaultID = f.ID;
               l.Details = f.Details;
               l.Date = DateTime.Now;
               l.Status = f.Status;

               new FaultServ.WCFFaultClient().AddFaultToLog(l);

               return Json("Success");
               }
               catch (Exception e)
               {
               return Json("Error");
               }
        }
예제 #2
0
        public PartialViewResult FaultDetails(FaultModel fm)
        {
            try
               {
               Fault f = new Fault();
               f.ID = Guid.NewGuid();
               string pid = (string) Session["faultProductID"];
               f.ProductID = new Guid(pid);
               string oID = (string)Session["faultOrderID"];
               f.OrderID = new Guid(oID);
               f.Username = User.Identity.Name;
               f.Barcode = fm.Code;
               f.Details = fm.Details;
               f.CategoryID = new Guid(fm.Category);
               f.Status = new Guid("cbd3ea58-b2b6-4549-9279-1711986bfb49");

               new FaultServ.WCFFaultClient().AddFault(f);

               Log l = new Log();
               l.ID = Guid.NewGuid();
               l.FaultID = f.ID;
               l.Details = f.Details;
               l.Date = DateTime.Now;
               l.Status = f.Status;

               new FaultServ.WCFFaultClient().AddFaultToLog(l);
               @ViewBag.faultAddedMsg = "Fault Was Added Succesfully";
               return PartialView("_faultAdded");
               }
               catch (Exception e)
               {
               @ViewBag.faultAddedMsg = "Fault Was Not Added";
               return PartialView("_faultAdded");
               }
        }
예제 #3
0
        public void UpdateFault(Fault f)
        {
            entities.Fault.Attach(GetProductFault(f.Username,f.ProductID));
            entities.Fault.ApplyCurrentValues(f);

            entities.SaveChanges();
        }
예제 #4
0
        public PartialViewResult ProductWithMostFaults()
        {
            List<Fault> poList = new ProductClient().GetProductWithMostFaults().ToList();
            Product p;
            Fault f = new Fault();
            foreach (Fault tempF in poList)
            {
                f = tempF;
            }
            p = new ProductClient().GetProductByID(f.ProductID);

            return PartialView("_productWithMostFaults", p);
        }
        public void can_notify_failure_of_InvoicedOrderMessage()
        {
            var message = new InvoicedOrderMessage {BusinessPartnerCode = "WWT"};
            var exception = new Exception("Test Exception");
            var fault = new Fault<InvoicedOrderMessage>(message, exception);

            _sut.NotifyFailureOf(fault);

            _notificationSender.Verify(x => x.SendNotification(
                                                It.IsAny<string>(),
                                                It.Is<IList<EmailAddress>>(
                                                    a =>
                                                    a[0].Address ==
                                                    EmailAddressConstants.InformationtechnologygroupEmailAddress &&
                                                    a[1].Address == EmailAddressConstants.AccountsReceivableEmailAddress),
                                                It.Is<string>(body => body.Contains(message.ToString()) &&
                                                                      body.Contains(exception.ToString()))));
        }
        public void can_notify_failure_of_CreateOrderMessage()
        {
            var message = new OrderHasBeenShippedMessage {BusinessPartnerCode = "WWT"};
            message.Add(new ShippedLine());

            var exception = new Exception("Test Exception");
            var fault = new Fault<OrderHasBeenShippedMessage>(message, exception);

            _sut.NotifyFailureOf(fault);

            _notificationSender.Verify(x => x.SendNotification(
                                                It.IsAny<string>(),
                                                It.Is<IList<EmailAddress>>(
                                                    a =>
                                                    a[0].Address ==
                                                    EmailAddressConstants.InformationtechnologygroupEmailAddress &&
                                                    a[1].Address == EmailAddressConstants.LogisticsEmailAddress),
                                                It.Is<string>(body => body.Contains(message.ToString()) &&
                                                                      body.Contains(exception.ToString()))));
        }
예제 #7
0
 /// <summary>
 /// Create a new Fault object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="ticketNumber">Initial value of the TicketNumber property.</param>
 /// <param name="productID">Initial value of the ProductID property.</param>
 /// <param name="accountID">Initial value of the AccountID property.</param>
 /// <param name="barcode">Initial value of the Barcode property.</param>
 public static Fault CreateFault(global::System.Int32 id, global::System.Int32 ticketNumber, global::System.Int32 productID, global::System.Int32 accountID, global::System.Byte[] barcode)
 {
     Fault fault = new Fault();
     fault.ID = id;
     fault.TicketNumber = ticketNumber;
     fault.ProductID = productID;
     fault.AccountID = accountID;
     fault.Barcode = barcode;
     return fault;
 }
예제 #8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Fault EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFault(Fault fault)
 {
     base.AddObject("Fault", fault);
 }
예제 #9
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");
            }
        }
 /// <summary>
 /// Create a new Fault object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="productID">Initial value of the ProductID property.</param>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Fault CreateFault(global::System.Guid id, global::System.Guid productID, global::System.String username, global::System.Guid status)
 {
     Fault fault = new Fault();
     fault.ID = id;
     fault.ProductID = productID;
     fault.Username = username;
     fault.Status = status;
     return fault;
 }
예제 #11
0
 public void DeleteFault(Fault f)
 {
     entities.Fault.DeleteObject(GetProductFault(f.Username, f.ProductID));
     entities.SaveChanges();
 }
예제 #12
0
 public void AddFault(Fault f)
 {
     entities.AddToFault(f);
     entities.SaveChanges();
 }
예제 #13
0
        public void UpdateFault(Fault f)
        {
            entities.Fault.Attach(GetProductFault(f.Username,f.ProductID,new Guid(f.OrderID.ToString())));
            entities.Fault.ApplyCurrentValues(f);

            entities.SaveChanges();
        }
예제 #14
0
파일: DAFault.cs 프로젝트: ClaireG90/DSA
 public void AddFault(Fault fault)
 {
     entities.Fault.AddObject(fault);
     entities.SaveChanges();
 }