public JsonResult Edit(DocumentScanat CurDocumentScanat)
        {
            response r      = new response();
            string   conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;

            if (CurDocumentScanat.ID == null)               // insert
            {
                DocumentScanat d   = new DocumentScanat(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr);
                PropertyInfo[] pis = CurDocumentScanat.GetType().GetProperties();
                foreach (PropertyInfo pi in pis)
                {
                    pi.SetValue(d, pi.GetValue(CurDocumentScanat));
                }
                r = d.Insert();
                //return Json(r, JsonRequestBehavior.AllowGet);
                JsonResult result = Json(r, JsonRequestBehavior.AllowGet);
                result.MaxJsonLength = Int32.MaxValue;
                return(result);
            }
            else // edit
            {
                //DocumenteScanateRepository dsr = new DocumenteScanateRepository(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr);
                //DocumentScanat d = (DocumentScanat)dsr.Find(Convert.ToInt32(CurDocumentScanat.ID)).Result;
                DocumentScanat d = new DocumentScanat(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr, Convert.ToInt32(CurDocumentScanat.ID));
                //string s = JsonConvert.SerializeObject(CurDocumentScanat, Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "dd.MM.yyyy" });
                string s = CommonFunctions.GenerateJsonFromModifiedFields(d, CurDocumentScanat);
                r = d.Update(s);
                //return Json(r, JsonRequestBehavior.AllowGet);
                JsonResult result = Json(r, JsonRequestBehavior.AllowGet);
                result.MaxJsonLength = Int32.MaxValue;
                return(result);
            }
        }
        public JsonResult RegenerareFisierDinDb(int id)
        {
            string         conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            DocumentScanat ds     = new DocumentScanat(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr, id);
            response       r      = FileManager.RestoreFileFromDb(ds);

            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Delete(int id)
        {
            string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            DocumenteScanateRepository dsr = new DocumenteScanateRepository(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr);
            DocumentScanat             d   = (DocumentScanat)dsr.Find(id).Result;
            response r = d.Delete();

            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Avizare(DocumentScanat CurDocumentScanat)
        {
            response r      = new response();
            string   conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            DocumenteScanateRepository dsr = new DocumenteScanateRepository(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr);
            DocumentScanat             d   = (DocumentScanat)dsr.Find(Convert.ToInt32(CurDocumentScanat.ID)).Result;

            r = d.Avizare(CurDocumentScanat.VIZA_CASCO);
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult UpdateTipDocument(int id, int id_tip_document)
        {
            response       r               = new response();
            string         conStr          = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int            _CURENT_USER_ID = Convert.ToInt32(Session["CURENT_USER_ID"]);
            DocumentScanat d               = new DocumentScanat(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr, id);

            r = d.UpdateTipDocument(id_tip_document);
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult PostFile(int id_tip_document, int id_dosar)
        {
            HttpPostedFileBase f         = Request.Files[0];
            string             initFName = f.FileName;
            string             extension = f.FileName.Substring(f.FileName.LastIndexOf('.'));
            string             newFName  = Guid.NewGuid() + extension;

            Request.Files[0].SaveAs(System.IO.Path.Combine(CommonFunctions.GetScansFolder(), newFName));
            //string toReturn = "{\"DENUMIRE_FISIER\":\"" + initFName + "\",\"EXTENSIE_FISIER\":\"" + extension + "\",\"CALE_FISIER\":\"" + newFName + "\"}";
            string         conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            DocumentScanat ds     = new DocumentScanat(Convert.ToInt32(Session["CURENT_USER_ID"]), conStr);

            ds.ID_DOSAR        = id_dosar;
            ds.ID_TIP_DOCUMENT = id_tip_document;
            ds.CALE_FISIER     = newFName;
            ds.DENUMIRE_FISIER = initFName;
            ds.EXTENSIE_FISIER = extension;
            response   r      = ds.Insert();
            JsonResult result = Json(r, JsonRequestBehavior.AllowGet);

            result.MaxJsonLength = Int32.MaxValue;
            return(result);
        }
示例#7
0
        public static void CallService(bool WithoutEmails, bool WithoutMarkings, bool WithPdfs, string DenumireSocietate)
        {
            response r = new response();

            try
            {
                int           uid     = 1;
                List <string> conStrs = new List <string>();
                conStrs.Add(CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString(), CommonFunctions.StringCipher.RetrieveKey()));
                //conStrs.Add(StringCipher.Decrypt( ConfigurationManager.ConnectionStrings["MySqlConnectionString_test"].ToString(), RetrieveKey()));  // -- daca vrem insert si in baza de test !!! dubleaza documentele in "scan"

                /*
                 * BasicHttpBinding binding = new BasicHttpBinding();
                 * binding.MaxBufferPoolSize = binding.MaxBufferSize = Int32.MaxValue;
                 * binding.MaxReceivedMessageSize = long.MaxValue;
                 */
                SubrogationServiceClient s = new SubrogationServiceClient();

                /*
                 * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferPoolSize = Int32.MaxValue;
                 * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxBufferSize = Int32.MaxValue;
                 * (s.ChannelFactory.Endpoint.Binding as BasicHttpBinding).MaxReceivedMessageSize = Int32.MaxValue;
                 */

                s.ClientCredentials.UserName.UserName = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.AppSettings["AllianzWSUser"].ToString(), CommonFunctions.StringCipher.RetrieveKey());
                s.ClientCredentials.UserName.Password = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.AppSettings["AllianzWSPassword"].ToString(), CommonFunctions.StringCipher.RetrieveKey());

                s.InnerChannel.OperationTimeout = new TimeSpan(0, 10, 0);

                SubrogationInfo[] sis = s.BrowseUnreadSubrogations(DateTime.MinValue, DateTime.MinValue);
                int counter           = 0;
                foreach (SubrogationInfo si in sis)
                {
                    //if (counter > 2) return;
                    foreach (string conStr in conStrs) // salvam in ambele baze !
                    {
                        try
                        {
                            response            validationResponse = new response();
                            SOCISA.Models.Dosar d = new SOCISA.Models.Dosar(uid, conStr);
                            try
                            {
                                SocietateAsigurare sCasco = new SocietateAsigurare(uid, conStr, DenumireSocietate, true);
                                d.ID_SOCIETATE_CASCO = sCasco.ID;
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }
                            try
                            {
                                //SocietateAsigurare sRca = new SocietateAsigurare(uid, conStr, si.SubrogationInsurerName, false);
                                SocietateAsigurare sRca = null;
                                int?id_soc = GetSocietateMapping(SocietatiMappings, si.SubrogationInsurerId);
                                if (id_soc != null && id_soc != 0)
                                {
                                    sRca = new SocietateAsigurare(uid, conStr, Convert.ToInt32(id_soc));
                                }
                                if (sRca == null || sRca.ID == null)
                                {
                                    sRca          = new SocietateAsigurare(uid, conStr);
                                    sRca.DENUMIRE = sRca.DENUMIRE_SCURTA = si.SubrogationInsurerName;
                                    sRca.ADRESA   = si.SubrogationInsurerCountry;
                                    r             = sRca.Insert();

                                    /*
                                     * if(r.InsertedId != null && id_soc == null)
                                     * {
                                     *  DataRow newRow = SocietatiMappings.NewRow();
                                     *  newRow["ID_SCA"] = r.InsertedId;
                                     *  newRow["ID_SOCIETATE"] = id_soc;
                                     *  SocietatiMappings.Rows.Add(newRow);
                                     *  SocietatiMappings.AcceptChanges();
                                     *  SaveSocietatiMappings(DenumireSocietate);
                                     * }
                                     */
                                }
                                d.ID_SOCIETATE_RCA = sRca.ID;
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }

                            try
                            {
                                if (!String.IsNullOrWhiteSpace(si.InsuredFullName))
                                {
                                    Asigurat aCasco = new Asigurat(uid, conStr, si.InsuredFullName);
                                    if (aCasco == null || aCasco.ID == null)
                                    {
                                        aCasco          = new Asigurat(uid, conStr);
                                        aCasco.DENUMIRE = si.InsuredFullName;
                                        r = aCasco.Insert();
                                    }
                                    d.ID_ASIGURAT_CASCO = aCasco.ID;
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }

                            try
                            {
                                if (!String.IsNullOrWhiteSpace(si.SubrogationGuiltyPartner))
                                {
                                    Asigurat aRca = new Asigurat(uid, conStr, si.SubrogationGuiltyPartner);
                                    if (aRca == null || aRca.ID == null)
                                    {
                                        aRca          = new Asigurat(uid, conStr);
                                        aRca.DENUMIRE = si.SubrogationGuiltyPartner;
                                        r             = aRca.Insert();
                                    }
                                    d.ID_ASIGURAT_RCA = aRca.ID;
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }

                            try
                            {
                                if (!String.IsNullOrWhiteSpace(si.InsuredCarPlateNo))
                                {
                                    Auto autoCasco = new Auto(uid, conStr, si.InsuredCarPlateNo);
                                    if (autoCasco == null || autoCasco.ID == null)
                                    {
                                        autoCasco             = new Auto(uid, conStr);
                                        autoCasco.NR_AUTO     = si.InsuredCarPlateNo;
                                        autoCasco.MARCA       = si.InsuredCarBrandName;
                                        autoCasco.MODEL       = si.InsuredCarModelName;
                                        autoCasco.SERIE_SASIU = si.InsuredCarChassisNo;
                                        r = autoCasco.Insert();
                                    }
                                    d.ID_AUTO_CASCO = autoCasco.ID;
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }

                            try
                            {
                                if (!String.IsNullOrWhiteSpace(si.SubrogationCarPlateNo))
                                {
                                    Auto autoRca = new Auto(uid, conStr, si.SubrogationCarPlateNo);
                                    if (autoRca == null || autoRca.ID == null)
                                    {
                                        autoRca         = new Auto(uid, conStr);
                                        autoRca.NR_AUTO = si.SubrogationCarPlateNo;
                                        //autoRca.MARCA = si.SubrogationCarBrandName;
                                        //autoRca.MODEL = si.SubrogationCarModelName;
                                        autoRca.SERIE_SASIU = si.SubrogationCarChassisNo;
                                        r = autoRca.Insert();
                                    }
                                    d.ID_AUTO_RCA = autoRca.ID;
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }

                            try { d.CAZ = si.AmiableAssessmentNo; } catch { }
                            try { d.DATA_CREARE = d.DATA_ULTIMEI_MODIFICARI = DateTime.Now; } catch { }
                            try {
                                if (si.LossDate == DateTime.MinValue)
                                {
                                    d.DATA_EVENIMENT = null;
                                }
                                else
                                {
                                    d.DATA_EVENIMENT = si.LossDate;
                                }
                            } catch { }
                            try { d.DATA_NOTIFICARE = si.AssessmentDate; } catch { } //?? - la ei este Data Constatarii, nu cred ca e tot una cu Data Notificarii de la noi
                            try { d.NR_DOSAR_CASCO = si.ClaimFileNo; } catch { }
                            try { d.NR_POLITA_CASCO = si.InsuredPolicyNo; } catch { }
                            try { d.NR_POLITA_RCA = si.SubrogationRcoPolicyNo; } catch { }
                            try { d.SUMA_IBNR = d.VALOARE_DAUNA = d.VALOARE_REGRES = d.VMD = d.REZERVA_DAUNA = Convert.ToDouble(si.ClaimReserveValueRon); } catch { }
                            try { d.LOC_ACCIDENT = String.Format("{0}{1}{2}{3}{4}{5}",
                                                                 si.LossCountry,
                                                                 String.IsNullOrWhiteSpace(si.LossCity) ? "" : ", " + si.LossCity,
                                                                 String.IsNullOrWhiteSpace(si.LossDistrictNo.ToString()) ? "" : ", sector " + si.LossDistrictNo.ToString(),
                                                                 String.IsNullOrWhiteSpace(si.LossStreet) ? "" : ", str. " + si.LossStreet,
                                                                 String.IsNullOrWhiteSpace(si.LossStreetNo) ? "" : ", nr. " + si.LossStreetNo,
                                                                 String.IsNullOrWhiteSpace(si.LossIntersection) ? "" : ", intersectie cu str. " + si.LossIntersection); } catch { }

                            validationResponse = d.Validare();
                            if (validationResponse.Status)
                            {
                                r = d.Insert();
                                validationResponse.InsertedId = r.InsertedId;
                                validationResponse.Status     = true;
                                if (r.Status && r.InsertedId != null)
                                {
                                    d.Log(validationResponse, 1);  // 1 = automatic import
                                    ClaimDocumentSummary[] cdss = s.BrowseClaimDocuments(si.ClaimId, DateTime.MinValue);
                                    foreach (ClaimDocumentSummary cds in cdss)
                                    {
                                        try
                                        {
                                            //TipDocument td = new TipDocument(uid, conStr, cds.CategoryName);
                                            TipDocument td         = null;
                                            int?        id_tip_doc = GetTipDocumentMapping(TipuriDocumentMappings, cds.CategoryId);
                                            if (id_tip_doc != null && id_tip_doc != 0)
                                            {
                                                td = new TipDocument(uid, conStr, Convert.ToInt32(id_tip_doc));
                                            }

                                            DocumentScanat ds = new DocumentScanat(uid, conStr);
                                            ds.DENUMIRE_FISIER = String.IsNullOrWhiteSpace(cds.Name) ? cds.FileName : cds.Name;
                                            ds.EXTENSIE_FISIER = !String.IsNullOrWhiteSpace(cds.Extension) ? cds.Extension : !String.IsNullOrWhiteSpace(cds.Name) ? cds.Name.Substring(cds.Name.LastIndexOf('.')) : cds.FileName.Substring(cds.FileName.LastIndexOf('.'));
                                            ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID);
                                            ds.ID_DOSAR        = Convert.ToInt32(d.ID);

                                            BinaryContent bc = s.GetClaimDocumentDetails(cds.Id);
                                            ds.FILE_CONTENT = bc.BinaryData;

                                            ds.CALE_FISIER = FileManager.SaveBinaryContentToFile(bc.BinaryData, ds.EXTENSIE_FISIER);

                                            response rd = ds.Validare();
                                            if (rd.Status)
                                            {
                                                rd = ds.Insert();
                                                ds.Log(rd, 1); // 1 = automatic import
                                            }
                                            if (!rd.Status)    // marcam dosarul ca citit (preluat) de la Allianz doar daca s-a reusit preluarea tuturor documentelor asociate
                                            {
                                                r.AddResponse(rd);
                                            }
                                        }
                                        catch (Exception exp) {
                                            LogWriter.Log(exp);
                                            r.AddResponse(new response(false, exp.ToString(), null, null, new List <Error>()
                                            {
                                                new Error(exp)
                                            }));
                                        }
                                    }

                                    if (r.Status)
                                    {
                                        if (!WithoutMarkings)
                                        {
                                            s.MarkAsReadByClaimId(si.ClaimId);
                                        }
                                        if (WithoutEmails && WithPdfs)
                                        {
                                            d.GenerateNotificarePdf();
                                        }
                                        if (!WithoutEmails)
                                        {
                                            d.SendNotificare(EmailProfiles.AwsNotificariSES);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                r = d.InsertWithErrors();
                                validationResponse.Status     = false;
                                validationResponse.InsertedId = r.InsertedId;
                                if (r.Status && r.InsertedId != null)
                                {
                                    d.Log(validationResponse, 1); // 1 = automatic import
                                    ClaimDocumentSummary[] cdss = s.BrowseClaimDocuments(si.ClaimId, DateTime.MinValue);
                                    foreach (ClaimDocumentSummary cds in cdss)
                                    {
                                        try
                                        {
                                            //TipDocument td = new TipDocument(uid, conStr, cds.CategoryName);
                                            TipDocument td         = null;
                                            int?        id_tip_doc = GetTipDocumentMapping(TipuriDocumentMappings, cds.CategoryId);
                                            if (id_tip_doc != null && id_tip_doc != 0)
                                            {
                                                td = new TipDocument(uid, conStr, Convert.ToInt32(id_tip_doc));
                                            }

                                            DocumentScanat ds = new DocumentScanat(uid, conStr);
                                            ds.DENUMIRE_FISIER = String.IsNullOrWhiteSpace(cds.Name) ? cds.FileName : cds.Name;
                                            ds.EXTENSIE_FISIER = !String.IsNullOrWhiteSpace(cds.Extension) ? cds.Extension : !String.IsNullOrWhiteSpace(cds.Name) ? cds.Name.Substring(cds.Name.LastIndexOf('.')) : cds.FileName.Substring(cds.FileName.LastIndexOf('.'));
                                            ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID);
                                            ds.ID_DOSAR        = Convert.ToInt32(d.ID);

                                            BinaryContent bc = s.GetClaimDocumentDetails(cds.Id);
                                            ds.FILE_CONTENT = bc.BinaryData;

                                            ds.CALE_FISIER = FileManager.SaveBinaryContentToFile(bc.BinaryData, ds.EXTENSIE_FISIER);

                                            response rd = ds.Validare();
                                            if (rd.Status)
                                            {
                                                rd = ds.InsertWithErrors();
                                                ds.Log(rd, 1); // 1 = automatic import
                                            }
                                            if (!rd.Status)    // marcam dosarul ca citit (preluat) de la Allianz doar daca s-a reusit preluarea tuturor documentelor asociate
                                            {
                                                r.AddResponse(rd);
                                            }
                                        }
                                        catch (Exception exp) {
                                            LogWriter.Log(exp);
                                            r.AddResponse(new response(false, exp.ToString(), null, null, new List <Error>()
                                            {
                                                new Error(exp)
                                            }));
                                        }
                                    }

                                    if (r.Status)
                                    {
                                        if (!WithoutMarkings)
                                        {
                                            s.MarkAsReadByClaimId(si.ClaimId);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception exp) { LogWriter.Log(exp); }
                        counter++;
                    }
                }
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
            }
        }
示例#8
0
        // Process all files in the directory passed in, recurse on any directories
        // that are found, and process the files they contain.
        public static void ProcessDirectory(string targetDirectory, SOCISA.Models.Dosar dosar)
        {
            string   conStr          = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString(), CommonFunctions.StringCipher.RetrieveKey());
            int      _CURENT_USER_ID = 1;
            response r        = new response();
            string   LOG_FILE = "c:\\Uploads\\Log.txt";

            try
            {
                // Recurse into subdirectories of this directory.
                string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
                if (DocumenteAll)
                {
                    foreach (string subdirectory in subdirectoryEntries)
                    {
                        if (subdirectory.ToUpper().Substring(subdirectory.LastIndexOf('\\') + 1) == dosar.NR_DOSAR_CASCO.ToUpper())
                        {
                            try
                            {
                                //incarcam documentele
                                string[] docs = Directory.GetFiles(subdirectory, "*.*", SearchOption.AllDirectories);

                                /*
                                 * StreamWriter sss = File.AppendText(dosar.NR_DOSAR_CASCO + "_docs.txt");
                                 * foreach (string f in docs)
                                 * {
                                 *  sss.Write(String.Format("{0}\r\n", f));
                                 * }
                                 * sss.Flush(); sss.Dispose();
                                 */
                                TipDocument td = new TipDocument(_CURENT_USER_ID, conStr, "ALTE INSCRISURI");
                                foreach (string fileName in docs)
                                {
                                    try
                                    {
                                        DocumentScanat ods = new DocumentScanat(_CURENT_USER_ID, conStr, fileName.Substring(fileName.LastIndexOf('\\') + 1), Convert.ToInt32(dosar.ID));
                                        if (ods != null && ods.ID != null) // exista deja documentul in bd
                                        {
                                            Console.Write(String.Format("{0} - {1} exista deja in baza de date!", dosar.NR_DOSAR_CASCO, fileName));
                                            StreamWriter sw = File.AppendText(LOG_FILE);
                                            sw.Write(String.Format("{0} - {1} exista deja in baza de date!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                            sw.Flush(); sw.Dispose();
                                        }
                                        else
                                        {
                                            string newFName = FileManager.CopyFileToServer(fileName);
                                            if (newFName != null)
                                            {
                                                DocumentScanat ds = new DocumentScanat(_CURENT_USER_ID, conStr);
                                                ds.CALE_FISIER     = newFName;
                                                ds.DENUMIRE_FISIER = fileName.Substring(fileName.LastIndexOf('\\') + 1);
                                                ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID);
                                                ds.ID_DOSAR        = Convert.ToInt32(dosar.ID);
                                                r = ds.Insert();
                                                if (r.Status)
                                                {
                                                    Console.Write(String.Format("{0} - {1} importat!", dosar.NR_DOSAR_CASCO, fileName));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} importat!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                                else
                                                {
                                                    Console.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception exp) { LogWriter.Log(exp); }
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }
                        }
                        ProcessDirectory(subdirectory, dosar);
                    }
                }
                else
                {
                    foreach (string subdirectory in subdirectoryEntries)
                    {
                        if (subdirectory.ToUpper().Substring(subdirectory.LastIndexOf('\\') + 1) == String.Format("{0} DOC", dosar.NR_DOSAR_CASCO.ToUpper()))
                        {
                            try
                            {
                                //incarcam documentele
                                string[]    docs = Directory.GetFiles(subdirectory);
                                TipDocument td   = new TipDocument(_CURENT_USER_ID, conStr, "ALTE INSCRISURI");
                                foreach (string fileName in docs)
                                {
                                    try
                                    {
                                        DocumentScanat ods = new DocumentScanat(_CURENT_USER_ID, conStr, fileName.Substring(fileName.LastIndexOf('\\') + 1), Convert.ToInt32(dosar.ID));
                                        if (ods != null && ods.ID != null) // exista deja documentul in bd
                                        {
                                            Console.Write(String.Format("{0} - {1} exista deja in baza de date!", dosar.NR_DOSAR_CASCO, fileName));
                                            StreamWriter sw = File.AppendText(LOG_FILE);
                                            sw.Write(String.Format("{0} - {1} exista deja in baza de date!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                            sw.Flush(); sw.Dispose();
                                        }
                                        else
                                        {
                                            string newFName = FileManager.CopyFileToServer(fileName);
                                            if (newFName != null)
                                            {
                                                DocumentScanat ds = new DocumentScanat(_CURENT_USER_ID, conStr);
                                                ds.CALE_FISIER     = newFName;
                                                ds.DENUMIRE_FISIER = fileName.Substring(fileName.LastIndexOf('\\') + 1);
                                                ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID);
                                                ds.ID_DOSAR        = Convert.ToInt32(dosar.ID);
                                                r = ds.Insert();
                                                if (r.Status)
                                                {
                                                    Console.Write(String.Format("{0} - {1} importat!", dosar.NR_DOSAR_CASCO, fileName));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} importat!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                                else
                                                {
                                                    Console.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception exp) { LogWriter.Log(exp); }
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }
                        }

                        if (subdirectory.ToUpper().Substring(subdirectory.LastIndexOf('\\') + 1) == String.Format("{0} PLANSE", dosar.NR_DOSAR_CASCO.ToUpper()))
                        {
                            try
                            {
                                //incarcam plansele
                                string[]    docs = Directory.GetFiles(subdirectory);
                                TipDocument td   = new TipDocument(_CURENT_USER_ID, conStr, "FOTOGRAFII DE CONSTATARE");
                                foreach (string fileName in docs)
                                {
                                    try
                                    {
                                        DocumentScanat ods = new DocumentScanat(_CURENT_USER_ID, conStr, fileName.Substring(fileName.LastIndexOf('\\') + 1), Convert.ToInt32(dosar.ID));
                                        if (ods != null && ods.ID != null) // exista deja documentul in bd
                                        {
                                            Console.Write(String.Format("{0} - {1} exista deja in baza de date!", dosar.NR_DOSAR_CASCO, fileName));
                                            StreamWriter sw = File.AppendText(LOG_FILE);
                                            sw.Write(String.Format("{0} - {1} exista deja in baza de date!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                            sw.Flush(); sw.Dispose();
                                        }
                                        else
                                        {
                                            string newFName = FileManager.CopyFileToServer(fileName);
                                            if (newFName != null)
                                            {
                                                DocumentScanat ds = new DocumentScanat(_CURENT_USER_ID, conStr);
                                                ds.CALE_FISIER     = newFName;
                                                ds.DENUMIRE_FISIER = fileName.Substring(fileName.LastIndexOf('\\') + 1);
                                                ds.ID_TIP_DOCUMENT = Convert.ToInt32(td.ID);
                                                ds.ID_DOSAR        = Convert.ToInt32(dosar.ID);
                                                r = ds.Insert();
                                                if (r.Status)
                                                {
                                                    Console.Write(String.Format("{0} - {1} importat!", dosar.NR_DOSAR_CASCO, fileName));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} importat!\r\n", dosar.NR_DOSAR_CASCO, fileName));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                                else
                                                {
                                                    Console.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    StreamWriter sw = File.AppendText(LOG_FILE);
                                                    sw.Write(String.Format("{0} - {1} eroare, {2}!", dosar.NR_DOSAR_CASCO, fileName, r.Message));
                                                    sw.Flush(); sw.Dispose();
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception exp) { LogWriter.Log(exp); }
                                }
                            }
                            catch (Exception exp) { LogWriter.Log(exp); }
                        }
                        ProcessDirectory(subdirectory, dosar);
                    }
                }
            }
            catch (Exception exp)
            {
                LogWriter.Log(exp);
            }
        }