Beispiel #1
0
        public IHttpActionResult PostUser(User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Users.Add(user);
            ManageFiles.CreateUserFolder(user.sub, user.given_name);
            ManageFiles.CreateUserFolder(user.sub, "Shared");

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (UserExists(user.sub))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
 protected void btnExportPDF_Click(object sender, EventArgs e)
 {
     incializarExports();
     GridView1.Rows[1].ControlStyle.BackColor = System.Drawing.Color.Black;
     GridView1.Rows[1].ControlStyle.CssClass  = "text-center";
     ManageFiles.ExportToPdf(this, GridView1, "ListadeTrabajadores", "Lista de Trabajadores", "azul");
 }
Beispiel #3
0
        public ActionResult LoadFile(FormCollection itemFile)
        {
            ViewBag.Instrucoes = false;
            var fileItem    = Request.Files[0];
            var uploadFILE1 = itemFile["uploadFILE1"];

            string retornoErro = "";
            // caminho provisório para teste, este deve receber o valor do input
            string caminho = itemFile["filePath"];

            if (ValidaPadraoDir(caminho))
            {
                List <DocumentoModel> itensPlanilha = new List <DocumentoModel>();
                itensPlanilha          = ReadSpreadsheet.ObtemItems(fileItem, out retornoErro);
                @ViewBag.TotalPlanilha = itensPlanilha.Count;
                if (retornoErro == "")
                {
                    if (itensPlanilha.Count > 0)
                    {
                        List <ColecaoDocumentosModel> colecaoDocumentos = new List <ColecaoDocumentosModel>();
                        string dataDiretorio = "";
                        colecaoDocumentos = ManageFiles.LeArquivos(caminho, itensPlanilha, out retornoErro, out dataDiretorio);
                        new Log("Retorno de leitura de arquivos.", colecaoDocumentos);
                        if (retornoErro == "")
                        {
                            ServicoEmail.EnviaEmail(colecaoDocumentos, itensPlanilha, dataDiretorio, out retornoErro);
                            Sumarizacao(colecaoDocumentos);
                            if (retornoErro != "")
                            {
                                @ViewBag.error = retornoErro;
                            }
                            return(View("Index"));
                        }
                        else
                        {
                            @ViewBag.error = retornoErro;
                            return(View("Index"));
                        }
                    }
                    else
                    {
                        @ViewBag.error = "Não foram retornadas informações a partir da planilha selecionada.";
                        return(View("Index"));
                    }
                }
                else
                {
                    @ViewBag.error = retornoErro;
                    return(View("Index"));
                }
            }
            return(View("Index"));
        }
        private void populatelistView(string p)
        {
            try
            {
                //dataGridView1.DataSource = null;
                //dataGridView1.Rows.Clear();

                //dataGridView1.Refresh();
                label2.Text = "";
               //List<Sheets> myMessage= JsonConvert.DeserializeObject<List<Sheets>>(File.ReadAllText(@p));

               var reader = new JsonTextReader(new StreamReader(@p, Encoding.GetEncoding(1251)));
               var serializer = new JsonSerializer { CheckAdditionalContent = false };
               List<Sheets> myMessage = (List<Sheets>)serializer.Deserialize(reader, typeof(List<Sheets>));

                //using (StreamWriter sw = new StreamWriter(@"c:\json.txt"))
                // using (JsonWriter writer = new JsonTextWriter(sw))
                //{
                //    myMessage = JsonConvert.DeserializeObject<List<Sheets>>(writer);
                //     //JsonConvert.de
                //    //serializer.Serialize(writer, product);
                //    // {"ExpiryDate":new Date(1230375600000),"Price":0}
                //}

                foreach (var file in myMessage)
                {                   
                    foreach (Rows r in file.Rows)
                    {
                        if (r.Folders != null)
                        {
                            string strDirIssues = null;
                            foreach (Folder f in r.Folders)
                            {                                                            
                                try
                                {
                                    if (f.MigrateLoc != null)
                                    {
                                        if (Directory.Exists(f.MigrateLoc))
                                        {
                                            ManageFiles mf = new ManageFiles();
                                            intMigratedfiles = 0;
                                            var txtFiles = Directory.EnumerateFiles(f.MigrateLoc, "*.*", SearchOption.TopDirectoryOnly);
                                            mf.sheetno = f.SheetLine;
                                            mf.Location = f.MigrateLoc;
                                            mf.SourceCnt = txtFiles.Count();
                                            mf.MigrateCnt = 0;
                                            mf.MigrateUri = Convert.ToInt64(f.RMuri);
                                            lstmf.Add(mf);
                                        }
                                        else
                                        {
                                            ManageFiles mf = new ManageFiles();
                                            mf.sheetno = f.SheetLine;
                                            mf.Location = f.MigrateLoc;
                                            mf.SourceCnt = 0;
                                            mf.MigrateCnt = 0;
                                            mf.Comments = "Not a valid directory";
                                            mf.MigrateUri = Convert.ToInt64(f.RMuri);
                                            lstmf.Add(mf);
                                            //Loggitt("Source directory issure", f.MigrateLoc + " - " + f.SheetLine.ToString(), LogTypes.dir);
                                            strDirIssues += "Not a valid directory("+f.MigrateLoc + ") - SS line No. " + f.SheetLine.ToString() + Environment.NewLine;
                                        }
                                    }
                                }
                                catch (Exception exp)
                                {
                                    ManageFiles mf = new ManageFiles();
                                    mf.sheetno = f.SheetLine;
                                    mf.Location = f.MigrateLoc;
                                    mf.SourceCnt = 0;
                                    mf.MigrateCnt = 0;
                                    mf.Comments = "Error: " + exp.Message.ToString();
                                    mf.MigrateUri = Convert.ToInt64(f.RMuri);
                                    lstmf.Add(mf);
                                    Loggitt("Error", exp.Message.ToString() + " " + f.MigrateLoc + " - " + f.SheetLine.ToString(), LogTypes.err);
                                }
                                if (f.SubFolders != null)
                                {
                                    foreach (Subfolder sf in f.SubFolders)
                                    {
                                        try
                                        {
                                            if (sf.MigrateLoc != null)
                                            {
                                                //Console.WriteLine("File Location: " + sf.MigrateLoc);
                                                if (Directory.Exists(sf.MigrateLoc))
                                                {
                                                    ManageFiles mf = new ManageFiles();
                                                    intMigratedfiles = 0;
                                                    var txtFiles = Directory.EnumerateFiles(sf.MigrateLoc, "*.*", SearchOption.TopDirectoryOnly);
                                                    mf.sheetno = sf.SheetLine;
                                                    mf.Location = sf.MigrateLoc;
                                                    mf.SourceCnt = txtFiles.Count();
                                                    mf.MigrateCnt = 0;
                                                    mf.MigrateUri = Convert.ToInt64(sf.RMuri);
                                                    lstmf.Add(mf);
                                                }
                                                else
                                                {
                                                    ManageFiles mf = new ManageFiles();
                                                    mf.sheetno = sf.SheetLine;
                                                    mf.Location = sf.MigrateLoc;
                                                    mf.SourceCnt = 0;
                                                    mf.MigrateCnt = 0;
                                                    mf.Comments = "Not a valid directory";
                                                    mf.MigrateUri = Convert.ToInt64(sf.RMuri);
                                                    lstmf.Add(mf);
                                                    //Loggitt("Source directory issure", sf.MigrateLoc+" - "+sf.SheetLine.ToString(), LogTypes.dir);
                                                    strDirIssues += "Not a valid directory(" + f.MigrateLoc + ") - SS line No. " + f.SheetLine.ToString() + Environment.NewLine;
                                                }
                                            }
                                        }
                                        catch (Exception exp)
                                        {
                                            ManageFiles mf = new ManageFiles();
                                            mf.sheetno = f.SheetLine;
                                            mf.Location = f.MigrateLoc;
                                            mf.SourceCnt = 0;
                                            mf.MigrateCnt = 0;
                                            mf.Comments = "Error: " + exp.Message.ToString();
                                            mf.MigrateUri = Convert.ToInt64(f.RMuri);
                                            lstmf.Add(mf);
                                            Loggitt("Error", exp.Message.ToString()+" "+sf.MigrateLoc + " - " + sf.SheetLine.ToString(), LogTypes.err);
                                        }
                                    }
                                }
                                
                            }
                            //build directory log here
                            Loggitt("Source directory issures", strDirIssues, LogTypes.dir);
                        }
                    }
                    
                }
                dataGridView1.DataSource = lstmf;
            }
            catch (Exception exp)
            {
                
                lblError.Text = exp.Message.ToString();
                Loggitt("Error", exp.Message.ToString(), LogTypes.err);
            }
        }
 protected void btnExportExcel_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToExcel(this, GridView1, "ListadeTrabajadores", "Lista de Trabajadores", "azul");
 }
 protected void btnExportWord_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToWord(this, GridView1, "ListadeTrabajadores", "Lista de Trabajadores", "rojo");
 }
 protected void btnExportPDF_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToPdf(this, GridView1, "Planes", "Lista de Planes");
 }
 protected void btnExportPDF_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToPdf(this, GridView1, "GestionLaboral", "Lista de Gestiones Laborales");
 }
 protected void btnExportExcel_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToExcel(this, GridView1, "Alarmas", "Lista de Alarmas");
 }
 protected void btnExportPDF_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToPdf(this, GridView1, "HistoriaClinicaOcupacional", "Lista de examenes");
 }
 protected void btnExportExcel_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToExcel(this, GridView1, "Accidente_Laboral", "Lista de Accidentes Laborales");
 }
 protected void btnExportExcel_Click(object sender, EventArgs e)
 {
     incializarExports();
     ManageFiles.ExportToExcel(this, GridView1, "Puesto_Trabajo", "Lista de Puestos de Trabajo");
 }