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 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));
        }
Exemple #3
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");
    }
        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);
                }
            }
        }
    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");
        }
    }
Exemple #9
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();
            }
        }