예제 #1
0
        private void btnAcquisisceMisure_Click(object sender, EventArgs e)
        {
            List <UploadMeasuresElementRequest> measures = new List <UploadMeasuresElementRequest>();
            UploadMeasuresElementRequest        e1       = new UploadMeasuresElementRequest();

            e1.Material = txtMaterial1.Text;
            e1.Measure  = nMeasure1.Value;
            if (!String.IsNullOrEmpty(txtMaterial1.Text))
            {
                measures.Add(e1);
            }

            UploadMeasuresElementRequest e2 = new UploadMeasuresElementRequest();

            e2.Material = txtMaterial2.Text;
            e2.Measure  = nMeasure2.Value;
            if (!String.IsNullOrEmpty(txtMaterial2.Text))
            {
                measures.Add(e2);
            }

            UploadMeasuresElementRequest e3 = new UploadMeasuresElementRequest();

            e3.Material = txtMaterial3.Text;
            e3.Measure  = nMeasure3.Value;
            if (!String.IsNullOrEmpty(txtMaterial3.Text))
            {
                measures.Add(e3);
            }

            string json = JSonSerializer.Serialize <List <UploadMeasuresElementRequest> >(measures);

            CertixWS.CertixServicesSoapClient client = new CertixWS.CertixServicesSoapClient();
            txtMessaggio.Text = client.UploadMeasures((int)nIdMeasure.Value, json);
        }
        private string CreaUploadMeasuresResponse(string Status, string messaggioErrore)
        {
            UploadMeasuresResponse response = new UploadMeasuresResponse();

            response.Status = Status;
            response.Error  = messaggioErrore;

            return(JSonSerializer.Serialize <UploadMeasuresResponse>(response));
        }
        private string CreaUploadCodeResponsePerErrore(string messaggioErrore)
        {
            UploadCodeResponse response = new UploadCodeResponse();

            response.Status    = Status.ERRORE;
            response.Error     = messaggioErrore;
            response.IdMeasure = -1;
            response.Materials = new List <string>();

            return(JSonSerializer.Serialize <UploadCodeResponse>(response));
        }
        public async Task SerializeElementAsJson()
        {
            var store = await StoreBuilder.New().CreateAsync();

            await store.Schemas.New <LibraryDefinition>().CreateAsync();

            var domain = await store.DomainModels.New().CreateAsync("Test");

            Library lib;

            using (var session = store.BeginSession())
            {
                lib      = new Library(domain);
                lib.Name = "Lib1";
                for (int i = 0; i < 3; i++)
                {
                    var b = new Book(domain);
                    b.Title  = "Book \"book\" " + i.ToString();
                    b.Copies = i + 1;
                    lib.Books.Add(b);

                    var m = new Member(domain);
                    m.Name = "Book " + i.ToString();
                    lib.Members.Add(m);
                }
                session.AcceptChanges();
            }

            var txt = JSonSerializer.Serialize(lib, JSonSerializationOption.Hyperstore);

            Assert.True(!String.IsNullOrEmpty(txt));

            var json = JSonSerializer.Serialize(lib, JSonSerializationOption.Json);

            Assert.True(!String.IsNullOrEmpty(json));

            var newton = Newtonsoft.Json.JsonConvert.SerializeObject(lib, new Newtonsoft.Json.JsonSerializerSettings {
                PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects
            });

            store.DomainModels.Unload(domain);
            domain = await store.DomainModels.New().CreateAsync("Test");

            using (var session = store.BeginSession(new SessionConfiguration {
                DefaultDomainModel = domain, Mode = SessionMode.Loading
            }))
            {
                Newtonsoft.Json.JsonConvert.DeserializeObject <Library>(json);
                session.AcceptChanges();
            }
            lib = domain.GetEntities <Library>().FirstOrDefault();
            Assert.NotNull(lib);
            Assert.Equal(3, lib.Books.Count());
        }
        public string GetToken(string user, string password, string url)
        {
            string            method = @"topfinish-tmr-api/auth/login";
            string            StatusDescription;
            Uri               uri  = new Uri(url + method);
            AuthenticationDto adto = new AuthenticationDto();

            adto.password = password;
            adto.username = user;
            string   Json       = JSonSerializer.Serialize <AuthenticationDto>(adto);
            object   jsonObject = executeCall(uri, Json, out StatusDescription);
            string   result     = jsonObject as string;
            TokenDto o          = JSonSerializer.Deserialize <TokenDto>(jsonObject as string);

            return(o.value);
        }
예제 #6
0
 /// <summary>
 /// Insert customer data to cache
 /// </summary>
 public void StoreNewCustomerData(ExpirationType expirationType = ExpirationType.None)
 {
     try
     {
         var cacheItem = new CacheItem(_serializer.Serialize(Customer));
         if (expirationType.Equals(ExpirationType.Absolute))
         {
             cacheItem.Expiration = new Expiration(ExpirationType.Absolute, new TimeSpan(0, 0, 10));
         }
         _cache.Insert(Customer.CustomerID.ToUpper(), cacheItem, new WriteThruOptions(WriteMode.WriteThru, WriteThruProviderName));
         Console.WriteLine("Customer information Inserted successfuly");
     }
     catch (Exception e)
     {
         Console.WriteLine("\n" + "Error: " + e.Message);
     }
 }
        public string AssociazioneTelaio(string odl, string prodotto, string telaio, int qta, int stato, string url, string token)
        {
            string method = @"topfinish-tmr-api/custom/productionLot/createProductionLot";
            string StatusDescription;
            Uri    uri = new Uri(url + method);
            AssociazioneTelaioDto adto = new AssociazioneTelaioDto();

            adto.odl      = odl;
            adto.prodotto = prodotto;
            adto.telaio   = telaio;
            adto.qty      = qta;
            adto.stato    = stato;
            string Json       = JSonSerializer.Serialize <AssociazioneTelaioDto>(adto);
            object jsonObject = executeCall(uri, Json, token, out StatusDescription);
            string result     = jsonObject as string;

            return(result);
        }
        public string UploadCode(int IdLine, string Code)
        {
            ScriviMessaggioInLog("*************  UploadCode Richiamato");

            try
            {
                CertixBLL bll = new CertixBLL();

                List <string> Measures;
                int           IdMeasure = bll.CreateIdMeasureFromCodeAndIdLine(IdLine, Code, Properties.Settings.Default.IsTest, out Measures);

                UploadCodeResponse response = new UploadCodeResponse();
                response.Status    = Status.OK;
                response.Error     = string.Empty;
                response.IdMeasure = IdMeasure;
                response.Materials = Measures;

                return(JSonSerializer.Serialize <UploadCodeResponse>(response));
            }
            catch (ArgumentException ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("********** ERRORE IN UPLOADCODE");
                ScriviErroreGestitoInLog(ex, sb.ToString());
                return(CreaUploadCodeResponsePerErrore(ex.Message));
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("********** ERRORE IN UPLOADCODE");
                sb.AppendLine(string.Format(" IdLine: {0}  ", IdLine));
                sb.AppendLine(string.Format("Code: {0}  ", Code));
                ScriviEccezioneInLog(ex, sb.ToString());
                return(CreaUploadCodeResponsePerErrore("Errore non recuperabile."));
            }
        }