Ejemplo n.º 1
0
 public static IConventionDbFunction AddDbFunction(
     [NotNull] this IConventionModel model,
     [NotNull] MethodInfo methodInfo,
     bool fromDataAnnotation = false)
 => DbFunction.AddDbFunction(
     (IMutableModel)model, Check.NotNull(methodInfo, nameof(methodInfo)),
     fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Ejemplo n.º 2
0
        public static void SendIncidentReport(string startTime, string endTime, double TimeZone, string SendTo)
        {
            double cutTimeZone   = 0 - TimeZone;
            var    StartDateTime = Convert.ToDateTime(startTime).AddHours(cutTimeZone);
            var    EndDateTime   = Convert.ToDateTime(endTime).AddHours(cutTimeZone);

            startTime = StartDateTime.ToString("yyyy-MM-dd HH:mm");
            endTime   = EndDateTime.ToString("yyyy-MM-dd HH:mm");

            string TemplatePath = EmailExtend.MapPath("/Views/Home/IncidentReportTemplate.cshtml");

            var index = File.ReadAllText(TemplatePath, System.Text.Encoding.GetEncoding("GBK"));

            var ModelList      = DbFunction.IncidentHistoryEmail(startTime, endTime, TimeZone);
            var OpenCount      = ModelList.Count(x => x.GuestMood == "--");
            var SatisfiedCount = ModelList.Count(x => x.GuestMood == "Staisfied");
            var AcceptedCount  = ModelList.Count(x => x.GuestMood == "Accepted");
            var AngryCount     = ModelList.Count(x => x.GuestMood == "Angry");
            var ComplaintCount = ModelList.Count(x => x.GuestMood == "Complaint");
            var ImpatientCount = ModelList.Count(x => x.GuestMood == "Impatient");

            var result = Razor.Parse(index, new
            {
                OpenCount      = ModelList.Count(x => x.GuestMood == "--"),
                SatisfiedCount = ModelList.Count(x => x.GuestMood == "Staisfied"),
                AcceptedCount  = ModelList.Count(x => x.GuestMood == "Accepted"),
                AngryCount     = ModelList.Count(x => x.GuestMood == "Angry"),
                ComplaintCount = ModelList.Count(x => x.GuestMood == "Complaint"),
                ImpatientCount = ModelList.Count(x => x.GuestMood == "Impatient"),
                ModelList
            });

            EmailExtend.SendEmail(SendTo, string.Format("Incident Report {0} to {1}", StartDateTime.ToString("MM/dd/yyyy"), EndDateTime.ToString("MM/dd/yyyy")), result);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Removes the <see cref="IMutableDbFunction" /> that is mapped to the method represented by the given
        ///     <see cref="MethodInfo" />.
        /// </summary>
        /// <param name="model"> The model to find the function in. </param>
        /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
        /// <returns> The removed <see cref="IMutableDbFunction" /> or <c>null</c> if the method is not mapped. </returns>
        public static IMutableDbFunction RemoveDbFunction([NotNull] this IMutableModel model, [NotNull] MethodInfo method)
        {
            Check.NotNull(model, nameof(model));
            Check.NotNull(method, nameof(method));

            return(DbFunction.RemoveDbFunction(
                       Check.NotNull(model, nameof(model)),
                       Check.NotNull(method, nameof(method))));
        }
Ejemplo n.º 4
0
        public string getDBType(string PID)
        {
            ExcelDataBase.Database db = DbFunction.GetDB("");

            return(db.DBType.Equals(DataBaseType.ORA) ? "ORA" : "MSS");

            //GS_PublicVar.Dev_LoginGS(PID);
            //return Convert.ToString(CommonFunction.GlobalVariable["Genersoft.BS.Public.DbType"]).Trim();
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Finds a <see cref="IDbFunction" /> that is mapped to the method represented by the given <see cref="MethodInfo" />.
        /// </summary>
        /// <param name="model"> The model to find the function in. </param>
        /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
        /// <returns> The <see cref="IDbFunction" /> or <c>null</c> if the method is not mapped. </returns>
        public static IDbFunction FindDbFunction([NotNull] this IModel model, [NotNull] MethodInfo method)
        {
            Check.NotNull(model, nameof(model));
            Check.NotNull(method, nameof(method));

            return(DbFunction.FindDbFunction(
                       Check.NotNull(model, nameof(model)),
                       Check.NotNull(method, nameof(method))));
        }
Ejemplo n.º 6
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public DbFunctionParameter(
     DbFunction function,
     string name,
     Type clrType)
 {
     Name     = name;
     Function = function;
     ClrType  = clrType;
     _builder = new InternalDbFunctionParameterBuilder(this, function.Builder.ModelBuilder);
 }
 public static IConventionDbFunction AddDbFunction(
     [NotNull] this IConventionModel model,
     [NotNull] string name,
     [NotNull] Type returnType,
     bool fromDataAnnotation = false)
 => DbFunction.AddDbFunction(
     (IMutableModel)model,
     Check.NotNull(name, nameof(name)),
     returnType,
     fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
Ejemplo n.º 8
0
        //public ActionResult About()
        //{
        //    ViewBag.Message = "Your application description page.";

        //    return View();
        //}



        //public ActionResult Contact()
        //{
        //    ViewBag.Message = "Your contact page.";

        //    return View();
        //}

        public JsonResult GetUserByParentID(int ParentID)
        {
            List <UserInfo> UserInfoList = new List <UserInfo>();

            if (ParentID != 0)
            {
                UserInfoList = DbFunction.GetUserList(ParentID);
            }
            return(Json(UserInfoList));
        }
Ejemplo n.º 9
0
        public JsonResult GetMetricByParentID(int ParentID)
        {
            List <TaskMetric> MetricList = new List <TaskMetric>();

            if (ParentID != 0)
            {
                MetricList = DbFunction.GetMetricList(ParentID);
            }
            return(Json(MetricList));
        }
Ejemplo n.º 10
0
        public JsonResult GetLocationByParentID(string ParentID)
        {
            List <ZoneInfo> locationList = new List <ZoneInfo>();

            if (ParentID != "")
            {
                locationList = DbFunction.GetLocationList(ParentID);
            }
            return(Json(locationList));
        }
Ejemplo n.º 11
0
        public DataSet getDataSet(string processID, string sql)
        {
            string tmp = "";

            try
            {
                sql = DecSql(sql);

                return(DbFunction.ExecuteDataSet(sql));
            }
            catch (Exception ex)
            {
                throw new Exception(sql + tmp + " <br> " + ex.Message);
            }
        }
Ejemplo n.º 12
0
        public QueryResult Execute(string query, MongoUrl url, string database)
        {
            if (String.IsNullOrWhiteSpace(query))
            {
                return(null);
            }
            query = query.Trim();

            Module     module   = ModuleFactory.GetModule(query);
            DbFunction function = module.GetDbFunction(query);

            function.Url          = url;
            function.DatabaseName = database;
            function.Url          = url;
            var result = function.Execute();

            return(result);
        }
Ejemplo n.º 13
0
        public override DbFunction GetDbFunction(string query)
        {
            DbFunction dbFunction = null;

            if (Regex.IsMatch(query, Patterns.find))
            {
                dbFunction = new Find(query);
            }
            else if (Regex.IsMatch(query, Patterns.findOne))
            {
                dbFunction = new FindOne(query);
            }
            else if (Regex.IsMatch(query, Patterns.findAndModify))
            {
                dbFunction = new FindAndModify(query);
            }
            return(dbFunction);
        }
Ejemplo n.º 14
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //modelBuilder.Entity<Person>().ToTable("People");
            //modelBuilder.Entity<BankAccount>().ToTable("People");
            //modelBuilder.Entity<Person>().HasOne(c => c.BankAccount).WithOne(c => c.Person)
            //    .HasForeignKey<Person>(c => c.Id);
            //modelBuilder.Entity<Person>().OwnsOne(c => c.Home);
            modelBuilder.Entity <Person>().HasDiscriminator <int>("Split").HasValue <Person>(1)
            .HasValue <Teacher>(2);
            modelBuilder.HasDbFunction(() => DbFunction.MyFunction());

            modelBuilder.Entity <Person>().Property(c => c.Year)
            .HasComputedColumnSql("DatePart(yyyy,[BirthDate])");

            modelBuilder.Entity <Person>().Property(c => c.BirthDate).HasValueGenerator <DateTimeValueGenerator>();
            //modelBuilder.Entity<Person>().Property(c => c.BirthDate).HasDefaultValueSql("getdate()");

            //modelBuilder.HasSequence<int>("TestInt", c => {

            //    c.HasMin(12);
            //    c.IncrementsBy(2);

            //});

            //modelBuilder.Entity<Person>().Property(c => c.FirstName)
            //    .IsConcurrencyToken();
            modelBuilder.Entity <Person>().Property(c => c.Token).IsRowVersion();

            //modelBuilder.Entity<BankAccount>().Property(c => c.RowVersion).IsRowVersion();

            modelBuilder.Entity <Person>().HasData(

                new Person {
                BirthDate = DateTime.Now,
                FirstName = "1",
                LastName  = "2",

                Id = 1
            }

                );
        }
 public static IMutableDbFunction AddDbFunction(
     [NotNull] this IMutableModel model,
     [NotNull] string name,
     [NotNull] Type returnType)
 => DbFunction.AddDbFunction(
     model, Check.NotNull(name, nameof(name)), returnType, ConfigurationSource.Explicit);
 public static IMutableDbFunction AddDbFunction([NotNull] this IMutableModel model, [NotNull] MethodInfo methodInfo)
 => DbFunction.AddDbFunction(
     model, Check.NotNull(methodInfo, nameof(methodInfo)), ConfigurationSource.Explicit) !;
 public static IDbFunction?FindDbFunction([NotNull] this IModel model, [NotNull] string name)
 => DbFunction.FindDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(name, nameof(name)));
Ejemplo n.º 18
0
 /// <summary>
 ///     Returns all functions contained in the model.
 /// </summary>
 /// <param name="model"> The model to get the functions in. </param>
 public static IEnumerable <IDbFunction> GetDbFunctions(this IReadOnlyModel model)
 => DbFunction.GetDbFunctions((Model)Check.NotNull(model, nameof(model)));
Ejemplo n.º 19
0
 /// <summary>
 ///     Returns all functions contained in the model.
 /// </summary>
 /// <param name="model"> The model to get the functions in. </param>
 public static IEnumerable <IMutableDbFunction> GetDbFunctions(this IMutableModel model)
 => DbFunction.GetDbFunctions((Model)Check.NotNull(model, nameof(model))).Cast <IMutableDbFunction>();
Ejemplo n.º 20
0
 /// <summary>
 ///     Removes the function that is mapped to the method represented by the given
 ///     <see cref="MethodInfo" />.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
 /// <returns> The removed function or <see langword="null" /> if the method is not mapped. </returns>
 public static IMutableDbFunction?RemoveDbFunction(this IMutableModel model, MethodInfo method)
 => DbFunction.RemoveDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(method, nameof(method)));
Ejemplo n.º 21
0
 /// <summary>
 ///     Finds a function that is mapped to the method represented by the given name.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="name"> The model name of the function. </param>
 /// <returns> The function or <see langword="null" /> if the method is not mapped. </returns>
 public static IReadOnlyDbFunction?FindDbFunction(this IReadOnlyModel model, string name)
 => DbFunction.FindDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(name, nameof(name)));
Ejemplo n.º 22
0
 partial void OnModelCreatingPartial(ModelBuilder modelBuilder)
 {
     modelBuilder.HasDbFunction(() => DbFunction.ExampleFunction(default(string)));
 }
 public static IEnumerable <IConventionDbFunction> GetDbFunctions([NotNull] this IConventionModel model)
 => DbFunction.GetDbFunctions((Model)Check.NotNull(model, nameof(model)));
 public static IMutableDbFunction?RemoveDbFunction([NotNull] this IMutableModel model, [NotNull] string name)
 => DbFunction.RemoveDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(name, nameof(name)));
 public static IEnumerable <IDbFunction> GetDbFunctions([NotNull] this IModel model)
 => DbFunction.GetDbFunctions(Check.NotNull(model, nameof(model)));
Ejemplo n.º 26
0
        public JsonResult GetTaskFrequencyDistributionDetails(string startTime, string endTime, string DepartmentName, string TimeHour)
        {
            List <SearchInfo> ModelList = DbFunction.GetTaskFrequencyDistributionDetails(DepartmentName, startTime, endTime, TimeHour);

            return(Json(ModelList));
        }
Ejemplo n.º 27
0
        internal dynamic findOne(DbFunction dbFunction)
        {
            ConnectionManager.OpenConnection(dbFunction.Url, dbFunction.DatabaseName);
            var collection = ConnectionManager.GetCollection(dbFunction.Collection);
            BsonDocument filter = new BsonDocument();
            BsonDocument projection = new BsonDocument();

            if (dbFunction.Arguments.Count > 0
                && !dbFunction.Arguments[0].GetType().Name.Equals(DataType.BsonDocument))
            {
                HasError = true;
                return FindErrors.GetDontKnowHowToMessageObject();
            }
            if (dbFunction.SuffixFunction != null)
            {
                HasError = true;
                return FindErrors.NotAFunction(dbFunction);
            }
            switch (dbFunction.Arguments.Count)
            {
                case 0:
                    {

                        return collection.Find(filter).FirstOrDefault();
                    }

                case 1:
                    {

                        filter = dbFunction.Arguments[0].ToBsonDocument();
                        return collection.Find(filter).FirstOrDefault();
                    }
                case 2:
                    {
                        if (dbFunction.Arguments[1].GetType().Name.Equals(DataType.BsonDocument))
                        {
                            filter = dbFunction.Arguments[0].ToBsonDocument();
                            projection = dbFunction.Arguments[1].ToBsonDocument();

                        }
                        return collection.Find(filter).Limit(1).Project(projection).FirstOrDefault();
                    }
                default:
                    {
                        if (dbFunction.Arguments[3] is BsonString)
                        {
                            if (dbFunction.Arguments[1].GetType().Name.Equals(DataType.BsonDocument))
                            {
                                filter = dbFunction.Arguments[0].ToBsonDocument();
                                projection = dbFunction.Arguments[1].ToBsonDocument();

                            }
                            int limit = dbFunction.Arguments[2].ToInt32();
                            return collection.Find(filter).Limit(1).Project(projection).Limit(limit).FirstOrDefault();
                        }
                        HasError = true;
                        return FindErrors.GetArgumentDataTypeMissMatch();

                    }
            }
        }
Ejemplo n.º 28
0
        public DbFunctionBuilder([NotNull] DbFunction function)
        {
            Check.NotNull(function, nameof(function));

            _builder = new InternalDbFunctionBuilder(function);
        }
Ejemplo n.º 29
0
        public DbFunctionBuilder([NotNull] IMutableDbFunction function)
        {
            Check.NotNull(function, nameof(function));

            _function = (DbFunction)function;
        }
Ejemplo n.º 30
0
 /// <summary>
 ///     Finds a function that is mapped to the method represented by the given <see cref="MethodInfo" />.
 /// </summary>
 /// <param name="model"> The model to find the function in. </param>
 /// <param name="method"> The <see cref="MethodInfo" /> for the method that is mapped to the function. </param>
 /// <returns> The function or <see langword="null" /> if the method is not mapped. </returns>
 public static IReadOnlyDbFunction?FindDbFunction(this IReadOnlyModel model, MethodInfo method)
 => DbFunction.FindDbFunction(
     Check.NotNull(model, nameof(model)),
     Check.NotNull(method, nameof(method)));