Exemple #1
0
        public object SendBatchNotice(LogicData arg)
        {
            var touser     = ComFunc.nvl(arg["touser"]);
            var remark     = ComFunc.nvl(arg["remark"]);
            var taskname   = ComFunc.nvl(arg["taskname"]);
            var starttime  = DateTimeStd.IsDateTimeThen(arg["starttime"], "yyyy-MM-dd HH:mm:ss");
            var endtime    = DateTimeStd.IsDateTimeThen(arg["endtime"], "yyyy-MM-dd HH:mm:ss");
            var resultdesc = ComFunc.nvl(arg["result"]);
            var up         = DB.NewDBUnitParameter();
            var s          = from t in DB.LamdaTable("user_info", "")
                             where t.userid == touser || t.UserName == touser || t.weixinid == touser
                             select t;
            var result = DB.ExcuteLamda(up, s);

            if (result.QueryTable.RowLength <= 0)
            {
                return(new
                {
                    issuccess = false,
                    msg = "用户不存在"
                });
            }
            touser = ComFunc.nvl(result.QueryTable[0, "weixinid"]);

            //var sendresult = Weixin.SendTemplateMsg(touser, "qQvNxlTbAtnkN7dM6M3-Wk0BRMLNg1f-pghYNcn3VVw", "", "", "",
            //    "批次执行通知", remark, taskname, starttime, endtime, resultdesc);

            return("");
        }
        private FrameDLRObject copyPOItem(dynamic source)
        {
            var rtn = FrameDLRObject.CreateInstance();

            rtn.hw_contract_no         = source.hw_contract_no;
            rtn.cust_contract_no       = source.cust_contract_no;
            rtn.version                = source.version;
            rtn.status                 = source.status;
            rtn.hw_frame_contract_no   = source.hw_frame_contract_no;
            rtn.cust_frame_contract_no = source.cust_frame_contract_no;
            rtn.hw_sign_entity         = source.hw_sign_entity;
            rtn.cust_sign_entity       = source.cust_sign_entity;
            rtn.cust_type_lv1          = source.cust_type_lv1;
            rtn.cust_type_lv2          = source.cust_type_lv2;
            rtn.trade_terms            = source.trade_terms;
            rtn.transport_mode         = source.transport_mode;
            rtn.payment_terms          = source.payment_terms;
            rtn.is_vat_included        = source.is_vat_included;
            rtn.contract_amount_cny    = DoubleStd.IsDouble(source.contract_amount_cny) ? DoubleStd.ParseStd(source.contract_amount_cny).Value : null;
            rtn.contract_amount_usd    = DoubleStd.IsDouble(source.contract_amount_usd) ? DoubleStd.ParseStd(source.contract_amount_usd).Value : null;
            rtn.retail_sample          = source.retail_sample;
            rtn.created_by             = source.created_by;
            rtn.created_date           = DateTimeStd.IsDateTime(source.created_date) ? DateTimeStd.ParseStd(source.created_date).Value.ToString("yyyyMMddHHmmss") : null;
            rtn.accepted_date          = DateTimeStd.IsDateTime(source.accepted_date) ? DateTimeStd.ParseStd(source.accepted_date).Value.ToString("yyyyMMddHHmmss") : null;
            rtn.review_completed_date  = DateTimeStd.IsDateTime(source.review_completed_date) ? DateTimeStd.ParseStd(source.review_completed_date).Value.ToString("yyyyMMddHHmmss") : null;
            rtn.signed_date            = DateTimeStd.IsDateTime(source.signed_date) ? DateTimeStd.ParseStd(source.signed_date).Value.ToString("yyyyMMddHHmmss") : null;
            return(rtn);
        }
        public object QueryList()
        {
            var estate_id  = ComFunc.nvl(PostDataD.estate);
            var position   = ComFunc.nvl(PostDataD.position);
            var start_time = DateTimeStd.IsDateTimeThen(PostDataD.start_time, "yyyy-MM-dd HH:mm:ss");
            var end_time   = DateTimeStd.IsDateTimeThen(PostDataD.start_time, "yyyy-MM-dd HH:mm:ss");
            var plate_no   = ComFunc.nvl(PostDataD.plate_no);

            var up     = DB.NewDBUnitParameter();
            var result = (from t in DB.LamdaTable(up, "IC_Car_Monitor", "a")
                          join t2 in DB.LamdaTable(up, "IC_Vehicle", "b").LeftJoin() on t.CM_Plate_No equals t2.V_No
                          join t3 in DB.LamdaTable(up, "IC_Device", "c").LeftJoin() on t.CM_Device equals t3.D_UID
                          join t4 in DB.LamdaTable(up, "IC_Estate", "d").LeftJoin() on t.CM_Estate_ID equals t4.E_ID
                          join t5 in DB.LamdaTable(up, "IC_Position", "e").LeftJoin() on t.CM_Position_XY equals t5.P_GUID
                          where t.notnull(estate_id, t.CM_Estate_ID == estate_id) &&
                          t.notnull(position, t.CM_Position_XY == position) &&
                          t.notnull(start_time, t.CM_Occur_Time >= start_time) &&
                          t.notnull(end_time, t.CM_Occur_Time <= end_time) &&
                          t.notnull(plate_no, t.CM_Plate_No.contains(plate_no))
                          select new
            {
                id = t.CM_GUID,
                plate_no = t.CM_Plate_No,
                plate_color = t.CM_Plate_Color,
                vertical_color = t.CM_Color,
                occur_time = t.CM_Occur_Time,
                position = t5.P_Name,
                device_id = t3.D_UID,
                device_code = t3.D_Code,
                device_name = t3.D_Name,
                estate_id = t4.E_ID,
                estate = t4.E_Name,
                driver_uid = t2.V_Driver,
                t.add_time,
                t.last_time
            }).QueryByPage(up, "occur_time desc,add_time desc,last_time desc");

            var data = result.QueryData <FrameDLRObject>().Select((d) =>
            {
                var dobj          = (FrameDLRObject)d;
                d.occur_time      = DateTimeStd.IsDateTimeThen(d.occur_time, "yyyy-MM-dd HH:mm:ss");
                d.driver_add_time = DateTimeStd.IsDateTimeThen(d.driver_add_time, "yyyy-MM-dd HH:mm:ss");
                d.is_recorded     = ComFunc.nvl(d.driver_uid) == "" ? false : true;
                dobj.Remove("add_time");
                dobj.Remove("last_time");
                return(d);
            });

            return(new
            {
                code = "success",
                msg = "",
                total_count = result.TotalRow,
                page = result.CurrentPage,
                total_page = result.TotalPage,
                limit = result.Count_Of_OnePage,
                data = from t in data
                       select t
            });
        }
        protected virtual void LoadConfig(WebParameter p, GoData d)
        {
            foreach (var item in MyConfig.GetConfigurationList("ConnectionStrings"))
            {
                p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
            }
            p.DBConnectionString = ComFunc.nvl(p[DomainKey.CONFIG, "DefaultConnection"]);
            bool bvalue = true;

            foreach (var item in MyConfig.GetConfigurationList("EFFC"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }
        }
        object DeliverySign()
        {
            SetCacheEnable(false);
            var free_text = ComFunc.nvl(QueryStringD.free_text);
            var up        = DB.NewDBUnitParameter();
            var s         = from t in DB.LamdaTable("HW_DeliveryStatusInfo", "a")
                            where t.notnull(free_text, t.free_text == free_text) &&
                            t.pod_sign_date != null
                            select t;
            var result = DB.LamdaQueryByPage(up, s, "actual_shipped_date desc,pod_sign_date desc");

            return(new
            {
                total_num = result.TotalRow,
                current_page = result.CurrentPage,
                total_page = result.TotalPage,
                page_size = result.Count_Of_OnePage,
                data = from t in result.QueryData <FrameDLRObject>()
                       select new
                {
                    t.delivery_id,
                    t.packing_list_no,
                    t.hw_contract_no,
                    t.cust_contract_no,
                    t.cust_purchase_no,
                    //t.cust_code_cbg,
                    //t.cust_code_hw,
                    //t.cust_name,
                    //t.channel_id,
                    //t.cust_type_lv1,
                    //t.cust_type_lv2,
                    t.country_code,
                    //t.prod_type_cn,
                    //t.prod_type_en,
                    //t.prod_business_type,
                    t.prod_code_sale,
                    //t.prod_code_make,
                    t.prod_desc_hw,
                    //t.prod_desc_hw_en,
                    t.prod_code_cust,
                    t.prod_desc_cust,
                    //t.prod_model_hw,
                    //t.prod_model_ext,
                    //t.prod_color_cn,
                    //t.prod_color_en,
                    t.cust_purchase_item,
                    estimate_arrive_date = DateTimeStd.IsDateTimeThen(t.estimate_arrive_date, "yyyy-MM-dd HH:mm:ss"),
                    actual_shipped_date = DateTimeStd.IsDateTimeThen(t.actual_shipped_date, "yyyy-MM-dd HH:mm:ss"),
                    t.destination_city,
                    t.destination_province,
                    t.destination_detail,
                    delivery_quantity = IntStd.IsInt(t.delivery_quantity) ? IntStd.ParseStd(t.delivery_quantity).Value : 0,
                    pod_sign_date = DateTimeStd.IsDateTimeThen(t.pod_sign_date, "yyyy-MM-dd HH:mm:ss"),
                    sign_quantity = IntStd.IsInt(t.sign_quantity) ? IntStd.ParseStd(t.sign_quantity).Value : 0,
                    t.order_line_note,
                    t.free_text
                }
            });
        }
Exemple #6
0
        object QueryIMEI()
        {
            SetCacheEnable(false);
            var    delivery_id = QueryStringD.delivery_id;
            string start_time  = DateTimeStd.IsDateTimeThen(QueryStringD.start_time, "yyyy-MM-dd HH:mm:ss");
            string end_time    = DateTimeStd.IsDateTimeThen(QueryStringD.end_time, "yyyy-MM-dd HH:mm:ss");

            var up = DB.NewDBUnitParameter();
            var s  = from t in DB.LamdaTable("HW_IMEI_Info", "a")
                     join t2 in DB.LamdaTable("hw_deliverystatusinfo", "b") on t.delivery_id equals t2.delivery_id
                     where t.notnull(delivery_id, t.delivery_id == delivery_id) &&
                     t.notnull(start_time, t.create_time >= start_time) &&
                     t.notnull(end_time, t.end_time <= end_time)
                     select new
            {
                t.delivery_id,
                t.prod_model_ext,
                t.prod_code_sale,
                t.prod_code_make,
                t.prod_color_cn,
                t.prod_color_en,
                t.prod_barcode,
                t.imei,
                t.imei_1,
                t.imei_2,
                t.meid_hex,
                t.meid_dec,
                t.meid_dec_18,
                t.meid_hex_14,
                t.wifi,
                t.mac,
                t.mac_1,
                t.mac_2,
                t.ean_upc_code,
                t.software_version,
                t.spc,
                t.sim_card_no,
                t.caton_id_hw,
                t.pallet_id_hw,
                t.pallet_id_cust,
                t.caton_id_cust,
                t2.prod_code_cust,
                t2.prod_desc_cust
            };

            var result = DB.LamdaQueryByPage(up, s, "delivery_id");

            return(new
            {
                total_num = result.TotalRow,
                current_page = result.CurrentPage,
                total_page = result.TotalPage,
                page_size = result.Count_Of_OnePage,
                data = result.QueryData <FrameDLRObject>()
            });
        }
        public string ConvertTo(object obj)
        {
            if (obj == null)
            {
                return("");
            }

            string             rtn = "";
            UnitDataCollection udc = null;

            if (obj is UnitDataCollection)
            {
                udc = (UnitDataCollection)obj;
            }
            else
            {
                throw new Exception("QueryByPage2Json无法转化" + obj.GetType().FullName + "类型数据!");
            }

            if (udc.QueryTable != null)
            {
                JsonObjectCollection jsonrtn = new JsonObjectCollection();
                //jsonrtn.Add(new JsonStringValue("Count_Of_OnePage", udc.Count_Of_OnePage + ""));
                jsonrtn.Add(new JsonStringValue("page", udc.CurrentPage + ""));
                //jsonrtn.Add(new JsonStringValue("total", udc.TotalPage + ""));
                jsonrtn.Add(new JsonStringValue("total", udc.TotalRow + ""));

                DataTableStd        dts     = udc.QueryTable;
                JsonArrayCollection jsonobj = new JsonArrayCollection("rows");
                for (int j = 0; j < dts.RowLength; j++)
                {
                    JsonObjectCollection jac = new JsonObjectCollection();
                    foreach (string colname in dts.ColumnNames)
                    {
                        if (dts.ColumnDateType(colname).FullName == typeof(DateTime).FullName)
                        {
                            DateTimeStd dtime = DateTimeStd.ParseStd(dts[j, colname]);
                            jac.Add(new JsonStringValue(colname, dtime != null ? dtime.Value.ToString("yyyy/MM/dd HH:mm:ss") : ""));
                        }
                        else
                        {
                            jac.Add(new JsonStringValue(colname, ComFunc.nvl(dts[j, colname])));
                        }
                    }
                    jsonobj.Add(jac);
                }
                jsonrtn.Add(jsonobj);



                rtn = jsonrtn.ToString();
            }

            return(rtn);
        }
Exemple #8
0
        /// <summary>
        /// 獲得一個webrequest的實例
        /// </summary>
        /// <returns></returns>
        protected virtual HttpWebRequest GetRequestInstance()
        {
            HttpWebRequest hr           = (HttpWebRequest)WebRequest.Create(new Uri(_url));
            string         cookieheader = "";

            if (hr.CookieContainer != null)
            {
                cookieheader = hr.CookieContainer.GetCookieHeader(new Uri(_url));
            }

            CookieContainer cookieCon = new CookieContainer();

            hr.CookieContainer = cookieCon;
            hr.CookieContainer.SetCookies(new Uri(_url), cookieheader);

            hr.KeepAlive = false;
            hr.Method    = _requestmethod;
            hr.Proxy     = _proxy;
            if (_cert != null)
            {
                hr.ClientCertificates.Add(_cert);
            }
            //添加header
            foreach (var k in _header.Keys)
            {
                if (k.ToLower() == "date")
                {
                    hr.Date = DateTimeStd.IsDateTime(_header.GetValue(k)) ? DateTimeStd.ParseStd(ComFunc.nvl(_header.GetValue(k))).Value : DateTime.Now;
                }
                else if (k.ToLower() == "content-length")
                {
                    hr.ContentLength = long.Parse(ComFunc.nvl(_header.GetValue(k)));
                }
                else if (k.ToLower() == "user-agent")
                {
                    hr.UserAgent = ComFunc.nvl(_header.GetValue(k));
                }
                else
                {
                    if (ComFunc.nvl(hr.Headers[k]) != "")
                    {
                        hr.Headers[k] = ComFunc.nvl(_header.GetValue(k));
                    }
                    else
                    {
                        hr.Headers.Add(k, ComFunc.nvl(_header.GetValue(k)));
                    }
                }
            }
            return(hr);
        }
Exemple #9
0
        object DoSyncSummaryPerDay17()
        {
            lock (lockobj)
            {
                DateTime start = DateTimeStd.ParseStd($"{DateTime.Now.ToString("yyyy-MM-dd")} 09:00:00").Value;
                DateTime end   = DateTimeStd.ParseStd($"{DateTime.Now.ToString("yyyy-MM-dd")} 17:00:00").Value;
                var      up    = DB.NewDBUnitParameter();
                //BeginTrans();
                var msg = "";
                if (!DoSyncAPPSummaryPerDay(up, start, end, ref msg))
                {
                    return(new
                    {
                        issuccess = false,
                        msg
                    });
                }
                if (!DoSyncRetailSummaryPerDay(up, start, end, ref msg))
                {
                    return(new
                    {
                        issuccess = false,
                        msg
                    });
                }
                if (!DoSyncChannelSummaryPerDay(up, start, end, ref msg))
                {
                    return(new
                    {
                        issuccess = false,
                        msg
                    });
                }
                if (!DoSyncPlatSummaryPerDay(up, start, end, ref msg))
                {
                    return(new
                    {
                        issuccess = false,
                        msg
                    });
                }

                //CommitTrans();
                return(new
                {
                    code = "success",
                    msg = "执行成功"
                });
            }
        }
        object GetLog()
        {
            SetCacheEnable(false);
            string userids    = ComFunc.nvl(QueryStringD.user_ids);
            var    start_date = DateTimeStd.IsDateTimeThen(QueryStringD.start_date, "yyyy-MM-dd HH:mm:ss");
            var    end_date   = DateTimeStd.IsDateTimeThen(QueryStringD.end_date, "yyyy-MM-dd HH:mm:ss");
            var    events     = ComFunc.nvl(QueryStringD.events);

            var up = DB.NewDBUnitParameter();

            var s = from t in DB.LamdaTable("ecs_user_wallet_log", "a")
                    where t.notnull(start_date, t.last_time >= start_date) &&
                    t.notnull(end_date, t.last_time <= end_date) &&
                    t.notnull(events, t.events.contains(events)) &&
                    t.notnull(userids, t.user_id.within(userids))
                    select t;
            var result = DB.LamdaQueryByPage(up, s, "last_time desc,seq desc");
            var list   = result.QueryData <FrameDLRObject>();

            return(new
            {
                code = "success",
                total_num = result.TotalRow,
                current_page = result.CurrentPage,
                total_page = result.TotalPage,
                page_size = result.Count_Of_OnePage,
                data = (from t in list
                        select new
                {
                    t.user_id,
                    t.amount,
                    t.ebs_wd_no,
                    t.events,
                    t.memo,
                    modi_time = DateTimeStd.IsDateTimeThen(t.last_time, "yyyy-MM-dd HH:mm:ss"),
                    t.seq,
                    in_amount = (t.events == "打款") ? t.amount : 0,
                    out_amount = (t.events == "核销") ? t.amount : 0,
                    t.total_amount,
                    t.available_amount,
                    t.freeze_amount,
                    t.used_amount,
                    t.line_total_amount,
                    t.line_available_amount,
                    t.line_freeze_amount,
                    t.line_used_amount
                }).ToList()
            });
        }
Exemple #11
0
        public string ConvertTo(object obj)
        {
            string rtn = "";

            if (obj == null)
            {
                return("");
            }

            DataSet ds = null;

            if (obj is DataSet)
            {
                ds = (DataSetStd)obj;
            }
            else
            {
                throw new Exception("DataSet2Json无法转化" + obj.GetType().FullName + "类型数据!");
            }

            JsonObjectCollection jsonrtn = new JsonObjectCollection();

            for (int i = 0; i < ds.Tables.Count; i++)
            {
                DataTableStd        dts     = DataTableStd.ParseStd(ds.Tables[i]);
                JsonArrayCollection jsonobj = new JsonArrayCollection("TableData" + i);
                for (int j = 0; j < dts.RowLength; j++)
                {
                    JsonObjectCollection jac = new JsonObjectCollection();
                    foreach (string colname in dts.ColumnNames)
                    {
                        if (dts.ColumnDateType(colname).FullName == typeof(DateTime).FullName)
                        {
                            DateTimeStd dtime = DateTimeStd.ParseStd(dts[j, colname]);
                            jac.Add(new JsonStringValue(colname, dtime != null ? dtime.Value.ToString("yyyy/MM/dd HH:mm:ss") : ""));
                        }
                        else
                        {
                            jac.Add(new JsonStringValue(colname, ComFunc.nvl(dts[j, colname])));
                        }
                    }
                    jsonobj.Add(jac);
                }
                jsonrtn.Add(jsonobj);
            }

            rtn = "{" + jsonrtn.ToString() + "}";
            return(rtn);
        }
Exemple #12
0
        protected override object Convert2DateTime(object[] args)
        {
            if (args == null || args.Length <= 0)
            {
                return(this);
            }

            var    rtn    = LinqDLRColumn.New <MysqlDLRColumn>("", this, SqlFlags);
            object value  = null;
            var    format = "%Y-%m-%d %H:%i:%s";

            if (args.Length == 1)
            {
                if (args[0] is LinqDLRColumn)
                {
                    value = args[0];
                }
                else
                {
                    value = DateTimeStd.IsDateTimeThen(args[0], "yyyy-MM-dd HH:mm:ss");
                }
            }
            else if (args.Length == 3)
            {
                var year  = ComFunc.nvl(args[0]);
                var month = ComFunc.nvl(args[1]);
                var day   = ComFunc.nvl(args[2]);

                value  = $"{year}-{month.PadLeft(2, '0')}-{day.PadLeft(2, '0')}";
                format = "%Y-%m-%d";
            }
            else if (args.Length > 3)
            {
                var year   = ComFunc.nvl(args[0]);
                var month  = ComFunc.nvl(args[1]);
                var day    = ComFunc.nvl(args[2]);
                var hour   = args.Length > 3 ? ComFunc.nvl(args[3]) : "00";
                var minute = args.Length > 4 ? ComFunc.nvl(args[4]) : "00";
                var second = args.Length > 5 ? ComFunc.nvl(args[5]) : "00";

                value = $"{year}-{month.PadLeft(2, '0')}-{day.PadLeft(2, '0')} {hour.PadLeft(2, '0')}:{minute.PadLeft(2, '0')}:{second.PadLeft(2, '0')}";
            }

            var express = $"STR_TO_DATE({rtn.Convert2Express(value)},'{format}')";

            rtn.ColumnExpress = express;
            return(rtn);
        }
Exemple #13
0
 private void SetPropertyValue <M>(ref M m, PropertyInfo fi, object value)
 {
     if (fi.PropertyType.FullName == typeof(DateTime).FullName)
     {
         fi.SetValue(m, DateTimeStd.ParseStd(value).Value, null);
     }
     else if (fi.GetCustomAttributes(typeof(ConvertorAttribute), false).Length > 0)
     {
         ConvertorAttribute ca = (ConvertorAttribute)Attribute.GetCustomAttribute(fi, typeof(ConvertorAttribute), false);
         fi.SetValue(m, ca.Convertor.ConvertTo(value), null);
     }
     else
     {
         fi.SetValue(m, value, null);
     }
 }
        /// <summary>
        /// 獲得一個webrequest的實例
        /// </summary>
        /// <returns></returns>
        protected HttpWebRequest GetRequestInstance(HttpParameter hp, ResponseObject hd)
        {
            var handler = new HttpClientHandler();

            HttpWebRequest hr           = (HttpWebRequest)WebRequest.Create(new Uri(hp.ToUrl));
            string         cookieheader = "";

            if (hr.CookieContainer != null)
            {
                cookieheader = hr.CookieContainer.GetCookieHeader(new Uri(hp.ToUrl));
            }

            CookieContainer cookieCon = new CookieContainer();

            hr.CookieContainer = cookieCon;
            hr.CookieContainer.SetCookies(new Uri(hp.ToUrl), cookieheader);
            hr.Method = hp.RequestMethod;
            hr.Proxy  = hp.HttpWebProxy;
            //if (_cert != null)
            //{
            //    hr.ClientCertificates.Add(_cert);
            //}
            //添加header
            foreach (var k in hp.Header.Keys)
            {
                if (k.ToLower() == "date")
                {
                    hr.Headers["Date"] = DateTimeStd.IsDateTime(hp.Header.GetValue(k)) ? DateTimeStd.ParseStd(ComFunc.nvl(hp.Header.GetValue(k))).Value.ToUniversalTime().ToString("r") : DateTime.Now.ToString("r");
                }
                else if (k.ToLower() == "content-length")
                {
                    hr.Headers["Content-Length"] = ComFunc.nvl(hp.Header.GetValue(k));
                }
                else if (k.ToLower() == "user-agent")
                {
                    hr.Headers["User-Agent"] = ComFunc.nvl(hp.Header.GetValue(k));
                }
                else
                {
                    hr.Headers[k] = ComFunc.nvl(hp.Header.GetValue(k));
                }
            }


            return(hr);
        }
Exemple #15
0
        public JsonCollection ConvertTo(object obj)
        {
            if (obj == null)
            {
                return(new JsonObjectCollection());
            }

            DataTableStd dtt = null;

            if (obj is DataTable)
            {
                dtt = DataTableStd.ParseStd(obj);
            }
            else if (obj is DataTableStd)
            {
                dtt = (DataTableStd)obj;
            }
            else
            {
                throw new Exception("DataTable2Json无法转化" + obj.GetType().FullName + "类型数据!");
            }

            JsonArrayCollection jsonobj = new JsonArrayCollection("rows");

            for (int i = 0; i < dtt.RowLength; i++)
            {
                JsonObjectCollection jac = new JsonObjectCollection();
                foreach (string colname in dtt.ColumnNames)
                {
                    if (dtt.ColumnDateType(colname).FullName == typeof(DateTime).FullName)
                    {
                        DateTimeStd dtime = DateTimeStd.ParseStd(dtt[i, colname]);
                        jac.Add(new JsonStringValue(colname, dtime != null ? dtime.Value.ToString("yyyy/MM/dd HH:mm:ss") : ""));
                    }
                    else
                    {
                        jac.Add(new JsonStringValue(colname, ComFunc.nvl(dtt[i, colname])));
                    }
                }
                jsonobj.Add(jac);
            }


            return(jsonobj);
        }
 private object ConvertConditionValue(string datatype, object v)
 {
     if (new string[] { "datetime" }.Contains(datatype.ToLower()))
     {
         return(DateTimeStd.IsDateTimeThen(v, "yyyy-MM-dd HH:mm:ss"));
     }
     else if (new string[] { "bit" }.Contains(datatype.ToLower()))
     {
         return(BoolStd.ConvertTo(v, 1, 0));
     }
     else if (new string[] { "text", "picture", "file" }.Contains(datatype.ToLower()))
     {
         return("");
     }
     else
     {
         return(v);
     }
 }
            /// <summary>
            /// 判定是否为日期类型
            /// </summary>
            /// <param name="rule">json结构,key为传入参数名称,value为提示信息</param>
            /// <returns></returns>
            public virtual dynamic DateTimeValidation(FrameDLRObject rule)
            {
                var rtn = FrameDLRObject.CreateInstance(@"{
issuccess:true,
msg:''
}");

                foreach (var s in rule.Keys)
                {
                    var input = _logic.CallContext_Parameter[DomainKey.POST_DATA, s];
                    input = input == null ? _logic.CallContext_Parameter[DomainKey.QUERY_STRING, s] : input;
                    if (!DateTimeStd.IsDateTime(input))
                    {
                        rtn.issuccess = false;
                        rtn.msg       = rule.GetValue(s);
                        return(rtn);
                    }
                }
                return(rtn);
            }
Exemple #18
0
        protected override void LoadConfig(WebParameter p, GoData d)
        {
            base.LoadConfig(p, d);
            bool bvalue = true;

            foreach (var item in MyConfig.GetConfigurationList("Weixin"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }
        }
        protected override ParameterStd ConvertParameters(object[] obj)
        {
            var p = new ConsoleParameter();

            if (obj != null & obj.Length > 0)
            {
                var command = ComFunc.nvl(obj[0]).ToLower();
                if (command == "stop")
                {
                    p.ExtentionObj.stop = true;
                }
            }
            //config
            foreach (var item in MyConfig.GetConfigurationList("ConnectionStrings"))
            {
                p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
            }
            p.DBConnectionString = ComFunc.nvl(p[DomainKey.CONFIG, "DefaultConnection"]);
            bool bvalue = true;

            foreach (var item in MyConfig.GetConfigurationList("EFFC"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }

            return(p);
        }
        object GetDriverInfo(string id)
        {
            var up     = DB.NewDBUnitParameter();
            var result = (from t in DB.LamdaTable(up, "IC_Resident", "f")
                          join t1 in DB.LamdaTable(up, "IC_House", "g").LeftJoin() on t.R_House_ID equals t1.H_ID
                          join t2 in DB.LamdaTable(up, "IC_Building", "h").LeftJoin() on t1.H_Building_ID equals t2.B_ID
                          where t.R_ID == id
                          select new
            {
                driver_uid = t.R_ID,
                driver_name = t.R_Name,
                driver_id_no = t.R_ID_No,
                driver_add_time = t.add_time,
                driver_house_id = t1.R_House_ID,
                driver_house_no = t1.H_No,
                driver_house_unit = t1.H_Unit,
                driver_building_name = t2.B_Name
            }).GetQueryList(up);

            if (result.Count <= 0)
            {
                return(new
                {
                    code = "failed",
                    msg = "无该车主资料"
                });
            }
            dynamic data = result.First();

            data.driver_add_time = DateTimeStd.IsDateTimeThen(data.driver_add_time, "yyyy-MM-dd HH:mm:ss");
            return(new
            {
                code = "success",
                msg = "",
                data
            });
        }
Exemple #21
0
        /// <summary>
        /// 通过xml建立动态对象,最简单的xml结构,如下:
        /// <xxx>
        ///     <n1></n1>
        ///     <n2></n2>
        ///     <nodes>
        ///         <nn1></nn1>
        ///         <nnn></nnn>
        ///     </nodes>
        ///     <nn></nn>
        /// </xxx>
        /// </summary>
        /// <param name="node"></param>
        /// <param name="flags"></param>
        /// <returns></returns>
        private static dynamic BuildLoopXml(XmlNodeList nodelist, FrameDLRFlags flags)
        {
            FrameDLRObject rtn = new FrameDLRObject();

            if ((flags & FrameDLRFlags.SensitiveCase) != 0)
            {
                rtn.ignorecase = false;
            }
            else
            {
                rtn.ignorecase = true;
            }

            foreach (XmlNode item in nodelist)
            {
                if (item.HasChildNodes && item.FirstChild.NodeType == XmlNodeType.Element)
                {
                    FrameDLRObject rtnloop = BuildLoopXml(item.ChildNodes, flags);
                    rtn.SetValue(item.Name, rtnloop);
                }
                else
                {
                    if (DateTimeStd.IsDateTime(item.InnerText))
                    {
                        rtn.SetValue(item.Name, DateTimeStd.ParseStd(item.InnerText).Value);
                    }
                    else
                    {
                        rtn.SetValue(item.Name, item.InnerText);
                    }
                }
            }


            return(rtn);
        }
        protected override ParameterStd ConvertParameters(object[] obj)
        {
            var p = new ConsoleParameter();

            if (obj != null & obj.Length > 0)
            {
                var la = ComFunc.nvl(obj[0]).Split('.', StringSplitOptions.RemoveEmptyEntries);
                p.CallLogicName = la.Length > 0 ? la[0] : "";
                p.CallAction    = la.Length > 1 ? la[1] : "";
            }
            //config
            foreach (var item in MyConfig.GetConfigurationList("ConnectionStrings"))
            {
                p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
            }
            p.DBConnectionString = ComFunc.nvl(p[DomainKey.CONFIG, "DefaultConnection"]);
            bool bvalue = true;

            foreach (var item in MyConfig.GetConfigurationList("EFFC"))
            {
                if (bool.TryParse(ComFunc.nvl(item.Value), out bvalue))
                {
                    p[DomainKey.CONFIG, item.Key] = bool.Parse(ComFunc.nvl(item.Value));
                }
                else if (DateTimeStd.IsDateTime(item.Value))
                {
                    p[DomainKey.CONFIG, item.Key] = DateTimeStd.ParseStd(item.Value).Value;
                }
                else
                {
                    p[DomainKey.CONFIG, item.Key] = ComFunc.nvl(item.Value);
                }
            }

            return(p);
        }
        private DateTime GetSettingTime()
        {
            var maxday = 0;
            var dt     = DateTime.Now;
            var year   = dt.Year;
            var month  = _month > 0 && _month < 13 ? _month : dt.Month;

            maxday = new DateTimeStd(year, month, 1).DayOfMonth;

            var day    = _day > 0 && _day <= maxday?_day: dt.Day;
            var hour   = _hour >= 0 && _hour <= 23 ? _hour : dt.Hour;
            var minute = _minute >= 0 && _minute <= 59 ? _minute : dt.Hour;
            var second = _second >= 0 && _second <= 59 ? _second : dt.Hour;
            var rtn    = new DateTime(year, month, day, hour, minute, second);

            if (rtn > DateTime.Now)
            {
                return(rtn);
            }
            else
            {
                return(DateTime.MinValue);
            }
        }
Exemple #24
0
        protected void SetControlValue(Control c, object value)
        {
            if (value is string)
            {
                value = value.ToString().Trim();
            }

            if (c is TextBox)
            {
                ((TextBox)c).Text = ComFunc.nvl(value);
            }
            else if (c is Label)
            {
                ((Label)c).Text = ComFunc.nvl(value);
            }
            else if (c is DropDownList)
            {
                if (value != null)
                {
                    if (value is string)
                    {
                        string v = ComFunc.nvl(value);
                        if (((DropDownList)c).Items.FindByValue(v) != null)
                        {
                            ((DropDownList)c).SelectedValue = ComFunc.nvl(value);
                        }
                    }
                }
            }
            else if (c is RadioButton)
            {
                ((RadioButton)c).Checked = value != null?bool.Parse(ComFunc.nvl(value)) : false;
            }
            else if (c is RadioButtonList)
            {
                ((RadioButtonList)c).SelectedValue = ComFunc.nvl(value);
            }
            else if (c is CalendarInput)
            {
                if (value is DateTime)
                {
                    ((CalendarInput)c).SelectedDate = DateTimeStd.ParseStd(value).Value;
                }
                else if (value is DateTimeStd)
                {
                    ((CalendarInput)c).SelectedDate = DateTimeStd.ParseStd(value);
                }
                else
                {
                    ((CalendarInput)c).Text = ComFunc.nvl(value);
                }
            }
            else if (c is CheckBox)
            {
                ((CheckBox)c).Checked = value != null?bool.Parse(ComFunc.nvl(value)) : false;
            }
            else if (c is CheckBoxList)
            {
                string stempvalue = (string)value;
                if (stempvalue != null)
                {
                    List <string> ltemp       = new List <string>();
                    string[]      splitvalues = stempvalue.Split(',');
                    foreach (string v in splitvalues)
                    {
                        ltemp.Add(v);
                    }
                    foreach (ListItem item in ((CheckBoxList)c).Items)
                    {
                        if (ltemp.Contains(item.Value))
                        {
                            item.Selected = true;
                        }
                    }
                }
            }
            else if (c is HiddenField)
            {
                ((HiddenField)c).Value = ComFunc.nvl(value);
            }
        }
        public DataCollection DoOperate(ParameterStd p)
        {
            UnitDataCollection rtn  = new UnitDataCollection();
            string             flag = p.GetValue <string>("_unit_action_flag_");
            UnitParameter      up   = (UnitParameter)p;

            if (up.Dao is ADBAccess)
            {
                T   t      = (T)Activator.CreateInstance(typeof(T), true);
                var sqlobj = t.GetSqlFunc(flag)(up);
                if (!(sqlobj is FrameDLRObject))
                {
                    throw new TypeRequiredException("需要指定的动态数据对象:FrameDLRObject");
                }
                string    sql = sqlobj.sql;
                ADBAccess dba = (ADBAccess)up.Dao;
                DBOParameterCollection dbc = new DBOParameterCollection();
                if (!string.IsNullOrEmpty(sql))
                {
                    string regstr = "";
                    regstr = @"(?<=" + (dba.ParameterFlagChar == "$"?"\\$": dba.ParameterFlagChar) + @")[A-Za-z0-9_]+\d*";
                    string regexpress = @"(?isx)
                                (')                                                           #开始标记“<tag...>”
                                (?>                                                                  #分组构造,用来限定量词“*”修饰范围
                                \1  (?<Open>)                                                 #命名捕获组,遇到开始标记,入栈,Open计数加1
                                |\1  (?<-Open>)                                                   #狭义平衡组,遇到结束标记,出栈,Open计数减1
                                |[^']*                                                   #右侧不为开始或结束标记的任意字符
                                )
                                (?(Open)(?!))                                                        #判断是否还有'OPEN',有则说明不配对,什么都不匹配
                                \1                                                                #结束标记“</tag>”
                     ";
                    Regex  re         = new Regex(regstr);
                    string tmpsql     = "";
                    Regex  re2        = new Regex(regexpress);
                    tmpsql = sql.Replace("''", "#sp#");
                    foreach (Match m in re2.Matches(tmpsql))
                    {
                        tmpsql = tmpsql.Replace(m.Value, "#sp#");
                    }
                    foreach (System.Text.RegularExpressions.Match m in re.Matches(tmpsql))
                    {
                        if (up.GetValue(m.ToString()) is byte[])
                        {
                            dbc.Add(m.ToString(), up.GetValue(m.ToString()), System.Data.DbType.Binary);
                        }
                        else if (up.GetValue(m.ToString()) is DateTime)
                        {
                            dbc.Add(m.ToString(), up.GetValue(m.ToString()), System.Data.DbType.DateTime);
                        }
                        else if (up.GetValue(m.ToString()) is int)
                        {
                            dbc.Add(m.ToString(), up.GetValue(m.ToString()), System.Data.DbType.Int32);
                        }
                        else if (up.GetValue(m.ToString()) is double)
                        {
                            dbc.Add(m.ToString(), up.GetValue(m.ToString()), System.Data.DbType.Double);
                        }
                        else
                        {
                            dbc.Add(m.ToString(), up.GetValue(m.ToString()));
                        }
                    }
                }
                try
                {
                    rtn.QueryDatas = dba.Query(sql, dbc);
                }catch (Exception ex)
                {
                    FrameDLRObject dp = FrameDLRObject.CreateInstance(Base.Constants.FrameDLRFlags.SensitiveCase);
                    foreach (var item in dbc)
                    {
                        if (item.Value.ParameterValue is DateTime)
                        {
                            dp.SetValue(item.Key, DateTimeStd.IsDateTimeThen(item.Value.ParameterValue, "yyyy-MM-dd HH:mm:ss"));
                        }
                        else if (item.Value.ParameterValue is DBNull)
                        {
                            dp.SetValue(item.Key, null);
                        }
                        else
                        {
                            dp.SetValue(item.Key, item.Value.ParameterValue);
                        }
                    }
                    GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"QuerySql={sql};\nParameters={dp.ToJSONString()}");

                    throw ex;
                }
                if (rtn.QueryDatas != null && rtn.QueryDatas.Tables.Count > 0)
                {
                    rtn.QueryTable = rtn.QueryDatas[0];
                }
            }
            return(rtn);
        }
Exemple #26
0
        void load(dynamic args)
        {
            var uppsql = DB.NewPSQLDBUnitParameter();
            var up     = DB.NewDBUnitParameter();



            var s2 = from t in DB.LamdaTable("common_sale_proxy", "a")
                     select new
            {
                t.prod_code,
                t.state,
                t.dealer_type,
                t.dealer_code
            };
            var s3 = from t in DB.LamdaTable("common_hw_prod_map", "a")
                     select new
            {
                t.prod_code,
                t.prod_code_hw
            };

            var salemapresult = DB.ExcuteLamda(up, s2);
            var prodmapresult = DB.ExcuteLamda(up, s3);

            var salemaplist = (from t in salemapresult.QueryData <FrameDLRObject>()
                               select new
            {
                key = t.prod_code + "|" + t.dealer_type + "|" + t.dealer_code,
                value = t.dealer_code
            }).ToList();

            salemaplist.AddRange(from t in salemapresult.QueryData <FrameDLRObject>()
                                 select new
            {
                key   = t.prod_code + "|" + t.state.Replace("省", "").Replace("市", "").Replace("自治区", ""),
                value = t.dealer_code
            });
            salemaplist.AddRange(from t in salemapresult.QueryData <FrameDLRObject>()
                                 select new
            {
                key   = t.prod_code + "|" + t.plateform_code,
                value = t.dealer_code
            });
            var salemap = salemaplist.ToDictionary <string, string>(k => k.key, v => v.value);
            var prodmap = (from t in prodmapresult.QueryData <FrameDLRObject>()
                           select new
            {
                key = t.prod_code_hw,
                value = t.prod_code
            }).ToDictionary <string, string>(k => k.key, v => v.value);


            var smax = (from t in DB.PSQLLamdaTable("t_sale_so", "a")
                        select t.modi_time).Max("a.modi_time");
            var maxresult     = DB.ExcuteLamda(up, smax);
            var max_modi_time = maxresult.QueryTable.RowLength > 0 ? ComFunc.nvl(maxresult.QueryTable[0, 0]) : "";

            var s1 = from t in DB.PSQLLamdaTable("t_terminal_so_line", "a")
                     where t.modi_time != null && t.province_name_so != "" && t.notnull(max_modi_time, t.append(t.modi_time > max_modi_time, "::timestamp"))
                     select new
            {
                t.id,
                t.comp_code,
                t.prod_code,
                t.qty,
                t.form_date,
                t.modi_time,
                type  = t.busi_type,
                state = t.province_name_so,
                t.dealer_code,
                t.dealer_code2,
                t.dealer_code3
            };

            uppsql.Count_Of_OnePage = 10000;
            uppsql.ToPage           = 1;
            var result = DB.LamdaQueryByPage(uppsql, s1, "id");

            do
            {
                var list = result.QueryData <FrameDLRObject>().Select(d =>
                {
                    dynamic rtn = FrameDLRObject.CreateInstance();
                    //采用bulkinsert,必须保证栏位顺序与db中的一致才行
                    rtn.id          = d.id;
                    rtn.dealer_code = "";
                    rtn.comp_code   = d.comp_code;
                    rtn.prod_code   = prodmap.ContainsKey(d.prod_code) ? prodmap[d.prod_code] : "";
                    rtn.qty         = d.qty;
                    rtn.form_date   = d.form_date;
                    rtn.modi_time   = DateTimeStd.IsDateTimeThen(d.modi_time, "yyyy-MM-dd HH:mm:ss");
                    rtn.type        = null;
                    rtn.state       = d.state;

                    if (d.type == "总部发货")
                    {
                        rtn.type = 1;
                    }
                    else if (d.type == "本省发货")
                    {
                        rtn.type = 2;
                    }
                    else
                    {
                        rtn.type = null;
                    }
                    var dealercode_ok = "";
                    //一、用dealer_code,dealer_code2,dealer_code3分别去“主辅省包-平台对应关系”匹配,找到辅省包由记该省包SO,没找到继续下一步
                    //二、用dealer_code,dealer_code2,dealer_code3分别去“主辅省包-平台对应关系”匹配,找到主省包由记该省包SO,没找到继续下一步
                    //三、以上两步都没找到匹配的,则用省份名称去“主辅省包-平台对应关系”找主省包,记该省包SO
                    var key11 = rtn.prod_code + "|2|" + d.dealer_code;
                    var key12 = rtn.prod_code + "|2|" + d.dealer_code2;
                    var key13 = rtn.prod_code + "|2|" + d.dealer_code3;
                    var key21 = rtn.prod_code + "|1|" + d.dealer_code;
                    var key22 = rtn.prod_code + "|1|" + d.dealer_code2;
                    var key23 = rtn.prod_code + "|1|" + d.dealer_code3;
                    var key3  = rtn.prod_code + "|" + d.state;

                    if (salemap.ContainsKey(key11) && salemap[key11].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key11];
                    }
                    else if (salemap.ContainsKey(key12) && salemap[key12].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key12];
                    }
                    else if (salemap.ContainsKey(key13) && salemap[key13].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key13];
                    }
                    else if (salemap.ContainsKey(key21) && salemap[key21].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key21];
                    }
                    else if (salemap.ContainsKey(key22) && salemap[key22].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key22];
                    }
                    else if (salemap.ContainsKey(key23) && salemap[key23].StartsWith("R"))
                    {
                        dealercode_ok = salemap[key23];
                    }
                    else if (salemap.ContainsKey(key3))
                    {
                        dealercode_ok = salemap[key3];
                    }
                    else
                    {
                        dealercode_ok = "";
                    }
                    rtn.dealer_code = dealercode_ok;

                    return(rtn);
                }).ToList();

                DB.BulkInsert(up, "t_sale_so", list);
                //foreach (dynamic item in list)
                //{
                //    DB.QuickInsertNotExists(up, "t_sale_so", item, new
                //    {
                //        id = item.id
                //    });

                //}

                list.Clear();
                uppsql.ToPage++;
                result.Clear();
                result = DB.LamdaQueryByPage(uppsql, s1, "id");
            } while (result.QueryTable.RowLength > 0 && result.CurrentPage == uppsql.ToPage);
        }
Exemple #27
0
        public DataCollection DoOperate(ParameterStd p)
        {
            string flag = p.GetValue <string>("_unit_action_flag_");
            //预执行
            T                  t   = (T)Activator.CreateInstance(typeof(T), true);
            UnitParameter      up  = (UnitParameter)p;
            UnitDataCollection rtn = new UnitDataCollection();

            if (up.Dao is ADBAccess)
            {
                var       sqlobj     = t.GetSqlFunc(flag)(up);
                ADBAccess dba        = (ADBAccess)up.Dao;
                string    regstr     = "";
                string    regexpress = @"(?isx)
                                (')                                                           #开始标记“<tag...>”
                                (?>                                                                  #分组构造,用来限定量词“*”修饰范围
                                \1  (?<Open>)                                                 #命名捕获组,遇到开始标记,入栈,Open计数加1
                                |\1  (?<-Open>)                                                   #狭义平衡组,遇到结束标记,出栈,Open计数减1
                                |[^']*                                                   #右侧不为开始或结束标记的任意字符
                                )
                                (?(Open)(?!))                                                        #判断是否还有'OPEN',有则说明不配对,什么都不匹配
                                \1                                                                #结束标记“</tag>”
                     ";
                string    tmpsql     = "";
                regstr = @"(?<=" + (dba.ParameterFlagChar == "$" ? "\\$" : dba.ParameterFlagChar) + @")[A-Za-z0-9_]+\d*";

                Regex re  = new Regex(regstr);
                Regex re2 = new Regex(regexpress);
                try
                {
                    if (!(sqlobj is FrameDLRObject))
                    {
                        throw new TypeRequiredException("需要指定的动态数据对象:FrameDLRObject");
                    }

                    string   presql = sqlobj.presql;
                    DBAPageP dbc    = new DBAPageP();
                    //dba.BeginTransaction();
                    if (!string.IsNullOrEmpty(presql))
                    {
                        tmpsql = presql.Replace("''", "#sp#");
                        foreach (Match m in re2.Matches(tmpsql))
                        {
                            tmpsql = tmpsql.Replace(m.Value, "#sp#");
                        }

                        foreach (System.Text.RegularExpressions.Match m in re.Matches(tmpsql))
                        {
                            dbc.SQL_Parameters.Add(m.ToString(), up.GetValue(m.ToString()));
                        }
                        try
                        {
                            dba.ExecuteNoQuery(presql, dbc.SQL_Parameters);
                        }
                        catch (Exception ex)
                        {
                            FrameDLRObject dp = FrameDLRObject.CreateInstance(Base.Constants.FrameDLRFlags.SensitiveCase);
                            foreach (var item in dbc.SQL_Parameters)
                            {
                                if (item.Value.ParameterValue is DateTime)
                                {
                                    dp.SetValue(item.Key, DateTimeStd.IsDateTimeThen(item.Value.ParameterValue, "yyyy-MM-dd HH:mm:ss"));
                                }
                                else if (item.Value.ParameterValue is DBNull)
                                {
                                    dp.SetValue(item.Key, null);
                                }
                                else
                                {
                                    dp.SetValue(item.Key, item.Value.ParameterValue);
                                }
                            }
                            GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"QueryByPage PreSql={presql};\nParameters={dp.ToJSONString()}");

                            throw ex;
                        }
                    }
                    //执行翻页查询
                    string sql     = sqlobj.sql;
                    string orderby = sqlobj.orderby;
                    if (!string.IsNullOrEmpty(sql))
                    {
                        tmpsql = sql.Replace("''", "#sp#");
                        foreach (Match m in re2.Matches(tmpsql))
                        {
                            tmpsql = tmpsql.Replace(m.Value, "#sp#");
                        }

                        dbc.SQL_Parameters.Clear();
                        foreach (System.Text.RegularExpressions.Match m in re.Matches(tmpsql))
                        {
                            if (up.GetValue(m.ToString()) is byte[])
                            {
                                dbc.SQL_Parameters.Add(m.ToString(), up.GetValue(m.ToString()), System.Data.DbType.Binary);
                            }
                            else
                            {
                                dbc.SQL_Parameters.Add(m.ToString(), up.GetValue(m.ToString()));
                            }
                        }
                        try
                        {
                            dbc.SQL              = sql;
                            dbc.OrderBy          = orderby;
                            dbc.Count_of_OnePage = up.Count_Of_OnePage;
                            dbc.CurrentPage      = up.CurrentPage;
                            dba.StartPageByCondition(dbc);
                            rtn.QueryTable = dba.GoToPage(up.ToPage);
                            rtn.QueryDatas = new DataSetStd();
                            rtn.QueryDatas.Tables.Add(rtn.QueryTable);
                            rtn.Count_Of_OnePage = up.Count_Of_OnePage;
                            rtn.CurrentPage      = dba.CurrentPage;
                            rtn.TotalPage        = dba.TotalPage;
                            rtn.TotalRow         = dba.TotalRow;
                        }
                        catch (Exception ex)
                        {
                            FrameDLRObject dp = FrameDLRObject.CreateInstance(Base.Constants.FrameDLRFlags.SensitiveCase);
                            foreach (var item in dbc.SQL_Parameters)
                            {
                                if (item.Value.ParameterValue is DateTime)
                                {
                                    dp.SetValue(item.Key, DateTimeStd.IsDateTimeThen(item.Value.ParameterValue, "yyyy-MM-dd HH:mm:ss"));
                                }
                                else if (item.Value.ParameterValue is DBNull)
                                {
                                    dp.SetValue(item.Key, null);
                                }
                                else
                                {
                                    dp.SetValue(item.Key, item.Value.ParameterValue);
                                }
                            }
                            GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"QueryByPage sql={sql};\n order by={orderby};\nParameters={dp.ToJSONString()}");

                            throw ex;
                        }
                    }
                    //收尾处理
                    string aftersql = sqlobj.aftersql;
                    if (!string.IsNullOrEmpty(aftersql))
                    {
                        tmpsql = aftersql.Replace("''", "#sp#");
                        foreach (Match m in re2.Matches(tmpsql))
                        {
                            tmpsql = tmpsql.Replace(m.Value, "#sp#");
                        }

                        dbc.SQL_Parameters.Clear();
                        foreach (System.Text.RegularExpressions.Match m in re.Matches(tmpsql))
                        {
                            dbc.SQL_Parameters.Add(m.ToString(), up.GetValue(m.ToString()));
                        }
                        try
                        {
                            dba.ExecuteNoQuery(aftersql, dbc.SQL_Parameters);
                        }catch (Exception ex)
                        {
                            FrameDLRObject dp = FrameDLRObject.CreateInstance(Base.Constants.FrameDLRFlags.SensitiveCase);
                            foreach (var item in dbc.SQL_Parameters)
                            {
                                if (item.Value.ParameterValue is DateTime)
                                {
                                    dp.SetValue(item.Key, DateTimeStd.IsDateTimeThen(item.Value.ParameterValue, "yyyy-MM-dd HH:mm:ss"));
                                }
                                else if (item.Value.ParameterValue is DBNull)
                                {
                                    dp.SetValue(item.Key, null);
                                }
                                else
                                {
                                    dp.SetValue(item.Key, item.Value.ParameterValue);
                                }
                            }
                            GlobalCommon.Logger.WriteLog(Base.Constants.LoggerLevel.ERROR, $"QueryByPage AfterSql={aftersql};\nParameters={dp.ToJSONString()}");

                            throw ex;
                        }
                    }

                    //dba.CommitTransaction();
                }
                catch
                {
                    //if (dba != null)
                    //    dba.RollbackTransaction();
                    throw;
                }
            }
            return(rtn);
        }
        object Search()
        {
            SetCacheEnable(false);
            var no         = ComFunc.nvl(QueryStringD.no);
            var userno     = ComFunc.nvl(QueryStringD.userno);
            var status     = ComFunc.nvl(QueryStringD.status);
            var start_time = DateTimeStd.IsDateTimeThen(QueryStringD.start_time, "yyyy-MM-dd HH:mm:ss");
            var end_time   = DateTimeStd.IsDateTimeThen(QueryStringD.end_time, "yyyy-MM-dd HH:mm:ss");
            var sortcolumn = ComFunc.nvl(QueryStringD.sortcolumn);
            var sort       = ComFunc.nvl(QueryStringD.sort);

            //当前页超过末页时,自动显示最后一页的资料
            DB.Is_Auto_To_Last_Page = true;
            var up = DB.NewDBUnitParameter();
            var s  = from t in DB.LamdaTable("ecs_forpay", "a")
                     join t2 in DB.LamdaTable("ecs_users", "b") on t.user_id equals t2.user_id
                     where t.notnull(no, t.forpay_no.contains(no)) &&
                     t2.notnull(userno, (t2.user_name.contains(userno) || t2.company_name.contains(userno) || t2.customer_num.contains(userno))) &&
                     t.notnull(status, t.status == status) &&
                     t.notnull(start_time, t.add_time >= start_time) &&
                     t.notnull(end_time, t.add_time <= end_time)
                     select new
            {
                t.uid,
                t.forpay_no,
                t2.company_name,
                t.foruse,
                t.charge_amount,
                t.charge_type,
                t.bank_name,
                t.bank_no,
                t.trans_seq_no,
                t.add_time,
                t.status,
                t.uploadfile_name
            };
            var sortstr = "forpay_no desc";
            var sortrtn = "";
            var dicsort = new Dictionary <string, string>();

            dicsort.Add("seq_no", "forpay_no");
            dicsort.Add("company_name", "company_name");
            dicsort.Add("add_time", "add_time");
            dicsort.Add("foruse", "foruse");
            dicsort.Add("charge_type", "charge_type");
            dicsort.Add("charge_amount", "charge_amount");
            dicsort.Add("bank_name", "bank_name");
            dicsort.Add("bank_no", "bank_no");
            dicsort.Add("trans_seq_no", "trans_seq_no");
            dicsort.Add("status", "status");
            if (sortcolumn != "" && dicsort.ContainsKey(sortcolumn))
            {
                sortstr = dicsort[sortcolumn] + (sort == "" ? "" : " " + sort);
                sortrtn = sortcolumn + "#" + (sort == "" ? "asc" : sort);
            }
            var result = DB.LamdaQueryByPage(up, s, sortstr);
            var dic    = new Dictionary <string, string>();

            dic.Add("Create", "待审核");
            dic.Add("Review", "已审核");
            dic.Add("Success", "充值成功");
            dic.Add("Failed", "充值失败");
            return(new
            {
                code = "success",
                totalrow = result.TotalRow,
                totalpage = result.TotalPage,
                currentpage = result.CurrentPage,
                pagesize = result.Count_Of_OnePage,
                data = from t in result.QueryData <FrameDLRObject>()
                       select new
                {
                    t.uid,
                    seq_no = t.forpay_no,
                    charge_amount = "¥" + DecimalStd.IsNotDecimalThen(t.charge_amount).ToString("###,###.##"),
                    t.charge_type,
                    t.bank_name,
                    t.bank_no,
                    t.trans_seq_no,
                    t.company_name,
                    t.foruse,
                    add_time = DateTimeStd.IsDateTimeThen(t.add_time, "yyyy-MM-dd HH:mm:ss"),
                    status = dic.ContainsKey(t.status) ? dic[t.status] : "",
                    filename = t.uploadfile_name
                },
                sort = sortrtn
            });
        }
Exemple #29
0
        object ReportRetails_Users_Plat(string report_uid)
        {
            SetCacheEnable(false);
            string user_uid = ComFunc.nvl(TokenPayLoad["no"]);

            var up   = DB.NewDBUnitParameter();
            var list = (from t in DB.LamdaTable(up, "RetailSummaryPerDay", "a")
                        where t.uid == report_uid
                        select t).GetQueryList(up);

            if (list.Count <= 0)
            {
                return(new
                {
                    code = "failed",
                    msg = "没有该报表的资料"
                });
            }
            dynamic info = list.First();
            var     dt   = DateTimeStd.IsDateTimeThen(info.log_time, "yyyy-MM-dd");
            var     s    = from t in DB.LamdaTable(up, "APPExchange", "a")
                           join t2 in DB.LamdaTable(up, "UserInfo", "b").LeftJoin() on t.mobile equals t2.mobile
                           where t2.recommend_uid == info.retail_uid && t.log_time >= $"{dt} 00:00:00" && t.log_time <= $"{dt} 23:59:59"
                           select new
            {
                t.log_time,
                t.mobile,
                t2.name,
                t.is_deal,
                t.is_register,
                t.is_perfection,
                t.deal_amount
            };
            var result = s.QueryByPage(up, "log_time desc");
            var tdata  = from t in result.QueryData <FrameDLRObject>()
                         select new
            {
                log_time      = DateTimeStd.IsDateTimeThen(t.log_time, "yyyy-MM-dd HH:mm:ss"),
                mobile        = ComFunc.nvl(t.mobile),
                name          = ComFunc.nvl(t.name).Length > 0 ? ComFunc.AESDecrypt(ComFunc.nvl(t.name)) : "",
                is_deal       = BoolStd.IsNotBoolThen(t.is_deal),
                is_register   = BoolStd.IsNotBoolThen(t.is_register),
                is_perfection = BoolStd.IsNotBoolThen(t.is_perfection),
                t.deal_amount
            };

            return(new
            {
                code = "success",
                msg = "",
                total_count = result.TotalRow,
                page = result.CurrentPage,
                total_page = result.TotalPage,
                limit = result.Count_Of_OnePage,
                data = from t in tdata
                       select new
                {
                    t.log_time,
                    mobile = ComFunc.nvl(t.mobile).Length > 3 ? $"{ ComFunc.nvl(t.mobile).Substring(0, 3)}***{ComFunc.nvl(t.mobile).Substring(ComFunc.nvl(t.mobile).Length - 2, 2)}" : "",
                    name = $"{(ComFunc.nvl(t.name).Length > 0 ? ComFunc.nvl(t.name).Substring(0, 1) : "")}***",
                    t.is_deal,
                    t.is_register,
                    t.is_perfection,
                    t.deal_amount
                }
            });
        }
        public object QueryList(string id)
        {
            SetCacheEnable(false);
            var up = DB.NewDBUnitParameter();
            var s  = from t in DB.LamdaTable(up, "EXTEND_SINGLETABLE_OP", "a")
                     where (t.s_uid == id || t.S_Name == id)
                     select t;
            var list = s.GetQueryList(up);

            if (list.Count <= 0)
            {
                return(new
                {
                    code = "failed",
                    msg = "设定资料不存在"
                });
            }
            dynamic info = list.First();

            var metainfo = (from t in DB.LamdaTable(up, "EXTEND_METADATA", "a")
                            where t.MetaUID == info.MetaUID && t.IsCreated == 1
                            select new
            {
                table_name = t.MetaName
            }).GetQueryList(up);

            if (metainfo.Count <= 0)
            {
                return(new
                {
                    code = "failed",
                    msg = "元数据表不存在,无法继续进行操作"
                });
            }
            var table_name = ComFunc.nvl(metainfo.First().GetValue("table_name"));
            //组织查询表达式
            FrameDLRObject express = FrameDLRObject.CreateInstance($@"{{
$acttype : 'QueryByPage',
$orderby : 'sort_no',
$table:'{table_name}',
sort_no:true
                }}", EFFC.Frame.Net.Base.Constants.FrameDLRFlags.SensitiveCase);

            #region 获取查询条件信息
            var conditionlist = (from t in DB.LamdaTable(up, "EXTEND_SINGLETABLE_OP_CONDITIONS", "a")
                                 join t2 in DB.LamdaTable(up, "EXTEND_METADATA_COLUMNS", "b").LeftJoin() on t.S_ColumnName equals t2.MetaColumnName
                                 where t.S_UID == info.S_UID && t2.MetaUID == info.MetaUID
                                 select new
            {
                op = t.S_ConditionOP,
                column_name = t.S_ColumnName,
                parameter_name = t.S_Parameter,
                data_type = t2.MetaDataType
            }).GetQueryList(up);
            FrameDLRObject where_express = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase);
            foreach (dynamic citem in conditionlist)
            {
                if (ComFunc.nvl(QueryString[citem.parameter_name]) == "")
                {
                    continue;
                }
                var            value = ConvertConditionValue(citem.data_type, ComFunc.nvl(QueryString[citem.parameter_name]));
                FrameDLRObject exp   = where_express.GetValue(citem.column_name);
                if (exp == null)
                {
                    exp = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase);
                }
                switch (citem.op)
                {
                case "like":
                    exp.SetValue("$like", value);
                    where_express.SetValue(citem.column_name, exp);
                    break;

                case "=":
                    where_express.SetValue(citem.column_name, value);
                    break;

                case ">":
                    exp.SetValue("$gt", value);
                    where_express.SetValue(citem.column_name, exp);
                    break;

                case ">=":
                    exp.SetValue("$gte", value);
                    where_express.SetValue(citem.column_name, exp);
                    break;

                case "<":
                    exp.SetValue("$lt", value);
                    where_express.SetValue(citem.column_name, exp);
                    break;

                case "<=":
                    exp.SetValue("$lte", value);
                    where_express.SetValue(citem.column_name, exp);
                    break;
                }
            }
            if (where_express.Items.Count > 0)
            {
                express.SetValue("$where", where_express);
            }
            #endregion
            #region 组织select栏位
            var columns = (from t in DB.LamdaTable(up, "EXTEND_SINGLETABLE_OP_COLUMNS", "a")
                           where t.S_UID == info.S_UID
                           select new
            {
                column_name = t.S_ColumnName
            }).GetQueryList(up);
            foreach (dynamic item in columns)
            {
                express.SetValue(item.column_name, true);
            }
            #endregion
            var result = DB.Excute(up, express, true);

            return(new
            {
                code = "success",
                msg = "",
                total_count = result.TotalRow,
                page = result.CurrentPage,
                total_page = result.TotalPage,
                limit = result.Count_Of_OnePage,
                data = result.QueryData <FrameDLRObject>().Select((d) =>
                {
                    FrameDLRObject dobj = (FrameDLRObject)d;
                    dobj.Remove("RowNumber");
                    //时间类型需要转string
                    foreach (var item in dobj.Items)
                    {
                        if (item.Value is DateTime)
                        {
                            dobj.SetValue(item.Key, DateTimeStd.IsDateTimeThen(item.Value));
                        }
                    }
                    return dobj;
                })
            });
        }