public void SaveUserSettings(string userId, QueriesAndReportingModel qrModel)
 {
     throw new NotImplementedException();
 }
Exemple #2
0
        /// <summary>
        /// 将前台的字符串设置转化成SQL模型
        /// </summary>
        /// <param name="table"></param>
        /// <param name="selfil"></param>
        /// <param name="join"></param>
        /// <param name="where"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public QueriesAndReportingModel ToSQLString(string table, string selfil, string join, string where, string combo, string order)
        {
            //参数的判断放在页面端。
            string[] tableArr  = string.IsNullOrWhiteSpace(table) ? new string[] { } : table.Split(',');
            string[] selfilArr = string.IsNullOrWhiteSpace(selfil) ? new string[] { } : selfil.Split(',');
            string[] joinArr   = string.IsNullOrWhiteSpace(join) ? new string[] { } : join.Split(',');
            string[] whereArr  = string.IsNullOrWhiteSpace(where) ? new string[] { } : where.Split(',');
            string[] comboArr  = string.IsNullOrWhiteSpace(combo) ? new string[] { } : combo.Split(',');
            string[] orderArr  = string.IsNullOrWhiteSpace(order) ? new string[] { } : order.Split(',');
            var      model     = new QueriesAndReportingModel();

            if (tableArr.Length > 0)
            {
                var tables = new List <SettingTableModel>();
                foreach (var m in tableArr)
                {
                    var mArr = m.Split('.');
                    tables.Add(new SettingTableModel
                    {
                        Id     = mArr[0],
                        ENName = mArr[1]
                    });
                }
                model.Tables = tables;
            }
            if (selfilArr.Length > 0)
            {
                var selfils = new List <SettingFieldModel>();
                foreach (var m in selfilArr)
                {
                    var mArr = m.Split('.');
                    selfils.Add(new SettingFieldModel
                    {
                        TableId     = mArr[0],
                        Id          = mArr[1],
                        TableENName = mArr[2],
                        ENName      = mArr[3]
                    });
                }
                model.Fields = selfils;
            }
            if (joinArr.Length >= 3)
            {
                var joins = new List <JoinSettingModel>();

                for (int j = 0; j < joinArr.Length; j += 3)
                {
                    if (string.IsNullOrWhiteSpace(joinArr[j]) || string.IsNullOrWhiteSpace(joinArr[j + 1]) || string.IsNullOrWhiteSpace(joinArr[j + 2]))
                    {
                        continue;
                    }
                    joins.Add(new JoinSettingModel
                    {
                        LeftTableENName      = joinArr[j].Split('.')[0],
                        LeftAttributeENName  = joinArr[j].Split('.')[1],
                        Connectors           = joinArr[j + 1],
                        RightTableENName     = joinArr[j + 2].Split('.')[0],
                        RightAttributeENName = joinArr[j + 2].Split('.')[1]
                    });
                }
                model.JoinSettings = joins;
            }
            //if (whereArr.Length >= 3 )
            //{
            //    var wheres = new List<WhereSettingModel>
            //    {
            //        new WhereSettingModel
            //        {
            //            LeftTableENName = whereArr[0].Split('.')[0],
            //            LeftAttributeENName = whereArr[0].Split('.')[1],
            //            Connectors = whereArr[1],
            //            RightTableENName = whereArr[2].Split('.').Length>1?whereArr[2].Split('.')[0]:null,
            //            RightAttributeENName = whereArr[2].Split('.').Length>1?whereArr[2].Split('.')[1]:whereArr[2]
            //        }
            //    };
            //    if (whereArr.Length >= 3)
            //    {
            //        for (int i = 3; i < whereArr.Length; i += 4)
            //        {
            //            var addmodel = new WhereSettingModel
            //            {
            //                Operator = whereArr[i],
            //                LeftTableENName = whereArr[i+1].Split('.')[0],
            //                LeftAttributeENName = whereArr[i+1].Split('.')[1],
            //                Connectors = whereArr[i + 2],
            //                RightTableENName = whereArr[i + 3].Split('.').Length > 1 ? whereArr[i + 3].Split('.')[0] : null,
            //                RightAttributeENName = whereArr[i + 3].Split('.').Length > 1 ? whereArr[i + 3].Split('.')[1] : whereArr[i + 3]
            //            };
            //            wheres.Add(addmodel);
            //        }
            //    }
            //    model.WhereSettings = wheres;
            //}

            if (whereArr.Length >= 2 && string.IsNullOrWhiteSpace(whereArr[0]) && string.IsNullOrWhiteSpace(whereArr[1]))
            {
                var wheres = new List <WhereSettingModel>
                {
                    new WhereSettingModel
                    {
                        LeftTableENName     = whereArr[0].Split('.')[0],
                        LeftAttributeENName = whereArr[0].Split('.')[1],
                        Connectors          = whereArr[1],
                        //RightTableENName = whereArr[2].Split('.').Length>1?whereArr[2].Split('.')[0]:null,
                        //RightAttributeENName = whereArr[2].Split('.').Length>1?whereArr[2].Split('.')[1]:whereArr[2]
                    }
                };
                if (whereArr.Length >= 3)
                {
                    for (int i = 2; i < whereArr.Length; i += 3)
                    {
                        if (string.IsNullOrWhiteSpace(whereArr[i]) || string.IsNullOrWhiteSpace(whereArr[i + 1]) || string.IsNullOrWhiteSpace(whereArr[i + 2]))
                        {
                            continue;
                        }
                        var addmodel = new WhereSettingModel
                        {
                            Operator            = whereArr[i],
                            LeftTableENName     = whereArr[i + 1].Split('.')[0],
                            LeftAttributeENName = whereArr[i + 1].Split('.')[1],
                            Connectors          = whereArr[i + 2],
                            //RightTableENName = whereArr[i + 3].Split('.').Length > 1 ? whereArr[i + 3].Split('.')[0] : null,
                            //RightAttributeENName = whereArr[i + 3].Split('.').Length > 1 ? whereArr[i + 3].Split('.')[1] : whereArr[i + 3]
                        };
                        wheres.Add(addmodel);
                    }
                }
                model.WhereSettings = wheres;
            }

            if (comboArr.Length >= 1 && string.IsNullOrWhiteSpace(comboArr[0]))
            {
                var combos = new List <ComboSettingModel>();
                //{
                //    new ComboSettingModel
                //    //{
                //    //    //RightTableENName = comboArr[0].Split('.').Length>1?comboArr[0].Split('.')[2]:comboArr[0],
                //    //    //RightAttributeENName =  comboArr[0].Split('.').Length>1?comboArr[0].Split('.')[3]:comboArr[0],
                //    //}
                //};
                if (comboArr.Length >= 1)
                {
                    for (int i = 0; i < comboArr.Length; i++)
                    {
                        if (string.IsNullOrWhiteSpace(comboArr[i]))
                        {
                            continue;
                        }
                        var addmodel = new ComboSettingModel
                        {
                            RightTableENName     = comboArr[i].Split('.').Length > 3?comboArr[i].Split('.')[2]:comboArr[i],//如果输入小数,就会报错,超出数组界限
                            RightAttributeENName = comboArr[i].Split('.').Length > 3?comboArr[i].Split('.')[3]:null,
                        };
                        combos.Add(addmodel);
                    }
                }
                model.ComboSettings = combos;
            }

            if (orderArr.Length >= 2)
            {
                var orders = new List <OrderSettingModel>();
                for (int i = 0; i < orderArr.Length; i += 2)
                {
                    if (string.IsNullOrWhiteSpace(orderArr[i]) || string.IsNullOrWhiteSpace(orderArr[i + 1]))
                    {
                        continue;
                    }
                    orders.Add(new OrderSettingModel
                    {
                        TableENName     = orderArr[i].Split('.')[0],
                        AttributeENName = orderArr[i].Split('.')[1],
                        SortBy          = orderArr[i + 1]
                    });
                }
                model.OrderSettings = orders;
            }
            return(model);
        }
 public string GetSql(QueriesAndReportingModel qrModel)
 {
     throw new NotImplementedException();
 }