public static Process GetOneProcess(RequestorInfo requestorInfo)
        {
            Process tempProcess = new Process();

            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                tempProcess = ctx.Process.Include("DataToProcess").Include("DataToResult").Include("Model").Include("ConfigApp").Include("Output").FirstOrDefault(p => p.status_id == 1); // || p.status_id == 3 || p.status_id == 4);

                try
                {
                    if (tempProcess != null)
                    {
                        //TRATATIVA de INTEGRIDADE dos DADOS
                        ParseIntegration(ref tempProcess);
                        //SETA STATUS, se possível
                        SetStatus(ref tempProcess, ref requestorInfo);
                    }
                    return(tempProcess);
                }
                catch (Exception ex)
                {
                    GICO.WriteLine(String.Format("{0}> {1} ({2} {3})", tempProcess.guid.ToString(), DateTime.Now, "Exception:", ex.Message.ToString()));

                    BasicEnums.State newstatus = BasicEnums.State.Error;
                    SetOneProcess(tempProcess.guid, newstatus, requestorInfo);

                    return(null);
                }
            }
        }
    protected void GridViewProcess_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Guid user = new Guid(e.Row.Cells[4].Text.ToString());
            e.Row.Cells[4].Text = User(user);

            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                List <Process> processes = new List <Process>();

                GridView gvChildGrid = (GridView)e.Row.FindControl("gvChildGrid");
                Guid     gui         = new Guid(e.Row.Cells[2].Text.Trim());

                foreach (Process temp in ctx.Process.Include("DataToProcess").Include("Status").Where(p => p.guidFather == gui || p.guid == gui).ToList().OrderBy(p => p.date))
                {
                    Process item = new Process();
                    item.label         = temp.label;
                    item.date          = temp.date;
                    item.guid          = temp.guid;
                    item.userId        = temp.userId;
                    item.status_id     = temp.status_id;
                    item.Status        = temp.Status;
                    item.DataToProcess = temp.DataToProcess;

                    processes.Add(item);
                }

                gvChildGrid.DataSource = processes;
                gvChildGrid.DataBind();
            }
        }
    }
        public static Process GetOneProcessGuiForETL(Guid gui, Services.DistributedService.RequestorInfo requestorInf)
        {
            Process tempProcess = new Process();

            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                tempProcess = ctx.Process.Include("DataToProcess").Include("DataToResult").Include("Model").Include("ConfigApp").Include("Output").FirstOrDefault(p => p.guid == gui);

                try
                {
                    if (tempProcess != null)
                    {
                        //TRATATIVA de INTEGRIDADE dos DADOS
                        ParseIntegration(ref tempProcess);
                        GICO.WriteLine(gui, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "Processing ETL", requestorInf.macAddr, requestorInf.machineName));
                    }
                    return(tempProcess);
                }
                catch (Exception ex)
                {
                    GICO.WriteLine(String.Format("{0} {1} ({2} {3})", tempProcess.guid.ToString(), DateTime.Now, "Exception:", ex.Message.ToString()));

                    BasicEnums.State newstatus = BasicEnums.State.ETLError;
                    SetOneProcess(tempProcess.guid, newstatus, requestorInf);

                    return(null);
                }
            }
        }
    private static void SendMail(GridProteinFoldingEntities ctx, Guid guid, string message, string webServerName)
    {
        //Sent e-mail
        SmtpClient   smtpClient = new SmtpClient();
        Process      process    = ctx.Process.FirstOrDefault(p => p.guid == guid);
        aspnet_Users user       = new GridProteinFolding_MemberShipEntities().aspnet_Users.FirstOrDefault(u => u.UserId == process.userId);

        try
        {
            string key = string.Empty;

            System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(user.aspnet_Membership.LoweredEmail, user.UserName);
            string subject = "eFolding - Simulation";
            string body    = "Simulation " + process.guid.ToString() + message;

            body += "</br>Direct access: " + string.Format("http://" + webServerName + "/Pages/SimulationAddEdit.aspx?guId={0}", process.guid.ToString());

            smtpClient.Send(to, subject, body);
        }
        catch (Exception ex)
        {
            GICO.WriteLine(ex);
        }
        finally
        {
            smtpClient = null;
        }
    }
    private void UpdateStatus(Guid guid, int value)
    {
        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            Process process = ctx.Process.FirstOrDefault(p => p.guid == guid);
            process.status_id = Convert.ToByte(value);

            ctx.SaveChanges();
        }
    }
        public static List <Guid> GetGuidsToApplications()
        {
            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                List <Guid> guid = ctx.Process.Where(p => p.status_id == 8)
                                   .Select(p => p.guid)
                                   .ToList <Guid>();

                return(guid);
            }
        }
        public static byte SetOneProcess(Guid guid, BasicEnums.State state, RequestorInfo requestorInfo)
        {
            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                Process temp = ctx.Process.FirstOrDefault(p => p.guid == guid);
                temp.status_id   = Convert.ToByte(state);
                temp.macAddr     = requestorInfo.macAddr;
                temp.machineName = requestorInfo.machineName;
                ctx.SaveChanges();

                Condicional(guid, ctx, temp, ref state, ref requestorInfo);
            }

            return(GetStatus(guid));
        }
 public static bool Autentication(RequestorInfo requestorInfo, ref string message)
 {
     using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
     {
         ClientCurrentVersion clientCurrentVersion = ctx.ClientCurrentVersion.FirstOrDefault();
         if (clientCurrentVersion.currentVersion.Equals(requestorInfo.clientVersion))
         {
             return(true);
         }
         else
         {
             message = "ERROR: Client version is not valid. You must make the update through the version available at http://efolding.fcfrp.usp.br/App/";
             return(false);
         }
     }
 }
        public static byte GetStatus(Guid guid)
        {
            Process temp = new Process();

            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                temp = ctx.Process.FirstOrDefault(p => p.guid == guid);
                if (temp != null)
                {
                    return(temp.status_id);
                }
                else
                {
                    return(0);
                }
            }
        }
    private void List(string text)
    {
        List <Process> processes = new List <Process>();

        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            if (text == string.Empty)
            {
                foreach (Process temp in ctx.Process.Include("DataToProcess").Include("Status").Where(p => p.guidFather == null).ToList().OrderByDescending(p => p.date))
                {
                    Process item = new Process();
                    item.label         = temp.label;
                    item.date          = temp.date;
                    item.guid          = temp.guid;
                    item.userId        = temp.userId;
                    item.status_id     = temp.status_id;
                    item.Status        = temp.Status;
                    item.DataToProcess = temp.DataToProcess;
                    processes.Add(item);
                }
            }
            else
            {
                foreach (Process temp in ctx.Process.Include("DataToProcess").Include("Status").ToList().Where(p => p.guidFather == null && p.label.Contains(text)).OrderByDescending(p => p.date))
                {
                    Process item = new Process();
                    item.label         = temp.label;
                    item.date          = temp.date;
                    item.guid          = temp.guid;
                    item.userId        = temp.userId;
                    item.status_id     = temp.status_id;
                    item.Status        = temp.Status;
                    item.DataToProcess = temp.DataToProcess;
                    processes.Add(item);
                }
            }
        }

        GridViewProcess.DataSource = processes;
        GridViewProcess.DataBind();

        lblTotal.Text      = processes.Count.ToString();
        lblActualPage.Text = (GridViewProcess.PageIndex + 1).ToString();
        lblTotalPages.Text = GridViewProcess.PageCount.ToString();
    }
        private static bool SendMail(GridProteinFoldingEntities ctx, Guid guid, string message, aspnet_Users user)
        {
            //Sent e-mail
            Middle.Helpers.NetworkHelpers.SmtpClient smtpClient = new Middle.Helpers.NetworkHelpers.SmtpClient();
            Process process = ctx.Process.FirstOrDefault(p => p.guid == guid);


            if (!(process.emailNotification == Convert.ToByte(BasicEnums.EmailNotification.Enviar)))
            {
                try
                {
                    System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress(user.aspnet_Membership.LoweredEmail, user.UserName);
                    string subject = "eFolding - Simulation";
                    string body    = "Simulation " + process.guid.ToString() + message;
                    body += "Direct access: efolding.fcfrp.usp.br/Pages/GCPS.aspx?guid= " + process.guid.ToString();

                    if (smtpClient.Send(to, subject, body))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (SmtpException ex)
                {
                    new GridProteinFolding.Middle.Helpers.LoggingHelpers.Log().SmtpException(ex, Types.ErrorLevel.Warning);
                    return(false);
                }
                catch (Exception ex)
                {
                    GICO.WriteLine(ex);
                    throw;
                }
                finally
                {
                    smtpClient = null;
                }
            }
            else
            {
                return(true);
            }
        }
Example #12
0
        private GridProteinFoldingEntities AddToContext(GridProteinFoldingEntities context,
                                                        Entities.Internal.Configuration entity, int count, int commitCount, bool recreateContext)
        {
            context.Set <Entities.Internal.Configuration>().Add(entity);

            if (count % commitCount == 0)
            {
                context.SaveChanges();
                if (recreateContext)
                {
                    context.Dispose();
                    context = new GridProteinFoldingEntities();
                    //context.Configuration.AutoDetectChangesEnabled = false;
                }
            }

            return(context);
        }
    private void Delete(Guid guid)
    {
        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            var model = ctx.Model.FirstOrDefault(f => f.process_guid == guid);
            ctx.Model.Remove(model);


            var data = ctx.DataToProcess.FirstOrDefault(f => f.process_guid == guid);
            ctx.DataToProcess.Remove(data);

            var form = ctx.Process.FirstOrDefault(f => f.guid == guid);
            ctx.Process.Remove(form);

            ctx.SaveChanges();
        }

        List();
    }
        public static bool SetBlob(Guid guid, byte[] data)
        {
            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                Blob temp = ctx.Blob.FirstOrDefault(p => p.process_guid == guid);

                if (temp == null)
                {
                    temp.blob1 = data;
                }
                else
                {
                    temp.process_guid = guid;
                    temp.blob1        = data;
                    ctx.Blob.Add(temp);
                }

                ctx.SaveChanges();
            }

            return(true);
        }
    private void Edit()
    {
        Guid guid = new Guid(ViewState["guid"].ToString());

        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            Process process = ctx.Process.First(p => p.guid == guid);
            process.note = txtNote.Text.ToString().Trim();

            DataToProcess data = ctx.DataToProcess.First(p => p.process_guid == guid);

            data.isem           = Convert.ToInt32(txtIsem.Text.Trim());
            data.loadDatFile    = false;
            data.maxInterations = Convert.ToInt32(txtMaxInterations.Text.Trim());
            //data.numberOfDelta = Convert.ToDouble(txtNumberOfDelta.Text.Trim());
            data.totalSitio = Convert.ToInt32(txtTotalSitio.Text.Trim());

            //List<Model> model = ctx.Model.Where(p=>p.process_guid == guid).ToList<Model>();

            ctx.SaveChanges();
        }
        Response.Redirect("~/Pages/Simulation.aspx");
    }
Example #16
0
        private void SentData(Param param)
        {
            GICO.WriteLine("OriginConnect: Salving points of Seed {0}..", param.dataToProcess.Guid.ToString());
            //Protein.LoadSeedCoord(fileReader, true);
            using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            {
                List <Entities.Internal.Configuration> configuration = ctx.Configuration.Where(c => c.process_guid == param.dataToProcess.Guid && c.mcStep == 0).ToList();

                foreach (Entities.Internal.Configuration coordinate in configuration)
                {
                    int nFactor = pWorksheet.Rows;
                    pointX = coordinate.x;
                    pointY = coordinate.y;
                    pointZ = coordinate.z;

                    double[,] Data = new double[1, 3];
                    Data[0, 0]     = pointX;
                    Data[0, 1]     = pointY;
                    Data[0, 2]     = pointZ;
                    pWorksheet.SetData(Data, -1, 0); //append
                }
            }
        }
    private void GetData()
    {
        Guid guid = new Guid(ViewState["guid"].ToString());

        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            Process temp = ctx.Process
                           .Include("DataToProcess")
                           .Include("Status").SingleOrDefault(p => p.guid == guid);

            txtIsem.Text           = temp.DataToProcess.isem.ToString();
            txtMaxInterations.Text = temp.DataToProcess.maxInterations.ToString();

            txtTotalSitio.Text  = temp.DataToProcess.totalSitio.ToString();
            txtTemperature.Text = temp.DataToProcess.temperature.ToString();

            txtNote.Text  = temp.note;
            txtLabel.Text = temp.label;

            txtTemperature.Text = string.Empty;
            foreach (Model model in ctx.Model.Where(p => p.process_guid == guid).ToList <Model>())
            {
                txtModelHP.Text += model.value == 0 ? "H;" : "P;";
            }

            gvLog.DataSource = ctx.ProcessLog.Where(p => p.process_guid == guid).ToList();

            gvLog.DataBind();

            if (temp.StatusDescription != "created")
            {
                bttFinish.Visible = false;
            }
        }

        return;
    }
        //public static Entities.Internal.ConfigApp GetConfigApp()
        //{

        //    Entities.Internal.ConfigApp temp = new Entities.Internal.ConfigApp();

        //    using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        //    {
        //        temp = ctx.ConfigApp.FirstOrDefault();
        //    }

        //    return temp;
        //}


        //public static void RunMonteC(Guid guid)
        //{
        //    using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        //    {
        //        GridProteinFolding.Entities.Internal.DataToProcess temp = ctx.DataToProcess.FirstOrDefault(p => p.process_guid == guid);

        //        temp.runMonteC = true;

        //        ctx.SaveChanges();
        //    }
        //}


        //public static void SetUFile(Param param)
        //{
        //    SetUFile(param.dataToProcess.Guid, param.files.Debug);
        //}

        //public static void SetUFile(Guid guid, string Ufile)
        //{
        //    using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        //    {
        //        GridProteinFolding.Entities.Internal.Files temp = ctx.Files.FirstOrDefault(p => p.guid == guid);
        //        if (temp != null)
        //            temp.UFile = Ufile;
        //        else
        //        {
        //            GridProteinFolding.Entities.Internal.Files files = new GridProteinFolding.Entities.Internal.Files();
        //            files.guid = guid;
        //            files.UFile = Ufile;
        //            ctx.AddToFiles(files);
        //        }
        //        ctx.SaveChanges();
        //    }
        //}

        private static void Expurg(Guid processGuid, GridProteinFoldingEntities ctx)
        {
            ////List<Seed> seed = ctx.Seed.Where(p => p.process_guid == processGuid).ToList<Seed>();

            ////if (seed != null & seed.Count > 0)
            ////{
            ////int seedId = seed[0].isem;
            ////List<Histogram> histogram = ctx.Histogram.Where(p => p.seed_isem == seedId).ToList<Histogram>();

            ////if (histogram != null)
            ////{
            ////    foreach (Histogram item in histogram)
            ////    {
            ////        Frequencies frequencies = ctx.Frequencies.FirstOrDefault(p => p.histogram_id == item.id);
            ////        ctx.DeleteObject(frequencies);

            ////        ctx.DeleteObject(histogram);
            ////    }
            ////}

            ////List<Neighbors> neighbors = ctx.Neighbors.Where(p => p.seed_isem == seedId).ToList<Neighbors>();
            ////if (neighbors != null && neighbors.Count > 0)
            ////{
            ////    ctx.DeleteObject(neighbors);
            ////}

            ////foreach (Seed item in seed)
            ////{
            ////    ctx.DeleteObject(item);
            ////}

            //ProcessLog processLog = ctx.ProcessLog.FirstOrDefault(p => p.process_guid == processGuid);
            //ctx.DeleteObject(processLog);

            //ctx.SaveChanges();
            //// }
        }
    private void Create()
    {
        //lblLog.Visible = false;
        //byte[] appData = null;
        //bool uploadFile = false;

        //foreach (string fileName in Request.Files)
        //{

        //    HttpPostedFileBase postedFile = Request.Files[fileName];

        //    if (postedFile.FileName != string.Empty)
        //    {
        //        uploadFile = true;
        //        Stream s = postedFile.InputStream;
        //        appData = new byte[postedFile.ContentLength + 1];
        //        s.Read(appData, 0, postedFile.ContentLength);
        //    }
        //}

        //load last CONFIGAPP
        ConfigApp lastConfigApp;

        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            lastConfigApp = ctx.ConfigApp.FirstOrDefault();
        }

        using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
        {
            bool first      = true;
            Guid guidFather = new Guid();

            double[] tempers = txtTemperature.Text.Split(';').Select(double.Parse).ToArray();

            for (int t = 0; t < tempers.Length; t++)
            {
                double temper = tempers[t];
                #region NEW PROCESS
                Process process = new Process();
                process.guid              = Guid.NewGuid();
                process.date              = DateTime.Now;
                process.userId            = GetUserID();
                process.status_id         = 0; //=CRIADO
                process.note              = txtNote.Text.ToString().Trim();
                process.emailNotification = Convert.ToByte(chkEmail.Checked);
                process.label             = txtLabel.Text.ToString().Trim();

                process.configApp_id = lastConfigApp.id;

                if (!first)
                {
                    process.guidFather = guidFather;
                }
                ctx.Process.Add(process);
                #endregion

                #region NEW DATATORESULT
                DataToResult dataToResult = new DataToResult();
                dataToResult.process_guid   = process.guid;
                dataToResult.valueDiscard   = Convert.ToInt32(txtValueDiscard.Text);
                dataToResult.valueDivResult = Convert.ToInt32(txtValueDivResult.Text);
                ctx.DataToResult.Add(dataToResult);
                #endregion


                #region DATATOPROCESS
                DataToProcess dataToProcess = new DataToProcess();
                //dataToProcess.loadDatFile = uploadFile;

                //if (uploadFile)
                //{

                //    dataToProcess.file = new System.Text.ASCIIEncoding().GetString(appData);
                //    dataToProcess.isem = Convert.ToInt32(txtIsem.Text.Trim());
                //    dataToProcess.maxInterations = 1;
                //    dataToProcess.numberOfDelta = Convert.ToDouble(txtNumberOfDelta.Text.Trim());
                //    dataToProcess.calcDelta = true;
                //    dataToProcess.process_guid = process.guid;
                //    //string[] lines = Regex.Split(dataToProcess.file, "\r\n");
                //    dataToProcess.totalSitio = lines.Length - 1;
                //}

                //else
                //{
                dataToProcess.file           = null;
                dataToProcess.isem           = Convert.ToInt32(txtIsem.Text.Trim());
                dataToProcess.maxInterations = Convert.ToInt32(txtMaxInterations.Text.Trim());
                //P dataToProcess.valueOfDelta = Convert.ToDouble(txtValueOfDelta.Text.Trim());
                dataToProcess.process_guid      = process.guid;
                dataToProcess.totalSitio        = Convert.ToInt32(txtTotalSitio.Text.Trim());
                dataToProcess.modelType         = Convert.ToByte(ddlModel.SelectedValue);
                dataToProcess.beta              = 1;      // Convert.ToDouble(txtBeta.Text.Trim());
                dataToProcess.maxMotionPeerIsem = Convert.ToInt64(txtMaxMotionPeerIsem.Text.Trim());
                dataToProcess.temperature       = temper; // Convert.ToDouble(txtTemperature.Text);
                dataToProcess.loadDatFile       = null;
                dataToProcess.recPathEvery      = Convert.ToInt32(txtRecPathEvery.Text.Trim());
                dataToProcess.splitFileEvery    = Convert.ToInt32(txtSplitFileEvery.Text.Trim());
                //}
                ctx.DataToProcess.Add(dataToProcess);
                #endregion

                Output output = new Output();
                output.guid          = process.guid;
                output.evolution     = chkEvolution.Checked;
                output.distribution  = chkDistribution.Checked;
                output.configuration = chkConfiguration.Checked;
                //output.configurationJumpStep = Convert.ToInt32(txtConfigRange.Text.Trim());
                output.debug      = chkDebug.Checked;
                output.trajectory = true;

                ctx.Output.Add(output);

                if (dataToProcess.modelType == 3)
                { //ModelTYPE HP
                    string[] modelHP = txtModelHP.Text.Split(';').ToArray <string>();
                    for (int i = 0; i < modelHP.Count(); i++)
                    {
                        Model model = new Model();
                        model.process_guid = process.guid;
                        model.monomero     = (byte)i;
                        model.value        = Convert.ToDouble(modelHP[i] == "H" ? 0 : 1);

                        ctx.Model.Add(model);
                    }
                }
                else
                {
                    //Demais ModelTYPE
                    #region MODEL
                    for (int i = 0; i < dataToProcess.totalSitio; i++)
                    {
                        Model model = new Model();
                        model.process_guid = process.guid;
                        model.monomero     = (byte)i;

                        if (dataToProcess.modelType == 0)
                        {
                            //ModelTYPE Random
                            model.value = 0;
                        }
                        else if (dataToProcess.modelType == 1)
                        {
                            //ModelTYPE Negative
                            model.value = -1;
                        }
                        else if (dataToProcess.modelType == 2)
                        {
                            //ModelTYPE Negative
                            model.value = 1;
                        }

                        ctx.Model.Add(model);
                    }
                    #endregion
                }

                ctx.SaveChanges();

                if (first)
                {
                    guidFather = process.guid;
                    first      = false;
                }

                if (Convert.ToBoolean(process.emailNotification))
                {
                    SendMail(ctx, process.guid, " was created!", Application["webServerName"].ToString());
                }
            }



            Response.Redirect("~/Pages/Simulation.aspx");
        }
    }
Example #20
0
        public void LoadConfigurationOutPutForOrigin()
        {
            GICO.WriteLine(String.Format("  Output: LoadConfigurationOutPutToOrigin: Delete..."));
            ////Delete IF EXIST
            //using (GridProteinFoldingEntities ctx = new GridProteinFoldingEntities())
            //{
            //    ctx.Database.ExecuteSqlCommand("DELETE FROM OUTPUT WHERE guid= {0}", param.dataToProcess.Guid);
            //}

            string readerFile = dirBaseWeb.FullName() + this.param.dataToProcess.Guid + @"\Result\Configuration.dat";

            using (ExtendedStreamReader souceFile = new ExtendedStreamReader(readerFile,
                                                                             this.param.dataToProcess.Guid, false))
            {
                string line;
                int    i = 0;


                GICO.WriteLine(String.Format("  Output: LoadConfigurationOutPutToOrigin: Insert..."));
                while ((line = souceFile.ReadLine()) != null)
                {
                    if (String.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    //pulas cabeçalho e o número de discartes
                    if (i == 0)
                    {
                        line = souceFile.ReadLine();
                    }

                    string[] data   = line.Split('\t').ToArray();
                    Int32    mcStep = 0;
                    int      order  = 0;
                    int      count  = 0;

                    using (TransactionScope scope = new TransactionScope())
                    {
                        GridProteinFoldingEntities ctx = null;

                        try
                        {
                            ctx = new GridProteinFoldingEntities();
                            Entities.Internal.Configuration configuration = null;

                            for (int j = 0; j < data.Length; j++)
                            {
                                if (j == 0)
                                {
                                    mcStep = Convert.ToInt32(data[j]); j++;
                                }

                                configuration = new Entities.Internal.Configuration();

                                configuration.process_guid = this.param.dataToProcess.Guid;
                                configuration.mcStep       = mcStep;
                                configuration.order        = order;
                                configuration.x            = Convert.ToInt32(data[j]); j++;
                                configuration.y            = Convert.ToInt32(data[j]); j++;
                                configuration.z            = Convert.ToInt32(data[j]);

                                order++;

                                ++count;
                                ctx = AddToContext(ctx, configuration, count, 100, true);
                                //ctx.Configuration.Add(configuration);
                            }

                            if (configuration != null)
                            {
                                ctx.SaveChanges();
                                configuration = null;
                            }
                        }
                        finally
                        {
                            if (ctx != null)
                            {
                                ctx.Dispose();
                            }
                        }
                        scope.Complete();
                    }
                    i++;
                }


                souceFile.Close();
                //souceFile = null;
                souceFile.Dispose();
            }
        }
        private static void Condicional(Guid guid, GridProteinFoldingEntities ctx, Process temp, ref BasicEnums.State state, ref RequestorInfo requestorInfo)
        {
            aspnet_Users user = new GridProteinFolding_MemberShipEntities().aspnet_Users.FirstOrDefault(u => u.UserId == temp.userId);

            if (state == BasicEnums.State.Processing)
            {
                GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "Processing", temp.macAddr, temp.machineName));

                string message = " was started!";

                if (temp.emailNotification == Convert.ToByte(BasicEnums.EmailNotification.Enviar))
                {
                    SendMail(ctx, guid, message, user);
                }

                Expurg(guid, ctx);
            }
            if (state == BasicEnums.State.BULK)
            {
                #region BULK
                GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "BULK", temp.macAddr, temp.machineName));
                //ExtendedDirectoryInfo dirBaseServer = new ExtendedDirectoryInfo(ConfigurationManager.AppSettings["dirBaseServer"].ToString());

                //object[] parameters = new object[2];
                //parameters[0] = dirBaseServer + @"\" + guid + @"\Seed";
                //parameters[1] = guid.ToString();

                //ctx.ExecuteStoreCommand("EXEC dbo.BunkFiles {0},{1}", parameters);

                state          = BasicEnums.State.ClearTempClient;
                temp.status_id = Convert.ToByte(state);
                ctx.SaveChanges();
                #endregion

                #region ClearTempServer
                GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "ClearTempServer", temp.macAddr, temp.machineName));
                DeleteFileServer_temp(guid);

                state          = BasicEnums.State.Finalized;
                temp.status_id = Convert.ToByte(state);
                ctx.SaveChanges();
                #endregion
            }

            //if (state == Enums.BasicEnums.State.Excel)
            //{

            //    Applications objApplications = new Applications();

            //    GICO.Write("Excel..");
            //    objApplications.Excel(param);

            //    GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!");
            //    objApplications = null;

            //    state = Enums.BasicEnums.State.Origin;
            //    temp.status_id = Convert.ToByte(state);
            //    ctx.SaveChanges();
            //}

            //if (state == Enums.BasicEnums.State.Origin)
            //{
            //    ProcessData(param.dataToProcess.Guid);

            //    Applications objApplications = new Applications();

            //    GICO.Write("Origin..");
            //    objApplications.Origin(param.dataToProcess.Guid);

            //    GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!");
            //    objApplications = null;

            //    state = Enums.BasicEnums.State.ClearTempClient;
            //    temp.status_id = Convert.ToByte(state);
            //    ctx.SaveChanges();
            //}

            //if (state == BasicEnums.State.ClearTempServer)
            //{
            //    GICO.WriteLine(guid, String.Format("{0} {1}:", DateTime.Now, "ClearTempServer.."));
            //    DeleteFileServer_temp(guid);

            //    state = BasicEnums.State.Finalized;
            //    temp.status_id = Convert.ToByte(state);
            //    ctx.SaveChanges();
            //}

            //if (state == Enums.BasicEnums.State.Decrypt)
            //{
            //    Applications objApplications = new Applications();
            //    GICO.Write("Decrypt..");
            //    objApplications.Decrypt(param);
            //    GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!");
            //    objApplications = null;

            //    state = Enums.BasicEnums.State.Web;
            //    temp.status_id = Convert.ToByte(state);
            //    ctx.SaveChanges();
            //}

            //if (state == Enums.BasicEnums.State.Web)
            //{

            //    Applications objApplications = new Applications();
            //    GICO.Write("Web..");
            //    objApplications.Web(param);
            //    GICO.WriteLine("{0}:{1}", param.dataToProcess.Guid.ToString(), "DONE!");
            //    objApplications = null;

            //    state = Enums.BasicEnums.State.Finalized;
            //    temp.status_id = Convert.ToByte(state);
            //    ctx.SaveChanges();
            //}

            if (state == BasicEnums.State.Finalized)
            {
                GICO.WriteLine(guid, String.Format("{0} {1} @ {2}({3})", DateTime.Now, "Finalized", temp.macAddr, temp.machineName));

                if (temp.emailNotification == Convert.ToByte(BasicEnums.EmailNotification.Enviar))
                {
                    string message = "was completed!";
                    SendMail(ctx, guid, message, user);
                }
            }
        }