Ejemplo n.º 1
0
        private async Task <IActionResult> SaveDocument(JsonSet json)
        {
            try
            {
                var data       = GetFormData(json);
                var jsondata   = JsonConvert.SerializeObject(data);
                var fileName   = GetFileName(json);
                var sourceFile = GetSourceFile(json);

                var keyValues = new Dictionary <string, string>();
                keyValues.Add("jsondata", jsondata);
                keyValues.Add("fileName", fileName);
                keyValues.Add("sourceFile", sourceFile);

                var request = new HttpRequestMessage
                {
                    Method     = HttpMethod.Post,
                    RequestUri = new Uri(_configuration.GetSection("SaveDocumentRequestUrl").Value),
                    Content    = new FormUrlEncodedContent(keyValues)
                };
                request.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36");

                var response = await _httpClient.SendAsync(request);

                response.EnsureSuccessStatusCode();
                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 2
0
        private FormData GetFormData(JsonSet json)
        {
            var formData = new FormData();

            formData.DirectorateName   = json.NAZIV_DIR;
            formData.Number            = json.ARHIVSKI_BR_NAS;
            formData.Date              = json.DATUM;
            formData.EmployeeEmail     = json.EMAIL_RADNIKA;
            formData.ManagerEmail      = json.EMAIL_RUKOVODIOCA;
            formData.SignatoryPosition = json.NAZIV_POTPISNIKA;
            formData.SignatoryFullName = json.POTPISNIK_PREZIME_IME;
            formData.PreambleText      = Preamble.GeneratePreamble(json.ID_ODSUSTVA);
            formData.MainText          = MainText.GenerateMainText(json);
            formData.RationaleText     = Rationale.GenerateRationaleText(json.ID_ODSUSTVA);
            if (json.POL == "Z")
            {
                formData.Deliver = "Zaposlenoj";
            }
            else if (json.POL == "M")
            {
                formData.Deliver = "Zaposlenom";
            }

            return(formData);
        }
        public void Addconfig(String[] args)
        {
            IIPGet  IPGET       = new Netvim();
            JsonSet writeconfig = new JsonSet(args[1], args[2], IPGET.IPGet());

            Console.WriteLine("config add success");
        }
Ejemplo n.º 4
0
        private async Task SyncSet(JsonSet set)
        {
            Console.WriteLine("Syncing set {0} - {1}", set.Code, set.Name);

            var artists    = set.Cards.Select(c => c.Artist).Distinct();
            var watermarks = set.Cards.Select(c => c.Watermark).Distinct();
            var frames     = set.Cards.Select(c => c.FrameVersion).Distinct();
            var rarities   = set.Cards.Select(c => c.Rarity).Distinct();
            var borders    = set.Cards.Select(c => c.BorderColor).Distinct();
            var layouts    = set.Cards.Select(c => c.Layout).Distinct();

            foreach (var artist in artists)
            {
                UpsertSimpleLookup(db.Artists, artist);
            }

            foreach (var watermark in watermarks)
            {
                UpsertSimpleLookup(db.Watermarks, watermark);
            }

            foreach (var frame in frames)
            {
                UpsertSimpleLookup(db.Frames, frame);
            }

            foreach (var rarity in rarities)
            {
                UpsertSimpleLookup(db.Rarities, rarity);
            }

            foreach (var border in borders)
            {
                UpsertSimpleLookup(db.Borders, border);
            }

            foreach (var layout in layouts)
            {
                UpsertSimpleLookup(db.Layouts, layout);
            }

            await this.SaveChanges();

            var setUpsert = this.UpsertSet(set);

            db.RemoveRange(setUpsert.ObjectsToRemove);
            db.AddRange(setUpsert.ObjectsToAdd);

            var multiSideCards = set.Cards.Where(c => c.Side != null && c.Side != "a");

            foreach (var card in multiSideCards)
            {
                this.LinkSides(card);
            }

            await this.SaveChanges();
        }
Ejemplo n.º 5
0
        //PO_YYYY_IdOdsustva_Radbr_IdResenja_hhmiss(vreme generisanja fajla)
        private string GetFileName(JsonSet json)
        {
            StringBuilder fileName = new StringBuilder();

            fileName.Append("PO");
            fileName.Append("_" + DateTime.Now.Year.ToString());
            fileName.Append("_" + json.ID_ODSUSTVA);
            fileName.Append("_" + json.RADBR);
            fileName.Append("_" + json.ID_RESENJA);
            fileName.Append("_" + DateTime.Now.ToString("HHmmss"));

            return(fileName.ToString());
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> GenerateDocument([FromBody] JsonSet json)
        {
            try
            {
                var actionResult = await SaveDocument(json);



                return(Ok());
            }
            catch (Exception)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
Ejemplo n.º 7
0
        private string GetSourceFile(JsonSet json)
        {
            string sourceFile = "";

            //Grupa izvestaja postoji samo za PO. Za GO je vrednost 0
            if (json.GRUPA_IZVESTAJA.Equals("0")) //TO DO: Godisnji odmori
            {
            }
            else
            {
                sourceFile = "/algotech/POTelekom.ozr"; //template za Telekom - Placena odsustva
            }

            return(sourceFile);
        }
Ejemplo n.º 8
0
        private UpsertResult <Set> UpsertSet(JsonSet set)
        {
            var result = new UpsertResult <Set>();

            var dbSet = db.Sets.Local
                        .Where(s => s.Name == set.Name)
                        .FirstOrDefault();

            if (dbSet == null)
            {
                dbSet = new Set()
                {
                    Name = set.Name
                };

                result.ObjectsToAdd.Add(dbSet);
            }

            dbSet.Code        = set.Code;
            dbSet.KeyruneCode = set.KeyruneCode;
            dbSet.Date        = set.ReleaseDate;

            dbSet.SetType = UpsertSimpleLookup(db.SetTypes, set.Type);
            dbSet.Block   = UpsertSimpleLookup(db.Blocks, set.Block);

            foreach (var card in set.Cards)
            {
                var printingUpsert = this.UpsertPrinting(card);
                result.Merge(printingUpsert);
                if (printingUpsert.MainObject != null)
                {
                    dbSet.Printings.Add(printingUpsert.MainObject);
                }
            }

            result.MainObject = dbSet;

            return(result);
        }
        public StartCheck()
        {
            string path1 = Directory.GetCurrentDirectory() + "/HUALI_login_info.json";

            if (File.Exists(path1) == false)
            {
                Console.WriteLine("try to connect remote server........");
                try
                {
                    IIPGet  ip      = new Netvim();
                    JsonSet jsonset = new JsonSet(null, null, ip.IPGet());
                    Console.WriteLine("data set success");
                }
                catch
                {
                    Console.WriteLine("connect remoteserver failed , write ip null");
                }
            }
            else
            {
                Console.WriteLine("json check ........ok");
            }
        }
Ejemplo n.º 10
0
 static void Main()
 {
     JsonSet ins = new JsonSet("ins", "ins");
 }