Beispiel #1
0
        public response Update(int id, string fieldValueCollection)
        {
            //TipDocument item = JsonConvert.DeserializeObject<TipDocument>(Find(id).Message);
            TipDocument item = (TipDocument)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
Beispiel #2
0
 public response GetAll()
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "TIP_DOCUMENTsp_select", new object[] {
             new MySqlParameter("_SORT", null),
             new MySqlParameter("_ORDER", null),
             new MySqlParameter("_FILTER", null),
             new MySqlParameter("_LIMIT", null)
         });
         ArrayList       aList = new ArrayList();
         MySqlDataReader r     = da.ExecuteSelectQuery();
         while (r.Read())
         {
             TipDocument a = new TipDocument(authenticatedUserId, connectionString, (IDataRecord)r);
             aList.Add(a);
         }
         r.Close(); r.Dispose();
         TipDocument[] toReturn = new TipDocument[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (TipDocument)aList[i];
         }
         return(new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Beispiel #3
0
        public response Update(string fieldValueCollection)
        {
            TipDocument tmpItem = JsonConvert.DeserializeObject <TipDocument>(fieldValueCollection); // sa vedem daca merge asa sau trebuie cu JObject

            //return JsonConvert.DeserializeObject<TipDocument>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((TipDocument)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
Beispiel #4
0
 public response Find(int _id)
 {
     try
     {
         TipDocument item = new TipDocument(authenticatedUserId, connectionString, _id);
         return(new response(true, JsonConvert.SerializeObject(item, CommonFunctions.JsonSerializerSettings), item, null, null));;
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Beispiel #5
0
 public response GetTipDocument()
 {
     try
     {
         //Nomenclator toReturn = new Nomenclator(authenticatedUserId, connectionString, "tip_document", (Convert.ToInt32(this.ID_TIP_DOCUMENT)));
         TipDocument toReturn = new TipDocument(authenticatedUserId, connectionString, (Convert.ToInt32(this.ID_TIP_DOCUMENT)));
         return(new response(true, Newtonsoft.Json.JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
     }
     catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new List <Error>()
         {
             new Error(exp)
         })); }
 }
Beispiel #6
0
        public static response CreateZipFromDosar(Models.Dosar dosar, bool bulk) // bulk = false - fisiere grupate pe tip documente / bulk = true - fisiere la gramada
        {
            response r = new response();

            try
            {
                Models.DocumentScanat[] dss = (Models.DocumentScanat[])dosar.GetDocumente().Result;
                //Models.TipDocument[] tds = (Models.TipDocument[])dosar.GetDocumenteTipuri().Result;

                string zipFilePath = Path.Combine(CommonFunctions.GetTempFolder(), String.Format("{0}.zip", dosar.NR_DOSAR_CASCO));
                using (FileStream zipFile = new FileStream(zipFilePath, FileMode.Create))
                {
                    using (ZipArchive archive = new ZipArchive(zipFile, ZipArchiveMode.Create))
                    {
                        foreach (Models.DocumentScanat ds in dss)
                        {
                            try
                            {
                                if (ds.VIZA_CASCO)
                                {
                                    response        rg    = PdfGenerator.GeneratePdfWithSignatureFromDocument(ds);
                                    ZipArchiveEntry entry = null;
                                    if (!bulk)
                                    {
                                        //entry = archive.CreateEntry(String.Format("{0}/{1}", dosar.NR_DOSAR_CASCO, ds.DENUMIRE_FISIER), CompressionLevel.Optimal); // old version - fara semnatura digitala
                                        entry = archive.CreateEntry(String.Format("{0}/{1}", dosar.NR_DOSAR_CASCO, rg.Message), CompressionLevel.Optimal);
                                    }
                                    else
                                    {
                                        Models.TipDocument td = (Models.TipDocument)ds.GetTipDocument().Result;
                                        //entry = archive.CreateEntry(String.Format("{0}/{1}/{2}", dosar.NR_DOSAR_CASCO, td.DENUMIRE, ds.DENUMIRE_FISIER), CompressionLevel.Optimal); // old version - fara semnatura digitala
                                        entry = archive.CreateEntry(String.Format("{0}/{1}/{2}", dosar.NR_DOSAR_CASCO, td.DENUMIRE, rg.Message), CompressionLevel.Optimal);
                                    }
                                    using (BinaryWriter writer = new BinaryWriter(entry.Open()))
                                    {
                                        /*
                                         * ds.GetFileContent();
                                         * writer.Write(ds.FILE_CONTENT);
                                         * writer.Flush();
                                         */
                                        byte[] src = File.ReadAllBytes(rg.Result.ToString());
                                        writer.Write(src);
                                        writer.Flush();
                                        File.Delete(rg.Result.ToString());
                                    }
                                }
                            }catch (Exception exp)
                            {
                                LogWriter.Log(exp);
                            }
                        }
                    }
                }
                return(new response(true, zipFilePath, zipFilePath, null, null));
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
                return(new response(false, exp.Message, null, null, new List <Error>()
                {
                    new Error(exp)
                }));
            }
        }
Beispiel #7
0
 public response GetChildren(TipDocument item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
Beispiel #8
0
 public response GetChildrens(TipDocument item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
Beispiel #9
0
 public response Delete(TipDocument item)
 {
     return(item.Delete());
 }
Beispiel #10
0
 public response Update(TipDocument item)
 {
     return(item.Update());
 }
Beispiel #11
0
 public response Insert(TipDocument item)
 {
     return(item.Insert());
 }
Beispiel #12
0
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                #region -- initial --

                /*
                 * string newFilter = null;
                 * try
                 * {
                 *  try
                 *  {
                 *      Action x = Newtonsoft.Json.JsonConvert.DeserializeObject<Action>(_filter);
                 *      newFilter = x.GenerateFilterFromJsonObject();
                 *  }
                 *  catch
                 *  {
                 *      try
                 *      {
                 *          dynamic jObj = Newtonsoft.Json.JsonConvert.DeserializeObject(_filter);
                 *          Action x = new Action(authenticatedUserId, connectionString);
                 *          PropertyInfo[] pisX = x.GetType().GetProperties();
                 *          PropertyInfo[] pisJObj = jObj.GetType().GetProperties();
                 *          foreach (PropertyInfo piX in pisX)
                 *          {
                 *              foreach (PropertyInfo piJObj in pisJObj)
                 *              {
                 *                  if (piX.Name == piJObj.Name)
                 *                  {
                 *                      piX.SetValue(x, piJObj.GetValue(jObj));
                 *                      break;
                 *                  }
                 *              }
                 *          }
                 *          newFilter = x.GenerateFilterFromJsonObject();
                 *      }
                 *      catch { }
                 *  }
                 * }
                 * catch { }
                 * if (newFilter != null) _filter = newFilter;
                 */
                #endregion
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(TipDocument), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter == null ? _filter : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "TIP_DOCUMENTsp_select", new object[] {
                    new MySqlParameter("_SORT", _sort),
                    new MySqlParameter("_ORDER", _order),
                    new MySqlParameter("_FILTER", _filter),
                    new MySqlParameter("_LIMIT", _limit)
                });
                ArrayList       aList = new ArrayList();
                MySqlDataReader r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    TipDocument a = new TipDocument(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose();
                TipDocument[] toReturn = new TipDocument[aList.Count];
                for (int i = 0; i < aList.Count; i++)
                {
                    toReturn[i] = (TipDocument)aList[i];
                }
                return(new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.ToString(), null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }