Example #1
0
        public string TekSostojba(string embs)
        {
            try
            {
                InteropFault faultException;

                #region ValidationErrors

                if (string.IsNullOrEmpty(embs))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'ЕМБС' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException,
                                                            faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (!string.IsNullOrEmpty(embs) && embs.Length != 7)
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Вредноста на параметарот 'ЕМБС' е надвор од дозволениот опсег!");
                    throw new FaultException <InteropFault>(faultException,
                                                            faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                #endregion

                #region LogicBeforeCallingService

                var xdoc = new XDocument(
                    new XElement("CrmRequest",
                                 new XAttribute("ProductName", "LECViewForAKN"),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVLEInfo"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVUnits"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVActors"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVOwners"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVActivities"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVMembership"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID"))),
                                 new XElement("Parameters", new XAttribute("TemplateName", "CVFounding"),
                                              new XElement("Parameter", embs, new XAttribute("Name", "@LEID")))
                                 )
                    );
                var xmldoc = new XmlDocument();
                using (var xmlReader = xdoc.CreateReader())
                {
                    xmldoc.Load(xmlReader);
                }
                var certUser = WebConfigurationManager.AppSettings["MyCertificateUserProduction"];
                var store    = new X509Store(StoreName.My, StoreLocation.LocalMachine);
                store.Open(OpenFlags.ReadOnly);

                var certificate = store.Certificates
                                  .Find(X509FindType.FindBySubjectName, certUser, false)
                                  .OfType <X509Certificate2>()
                                  .First();
                var param = SignXml(xmldoc, certificate);

                #endregion

                #region CallingInstitutionService

                var outDoc = new XmlDocument();
                var client = new CRM_TS_AKN_Prod_NaTest.CRM_TS_AKNClient();
                var output = client.Get_TS_AKN(param);

                outDoc.LoadXml(output);
                var signatureNode = (XmlElement)outDoc.DocumentElement.SelectSingleNode("//*[local-name()='Signature']");
                signatureNode.ParentNode.RemoveChild(signatureNode);

                #endregion

                return(outDoc.OuterXml);
            }
            catch (FaultException <InteropFault> )
            {
                throw;
            }
            catch (EndpointNotFoundException ex)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", ex.Message);
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (Exception ex)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Настана грешка во адаптерот или при повикување на сервисот на институцијата:", ex.Message);
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
        }
Example #2
0
        public Contracts.DTO_s.AKNService.dzgr GetPropertyList(string username, string password, string opstina, string katastarskaOpstina, string brImotenList)
        {
            try
            {
                InteropFault faultException;

                #region ValidationErrors

                if (String.IsNullOrEmpty(username))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'корисничко име' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(password))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'лозинка' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(opstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(katastarskaOpstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'катастарска општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(brImotenList))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'број на имотен лист' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                #endregion

                #region CallingInstitutionService

                System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);//sertifikatot ne im e u red za toa go stavam ova za da go ignorira
                var aknClient = new Service_MACEDONIAN_CADASTRESoapClient();
                var output    = aknClient.ReturnImotenList_3(username, password, opstina, katastarskaOpstina, brImotenList);

                #endregion

                #region LogicAfterCallingInstitutionService

                if (output.nizobj == null && output.nizpar == null && output.nizsop == null && output.niztov == null)
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", "Не постојат податоци за внесените параметри. " + output.message);
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (output.nizsop != null && (output.nizpar != null && (output.nizobj != null && (output.nizobj.Count == 0 && output.nizpar.Count == 0 && output.nizsop.Count == 0 && output.niztov.Count == 0))))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", output.message);
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                var loads   = new List <Loads>();
                var objects = new List <Objects>();
                var owners  = new List <Owner>();
                var parcels = new List <Parcel>();
                if (output.niztov != null)
                {
                    foreach (var tovar in output.niztov)
                    {
                        var tov = new Loads {
                            text = tovar.text
                        };
                        loads.Add(tov);
                    }
                }
                if (output.nizobj != null)
                {
                    foreach (var obj in output.nizobj)
                    {
                        var objectItem = new Objects
                        {
                            broj         = obj.broj,
                            objekt       = obj.objekt,
                            vlez         = obj.vlez,
                            kat          = obj.kat,
                            stan         = obj.stan,
                            namena       = obj.namena,
                            mesto        = obj.mesto,
                            povrsina     = obj.povrsina,
                            godinagradba = obj.godinagradba,
                            osnov        = obj.osnov,
                            pravo        = obj.pravo
                        };
                        objects.Add(objectItem);
                    }
                }
                if (output.nizsop != null)
                {
                    foreach (var sopstvenik in output.nizsop)
                    {
                        var owner = new Owner
                        {
                            embg  = sopstvenik.embg,
                            ime   = sopstvenik.ime,
                            mesto = sopstvenik.mesto,
                            ulica = sopstvenik.ulica,
                            broj  = sopstvenik.broj,
                            del   = sopstvenik.del
                        };
                        owners.Add(owner);
                    }
                }
                if (output.nizpar != null)
                {
                    foreach (var parcela in output.nizpar)
                    {
                        var parcel = new Parcel
                        {
                            broj_del = parcela.broj_del,
                            objekt   = parcela.objekt,
                            mesto    = parcela.mesto,
                            kultura  = parcela.kultura,
                            klasa    = parcela.klasa,
                            povrsina = parcela.povrsina,
                            pravo    = parcela.pravo
                        };
                        parcels.Add(parcel);
                    }
                }
                var propertyList = new Contracts.DTO_s.AKNService.dzgr
                {
                    ops     = output.ops,
                    kops    = output.kops,
                    ilist   = output.ilist,
                    niztov  = loads,
                    nizobj  = objects,
                    nizsop  = owners,
                    nizpar  = parcels,
                    data    = output.data,
                    message = output.message,
                };

                #endregion

                return(propertyList);
            }
            catch (FaultException <InteropFault> )
            {
                throw;
            }
            catch (TimeoutException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (EndpointNotFoundException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (Exception ex)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Настана грешка во адаптерот или при повикување на сервисот на институцијата:", ex.Message);
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
        }
        public AKNDocOutput GetIFDoc(string opstina, string katastarskaOpstina, string brImotenList, string brParcela, bool showEmb)
        {
            try
            {
                InteropFault faultException;

                #region ValidationErrors

                if (String.IsNullOrEmpty(opstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(katastarskaOpstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'катастарска општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(brImotenList))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'број на имотен лист' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                #endregion

                #region CallingInstitutionService

                var output = new AKNDocOutput();
                var client = new IntegracijaWSImplClient();
                var info   = client.getPlistInfo(opstina, katastarskaOpstina, brImotenList, brParcela, "0");

                #endregion

                #region LogicAfterCallingInstitutionService

                if (string.IsNullOrEmpty(info.idPtype))//2005
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", "Не постои предбележување на градба за дадените параметри!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                var show    = showEmb ? "1" : "0";
                var docInfo = client.generateDocument(opstina, katastarskaOpstina, brImotenList, brParcela, show, "2005");//2005 лист предбележување
                if (docInfo.errmsg == null)
                {
                    using (var sftp = new SftpClient(Host, Port, Username, Password))
                    {
                        sftp.Connect();
                        if (!sftp.IsConnected)
                        {
                            faultException = FaultExceptionHelper.CreateFaultException("Грешка во FTP клиентот.", "Не може да се воспостави конекција со FTP серверот!");
                            throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                        }
                        string filePath = docInfo.filePath + "//" + docInfo.fileName;
                        if (sftp.Exists(filePath))
                        {
                            byte[] arr = sftp.ReadAllBytes(filePath);
                            output.Document    = arr;
                            output.HasDocument = true;
                            output.Message     = "Сервисот на институцијата врати порака: Успешна операција!";
                        }
                        else
                        {
                            faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", "Не постои таков документ!");
                            throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                        }
                        sftp.Disconnect();
                    }
                }
                else
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата. Не е пронајден таков документ!", docInfo.errmsg);
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                #endregion

                return(output);
            }
            catch (FaultException <InteropFault> )
            {
                throw;
            }
            catch (TimeoutException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (EndpointNotFoundException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (Exception ex)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Настана грешка во адаптерот или при повикување на сервисот на институцијата:", ex.Message);
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
        }
Example #4
0
        public Contracts.DTO_s.AKNService.ATRparceli GetCParcel(string username, string password, string opstina, string katastarskaOpstina, string brParcela)
        {
            try
            {
                InteropFault faultException;

                #region ValidationErrors

                if (String.IsNullOrEmpty(username))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'корисничко име' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(password))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'лозинка' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(opstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(katastarskaOpstina))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'катастарска општина' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (String.IsNullOrEmpty(brParcela))
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Параметарот 'број на катастарска парцела' е задолжителен!");
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }

                #endregion

                #region CallingInstitutionService

                //System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);//sertifikatot ne im e u red za toa go stavam ova za da go ignorira
                var aknClient = new Service_MACEDONIAN_CADASTRESoapClient();
                var output    = aknClient.ReturnParcela_7(username, password, opstina, katastarskaOpstina, brParcela);

                #endregion

                #region LogicAfterCallingInstitutionService

                if (output.nizpar == null)
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", "Не постојат податоци за внесените параметри. " + output.message);
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                if (output.nizpar.Count == 0)
                {
                    faultException = FaultExceptionHelper.CreateFaultException("Грешка во сервисот на институцијата.", output.message);
                    throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
                }
                var attributes = new List <ParcelAtr>();
                foreach (var parcel in output.nizpar)
                {
                    var attribute = new ParcelAtr()
                    {
                        ops      = parcel.ops,
                        kops     = parcel.kops,
                        ilist    = parcel.ilist,
                        broj_del = parcel.broj_del,
                        objekt   = parcel.objekt,
                        mesto    = parcel.mesto,
                        kultura  = parcel.kultura,
                        povrsina = parcel.povrsina,
                        pravo    = parcel.pravo
                    };
                    attributes.Add(attribute);
                }
                var cadastralParcelDto = new Contracts.DTO_s.AKNService.ATRparceli
                {
                    nizpar  = attributes,
                    message = output.message
                };
                return(cadastralParcelDto);

                #endregion
            }
            catch (FaultException <InteropFault> )
            {
                throw;
            }
            catch (TimeoutException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (EndpointNotFoundException)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Адаптерот на сервисот врати грешка.", "Конекцијата до АКН сервисот не може да се воспостави.");
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
            catch (Exception ex)
            {
                InteropFault faultException = FaultExceptionHelper.CreateFaultException("Настана грешка во адаптерот или при повикување на сервисот на институцијата:", ex.Message);
                throw new FaultException <InteropFault>(faultException, faultException.ErrorMessage + " " + faultException.ErrorDetails);
            }
        }