Exemplo n.º 1
0
        /// <summary>
        /// GetTpUserInfo call
        /// </summary>
        /// <remarks>
        /// Either returns a valid response or a fault information
        /// </remarks>
        public virtual GetTpUserInfoResponse GetTpUserInfo(
            string sessionIndex,
            out FaultModel fault)
        {
            if (string.IsNullOrEmpty(sessionIndex))
            {
                throw new ArgumentNullException("sessionIndex");
            }
            fault = null;

            // request
            var request =
                new GetTpUserInfoRequest()
            {
                TgSid = sessionIndex,
                SystemOrganisationId = "0"
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <GetTpUserInfoRequest, GetTpUserInfoResponse, GetTpUserInfoResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 2
0
        public override void OnException(ExceptionContext context)
        {
            _logger.LogDebug("Start - ExceptionHandlerFilter - OnException");

            base.OnException(context);

            var fault = new FaultModel
            {
                Id     = Guid.NewGuid().ToString(),
                Status = (short)HttpStatusCode.InternalServerError,
                Title  = "Some kind of error occured in the API. Please use the id and contact out " +
                         "support team if the problem persits."
            };

            var innerExMessage = GetInnerMostExceptionMessage(context.Exception);

            _logger.LogError(context.Exception, innerExMessage + $" -- {fault.Id}");

            context.ExceptionHandled = true;
            var result = JsonConvert.SerializeObject(fault);

            context.HttpContext.Response.ContentType = "application/json";
            context.HttpContext.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;
            context.HttpContext.Response.WriteAsync(result);

            _logger.LogDebug("End - ExceptionHandlerFilter - OnException");
        }
Exemplo n.º 3
0
 private void CompareExpectedResult(FaultModel result, bool isCurrentActive)
 {
     // Validate response
     Assert.Equal(result.Properties.FaultId, Guid.Parse("c8e6bfe487b4b8eceb5dc36ff6a24521"));
     Assert.Equal(result.Properties.ActivatedTime, DateTime.Parse("2015-05-18T18:02:00Z", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind));
     Assert.Equal(result.Properties.Description, "TBD");
     Assert.Equal(result.Properties.FaultRuleName, "faultRule1");
     Assert.Equal(result.Properties.ResolutionText, "TBD");
     if (isCurrentActive)
     {
         Assert.Equal(result.Properties.ResolvedTime, null);
     }
     else
     {
         Assert.Equal(result.Properties.ResolvedTime, DateTime.Parse("2015-05-18T18:04:00Z", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind));
     }
     Assert.Equal(result.Properties.ResourceUri, "/subscriptions/serviceAdmin/resourceGroups/system/providers/Microsoft.Storage.Admin/farms/WEST_US_1/tableserverinstances/woss-node1");
     Assert.Equal(result.Properties.Severity, Severity.Critical);
     if (isCurrentActive)
     {
         Assert.Equal(result.Properties.AssociatedDataType, AssociatedDataType.Metrics);
         Assert.Equal(result.Properties.AssociatedMetricsName, "MetricsName");
     }
     else
     {
         Assert.Equal(result.Properties.AssociatedDataType, AssociatedDataType.Event);
         var eventQuery = result.Properties.AssociatedEventQuery;
         EventQueryResultValidator.ValidateGetEventQueryResult(eventQuery);
     }
 }
        /// <summary>
        /// GetSignedDocument call
        /// </summary>
        public virtual VerifySignedDocument5Response VerifySignedDocument(
            byte[] document,
            out FaultModel fault)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }

            fault = null;

            // request
            var request =
                new VerifySignedDocument5Request()
            {
                Document = document
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <VerifySignedDocument5Request, VerifySignedDocument5Response, VerifySignedDocument5ResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
        /// <summary>
        /// TrustedProfileInfoForPESEL call
        /// </summary>
        /// <remarks>
        /// Either returns a valid response or a fault information
        /// </remarks>
        public virtual TrustedProfileInfoForPESELResponse TrustedProfileInfoForPESEL(
            string PESEL,
            ProfileInfoEnum profileInfo,
            out FaultModel fault)
        {
            if (string.IsNullOrEmpty(PESEL))
            {
                throw new ArgumentNullException("PESEL");
            }
            fault = null;

            // request
            var request =
                new TrustedProfileInfoForPESELRequest()
            {
                PESEL       = PESEL,
                ProfileInfo = profileInfo
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <TrustedProfileInfoForPESELRequest, TrustedProfileInfoForPESELResponse, TrustedProfileInfoForPESELResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
        /// <summary>
        /// GetSignedDocument call
        /// </summary>
        public virtual GetSignedDocument5Response GetSignedDocument(
            string id,
            out FaultModel fault)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }

            fault = null;

            // request
            var request =
                new GetSignedDocument5Request()
            {
                Id = id
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <GetSignedDocument5Request, GetSignedDocument5Response, GetSignedDocument5ResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
        /// <summary>
        /// Interfejs służy do pobierania załącznika/dokumentu z repozytorium plików
        /// </summary>
        /// <param name="fileId">Identyfikator pliku/załącznika</param>
        public virtual DownloadFileResponse DownloadFile(
            string fileId,
            string podmiot,
            out FaultModel fault
            )
        {
            // validation
            if (string.IsNullOrEmpty(fileId))
            {
                throw new ArgumentNullException("fileId");
            }

            //string queryString = new System.Uri(fileId).Query;
            //var queryDictionary = System.Web.HttpUtility.ParseQueryString(queryString);

            var request = new DownloadFileRequest()
            {
                //mozna podac caly link
                //FileId = queryDictionary["fileId"],
                FileId  = fileId,
                Subject = podmiot
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <DownloadFileRequest, DownloadFileResponse, DownloadFileResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 8
0
        public AddDocumentToSigningResponse FromSOAP(string soapResponse, out FaultModel fault)
        {
            fault = null;

            if (string.IsNullOrEmpty(soapResponse))
            {
                throw new ArgumentNullException();
            }

            try
            {
                var xd = new XmlDocument();
                xd.LoadXml(soapResponse);

                var nsManager = new XmlNamespaceManager(xd.NameTable);
                nsManager.AddNamespace("ns1", Namespaces.COMARCH_SIGN);

                var response = xd.SelectSingleNode("//ns1:addDocumentToSigningResponse", nsManager) as XmlElement;
                if (response != null)
                {
                    // tak zwraca TpSigning
                    var serializer = new XmlSerializer(typeof(AddDocumentToSigningResponse));
                    using (var reader = new StringReader(response.OuterXml))
                    {
                        return(serializer.Deserialize(reader) as AddDocumentToSigningResponse);
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw new ServiceClientException("Cannot deserialize AddDocumentToSigning", ex);
            }
        }
        /// <summary>
        /// Interfejs służy do umieszczenia dowolnego dokumentu w podanej skrzynce
        /// </summary>
        public virtual DodajDokumentResponse DodajDokument(
            Sklad sklad,
            Dokument dokument,
            out FaultModel fault
            )
        {
            // validation
            if (sklad == null || string.IsNullOrEmpty(sklad.Nazwa) || string.IsNullOrEmpty(sklad.Podmiot))
            {
                throw new ArgumentNullException("sklad");
            }
            if (dokument == null || dokument.Tresc == null)
            {
                throw new ArgumentNullException("dokument");
            }

            var request = new DodajDokumentRequest()
            {
                Sklad    = sklad,
                Dokument = dokument
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <DodajDokumentRequest, DodajDokumentResponse, DodajDokumentResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
        public TrustedProfileInfoForPESELResponse FromSOAP(string soapEnvelope, out FaultModel fault)
        {
            fault = null;

            if (string.IsNullOrEmpty(soapEnvelope))
            {
                throw new ArgumentNullException();
            }

            try
            {
                var xml = new XmlDocument();
                xml.LoadXml(soapEnvelope);

                var serializer = new XmlSerializer(typeof(TrustedProfileInfoForPESELResponse));
                var nsManager  = new XmlNamespaceManager(xml.NameTable);
                nsManager.AddNamespace("ns3", Namespaces.OBJECTINFO);

                var response = xml.SelectSingleNode("//ns3:respTrustedProfileInfoForPESEL", nsManager) as XmlElement;
                if (response != null)
                {
                    using (var reader = new StringReader(response.OuterXml))
                    {
                        return(serializer.Deserialize(reader) as TrustedProfileInfoForPESELResponse);
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw new ServiceClientException("Cannot deserialize GetTpUserInfoResponse", ex);
            }
        }
Exemplo n.º 11
0
        public ActionResult Edit(TamTruModel model)
        {
            if (ModelState.IsValid)
            {
                string user = User.Identity.Name.ToString();
                try
                {
                    proxy.Updatetamtru(model.MaTamTru, model.SelectedTypeValue, model.SelectedGiayToValue, model.SelectedLiDoValue, model.SelectedQuocTichValue, model.SelectedStatusValue, model.TT_FullName, model.TT_DiaChiThuongTru, model.TT_DiaChiTamTru, model.TT_NgayDen, model.TT_NgayDi, model.TT_Room, model.TT_GiayTo, model.TT_LiDoKhac, user);
                }
                catch (FaultException <FaultOutOfMemory> cex)
                {
                    FaultModel fault = new FaultModel();
                    fault.Issue  = cex.Message;
                    fault.Detail = cex.Reason.ToString();
                    return(View("fault", fault));
                }

                return(RedirectToAction("Details", new { id = model.MaTamTru }));
            }
            ViewData["GiayTo"]   = new SelectList(proxy.getAllGiayTo(), "ID_GiayTo", "GiayTo", model.SelectedGiayToValue);
            ViewData["LiDo"]     = new SelectList(proxy.getAllLiDo(), "ID_LiDo", "LiDo", model.SelectedLiDoValue);
            ViewData["QuocTich"] = new SelectList(proxy.getAllQuocTich(), "ID_QuocTich", "QuocTich", model.SelectedQuocTichValue);
            ViewData["Status"]   = new SelectList(proxy.getAllStatus(), "ID_Status", "Status", model.SelectedStatusValue);
            ViewData["Type"]     = new SelectList(proxy.getAllType(), "ID_Type", "Type", model.SelectedTypeValue);
            return(View());
        }
Exemplo n.º 12
0
 public IActionResult Create(FaultCreateViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             FaultModel fault = new FaultModel()
             {
                 Description       = viewModel.Description,
                 VehicleId         = viewModel.VehicleId,
                 AddDateTime       = DateTime.Now,
                 Status            = "Nowa",
                 Action            = null,
                 UserId            = _userManager.GetUserId(User),
                 AddDateTimeString = DateTime.Now.ToString("g")
             };
             _faultService.Create(fault);
             return(RedirectToAction("Confirm", new { id = fault.Id }));
         }
         catch
         {
             return(View(viewModel));
         }
     }
     else
     {
         return(View(viewModel));
     }
 }
        /// <summary>
        /// Interfejs służy do nadawania (przedkladania) dokumentów XML na skrytkę
        /// </summary>
        /// <param name="podmiot">Identyfikator podmiotu w kontekście ktorego nadawany jest dokument</param>
        /// <param name="adresSkrytki">Adres skrytki odbiorcy</param>
        /// <param name="adresOdpowiedzi">Adres skrytki nadawcy na ktory mają być przesyłane odpowiedzi w sprawie</param>
        /// <param name="czyProbne">Określa czy to jest nadanie próbne, jedynie w celu sprawdzenia poprawności dokumentu i adresu; przy nadawaniu probnym dokument nie jest przekazywany do odbiorcy ani nie jest wystawiane UPP</param>
        /// <param name="daneDodatkowe">Dodatkowe dane w formacie XML</param>
        /// <param name="dokument">Przesyłany dokument wraz z ewentualnymi załącznikami</param>
        public virtual NadajResponse Nadaj(
            string podmiot,
            string adresSkrytki,
            string adresOdpowiedzi,
            bool czyProbne,
            byte[] daneDodatkowe,
            DocumentType dokument,
            out FaultModel fault
            )
        {
            // validation
            if (string.IsNullOrEmpty(podmiot))
            {
                throw new ArgumentNullException("podmiot");
            }
            if (string.IsNullOrEmpty(adresSkrytki))
            {
                throw new ArgumentNullException("adresSkrytki");
            }
            if (string.IsNullOrEmpty(adresOdpowiedzi))
            {
                throw new ArgumentNullException("adresOdpowiedzi");
            }
            if (dokument == null)
            {
                throw new ArgumentException("dokument");
            }
            if (string.IsNullOrEmpty(dokument.NazwaPliku))
            {
                throw new ArgumentException("dokument");
            }
            if (string.IsNullOrEmpty(dokument.TypPliku))
            {
                throw new ArgumentException("dokument");
            }
            if (dokument.Zawartosc == null)
            {
                throw new ArgumentException("dokument");
            }

            var request = new NadajRequest()
            {
                DaneDodatkowe   = daneDodatkowe,
                CzyProbne       = czyProbne,
                AdresOdpowiedzi = adresOdpowiedzi,
                AdresSkrytki    = adresSkrytki,
                PodmiotNadawcy  = podmiot,
                Document        = dokument
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <NadajRequest, NadajResponse, NadajResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 14
0
        public ActionResult Register(RegisterModel model)
        {
            // CustomException exex = new CustomException();

            bool chkUsername = proxy.checkUsernameExist(model.UserName);
            bool chkEmail    = proxy.checkEmailExist(model.Email);

            //if (chkUsername == true)
            //{
            //    ModelState.AddModelError("UserName", "Tên Đăng Nhập Này Đã Có Người Dùng !!!");
            //    ViewBag.province = new SelectList(proxy.getAllProvince(), "ProvinceID", "ProvinceName");
            //    ViewBag.district = new SelectList(proxy.getAllDistrict(), "DistrictID", "DistrictName");
            //    ViewBag.detail = new SelectList(proxy.getAllDetailProvince(), "DetailID", "DetailName");
            //    return View();
            //}

            if (chkEmail == true)
            {
                ModelState.AddModelError("Email", "Email Này Đã Có Người Dùng !!!");
                ViewBag.province = new SelectList(proxy.getAllProvince(), "ProvinceID", "ProvinceName");
                ViewBag.district = new SelectList(proxy.getAllDistrict(), "DistrictID", "DistrictName");
                ViewBag.detail   = new SelectList(proxy.getAllDetailProvince(), "DetailID", "DetailName");
                return(View());
            }
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                try
                {
                    proxy.InsertUser(model.UserName, model.Password, model.Email, model.SelectedProvinceValue, model.SelectedDistrictValue, model.SelectedDetailProvincesValue, 0, model.question, model.answear, model.Companyname, model.BusinessCode, model.Phone, model.Mobile, model.CMND, model.Name, model.Age, model.Address, model.subAddress);
                }
                catch (FaultException <CustomException> cex)
                {
                    FaultModel fault = new FaultModel();
                    fault.Issue  = cex.Message;
                    fault.Detail = cex.Reason.ToString();
                    return(View("fault", fault));
                }
                createStatus = MembershipCreateStatus.Success;

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return(RedirectToAction("Index", "Home"));
                }
                else            // If we got this far, something failed, redisplay form
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }


            return(View(model));
        }
Exemplo n.º 15
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));
            }
        }
Exemplo n.º 16
0
        // PUT: api/Faults/5
        public void Put(int id, [FromBody] FaultDataModel value)
        {
            var service = new FaultService();
            var result  = new FaultModel()
            {
                id_mieszkania = value.id_mieszkania,
                id_usterki    = value.id_usterki,
                opis          = value.opis,
                stan          = value.stan
            };

            service.AddOrEditFault(result);
        }
        /// <summary>
        /// AddDocumentToSigning call
        /// </summary>
        public virtual AddDocumentToSigning5Response AddDocumentToSigning(
            byte[] document,
            string urlSuccess,
            string urlFailed,
            string additionalInfo,
            out FaultModel fault)
        {
            if (document == null)
            {
                throw new ArgumentNullException("document");
            }
            if (string.IsNullOrEmpty(urlSuccess))
            {
                throw new ArgumentNullException("urlSuccess");
            }
            if (string.IsNullOrEmpty(urlFailed))
            {
                throw new ArgumentNullException("urlFailed");
            }
            if (string.IsNullOrEmpty(additionalInfo))
            {
                throw new ArgumentNullException("additionalInfo");
            }

            fault = null;

            // request
            var request =
                new AddDocumentToSigning5Request()
            {
                Doc            = document,
                SuccessUrl     = urlSuccess,
                FailureUrl     = urlFailed,
                AdditionalInfo = additionalInfo
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <AddDocumentToSigning5Request, AddDocumentToSigning5Response, AddDocumentToSigning5ResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Interfejs służy do potwierdzania prawidłowego odbioru dokumentu przez system zewnętrzny oraz usuwania dokumentu z kolejki oczekujących na pobranie.
        /// </summary>
        /// <param name="podmiot">Identyfikator podmiotu</param>
        /// <param name="nazwaSkrytki">Nazwa sprawdzanej skrytki</param>
        /// <param name="adresSkrytki">Adres sprawdzanej skrytki</param>
        /// <param name="skrot">Obliczony skrot SHA-1 odebranego dokumentu</param>
        public virtual PotwierdzOdebranieResponse PotwierdzOdebranie(
            string podmiot,
            string nazwaSkrytki,
            string adresSkrytki,
            byte[] skrot,
            out FaultModel fault
            )
        {
            // validation
            if (string.IsNullOrEmpty(podmiot))
            {
                throw new ArgumentNullException("podmiot");
            }
            if (string.IsNullOrEmpty(nazwaSkrytki))
            {
                throw new ArgumentNullException("nazwaSkrytki");
            }
            if (string.IsNullOrEmpty(adresSkrytki))
            {
                throw new ArgumentNullException("adresSkrytki");
            }
            if (skrot == null)
            {
                throw new ArgumentNullException("skrot");
            }

            var request = new PotwierdzOdebranieRequest()
            {
                Podmiot      = podmiot,
                NazwaSkrytki = nazwaSkrytki,
                AdresSkrytki = adresSkrytki,
                Skrot        = skrot
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <PotwierdzOdebranieRequest, PotwierdzOdebranieResponse, PotwierdzOdebranieResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 19
0
        public FaultModel GetSingleStrictFaultDataModel(int faultId)
        {
            var fault = new FaultModel();

            try
            {
                using (var ctx = new DBProjectEntities())
                {
                    var queryResult = ctx.Usterki.Find(faultId);

                    fault = ModelMapper.Mapper.Map <FaultModel>(queryResult);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(fault);
        }
        Task HandleExceptionAsync(HttpContext context, Exception exception)
        {
            var fault = new FaultModel
            {
                Id     = Guid.NewGuid().ToString(),
                Status = (short)HttpStatusCode.InternalServerError,
                Title  = "Some kind of error occured in the API. Please use the id and contact out " +
                         "support team if the problem persits."
            };

            _options.AddResponseDetails?.Invoke(context, exception, fault);

            var innerExMessage = GetInnerMostExceptionMessage(exception);

            _logger.LogError(exception, innerExMessage + $" -- {fault.Id}");

            var result = JsonConvert.SerializeObject(fault);

            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)HttpStatusCode.InternalServerError;
            return(context.Response.WriteAsync(result));
        }
        /// <summary>
        /// Interfejs służy do wysyłania załącznika/dokumentu do repozytorium plików
        /// </summary>
        /// <param name="podmiot">Identyfikator podmiotu</param>
        /// <param name="nazwaSkrytki">Nazwa sprawdzanej skrytki</param>
        /// <param name="adresSkrytki">Adres sprawdzanej skrytki</param>
        public virtual UploadFileResponse UploadFile(
            string file,
            string filename,
            string mimeType,
            string subject,
            out FaultModel fault
            )
        {
            // validation
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentNullException("file");
            }
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }
            if (string.IsNullOrEmpty(mimeType))
            {
                throw new ArgumentNullException("mimeType");
            }

            var request = new UploadFileRequest()
            {
                File     = file,
                Filename = filename,
                MimeType = mimeType,
                Subject  = subject
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <UploadFileRequest, UploadFileResponse, UploadFileResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Interfejs służy do uzyskania informacji o liczbie dokumentów oczekujących na pobranie dla wskazanego podmiotu i adresu skrytki.
        /// </summary>
        /// <param name="podmiot">Identyfikator podmiotu</param>
        /// <param name="nazwaSkrytki">Nazwa sprawdzanej skrytki</param>
        /// <param name="adresSkrytki">Adres sprawdzanej skrytki</param>
        public virtual OczekujaceDokumentyResponse OczekujaceDokumenty(
            string podmiot,
            string nazwaSkrytki,
            string adresSkrytki,
            out FaultModel fault
            )
        {
            // validation
            if (string.IsNullOrEmpty(podmiot))
            {
                throw new ArgumentNullException("podmiot");
            }
            if (string.IsNullOrEmpty(nazwaSkrytki))
            {
                throw new ArgumentNullException("nazwaSkrytki");
            }
            if (string.IsNullOrEmpty(adresSkrytki))
            {
                throw new ArgumentNullException("adresSkrytki");
            }

            var request = new OczekujaceDokumentyRequest()
            {
                Podmiot      = podmiot,
                NazwaSkrytki = nazwaSkrytki,
                AdresSkrytki = adresSkrytki
            };

            // call ePUAP service and parse the response
            var response = WSSecurityRequest <OczekujaceDokumentyRequest, OczekujaceDokumentyResponse, OczekujaceDokumentyResponseHandler>(
                this.ServiceUri,
                request,
                out fault);

            // parsed response
            return(response);
        }
Exemplo n.º 23
0
        //FAULTS
        public bool AddOrEditFault(FaultModel newFaultData)
        {
            if (newFaultData.id_mieszkania == null)
            {
                return(false);       //There's no residence assigned - quite useless fault.
            }
            try
            {
                using (var ctx = new DBProjectEntities())
                {
                    var fault = ctx.Usterki.Find(newFaultData.id_usterki);

                    if (fault == null)
                    {
                        fault = ModelMapper.Mapper.Map <Usterki>(newFaultData);
                        ctx.Usterki.Add(fault);
                    }
                    else
                    {
                        fault.id_usterki    = newFaultData.id_usterki;
                        fault.id_mieszkania = newFaultData.id_mieszkania;
                        fault.opis          = newFaultData.opis;
                        fault.stan          = newFaultData.stan;
                    }

                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
Exemplo n.º 24
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");
            //}
        }
Exemplo n.º 25
0
 private void CompareExpectedResult(FaultModel result, bool isCurrentActive)
 {
     // Validate response 
     Assert.Equal(result.Properties.FaultId, Guid.Parse("c8e6bfe487b4b8eceb5dc36ff6a24521"));
     Assert.Equal(result.Properties.ActivatedTime, DateTime.Parse("2015-05-18T18:02:00Z", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind));
     Assert.Equal(result.Properties.Description, "TBD");
     Assert.Equal(result.Properties.FaultRuleName, "faultRule1");
     Assert.Equal(result.Properties.ResolutionText, "TBD");
     if (isCurrentActive)
         Assert.Equal(result.Properties.ResolvedTime, null);
     else
         Assert.Equal(result.Properties.ResolvedTime, DateTime.Parse("2015-05-18T18:04:00Z", DateTimeFormatInfo.InvariantInfo, DateTimeStyles.RoundtripKind));
     Assert.Equal(result.Properties.ResourceUri, "/subscriptions/serviceAdmin/resourceGroups/system/providers/Microsoft.Storage.Admin/farms/WEST_US_1/tableserverinstances/woss-node1");
     Assert.Equal(result.Properties.Severity, Severity.Critical);
     if (isCurrentActive)
     {
         Assert.Equal(result.Properties.AssociatedDataType, AssociatedDataType.Metrics);
         Assert.Equal(result.Properties.AssociatedMetricsName, "MetricsName");
     }
     else
     {
         Assert.Equal(result.Properties.AssociatedDataType, AssociatedDataType.Event);
         var eventQuery = result.Properties.AssociatedEventQuery;
         EventQueryResultValidator.ValidateGetEventQueryResult(eventQuery);
     }
 }
 public UploadFileResponse FromSOAP(byte[] soapResponse, string content_typeResponse, out FaultModel fault)
 {
     throw new NotImplementedException();
 }
 public UploadFileResponse FromSOAP(string soapResponse, out FaultModel fault)
 {
     return(this.FromSOAP_Template <UploadFileResponse>(soapResponse, out fault));
 }
Exemplo n.º 28
0
 void UpdateApiErrorResponse(HttpContext context, Exception ex, FaultModel fault)
 {
     fault.Links = "https://gethelpforerror.com/";
 }
Exemplo n.º 29
0
 public FaultResponse(FaultModel resource) : base(resource)
 {
 }
Exemplo n.º 30
0
 public DoreczResponse FromSOAP(string soapResponse, out FaultModel fault)
 {
     return(FromSOAP_Template <DoreczResponse>(soapResponse, out fault));
 }
Exemplo n.º 31
0
        public void Put(int id, [FromBody] FaultModel value)
        {
            var service = new FaultService();

            service.AddOrEditFault(value);
        }
Exemplo n.º 32
0
 public FaultResponse(FaultModel resource) : base(resource)
 {
 }
Exemplo n.º 33
0
        public ActionResult Edit(TamTruModel model)
        {
            if (ModelState.IsValid)
            {
                string user = User.Identity.Name.ToString();
                try
                {
                    proxy.Updatetamtru(model.MaTamTru, model.SelectedTypeValue, model.SelectedGiayToValue, model.SelectedLiDoValue, model.SelectedQuocTichValue, model.SelectedStatusValue, model.TT_FullName, model.TT_DiaChiThuongTru, model.TT_DiaChiTamTru, model.TT_NgayDen, model.TT_NgayDi, model.TT_Room, model.TT_GiayTo, model.TT_LiDoKhac, user);
                }
                 catch(FaultException<FaultOutOfMemory> cex)
                {
                    FaultModel fault = new FaultModel();
                    fault.Issue = cex.Message;
                    fault.Detail = cex.Reason.ToString() ;
                    return View("fault", fault);
                }

                return RedirectToAction("Details", new { id = model.MaTamTru });
            }
            ViewData["GiayTo"] = new SelectList(proxy.getAllGiayTo(), "ID_GiayTo", "GiayTo", model.SelectedGiayToValue);
            ViewData["LiDo"] = new SelectList(proxy.getAllLiDo(), "ID_LiDo", "LiDo", model.SelectedLiDoValue);
            ViewData["QuocTich"] = new SelectList(proxy.getAllQuocTich(), "ID_QuocTich", "QuocTich", model.SelectedQuocTichValue);
            ViewData["Status"] = new SelectList(proxy.getAllStatus(), "ID_Status", "Status", model.SelectedStatusValue);
            ViewData["Type"] = new SelectList(proxy.getAllType(), "ID_Type", "Type", model.SelectedTypeValue);
            return View();
        }