Esempio n. 1
0
        public response GetPlatiFromLog(DateTime?data)
        {
            try
            {
                List <object[]> toReturnList = new List <object[]>();
                DataAccess      da           = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "IMPORT_LOG_PLATIsp_GetPlati", new object[] { new MySqlParameter("_DATA_IMPORT", data) });
                IDataReader     dr           = da.ExecuteSelectQuery();
                while (dr.Read())
                {
                    try
                    {
                        response r = new response();
                        r.Status     = Convert.ToBoolean(dr["STATUS"]);
                        r.Message    = dr["MESSAGE"].ToString();
                        r.InsertedId = Convert.ToInt32(dr["INSERTED_ID"]);
                        r.Error      = JsonConvert.DeserializeObject <List <Error> >(dr["ERRORS"].ToString(), CommonFunctions.JsonDeserializerSettings);

                        Plata         plata = r.Status ? new Plata(authenticatedUserId, connectionString, Convert.ToInt32(r.InsertedId)) : new Plata(authenticatedUserId, connectionString, Convert.ToInt32(r.InsertedId), true);
                        PlataExtended pe    = new PlataExtended(plata);

                        toReturnList.Add(new object[] { r, pe });
                    }
                    catch (Exception exp)
                    {
                        LogWriter.Log(exp);
                    }
                }
                dr.Close(); dr.Dispose();
                return(new response(true, JsonConvert.SerializeObject(toReturnList.ToArray(), CommonFunctions.JsonSerializerSettings), toReturnList.ToArray(), null, null));
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
                return(new response(false, exp.Message, null, null, new List <Error>()
                {
                    new Error(exp)
                }));
            }
        }
Esempio n. 2
0
 public response ImportAll(response responsesPlati, DateTime _date, int _import_type)
 {
     try
     {
         List <object[]> toReturnList = new List <object[]>();
         foreach (object[] responsePlata in (object[])responsesPlati.Result)
         {
             PlataExtended plataExtended = (PlataExtended)responsePlata[1];
             response      response      = (response)responsePlata[0];
             response      r             = new response();
             if (response.Status)
             {
                 r = plataExtended.Plata.Insert();
                 if (!r.Status)
                 {
                     response.Status = false;
                 }
             }
             else
             {
                 r = plataExtended.Plata.InsertWithErrors();
                 response.Status = false;
             }
             response.InsertedId = r.InsertedId;
             plataExtended.Plata.Log(response, _date, _import_type);
             toReturnList.Add(new object[] { response, plataExtended });
         }
         return(new response(true, JsonConvert.SerializeObject(toReturnList.ToArray(), CommonFunctions.JsonSerializerSettings), toReturnList.ToArray(), null, null));
     }
     catch (Exception exp)
     {
         LogWriter.Log(exp);
         return(new response(false, exp.Message, null, null, new List <Error>()
         {
             new Error(exp)
         }));
     }
 }