Exemple #1
0
 public response GetAll()
 {
     try
     {
         DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "ASIGURATIsp_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())
         {
             Asigurat a = new Asigurat(authenticatedUserId, connectionString, (IDataRecord)r);
             aList.Add(a);
         }
         r.Close(); r.Dispose();
         Asigurat[] toReturn = new Asigurat[aList.Count];
         for (int i = 0; i < aList.Count; i++)
         {
             toReturn[i] = (Asigurat)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.Message, null, null, new System.Collections.Generic.List <Error>()
         {
             new Error(exp)
         })); }
 }
Exemple #2
0
        public response Update(string fieldValueCollection)
        {
            Asigurat tmpItem = JsonConvert.DeserializeObject <Asigurat>(fieldValueCollection); // sa vedem daca merge asa sau trebuie cu JObject

            //return JsonConvert.DeserializeObject<Asigurat>(Find(Convert.ToInt32(tmpItem.ID)).Message).Update(fieldValueCollection);
            return(((Asigurat)(Find(Convert.ToInt32(tmpItem.ID)).Result)).Update(fieldValueCollection));
        }
Exemple #3
0
        public response Update(int id, string fieldValueCollection)
        {
            //Asigurat item = JsonConvert.DeserializeObject<Asigurat>(Find(id).Message);
            Asigurat item = (Asigurat)(Find(id).Result);

            return(item.Update(fieldValueCollection));
        }
Exemple #4
0
        public static response ExportDosarToPdfWithPdfForm(byte[] template_file_content, Models.Dosar dosar)
        {
            try
            {
                MemoryStream     ms         = new MemoryStream(template_file_content);
                string           fileName   = dosar.NR_DOSAR_CASCO.Replace('/', '_').Replace(' ', '_') + "_cerere.pdf";
                FileStream       fs         = File.Open(Path.Combine(CommonFunctions.GetPdfsFolder(), fileName), FileMode.Create, FileAccess.ReadWrite);
                PdfFixedDocument poDocument = new PdfFixedDocument(ms);

                Models.SocietateAsigurare sCasco = (Models.SocietateAsigurare)dosar.GetSocietateCasco().Result;
                Models.SocietateAsigurare sRca   = (Models.SocietateAsigurare)dosar.GetSocietateRca().Result;
                Models.Asigurat           aCasco = (Models.Asigurat)dosar.GetAsiguratCasco().Result;
                Models.Asigurat           aRca   = (Models.Asigurat)dosar.GetAsiguratRca().Result;
                Models.Auto autoCasco            = (Models.Auto)dosar.GetAutoCasco().Result;
                Models.Auto autoRca = (Models.Auto)dosar.GetAutoRca().Result;

                poDocument.Form.Fields["FieldSocietateCasco"].Value           = sCasco.DENUMIRE;
                poDocument.Form.Fields["FieldAdresaSocietateCasco"].Value     = sCasco.ADRESA;
                poDocument.Form.Fields["FieldCUISocietateCasco"].Value        = sCasco.CUI;
                poDocument.Form.Fields["FieldContBancarSocietateCasco"].Value = sCasco.IBAN;
                poDocument.Form.Fields["FieldBancaSocietateCasco"].Value      = sCasco.BANCA;
                poDocument.Form.Fields["FieldSocietateRCA"].Value             = sRca.DENUMIRE;
                poDocument.Form.Fields["FieldAdresaSocietateRCA"].Value       = sRca.ADRESA;
                poDocument.Form.Fields["FieldNrDosarCasco"].Value             = dosar.NR_DOSAR_CASCO;
                poDocument.Form.Fields["FieldPolitaRCA"].Value     = dosar.NR_POLITA_RCA;
                poDocument.Form.Fields["FieldPolitaCasco"].Value   = dosar.NR_POLITA_CASCO;
                poDocument.Form.Fields["FieldAsiguratCasco"].Value = aCasco.DENUMIRE;
                poDocument.Form.Fields["FieldAsiguratRCA"].Value   = aRca.DENUMIRE;
                poDocument.Form.Fields["FieldNrAutoCasco"].Value   = autoCasco.NR_AUTO;
                poDocument.Form.Fields["FieldAutoCasco"].Value     = autoCasco.MARCA + " " + autoCasco.MODEL;
                poDocument.Form.Fields["FieldNrAutoRCA"].Value     = autoRca.NR_AUTO;
                poDocument.Form.Fields["FieldDataEveniment"].Value = Convert.ToDateTime(dosar.DATA_EVENIMENT).ToString("dd/MM/yyyy");
                poDocument.Form.Fields["FieldSuma"].Value          = dosar.VALOARE_DAUNA.ToString();

                string docs = "";
                Models.DocumentScanat[] dsj = (Models.DocumentScanat[])dosar.GetDocumente().Result;
                foreach (Models.DocumentScanat doc in dsj)
                {
                    docs = String.Format("- {1}\r\n{0}", docs, (doc.DETALII != "" && doc.DETALII != null ? doc.DETALII : doc.DENUMIRE_FISIER));
                }
                poDocument.Form.Fields["FieldDocumente"].Value = docs;

                poDocument.Form.FlattenFields();

                poDocument.Save(fs);
                fs.Flush();
                fs.Dispose();
                string toReturn = Path.Combine(CommonFunctions.GetPdfsFolder(), fileName);
                return(new response(true, toReturn, toReturn, null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.Message, null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }
Exemple #5
0
 public response Find(string _denumire)
 {
     try
     {
         Asigurat item = new Asigurat(authenticatedUserId, connectionString, _denumire);
         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)
         })); }
 }
Exemple #6
0
        public response GetFiltered(string _sort, string _order, string _filter, string _limit)
        {
            try
            {
                try
                {
                    string newFilter = Filtering.GenerateFilterFromJsonObject(typeof(Asigurat), _filter, authenticatedUserId, connectionString);
                    _filter = newFilter == null ? _filter : newFilter;
                }
                catch { }
                DataAccess da = new DataAccess(authenticatedUserId, connectionString, CommandType.StoredProcedure, "ASIGURATIsp_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())
                 * {
                 *  Asigurat a = new Asigurat(authenticatedUserId, connectionString, (IDataRecord)r);
                 *  aList.Add(a);
                 * }
                 * r.Close(); r.Dispose(); da.CloseConnection();
                 * Asigurat[] toReturn = new Asigurat[aList.Count];
                 * for (int i = 0; i < aList.Count; i++)
                 *  toReturn[i] = (Asigurat)aList[i];
                 * return new response(true, JsonConvert.SerializeObject(toReturn, CommonFunctions.JsonSerializerSettings), toReturn, null, null);
                 */
                List <Asigurat> aList = new List <Asigurat>();
                MySqlDataReader r     = da.ExecuteSelectQuery();
                while (r.Read())
                {
                    Asigurat a = new Asigurat(authenticatedUserId, connectionString, (IDataRecord)r);
                    aList.Add(a);
                }
                r.Close(); r.Dispose(); da.CloseConnection();
                return(new response(true, JsonConvert.SerializeObject(aList.ToArray(), CommonFunctions.JsonSerializerSettings), aList.ToArray(), null, null));
            }
            catch (Exception exp) { LogWriter.Log(exp); return(new response(false, exp.Message, null, null, new System.Collections.Generic.List <Error>()
                {
                    new Error(exp)
                })); }
        }
Exemple #7
0
 public response GetChildren(Asigurat item, string tableName, int childrenId)
 {
     return(item.GetChildren(tableName, childrenId));
 }
Exemple #8
0
 public response GetChildrens(Asigurat item, string tableName)
 {
     return(item.GetChildrens(tableName));
 }
Exemple #9
0
 public response Delete(Asigurat item)
 {
     return(item.Delete());
 }
Exemple #10
0
 public response Update(Asigurat item)
 {
     return(item.Update());
 }
Exemple #11
0
 public response Insert(Asigurat item)
 {
     return(item.Insert());
 }
Exemple #12
0
        //public static PdfFlowTextContent GeneratePdfContent(List<string> pdfText, Models.Dosar dosar)
        public static PdfFormattedContent GeneratePdfContent(List <string> pdfText, Models.Dosar dosar)
        {
            Models.SocietateAsigurare sCasco = (Models.SocietateAsigurare)dosar.GetSocietateCasco().Result;
            Models.SocietateAsigurare sRca   = (Models.SocietateAsigurare)dosar.GetSocietateRca().Result;
            Models.Asigurat           aCasco = (Models.Asigurat)dosar.GetAsiguratCasco().Result;
            Models.Asigurat           aRca   = (Models.Asigurat)dosar.GetAsiguratRca().Result;
            Models.Auto autoCasco            = (Models.Auto)dosar.GetAutoCasco().Result;
            Models.Auto autoRca = (Models.Auto)dosar.GetAutoRca().Result;

            Dictionary <string, string> field_names = new Dictionary <string, string>();

            field_names.Add("{{NR_SCA}}", dosar.NR_SCA == null || dosar.NR_SCA.Trim() == "" ? "_________" : dosar.NR_SCA);
            field_names.Add("{{DATA_SCA}}", dosar.DATA_SCA == null ? "____________" : Convert.ToDateTime(dosar.DATA_SCA).Year.ToString());
            field_names.Add("{{NR_DOSAR_CASCO}}", dosar.NR_DOSAR_CASCO == null || dosar.NR_DOSAR_CASCO.Trim() == "" ? "_________________" : dosar.NR_DOSAR_CASCO);
            field_names.Add("{{VALOARE_DAUNA}}", dosar.VALOARE_DAUNA.ToString().Trim() == "" ? "___________" : dosar.VALOARE_DAUNA.ToString());
            field_names.Add("{{NR_POLITA_CASCO}}", dosar.NR_POLITA_CASCO == null || dosar.NR_POLITA_CASCO.Trim() == "" ? "_________________" : dosar.NR_POLITA_CASCO);
            field_names.Add("{{NR_POLITA_RCA}}", dosar.NR_POLITA_RCA == null || dosar.NR_POLITA_RCA.Trim() == "" ? "_________________" : dosar.NR_POLITA_RCA);
            field_names.Add("{{DATA_EVENIMENT}}", dosar.DATA_EVENIMENT == null ? "___________" : Convert.ToDateTime(dosar.DATA_EVENIMENT).ToString("dd/MM/yyyy"));

            field_names.Add("{{SOCIETATE_CASCO}}", sCasco.DENUMIRE == null || sCasco.DENUMIRE.Trim() == "" ? "__________________________________" : sCasco.DENUMIRE);
            field_names.Add("{{ADRESA_SOCIETATE_CASCO}}", sCasco.ADRESA == null || sCasco.ADRESA.Trim() == "" ? "___________________________________________________" : sCasco.ADRESA);
            field_names.Add("{{NR_REG_COM_SOCIETATE_CASCO}}", sCasco.NR_REG_COM == null || sCasco.NR_REG_COM.Trim() == "" ? "_______________" : sCasco.NR_REG_COM.ToUpper());
            field_names.Add("{{CUI_SOCIETATE_CASCO}}", sCasco.CUI == null || sCasco.CUI.Trim() == "" ? "______________" : sCasco.CUI.ToUpper());
            field_names.Add("{{IBAN_SOCIETATE_CASCO}}", sCasco.IBAN == null || sCasco.IBAN.Trim() == "" ? "__________________________________________" : sCasco.IBAN.ToUpper());
            field_names.Add("{{BANCA_SOCIETATE_CASCO}}", sCasco.BANCA == null || sCasco.BANCA.Trim() == "" ? "____________________________________" : sCasco.BANCA.ToUpper());

            field_names.Add("{{SOCIETATE_RCA}}", sRca.DENUMIRE == null || sRca.DENUMIRE.Trim() == "" ? "_________________________________" : sRca.DENUMIRE);
            field_names.Add("{{ADRESA_SOCIETATE_RCA}}", sRca.ADRESA == null || sRca.ADRESA.Trim() == "" ? "___________________________________________________" : sRca.ADRESA);
            field_names.Add("{{ASIGURAT_CASCO}}", aCasco.DENUMIRE == null || aCasco.DENUMIRE.Trim() == "" ? "__________________________________" : aCasco.DENUMIRE);
            field_names.Add("{{ASIGURAT_RCA}}", aRca.DENUMIRE == null || aRca.DENUMIRE.Trim() == "" ? "__________________________________" : aRca.DENUMIRE);

            field_names.Add("{{NR_AUTO_CASCO}}", autoCasco.NR_AUTO == null || autoCasco.NR_AUTO.Trim() == "" ? "____________" : autoCasco.NR_AUTO.ToUpper());
            field_names.Add("{{MARCA_AUTO_CASCO}}", autoCasco.MARCA == null || autoCasco.MARCA.Trim() == "" ? "______________" : autoCasco.MARCA.ToUpper());
            field_names.Add("{{NR_AUTO_RCA}}", autoRca.NR_AUTO == null || autoRca.NR_AUTO.Trim() == "" ? "____________" : autoRca.NR_AUTO.ToUpper());
            field_names.Add("{{PROPRIETAR_AUTO_RCA}}", "_______________________");

            field_names.Add("{{NORMA}}", dosar.DATA_EVENIMENT < new DateTime(2015, 1, 1) ? Articole.articole[0].Ordin : dosar.DATA_EVENIMENT >= new DateTime(2015, 1, 1) && dosar.DATA_EVENIMENT <= new DateTime(2016, 12, 22) ? Articole.articole[1].Ordin : Articole.articole[2].Ordin);
            field_names.Add("{{ARTICOL_PLATA}}", dosar.DATA_EVENIMENT < new DateTime(2015, 1, 1) ? Articole.articole[0].ArticolPlata : dosar.DATA_EVENIMENT >= new DateTime(2015, 1, 1) && dosar.DATA_EVENIMENT <= new DateTime(2016, 12, 22) ? Articole.articole[1].ArticolPlata : Articole.articole[2].ArticolPlata);
            field_names.Add("{{ARTICOL_OBIECTIUNI}}", dosar.DATA_EVENIMENT < new DateTime(2015, 1, 1) ? Articole.articole[0].ArticolObiectiuni : dosar.DATA_EVENIMENT >= new DateTime(2015, 1, 1) && dosar.DATA_EVENIMENT <= new DateTime(2016, 12, 22) ? Articole.articole[1].ArticolObiectiuni : Articole.articole[2].ArticolObiectiuni);
            field_names.Add("{{TERMEN}}", dosar.DATA_EVENIMENT < new DateTime(2015, 1, 1) ? Articole.articole[0].NrZile : dosar.DATA_EVENIMENT >= new DateTime(2015, 1, 1) && dosar.DATA_EVENIMENT <= new DateTime(2016, 12, 22) ? Articole.articole[1].NrZile : Articole.articole[2].NrZile);
            field_names.Add("{{CAZ}}", dosar.CAZ == null || dosar.CAZ.Trim() == "" ? "_____" : dosar.CAZ);
            field_names.Add("{{DATA}}", DateTime.Now.ToString("dd/MM/yyyy"));


            string docs = "";

            //pentru insiruirea in opis a tuturor documentelor, negrupate pe tip

            /*
             * Models.DocumentScanat[] dsj = (Models.DocumentScanat[])dosar.GetDocumente().Result;
             * foreach (Models.DocumentScanat doc in dsj)
             * {
             *  Models.Nomenclator tip_document = (Models.Nomenclator)doc.GetTipDocument().Result;
             *  //docs = String.Format("- {1}\r\n{0}", docs, (doc.DETALII != "" && doc.DETALII != null ? doc.DETALII : doc.DENUMIRE_FISIER));
             *  docs = String.Format("- {1}\r\n{0}", docs, tip_document.DENUMIRE + " " + (doc.DETALII != "" && doc.DETALII != null ? doc.DETALII : ""));
             * }
             */
            object[] DocumenteTipuri = (object[])dosar.GetDocumenteTipuri().Result;
            foreach (object[] documentTip in DocumenteTipuri)
            {
                docs = String.Format("{0}\r\n- {1}{2}", docs, documentTip[1].ToString(), Convert.ToInt32(documentTip[2]) > 1 ? " (" + documentTip[2].ToString() + " file)" : "");
            }

            field_names.Add("{{DOCUMENTE}}", docs);


            PdfUnicodeTrueTypeFont boldFont    = new PdfUnicodeTrueTypeFont(new FileStream(Path.Combine(AppContext.BaseDirectory, "Content", "arialbold.ttf"), FileMode.Open, FileAccess.Read, FileShare.Read), 12, true);
            PdfUnicodeTrueTypeFont regularFont = new PdfUnicodeTrueTypeFont(new FileStream(Path.Combine(AppContext.BaseDirectory, "Content", "arial.ttf"), FileMode.Open, FileAccess.Read, FileShare.Read), 12, true);

            PdfFormattedContent pfc = new PdfFormattedContent();

            foreach (string s in pdfText)
            {
                PdfFormattedParagraph pfp = new PdfFormattedParagraph();
                pfp.LineSpacingMode = PdfFormattedParagraphLineSpacing.Multiple;
                pfp.LineSpacing     = 1.3;
                pfp.SpacingAfter    = 15;

                if (s.IndexOf("{{NR_SCA}}") > -1)
                {
                    pfp.HorizontalAlign = PdfStringHorizontalAlign.Right;
                }
                else if (s.IndexOf("CERERE DE DESPAGUBIRE") > -1)
                {
                    pfp.HorizontalAlign = PdfStringHorizontalAlign.Center;
                }
                else
                {
                    pfp.HorizontalAlign = PdfStringHorizontalAlign.Justified;
                    if (s.IndexOf("Catre") < 0 && s.IndexOf("{{DOCUMENTE}}") < 0 && s.IndexOf("$$") < 0)
                    {
                        pfp.FirstLineIndent = 30;
                    }
                    if (s.IndexOf("{{DOCUMENTE}}") > -1 || s.IndexOf("$$") > -1)
                    {
                        pfp.LeftIndentation = 50;
                    }
                }

                List <string> splitters = new List <string>();
                foreach (KeyValuePair <string, string> field in field_names)
                {
                    if (s.IndexOf(field.Key) > -1)
                    {
                        splitters.Add(field.Key);
                    }
                }
                string[] sBlocks = null;
                if (splitters.Count > 0)
                {
                    sBlocks = s.Split(splitters.ToArray(), StringSplitOptions.None);
                }
                else
                {
                    sBlocks = new string[] { s }
                };

                int splitter_count = 0;
                for (int i = 0; i < sBlocks.Length; i++)
                {
                    try
                    {
                        PdfFormattedTextBlock b1 = new PdfFormattedTextBlock(sBlocks[i].Replace("$$", "\r\n"), sBlocks[i].IndexOf("CERERE DE DESPAGUBIRE") > -1 ? boldFont : regularFont);
                        pfp.Blocks.Add(b1);
                        string theFuckingWrightSplitter = "";
                        //if (splitter_count < splitters.Count)
                        {
                            foreach (string splitter in splitters)
                            {
                                if (s.IndexOf(sBlocks[i] + splitter) > -1)
                                {
                                    theFuckingWrightSplitter = splitter;
                                    splitter_count++;
                                    splitters.Remove(splitter);
                                    break;
                                }
                            }
                            //PdfFormattedTextBlock b2 = new PdfFormattedTextBlock(field_names[splitters[i]], boldFont);
                            PdfFormattedTextBlock b2 = new PdfFormattedTextBlock(field_names[theFuckingWrightSplitter], boldFont);
                            pfp.Blocks.Add(b2);
                        }
                    }
                    catch { }
                }
                pfc.Paragraphs.Add(pfp);
            }
            //pfc.SplitByBox(485, 742);
            //PdfFlowTextContent pftc = new PdfFlowTextContent(pfc);
            //return pftc;
            return(pfc);
        }