public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json;utf-8"; #region 获取post过来的参数 string aText = TypeConvertHelper.ToString(context.Request["Text"]); string aPagerString = TypeConvertHelper.ToString(context.Request["Pager"]); ; Pager aPager = null; if (!string.IsNullOrWhiteSpace(aPagerString)) { aPager = JsonConvert.DeserializeObject <Pager>(aPagerString); //反序列化jason时,属性不区分大小写!不过建议类属性跟jason对象的属性大小写相一致 } #endregion #region 将数据以jason格式传递给客户端 //obj list to jason List <DataItem> aList = DataItem.GetList(9); string aJason = JsonConvert.SerializeObject(aList); context.Response.Write(aJason); #endregion ////jason to obj //string aJason = // "[{'Text':'Text_1','Value':'Value_1'},{'Text':'Text_2','Value':'Value_2'},{'Text':'Text_3','Value':'Value_3'},{'Text':'Text_4','Value':'Value_4'},{'Text':'Text_5','Value':'Value_5'},{'Text':'Text_6','Value':'Value_6'},{'Text':'Text_7','Value':'Value_7'},{'Text':'Text_8','Value':'Value_8'},{'Text':'Text_9','Value':'Value_9'}]"; //var aList = JsonConvert.DeserializeObject<List<Item>>(aJason); }
void SetupUserInterface() { CGRect viewRect = new CGRect(0, 0, View.Frame.Size.Width, View.Frame.Size.Height); mPdfViewCtrl = new pdftron.PDF.PDFViewCtrl(viewRect); mPdfViewCtrl.SetupThumbnails(false, true, true, 0, 500 * 1024 * 1024, 0.5); View.AddSubview(mPdfViewCtrl); mPdfViewCtrl.TranslatesAutoresizingMaskIntoConstraints = false; NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { mPdfViewCtrl.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor), mPdfViewCtrl.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor), mPdfViewCtrl.TopAnchor.ConstraintEqualTo(this.View.LayoutMarginsGuide.TopAnchor), mPdfViewCtrl.BottomAnchor.ConstraintEqualTo(this.View.BottomAnchor) }); var docPath = "sample.pdf"; mPdfDoc = new PDFDoc(docPath); mPdfViewCtrl.Doc = TypeConvertHelper.ConvPDFDocToNative(mPdfDoc); mPdfViewCtrl.PagePresentationMode = PagePresentationModes.e_single_page; mPdfViewCtrl.SetHighlightFields(true); mToolManager = new PTToolManager(mPdfViewCtrl); mPdfViewCtrl.ToolManager = mToolManager; mAnnotationToolbar = new PTAnnotationToolbar(mToolManager); View.AddSubview(mAnnotationToolbar); mAnnotationToolbar.TranslatesAutoresizingMaskIntoConstraints = false; NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { mAnnotationToolbar.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor), mAnnotationToolbar.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor), mAnnotationToolbar.TopAnchor.ConstraintEqualTo(this.View.LayoutMarginsGuide.TopAnchor) }); mThumbnailSliderViewController = new PTThumbnailSliderViewController(mPdfViewCtrl); mThumbnailSliderViewController.View.TranslatesAutoresizingMaskIntoConstraints = false; AddChildViewController(mThumbnailSliderViewController); View.AddSubview(mThumbnailSliderViewController.View); bool isIOS11 = UIDevice.CurrentDevice.CheckSystemVersion(11, 0); var bottomAnchor = this.View.BottomAnchor; if (isIOS11) { bottomAnchor = this.View.SafeAreaLayoutGuide.BottomAnchor; } NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { mThumbnailSliderViewController.View.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor), mThumbnailSliderViewController.View.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor), mThumbnailSliderViewController.View.BottomAnchor.ConstraintEqualTo(bottomAnchor) }); mThumbnailSliderViewController.DidMoveToParentViewController(this); }
public virtual Expression CreateConvertExpression( Context context, Expression source, Type destinationType, MappingType mappingType) { var convert = source; var sourceType = source.Type; if (sourceType != destinationType) { if (sourceType.IsNullable(out var nullableBaseType)) { convert = Expression.Convert(convert, nullableBaseType); //src == null ? default(TDestination) : {convert}(src) var compareNull = Expression.Equal(convert, Expression.Constant(null, sourceType)); convert = Expression.Condition(compareNull, Expression.Default(destinationType), convert); } else if (sourceType.IsPrimitiveOrDecimal()) { convert = Expression.Convert(convert, destinationType); } else if (sourceType.IsConvertible()) { MethodInfo convertMethodInfo; if (TypeConvertHelper.ConvertMethodNameMapping.TryGetValue(destinationType, out var methodName) && (convertMethodInfo = typeof(Convert).GetMethod(methodName, new[] { sourceType })) != null ) { //Convert.To{DestinationType}(source) convert = Expression.Call(convertMethodInfo, convert); } else { convertMethodInfo = typeof(Convert).GetMethod(nameof(Convert.ChangeType), new[] { typeof(object), typeof(Type) }); convert = Expression.Call(convertMethodInfo, Expression.Convert(source, typeof(object)), Expression.Constant(destinationType)); convert = Expression.Convert(convert, destinationType); } } else { throw TypeConvertHelper.ConvertException(sourceType, destinationType); } } return(convert); }
/// <summary> /// Initializes a new instance of the <see cref="AudioSourceSettingKeyValue"/> class /// with the model, setting information and if it was saved. /// </summary> /// <param name="audioSource">The associated <see cref="IInternalAudioSource"/>.</param> /// <param name="source">The setting model.</param> /// <param name="settingAttribute">The <see cref="AudioSourceSettingAttribute"/>.</param> public AudioSourceSettingKeyValue(IInternalAudioSource audioSource, AudioSourceSetting source, AudioSourceSettingAttribute settingAttribute) { _settingAttribute = settingAttribute; _audioSource = audioSource; _originalSource = source; MapSelf(_originalSource, _model); // Model value was deserialized from string maybe so change to correct type source.Value = TypeConvertHelper.ConvertToType(source.Value, SettingType); }
/// <summary> /// Initializes a new instance of the <see cref="AudioSourceSettingVM"/> class /// with the model, setting information and if it was saved, /// </summary> /// <param name="audioSource">The associated <see cref="IInternalAudioSource"/>.</param> /// <param name="model">The <see cref="AudioSource"/>.</param> /// <param name="settingAttribute">The <see cref="AudioSourceSettingAttribute"/>.</param> /// <param name="saved">If this setting was saved.</param> public AudioSourceSettingVM(IInternalAudioSource audioSource, AudioSourceSetting model, AudioSourceSettingAttribute settingAttribute, bool saved = true) : base(model) { _settingAttribute = settingAttribute; _audioSource = audioSource; // Model value was deserialized from string maybe so change to correct type model.Value = TypeConvertHelper.ConvertToType(model.Value, SettingType); // If sensitive data and was not saved from before, don't automatically remember it if (Sensitive && !saved) { Remember = false; } }
/// <summary> /// 从缓存中获取数据 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="DbContext"></param> /// <returns></returns> internal T GetEntitiesFromCache <T>() { //如果QueryCache里面有该缓存键,则直接获取,并从单个表单位中获取到对应sql的值 if (CacheStorageManager.IsExist(GetQueryCacheKey(), out Dictionary <string, object> t)) { string sqlQueryCacheKey = GetSqlQueryCacheKey(); if (t.ContainsKey(sqlQueryCacheKey)) { DbContext.IsFromCache = true; return(TypeConvertHelper.ToGenericType <T>(t[sqlQueryCacheKey])); } } return(default(T)); }
public StatisticsDto GetStatistics() { string sql = string.Format(@" select count(Id) from [{0}.Job] where StateName = 'Enqueued'; select count(Id) from [{0}.Job] where StateName = 'Failed'; select count(Id) from [{0}.Job] where StateName = 'Processing'; select count(Id) from [{0}.Job] where StateName = 'Scheduled'; select count(Id) from [{0}.Server]; select sum(s.[Value]) from ( select sum([Value]) as [Value] from [{0}.Counter] where [Key] = 'stats:succeeded' union all select [Value] from [{0}.AggregatedCounter] where [Key] = 'stats:succeeded' ) as s; select sum(s.[Value]) from ( select sum([Value]) as [Value] from [{0}.Counter] where [Key] = 'stats:deleted' union all select [Value] from [{0}.AggregatedCounter] where [Key] = 'stats:deleted' ) as s; select count(*) from [{0}.Set] where [Key] = 'recurring-jobs'; ", _storage.GetSchemaName()); var statistics = UseConnection(connection => { var stats = new StatisticsDto(); using (var multi = connection.QueryMultiple(sql)) { //Dapper QueryMultiple情况下 multi.Read<T>()方法 对于基础类型 不会做类型转换 stats.Enqueued = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); stats.Failed = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); stats.Processing = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); stats.Scheduled = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); stats.Servers = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); stats.Succeeded = TypeConvertHelper.ParseDbValue <long?>(multi.Read(typeof(long?)).SingleOrDefault()) ?? 0; stats.Deleted = TypeConvertHelper.ParseDbValue <long?>(multi.Read(typeof(long?)).SingleOrDefault()) ?? 0; stats.Recurring = TypeConvertHelper.ParseDbValue <int>(multi.Read(typeof(int)).Single()); } return(stats); }); statistics.Queues = _storage.QueueProviders .SelectMany(x => x.GetJobQueueMonitoringApi().GetQueues()) .Count(); return(statistics); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); PTTabbedDocumentViewController tabbedDocumentViewController = mTabViewController; mTabViewController = null; nuint index = tabbedDocumentViewController.SelectedIndex; PTDocumentViewController documentViewController = tabbedDocumentViewController.SelectedViewController; PDFDoc pdfDoc = TypeConvertHelper.ConvPdfDocToManaged(documentViewController.PdfViewCtrl.GetDoc()); documentViewController.CloseDocumentWithCompletionHandler((bool success) => { pdfDoc.Close(); pdfDoc = null; }); tabbedDocumentViewController.RemoveTabAtIndex(index); tabbedDocumentViewController = null; GC.Collect(); }
public DetailPage(VideosViewModel videoViewModel) { InitializeComponent(); BindingContext = videoViewModel; NavigationPage.SetHasNavigationBar(this, true); NavigationPage.SetHasBackButton(this, true); foreach (string cast in videoViewModel.Cast) { castStack.Children.Add( new Label { HorizontalOptions = LayoutOptions.FillAndExpand, Text = cast, TextColor = Color.Black, FontSize = 16, FontAttributes = FontAttributes.Italic, } ); } foreach (string character in videoViewModel.Characters) { characterStack.Children.Add( new Label { HorizontalOptions = LayoutOptions.FillAndExpand, Text = character, TextColor = Color.Black, FontSize = 16, FontAttributes = FontAttributes.Italic, } ); } foreach (string keyword in videoViewModel.Keywords) { keywordStack.Children.Add( new Label { HorizontalOptions = LayoutOptions.FillAndExpand, Text = keyword, TextColor = Color.Black, FontSize = 16, FontAttributes = FontAttributes.Italic, } ); } try { Video video = TypeConvertHelper.ConvertVideoViewModelToVideo(videoViewModel); VideoBusiness videoBusiness = new VideoBusiness(); if (videoBusiness.CreateVideo(video) > 0) { System.Diagnostics.Debug.WriteLine("Video Information added in table Successfully."); } } catch (Exception pException) { System.Diagnostics.Debug.WriteLine("Error in Adding Video Information in Database : Message : " + pException.Message); } }
private void btnSet_Click(object sender, EventArgs e) { ValueForReadProcessMemory = TypeConvertHelper.ToInt(txtSet.Text); }
public void LoadIEnumerableToDatabase <T>(IEnumerable <T> lists, string tableName) { DataTable dataTable = TypeConvertHelper.ConvertIEnumerableToDataTable(lists, DateTime.Now.Ticks); SqlHelper.LoadDataTableToDBModelTable(dataTable, tableName); }
private void InitCommand() { CRMUserSyncCommand = new DelegateCommand((obj) => { var r = CRMService.GetQueryXoqlData <SRUserQueryXoqlModel>(@"select id Id,name Name,dimDepart DeptId from user ;"); if (r.code == 200) { SqlHelper.ExecuteNonQuerySR(" truncate table SRUserXoqlTable ;", null); SqlHelper.LoadIEnumerableToDBModelTableSR(r.data.records, "SRUserXoqlTable"); } }); CRMItemSyncCommand = new DelegateCommand((obj) => { List <SROpportunityQueryXoqlDbModel> lists = new List <SROpportunityQueryXoqlDbModel>(); var ss2 = CRMService.GetQueryXoqlData <SROpportunityQueryXoqlModel>(@" select customItem177__c ItemCode,opportunityName ItemName ,ownerId XiangMuJingLi,dbcVarchar6 ShiChangZhiChi,customItem172__c YeWuZhiChi, customItem175__c JiShuZhiChi,customItem182__c PinZhiZhiChi,customItem173__c ChanPinJingLi,customItem180__c JiFuZhiChi,customItem181__c SeCaiZhiChi,createdAt BeginDate from opportunity where dimDepart=1047572968276306 "); if (ss2.code == 200) { SROpportunityQueryXoqlModel[] rr = ss2.data.records; foreach (var item in rr) { SROpportunityQueryXoqlDbModel model = new SROpportunityQueryXoqlDbModel { Id = item.Id, BeginDate = TypeConvertHelper.ConvertTimeStampToDateTime(item.BeginDate), EndDate = TypeConvertHelper.ConvertTimeStampToDateTime(item.EndDate), ItemCode = item.ItemCode, ItemName = item.ItemName, HouDuanZhiChi = item.HouDuanZhiChi, JiFuZhiChi = item.JiFuZhiChi, PinZhiZhiChi = item.PinZhiZhiChi, SeCaiZhiChi = item.SeCaiZhiChi, ShiChangZhiChi = item.ShiChangZhiChi, XiangMuJingLi = item.XiangMuJingLi, YeWuZhiChi = item.YeWuZhiChi == null? "": string.Join(",", item.YeWuZhiChi), ChanPinJingLi = item.ChanPinJingLi == null? "" :string.Join(",", item.ChanPinJingLi), JiShuZhiChi = item.JiShuZhiChi == null ?"":string.Join(",", item.JiShuZhiChi), }; lists.Add(model); } SqlHelper.ExecuteNonQuerySR(" truncate table SROpportunityXoqlTable ;", null); SqlHelper.LoadIEnumerableToDBModelTableSR(lists, "SROpportunityXoqlTable"); } else { MessageBox.Show($"{ss2.code} \r\n{ss2.msg}"); } }); EmployeeCostImportCommand = new DelegateCommand((obj) => { //文件选择窗口 System.Windows.Forms.OpenFileDialog opd = new System.Windows.Forms.OpenFileDialog { Title = "选择文件", Filter = "EXCEL文件|*.xls*" //第一个参数是名称,随意取,第二个是模式匹配, 多个也是用“|”分割 }; if (opd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int monthId = Convert.ToInt32(CommonService.ImportExcelToDatabaseTableWithoutSeq(opd.FileName, "SREmployeeCost", "SR")); SettleMonthSearchedItem.Id = monthId; SettleMonthSearchedItem.SearchText = monthId.ToString(); // 数据验证后加载验证模型列表到表格 //MessageBox.Show("导入成功"); } opd.Dispose(); }); ItemProfitSettleCommand = new DelegateCommand((obj) => { if (SettleMonthSearchedItem == null) { MessageBox.Show("请先导入人员支出Excel"); return; } //同步OA费用数据到松润数据库 DataTable dataTable = _itemProfitAccountingService.GetOaItemCostDataTable(SettleMonthSearchedItem.Id); _itemProfitAccountingService.ImportDataTableToDatabaseTableSR(dataTable, "SROaItemCost"); // 计算最终的结果 _itemProfitAccountingService.AccountItemProfit(SettleMonthSearchedItem.Id); ItemProfitAccountingQueryCommand.Execute(null); }); ItemProfitAccountingQueryCommand = new DelegateCommand((obj) => { ItemProfitAccountingLists.Clear(); _itemProfitAccountingService.GetItemProfitAccountingLists($" and ItemName like '%{ItemNameParameter}%' ").ForEach(x => ItemProfitAccountingLists.Add(x)); ListsSum = ItemProfitAccountingLists.Sum(x => x.Profit); ListsCount = ItemProfitAccountingLists.Count(); }); ItemProfitDeleteCommand = new DelegateCommand((obj) => { MessageBoxResult result = MessageBox.Show($"确认删除【{SettleMonthSearchedItem.Id}】已经结算的数据", "温馨提示", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { } }); ItemProfitMonthlyQueryCommand = new DelegateCommand((obj) => { if (SettleMonthSearchedItem == null) { return; } ItemProfitAccountingMonthlyLists.Clear(); _itemProfitAccountingService.GetItemProfitAccountingMonthlyLists($" and SettleMonth = {SettleMonthSearchedItem.Id} ").ForEach(x => ItemProfitAccountingMonthlyLists.Add(x)); }); SelectionChangedCommand = new DelegateCommand((obj) => { if (ItemProfitAccountingSelectedItem == null) { return; } ItemProfitAccountingMonthlyLists.Clear(); _itemProfitAccountingService.GetItemProfitAccountingMonthlyLists($" and ItemCode = {ItemProfitAccountingSelectedItem.ItemCode} ").ForEach(x => ItemProfitAccountingMonthlyLists.Add(x)); }); }