public ActionResult AutoProduct(string productName)
 {
     ProductProvider provider = new ProductProvider();
     List<ProductEntity> list = provider.GetListByCache();
     if (!list.IsNullOrEmpty() && !productName.IsEmpty())
     {
         list = list.Where(a => a.ProductName.Contains(productName) || a.BarCode.Contains(productName) || a.SnNum.Contains(productName)).ToList();
     }
     list = list.IsNull() ? new List<ProductEntity>() : list;
     StringBuilder sb = new StringBuilder();
     JsonObject jsonObject = null;
     foreach (ProductEntity t in list)
     {
         jsonObject = new JsonObject();
         jsonObject.AddProperty("BarCode", t.BarCode);
         jsonObject.AddProperty("ProductName", t.ProductName);
         jsonObject.AddProperty("SnNum", t.SnNum);
         jsonObject.AddProperty("CateNum", t.CateNum);
         jsonObject.AddProperty("CateName", t.CateName);
         jsonObject.AddProperty("InPrice", t.InPrice);
         jsonObject.AddProperty("Unit", t.UnitNum);
         jsonObject.AddProperty("UnitName", t.UnitName);
         jsonObject.AddProperty("Size", t.Size);
         jsonObject.AddProperty("Num", t.Num);
         sb.Append(jsonObject.ToString() + "\n");
     }
     if (sb.Length == 0)
     {
         sb.Append("\n");
     }
     return Content(sb.ToString());
 }
Example #2
0
        public ActionResult AutoProduct(string productName)
        {
            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();

            if (!list.IsNullOrEmpty() && !productName.IsEmpty())
            {
                list = list.Where(a => a.ProductName.Contains(productName) || a.BarCode.Contains(productName) || a.SnNum.Contains(productName)).ToList();
            }
            list = list.IsNull() ? new List <ProductEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (ProductEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("BarCode", t.BarCode);
                jsonObject.AddProperty("ProductName", t.ProductName);
                jsonObject.AddProperty("SnNum", t.SnNum);
                jsonObject.AddProperty("CateNum", t.CateNum);
                jsonObject.AddProperty("CateName", t.CateName);
                jsonObject.AddProperty("InPrice", t.InPrice);
                jsonObject.AddProperty("Unit", t.UnitNum);
                jsonObject.AddProperty("UnitName", t.UnitName);
                jsonObject.AddProperty("Size", t.Size);
                jsonObject.AddProperty("Num", t.Num);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
        protected override void SetJsonProperties(JsonObject json)
        {
            if (json == null) throw new ArgumentNullException("json");

            json.AddProperty("v", new GoogleValue(DataType, Value));
            if (Formatted != null) json.AddProperty("f", Formatted);
        }
 public ActionResult Auto(string supName)
 {
     SupplierProvider provider = new SupplierProvider();
     List<SupplierEntity> list = provider.GetList();
     if (!list.IsNullOrEmpty() && !supName.IsEmpty())
     {
         list = list.Where(a => a.SupNum.Contains(supName) || a.SupName.Contains(supName)).ToList();
     }
     list = list.IsNull() ? new List<SupplierEntity>() : list;
     StringBuilder sb = new StringBuilder();
     JsonObject jsonObject = null;
     foreach (SupplierEntity t in list)
     {
         jsonObject = new JsonObject();
         jsonObject.AddProperty("SupNum", t.SupNum);
         jsonObject.AddProperty("SupName", t.SupName);
         jsonObject.AddProperty("ContactName", t.ContactName);
         jsonObject.AddProperty("Phone", t.Phone);
         sb.Append(jsonObject.ToString() + "\n");
     }
     if (sb.Length == 0)
     {
         sb.Append("\n");
     }
     return Content(sb.ToString());
 }
        public ActionResult Auto(string cusName)
        {
            CustomerProvider      provider = new CustomerProvider();
            List <CustomerEntity> list     = provider.GetList();

            if (!list.IsNullOrEmpty() && !cusName.IsEmpty())
            {
                list = list.Where(a => a.CusNum.Contains(cusName) || a.CusName.Contains(cusName)).ToList();
            }
            list = list.IsNull() ? new List <CustomerEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (CustomerEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("CusNum", t.CusNum);
                jsonObject.AddProperty("CusName", t.CusName);
                //jsonObject.AddProperty("Phone", t.Phone);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Example #6
0
        public ActionResult AutoOrder(string productName)
        {
            string   orderNum = WebUtil.GetFormValue <string>("orderNum", string.Empty);
            PageInfo page     = new PageInfo {
                PageIndex = 1, PageSize = 5
            };
            Bill <OrdersEntity, OrderDetailEntity> bill = new OrderBill();
            OrdersEntity entity = new OrdersEntity();

            if (orderNum != string.Empty)
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            entity.Where(a => a.AuditeStatus == (int)EAudite.Pass).And(a => a.Status != (int)EOrderStatus.AllDelivery);
            List <OrdersEntity> list = bill.GetList(entity, ref page);

            list = list.IsNull() ? new List <OrdersEntity>() : list;
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (OrdersEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("OrderNum", t.OrderNum);
                jsonObject.AddProperty("CusName", t.CusName);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Example #7
0
        /// <summary>
        /// 将枚举类型转化为JSON字符串
        /// </summary>
        /// <returns></returns>
        public static string GetJson(Type type)
        {
            List <ReadEnum> list     = EnumHelper.GetEnumList(type);
            JsonProperty    property = new JsonProperty();

            foreach (ReadEnum item in list)
            {
                JsonObject jsonItem = new JsonObject();
                jsonItem.AddProperty("Name", item.Name);
                jsonItem.AddProperty("Value", item.Value);
                jsonItem.AddProperty("Description", item.Description);
                property.Add(jsonItem);
            }
            return(property.ToString());
        }
        public Task <OfflinePack> DownloadMap(OfflinePackRegion region, Dictionary <string, string> packInfo)
        {
            var tcs          = new TaskCompletionSource <OfflinePack>();
            var latLngBounds = new LatLngBounds.Builder()
                               .Include(region.Bounds.NorthEast.ToLatLng())                          // Northeast
                               .Include(region.Bounds.SouthWest.ToLatLng())                          // Southwest
                               .Build();
            var definition = new OfflineTilePyramidRegionDefinition(
                region.StyleURL,
                latLngBounds,
                region.MinimumZoomLevel,
                region.MaximumZoomLevel,
                Android.App.Application.Context.Resources.DisplayMetrics.Density);

            byte[] metadata = null;
            if (packInfo != null)
            {
                //var binFormatter = new BinaryFormatter();
                //var mStream = new MemoryStream();
                //binFormatter.Serialize(mStream, packInfo);
                //metadata = mStream.ToArray();
                try
                {
                    var jsonObject = new JsonObject();

                    foreach (KeyValuePair <string, string> pair in packInfo)
                    {
                        jsonObject.AddProperty(pair.Key, pair.Value);
                    }
                    var json = new Java.Lang.String(jsonObject.ToString());
                    metadata = json.GetBytes(JSON_CHARSET);
                    System.Diagnostics.Debug.WriteLine("Encoding metadata succeeded: " + metadata.Length.ToString());
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Failed to encode metadata: " + ex.Message);
                }
            }

            offlineManager.CreateOfflineRegion(
                definition,
                metadata,
                new CreateOfflineRegionCallback(
                    (reg) =>
            {
                reg.SetDownloadState(OfflineRegion.StateActive);
                tcs.TrySetResult(reg.ToFormsPack());
            },
                    (msg) =>
            {
                System.Diagnostics.Debug.WriteLine("[ERROR] Couldn't create offline pack: " + msg);
                tcs.TrySetResult(null);
            }
                    )
                );

            return(tcs.Task);
        }
Example #9
0
        /// <summary>
        /// 获得枚举类型转化为json对象
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetJsonObject(Type type)
        {
            List <ReadEnum> list       = EnumHelper.GetEnumList(type);
            JsonObject      jsonObject = new JsonObject();

            foreach (ReadEnum item in list)
            {
                jsonObject.AddProperty(item.Name, item.Value);
            }
            return(jsonObject.ToString());
        }
Example #10
0
        public ActionResult AutoSinProduct(string ProductNum)
        {
            ProductProvider      provider = new ProductProvider();
            List <ProductEntity> list     = provider.GetListByCache();
            ProductEntity        entity   = null;

            if (!list.IsNullOrEmpty() && !ProductNum.IsEmpty())
            {
                entity = list.FirstOrDefault(a => a.SnNum == ProductNum);
            }
            entity = entity.IsNull() ? new ProductEntity() : entity;
            List <ProductEntity> listSource = new List <ProductEntity>();

            listSource.Add(entity);
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (ProductEntity t in listSource)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("BarCode", t.BarCode);
                jsonObject.AddProperty("ProductName", t.ProductName);
                jsonObject.AddProperty("SnNum", t.SnNum);
                jsonObject.AddProperty("CateNum", t.CateNum);
                jsonObject.AddProperty("CateName", t.CateName);
                jsonObject.AddProperty("InPrice", t.InPrice);
                jsonObject.AddProperty("Unit", t.UnitNum);
                jsonObject.AddProperty("UnitName", t.UnitName);
                jsonObject.AddProperty("Size", t.Size.Escape());
                jsonObject.AddProperty("Num", t.Num);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return(Content(sb.ToString()));
        }
Example #11
0
        public ActionResult Auto(string name)
        {
            var           dd         = DdUserHelp.GetUserList(name);
            StringBuilder sb         = new StringBuilder();
            JsonObject    jsonObject = null;

            foreach (var t in dd)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("Name", t.Name);
                jsonObject.AddProperty("Ddid", t.Ddid);
                jsonObject.AddProperty("DeptName", t.DeptName);
                jsonObject.AddProperty("NamePy", t.NamePY);
                sb.Append(jsonObject.ToString() + "\n");
            }

            if (sb.Length == 0)
            {
                sb.Append("\n");
            }

            return(Content(sb.ToString()));
        }
        protected override void SetJsonProperties(JsonObject json)
        {
            if (json == null) throw new ArgumentNullException("json");

            json.AddProperty("c", Cells.Select(c => c.ToJsonObject()));
        }
 protected override void SetJsonProperties(JsonObject json)
 {
     json.AddProperty("c", Cells.Select(c => c.ToJsonObject()));
 }
 protected override void SetJsonProperties(JsonObject json)
 {
     json.AddProperty("v", new GoogleValue(DataType, Value));
     if (Formatted != null) json.AddProperty("f", Formatted);
 }
 protected override void SetJsonProperties(JsonObject json)
 {
     json.AddProperty("cols", Columns.Select(c => c.ToJsonObject()).ToList());
     json.AddProperty("rows", Rows.Select(r => r.ToJsonObject()).ToList());
 }
        public ActionResult AutoOrder(string productName)
        {
            string orderNum = WebUtil.GetFormValue<string>("orderNum", string.Empty);
            PageInfo page = new PageInfo { PageIndex = 1, PageSize = 5 };
            Bill<OrdersEntity, OrderDetailEntity> bill = new OrderBill();
            OrdersEntity entity = new OrdersEntity();
            if (orderNum != string.Empty)
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            entity.Where(a => a.AuditeStatus == (int)EAudite.Pass).And(a => a.Status != (int)EOrderStatus.AllDelivery);
            List<OrdersEntity> list = bill.GetList(entity, ref page);

            list = list.IsNull() ? new List<OrdersEntity>() : list;
            StringBuilder sb = new StringBuilder();
            JsonObject jsonObject = null;
            foreach (OrdersEntity t in list)
            {
                jsonObject = new JsonObject();
                jsonObject.AddProperty("OrderNum", t.OrderNum);
                jsonObject.AddProperty("CusName", t.CusName);
                sb.Append(jsonObject.ToString() + "\n");
            }
            if (sb.Length == 0)
            {
                sb.Append("\n");
            }
            return Content(sb.ToString());
        }
Example #17
0
        private IEnumerable <TExcelType> ReadExcelSheetData <TExcelType>(WorkBook workBook, int sheetNum, ref JsonObjectList errorList) where TExcelType : ExcelData
        {
            if (workBook == null)
            {
                return(new List <TExcelType>());
            }
            if (sheetNum < 0)
            {
                return(new List <TExcelType>());
            }

            var tempDataList = new List <TExcelType>();

            workBook.Sheet = sheetNum;

            var lastRow = workBook.LastRow;
            var lastCol = workBook.LastCol;


            var myObject = CreateGeneric(typeof(TExcelType)) as ExcelData;

            // get properties of the ExcelMemberData only once
            PropertyInfo[] pps = myObject.GetType().GetProperties();

            ExcelGenericAttribute xlAttr = ExcelGenericAttribute.GetAttribute(myObject.GetType());

            for (var i = 1; i <= lastRow; i++)
            {
                var mbrLine = CreateGeneric(typeof(TExcelType)) as ExcelData;
                mbrLine.ExcelLine = i + 1;


                if (xlAttr != null && xlAttr.AllowBlank && IsLineEmpty(workBook, i, pps.Length))
                {
                    mbrLine.BlankLineFound = true;
                    continue;
                }

                foreach (PropertyInfo p in pps)
                {
                    ExcelColumnAttribute xlColAttr = ExcelColumnAttribute.GetAttribute(p);
                    if (xlColAttr == null || xlColAttr.OutputOnly)
                    {
                        continue;
                    }

                    var xlValue = workBook.getText(i, xlColAttr.Column);

                    try
                    {
                        ExcelColumnAttribute.Validate(p, xlValue, mbrLine);

                        mbrLine.CustomPropertyValidation(p, xlValue, mbrLine);
                    }catch (Exception er)
                    {
                        var importStats = BaseImportWorker.GetImportStatus("GroupProperty", BaseUserContext.Instance.UserName);
                        importStats.Status        = new { Msg = "Errors while validating" };
                        importStats.ImportProgres = 100;

                        mbrLine.IsValid      = false;
                        mbrLine.ErrorMessage = p.Name + ":" + er.Message;
                    }

                    if (mbrLine.CurrentPropertyIsBlank && xlColAttr.IgnoreLineIfBlank)
                    {
                        mbrLine.IsValid    = false;
                        mbrLine.WasIgnored = true;
                        continue;
                    }

                    try
                    {
                        if (mbrLine.IsValid && !mbrLine.CurrentPropertyIsBlank)
                        {
                            p.SetValue(mbrLine, mbrLine.ValidValue, null);
                        }
                    }
                    catch (Exception er)
                    {
                        if (mbrLine.IsValid) // to keep the first error
                        {
                            mbrLine.IsValid      = false;
                            mbrLine.ErrorMessage = er.Message;
                        }
                    }

                    if (!mbrLine.IsValid)
                    {
                        break;
                    }
                }

                if (!mbrLine.IsValid && !mbrLine.WasIgnored)
                {
                    var jso = new JsonObject();
                    jso.AddProperty("line", i + 1);
                    jso.AddProperty("sheet", sheetNum);
                    jso.AddProperty("error", mbrLine.ErrorMessage);
                    errorList.Add(jso);
                }

                tempDataList.Add((TExcelType)mbrLine);
            }

            return(tempDataList);
        }
        protected override void SetJsonProperties(JsonObject json)
        {
            if (json == null) throw new ArgumentNullException("json");

            json.AddProperty("cols", Columns.Select(c => c.ToJsonObject()).ToList());
            json.AddProperty("rows", Rows.Select(r => r.ToJsonObject()).ToList());
        }
 public ActionResult AutoSinProduct(string ProductNum)
 {
     ProductProvider provider = new ProductProvider();
     List<ProductEntity> list = provider.GetListByCache();
     ProductEntity entity = null;
     if (!list.IsNullOrEmpty() && !ProductNum.IsEmpty())
     {
         entity = list.FirstOrDefault(a => a.SnNum == ProductNum);
     }
     entity = entity.IsNull() ? new ProductEntity() : entity;
     List<ProductEntity> listSource = new List<ProductEntity>();
     listSource.Add(entity);
     StringBuilder sb = new StringBuilder();
     JsonObject jsonObject = null;
     foreach (ProductEntity t in listSource)
     {
         jsonObject = new JsonObject();
         jsonObject.AddProperty("BarCode", t.BarCode);
         jsonObject.AddProperty("ProductName", t.ProductName);
         jsonObject.AddProperty("SnNum", t.SnNum);
         jsonObject.AddProperty("CateNum", t.CateNum);
         jsonObject.AddProperty("CateName", t.CateName);
         jsonObject.AddProperty("InPrice", t.InPrice);
         jsonObject.AddProperty("Unit", t.UnitNum);
         jsonObject.AddProperty("UnitName", t.UnitName);
         jsonObject.AddProperty("Size", t.Size.Escape());
         jsonObject.AddProperty("Num", t.Num);
         sb.Append(jsonObject.ToString() + "\n");
     }
     if (sb.Length == 0)
     {
         sb.Append("\n");
     }
     return Content(sb.ToString());
 }
        protected override void SetJsonProperties(JsonObject json)
        {
            if (json == null) throw new ArgumentNullException("json");

            string type;

            switch(DataType)
            {
                case ColumnDataType.Boolean:
                    type = "boolean";
                    break;
                case ColumnDataType.Date:
                    type = "date";
                    break;
                case ColumnDataType.DateTime:
                    type = "datetime";
                    break;
                case ColumnDataType.Number:
                    type = "number";
                    break;
                case ColumnDataType.String:
                    type = "string";
                    break;
                case ColumnDataType.TimeOfDay:
                    type = "timeofday";
                    break;
                default:
                    throw new InvalidOperationException("DataType is not valid.");
            }

            json.AddProperty("type", type);
            if (!string.IsNullOrWhiteSpace(Id)) json.AddProperty("id", Id);
            if (!string.IsNullOrWhiteSpace(Label)) json.AddProperty("label", Label);
            if (!string.IsNullOrWhiteSpace(Pattern)) json.AddProperty("pattern", Pattern);
        }