public static string SaveToContour(this DynaForm dynaform, string formGuid, out string insertedRecordId, string userIpAddress = "", int umbracoPageId = 0) { var message = ""; insertedRecordId = ""; using (var recordStorage = new RecordStorage()) using (var formStorage = new FormStorage()) { var form = formStorage.GetForm(new Guid(formGuid)); using (var recordService = new RecordService(form)) { recordService.Open(); var record = recordService.Record; record.IP = userIpAddress; record.UmbracoPageId = umbracoPageId; recordStorage.InsertRecord(record, form); foreach (var field in recordService.Form.AllFields) { string currentFieldValue = ""; string contourFieldName = field.Caption.TrimStart('#'); if (dynaform.ModelDictionary.ContainsKey("f" + field.Id.ToString().Replace('-', '_'))) { currentFieldValue = dynaform.ModelDictionary["f" + field.Id.ToString().Replace('-', '_')].ToString(); } else if (dynaform.ModelDictionary.ContainsKey(contourFieldName)) { currentFieldValue = dynaform.ModelDictionary[contourFieldName].ToString(); } var key = Guid.NewGuid(); var recordField = new RecordField { Field = field, Key = key, Record = record.Id, Values = new List<object> { currentFieldValue } }; using (var recordFieldStorage = new RecordFieldStorage()) recordFieldStorage.InsertRecordField(recordField); record.RecordFields.Add(key, recordField); insertedRecordId = record.Id.ToString(); } recordService.Submit(); recordService.SaveFormToRecord(); } message=form.MessageOnSubmit; } return message; }
public void should_count_records_with_duplicate_titles() { var service = new RecordService(Db, new RecordValidator()); var record1 = new Record().With(r => { r.Id = new Guid("7ce85158-f6f9-491d-902e-b3f2c8bb5264"); r.Path = @"X:\path\to\duplicate\record\1"; r.Gemini = new Metadata().With(m => { m.Title = "This is a duplicate record"; m.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/jncc-domain", Value = "Marine" }); m.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/jncc-category", Value = "Example" }); }); }); var record2 = new Record().With(r => { r.Id = new Guid("afb4ebbf-4286-47ed-b09f-a4d40af139e1"); r.Path = @"X:\path\to\duplicate\record\2"; r.Gemini = new Metadata().With(m => { m.Title = "This is a duplicate record"; m.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/jncc-domain", Value = "Marine" }); m.Keywords.Add(new MetadataKeyword { Vocab = "http://vocab.jncc.gov.uk/jncc-category", Value = "Example" }); }); }); service.Insert(record1, TestUser); service.Insert(record2, TestUser); Db.SaveChanges(); RavenUtility.WaitForIndexing(Db); var results = Db.Query <RecordsWithDuplicateTitleCheckerIndex.Result, RecordsWithDuplicateTitleCheckerIndex>() .Where(x => x.Count > 1) .Take(100) .ToList(); // looks like we have some duplicates created by the seeder! results.Count.Should().BeInRange(1, 10); // perhaps prevent more duplicate titles being seeded in the future! results.Should().Contain(r => r.Title == "This is a duplicate record"); }
private void lbQues_MouseDoubleClick(object sender, MouseEventArgs e) { var problem = listBox4.SelectedItem.ToString().Substring(1); Question ques = RecordService.ShowQues(User, problem); MainWin.QuestionList = new List <Question>(); MainWin.QuestionList.Add(ques); MainWin.QuesRecord = new Record(); MainWin.QuesRecord.Questions = MainWin.QuestionList; var study = new QuestionStudyControl(MainWin); this.MainWin.SubView.Controls.Clear(); MainWin.SubView.Controls.Add(study); }
public ActionResult Success(string OrderID = "") { var RecordEntity = new RecordService().SelectByID(OrderID); //var CouponEntity = new CouponService().GetCouponByOrderID(OrderID); //ViewBag.PayType = PayType == "Consume" ? "消费" : "充值"; ViewBag.OrderID = RecordEntity != null ? RecordEntity.RecordID : ""; ViewBag.OrderNo = RecordEntity != null ? RecordEntity.OrderNo : ""; ViewBag.Description = RecordEntity != null ? RecordEntity.Description: ""; ViewBag.Status = RecordEntity != null ? RecordEntity.Status : 0; //ViewBag.Coupon = CouponEntity != null ? CouponEntity.Coupon : ""; return(View()); }
public void DeleteFromXML(Guid varId) { List <Guid> lstRecID = RecordService.GetAllRecordID(); Guid vrId = lstRecID.FirstOrDefault(); try { List <ExportRecordData> exportDataList = DataToList(); List <ExportRecordData> newExportDataList = new List <ExportRecordData>(); if (exportDataList != null) { foreach (ExportRecordData e in exportDataList) { var index = e.Variables.FindIndex(a => a.Key == varId.ToString()); List <KeyValue> vVariables = e.Variables.Where(v => v.Key != varId.ToString()).ToList(); //should be -1 Guid vRecID = e.RecID; List <ExportRecord> vRecords = e.Records.ToList(); List <ExportRecord> newVRecords = new List <ExportRecord>(); foreach (ExportRecord r in vRecords) { ExportRecord newExp = new ExportRecord(); newExp = r; try { r.VariableValues.RemoveAt(index); } catch { } newExp.VariableValues = r.VariableValues; newVRecords.Add(newExp); } #region [Create New Record] ExportRecordData exprt = new ExportRecordData(); exprt.RecID = vRecID; exprt.Records = newVRecords; exprt.Variables = vVariables; #endregion newExportDataList.Add(exprt); } SaveXMLToData(newExportDataList); } } catch (Exception ee) { ErrorLog.WriteLog("ManageRecordModel", "UpdateXML", ee, ""); } }
public void WxPayNotify() { WxPayData res = new WxPayData(); try { Notify notify = new Notify(this); WxPayData notifyData = notify.GetNotifyData(); var orderNo = notifyData.GetValue("out_trade_no").ToString(); var attach = notifyData.GetValue("attach").ToString(); // UserID 或者 UserID + "|" var resultCode = notifyData.GetValue("result_code").ToString(); var otherOrderNum = notifyData.GetValue("transaction_id").ToString(); var money = Convert.ToDecimal(notifyData.GetValue("total_fee").ToString()); if (resultCode.ToUpper() == "SUCCESS") { // 修改订单状态 ResultModel <Bis_Record> result = new RecordService().ModifyOrderStatus(orderNo, otherOrderNum); if (result.status > 0) { if (result.data != null) { // 支付成功,修改订单状态成功之后 // 推送微信通知消息 SendMsg(result.data); } res.SetValue("return_code", "SUCCESS"); res.SetValue("return_msg", "OK"); Response.Write(res.ToXml()); Response.End(); } } res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); Response.Write(res.ToXml()); Response.End(); } catch (Exception ex) { res.SetValue("return_code", "FAIL"); res.SetValue("return_msg", "FAIL"); Response.Write(res.ToXml()); Response.End(); MYLog.Error("支付回调", ex.ToString()); } }
public async Task <(CredentialRequestMessage, CredentialRecord)> CreateRequestAsync(IAgentContext agentContext, string credentialId) { var credential = await GetAsync(agentContext, credentialId); if (credential.State != CredentialState.Offered) { throw new AgentFrameworkException(ErrorCode.RecordInInvalidState, $"Credential state was invalid. Expected '{CredentialState.Offered}', found '{credential.State}'"); } var connection = await ConnectionService.GetAsync(agentContext, credential.ConnectionId); var definition = await LedgerService.LookupDefinitionAsync(await agentContext.Pool, credential.CredentialDefinitionId); var provisioning = await ProvisioningService.GetProvisioningAsync(agentContext.Wallet); var request = await AnonCreds.ProverCreateCredentialReqAsync(agentContext.Wallet, connection.MyDid, credential.OfferJson, definition.ObjectJson, provisioning.MasterSecretId); // Update local credential record with new info credential.CredentialRequestMetadataJson = request.CredentialRequestMetadataJson; await credential.TriggerAsync(CredentialTrigger.Request); await RecordService.UpdateAsync(agentContext.Wallet, credential); var threadId = credential.GetTag(TagConstants.LastThreadId); var response = new CredentialRequestMessage { Requests = new[] { new Attachment { Id = "libindy-cred-request-0", MimeType = CredentialMimeTypes.ApplicationJsonMimeType, Data = new AttachmentContent { Base64 = request.CredentialRequestJson.GetUTF8Bytes().ToBase64String() } } } }; response.ThreadFrom(threadId); return(response, credential); }
public void should_update_footer_for_existing_record() { var timeGetter = Clock.CurrentUtcDateTimeGetter; Clock.CurrentUtcDateTimeGetter = () => new DateTime(2015, 1, 1, 12, 0, 0); var recordId = Helpers.AddCollection("4d909f48-4547-4129-a663-bfab64ae97e9"); var record = new Record { Id = recordId, Path = @"X:\some\path", Gemini = Library.Blank().With(m => m.Title = "Footer update test"), Footer = new Footer { CreatedOnUtc = new DateTime(2015, 1, 1, 10, 0, 0), CreatedByUser = new UserInfo { DisplayName = "Creator", Email = "*****@*****.**" }, ModifiedOnUtc = new DateTime(2015, 1, 1, 10, 0, 0), ModifiedByUser = new UserInfo { DisplayName = "Creator", Email = "*****@*****.**" } } }; var database = Mock.Of <IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var result = service.Update(record, TestUser); Clock.CurrentUtcDateTimeGetter = timeGetter; var footer = result.Record.Footer; footer.Should().NotBeNull(); footer.CreatedOnUtc.Should().Be(new DateTime(2015, 1, 1, 10, 0, 0)); footer.CreatedByUser.DisplayName.Should().Be("Creator"); footer.CreatedByUser.Email.Should().Be("*****@*****.**"); footer.ModifiedOnUtc.Should().Be(new DateTime(2015, 1, 1, 12, 0, 0)); footer.ModifiedByUser.DisplayName.Should().Be("Test User"); footer.ModifiedByUser.Email.Should().Be("*****@*****.**"); }
protected virtual void LoadRecord() { if (RecordId.IsNullOrWhiteSpace()) { throw new NullReferenceException("Record Id Cannot Be Empty When Loading The Record"); } if (RecordType.IsNullOrWhiteSpace()) { throw new NullReferenceException("Record Type Cannot Be Empty When Loading The Record"); } if (RecordIdName.IsNullOrWhiteSpace()) { RecordIdName = RecordService.GetPrimaryKey(RecordType); } _record = RecordService.GetFirst(RecordType, RecordIdName, RecordId); }
private void Window_Loaded(object sender, RoutedEventArgs e) { RecordService recordService = new RecordService(); records = new RecordCollection(recordService.GetAll()); ProgramService programService = new ProgramService(); programs = new ProgramCollection(programService.GetAll()); dgridTvRecord.ItemsSource = records.collecion; dgridProgram.ItemsSource = programs.collecion; ChannelService channelService = new ChannelService(); channels = new ChannelCollection(channelService.GetAll()); }
public void ExamMode() { //打开选择窗口 var choose = new QuestionChooseForm(); choose.listBox1.DataSource = Datas.QuesTitleList; choose.ShowDialog(); //显示题目学习控件 if (choose.DialogResult == DialogResult.OK) { this.SubView.Controls.Clear(); QuestionList = DataProvider.GetQuestions(choose.choice); QuesRecord = RecordService.QuestionLearning(User, QuestionList); var study = new QuestionStudyControl(this); this.SubView.Controls.Add(study); } }
public void should_store_bounding_box_as_wkt() { var database = Mock.Of <IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var e = Library.Example(); var record = new Record { Gemini = e, Footer = new Footer() }; service.Update(record, TestUser); string expectedWkt = BoundingBoxUtility.ToWkt(e.BoundingBox); Mock.Get(database).Verify(db => db.Store(It.Is((Record r) => r.Wkt == expectedWkt))); }
public AnnoForm(MainWindow mainWindow, Word word) { MainWin = mainWindow; Word = word; InitializeComponent(); if (mainWindow.User != null) { RecordService.ShowUserWords(mainWindow.User, 4).ForEach(w => { if (w.KeyWord == word.KeyWord) { Word.Annotation = w.Annotation; } }); } lblKeyword.Text = word.KeyWord; richTextBox1.Text = Word.Annotation; }
public virtual void LoadFormSections() { var verifyConnection = RecordService.VerifyConnection(); if (!verifyConnection.IsValid) { ValidationPrompt = $"This Form Could Not Be Loaded Due To A Connection Error\n\n{string.Join("\n" ,verifyConnection.InvalidReasons)}"; LoadingViewModel.IsLoading = false; BackButtonViewModel.IsVisible = OnBack != null; CancelButtonViewModel.IsVisible = OnCancel != null; ApplicationController.LogEvent("Loading Form Connection Error", new Dictionary <string, string> { { "Is Error", true.ToString() }, { "Record Type", GetRecordType() } }); } else { //forcing enumeration up front var sections = FormService.GetFormMetadata(RecordType, RecordService).FormSections.ToArray(); var sectionViewModels = new List <SectionViewModelBase>(); //Create the section view models foreach (var section in sections) { if (section is FormFieldSection ffs) { var sectionVm = new FieldSectionViewModel( ffs, this ); sectionVm.IsVisible = ffs.FormFields.Any(f => FormService.IsFieldInContext(f.FieldName, GetRecord())); sectionViewModels.Add(sectionVm); } } //now set the section view model property in the ui thread which will notify the ui with the sections DoOnMainThread( () => { FormSectionsAsync = new ObservableCollection <SectionViewModelBase>(sectionViewModels); OnSectionLoaded(); }); } }
public void RoomEnd(HttpListenerContext context) { var request = context.Request; var response = context.Response; string roomid = request.QueryString["roomid"]; string createtime = request.QueryString["createtime"]; //读取客户端发送过来的数据 string filename = ""; using (Stream body = request.InputStream) { if (!Directory.Exists("frame")) { Directory.CreateDirectory("frame"); } filename = "frame/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".bin"; FileStream fs = new FileStream(filename, FileMode.Create); byte[] buff = new byte[1024]; int count = 0; while ((count = body.Read(buff, 0, 1024)) != 0) { fs.Write(buff, 0, count); } fs.Close(); } Dictionary <string, object> result = new Dictionary <string, object>(); Record record = RecordService.AddRecord(int.Parse(roomid), createtime, filename); if (record != null) { result.Add("code", 0); result.Add("data", new Dictionary <string, object>()); } else { result.Add("code", -1); result.Add("msg", "operate fail"); } Response(context, result); }
public override void Execute(SldWorksModelProxy model, ReleasedComponent component, GenerationSettings generationSettings) { var activeEnvironment = EnvironmentManager.GetEnvironment(generationSettings.Group); var activeGroupName = generationSettings.Group.Name; using (var recordService = new RecordService(activeEnvironment.GetSQLExtendConnectionString())) { try { int generationId = 0; int stateId = 0; if (this.Data.TryGetParameterValueAsInteger(GENERATIONID, ref generationId)) { this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "Generation id est invalide", null); } if (this.Data.TryGetParameterValueAsInteger(STATEID, ref stateId)) { this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "State id est invalide", null); } //récupération de la génération var theGeneration = recordService.GetGenerationById(generationId); if (theGeneration == null) { throw new Exception("La génération est introuvable"); } if (theGeneration.History.IsNotNullAndNotEmpty()) { theGeneration.History += Environment.NewLine; } theGeneration.History += "Modification le '{0}', par '{1}', vers l'état {2}".FormatString(DateTime.Now.ToStringDMYHMS(), generationSettings.Group.CurrentUser.DisplayName, ((GenerationStatusEnum)stateId).GetName("FR")); theGeneration.State = (GenerationStatusEnum)stateId; recordService.UpdageGeneration(theGeneration); } catch (Exception ex) { this.Report.WriteEntry(ReportingLevel.Minimal, ReportEntryType.Information, "Report generation progress", "Report generation progress", "Erreur : " + ex.Message, null); } } }
private void LoadFields() { foreach (var field in GridFields) { try { var viewModel = field.CreateFieldViewModel(RecordType, RecordService, this, ApplicationController); var isWriteable = RecordService?.GetFieldMetadata(field.FieldName, RecordType).Createable == true || RecordService?.GetFieldMetadata(field.FieldName, RecordType).Writeable == true; viewModel.IsEditable = !IsReadOnly && isWriteable && FormService != null && FormService.AllowGridFieldEditEdit(ParentFormReference); AddField(viewModel); } catch (Exception ex) { ApplicationController.ThrowException(ex); } } }
/// <inheritdoc /> public async Task <string> ProcessOfferAsync(IAgentContext agentContext, CredentialOfferMessage credentialOffer, ConnectionRecord connection) { var offerAttachment = credentialOffer.Offers.FirstOrDefault(x => x.Id == "libindy-cred-offer-0") ?? throw new ArgumentNullException(nameof(CredentialOfferMessage.Offers)); var offerJson = offerAttachment.Data.Base64.GetBytesFromBase64().GetUTF8String(); var offer = JObject.Parse(offerJson); var definitionId = offer["cred_def_id"].ToObject <string>(); var schemaId = offer["schema_id"].ToObject <string>(); // Write offer record to local wallet var credentialRecord = new CredentialRecord { Id = Guid.NewGuid().ToString(), OfferJson = offerJson, ConnectionId = connection.Id, CredentialDefinitionId = definitionId, CredentialAttributesValues = credentialOffer.CredentialPreview?.Attributes .Select(x => new CredentialPreviewAttribute { Name = x.Name, MimeType = x.MimeType, Value = x.Value }).ToArray(), SchemaId = schemaId, State = CredentialState.Offered }; credentialRecord.SetTag(TagConstants.Role, TagConstants.Holder); credentialRecord.SetTag(TagConstants.LastThreadId, credentialOffer.GetThreadId()); await RecordService.AddAsync(agentContext.Wallet, credentialRecord); EventAggregator.Publish(new ServiceMessageProcessingEvent { RecordId = credentialRecord.Id, MessageType = credentialOffer.Type, ThreadId = credentialOffer.GetThreadId() }); return(credentialRecord.Id); }
public static string CheckRecord(String recordId) { try { RecordStorage rs = new RecordStorage(); Record record = rs.GetRecord(Guid.Parse(recordId)); RecordService s = new RecordService(record); s.Approve(); } catch (Exception ex) { if (ex.Message.Contains("This license is invalid")) return new MessageBox("Record approved successfully", new Button("Ok", new Call("ViewData", new string[] { recordId }))).UmGo(); else return new MessageBox("Error to approved this record", new Button("Close")).UmGo("Warning"); } return new MessageBox("Record approved successfully", new Button("Ok", new Call("ViewData", new string[] { recordId }))) .UmGo(); }
private IEnumerable <IRecord> GetRecordsToProcess(bool selectedOnly) { IEnumerable <IRecord> recordsToUpdate = null; var fieldsToGet = new[] { RecordService.GetPrimaryField(QueryViewModel.RecordType) }; if (selectedOnly) { var ids = QueryViewModel.DynamicGridViewModel.SelectedRows.Select(r => r.Record.Id).ToArray(); recordsToUpdate = RecordService.RetrieveAllOrClauses(QueryViewModel.RecordType, ids.Select(i => new Condition(RecordService.GetPrimaryKey(QueryViewModel.RecordType), ConditionType.Equal, i)), fieldsToGet); } else { var query = QueryViewModel.GenerateQuery(); query.Fields = fieldsToGet; query.Top = -1; recordsToUpdate = RecordService.RetreiveAll(query); } return(recordsToUpdate); }
protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session["LoginValidate"]) != "1") { //Request.Abort(); Response.Redirect("/Support/AdminLogin.aspx?auth=RebuildDownloadXML.aspx"); } if (Request.QueryString["action"] != null) { string res = GetProgress(); Response.Clear(); Response.Write(res); Response.End(); return; } lblTotalRecords.Text = RecordService.GetRecords(AppSettingsUtility.GetGuid(AppSettingsKeys.DefaultLanguageID)).Count.ToString(); if ((recordProcessed == 0) || (recordProcessed == recordTotal)) { ScriptManager.RegisterStartupScript(this, GetType(), "disableButton", "$('#btnRebuildDownloadCache').prop('disabled', false); $('#loaderImg').hide();", true); ScriptManager.RegisterStartupScript(this, GetType(), "disableSuccess", "$('#dvSuccess').hide();", true); ScriptManager.RegisterStartupScript(this, GetType(), "disableFailure", "$('#dvFailure').hide();", true); recordProcessed = 0; lblTotalRecordsProcessed.Text = recordProcessed.ToString(); lblTotalRecordsNotProcessed.Text = recordNotProcessed.ToString(); recordTotal = Convert.ToInt32(lblTotalRecords.Text); } else { ScriptManager.RegisterStartupScript(this, GetType(), "disableButton", "$('#btnRebuildDownloadCache').prop('disabled', true); $('#loaderImg').show();", true); ScriptManager.RegisterStartupScript(this, GetType(), "disableSuccess", "$('#dvSuccess').hide();", true); ScriptManager.RegisterStartupScript(this, GetType(), "disableFailure", "$('#dvFailure').hide();", true); } }
public Join GetAsJoin() { if (RelationshipType == "nn") { var joinThrough = new Join(RecordService.GetPrimaryKey(SourceType), IntersectEntity, IntersectJoinTo); var join = new Join(IntersectOtherSide, OtherType, RecordService.GetPrimaryKey(OtherType)); joinThrough.Joins = new List <Join> { join }; return(joinThrough); } if (RelationshipType == "1n") { return(new Join(RecordService.GetPrimaryKey(SourceType), OtherType, FieldJoinTo)); } if (RelationshipType == "n1") { return(new Join(FieldJoin, OtherType, RecordService.GetPrimaryKey(OtherType))); } return(null); }
public ActionResult SubmitRefundApply(string OrderID, string Remark, decimal?Amount) { string RefundNo = WxPayApi.GenerateOutTradeNo(); var resultData = new RefundService().AddRefundApply(OrderID, RefundNo, SessionTools.UserID, Remark, Amount); if (resultData != null && resultData.status > 0) { // 修改订单状态为退款中 var resultOrderStatus = new RecordService().RefundOrder(OrderID); // 退款申请提交成功后,(修改订单状态为退款中),向管理员发送退款申请验证码 // 消息携带链接:/User/ValidateRefund?OrderID=&TelePhone=&CodeStr= // 管理员点击退款申请信息后,跳转至link,验证通过,管理员输入允许的退款金额 // 然后调用 POST - /User/RefundAmount 进行退款 // 退款成功后,修改订单状态、退款单状态、使用券状态 if (resultOrderStatus != null && resultOrderStatus.status > 0) { this.SendCode(OrderID, (int)Code_Type.Refund); } } return(Content(JsonHelper.SerializeObject(resultData))); }
public void should_give_new_record_a_footer() { var record = new Record { Path = @"X:\some\path", Gemini = Library.Blank().With(m => m.Title = "Footer creation test") }; var database = Mock.Of <IDocumentSession>(); var service = new RecordService(database, ValidatorStub()); var result = service.Insert(record, TestUser); var footer = result.Record.Footer; footer.Should().NotBeNull(); footer.CreatedOnUtc.Should().NotBe(DateTime.MinValue); footer.CreatedByUser.DisplayName.Should().Be("Test User"); footer.CreatedByUser.Email.Should().Be("*****@*****.**"); footer.ModifiedOnUtc.Should().NotBe(DateTime.MinValue); footer.ModifiedByUser.DisplayName.Should().Be("Test User"); footer.ModifiedByUser.Email.Should().Be("*****@*****.**"); }
public FakeGridViewModel() : base(new FakeApplicationController()) { PageSize = 50; ViewType = Record.Metadata.ViewType.MainApplicationView; RecordService = FakeRecordService.Get(); RecordType = FakeConstants.RecordType; IsReadOnly = true; FormController = new FakeFormController(); GetGridRecords = (b) => { return(new GetGridRecordsResponse(RecordService.RetrieveAll(RecordType, null))); }; MultiSelect = true; GridLoaded = false; //var customFunctions = new List<CustomGridFunction>() //{ // new CustomGridFunction("Dummy", () => { }) //}; //LoadGridButtons(customFunctions); ReloadGrid(); }
public ActionResult Edit() { BizAnswerBank bizAnswerBank = new BizAnswerBank(); bool result = false; AspectF.Define .Log(log, "AnswerBankController-Edit[post]开始", "AnswerBankController-Edit[post]结束") .HowLong(log) .Retry(log) .Do(() => { var reader = new StreamReader(Request.InputStream).ReadToEnd(); var model = JsonConvert.DeserializeObject <ViewAnswerBank>(reader); ViewToDBForModel(bizAnswerBank, model); if (string.IsNullOrEmpty(model.id)) { result = answerBankService.Add(bizAnswerBank); if (!string.IsNullOrEmpty(model.countID)) { BizRecord bizRecord = new BizRecord(); bizRecord.RecordID = model.countID; RecordService recordService = new RecordService(); recordService.Delete(new string[] { bizRecord.RecordID }); } } else { bizAnswerBank.UpdateTime = DateTime.Now; result = answerBankService.Update(bizAnswerBank); } }); if (result) { return(Json(new { status = "y" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "n" }, JsonRequestBehavior.AllowGet)); } }
public void UpdateXML() { List <Guid> lstRecID = RecordService.GetAllRecordID(); Guid vrId = lstRecID.FirstOrDefault(); try { List <ExportRecordData> exportDataList = DataToList(); List <ExportRecordData> newExportDataList = new List <ExportRecordData>(); if (exportDataList != null) { foreach (ExportRecordData e in exportDataList) { List <KeyValue> vVariables = e.Variables; Guid vRecID = e.RecID; List <ExportRecord> vRecords = e.Records.Where(x => x.RecordID != vrId).ToList(); #region [Create New Record] ExportRecordData exprt = CreateNewRecord(vrId); #endregion foreach (ExportRecord r in exprt.Records) { vRecords.Add(r); } ExportRecordData expData = new ExportRecordData(); expData.RecID = vRecID; expData.Records = vRecords; expData.Variables = exprt.Variables; newExportDataList.Add(expData); } SaveXMLToData(newExportDataList); } } catch (Exception ee) { ErrorLog.WriteLog("ManageRecordModel", "UpdateXML", ee, ""); } }
public CreateOrUpdateViewModel(IRecord record, FormController formController, Action postSave, Action onCancel, bool explicitIsCreate = false) : base(formController) { _record = record; RecordType = record.Type; OnSave = () => { if (GetRecord().Id == null || explicitIsCreate) { GetRecord().Id = RecordService.Create(GetRecord()); } else { RecordService.Update(GetRecord(), ChangedPersistentFields); } if (postSave != null) { postSave(); } }; OnCancel = onCancel; }
public QueryDefinition GenerateQuery() { var query = new QueryDefinition(RecordType); if (IsQuickFind) { query.IsQuickFind = true; query.QuickFindText = QuickFindText; if (!string.IsNullOrWhiteSpace(QuickFindText)) { query.RootFilter.Conditions.Add(new Condition(RecordService.GetPrimaryField(DynamicGridViewModel.RecordType), ConditionType.BeginsWith, QuickFindText)); } } else { query.RootFilter = FilterConditions.GetAsFilter(); } var view = DynamicGridViewModel.RecordService.GetView(DynamicGridViewModel.RecordType, DynamicGridViewModel.ViewType); query.Sorts = view.Sorts.ToList(); return(query); }
public ShowWordForm(MainWindow mainWindow, Word searchWord) { InitializeComponent(); this.searchWord = searchWord; //searchWord是单词 MainWin = mainWindow; if (searchWord.Translations.Count == 0) { this.searchWord = Clawler.DownLoad(searchWord.KeyWord); } ShowInfo(); if (MainWin.User != null) { RecordService.ShowUserWords(MainWin.User, 3).ForEach(w => { if (w.KeyWord == searchWord.KeyWord) { button5.Text = "移出单词本"; } }); } }
public ActionResult RefundAmount(string OrderID, decimal?Amount = null) { var recordEntity = new RecordService().SelectByID(OrderID); var refundEntity = new RefundService().SelectByID(OrderID); if (recordEntity != null) { JsApiPay jsApiPay = new JsApiPay(this); var userEntity = new UserService().SelectByID(recordEntity.UserID); jsApiPay.op_user_id = userEntity != null ? userEntity.WeiXin_Openid : ""; jsApiPay.order_no = recordEntity.OrderNo; jsApiPay.out_refund_no = refundEntity != null ? refundEntity.RefundNo : WxPayApi.GenerateOutTradeNo(); jsApiPay.total_fee = Convert.ToInt32(recordEntity.Amount * 100); jsApiPay.refund_fee = Amount != null?Convert.ToInt32(Amount * 100) : (refundEntity != null ? Convert.ToInt32(refundEntity.Amount * 100) : 0); try { WxPayData result = jsApiPay.GetRefundOrderResult(); if (result.IsSet("result_code") && result.GetValue("result_code").ToString() == "SUCCESS") { return(Content(JsonHelper.SerializeObject(Common.MessageRes.OperateSuccess.SetResult("SUCCESS")))); } else { MYLog.Error("退款申请失败:" + SessionTools.UserName, JsonHelper.SerializeObject(result.GetValues())); return(Content(JsonHelper.SerializeObject(result.GetValue("err_code_des").ToString().SetResult(null)))); } } catch (Exception ex) { MYLog.Error("退款申请失败,请返回重试:" + SessionTools.UserName, ex.ToString()); return(Content(JsonHelper.SerializeObject("退款申请失败,请返回重试".SetResult(null)))); } } return(Content(JsonHelper.SerializeObject(Common.MessageRes.OperateFailed.SetResult(null)))); }
/// <summary> /// Gets the field values for the specified field on the specified form. /// </summary> /// <param name="formName">The name of the Contour form.</param> /// <param name="fieldCaption">The caption for the field.</param> /// <returns> /// The field values and labels. /// </returns> public static List<ValueLabelStrings> GetFieldValues(string formName, string fieldCaption) { // Validation. if (string.IsNullOrWhiteSpace(formName) || string.IsNullOrWhiteSpace(fieldCaption)) { return null; } // Get cache of values for specified form/field. var cache = null as InstanceCache<List<ValueLabelStrings>>; lock (FieldValuesLock) { var key = new KeyValueStrings(formName, fieldCaption); if (!FieldValues.TryGetValue(key, out cache)) { cache = new InstanceCache<List<ValueLabelStrings>>(); FieldValues[key] = cache; } } // Get values from cache. return cache.Get(TimeSpan.FromHours(3), () => { var results = new List<ValueLabelStrings>(); using (var formStorage = new FormStorage()) { var form = formStorage.GetForm(formName); using (var recordService = new RecordService(form)) { recordService.Open(); foreach (var field in recordService.Form.AllFields) { if (fieldCaption.InvariantEquals(field.Caption)) { field.PreValueSource.Type.LoadSettings(field.PreValueSource); foreach (var item in field.PreValueSource.Type.GetPreValues(field)) { results.Add(new ValueLabelStrings(item.Id.ToString(), item.Value)); } } } } } return results; }); }
public void DeleteUser(HttpListenerContext context) { var request = context.Request; var response = context.Response; string id = request.QueryString["id"]; // 验证token string token = request.QueryString["token"]; if (!UserHandler.ValidateToken(token)) { ResponseTokenInvalid(context); return; } if (id == null) { ResponseParameterInvalid(context); return; } Dictionary <string, object> result = new Dictionary <string, object>(); bool success = RecordService.SoftDeleteRecord(int.Parse(id)); if (success) { result.Add("code", 0); Dictionary <string, object> data = new Dictionary <string, object>(); data.Add("id", int.Parse(id)); result.Add("data", data); } else { result.Add("code", -1); result.Add("msg", "operate fail"); } Response(context, result); }
public static string DeleteRecord(String recordId) { string formGuid = null; try { RecordStorage rs = new RecordStorage(); Record record = rs.GetRecord(Guid.Parse(recordId)); RecordService s = new RecordService(record); formGuid = record.Form.ToString(); s.Delete(); } catch (Exception ex) { if (ex.Message.Contains("This license is invalid")) return new MessageBox("Record deleted successfully", new Button("Ok", new Call("ListRecord", new string[] { formGuid, "1" }))).UmGo(); else return new MessageBox("Error to delete this record", new Button("Close")).UmGo("Warning"); } return new MessageBox("Record deleted successfully", new Button("Ok", new Call("ListRecord", new string[] { formGuid, "1" }))) .UmGo(); }
/// <summary> /// Stores a form record. /// </summary> /// <param name="form">The form to store a record to.</param> /// <param name="fieldValues">The field values to store.</param> /// <param name="ipAddress">The user's IP address.</param> /// <param name="pageId">The current page ID.</param> /// <param name="recordId">Outputs the ID of the record stored to Contour.</param> /// <returns>True, if the record was stored; otherwise, false.</returns> private static bool StoreRecord(Form form, Dictionary<string, List<object>> fieldValues, string ipAddress, int pageId, out Guid recordId) { using (var recordStorage = new RecordStorage()) using (var recordService = new RecordService(form)) { // Open record service. recordService.Open(); // Create record. var record = recordService.Record; record.IP = ipAddress; record.UmbracoPageId = pageId; record = recordStorage.InsertRecord(record, form); // Assign field values for record. foreach (var field in recordService.Form.AllFields) { // Check which field this is. var knownField = false; var values = default(List<object>); if (fieldValues.TryGetValue((field.Caption ?? string.Empty).ToLower(), out values)) { knownField = true; } // If the field is one of those that are known, store it. if (knownField && values != null && values.Any(x => x != null)) { // Create field. var key = Guid.NewGuid(); var recordField = new RecordField { Field = field, Key = key, Record = record.Id, Values = values }; // Store field. using (var recordFieldStorage = new RecordFieldStorage()) { recordFieldStorage.InsertRecordField(recordField); } // Add field to record. record.RecordFields.Add(key, recordField); } } // Submit / save record. recordService.Submit(); var result = recordService.SaveFormToRecord(); recordId = record.Id; return result; } }