ToInt16() public static method

public static ToInt16 ( DateTime value ) : short
value DateTime
return short
Ejemplo n.º 1
0
 private static void RegisterUInt64Conversions(
     ITypeConverterRegistry registry)
 {
     registry.Register <ulong, byte>(from => SysConv.ToByte(from));
     registry.Register <ulong, short>(from => SysConv.ToInt16(from));
     registry.Register <ulong, int>(from => SysConv.ToInt32(from));
     registry.Register <ulong, long>(from => SysConv.ToInt64(from));
     registry.Register <ulong, ushort>(from => SysConv.ToUInt16(from));
     registry.Register <ulong, uint>(from => SysConv.ToUInt32(from));
     registry.Register <ulong, decimal>(from => SysConv.ToDecimal(from));
     registry.Register <ulong, float>(from => SysConv.ToSingle(from));
     registry.Register <ulong, double>(from => SysConv.ToDouble(from));
     registry.Register <ulong, string>(from =>
                                       from.ToString(CultureInfo.InvariantCulture));
 }
Ejemplo n.º 2
0
 private void LoadData(DataRow dr)
 {
     if (dr == null)
     {
         Id = null;
         return;
     }
     Id          = Convert.ToInt32(dr["SONG_ID"]);
     Name        = dr["Name"].ToString();
     AlbumId     = Convert.ToInt32(dr["ALBUM_ID"]);
     ArtistId    = Convert.ToInt32(dr["ArtistId"]);
     AlbumName   = dr["AlbumName"].ToString();
     ArtistName  = dr["ArtistName"].ToString();
     TrackNumber = Convert.ToInt32(dr["TrackNumber"]);
     IsSeparator = dr["Separator"].ToString() == "Y";
     HasCD       = Convert.ToInt16(dr["nCD"]) == 1;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     判断枚举是否值,是否安全,值是否重复
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public static bool IsSafe <T>()
        {
            var result = true;
            var list   = new List <int>();

            foreach (var item in Enum.GetValues(typeof(T)))
            {
                var value = Convert.ToInt16(item);
                if (list.Contains(value))
                {
                    result = false;
                    throw new ValidException("枚举值定义重复");
                }

                list.Add(value);
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     更新分润执行结果
        /// </summary>
        /// <param name="resultList">The result list.</param>
        public void UpdatePriceTaskResult(IEnumerable <RuleResultItem> resultList)
        {
            var sqlList         = new List <string>();
            var dbParameterList = new List <DbParameter[]>();

            var  repositoryContext = RepositoryContext;
            long shareOrderId      = 0;
            var  sql = string.Empty;

            DbParameter[] parameters = null;

            IList <long> shareUsreIds = new List <long>();

            foreach (var shareResult in resultList)
            {
                shareUsreIds.Add(shareResult.ShareUser.Id);
            }

            var shareUsreAccounts =
                Ioc.Resolve <IAccountRepository>()
                .GetAccountByUserIds(shareUsreIds);     //获取所有分润用户的资产账户

            foreach (var shareResult in resultList)
            {
                if (shareOrderId == 0)
                {
                    shareOrderId = shareResult.ShareOrder.Id;
                }

                var account = shareUsreAccounts.FirstOrDefault(r =>
                                                               r.MoneyTypeId == shareResult.MoneyTypeId && r.UserId == shareResult.ShareUser.Id);
                if (account == null)
                {
                    break;
                }

                var afterAccount = account.Amount + shareResult.Amount; //账户金额
                //更新资产
                sql =
                    "update Asset_Account set Amount=Amount+@Amount, HistoryAmount=HistoryAmount+@Amount  where MoneyTypeId=@MoneyTypeId and  UserId=@UserId";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                //更新财务记录bill表
                sql =
                    @"INSERT INTO [dbo].[Asset_Bill]([UserId],[OtherUserId] ,[EntityId] ,[Type] ,[Flow],[MoneyTypeId],[Amount],[AfterAmount],[Intro],[CreateTime])
                                                    VALUES (@UserId,@OtherUserId ,@EntityId ,@Type ,@Flow,@MoneyTypeId,@Amount,@AfterAmount,@Intro,@CreateTime)";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@OtherUserId", shareResult.OrderUser.Id),
                    repositoryContext.CreateParameter("@EntityId", shareResult.ShareOrder.Id),
                    repositoryContext.CreateParameter("@Type", Convert.ToInt16(BillActionType.FenRun)),
                    repositoryContext.CreateParameter("@Flow", Convert.ToInt16(AccountFlow.Income)),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount),
                    repositoryContext.CreateParameter("@AfterAmount", afterAccount),
                    repositoryContext.CreateParameter("@Intro", shareResult.Intro),
                    repositoryContext.CreateParameter("@CreateTime", DateTime.Now)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                //添加分润记录
                sql =
                    @"INSERT INTO [dbo].[Share_Reward] ([UserId] ,[OrderUserId],[OrderId],[MoneyTypeId],[Amount] ,[AfterAmount],[ModuleId],[RuleId],[Intro],[CreateTime],[Status])
                             VALUES (@UserId ,@OrderUserId,@OrderId,@MoneyTypeId,@Amount ,@AfterAmount,@ModuleId,@RuleId,@Intro,@CreateTime,@Status)";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@UserId", shareResult.ShareUser.Id),
                    repositoryContext.CreateParameter("@OrderUserId", shareResult.OrderUser.Id),
                    repositoryContext.CreateParameter("@OrderId", shareResult.ShareOrder.Id),
                    repositoryContext.CreateParameter("@MoneyTypeId", shareResult.MoneyTypeId),
                    repositoryContext.CreateParameter("@Amount", shareResult.Amount),
                    repositoryContext.CreateParameter("@AfterAmount", afterAccount),
                    repositoryContext.CreateParameter("@ModuleId", shareResult.ModuleId),
                    repositoryContext.CreateParameter("@RuleId", shareResult.RuleId.ToString()),
                    repositoryContext.CreateParameter("@Intro", shareResult.Intro),
                    repositoryContext.CreateParameter("@Status", 3), // 分润状态暂时设定为成功
                    repositoryContext.CreateParameter("@CreateTime", DateTime.Now)
                };
                sqlList.Add(sql);
                dbParameterList.Add(parameters);

                // 更新货币类型的账号金额,否则多个账号增加金额时会导致账号金额一样
                shareUsreAccounts.Foreach(r => {
                    if (r.MoneyTypeId == shareResult.MoneyTypeId)
                    {
                        r.Amount += shareResult.Amount;
                    }
                });

                //添加的短信队列
                if (shareResult.SmsNotification)
                {
                    if (RegexHelper.CheckMobile(shareResult.ShareUser.Mobile) && !shareResult.SmsIntro.IsNullOrEmpty())
                    {
                        sql =
                            @"INSERT INTO [dbo].[Basic_MessageQueue] ([TemplateCode],[Mobile],[Content] ,[Parameters] ,[Status],[Message] ,[Summary],[IpAdress],[RequestTime],[SendTime])
                                VALUES (@TemplateCode,@Mobile,@Content ,@Parameters ,@Status,@Message ,@Summary,@IpAdress,@RequestTime,@SendTime)";
                        parameters = new[]
                        {
                            repositoryContext.CreateParameter("@TemplateCode", 0),
                            repositoryContext.CreateParameter("@Mobile", shareResult.ShareUser.Mobile),
                            repositoryContext.CreateParameter("@Content", shareResult.SmsIntro),
                            repositoryContext.CreateParameter("@Parameters", string.Empty),
                            repositoryContext.CreateParameter("@Status", Convert.ToInt16(MessageStatus.Pending)),
                            repositoryContext.CreateParameter("@Message", string.Empty),
                            repositoryContext.CreateParameter("@Summary", string.Empty),
                            repositoryContext.CreateParameter("@IpAdress", "127.0.0.3"),
                            repositoryContext.CreateParameter("@RequestTime", DateTime.Now),
                            repositoryContext.CreateParameter("@SendTime", DateTime.Now)
                        };
                        sqlList.Add(sql);
                        dbParameterList.Add(parameters);
                    }

                    Ioc.Resolve <IObjectCache>().Set("MessageIsAllSend_Cache", false);
                }
            }

            #region //获取得到升级点的用户,并加入升级队列

            var upgradePointsUserIds = resultList
                                       .Where(r => r.MoneyTypeId == Guid.Parse("E97CCD1E-1478-49BD-BFC7-E73A5D699006"))
                                       .Select(r => r.ShareUser.Id).ToList();
            if (upgradePointsUserIds.Count > 0)
            {
                foreach (var userId in upgradePointsUserIds)
                {
                    var taskQueue = new TaskQueue {
                        UserId   = userId,
                        ModuleId = TaskQueueModuleId.UserUpgradeByUpgradePoints,
                        Type     = TaskQueueType.Once
                    };
                    sql =
                        "INSERT INTO [dbo].[Task_TaskQueue] ([UserId]  ,[Type],[ModuleId] ,[Parameter],[ExecutionTimes] ,[ExecutionTime],[CreateTime] ,[HandleTime] ,[MaxExecutionTimes],[Status] ,[Message]) " +
                        "VALUES (@UserId  ,@Type,@ModuleId ,@Parameter,@ExecutionTimes ,@ExecutionTime,@CreateTime ,@HandleTime ,@MaxExecutionTimes,@Status ,@Message)";
                    parameters = new[]
                    {
                        repositoryContext.CreateParameter("@UserId", taskQueue.UserId),
                        repositoryContext.CreateParameter("@Type", taskQueue.Type), // 升级只需执行一次
                        repositoryContext.CreateParameter("@ModuleId", taskQueue.ModuleId),
                        repositoryContext.CreateParameter("@Parameter", taskQueue.Parameter),
                        repositoryContext.CreateParameter("@ExecutionTimes", taskQueue.ExecutionTimes),
                        repositoryContext.CreateParameter("@ExecutionTime", taskQueue.ExecutionTime),
                        repositoryContext.CreateParameter("@CreateTime", taskQueue.CreateTime),
                        repositoryContext.CreateParameter("@HandleTime", taskQueue.HandleTime),
                        repositoryContext.CreateParameter("@MaxExecutionTimes", taskQueue.MaxExecutionTimes),
                        repositoryContext.CreateParameter("@Status", taskQueue.Status),
                        repositoryContext.CreateParameter("@Message", taskQueue.Message)
                    };
                    sqlList.Add(sql);
                    dbParameterList.Add(parameters);
                }
            }

            #endregion //获取得到升级点的用户,并加入升级队列

            try {
                sql = $"select Status from Things_Trade where Id={shareOrderId}";
                //Thread.Sleep(1); // 停留1,防止重复触发
                var shareOrderStatus = repositoryContext.ExecuteScalar(sql).ConvertToInt();
                // 如果订单状态==1,在执行数据操作
                if (shareOrderStatus == 1)
                {
                    repositoryContext.ExecuteBatch(sqlList, dbParameterList);
                }
            } catch (Exception ex) {
                sql        = "update Things_Trade set Summary=@Summary ,Status=@Status ,UpdateTime=GETDATE() where Id=@Id";
                parameters = new[]
                {
                    repositoryContext.CreateParameter("@Id", shareOrderId),
                    repositoryContext.CreateParameter("@Status", Convert.ToInt16(ShareOrderStatus.Error)),
                    repositoryContext.CreateParameter("@Summary", ex.Message)
                };
                repositoryContext.ExecuteNonQuery(sql, parameters);
            }
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();


            _tempsize = DensityScrollViewer.ContentHorizontalOffset;

            Closing += (s, e) => ViewModelLocator.Cleanup();

            Messenger.Default.Register <DataRoad>(this, "ShowInfo", message =>
            {
                Info = message;
            });
            Messenger.Default.Register <float>(this, "ShowInfoDistance", message =>
            {
                Distance = message;
            });
            Messenger.Default.Register <ObservableCollection <Graphics> >(this, "ShowGeneralGraff", message =>
                                                                          GeneralGraff.DrawGraphic(message, collor = true));
            var timer = new System.Windows.Threading.DispatcherTimer
            {
                Interval  = new TimeSpan(0, 0, 1),
                IsEnabled = true
            };

            timer.Tick +=
                (o, t) =>
            {
                TimeBlock.Text = "        " + DateTime.Now.ToLongTimeString() + "\n" +
                                 DateTime.Now.ToLongDateString();
            };
            timer.Start();

            Messenger.Default.Register <List <List <object> > >(this, "GreatGraphic", message =>
            {
                LineSeries LS;
                AreaSeries AS;
                ColumnSeries CL;
                List <byte> CountGener;
                List <float> Distance;
                List <float> Layer123;
                List <double> Plotnost;
                List <Graphics> dataValues;
                LinearAxis linerAxx;
                LinearAxis linerAxy;
                Setter setter;
                Style style;
                Style legendStyle;
                Setter legendSetterw;
                Setter legendSetterl;
                AreaDataPoint areaDataPoint;
                int max;
                Control control;
                LineDataPoint lineDataPoint;
                Setter setterpoint;
                switch (_greatGraphicName)
                {
                case "CountChart":
                    CountGener = new List <byte>();
                    Distance   = new List <float>();
                    foreach (var count in message[0])
                    {
                        CountGener.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    dataValues = new List <Graphics>();

                    for (var i = 0; i < CountGener.Count - 1; i++)
                    {
                        var graph        = new Graphics();
                        graph.CountLayer = CountGener[i];
                        graph.Distance   = Distance[i];
                        dataValues.Add(graph);
                    }
                    setter = new Setter();

                    setter.Property     = BackgroundProperty;
                    setter.Value        = Brushes.Black;
                    style               = new Style();
                    var columnDataPoint = new ColumnDataPoint();
                    style.TargetType    = columnDataPoint.GetType();
                    style.Setters.Add(setter);

                    CL = new ColumnSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "CountLayer",
                        IndependentValuePath = "Distance"
                    };
                    CL.DataPointStyle = style;



                    linerAxx               = new LinearAxis();
                    linerAxy               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = 4;
                    linerAxx.Title         = "Расстояние, [м]";

                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Количество слоёв",
                    };
                    legendSetterw          = new Setter();
                    legendSetterl          = new Setter();
                    legendStyle            = new Style();
                    control                = new Control();
                    legendSetterw.Property = WidthProperty;
                    legendSetterw.Value    = (double)0;
                    legendSetterl.Property = HeightProperty;
                    legendSetterl.Value    = (double)0;
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(legendSetterl);
                    legendStyle.Setters.Add(legendSetterw);
                    chart.LegendStyle = legendStyle;
                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;
                    chart.Series.Add(CL);
                    LayoutRoot.Children.Add(chart);

                    break;

                case "ChartLayer3":
                    Layer123 = new List <float>();
                    Distance = new List <float>();

                    foreach (var count in message[0])
                    {
                        Layer123.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    dataValues = new List <Graphics>();
                    max        = Convert.ToInt16(Layer123[0]);
                    for (var i = 0; i < Layer123.Count - 1; i++)
                    {
                        var graph      = new Graphics();
                        graph.Layer3   = Layer123[i];
                        graph.Distance = Distance[i];
                        dataValues.Add(graph);
                        if (Layer123[i] > max)
                        {
                            max = Convert.ToInt16(Layer123[i]);
                        }
                    }
                    linerAxx               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxx.ShowGridLines = true;
                    linerAxx.Title         = "Расстояние, [м]";
                    linerAxy               = new LinearAxis();
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Title         = "Толщина, [см]";
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = max + 2;



                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Толщина слоя №1",
                    };

                    setter               = new Setter();
                    setterpoint          = new Setter();
                    setterpoint.Property = OpacityProperty;
                    setterpoint.Value    = (double)0;
                    setter.Property      = BackgroundProperty;
                    setter.Value         = Brushes.DodgerBlue;

                    style            = new Style();
                    areaDataPoint    = new AreaDataPoint();
                    style.TargetType = areaDataPoint.GetType();
                    style.Setters.Add(setterpoint);
                    style.Setters.Add(setter);

                    AS = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer3",
                        IndependentValuePath = "Distance",
                    };
                    AS.DataPointStyle      = style;
                    legendSetterw          = new Setter();
                    legendSetterl          = new Setter();
                    legendStyle            = new Style();
                    control                = new Control();
                    legendSetterw.Property = WidthProperty;
                    legendSetterw.Value    = (double)0;
                    legendSetterl.Property = HeightProperty;
                    legendSetterl.Value    = (double)0;
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(legendSetterl);
                    legendStyle.Setters.Add(legendSetterw);
                    chart.LegendStyle = legendStyle;


                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;
                    chart.Series.Add(AS);
                    LayoutRoot.Children.Add(chart);

                    break;


                case "ChartLayer2":
                    Layer123 = new List <float>();
                    Distance = new List <float>();
                    foreach (var count in message[0])
                    {
                        Layer123.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    dataValues = new List <Graphics>();
                    max        = Convert.ToInt16(Layer123[0]);
                    for (var i = 0; i < Layer123.Count - 1; i++)
                    {
                        var graph      = new Graphics();
                        graph.Layer2   = Layer123[i];
                        graph.Distance = Distance[i];
                        dataValues.Add(graph);
                        if (Layer123[i] > max)
                        {
                            max = Convert.ToInt16(Layer123[i]);
                        }
                    }
                    linerAxx               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxx.ShowGridLines = true;
                    linerAxx.Title         = "Расстояние, [м]";
                    linerAxy               = new LinearAxis();
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Title         = "Толщина, [см]";
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = max + 2;



                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Толщина слоя №2",
                    };
                    setter               = new Setter();
                    setterpoint          = new Setter();
                    setterpoint.Property = OpacityProperty;
                    setterpoint.Value    = (double)0;
                    setter.Property      = BackgroundProperty;
                    setter.Value         = Brushes.DarkRed;
                    style            = new Style();
                    areaDataPoint    = new AreaDataPoint();
                    style.TargetType = areaDataPoint.GetType();
                    style.Setters.Add(setter);
                    style.Setters.Add(setterpoint);
                    AS = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer2",
                        IndependentValuePath = "Distance"
                    };
                    AS.DataPointStyle      = style;
                    legendSetterw          = new Setter();
                    legendSetterl          = new Setter();
                    legendStyle            = new Style();
                    control                = new Control();
                    legendSetterw.Property = WidthProperty;
                    legendSetterw.Value    = (double)0;
                    legendSetterl.Property = HeightProperty;
                    legendSetterl.Value    = (double)0;
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(legendSetterl);
                    legendStyle.Setters.Add(legendSetterw);
                    chart.LegendStyle = legendStyle;

                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;

                    chart.Series.Add(AS);
                    LayoutRoot.Children.Add(chart);

                    break;

                case "ChartLayer1":
                    Layer123 = new List <float>();
                    Distance = new List <float>();
                    foreach (var count in message[0])
                    {
                        Layer123.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    dataValues = new List <Graphics>();
                    max        = Convert.ToInt16(Layer123[0]);
                    for (var i = 0; i < Layer123.Count - 1; i++)
                    {
                        var graph      = new Graphics();
                        graph.Layer1   = Layer123[i];
                        graph.Distance = Distance[i];
                        dataValues.Add(graph);
                        if (Layer123[i] > max)
                        {
                            max = Convert.ToInt16(Layer123[i]);
                        }
                    }



                    linerAxx               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxx.ShowGridLines = true;
                    linerAxx.Title         = "Расстояние, [м]";
                    linerAxy               = new LinearAxis();
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Title         = "Толщина, [см]";
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = max + 2;


                    setter               = new Setter();
                    setterpoint          = new Setter();
                    setterpoint.Property = OpacityProperty;
                    setterpoint.Value    = (double)0;
                    setter.Property      = BackgroundProperty;
                    setter.Value         = Brushes.OliveDrab;
                    style            = new Style();
                    areaDataPoint    = new AreaDataPoint();
                    style.TargetType = areaDataPoint.GetType();
                    style.Setters.Add(setter);
                    style.Setters.Add(setterpoint);
                    AS = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer1",
                        IndependentValuePath = "Distance"
                    };
                    AS.DataPointStyle = style;


                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Толщина слоя №3",
                    };

                    legendSetterw          = new Setter();
                    legendSetterl          = new Setter();
                    legendStyle            = new Style();
                    control                = new Control();
                    legendSetterw.Property = WidthProperty;
                    legendSetterw.Value    = (double)0;
                    legendSetterl.Property = HeightProperty;
                    legendSetterl.Value    = (double)0;
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(legendSetterl);
                    legendStyle.Setters.Add(legendSetterw);
                    chart.LegendStyle = legendStyle;

                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;

                    chart.Series.Add(AS);
                    LayoutRoot.Children.Add(chart);

                    break;

                case "ChartAll":
                    var Layer1 = new List <float>();
                    var Layer2 = new List <float>();
                    var Layer3 = new List <float>();
                    Distance   = new List <float>();
                    foreach (var count in message[0])
                    {
                        Layer1.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }
                    foreach (var count in message[2])
                    {
                        Layer2.Add(Convert.ToByte(count));
                    }
                    foreach (var count in message[3])
                    {
                        Layer3.Add(Convert.ToByte(count));
                    }

                    dataValues = new List <Graphics>();
                    max        = Convert.ToInt16(Layer3[0]);

                    for (var i = 0; i < Layer1.Count - 1; i++)
                    {
                        var graph      = new Graphics();
                        graph.Layer3   = Layer3[i];
                        graph.Layer2   = Layer2[i];
                        graph.Layer1   = Layer1[i];
                        graph.Distance = Distance[i];
                        dataValues.Add(graph);

                        if (Layer3[i] > max)
                        {
                            max = Convert.ToInt16(Layer3[i]);
                        }
                    }

                    linerAxx               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxx.ShowGridLines = true;
                    linerAxx.Title         = "Расстояние, [м]";
                    linerAxy               = new LinearAxis();
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Title         = "Толщина, [см]";
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = max + 2;

                    ////
                    var setter1           = new Setter();
                    var setterpoint1      = new Setter();
                    setterpoint1.Property = OpacityProperty;
                    setterpoint1.Value    = (double)0;
                    setter1.Property      = BackgroundProperty;
                    setter1.Value         = Brushes.OliveDrab;
                    var style1            = new Style();
                    var areaDataPoint1    = new AreaDataPoint();
                    style1.TargetType     = areaDataPoint1.GetType();
                    style1.Setters.Add(setter1);
                    style1.Setters.Add(setterpoint1);
                    var ser1 = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer1",
                        IndependentValuePath = "Distance",
                        Title = "Слой №3"
                    };
                    ser1.DataPointStyle = style1;
                    ///
                    var setter2           = new Setter();
                    var setterpoint2      = new Setter();
                    setterpoint2.Property = OpacityProperty;
                    setterpoint2.Value    = (double)0;
                    setter2.Property      = BackgroundProperty;
                    setter2.Value         = Brushes.DarkRed;
                    var style2            = new Style();
                    var areaDataPoint2    = new AreaDataPoint();
                    style2.TargetType     = areaDataPoint2.GetType();
                    style2.Setters.Add(setter2);
                    style2.Setters.Add(setterpoint2);
                    var ser2 = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer2",
                        IndependentValuePath = "Distance",
                        Title = "Слой №2"
                    };
                    ser2.DataPointStyle = style2;
                    ///
                    var setter3           = new Setter();
                    var setterpoint3      = new Setter();
                    setterpoint3.Property = OpacityProperty;
                    setterpoint3.Value    = (double)0;
                    setter3.Property      = BackgroundProperty;
                    setter3.Value         = Brushes.DodgerBlue;
                    var style3            = new Style();
                    var areaDataPoint3    = new AreaDataPoint();
                    style3.TargetType     = areaDataPoint3.GetType();
                    style3.Setters.Add(setter3);
                    style3.Setters.Add(setterpoint3);
                    var ser3 = new AreaSeries
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "Layer3",
                        IndependentValuePath = "Distance",
                        Title = "Слой №1"
                    };
                    ser3.DataPointStyle = style3;

                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Толщина слоёв",
                    };

                    var setterlegendcollor      = new Setter();
                    var setterlegendborder      = new Setter();
                    setterlegendcollor.Property = BackgroundProperty;
                    setterlegendcollor.Value    = new SolidColorBrush(Color.FromRgb(3, 94, 129));
                    setterlegendborder.Property = BorderBrushProperty;
                    setterlegendborder.Value    = new SolidColorBrush(Color.FromRgb(3, 94, 129));
                    legendStyle            = new Style();
                    control                = new Control();
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(setterlegendcollor);
                    legendStyle.Setters.Add(setterlegendborder);
                    chart.LegendStyle = legendStyle;



                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;

                    chart.Series.Add(ser3);
                    chart.Series.Add(ser2);
                    chart.Series.Add(ser1);


                    LayoutRoot.Children.Add(chart);

                    break;


                case "Plotnost":
                    Plotnost = new List <double>();
                    Distance = new List <float>();
                    foreach (var count in message[0])
                    {
                        Plotnost.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    dataValues = new List <Graphics>();
                    max        = Convert.ToInt16(Plotnost[0]);
                    for (var i = 0; i < Plotnost.Count - 1; i++)
                    {
                        var graph         = new Graphics();
                        graph.IntensityN1 = Plotnost[i];
                        graph.Distance    = Distance[i];
                        dataValues.Add(graph);
                        if (Plotnost[i] > max)
                        {
                            max = Convert.ToInt16(Plotnost[i]);
                        }
                    }
                    linerAxx               = new LinearAxis();
                    linerAxx.Orientation   = AxisOrientation.X;
                    linerAxx.ShowGridLines = true;
                    linerAxx.Title         = "Расстояние, [м]";
                    linerAxy               = new LinearAxis();
                    linerAxy.Orientation   = AxisOrientation.Y;
                    linerAxy.ShowGridLines = true;
                    linerAxy.Title         = "[кг/м^3]";
                    linerAxy.Minimum       = 0;
                    linerAxy.Maximum       = max + 2;

                    setter               = new Setter();
                    setterpoint          = new Setter();
                    setterpoint.Property = OpacityProperty;
                    setterpoint.Value    = (double)0;
                    setter.Property      = BackgroundProperty;
                    setter.Value         = Brushes.OliveDrab;
                    style            = new Style();
                    lineDataPoint    = new LineDataPoint();
                    style.TargetType = lineDataPoint.GetType();
                    style.Setters.Add(setter);
                    style.Setters.Add(setterpoint);
                    LS = new LineSeries()
                    {
                        ItemsSource          = dataValues,
                        DependentValuePath   = "IntensityN1",
                        IndependentValuePath = "Distance"
                    };
                    LS.DataPointStyle = style;



                    chart = new Chart()
                    {
                        Background = new SolidColorBrush(Color.FromRgb(3, 94, 129)),
                        Title      = "Плотность",
                    };

                    legendSetterw          = new Setter();
                    legendSetterl          = new Setter();
                    legendStyle            = new Style();
                    control                = new Control();
                    legendSetterw.Property = WidthProperty;
                    legendSetterw.Value    = (double)0;
                    legendSetterl.Property = HeightProperty;
                    legendSetterl.Value    = (double)0;
                    legendStyle.TargetType = control.GetType();
                    legendStyle.Setters.Add(legendSetterl);
                    legendStyle.Setters.Add(legendSetterw);
                    chart.LegendStyle = legendStyle;


                    chart.Axes.Add(linerAxx);
                    chart.Axes.Add(linerAxy);
                    chart.MouseLeftButtonDown += MouseLeftButtonDownGrid;

                    chart.Series.Add(LS);
                    LayoutRoot.Children.Add(chart);

                    break;

                case "GeneralGraff":
                    CountGener = new List <byte>();
                    Distance   = new List <float>();
                    foreach (var count in message[0])
                    {
                        CountGener.Add(Convert.ToByte(count));
                    }
                    foreach (var distance in message[1])
                    {
                        Distance.Add(Convert.ToSingle(distance));
                    }

                    var dataValues1 = new ObservableCollection <Graphics>();

                    for (var i = 0; i < CountGener.Count - 1; i++)
                    {
                        var graph          = new Graphics();
                        graph.GeneralState = CountGener[i];
                        graph.Distance     = Distance[i];
                        dataValues1.Add(graph);
                    }

                    Gridnorm = new Grid();
                    Gridd    = new Graff();

                    Gridd.DrawGraphic(dataValues1, collor = false);
                    Gridd.Width                     = 1111;
                    Gridd.Height                    = 234;
                    var text1                       = new TextBlock();
                    var text2                       = new TextBlock();
                    var collor1                     = new TextBlock();
                    var collor2                     = new TextBlock();
                    var collortext1                 = new TextBlock();
                    var collortext2                 = new TextBlock();
                    collor1.Background              = Brushes.Red;
                    collor2.Background              = Brushes.Green;
                    collor1.Width                   = 50;
                    collor1.Height                  = 50;
                    collor2.Width                   = 50;
                    collor2.Height                  = 50;
                    collor1.HorizontalAlignment     = HorizontalAlignment.Left;
                    collor1.VerticalAlignment       = VerticalAlignment.Top;
                    collor2.HorizontalAlignment     = HorizontalAlignment.Left;
                    collor2.VerticalAlignment       = VerticalAlignment.Top;
                    collor1.Margin                  = new Thickness(370, 650, 0, 0);
                    collor2.Margin                  = new Thickness(690, 650, 0, 0);
                    collortext1.Text                = "- не соответствует";
                    collortext2.Text                = "- соответствует";
                    collortext1.FontSize            = 19;
                    collortext2.FontSize            = 19;
                    collortext1.HorizontalAlignment = HorizontalAlignment.Left;
                    collortext1.VerticalAlignment   = VerticalAlignment.Top;
                    collortext2.HorizontalAlignment = HorizontalAlignment.Left;
                    collortext2.VerticalAlignment   = VerticalAlignment.Top;
                    collortext1.Margin              = new Thickness(440, 657, 0, 0);
                    collortext2.Margin              = new Thickness(760, 657, 0, 0);
                    text1.Text                      = "Общее состояние дорожного покрытия";
                    text2.Text                      = "Расстояние, [м]";
                    text2.FontStyle                 = FontStyles.Italic;
                    text1.FontSize                  = 22;
                    text2.FontSize                  = 19;
                    text1.HorizontalAlignment       = HorizontalAlignment.Left;
                    text1.VerticalAlignment         = VerticalAlignment.Top;
                    text2.HorizontalAlignment       = HorizontalAlignment.Left;
                    text2.VerticalAlignment         = VerticalAlignment.Top;
                    text1.Margin                    = new Thickness(440, 350, 0, 0);
                    text2.Margin                    = new Thickness(570, 530, 0, 0);
                    Gridnorm.Children.Add(collortext1);
                    Gridnorm.Children.Add(collortext2);
                    Gridnorm.Children.Add(collor1);
                    Gridnorm.Children.Add(collor2);
                    Gridnorm.Children.Add(text1);
                    Gridnorm.Children.Add(text2);
                    Gridnorm.Children.Add(Gridd);
                    Gridnorm.Background = new SolidColorBrush(Color.FromRgb(3, 94, 129));
                    LayoutRoot.Children.Add(Gridnorm);

                    Gridnorm.MouseLeftButtonDown += MouseLeftButtonDownGrid1;
                    Gridd.MouseLeftButtonDown    += MouseLeftButtonDownGrid1;

                    break;
                }
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     获取view
        /// </summary>
        /// <param name="id"></param>
        /// <param name="autoModel"></param>
        /// <returns></returns>
        public Alabo.UI.Design.AutoForms.AutoForm GetView(object id, AutoBaseModel autoModel)
        {
            var dic = autoModel.Query.ToObject <Dictionary <string, string> >();

            dic.TryGetValue("ChannelId", out var channelId);
            var result      = Resolve <IArticleService>().GetSingle(id);
            var articleForm = new ArticleAutoForm();

            if (result != null)
            {
                articleForm = result.MapTo <ArticleAutoForm>();
            }

            articleForm.Id = id.ToString();
            if (channelId == null)
            {
                articleForm.ChannelId = result.ChannelId.ToString();
            }
            else
            {
                articleForm.ChannelId = channelId;
            }

            if (result != null)
            {
                var channel = Resolve <IChannelService>().GetSingle(r => r.Id == articleForm.ChannelId.ToObjectId());
                if (channel != null)
                {
                    var classType = Resolve <IChannelService>().GetChannelClassType(channel);
                    var tagType   = Resolve <IChannelService>().GetChannelTagType(channel);

                    var classlist = Resolve <IRelationIndexService>()
                                    .GetRelationIds(classType.FullName, result.RelationId); //文章分类
                    if (!string.IsNullOrEmpty(classlist))
                    {
                        var clas = classlist.ToSplitList();
                        if (clas.Count > 0)
                        {
                            clas.ForEach(p => { articleForm.Classes.Add(Convert.ToInt16(p)); });
                        }
                    }

                    var relationList = Resolve <IRelationIndexService>()
                                       .GetRelationIds(tagType.FullName, result.RelationId); //文章标签

                    if (!string.IsNullOrEmpty(relationList))
                    {
                        articleForm.Tags.Clear();
                        var tags = relationList.ToSplitList();
                        if (tags.Count > 0)
                        {
                            tags.ForEach(p => { articleForm.Tags.Add(Convert.ToInt16(p)); });
                        }
                    }
                }
            }

            var autoForm = ToAutoForm(articleForm);

            return(autoForm);
        }
Ejemplo n.º 7
0
 short IConvertible.ToInt16(IFormatProvider provider)
 {
     return(Convert.ToInt16(m_value));
 }
Ejemplo n.º 8
0
        protected static internal object ConvertValue(Type type, NSJSValue value)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            object o = FetchValue(type, value);

            if (type == typeof(int))
            {
                o = (o == null ? 0 : Converter.ToInt32(o));
            }
            else if (type == typeof(uint))
            {
                o = (o == null ? 0u : Converter.ToUInt32(o));
            }
            else if (type == typeof(short))
            {
                o = (o == null ? (short)0 : Converter.ToInt16(o));
            }
            else if (type == typeof(ushort))
            {
                o = (o == null ? (ushort)0 : Converter.ToUInt16(o));
            }
            else if (type == typeof(sbyte))
            {
                o = (o == null ? (sbyte)0 : Converter.ToSByte(o));
            }
            else if (type == typeof(byte))
            {
                o = (o == null ? (byte)0 : Converter.ToByte(o));
            }
            else if (type == typeof(long))
            {
                o = (o == null ? 0L : Converter.ToInt64(o));
            }
            else if (type == typeof(ulong))
            {
                o = (o == null ? 0ul : Converter.ToUInt64(o));
            }
            else if (type == typeof(float))
            {
                o = (o == null ? 0f : Converter.ToSingle(o));
            }
            else if (type == typeof(double))
            {
                o = (o == null ? 0d : Converter.ToDouble(o));
            }
            else if (type == typeof(decimal))
            {
                o = (o == null ? 0m : Converter.ToDecimal(o));
            }
            else if (type == typeof(char))
            {
                o = (o == null ? '\0' : Converter.ToChar(o));
            }
            else if (type == typeof(DateTime))
            {
                long ticks = 0;
                if (o is long)
                {
                    ticks = (long)o;
                }
                else if (o != null)
                {
                    ticks = Converter.ToInt64(o);
                }
                o = NSJSDateTime.LocalDateToDateTime(ticks);
            }
            else if (type == typeof(string))
            {
                if (o == null)
                {
                    o = null;
                }
                else if (!(o is string))
                {
                    o = o.ToString();
                }
            }
            else if (typeof(NSJSValue).IsAssignableFrom(type))
            {
                return(type.IsInstanceOfType(value) ? value : null);
            }
            return(o);
        }
Ejemplo n.º 9
0
 public short ToInt16(object value)
     => SystemConvert.ToInt16(value);
Ejemplo n.º 10
0
        /// <summary>
        ///     sum报表表格Sql语句
        /// </summary>
        /// <param name="reportInput">表字段</param>
        /// <returns></returns>
        private Tuple <string, List <SumColumns> > GetSumTableQuerySql(SumReportInput reportInput, string EnumName)
        {
            //还得扩展 SpecialField
            var tempSqlWhere       = string.Empty;
            var tempSqlField       = string.Empty;
            var tempSqlStatusCount = string.Empty;
            var colList            = new List <SumColumns>();
            var col = new SumColumns();

            col.name = "日期";
            col.type = "Date";
            colList.Add(col);

            if (!string.IsNullOrEmpty(EnumName))
            {
                var typeEnum = EnumName.GetTypeByName();
                if (typeEnum != null)
                {
                    foreach (Enum item in Enum.GetValues(typeEnum))
                    {
                        var itemName = item.GetDisplayName();
                        itemName = FilterSpecial(itemName);
                        var itemValue = item.ToString();
                        var itemKey   = Convert.ToInt16(item);
                        col = new SumColumns();
                        //实体字段
                        foreach (var field in reportInput.Fields)
                        {
                            var tempDisplayName = reportInput.EntityType.GetFiledDisplayName(field);
                            //统计 Sum状态数量
                            var TotalAmountName  = tempDisplayName + itemName;
                            var TotalAmountValue = field + itemValue;
                            //待完成 已完成 等状态
                            tempSqlStatusCount = tempSqlStatusCount + @" , SUM(CASE WHEN " + reportInput.Field + "=" +
                                                 itemKey + " THEN " + field + " ELSE 0 END) AS " + TotalAmountValue;
                            //var tempTableHeadName= tempDisplayName+"["+ itemName + "]";
                            col.name = TotalAmountName;
                            col.type = TotalAmountValue;
                            colList.Add(col);
                        }
                    }
                }
            }

            if (reportInput.Fields.Count > 0) //实体字段 过滤
            {
                foreach (var field in reportInput.Fields)
                {
                    var tempDisplayName = reportInput.EntityType.GetFiledDisplayName(field);
                    tempSqlField = tempSqlField + " ,sum(" + field + ") as " + field;

                    col      = new SumColumns();
                    col.name = tempDisplayName;
                    col.type = field;
                    colList.Add(col);
                }
            }
            ////查询条件
            //if (!string.IsNullOrEmpty(sqlWhere))
            //{
            //    tempSqlWhere = tempSqlWhere + " and " + sqlWhere;
            //}

            //日期验证
            if (reportInput.Condition.StartTime.ToString().IndexOf("0001") == -1 ||
                reportInput.Condition.EndTime.ToString().IndexOf("0001") == -1)
            {
                tempSqlWhere = tempSqlWhere + "  and  CreateTime between CONVERT(VARCHAR(100), '" +
                               reportInput.Condition.StartTime + "', 23) and CONVERT(VARCHAR(100), '" +
                               reportInput.Condition.EndTime + "', 23)";
            }

            reportInput.Condition.EntityType = reportInput.EntityType;
            var tableName   = reportInput.Condition.GetTableName();
            var sqlBaseExec = @" select CONVERT(VARCHAR(100), CreateTime, 23) as Date
                                   " + tempSqlField + tempSqlStatusCount + @"
                                    from " + tableName + @"
                                    where 1=1 " + tempSqlWhere + @"
                                    group by CONVERT(VARCHAR(100), CreateTime, 23)";

            if (FilterSqlScript(sqlBaseExec))
            {
                throw new ArgumentNullException("sql语句有异常!");
            }

            return(Tuple.Create(sqlBaseExec, colList));
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     按天数根据状态 统计数量 扩展 报图图状
        /// </summary>
        /// <returns></returns>
        public List <AutoReport> GetDayCountReportByFiled(CountReportInput countReport)
        {
            var tableName    = "";
            var specialField = "";
            var startTime    = DateTime.Now;
            var endTime      = DateTime.Now;
            var sqlWhere     = "";

            var tempSqlWhere = string.Empty;
            var chartCols    = new List <string>();

            chartCols.Add("日期");
            chartCols.Add("全部数量");
            chartCols.Add("比率");

            //查询条件
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                tempSqlWhere = " and " + sqlWhere;
            }

            //日期验证
            if (startTime.ToString().IndexOf("0001") == -1 || endTime.ToString().IndexOf("0001") == -1)
            {
                var varStartTime = string.Format("{0:yyyy-MM-dd}", startTime);
                var varEndTime   = string.Format("{0:yyyy-MM-dd}", endTime);
                tempSqlWhere = @" and (CONVERT(VARCHAR(100), CreateTime, 23) >='" + varStartTime +
                               "' and CONVERT(VARCHAR(100), CreateTime, 23)<= '" + varEndTime + "') ";
            }

            var tempSqlStatusCount = string.Empty;

            //枚举
            if (!string.IsNullOrEmpty(specialField))
            {
                var typeEnum = specialField.GetTypeByName();

                foreach (Enum item in Enum.GetValues(typeEnum))
                {
                    var itemName  = item.GetDisplayName();
                    var itemValue = item.ToString();
                    var key       = Convert.ToInt16(item);
                    tempSqlStatusCount = tempSqlStatusCount + @" count(CASE WHEN " + specialField + " =" + key +
                                         " THEN " + specialField + " END) AS  " + itemName + " , ";

                    chartCols.Add(itemName);
                }
            }

            var dbContext     = Ioc.Resolve <IAlaboUserRepository>().RepositoryContext;
            var sqlCountByDay = @" select  CONVERT(VARCHAR(100), CreateTime, 23) 日期, count(id) as 全部数量," +
                                tempSqlStatusCount +
                                @"cast( convert (decimal(18,2),100*cast(count(distinct isnull(id,0)) as float)/cast(((select  count(id) from " +
                                tableName + @") )as float) ) as varchar)+'%' as 比率
                                from " + tableName +
                                @" where 1 = 1 " + tempSqlWhere +
                                @" group by CONVERT(VARCHAR(100), CreateTime, 23) ";

            var result = new List <AutoReport>();

            var typeEnumExt = specialField.GetTypeByName();

            if (FilterSqlScript(sqlCountByDay) != true)
            {
                using (var dr = dbContext.ExecuteDataReader(sqlCountByDay)) {
                    while (dr.Read())
                    {
                        var listItem = new List <AutoReportItem>();
                        var output   = new AutoReport();

                        chartCols.ForEach(p => {
                            if (p.ToLower() == "日期")
                            {
                                output.Date = dr[p].ToString();
                            }
                            else if (p.ToLower() == "全部数量")
                            {
                                output.Date = dr[p].ToString();
                            }
                            else if (p.ToLower() == "比率")
                            {
                                output.Date = dr[p].ToString();
                            }
                            else
                            {
                                listItem.Add(new AutoReportItem {
                                    Name = p.ToString(), Value = dr[p].ToString()
                                });
                            }
                        });
                        output.AutoReportItem = listItem;
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 12
0
        /// <summary>
        ///     ExeclCountTableSql 根据特殊字段统计报表表格语句
        /// </summary>
        /// <param name="reportInput"></param>
        /// <param name="EnumName"></param>
        /// <returns></returns>
        private Tuple <string, List <Columns> > ExeclCountTableSql(CountReportInput reportInput, string EnumName)
        {
            var listCol      = new List <Columns>();
            var col          = new Columns();
            var tempSqlWhere = string.Empty;

            col.name = "日期";
            col.type = "date";
            listCol.Add(col);
            col      = new Columns();
            col.name = "全部数量";
            col.type = "count";
            listCol.Add(col);
            col      = new Columns();
            col.name = "比率";
            col.type = "rate";
            listCol.Add(col);

            #region 条件查询

            ////查询条件
            //if (!string.IsNullOrEmpty(sqlWhere))
            //{
            //    tempSqlWhere = " and " + sqlWhere;
            //}

            //日期验证
            if (reportInput.Condition.StartTime.ToString().IndexOf("0001") == -1 ||
                reportInput.Condition.EndTime.ToString().IndexOf("0001") == -1)
            {
                var varStartTime = string.Format("{0:yyyy-MM-dd}", reportInput.Condition.StartTime);
                var varEndTime   = string.Format("{0:yyyy-MM-dd}", reportInput.Condition.EndTime);
                tempSqlWhere = @" and (CONVERT(VARCHAR(100), CreateTime, 23) >='" + varStartTime +
                               "' and CONVERT(VARCHAR(100), CreateTime, 23)<= '" + varEndTime + "') ";
            }

            #endregion 条件查询

            var tempSqlStatusCount      = string.Empty;
            var tempSqlStatusRatioCount = string.Empty;

            reportInput.Condition.EntityType = reportInput.EntityType;
            var tableName = reportInput.Condition.GetTableName();

            //枚举
            if (!string.IsNullOrEmpty(EnumName))
            {
                var typeEnum = EnumName.GetTypeByName();

                foreach (Enum item in Enum.GetValues(typeEnum))
                {
                    var itemName = item.GetDisplayName();
                    itemName = FilterSpecial(itemName);
                    var itemValue = item.ToString();
                    var key       = Convert.ToInt16(item);
                    col = new Columns();
                    //统计状态数量
                    tempSqlStatusCount = tempSqlStatusCount + @" count(CASE WHEN " + reportInput.Field + " =" + key +
                                         " THEN " + reportInput.Field + " END) AS  " + itemValue + " , ";
                    col.name = itemName;
                    col.type = itemValue;
                    listCol.Add(col);

                    col = new Columns();
                    //统计状态比率字段
                    var itemNameRatio      = itemName + "比率";
                    var itemNameRatioValue = itemValue + "Rate";
                    col.name = itemNameRatio;
                    col.type = itemNameRatioValue;

                    //统计状态比率
                    tempSqlStatusRatioCount = tempSqlStatusRatioCount +
                                              @" cast( convert (decimal(18,2),100*cast(count(CASE WHEN " +
                                              reportInput.Field + "=" + key + " THEN " + reportInput.Field +
                                              " END) as float)/cast(((count(1) ) )as float) ) as varchar)+'%' as " +
                                              itemNameRatioValue + " , ";

                    listCol.Add(col);
                }
            }

            var sqlCountByDay = @" select  CONVERT(VARCHAR(100), CreateTime, 23) date, count(1) as count," +
                                tempSqlStatusCount + tempSqlStatusRatioCount +
                                @"cast( convert (decimal(18,2),100*cast(count(distinct isnull(id,0)) as float)/cast(((select  count(id) from " +
                                tableName + @") )as float) ) as varchar)+'%' as rate
                                from " + tableName +
                                @" where 1 = 1 " + tempSqlWhere +
                                @" group by CONVERT(VARCHAR(100), CreateTime, 23) ";

            return(Tuple.Create(sqlCountByDay, listCol));
        }
Ejemplo n.º 13
0
        /// <summary>
        ///     ExeclCountSql:根据特殊字段 统计报表图状语句
        /// </summary>
        /// <param name="countReportInput"></param>
        /// <param name="EnumName"></param>
        /// <returns></returns>
        private Tuple <string, List <string> > ExeclCountSql(CountReportInput countReportInput, string EnumName)
        {
            var tempSqlWhere = string.Empty;
            var chartCols    = new List <string>();

            chartCols.Add("日期");
            chartCols.Add("全部数量");
            chartCols.Add("比率");

            #region 条件查询

            ////查询条件
            //if (!string.IsNullOrEmpty(sqlWhere))
            //{
            //    tempSqlWhere = " and " + sqlWhere;
            //}
            // tempSqlWhere += countReportInput.Condition.ToSqlWhere();

            //日期验证
            if (countReportInput.Condition.StartTime.ToString().IndexOf("0001") == -1 ||
                countReportInput.Condition.EndTime.ToString().IndexOf("0001") == -1)
            {
                var varStartTime = string.Format("{0:yyyy-MM-dd}", countReportInput.Condition.StartTime);
                var varEndTime   = string.Format("{0:yyyy-MM-dd}", countReportInput.Condition.EndTime);
                tempSqlWhere = @" and (CONVERT(VARCHAR(100), CreateTime, 23) >='" + varStartTime +
                               "' and CONVERT(VARCHAR(100), CreateTime, 23)<= '" + varEndTime + "') ";
            }

            #endregion 条件查询

            var tempSqlStatusCount = string.Empty;

            countReportInput.Condition.EntityType = countReportInput.EntityType;
            var tableName = countReportInput.Condition.GetTableName();

            //枚举
            if (!string.IsNullOrEmpty(EnumName))
            {
                var typeEnum = EnumName.GetTypeByName();
                if (typeEnum != null)
                {
                    foreach (Enum item in Enum.GetValues(typeEnum))
                    {
                        var itemName = item.GetDisplayName();
                        itemName = FilterSpecial(itemName);
                        var itemValue = item.ToString();
                        var key       = Convert.ToInt16(item);
                        tempSqlStatusCount = tempSqlStatusCount + @" count(CASE WHEN " + countReportInput.Field + " =" +
                                             key + " THEN " + countReportInput.Field + " END) AS  " + itemName + " , ";
                        chartCols.Add(itemName);
                    }
                }
            }

            var sqlCountByDay = @" select  CONVERT(VARCHAR(100), CreateTime, 23) 日期, count(id) as 全部数量," +
                                tempSqlStatusCount +
                                @"cast( convert (decimal(18,2),100*cast(count(distinct isnull(id,0)) as float)/cast(((select  count(id) from " +
                                tableName + @") )as float) ) as varchar)+'%' as 比率
                                from " + tableName +
                                @" where 1 = 1 " + tempSqlWhere +
                                @" group by CONVERT(VARCHAR(100), CreateTime, 23) ";

            return(Tuple.Create(sqlCountByDay, chartCols));
        }
Ejemplo n.º 14
0
		short IConvertible.ToInt16 (IFormatProvider provider)
		{
			return Convert.ToInt16 (Value, provider);
		}
Ejemplo n.º 15
0
 short IConvertible.ToInt16(IFormatProvider provider)
 {
     return(Convert.ToInt16((float)this));
 }