/// <summary> /// Create Invoice For Closure Charge and Auction Invoicing /// </summary> private void CreateInvoice(string type) { var tasks = new List <Task <ResultDTO> >(); var results = new List <string>(); //try { LogService.WriteInfo("Begin Mass Billing " + type); DraftService lObjDraftService = new DraftService(); lObjDraftService.DeleteDrafts(type); foreach (var doc in pendingInvoices) { // tasks.Add(Task.Run(() => { try { LogService.WriteInfo("Begin Creating Invoice for Cient: " + doc.Code); var invoice = new DocumentDTO(); invoice.Document = doc; invoice.FloorServiceLines = massInvoicingDAO.GetFloorServiceLines(doc.Code, user.WhsCode, type); invoice.DeliveryLines = massInvoicingDAO.GetDeliveryLines(doc.Code, user.WhsCode); //invoice.FloorServiceLines = massInvoicingDAO.GetFloorServiceLines(doc.Code, "CRHE", type); //invoice.DeliveryLines = massInvoicingDAO.GetDeliveryLines(doc.Code, "CRHE"); if (invoice.FloorServiceLines.Count == 0 && invoice.DeliveryLines.Count == 0) { results.Add("Sin servicio de piso ni entregas de alimento"); } else { results.Add(InvoiceDI.CreateInvoice(invoice, user, floorServiceItem, type).Message); } LogService.WriteInfo("Successfully Creating Invoice for Cient: " + doc.Code); // })); //Thread.Sleep(130); } catch (Exception ex) { HandleException(ex, "[Exception] Invoice for Client " + doc.Code); } //Task.WaitAll(tasks.ToArray()); } //catch(AggregateException ae) { // ae.Handle(e => { // HandleException(e, "(Closure)"); // return true; // }); //} //catch(Exception ex) { // HandleException(ex, "(Closure)"); //} Task.Factory.StartNew(() => { // BindResultColumn(tasks.Select(t => t.Result.Message).AsParallel().AsOrdered().ToList(), type); BindResultColumn(results, type); LogService.WriteInfo("Done Mass Billing " + type); }); UIApplication.ShowMessageBox("Revisar la Columna de Resultados"); }
private void ButtonSave_Click(object sender, EventArgs e) { try { var setting = SettingService.GetSettings(); var restMinutes = (int)(StaticAssets.Duration.TotalMinutes * setting.RestTimeInMinutes / 60); var stopDateTimeNow = StaticAssets.StopDateTime <= DateTime.MinValue ? DateTime.Now.AddMinutes(restMinutes) : StaticAssets.StopDateTime.AddMinutes(restMinutes); TimeService.Save(new TimeModel { ProjectId = int.Parse(_projectId), Duration = StaticAssets.Duration.Add(new TimeSpan(0, 0, restMinutes, 0)), StopDateTime = stopDateTimeNow, StartDateTime = StaticAssets.StartDateTime, Description = textBoxDescription.Text.Trim() }); ShowSuccessMessage("Time saved successfully"); StaticAssets.Duration = new TimeSpan(0, 0, 0, 0, 0); DraftService.Clear(); Close(); } catch (Exception exception) { ShowErrorMessage(exception.Message); } }
public DraftCreateTests() { _proxy = SettingsManager.GetGmailProxy(); var service = new DraftService(_proxy); _helper = CleanupHelpers.GetDraftServiceCleanupHelper(service); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="baseCampaignId">Id of the campaign to use as base of the /// draft.</param> public void Run(AdWordsUser user, long baseCampaignId) { // Get the DraftService. DraftService draftService = (DraftService)user.GetService( AdWordsService.v201603.DraftService); Draft draft = new Draft() { baseCampaignId = baseCampaignId, draftName = "Test Draft #" + ExampleUtilities.GetRandomString() }; DraftOperation draftOperation = new DraftOperation() { @operator = Operator.ADD, operand = draft }; try { draft = draftService.mutate(new DraftOperation[] { draftOperation }).value[0]; Console.WriteLine("Draft with ID {0}, base campaign ID {1} and draft campaign ID " + "{2} created.", draft.draftId, draft.baseCampaignId, draft.draftCampaignId); // Once the draft is created, you can modify the draft campaign as if it // were a real campaign. For example, you may add criteria, adjust bids, // or even include additional ads. Adding a criterion is shown here. CampaignCriterionService campaignCriterionService = (CampaignCriterionService)user.GetService( AdWordsService.v201603.CampaignCriterionService); Language language = new Language() { id = 1003L // Spanish }; // Make sure to use the draftCampaignId when modifying the virtual draft // campaign. CampaignCriterion campaignCriterion = new CampaignCriterion() { campaignId = draft.draftCampaignId, criterion = language }; CampaignCriterionOperation criterionOperation = new CampaignCriterionOperation() { @operator = Operator.ADD, operand = campaignCriterion }; campaignCriterion = campaignCriterionService.mutate( new CampaignCriterionOperation[] { criterionOperation }).value[0]; Console.WriteLine("Draft updated to include criteria in draft campaign ID {0}.", draft.draftCampaignId); } catch (Exception e) { throw new System.ApplicationException("Failed to create draft campaign and add " + "criteria.", e); } }
public static CleanupHelper <Draft, Draft> GetDraftServiceCleanupHelper(DraftService service) { Func <Draft, Task> deleteAction = async label => await service.DeleteAsync(label.Id); Func <Draft, Task <Draft> > createAction = service.CreateAsync; return(new CleanupHelper <Draft, Draft>(createAction, deleteAction)); }
/// <summary> /// Lists the drafts in the user's inbox. /// </summary> /// <param name="service">Gmail API service instance</param> /// <returns>A list of Drafts</returns> public static async Task <IList <Draft> > ListAsync(this DraftService service) { DraftList draftIds = await service.ListIdsAsync(); var tasks = draftIds.Drafts.Select(async draft => (await service.GetAsync(draft.Id))); return((await Task.WhenAll(tasks)).ToList()); }
/// <summary> /// Access to all Gmail services. /// </summary> /// <param name="accountCredential">The Google Account Credentials</param> /// <param name="emailAddress">The emailaddress of the user to impersonate</param> /// <param name="scopes">The required Gmail scopes, separated by space</param> public GmailClient(ServiceAccountCredential accountCredential, string emailAddress, string scopes) { _proxy = new GmailProxy(new AuthorizationDelegatingHandler(accountCredential, emailAddress, scopes)); Messages = new MessageService(_proxy); Drafts = new DraftService(_proxy); Labels = new LabelService(_proxy); Threads = new ThreadService(_proxy); History = new HistoryService(_proxy); }
public DraftServiceTest() { _draftRepositoryMock = new Mock <IDraftRepository>(); _contentRepositoryMock = new Mock <IContentRepository>(); _draftRelationshipRepositoryMock = new Mock <IDraftRelationshipRepository>(); _draftService = new DraftService( _draftRepositoryMock.Object, _contentRepositoryMock.Object, _draftRelationshipRepositoryMock.Object); }
public LeagueManagerController(FantasyCriticUserManager userManager, FantasyCriticService fantasyCriticService, InterLeagueService interLeagueService, LeagueMemberService leagueMemberService, DraftService draftService, PublisherService publisherService, IClock clock, IHubContext <UpdateHub> hubContext, EmailSendingService emailSendingService, GameAcquisitionService gameAcquisitionService) : base(userManager, fantasyCriticService, interLeagueService, leagueMemberService) { _draftService = draftService; _publisherService = publisherService; _clock = clock; _hubContext = hubContext; _emailSendingService = emailSendingService; _gameAcquisitionService = gameAcquisitionService; }
private void TimerBackup_Tick(object sender, EventArgs e) { _backupTimeSpan = _backupTimeSpan.Add(new TimeSpan(0, 0, 0, 1)); if (!(_backupTimeSpan.TotalMinutes > 10)) { return; } DraftService.Save(new DraftModel { StartDateTime = StaticAssets.StartDateTime, Duration = StaticAssets.Duration }); _backupTimeSpan = new TimeSpan(0, 0, 0, 0); }
private void FormMain_FormClosed(object sender, FormClosedEventArgs e) { KeyLogger.Stop(); if (StaticAssets.StopDateTime <= DateTime.MinValue) { StaticAssets.StopDateTime = DateTime.Now; } DraftService.Save(new DraftModel { StartDateTime = StaticAssets.StartDateTime, StopDateTime = StaticAssets.StopDateTime, Duration = StaticAssets.Duration }); }
public LeagueManagerController(FantasyCriticUserManager userManager, FantasyCriticService fantasyCriticService, InterLeagueService interLeagueService, LeagueMemberService leagueMemberService, DraftService draftService, PublisherService publisherService, IClock clock, IHubContext <UpdateHub> hubContext, IEmailSender emailSender, GameAcquisitionService gameAcquisitionService) { _userManager = userManager; _fantasyCriticService = fantasyCriticService; _interLeagueService = interLeagueService; _leagueMemberService = leagueMemberService; _draftService = draftService; _publisherService = publisherService; _clock = clock; _hubContext = hubContext; _emailSender = emailSender; _gameAcquisitionService = gameAcquisitionService; }
private void ButtonStop_Click(object sender, EventArgs e) { DisableDeactivateOperation = true; if (MessageBox.Show(this, @"Are you sure to stop timer?", @"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } StopTimers(); DraftService.Save(new DraftModel { StartDateTime = StaticAssets.StartDateTime, StopDateTime = StaticAssets.StopDateTime, Duration = StaticAssets.Duration }); }
private void ButtonReset_Click(object sender, EventArgs e) { DisableDeactivateOperation = true; if (MessageBox.Show(this, @"Are you sure to reset timer?", @"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes) { return; } StaticAssets.Duration = new TimeSpan(0, 0, 0, 0); labelDuration.Text = "00:00:00"; toolStripMenuItemTime.Text = "00:00:00"; labelStartFrom.Text = ""; if (_isTimerStarted) { StaticAssets.StartDateTime = DateTime.Now; labelStartFrom.Text = StaticAssets.StartDateTime.ToStandardString(); } DraftService.Clear(); }
/// <summary> /// Creates a test draft for running further tests. /// </summary> /// <param name="user">The AdWords user.</param> /// <param name="baseCampaignId">The base campaign ID for the draft.</param> /// <returns>The draft.</returns> /// <remarks>We are returning the Draft itself, since there's no way to get /// the draft campaign ID given a draft ID.</remarks> public Draft AddDraft(AdWordsUser user, long baseCampaignId) { // Get the DraftService. DraftService draftService = (DraftService)user.GetService( AdWordsService.v201607.DraftService); Draft draft = new Draft() { baseCampaignId = baseCampaignId, draftName = "Test Draft #" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffffff") }; DraftOperation draftOperation = new DraftOperation() { @operator = Operator.ADD, operand = draft }; return(draftService.mutate(new DraftOperation[] { draftOperation }).value[0]); }
/// <summary> /// Create a draft. /// </summary> /// <param name="service">Gmail API service instance</param> /// <param name="subject">The subject of the draft</param> /// <param name="body">The body of the draft</param> /// <returns></returns> public static async Task <Draft> CreateAsync(this DraftService service, string subject, string body) { Draft draftInput = new Draft { Message = new Message { Snippet = subject, PlainRaw = body.ToBase64UrlString(),//TODO: HTML headers Payload = { Headers = { new Header { Name = "Content-Type", Value = "text/html" } }, MimeType = "text/html" } } }; return(await service.CreateAsync(draftInput)); }
private void LoadSavedDraft() { var draftModel = DraftService.GetDraftModel(); if (draftModel == null) { return; } if (draftModel.StartDateTime > DateTime.MinValue) { StaticAssets.StartDateTime = draftModel.StartDateTime; SetLabelStartFromText(); } if (draftModel.StopDateTime > DateTime.MinValue) { StaticAssets.StopDateTime = draftModel.StopDateTime; } if (draftModel.Duration > TimeSpan.MinValue) { StaticAssets.Duration = draftModel.Duration; SetLabelDurationText(); } ChangeButtonStatus(); }
/// <summary> /// 删除草稿 /// </summary> /// <param name="ids"></param> /// <returns></returns> public static int DeleteDraftById(string ids) { return(DraftService.DeleteDraftById(ids)); }
/// <summary> /// 添加草稿 /// </summary> /// <param name="d"></param> /// <returns></returns> public static int InsertDraft(Draft d) { return(DraftService.InsertDraft(d)); }
/// <summary> /// 根据编号查询草稿 /// </summary> /// <param name="id"></param> /// <returns></returns> public static Draft SelectDraftById(int id) { return(DraftService.SelectDraftById(id)); }
/// <summary> /// 查询草稿总数量与页数 /// </summary> /// <param name="user"></param> /// <param name="count"></param> /// <param name="pageCount"></param> /// <returns></returns> public static string SelectAddGraftCountAndpageCountByUser(string user, out int count, out int pageCount) { return(DraftService.SelectAddGraftCountAndpageCountByUser(user, out count, out pageCount)); }
/// <summary> /// 查询用户所有草稿 /// </summary> /// <param name="user"></param> /// <returns></returns> public static List <Draft> SelectAllGraftByUser(int pageIndex, string user) { return(DraftService.SelectAllGraftByUser(pageIndex, user)); }
public DraftListTests() { _proxy = SettingsManager.GetGmailProxy(); _service = new DraftService(_proxy); }
public AttachmentGetTests() { _proxy = SettingsManager.GetGmailProxy(); _service = new AttachmentService(_proxy); _draftService = new DraftService(_proxy); }
public DraftController() { this.draftService = new DraftService(); }
public CubeHub() { _draftService = new DraftService(_db); }