From : Batiashvili Zurab <zbatiashvili@moh.gov.ge>
To : Dimitry Alkhazov <dalkhazov@moh.gov.ge>
Subject : rs.ge web-service
Received On : 08.05.2015 09:49
Attachments :

url : http://services.rs.ge/WayBillService/WayBillService.asmx

 

private ZednadebisAtvirtvisShedegisModel AtvirteZednadebi_V02(ShidaBrunvisZednadebiPrintModeli zednadebi,

            string userName, string userPassword, string iP, int rSUserId, int rSUnId)

        {

            // const string su = "zurabbat:202178927";

            var su = userName.ToUpper();

            //const string sp = "123456";

            var sp = userPassword;

            int erteulisInt;

            var transportirebit = zednadebi.Manqana != "AAA000" & zednadebi.Shoferi != "00000000000";

 

            using (var cl = new sr_RS.WayBillsSoapClient())

            {

                var zednadebisTipebi = new Infrastruqtura.RS.RS_Enumebi().ZednadebisTipebi;

                var xmlNode = new XElement(

                    new XElement("WAYBILL",

                        new XElement("SUB_WAYBILLS", ""),

                        new XElement("ID", "0"),

                        new XElement("TYPE", "1"), // "შიდა გადაზიდვა"

                        new XElement("BUYER_TIN", "202178927"), //zednadebi.MimgebiObiektiTAX.Trim()

                        new XElement("CHEK_BUYER_TIN", "1"),

                        new XElement("BUYER_NAME", "სსიპ სოციალური მომსახურების სააგენტო" /* zednadebi.MimgebiObiekti */),

                        new XElement("START_ADDRESS", zednadebi.GamcemiObiektisMisamarti),

                        new XElement("END_ADDRESS", zednadebi.MimgebiObiektiMisamarti),

                        new XElement("DRIVER_TIN", transportirebit ? zednadebi.Shoferi : ""), // ********     roca transportirebitaaa

                        new XElement("CHEK_DRIVER_TIN", "1"),

                        new XElement("DRIVER_NAME", ""),

                        new XElement("TRANSPORT_COAST", "0"),

                        new XElement("RECEPTION_INFO", zednadebi.GamcemiObiekti),

                        new XElement("RECEIVER_INFO", zednadebi.MimgebiObiekti),

                        new XElement("DELIVERY_DATE", string.Format("{0:yyyy-MM-dd}T18:00:15", zednadebi.OperaciisTarigi)),

                        new XElement("STATUS", "1"),

                        new XElement("SELER_UN_ID", rSUnId), //"1149251"),// 1149251 rSUserId

                        new XElement("PAR_ID", ""),

                        new XElement("FULL_AMOUNT", zednadebi.InvoisisFasi.ToString()),

                        new XElement("CAR_NUMBER", transportirebit ? zednadebi.Manqana : ""), //************ roca transportirebitaaa

                        new XElement("S_USER_ID", rSUserId), //"31888"), //1149251 rSUserId

                        new XElement("BEGIN_DATE", string.Format("{0:yyyy-MM-dd}T09:30:15", zednadebi.OperaciisTarigi)),

                        new XElement("TRAN_COST_PAYER", "1"),

                        new XElement("TRANS_ID", transportirebit ? "1" : "4"), // 1 - საავტომობილო , 4 - სხვა

                        new XElement("TRANS_TXT", transportirebit ? "" : "სხვა"),

                        new XElement("COMMENT", "")

                    ));

                var xGoogs = new XElement("GOODS_LIST");

                foreach (var camali in zednadebi.ZednadebisCamlebi)

                {

                    xGoogs.Add(new XElement("GOODS",

                                            new XElement("ID", "0"),

                                            new XElement("W_NAME", camali.CamlisDasaxeleba),

                                            new XElement("UNIT_ID", //"99"

                                                Enum.IsDefined(typeof(RS_Enumebi.ZednadebisZomisErteulebi), camali.ZomisErteuli.Trim()) ? (int)

                                                                                    (RS_Enumebi.ZednadebisZomisErteulebi)Enum.Parse(typeof(RS_Enumebi.ZednadebisZomisErteulebi), camali.ZomisErteuli.Trim(), true) : 99

                    ),

                                            new XElement("UNIT_TXT", camali.ZomisErteuli.Trim()),

                                            new XElement("QUANTITY", camali.Raodenoba),

                                            new XElement("PRICE", camali.ErteulisFasi),

                                            new XElement("STATUS", "1"),

                                            new XElement("AMOUNT", camali.SulFasi),

                                            new XElement("BAR_CODE", ""),

                                            new XElement("A_ID", "0"),

                                            new XElement("VAT_TYPE", "1")));

                }

                xmlNode.Add(xGoogs);

                var shedegi = cl.save_waybill(su, sp, xmlNode);

                var rrr = shedegi.Element("STATUS") == null ? "NULL" : shedegi.Element("STATUS").Value;

 

                if (rrr != "0")

                {

                    var stream = GetType().Assembly.GetManifestResourceStream("Camlebi.Infrastruqtura.RS.RS_Error_List.xml");

                    var atvirtvisShedegi =

                        (from x in XElement.Load(stream).Elements("ERROR_CODE")

                         where x.Element("ID").Value == rrr

                         select x).First().Element("TEXT").Value;

                    return new ZednadebisAtvirtvisShedegisModel()

                    {

                        Shecdoma = atvirtvisShedegi,

                        Status = int.Parse(rrr),

                        ZednadebisNomeri = "0"

                    };

                }

 

                return new ZednadebisAtvirtvisShedegisModel()

                {

                    Shecdoma = "აიტვირთა წარმატებით",

                    Status = int.Parse(rrr),

                    ZednadebisNomeri = shedegi.Element("WAYBILL_NUMBER").Value

                };

            }

        }

 

 

public RS_User MomeciRSUseri(int userId)

        {

            using (var db = new dbCamlebiDataContext())

            {

                return db.VW_RS_USERs

                    .Where(x => x.ID == userId)

                    .Select(x => new RS_User()

                        {

                            UserName = x.RS_USER_NAME,

                            UserPassword = x.RS_PASSWORD,

                            UserId = x.RS_USER_ID.Value,

                            IP = x.IP,

                            RSUnId = x.RS_UN_ID.Value,

                            RSUserId = x.RS_USER_ID.Value

                        })

                        .FirstOrDefault();

            }

        }