Ejemplo n.º 1
0
        public async Task <IActionResult> Create(FaultLogForCreateDto faultLogForCreateDto)
        {
            var atmFaultToCreate = new FaultLog
            {
                TerminalId      = faultLogForCreateDto.TerminalId,
                TerminalName    = faultLogForCreateDto.TerminalName,
                AtmFleetId      = faultLogForCreateDto.AtmFleetId,
                Vendor          = faultLogForCreateDto.Vendor,
                Brand           = faultLogForCreateDto.Brand,
                NatureOfFault   = faultLogForCreateDto.NatureOfFault,
                CustodianName   = faultLogForCreateDto.CustodianName,
                CustodianNumber = faultLogForCreateDto.CustodianNumber,
                DateLogged      = faultLogForCreateDto.DateLogged,
                DateResolved    = faultLogForCreateDto.DateResolved,
                DefaultDays     = (faultLogForCreateDto.DateResolved - faultLogForCreateDto.DateLogged)
            };

            _repo.Add(atmFaultToCreate);
            if (await _repo.SaveAll())
            {
                var atmFaultToReturn = _mapper.Map <FaultLogForListDto>(atmFaultToCreate);
                return(CreatedAtRoute("GetFaultLog", new FaultLogForListDto {
                    Id = atmFaultToCreate.Id
                }, atmFaultToReturn));
            }

            return(StatusCode(201));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        /// <param name="rawView">Массив байт, прочитанных из файла вида AVRXX.bin</param>
        /// <param name="ownerFault">Авария, к которой относится данная страница</param>
        public FaultArchivePage(byte[] rawView, FaultLog ownerFault)
        {
            RawView    = rawView;
            OwnerFault = ownerFault;

            //первые 6 байт - дата и время создания страницы
            TimeCreated = new DateTime(rawView[3], rawView[2], rawView[1], rawView[4], rawView[5], rawView[6]);

            //индекс (порядковый номер страницы (7-ой и 8-ой байты)
            Index = rawView[7] * 256 + rawView[8];

            MeterNumber = rawView[0];

            Lines = new List <VariableLengthPageLine>();
            for (int i = 11; i < 11 + 21 * 97; i += 21)
            {
                var lineRaw = new byte[21];
                for (int j = 0; j < 21; ++j)
                {
                    lineRaw[j] = rawView[i + j];
                }
                var pl = new VariableLengthPageLine(lineRaw);
                Lines.Add(pl);
            }
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> AssignToTechnician(FaultTrackingViewModel model)
        {
            try
            {
                var teknisyen = await NewUserStore().FindByIdAsync(model.TechnicianID);

                var fault = new FaultRepo().GetById(model.FaultID);
                if (teknisyen != null)
                {
                    fault.TechnicianId    = teknisyen.Id;
                    fault.TechnicianState = TechnicianState.Calısıyor;
                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = $"Arıza {teknisyen.Name} {teknisyen.Surname} isimli teknisyene atandı",
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);
                    TempData["message"] = $"{fault.FaultID} no'lu arıza işlemi {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyene atanmıştır.";
                }
                else
                {
                    throw new Exception("Teknisyen atama işlemi yapılırken bir hata oluştu");
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Update(FaultModel fm, int reportID)
        {
            try
            {
                FaultLog fll = new FaultLog();
                // fll.Status = fm.Status;
                fll.Description   = fm.Description;
                fll.DateReport    = System.DateTime.Now.Date;
                fll.FaultReportID = reportID;
                //fll.Status = fm.stat;
                int idstat = Convert.ToInt32(fm.stat);
                if (idstat == 1)
                {
                    fll.Status = "Reported";
                    sendSMS("Reported");
                }
                else if (idstat == 2)
                {
                    fll.Status = "Picked up - Transit to main office";
                    sendSMS("Picked up - Transit to main office");
                }
                else if (idstat == 3)
                {
                    fll.Status = "Service in progress";
                    sendSMS("Service in progress");
                }
                else if (idstat == 4)
                {
                    fll.Status = "Service completed - Ready for Delivery";
                    sendSMS("Service completed - Ready for Delivery");
                }
                else if (idstat == 5)
                {
                    fll.Status = "Picked up - Transit to customer";
                    sendSMS("Picked up - Transit to customer");
                }
                else if (idstat == 6)
                {
                    fll.Status = "Fault Completed";
                    sendSMS("Fault Completed");
                }
                new FaultsServ.FaultReportLogServiceClient().CreateLog(fll);
                fl.Add(fll);

                SendEmailtoClient(reportID);
                return(RedirectToAction("Index", fl));
            }
            catch (Exception ex)
            {
                TempData["CatchError"] = "An error was encountered. Please try again later";
                return(RedirectToAction("Index", fl));
            }
        }
Ejemplo n.º 5
0
        public Signal(FaultLog owner, string name, string mathOperation)
        {
            this.OwnerFault    = owner;
            this.Name          = name;
            this.MathOperation = mathOperation;
            this.Channels      = new ObservableCollection <IRpdChannel>();

            Trend         = new List <IDataPoint>();
            IsTrendExists = false;
            IsTrendLoaded = false;

            InitWorker();
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> ConfirmFault(Guid id)
        {
            try
            {
                var fault    = new FaultRepo().GetById(id);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                var technician = await NewUserStore().FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                if (technician != null)
                {
                    fault.haveJob = true;

                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = $"Arıza {technician.Name} {technician.Surname} isimli teknisyene arızayı onayladı",
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);

                    string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                     (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

                    var emailService = new EmailService();
                    var body         = $"Merhaba <b>{customer.Name} {customer.Surname}</b><br>{technician.Name} {technician.Surname} isimli teknisyen 2 iş günü içerisinde gelecek";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "Teknisyen atandı"
                    }, customer.Email);
                }

                TempData["Message"] = $"Teknisyen arızayı onaylanmıştır";
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu {ex.Message}",
                    ActionName     = "Index",
                    ControllerName = "Operator",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
Ejemplo n.º 7
0
        //private void LoadTrendCore(List<IDataPoint> trend)
        private ReadChannelTrendResult LoadTrendCore()
        {
            FaultLog ownerFault = (FaultLog)this.OwnerMeter.OwnerFault;
            //ReadChannelTrendResult result = ownerFault.ReadChannelTrendFromBinaryFile(ownerFault.BinFileInfo.Name, this);
            ReadChannelTrendResult result = ownerFault.ReadChannelTrendFromBinaryFile(this);

            /*
             * RpdMeter OwnerPsnMeter = (RpdMeter)this.OwnerPsnMeter;
             * OwnerPsnMeter.SettingsReaded = result.Result.SettingsReaded;
             * owner
             */
            //IsTrendLoaded = true;
            return(result);
        }
Ejemplo n.º 8
0
 //****************************************************************************
 public RpdMeter(FaultLog owner, int address, string name)
 {
     OwnerFault = owner;
     Address    = address;
     Name       = name;
     //--------------------------------------------------+
     //this.Channels = new ObservableCollection<IChannel>();
     Type = RpdMeterType.Undefined;             //каналы регенерируются при изменении свойства, например
     //--------------------------------------------------
     ArchivePages = new List <FaultArchivePage>();
     //--------------------------------------------------+
     TrendsTimeOffset         = 0;
     TrendDataCountBeforeDump = 0;
     TrendDataCountAfterDump  = 0;
     //---------------------------------------------------
     SettingsReaded = false;
     //---------------------------------------------------
     SettingsLines = new List <VariableLengthPageLine>();
     SettingsRaw   = new byte[RegSetupRpd.SizeInBytes];
 }
Ejemplo n.º 9
0
 public void AddFaultRecord(List <Alarm> alarmLst)
 {
     for (int i = 0; i < alarmLst.Count; i++)
     {
         Alarm  ar  = alarmLst[i];
         Device smg = new CWDevice().Find(d => d.Warehouse == ar.Warehouse && d.DeviceCode == ar.DeviceCode);
         if (smg != null)
         {
             FaultLog log = new FaultLog
             {
                 Warehouse   = smg.Warehouse,
                 DeviceCode  = smg.DeviceCode,
                 RunStep     = smg.RunStep,
                 InStep      = smg.InStep,
                 OutStep     = smg.OutStep,
                 Description = ar.Description,
                 CreateDate  = DateTime.Now
             };
             manager.Add(log);
         }
     }
 }
Ejemplo n.º 10
0
        public RpdMeter CloneAndLinkWithFault(FaultLog f)
        {
            //Log.Global.Info("Called");
            RpdMeter met = null;

            try
            {
                met = new RpdMeter(f, Address, Name)
                {
                    Channels = new ObservableCollection <IRpdChannel>(), Type = Type
                };
                // дублирование регенерации каналов
                met.Channels.Clear();
                foreach (RpdChannel ch in Channels)
                {
                    met.Channels.Add(ch.CloneAndLinkWithMeter(met));
                }
            }
            catch
            {
                // TODO: remove empty catch
            }
            return(met);
        }
Ejemplo n.º 11
0
 public void CreateLog(FaultLog faultLog)
 {
     entities.AddToFaultLog(faultLog);
     entities.SaveChanges();
 }
Ejemplo n.º 12
0
        public async Task <ActionResult> FaultCreate(FaultViewModel model)
        {
            //o anki sistemdeki kullanıcının idsini verir.

            var MusteriId = HttpContext.User.Identity.GetUserId();


            //if (!ModelState.IsValid)
            //{
            //    //Gelen model valid degiilse bu sayfaya yönlendirilip hatalar gösterilicek.
            //    return RedirectToAction("Index", "Musteri", model);
            //}


            try
            {
                #region ArızaResimİşlemi
                if (model.PostedFileFault != null &&
                    model.PostedFileFault.ContentLength > 0)
                {
                    var    file     = model.PostedFileFault;
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    string extName  = Path.GetExtension(file.FileName);
                    fileName  = StringHelper.UrlFormatConverter(fileName);
                    fileName += StringHelper.GetCode();
                    var klasoryolu = Server.MapPath("~/Ariza/");
                    var dosyayolu  = Server.MapPath("~/Ariza/") + fileName + extName;

                    if (!Directory.Exists(klasoryolu))
                    {
                        Directory.CreateDirectory(klasoryolu);
                    }
                    file.SaveAs(dosyayolu);

                    WebImage img = new WebImage(dosyayolu);
                    img.Resize(250, 250, false);
                    img.AddTextWatermark("FİTech");
                    img.Save(dosyayolu);
                    var oldPath = model.FaultPath;
                    model.FaultPath = "/Ariza/" + fileName + extName;

                    System.IO.File.Delete(Server.MapPath(oldPath));
                }


                #endregion

                #region FaturaResimİşlemleri
                if (model.PostedFileInvoice != null &&
                    model.PostedFileInvoice.ContentLength > 0)
                {
                    var    file     = model.PostedFileInvoice;
                    string fileName = Path.GetFileNameWithoutExtension(file.FileName);
                    string extName  = Path.GetExtension(file.FileName);
                    fileName  = StringHelper.UrlFormatConverter(fileName);
                    fileName += StringHelper.GetCode();
                    var klasoryolu = Server.MapPath("~/Fatura/");
                    var dosyayolu  = Server.MapPath("~/Fatura/") + fileName + extName;

                    if (!Directory.Exists(klasoryolu))
                    {
                        Directory.CreateDirectory(klasoryolu);
                    }
                    file.SaveAs(dosyayolu);

                    WebImage img = new WebImage(dosyayolu);
                    img.Resize(250, 250, false);
                    img.AddTextWatermark("FİTech");
                    img.Save(dosyayolu);
                    var oldPath = model.InvoicePath;
                    model.InvoicePath = "/Fatura/" + fileName + extName;

                    System.IO.File.Delete(Server.MapPath(oldPath));
                }


                #endregion

                var data = new Fault
                {
                    CustomerId       = MusteriId,
                    FaultPath        = model.FaultPath,
                    InvoicePath      = model.InvoicePath,
                    Adress           = model.Adress,
                    FaultDescription = model.FaultDescription,
                    AssignedOperator = false,
                    FaultState       = FaultState.Uncompleted,
                    FaultID          = model.FaultID,
                };
                new FaultRepo().Insert(data);
                var Log = new FaultLog
                {
                    TechnicianId         = data.TechnicianId,
                    CustomerId           = data.CustomerId,
                    Operation            = "Arıza kaydı oluşturuldu",
                    FaultId              = data.FaultID,
                    OperationDescription = data.FaultDescription
                };
                new FaultLogRepo().Insert(Log);

                var fault    = new FaultRepo().GetById(data.FaultID);
                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                 (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

                var emailService = new EmailService();
                var body         = $"Merhaba <b>{data.FaultID} nolu Arıza kaydınız alınmıştır";
                await emailService.SendAsync(new IdentityMessage()
                {
                    Body = body, Subject = "Arıza Kaydı"
                }, customer.Email);

                TempData["Message"] = $"{model.FaultID} no'lu kayıt başarıyla eklenmiştir";
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu: {EntityHelpers.ValidationMessage(ex)}",
                    ActionName     = "Index",
                    ControllerName = "Musteri",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
            catch (Exception ex)
            {
                TempData["Model"] = new ErrorViewModel()
                {
                    Text           = $"Bir hata oluştu: {ex.Message}",
                    ActionName     = "Index",
                    ControllerName = "Musteri",
                    ErrorCode      = 500
                };
                return(RedirectToAction("Error", "Home"));
            }
        }
Ejemplo n.º 13
0
        public ActionResult GenerateTicket(FaultModel fm, int pid)
        {
            //try
            //{
            string  username  = Session["username"].ToString();
            Account a         = new AccountServ.AccountServiceClient().getAccountByUsername(username);
            int     accountID = a.ID;

            int         ticketNum      = new FaultsServ.FaultReportLogServiceClient().GenerateTicketNum();
            FaultReport checkTicketnum = new FaultsServ.FaultReportLogServiceClient().getTicketNum(ticketNum);

            if (checkTicketnum == null)
            {
                //FaultReport
                FaultReport fr = new FaultReport();
                //fr.ID = new int();
                fr.TicketNum = ticketNum;
                //add barcode
                BarCodeServ.BarCodeSoapClient bc = new BarCodeServ.BarCodeSoapClient();

                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 = bc.GenerateBarCode(barCodeData, randumNum.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));


                //end of barcode method
                fr.Barcode   = imgBarcode;
                fr.ProductID = pid;
                fr.AccountID = accountID;
                new FaultsServ.FaultReportLogServiceClient().Create(fr);

                //FaultLog
                FaultReport details = new FaultsServ.FaultReportLogServiceClient().getFaultReportIDByAccountIDTicket(accountID, ticketNum);

                FaultLog fl = new FaultLog();
                fl.Status        = "Reported";
                fl.Description   = fm.Description;
                fl.DateReport    = System.DateTime.Now;
                fl.FaultReportID = details.ID;

                new FaultsServ.FaultReportLogServiceClient().CreateLog(fl);
                SendEmailToClient(accountID, image, pid, memStream, Convert.ToInt32(fr.TicketNum));
                //SendEmailToClient(accountID, memStream,pid);
                return(RedirectToAction("Index", "Warranty"));
            }
            else
            {
                //show error
                ViewBag.Msg = "An error was encountered during the generation of the ticket";
            }
            return(RedirectToAction("Index", "Warranty"));
            //}
            //catch (Exception ex)
            //{
            //    TempData["CatchError"] = "An error was encountered. Please try again later";
            //    return RedirectToAction("Index", "Warranty");
            //}
        }
Ejemplo n.º 14
0
        public async Task <ActionResult> FaultFinish(FaultFinishViewModel model)
        {
            try
            {
                var teknisyen = await NewUserStore()
                                .FindByIdAsync(HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId());

                var fault     = new FaultRepo().GetById(model.FaultID);
                var operatorr = await NewUserStore().FindByIdAsync(fault.OperatorId);

                var customer = await NewUserStore().FindByIdAsync(fault.CustomerId);

                if (teknisyen != null && model.faultState == FaultState.Completed)
                {
                    fault.FaultState            = model.faultState;
                    fault.FaultResultDate       = DateTime.Now;;
                    fault.TechnicianDescription = model.TechnicianDescription;
                    fault.haveJob         = false;
                    fault.TechnicianState = TechnicianState.Bosta;
                    new FaultRepo().Update(fault);
                    var Log = new FaultLog
                    {
                        TechnicianId         = fault.TechnicianId,
                        CustomerId           = fault.CustomerId,
                        Operation            = fault.FaultState.ToString(),
                        FaultId              = fault.FaultID,
                        OperationDescription = fault.FaultDescription
                    };
                    new FaultLogRepo().Insert(Log);
                    TempData["message"] =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.";
                    string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                     (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);

                    var emailService = new EmailService();
                    var body         =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "İş Durumu"
                    },
                                                 operatorr.Email);

                    var bodyy =
                        $"{fault.FaultID} no'lu arızanız {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilmiştir.<br>Bizi tercih ettiğiniz için teşekkür ederiz";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = bodyy, Subject = "İş Durumu"
                    },
                                                 customer.Email);
                }
                else if (teknisyen != null && model.faultState == FaultState.Pending)
                {
                    fault.FaultState = model.faultState;
                    new FaultRepo().Update(fault);
                    TempData["message"] =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilememiştir.";
                    string SiteUrl = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                     (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
                    var emailService = new EmailService();
                    var body         =
                        $"{fault.FaultID} no'lu arıza {teknisyen.Name + " " + teknisyen.Surname} isimli teknisyen tarafından giderilememiştir.<br>Açıklama:{model.TechnicianDescription} ";
                    await emailService.SendAsync(new IdentityMessage()
                    {
                        Body = body, Subject = "İş Durumu"
                    },
                                                 operatorr.Email);
                }
                else
                {
                    throw new Exception("İşlemi bitirirken hata oluştu");
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            return(RedirectToAction("Index", "Technician", model));
        }