public async Task <TOutput> ExecuteAsync(IQuery <TOutput> query) { string payload = formatters.Query.Serialize(query); Type type = query.GetType(); log.Debug($"Request Type: '{type.AssemblyQualifiedName}'."); log.Debug($"Request Payload: '{payload}'."); Response response = await api.QueryAsync(type, payload); log.Debug($"Response Type: '{response.Type}'"); log.Debug($"Response Payload: '{response.Payload}'"); if (!string.IsNullOrEmpty(response.Payload)) { if (response.ResponseType == ResponseType.Plain) { TOutput output = (TOutput)Converts.To(typeof(TOutput), response.Payload); log.Debug($"Output success (plain): '{output != null}'."); return(output); } else { TOutput output = formatters.Query.Deserialize <TOutput>(response.Payload); log.Debug($"Output success (composite): '{output != null}'."); return(output); } } log.Debug("Fallback to default value."); return(Activator.CreateInstance <TOutput>()); }
private void DeleteMenu() { if (lisMenuOrder.SelectedItems.Count > 0) { ListViewItem delItem = lisMenuOrder.SelectedItems[0]; long sales_order_detail_id = Converts.ParseLong(delItem.Name); OrderDTO updateItem = this.OrderHeads.OrderList.Where(a => a.sales_order_detail_id == sales_order_detail_id).FirstOrDefault(); updateItem.order_amount = updateItem.order_amount - 1; if (updateItem.order_amount <= 0) { if (updateItem != null && updateItem.OrderState == ObjectState.Add) { this.OrderHeads.OrderList.Remove(updateItem); } else if (updateItem != null && updateItem.OrderState == ObjectState.Edit) { updateItem.OrderState = ObjectState.Delete; } fPnlMenuItem.Controls.Clear(); } else { updateItem.Selected = true; } this.BindListOrder(); } }
public RequestResponse Insert(string password, string path) { RequestResponse r = new RequestResponse(); Shop s = Converts.ToShop(this, password); //generalDB.Shops.Add(s); //MessageBox.Show("befor you have "+generalDB.MyDb.Shops.Count()); s = resetCode(s); generalDB.MyDb.Shops.Add(s); //TODO: להעביד אותו חזרה try { generalDB.MyDb.SaveChanges(); } catch (Exception e) { MessageBox.Show(e.InnerException.Message); } //MessageBox.Show("after you have "+generalDB.MyDb.Shops.Count()); s = generalDB.MyDb.Shops.ToList().Last(); dtoShop dtos = Converts.ToDtoShop(s); if (dtos.Connections != null && dtos.Connections.Count > 0) { WriteDistanceMatrix(s, path); } dtos.Connections = new List <dtoConnection>(); r.Data = dtos; return(r); }
public void StringToCollection() { Converts.Repository .AddStringToCollection <int>(Int32.TryParse); List <int> values1; Assert.AreEqual(true, Converts.Try("1,2,3", out values1)); Assert.AreEqual(true, Converts.Try("1, 2, 3", out values1)); IList <int> values2; Assert.AreEqual(true, Converts.Try("1,2,3", out values2)); Assert.AreEqual(true, Converts.Try("1, 2, 3", out values2)); ICollection <int> values3; Assert.AreEqual(true, Converts.Try("1,2,3", out values3)); Assert.AreEqual(true, Converts.Try("1, 2, 3", out values3)); IEnumerable <int> values4; Assert.AreEqual(true, Converts.Try("1,2,3", out values4)); Assert.AreEqual(true, Converts.Try("1, 2, 3", out values4)); }
public List <int> sortStands(I2Points g) { dtoStand stand; List <int> arr = new List <int> { Capacity = ExtraStand.Count() }; Point midOfG = UtilitiesFunctions.MidPoint(g.P1, g.P2); Point closerer; if (UtilitiesFunctions.CalculteDist(midOfG, P1) < UtilitiesFunctions.CalculteDist(midOfG, P2)) { closerer = P1; } else { closerer = P2; } for (int i = 0; i < ExtraStand.Count(); i++) { /* מחשב מרחק לכל סטנד*/ calculateDistances(closerer); ExtraStand.Keys.ToList().Sort(); stand = Converts.ToDtoStand(ExtraStand.Keys.Where(x => !arr.Contains(x.Code)).First()); arr.Add(stand.Code); closerer = UtilitiesFunctions.MidPoint(stand.P1, stand.P2); } return(arr); }
public static List <dtoStand> GetStands(int codeShop) { GeneralDB generalDB = new GeneralDB(); //generalDB.MyDb.Shops.First().Stands.First().Shelves.First().ProductShelves.Add(); return(Converts.ToDtoStands(generalDB.MyDb.Stands.Where(s => s.CodeShop == codeShop).ToList())); }
private void advTree1_NodeClick(object sender, DevComponents.AdvTree.TreeNodeMouseEventArgs e) { List <OrderDetails> listOrderDetails = objOrderDetails.SelectAll(); if (e.Node.Name.Contains("Produt_")) { this.listViewEx1.Items.Clear(); int ProductId = int.Parse(e.Node.Name.Split('_')[1]); int STT = 0; float TongTien = 0; for (int i = 0; i < listOrderDetails.Count; i++) { if (listOrderDetails[i].ProductID == ProductId) { STT++; ListViewItem item = new ListViewItem(STT.ToString()); item.SubItems.Add(listOrderDetails[i].OrderID.ToString()); item.SubItems.Add(listOrderDetails[i].Quantity.ToString()); item.SubItems.Add(Converts.ChuyenDoiTienTeVietNam(listOrderDetails[i].UnitPrice)); item.SubItems.Add(Converts.ChuyenDoiTienTeVietNam(listOrderDetails[i].SubTotal)); this.listViewEx1.Items.Add(item); TongTien += listOrderDetails[i].SubTotal; } } this.lblThongKE.Text = "Tổng số lượng bán ra : " + STT + " , giúp thu vào : " + Converts.ChuyenDoiTienTeVietNam(TongTien); } }
//public static int GetNoticeListForEditPageCount(SystemRollEnum roll, string organizationID, int PageSize) //{ // var noticeCount=GetNoticeListForEditCount( roll, organizationID); // var pageCount = noticeCount / PageSize; // if (noticeCount % PageSize != 0) // { // pageCount++; // } // return pageCount; //} public static int GetNoticeListForEditCount(SystemRollEnum roll, string organizationID) { using (var utility = DbUtility.GetInstance()) { var sql = new StringBuilder(); sql.Append(@" SELECT Count(`t_notice`.`NoticeID`) as NoticeCount FROM `t_notice` where "); if (roll == SystemRollEnum.SysAdmin) { sql.Append(@" (`t_notice`.`OrganizationID` is null or `t_notice`.`OrganizationID`=@OrganizationID)"); } else { sql.Append(@" `t_notice`.`OrganizationID`=@OrganizationID"); } sql.Append(@";"); utility.AddParameter("OrganizationID", organizationID); var list = utility.ExecuteReader(sql.ToString()); foreach (var dic in list) { var noticeCount = Converts.ToTryInt(dic["NoticeCount"], 0); return(noticeCount); } } return(0); }
private void LoadData() { EnableMode(); SOMenu entity = new SOMenu(); if (modeHead == ObjectState.Edit && !string.IsNullOrEmpty(keyCode)) { //---Header entity.menu_id = Converts.ParseLong(keyCode); entity = ServiceProvider.MenuService.FindByKeys(entity, true); txtMenuCode.Text = entity.menu_code; txtMenuName.Text = entity.menu_name; txtMenuDescription.Text = entity.menu_description; chkActive.Checked = entity.active; //---Detail modeDetail = ObjectState.Add; InitialGridDetail(); LoadDataDetail(0); } else { txtMenuCode.Text = string.Empty; txtMenuName.Text = string.Empty; txtMenuDescription.Text = string.Empty; chkActive.Checked = true; } }
private TranHead GetHeadData() { TranHead entity = new TranHead(); if (base.FormMode == ObjectState.Edit) { entity.tran_head_id = base.FormKeyCode.ToLong(); entity = ServiceProvider.TranHeadService.FindByKeys(entity, false); } //entity.or = txtOrderNo.Text; entity.transaction_date = DateTime.Now; entity.document_type_id = this._documentTypeID; entity.reason_id = Converts.ParseLong(ddlReason.SelectedValue.ToString()); entity.warehouse_id = ddlWarehouse.SelectedValue.ToLong(); entity.remark = txtRemark.Text; if (base.FormMode == ObjectState.Add) { entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.transaction_status = TransactionStatus.IN.NormalCode; } else if (base.FormMode == ObjectState.Edit) { entity.transaction_status = TransactionStatus.IN.FinalCode; } entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; return(entity); }
private MenuMapping GetDataDetail() { MenuMapping entity = new MenuMapping(); entity.menu_mapping_id = keyCodeDetail; entity.menu_id = Converts.ParseLong(keyCode); if (modeDetail == ObjectState.Add) { entity.bill_of_material_head_id = Converts.ParseLongNullable(ddlBomHead.SelectedValue.ToString()); entity.quantity = Converts.ParseDecimalNullable(txtQuantity.Text); entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } else { entity = ServiceProvider.MenuMappingService.FindByKeys(entity, false); if (entity != null) { entity.bill_of_material_head_id = Converts.ParseLongNullable(ddlBomHead.SelectedValue.ToString()); entity.quantity = Converts.ParseDecimalNullable(txtQuantity.Text); entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } } return(entity); }
protected override bool TryConvert(IKey source, out JObject target) { StringKey stringSource = source as StringKey; if (stringSource != null) { JToken token; if (Converts.Try <StringKey, JToken>(stringSource, out token)) { target = token as JObject; return(target != null); } } GuidKey guidSource = source as GuidKey; if (guidSource != null) { JToken token; if (Converts.Try <GuidKey, JToken>(guidSource, out token)) { target = token as JObject; return(target != null); } } target = null; return(false); }
private BillOfMaterialDetail GetDataDetail() { BillOfMaterialDetail entity = new BillOfMaterialDetail(); entity.bill_of_material_detail_id = keyCodeDetail; entity.bill_of_material_head_id = Converts.ParseLong(keyCode); if (modeDetail == ObjectState.Add) { entity.material_id = Converts.ParseLongNullable(ddlMaterial.SelectedValue.ToString()); entity.bill_of_material_head_id_sub = Converts.ParseLongNullable(ddlBOMDetail.SelectedValue.ToString()); entity.amount = Converts.ParseDecimalNullable(txtAmount.Text); entity.IsCheckedMaterial = rdbMaterial.Checked; entity.lost_factor = 0; entity.created_by = "SYSTEM"; entity.created_date = DateTime.Now; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } else { entity = ServiceProvider.BillOfMaterialDetailService.FindByKeys(entity, false); if (entity != null) { entity.material_id = Converts.ParseLongNullable(ddlMaterial.SelectedValue.ToString()); entity.bill_of_material_head_id_sub = Converts.ParseLongNullable(ddlBOMDetail.SelectedValue.ToString()); entity.amount = Converts.ParseDecimalNullable(txtAmount.Text); entity.IsCheckedMaterial = rdbMaterial.Checked; entity.updated_by = "SYSTEM"; entity.updated_date = DateTime.Now; } } return(entity); }
/// <summary> /// Return a new array of given shape and type, filled with ones. /// </summary> /// <param name="shape">Shape of the new array.</param> /// <param name="typeCode">The desired data-type for the array, e.g., <see cref="uint8"/>. Default is <see cref="float64"/> / <see cref="double"/>.</param> /// <remarks>https://docs.scipy.org/doc/numpy/reference/generated/numpy.ones.html</remarks> public static NDArray ones(Shape shape, NPTypeCode typeCode) { object one = null; switch (typeCode) { case NPTypeCode.Complex: one = new Complex(1d, 0d); break; case NPTypeCode.NDArray: one = NDArray.Scalar(1, np.int32); break; case NPTypeCode.String: one = "1"; break; case NPTypeCode.Char: one = '1'; break; default: one = Converts.ChangeType((byte)1, typeCode); break; } return(new NDArray(ArraySlice.Allocate(typeCode, shape.size, one), shape)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var result = Visibility.Collapsed; if (parameter != null) { var paramsConv = parameter.ToString(); var paramsList = paramsConv.Split('|'); if (BooleanResultConverter.CheckedValue(value, paramsList[0])) { result = Visibility.Visible; } else if (paramsList.Count() >= 2 && BooleanResultConverter.CheckedValue(value, paramsList[1])) { result = Visibility.Hidden; } else if (paramsList.Count() >= 3) { if (!BooleanResultConverter.CheckedValue(value, paramsList[2])) { result = Visibility.Visible; } } } else if (Converts.To <object>(value) != null) { result = Visibility.Visible; } return(result); }
private async Task BindHotKeyAsync() { runHotKey = new DefaultRunHotKeyService(this, this); KeyViewModel runKey; if (Converts.Try(settings.RunKey, out runKey) && runKey != null) { try { runHotKey.Bind(runKey.Key, runKey.Modifier); } catch (Win32Exception) { MessageBox.Show($"The global hotkey '{settings.RunKey}' is already in use. Configure another one in the settings.", "SolutionRunner"); runHotKey.UnBind(); settings.RunKey = null; await settingsService.SaveAsync(settings); } } if (!runHotKey.IsSet) { startup.IsHidden = false; } }
private bool TryConvertFromJson(Type targetType, JValue jValue, out object targetValue) { bool isNullable = false; if (targetType.IsNullableType()) { isNullable = true; targetType = targetType.GetGenericArguments()[0]; } if (jValue.Value == null) { targetValue = null; return(isNullable); } if (targetType.GetTypeInfo().IsEnum) { if (type == JsonEnumConverterType.UseInderlayingValue) { int value = jValue.Value <int>(); targetValue = Enum.ToObject(targetType, value); return(true); } else if (type == JsonEnumConverterType.UseTextName) { string value = jValue.Value <string>(); return(Converts.Try(typeof(string), targetType, value, out targetValue)); } } targetValue = null; return(false); }
/// <summary> /// 发送报文至所有客户端 /// </summary> /// <param name="datagram">报文</param> public void SendAll(byte[] datagram) { if (!IsRunning) { LogHelper.WriteLog(DateTime.Now.ToString("HH-mm-ss:") + "This TCP server has not been started."); return; } //throw new InvalidProgramException("This TCP server has not been started."); for (int i = 0; i < this.clients.Count; i++) { try { if (this.clients[i].TcpClient != null && this.clients[i].TcpClient.Connected) { Send(this.clients[i].TcpClient, datagram); Thread.Sleep(150); } } catch (Exception e) { //LogHelper.WriteLog("异常的客户端异常数据:" + e.Message); LogHelper.WriteLog("异常的客户端:" + Converts.GetTPandMac(datagram) + ":" + e.Message); continue; } } }
private bool TrySetField <T>(string title, string value, string targetTitle, Action <T> setter) { if (targetTitle.Equals(title, StringComparison.InvariantCultureIgnoreCase)) { value = value.Trim(); void StripSuffix(ref string val, string suffix) { if (val.EndsWith(suffix)) { val = val.Substring(0, value.Length - suffix.Length); } } StripSuffix(ref value, " cm"); StripSuffix(ref value, " Kč"); StripSuffix(ref value, "%"); if (Converts.Try(value, out T targetValue)) { setter(targetValue); return(true); } } return(false); }
public static List <ExtraAlias> GetDepartment() { GeneralDB generalDB = new GeneralDB(); List <Alias> aliases = generalDB.MyDb.Aliases.Where(x => x.Parent == null).ToList(); List <ExtraAlias> departments = Converts.ToExtraAliases(aliases); departments.Remove(departments.Where(x => x.TextAlias == "placeAlias").FirstOrDefault()); List <dtoProduct> dtoProducts = Converts.ToDtoProducts(generalDB.MyDb.Products.ToList()); var q = dtoProducts.Where(x => x.Alias.TextAlias == "cash" || x.Alias.TextAlias == "wall" || x.Alias.TextAlias == "סטנד").ToList(); q.ForEach(x => dtoProducts.Remove(x)); ExtraAlias e; foreach (var item in dtoProducts) { if (item.Alias.Parent != null && item.Alias.Parent != 0) { e = departments.Where(x => x.Code == item.Alias.Parent).First(); e.products.Add(item); } } //departments = departments.Where(x => x.products.Count>0).ToList(); return(departments); }
public long?GetIDByCode(string CodeValue) { PropertyInfo PropertyInfoDataCode = typeof(TEntity).GetTaggedPropertyInfos <EntityScalarPropertyAttribute>("DataCode", true, true).FirstOrDefault(); PropertyInfo PropertyInfoIdentityKey = typeof(TEntity).GetTaggedPropertyInfos <EntityScalarPropertyAttribute>("IdentityKey", true, true).FirstOrDefault(); if (PropertyInfoDataCode == null) { PropertyInfoDataCode = typeof(TEntity).GetProperties().Where(w => w.Name.Contains("code")).FirstOrDefault(); } if (PropertyInfoIdentityKey == null) { PropertyInfoIdentityKey = typeof(TEntity).GetProperties().Where(w => w.Name.Contains("id")).FirstOrDefault(); } long?ID = null; StringBuilder Query = new StringBuilder(); Query.AppendFormat("SELECT {0} FROM {1} WHERE {2} = @Code", PropertyInfoIdentityKey.Name, base.EntityTableName, PropertyInfoDataCode.Name); DbParameter param = base.CreateParameter("Code", CodeValue); ID = Converts.ParseLongNullable(base.ExecuteScalar(Query.ToString(), param).ToStringNullable()); return(ID); }
public static List <dtoShop> GetDtoShops() { GeneralDB generalDB = new GeneralDB(); List <Shop> l = generalDB.MyDb.Shops.ToList(); return(Converts.ToDtoShops(l)); }
//TODO: להחליף קוד #region function level2 מקבץ את הסטנדים לפי איזור public static Dictionary <KeyArea, Area> Level2GroupStandsByArea(Dictionary <Stand, List <Product> > ExtraStand, List <GetawayProcI_Result> getaways, Shop shop) { //level 2: מקבץ את הסטנדים שבאותו אזור -כלומר יש להם אותם השערים //key: המפתח הוא השערים של האזור וגם השערים הכי קרובים של האזור //value: הערך הוא איזור המכיל רשימת סטנדים, נקודת התחלת אזור, נקודת סוף אזור Dictionary <KeyArea, Area> productArea = new Dictionary <KeyArea, Area>(); List <Connection> connections; Stand stand; foreach (var productStand in ExtraStand) { KeyArea key = new KeyArea(); stand = productStand.Key; connections = stand.GetConnections(shop); key.Nearestes = connections.Where(x => x.Nearest == true).Select(x => x.Getaway).ToList(); key.Getaways = Converts.ToGetawayProcResult(connections.Select(x => x.Getaway).ToList(), dtoShop.GetawayProcI_Results(CodeShop)); KeyArea anotherKey = productArea.Keys.FirstOrDefault(x => x.Equals(key)); if (anotherKey == null) { Area ee = new Area(); ee.ExtraStand[productStand.Key] = productStand.Value; productArea.Add(key, ee); } else { productArea[anotherKey].ExtraStand.Add(productStand.Key, productStand.Value); } } return(productArea); }
public void Context() { Converts.Repository .Add <string, int>(Int32.TryParse) .Add(new StringToListConverter <int>()); List <int> list; Assert.AreEqual(true, Converts.Try("2,34,1", out list)); AssertList(list); object rawList; Assert.AreEqual(true, Converts.Try(typeof(string), typeof(List <int>), "2,34,1", out rawList)); Assert.IsInstanceOfType(rawList, typeof(List <int>)); AssertList((List <int>)rawList); Func <string, List <int> > converter = Converts.Repository.GetConverter <string, List <int> >(); list = converter("2,34,1"); AssertList(list); OutFunc <string, List <int>, bool> tryConverter = Converts.Repository.GetTryConverter <string, List <int> >(); Assert.AreEqual(true, tryConverter("2,34,1", out list)); AssertList(list); }
private static void OpenArea(Goal gw, int num, List <KeyValuePair <KeyArea, Area> > productAreaList, List <Goal> way, List <GetawayProcI_Result> getawayProcI_Results) { GetawayProcI_Result g = getawayProcI_Results.Where(x => x.Code == gw.num).FirstOrDefault(); if (g == null) { g = new GetawayProcI_Result(); g.X1 = way.Last().midPoint.X; g.X2 = way.Last().midPoint.X; g.Y1 = way.Last().midPoint.Y; g.Y2 = way.Last().midPoint.Y; } List <ProductShop> products = new List <ProductShop>(); //למיין את הסטנדים לפי המרחק מנקודת גישה Area area = productAreaList[num].Value; if (area != null) { List <int> orederStand = area.sortStands(Converts.ToDtoGetawayI(g)); foreach (var item in orederStand) { var curExtraStand = area.ExtraStand.Where(x => x.Key.Code == item).First(); Point p = UtilitiesFunctions.MidPoint(new Point(Convert.ToInt32(curExtraStand.Key.X1.ToString()), Convert.ToInt32(curExtraStand.Key.Y1.ToString())), new Point(Convert.ToInt32(curExtraStand.Key.X2.ToString()), Convert.ToInt32(curExtraStand.Key.Y2.ToString()))); way.Add(new Goal('s', item, Converts.ToDtoProducts(curExtraStand.Value), p)); } } }
private void _setContractValue(string propertyName, Type type, object value) { object contractValue = null; if (type == typeof(Int16) || type == typeof(Int32) || type == typeof(Int64)) { contractValue = Converts.ToTryInt(value); } else if (type == typeof(String)) { contractValue = Converts.ToTryString(value); } else if (type == typeof(Boolean)) { contractValue = Converts.ToTryBool(value); } else if (type == typeof(Decimal) || type == typeof(Decimal?)) { contractValue = Converts.ToTryDecimal(value); } else if (type == typeof(Double) || type == typeof(Double?)) { contractValue = Converts.ToTryDouble(value, 0); } else if (type == typeof(DateTime) || type == typeof(DateTime?)) { contractValue = Converts.ToTryDateTimeNullable(value, null); } else { _throwAutoPropertyExceptoin(propertyName); } GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, this, new[] { contractValue }); }
private void DoClient(TcpClient socket) { while (socket.Connected) { var Stream = socket.GetStream(); var sr = new StreamReader(Stream); var sw = new StreamWriter(Stream); sw.AutoFlush = true; string[] Strings; Strings = sr.ReadLine().Split(' '); string serverText = Strings[0].ToUpper(); if (serverText == "TOGRAMS") { double weight = double.Parse(Strings[1]); double result = Converts.ConvertToGrams(weight); sw.WriteLine(result); } else if (serverText == "TOOUNCES") { double weight = double.Parse(Strings[1]); double result = Converts.ConvertToOunces(weight); sw.WriteLine(result); } } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { if (Converts.Try(Value, out string stringValue)) { builder.AddContent(0, stringValue); } }
public static List <dtoAlias> GetAliases() { GeneralDB db = new GeneralDB(); List <dtoAlias> dtoAliases = Converts.ToDtoAliases(db.MyDb.Aliases.ToList()); return(dtoAliases); }
public JsonResult GetNotificationsOnUser() { var userLogged = _userService.GetUserByUserName(this.User.Identity.Name); var resoultNotifications = _infoNotificationOnUser.GetDataForNotofiactionsOnUser(userLogged.Id).Reverse(); var countNotifications = resoultNotifications.Where(x => x.IsSaw == false).Count(); var listNotification = new List <ListNotification>(); foreach (var notification in resoultNotifications) { var pictureOfProfile = _postService.GetPictureProfileFromPost(_userService.GetUserByUserName(notification.Username)); listNotification.Add(new ListNotification { Username = notification.Username, Description = notification.Description, ImgUser = Converts.ConvertByteArrToStringForImg(pictureOfProfile), NotificationId = notification.NotificationId, IsSaw = notification.IsSaw, PostId = notification.PostId }); } var resoultModel = new HomeNotificationModel() { CountNoSeenNotification = countNotifications, Notification = listNotification }; return(Json(resoultModel, JsonRequestBehavior.AllowGet)); }
public static string ConvertBase64(string code, Converts conv) { if (conv == Converts.Convert) { var bytes = Encoding.Default.GetBytes(code); return Convert.ToBase64String(bytes); } else { //解码: var outputb = Convert.FromBase64String(code); return Encoding.Default.GetString(outputb); } }