コード例 #1
0
        public void CargarDatos()
        {
            //Datos
            var db            = new Models.Entities();
            var suministrador = SumID.Value.ToString();
            var zafra         = db.ParqueEquipos.Where(i => i.Suministradores.nombreSuministrador == suministrador).ToList();

            var diarioGroups = from dia in zafra
                               select new
            {
                tipoEquipo = dia.TipoEquipos.descripcionEquipo,
                cantidad   = dia.cantidadEquipos
            };

            //Fin Datos

            //Enlazando datos
            DataSource = diarioGroups;

            this.Equipo.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "tipoEquipo")
            });

            this.cantEquiposCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "cantidad")
            });

            totalEquiposCell.Text = diarioGroups.Sum(u => u.cantidad).ToString();


            //fin de enlace
        }
コード例 #2
0
        public bool DeleteUser(string userName)
        {
            try
            {
                var               en     = new Models.Entities();
                aspnet_Users      u      = null;
                aspnet_Membership member = null;
                try
                {
                    u      = en.aspnet_Users.First(m => m.UserName == userName);
                    member = en.aspnet_Membership.First(m => m.UserId == u.UserId);

                    en.DeleteObject(member);
                    en.DeleteObject(u);

                    en.SaveChanges();

                    return(true);
                }
                catch
                {
                    throw new ArgumentException("注销失败");
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
ファイル: ExecutionContext.cs プロジェクト: matarillo/Oryzae
 public void SetCurrentUserFromIdentity()
 {
     // ユーザー情報
     // 企業ユーザーの場合は会社情報も取得
     var p = _context.User.Identity;
     if (p.IsAuthenticated)
     {
         using (var db = new Models.Entities())
         {
             db.Configuration.ProxyCreationEnabled = false;
             // TODO: UserNameの一意性保証
             this.CurrentUser = db.Users.FirstOrDefault(x => x.UserName == p.Name);
             var au = this.CurrentUser as Models.AccountUser;
             if (au != null)
             {
                 db.Entry(au).Reference(x => x.Company).Load();
             }
         }
     }
     if (this.CurrentUser == null)
     {
         // 未認証とする
         this.CurrentUser = Models.User.Anonymous;
         if (p.IsAuthenticated)
         {
             // 認証クッキーが有効だが、DBにユーザーが存在しない場合の対処
             var identity = new System.Security.Principal.GenericIdentity("");
             var principal = new System.Security.Principal.GenericPrincipal(identity, null);
             _context.User = principal;
         }
     }
 }
コード例 #4
0
        public string SetValidationCode(string userName)
        {
            if (string.IsNullOrWhiteSpace(userName))
            {
                throw new ArgumentNullException("用户名为空");
            }

            try
            {
                var          en = new Models.Entities();
                aspnet_Users u  = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.UserName == userName);
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                // set a 20-lengthed validation string (code), it's only validate in 24 hours
                u.ValidationCode = (new Utilities.RandString()).Generate();
                u.validUntil     = DateTime.Now.AddDays(1);

                en.ApplyCurrentValues("aspnet_Users", u);
                en.SaveChanges();

                return(u.ValidationCode);
            }
            catch
            {
                throw;
            }
        }
コード例 #5
0
        public string[] Search(string userName = null, int start = 0, int count = 0)
        {
            try
            {
                var en = new Models.Entities();
                var us = string.IsNullOrEmpty(userName) ? en.aspnet_Users : en.aspnet_Users.Where(m => m.UserName.Contains(userName));

                if (start > 0)
                {
                    us = us.Skip(start);
                }

                if (count > 0)
                {
                    us = us.Take(count);
                }

                var us2 = new string[us.Count()];
                int i   = 0;
                foreach (var u in us)
                {
                    us2[i] = u.UserName;
                    i++;
                }

                return(us2);
            }
            catch
            {
                throw new ArgumentException("用户名不存在");
            }
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="ipAddress"></param>
        /// <param name="machineName"></param>
        /// <returns></returns>
        public bool CreateSession(string userName)
        {
            using (Models.Entities entity = new Models.Entities())
            {
                try
                {
                    Models.SessionManagement sessionManagement = new Models.SessionManagement();

                    sessionManagement.SessionGuiId = Guid.NewGuid();
                    sessionManagement.CreatedDate  = DateTime.Now;
                    sessionManagement.EndDate      = DateTime.Now.AddHours(1);
                    sessionManagement.IpAddress    = GetIp();
                    sessionManagement.MachineName  = null;

                    entity.SessionManagements.Add(sessionManagement);
                    entity.SaveChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    entity.Dispose();
                    throw;
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sessionGuiId"></param>
        /// <returns></returns>
        public bool CheckSession(Guid sessionGuiId)
        {
            using (Models.Entities entity = new Models.Entities())
            {
                try
                {
                    Models.SessionManagement sessionManagement = new Models.SessionManagement();

                    var result = entity.SessionManagements.SingleOrDefault(w => w.SessionGuiId == sessionGuiId);
                    if (result != null && result.EndDate > DateTime.Now)
                    {
                        if (result.IpAddress != null)
                        {
                            if (result.IpAddress != GetIp())
                            {
                                return(false);
                            }
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    entity.Dispose();
                    throw;
                }
            }
        }
コード例 #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sessionGuiId"></param>
 /// <returns></returns>
 public bool UpdateSession(Guid sessionGuiId)
 {
     using (Models.Entities entity = new Models.Entities())
     {
         try
         {
             Models.SessionManagement sessionManagement = new Models.SessionManagement();
             var result = entity.SessionManagements.SingleOrDefault(w => w.SessionGuiId == sessionGuiId);
             if (result != null)
             {
                 result.EndDate = DateTime.Now.AddHours(1);
                 entity.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             entity.Dispose();
             throw;
         }
     }
 }
コード例 #9
0
        public DiarioCentrosRecepcion()
        {
            InitializeComponent();
            // Mi codigo personalizado
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.DataSource = paramGen;

            this.zafraLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "Zafras.descripcionZafra")
            });

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin de mi codigo
            //datos del reporte
            var d = db.DiarioEquiposZafra.ToArray();



            this.suministradorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", d, "PlanEquiposAgricZafra.ParqueEquipos.Suministradores")
            });
        }
コード例 #10
0
        public void SetCurrentUserFromIdentity()
        {
            // ユーザー情報
            // 企業ユーザーの場合は会社情報も取得
            var p = _context.User.Identity;

            if (p.IsAuthenticated)
            {
                using (var db = new Models.Entities())
                {
                    db.Configuration.ProxyCreationEnabled = false;
                    // TODO: UserNameの一意性保証
                    this.CurrentUser = db.Users.FirstOrDefault(x => x.UserName == p.Name);
                    var au = this.CurrentUser as Models.AccountUser;
                    if (au != null)
                    {
                        db.Entry(au).Reference(x => x.Company).Load();
                    }
                }
            }
            if (this.CurrentUser == null)
            {
                // 未認証とする
                this.CurrentUser = Models.User.Anonymous;
                if (p.IsAuthenticated)
                {
                    // 認証クッキーが有効だが、DBにユーザーが存在しない場合の対処
                    var identity  = new System.Security.Principal.GenericIdentity("");
                    var principal = new System.Security.Principal.GenericPrincipal(identity, null);
                    _context.User = principal;
                }
            }
        }
コード例 #11
0
        public EquiposPorSuministrador()
        {
            InitializeComponent();
            // Info de los parametros
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.zafraLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "Zafras.descripcionZafra")
            });

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin Info de los parametros

            xrSubreport1.ReportSource = new SubReportTipoEqExitente();

            DataSource = db.Suministradores.ToList();

            this.suministradorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "nombreSuministrador")
            });
        }
コード例 #12
0
        public ActionResult <string> GetEntities(int id)
        {
            List <Models.Entities>    obj     = new List <Models.Entities>();
            EntitiesBatchResultV2dot1 result4 = client.EntitiesAsync(
                new MultiLanguageBatchInput(
                    new List <MultiLanguageInput>()
            {
                new MultiLanguageInput("en", "0", "The Great Depression began in 1929. By 1933, the GDP in America fell by 25%.")
            })).Result;

            // Printing entities results
            foreach (var document in result4.Documents)
            {
                Models.Entities temp = new Models.Entities();
                temp.id = document.Id;

                foreach (EntityRecordV2dot1 entity in document.Entities)
                {
                    temp.entity.Add(entity);
                }
                obj.Add(temp);
            }

            return(Ok(obj));
        }
コード例 #13
0
        public void Task(Models.Entities con, Test_Schedule model, Mutex mutex, bool saveFlags)
        {
            try
            {
                if (saveFlags)
                {
                    model.Flag_Start = 1;
                    con.SaveChanges();
                }

                var db    = model.Test_Db;
                var url   = model.Test_Url;
                var users = model.Test_Url.Test_User;

                foreach (var tgRef in model.Test_Group.Test_Group_Ref)
                {
                    foreach (var user in users)
                    {
                        var result = new AspMvcEf.Models.Test_Result()
                        {
                            Id = 0,
                            Test_Schedule_Id = model.Id,
                            Test_Group_Id    = tgRef.Test_Group_Id,
                            Test_Id          = tgRef.Test_Id,
                            Flag_Ok          = null,
                            Result           = null,
                            Time_Start       = DateTime.Now,
                            Time_Stop        = null
                        };
                        try
                        {
                            //Models.SeleniumTest.Run(tgRef.Test.Test_Type.Type, tgRef.Test.Insurance_Id, user.Username, user.Password, url.Url, db.CisConnectionString, db.WebConnectionString);
                            result.Result  = "";
                            result.Flag_Ok = 1;
                        }
                        catch (Exception e)
                        {
                            result.Result  = e.ToString();
                            result.Flag_Ok = 0;
                        }
                        result.Time_Stop        = DateTime.Now;
                        con.Entry(result).State = System.Data.Entity.EntityState.Added;
                        con.SaveChanges();
                    }
                }

                if (saveFlags)
                {
                    model.Flag_Stop = 1;
                    con.SaveChanges();
                }
            }
            finally
            {
                mutex.Close();
            }
        }
コード例 #14
0
        public void CargarDatos()
        {
            //Datos
            var db            = new Models.Entities();
            var suministrador = SumID.Value.ToString();
            var paramGen      = db.ParametrosGenerales.ToArray();
            var param         = paramGen.First();
            var idZafra       = int.Parse(Zafra.Value.ToString());

            var zafra = db.DiarioOperadorCombinadas.Where(i => i.Zafrasid == idZafra &&
                                                          i.PlanOperadoresCombinadas.OperadorCombinada.PelotonCombinadas.Suministradores.nombreSuministrador == suministrador).ToList();

            var diarioGroups = from dia in zafra
                               group dia by dia.PlanOperadoresCombinadas.OperadorCombinada.nombreOperador
                               into diarioGroup
                               select new
            {
                operador  = diarioGroup.Key,
                acumulado = diarioGroup.Sum(i => i.cantVerde) + diarioGroup.Sum(i => i.cantQuemada) + diarioGroup.Sum(i => i.cantQuemadaProgram),
                plan      = diarioGroup.Sum(i => i.PlanOperadoresCombinadas.tareaDiaria),
                periodo   = diarioGroup.Where(i => i.fecha >= (DateTime)fechaInicio.Value && i.fecha <= (DateTime)fechaFin.Value)
                            .Sum(i => i.cantVerde)
                            + diarioGroup.Where(i => i.fecha >= (DateTime)fechaInicio.Value && i.fecha <= (DateTime)fechaFin.Value)
                            .Sum(i => i.cantQuemada)
                            + diarioGroup.Where(i => i.fecha >= (DateTime)fechaInicio.Value && i.fecha <= (DateTime)fechaFin.Value)
                            .Sum(i => i.cantQuemadaProgram)
            };

            //Fin Datos

            //Enlazando datos
            DataSource = diarioGroups;

            this.operadorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "operador")
            });

            this.planCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "plan")
            });

            this.periodoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "periodo")
            });

            this.acumCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "acumulado")
            });

            totalPlanCell.Text    = diarioGroups.Sum(u => u.plan).ToString();
            totalPeriodoCell.Text = diarioGroups.Sum(u => u.periodo).ToString();
            totalAcumCell.Text    = diarioGroups.Sum(u => u.acumulado).ToString();

            //fin de enlace
        }
コード例 #15
0
        public Campos()
        {
            InitializeComponent();
            // Info de los parametros
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.zafraLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "Zafras.descripcionZafra")
            });

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin Info de los parametros


            //Datos
            var campos = from c in db.Campo select new { campo = c.Suministradores.nombreSuministrador, verde = c.cantCanaVerde, quemada = c.cantCanaQuemada, c.cepa, c.VariedadCana.nombreVariedad };

            //Fin datos

            //Enlazando datos
            DataSource = campos.ToList();

            this.campoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "campo")
            });

            this.canaVerdeCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "verde")
            });

            this.canaQuemadaCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "quemada")
            });


            this.cepaCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "cepa")
            });

            this.variedadCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "nombreVariedad")
            });


            totalVerdeCell.Text   = campos.Sum(u => u.verde).ToString();
            totalQuemadaCell.Text = campos.Sum(u => u.quemada).ToString();
            //fin de enlace
        }
コード例 #16
0
        public void CargarDatos()
        {
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.First();
            //Datos
            var idZafra = int.Parse(Zafra.Value.ToString());
            var z       = db.Zafras.Find(idZafra);

            fechaInicio.Value = z.fechaInicio;
            fechaFin.Value    = z.fechaFin;
            if (idZafra == paramGen.zafraAct)
            {
                fechaFin.Value = paramGen.fechaActual;
            }



            this.zafraLabel.DataBindings.AddRange(new[] { new XRBinding("Text", z, "descripcionZafra") });

            var zafra = db.DiarioOperadorCombinadas.Where(i => i.Zafrasid == idZafra).ToList();

            var diarioGroups = from dia in zafra
                               group dia by dia.PlanOperadoresCombinadas.OperadorCombinada.PelotonCombinadas.Suministradores.nombreSuministrador
                               into diarioGroup
                               select new
            {
                unidad  = diarioGroup.Key,
                cortada = diarioGroup.Sum(i => i.cantVerde) + diarioGroup.Sum(i => i.cantQuemada) + diarioGroup.Sum(i => i.cantQuemadaProgram),
                plan    = diarioGroup.Sum(i => i.PlanOperadoresCombinadas.tareaDiaria)
            };

            var result = from unidad in diarioGroups where unidad.cortada < unidad.plan select unidad;

            //Fi Datos

            //Enlazando datos
            DataSource = result.ToList();

            this.suministradorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "unidad")
            });

            this.planCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "plan")
            });

            this.cortadaCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "cortada")
            });

            totalPlan.Text    = result.Sum(u => u.plan).ToString();
            totalCortada.Text = result.Sum(u => u.cortada).ToString();
            //fin de enlace
        }
コード例 #17
0
 public bool IsAdmin(string userName)
 {
     try
     {
         var en = new Models.Entities();
         var u  = en.aspnet_Users.First(m => m.UserName == userName);
         return(u.IsAdmin == true);
     }
     catch
     {
         throw;
     }
 }
コード例 #18
0
        public static int ToolStat(Models.Entities store)
        {
            var toolsUses = store
                            .ToolsUses
                            .Where(t => !t.Tool.Category.IsDeleted && (!t.Tool.IsDeleted.HasValue || (t.Tool.IsDeleted.HasValue && !t.Tool.IsDeleted.Value)))
                            .Select(it => it.Count)
                            .ToList();

            if (toolsUses.Count > 0)
            {
                return(toolsUses.Sum());
            }
            return(0);
        }
コード例 #19
0
        public void CargarDatos()
        {
            //Datos
            var db            = new Models.Entities();
            var suministrador = SumID.Value.ToString();
            var paramGen      = db.ParametrosGenerales.ToArray();
            var param         = paramGen.First();
            var idZafra       = int.Parse(Zafra.Value.ToString());
            var zafra         = db.DiarioEquiposZafra.Where(i => i.Zafrasid == idZafra &&
                                                            i.PlanEquiposAgricZafra.ParqueEquipos.Suministradores.nombreSuministrador == suministrador).ToList();

            var diarioGroups = from dia in zafra
                               group dia by dia.PlanEquiposAgricZafra.ParqueEquipos.TipoEquipos.descripcionEquipo
                               into diarioGroup
                               select new
            {
                tipoEquipo = diarioGroup.Key,
                acumulado  = diarioGroup.Sum(i => i.arrobasTiradas),
                plan       = diarioGroup.Sum(i => i.PlanEquiposAgricZafra.tareaDiaria),
                periodo    = diarioGroup.Where(i => i.fecha >= (DateTime)fechaInicio.Value && i.fecha <= (DateTime)fechaFin.Value)
                             .Sum(i => i.arrobasTiradas)
            };

            //Fin Datos

            //Enlazando datos
            DataSource = diarioGroups;

            this.Equipo.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "tipoEquipo")
            });

            this.planCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "plan")
            });

            this.periodoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "periodo")
            });

            this.acumCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "acumulado")
            });

            totalPlanCell.Text    = diarioGroups.Sum(u => u.plan).ToString();
            totalPeriodoCell.Text = diarioGroups.Sum(u => u.periodo).ToString();
            totalAcumCell.Text    = diarioGroups.Sum(u => u.acumulado).ToString();

            //fin de enlace
        }
コード例 #20
0
        public void CargarDatos()
        {
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();
            int zafraid  = int.Parse(Parameters["Zafra"].Value.ToString());
            var Zafra    = db.Zafras.Find(zafraid);

            this.zafraLabel.Text = Zafra.descripcionZafra;
            //Datos
            var param = paramGen.First();
            var zafra = db.DiarioEquiposZafra.Where(i => i.Zafrasid == zafraid).ToList();

            var result = from dia in zafra
                         group dia by dia.PlanEquiposAgricZafra.CentrosRecepcion.nombreCentroRecepcion
                         into diarioGroup
                         select new
            {
                suministrador = diarioGroup.Key,
                acumulado     = diarioGroup.Sum(i => i.arrobasTiradas),
                plan          = diarioGroup.Sum(i => i.PlanEquiposAgricZafra.tareaDiaria),
                periodo       = diarioGroup.Where(i => i.fecha >= (DateTime)fechaInicio.Value && i.fecha <= (DateTime)fechaFin.Value).Sum(i => i.arrobasTiradas)
            };

            //Fi Datos

            //Enlazando datos
            DataSource = result.ToList();

            this.centroCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "suministrador")
            });

            this.planCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "plan")
            });

            this.periodoCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "periodo")
            });

            this.acumuladaCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "acumulado")
            });

            totalPlan.Text    = result.Sum(u => u.plan).ToString();
            totalPeriodo.Text = result.Sum(u => u.periodo).ToString();
            totalAcum.Text    = result.Sum(u => u.acumulado).ToString();
            //fin de enlace
        }
コード例 #21
0
        public static int ToolStatByToolIDWorkerID(Models.Entities store, int toolID, int workerID)
        {
            var toolsUses = store
                            .ToolsUses
                            .Where(t => !t.Tool.Category.IsDeleted && (!t.Tool.IsDeleted.HasValue || (t.Tool.IsDeleted.HasValue && !t.Tool.IsDeleted.Value)))
                            .Where(it => it.ToolID == toolID && it.WorkerID == workerID)
                            .Select(it => it.Count)
                            .ToList();

            if (toolsUses.Count > 0)
            {
                return(toolsUses.Sum());
            }
            return(0);
        }
コード例 #22
0
        public UnidadesIncumplidorasCorte()
        {
            InitializeComponent();
            // Info de los parametros
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin Info de los parametros
        }
コード例 #23
0
        public static Task <int> Role_InsertUpdateDelete(int?roleId, string name, string description, bool delete)
        {
            try
            {
                using (var dbContext = new Models.Entities())
                {
                    roleId = dbContext.AspNetRoles_InsertUpdateDelete(roleId, name, description, delete).FirstOrDefault() ?? -1;
                }
            }
            catch (Exception ex)
            {
                CommonDAL.InsertExceptionLog(DatabaseIdEnum.LogType_SiteException, SiteUtils.GetPageName(), null, ex.Message, ex.StackTrace, roleId.ToString());
                roleId = -1;
            }

            return(Task.FromResult(roleId ?? -1));
        }
コード例 #24
0
        public CanaxEquipo()
        {
            InitializeComponent();
            // Info de los parametros
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin Info de los parametros
            xrSubreport1.ReportSource = new SubReportEqZafra();
        }
コード例 #25
0
 /*
  * Thread #1
  */
 private void Runnable()
 {
     while (true)
     {
         using (Models.Entities con = new Models.Entities())
         {
             Test_Schedule model = con.Test_Schedule.FirstOrDefault(x => x.Flag_Start != 1 && x.Time_Start < DateTime.Now);
             if (model != null)
             {
                 Mutex mutex = new Mutex(false, "Task_" + model.Id);
                 if (mutex.WaitOne(1000, false))
                 {
                     Task(con, model, mutex, true);
                 }
             }
         }
         Thread.Sleep(1000 * 1);
     }
 }
コード例 #26
0
        public PlantillaDiario()
        {
            InitializeComponent();
            // Info de los parametros
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();

            this.zafraLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "Zafras.descripcionZafra")
            });

            this.emprezaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "nombreEmpresa")
            });

            this.fechaLabel.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", paramGen, "fechaActual", "{0:dd/MM/yyyy}")
            });
            //fin Info de los parametros
        }
コード例 #27
0
        public void SetPhotoUrl(string userName, string photoUrl)
        {
            if (string.IsNullOrWhiteSpace(photoUrl))
            {
                throw new ArgumentNullException("头像图片地址为空");
            }

            try
            {
                var          en = new Models.Entities();
                aspnet_Users u  = en.aspnet_Users.First(m => m.UserName == userName);

                u.PhotoUrl = photoUrl;
                en.ApplyCurrentValues("aspnet_Users", u);
                en.SaveChanges();
            }
            catch
            {
                throw new ArgumentException("用户名不存在");
            }
        }
コード例 #28
0
        public void SetEmail(string userName, string newEmail)
        {
            if (string.IsNullOrEmpty(newEmail))
            {
                throw new ArgumentException("新的Email为空");
            }

            if (GetUserNameByEmail(newEmail) != null)
            {
                throw new ArgumentException("Email已经被注册");
            }

            try
            {
                var               en     = new Models.Entities();
                aspnet_Users      u      = null;
                aspnet_Membership member = null;
                try
                {
                    u      = en.aspnet_Users.First(m => m.UserName == userName);
                    member = en.aspnet_Membership.First(m => m.UserId == u.UserId);
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                u.Email             = newEmail;
                member.Email        = newEmail;
                member.LoweredEmail = newEmail.ToLower();

                en.ApplyCurrentValues("aspnet_Users", u);
                en.ApplyCurrentValues("aspnet_Membership", member);
                en.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
コード例 #29
0
        public void CargarDatos()
        {
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();
            //Datos

            var fecha   = (DateTime)FechaActual.Value;
            var idZafra = int.Parse(Zafra.Value.ToString());


            var zafra = db.Zafras.Find(idZafra);

            this.zafraLabel.DataBindings.AddRange(new[] { new XRBinding("Text", zafra, "descripcionZafra") });

            var diariosHoy = db.DiarioOperadorCombinadas.Where(i => i.Zafrasid == idZafra && i.fecha == fecha).ToList();

            var equiposParados = from dia in diariosHoy
                                 where dia.EstadoEquipo.nombreEstado == "Roto"
                                 select new
            {
                operador = dia.PlanOperadoresCombinadas.OperadorCombinada.nombreOperador,
                peloton  = dia.PlanOperadoresCombinadas.OperadorCombinada.PelotonCombinadas.Suministradores.nombreSuministrador
            };

            //Fi Datos

            //Enlazando datos
            DataSource = equiposParados.ToList();

            this.operadorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "operador")
            });

            this.pelotonCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "peloton")
            });

            totalParados.Text = equiposParados.Count().ToString();
            //fin de enlace
        }
コード例 #30
0
        public void CargarDatos()
        {
            var db       = new Models.Entities();
            var paramGen = db.ParametrosGenerales.ToArray();
            //Datos

            var fecha   = (DateTime)FechaActual.Value;
            var idZafra = int.Parse(Zafra.Value.ToString());


            var zafra = db.Zafras.Find(idZafra);

            this.zafraLabel.DataBindings.AddRange(new[] { new XRBinding("Text", zafra, "descripcionZafra") });

            var diariosHoy = db.DiarioEquiposZafra.Where(i => i.Zafrasid == idZafra && i.fecha == fecha).ToList();

            var equiposParados = from dia in diariosHoy
                                 group dia by dia.PlanEquiposAgricZafra.ParqueEquipos.TipoEquipos.descripcionEquipo
                                 into diarioGroup
                                 select new
            {
                tipoEquipo = diarioGroup.Key,
                parados    = diarioGroup.Sum(i => i.parqueParado)
            };


            //Fi Datos

            //Enlazando datos
            DataSource = db.Suministradores.ToList();

            this.suministradorCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "nombreSuministrador")
            });

            totalPlan.Text = equiposParados.Sum(u => u.parados).ToString();
            //fin de enlace
        }
コード例 #31
0
        public void CargarDatos()
        {
            //Datos
            var db = new Models.Entities();
            var idSuministrador = SumID.Value.ToString();
            var fecha           = (DateTime)FechaActual.Value;
            var idZafra         = int.Parse(Zafra.Value.ToString());

            var diariosHoy = db.DiarioEquiposZafra.Where(i => i.Zafrasid == idZafra &&
                                                         i.PlanEquiposAgricZafra.ParqueEquipos.Suministradores.nombreSuministrador == idSuministrador && i.fecha == fecha).ToList();

            var equiposParados = from dia in diariosHoy
                                 group dia by dia.PlanEquiposAgricZafra.ParqueEquipos.TipoEquipos.descripcionEquipo
                                 into diarioGroup
                                 select new
            {
                tipoEquipo = diarioGroup.Key,
                parados    = diarioGroup.Sum(i => i.parqueParado)
            };

            //Fin Datos

            //Enlazando datos
            DataSource = equiposParados.ToList();

            this.Equipo.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "tipoEquipo")
            });

            this.paradosCell.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] {
                new DevExpress.XtraReports.UI.XRBinding("Text", null, "parados")
            });

            totalParadosCell.Text = equiposParados.Sum(u => u.parados).ToString();

            //fin de enlace
        }
コード例 #32
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public bool DeleteUser(string userName)
        {
            try
            {
                var en = new Models.Entities();
                aspnet_Users u = null;
                aspnet_Membership member = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.UserName == userName);
                    member = en.aspnet_Membership.First(m => m.UserId == u.UserId);

                    en.DeleteObject(member);
                    en.DeleteObject(u);

                    en.SaveChanges();

                    return true;
                }
                catch
                {
                    throw new ArgumentException("注销失败");
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #33
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
 public bool IsAdmin(string userName)
 {
     try
     {
         var en = new Models.Entities();
         var u = en.aspnet_Users.First(m => m.UserName == userName);
         return (u.IsAdmin == true);
     }
     catch
     {
         throw;
     }
 }
コード例 #34
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public string GetEmail(string userName)
        {
            try
            {
                var en = new Models.Entities();
                aspnet_Users u = null;
                aspnet_Membership member = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.UserName == userName);
                    member = en.aspnet_Membership.First(m => m.UserId == u.UserId);

                    return member.Email;
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #35
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public string SetValidationCode(string userName)
        {
            if (string.IsNullOrWhiteSpace(userName))
            {
                throw new ArgumentNullException("用户名为空");
            }

            try
            {
                var en = new Models.Entities();
                aspnet_Users u = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.UserName == userName);
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                // set a 20-lengthed validation string (code), it's only validate in 24 hours
                u.ValidationCode = (new Utilities.RandString()).Generate();
                u.validUntil = DateTime.Now.AddDays(1);

                en.ApplyCurrentValues("aspnet_Users", u);
                en.SaveChanges();

                return u.ValidationCode;
            }
            catch
            {
                throw;
            }
        }
コード例 #36
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public void SetPhotoUrl(string userName, string photoUrl)
        {
            if (string.IsNullOrWhiteSpace(photoUrl))
            {
                throw new ArgumentNullException("头像图片地址为空");
            }

            try
            {
                var en = new Models.Entities();
                aspnet_Users u = en.aspnet_Users.First(m => m.UserName == userName);

                u.PhotoUrl = photoUrl;
                en.ApplyCurrentValues("aspnet_Users", u);
                en.SaveChanges();
            }
            catch
            {
                throw new ArgumentException("用户名不存在");
            }
        }
コード例 #37
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public void SetEmail(string userName, string newEmail)
        {
            if (string.IsNullOrEmpty(newEmail))
            {
                throw new ArgumentException("新的Email为空");
            }

            if (GetUserNameByEmail(newEmail) != null)
            {
                throw new ArgumentException("Email已经被注册");
            }

            try
            {
                var en = new Models.Entities();
                aspnet_Users u = null;
                aspnet_Membership member = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.UserName == userName);
                    member = en.aspnet_Membership.First(m => m.UserId == u.UserId);
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                u.Email = newEmail;
                member.Email = newEmail;
                member.LoweredEmail = newEmail.ToLower();

                en.ApplyCurrentValues("aspnet_Users", u);
                en.ApplyCurrentValues("aspnet_Membership", member);
                en.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
コード例 #38
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public string[] Search(string userName = null, int start = 0, int count = 0)
        {
            try
            {
                var en = new Models.Entities();
                var us = string.IsNullOrEmpty(userName) ? en.aspnet_Users : en.aspnet_Users.Where(m => m.UserName.Contains(userName));

                if (start > 0)
                {
                    us = us.Skip(start);
                }

                if (count > 0)
                {
                    us = us.Take(count);
                }

                var us2 = new string[us.Count()];
                int i = 0;
                foreach (var u in us)
                {
                    us2[i] = u.UserName;
                    i++;
                }

                return us2;
            }
            catch
            {
                throw new ArgumentException("用户名不存在");
            }
        }
コード例 #39
0
ファイル: AccountModels.cs プロジェクト: jjfd/HITRating
        public void ResetPassword(string validationCode, string newPassword)
        {
            if (string.IsNullOrEmpty(validationCode))
            {
                throw new ArgumentNullException("验证码为空");
            }

            if (string.IsNullOrEmpty(newPassword))
            {
                throw new ArgumentNullException("新密码不能为空");
            }

            if (newPassword.Length < 6)
            {
                throw new ArgumentNullException("新密码不能少于6个字符");
            }

            try
            {
                var en = new Models.Entities();
                aspnet_Users u = null;
                try
                {
                    u = en.aspnet_Users.First(m => m.ValidationCode == validationCode);
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                if (((DateTime)u.validUntil).CompareTo(DateTime.Now) < 0)
                {
                    throw new ArgumentException("验证码过期");
                }

                aspnet_Membership member = en.aspnet_Membership.First(m => m.UserId == u.UserId);

                var userName = u.UserName;
                var email = member.Email;

                var cd = member.CreateDate;
                var lld = member.LastLoginDate;
                var unc = u.UserNameChanged;

                // delete old user
                en.DeleteObject(member);
                en.DeleteObject(u);

                en.SaveChanges();

                // recreate the user
                CreateUser(userName, newPassword, email);

                // copy the old user's attrs to the new one
                try
                {
                    var newU = en.aspnet_Users.First(m => m.UserName == userName);
                    var newMember = en.aspnet_Membership.First(m => m.UserId == newU.UserId);

                    newU.UserNameChanged = unc;
                    newMember.CreateDate = cd;
                    newMember.LastLoginDate = lld;

                    en.ApplyCurrentValues("aspnet_Users", newU);
                    en.ApplyCurrentValues("aspnet_Membership", newMember);

                    en.SaveChanges();
                }
                catch
                {
                    throw new ArgumentException("用户名不存在");
                }

                return;
            }
            catch
            {
                throw;
            }
        }