protected void Page_Load(object sender, EventArgs e) { int userId = Int32.Parse(Request.Form["userid"].ToString()); DataTable dt = SyncHelper.SyncGetDeleteListWeb(userId); string result = "{"; if (dt.Rows.Count > 0) { result += "\"deletelist\":["; for (int i = 0; i < dt.Rows.Count; i++) { result += "{\"itemid\":\"" + dt.Rows[i]["ItemID"].ToString() + "\","; result += "\"itemappid\":\"" + dt.Rows[i]["ItemAppID"].ToString() + "\"},"; } result = result.Substring(0, result.Length - 1); result += "]"; } else { result += "\"deletelist\":[]"; } result += "}"; Response.Write(result); Response.End(); }
private bool TryToUpdateFiles() { Log.Append("TryToUpdateFiles() - enter"); if (!File.Exists(downloadsSchemaPath)) { Starter.SetUpdateExistingStatus(false); Log.Append("if ( !File.Exists( downloadsSchemaPath ) )"); return(true); } bool possibilityToChangeFilesToNewVersion = !Starter.SolutionExecuting && SyncHelper.EnterMutex(Starter.RunSolutionMutex, TRY_TO_UPDATE_FILES_TIME_OUT); Log.Append("possibilityToChangeFilesToNewVersion = " + possibilityToChangeFilesToNewVersion.ToString()); if (possibilityToChangeFilesToNewVersion) { bool filesUpdated = UpdateFiles(); SyncHelper.ExitMutex(Starter.RunSolutionMutex); return(filesUpdated); } else { Starter.SetUpdateExistingStatus(true, GetDownloadedUpdateNumber()); return(false); } }
void SearchCriteriaChanged(object sender, EventArgs e) { SyncHelper.CancelAndDispose(ref _Bar._cancellationSource, true); _Menu.ItemsSource = null; _Menu.Clear(); var s = _FinderBox.Text; if (s.Length == 0) { _Menu.ContainerType = SymbolListType.NodeList; ShowNamespaceAndTypeMenu(); return; } _Menu.ContainerType = SymbolListType.None; try { switch (_ScopeBox.Filter) { case ScopeType.ActiveDocument: FindInDocument(s); break; case ScopeType.ActiveProject: FindInProject(s); break; } _Menu.RefreshItemsSource(); _Menu.UpdateLayout(); } catch (OperationCanceledException) { // ignores cancellation } catch (ObjectDisposedException) { } }
private async void Initialize() { bool exist = await ApplicationData.Current.LocalFolder.FileExistsAsync("db.sqlite"); if (!exist) { await SyncHelper.CopyDbFileFromOneDrive(); } DalBase.CreateBackup(); DalBase.CreateDb(); DalBase.ConvertCategories(); DalBase.CheckDefaultCategory(); DalBase.AddItemsIfEmpty(); ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(360, 530)); SetTitleBar(); if (OperationsAppBarRadioButton != null) { OperationsAppBarRadioButton.IsChecked = true; } if (Strona_glowna_ListBoxItem != null) { Strona_glowna_ListBoxItem.IsChecked = true; } WhatsNewMessageDialog.CheckForNewerAppVersion(); SyncHelper.CheckSyncBase(); }
private DataTable GetFromWizardApprovedDate() { SqlConnection con = SyncHelper.WizardProductionConnection(); SqlCommand com = new SqlCommand(); SqlDataAdapter ad = new SqlDataAdapter(com); System.Text.StringBuilder sql = new System.Text.StringBuilder(); sql.AppendLine("SELECT [RefNumber],[Status],[StatusDate]"); sql.AppendLine("FROM [Production].[dbo].[tbRefStatusHist]"); sql.AppendLine("where YEAR(StatusDate) =" + DateTime.Now.Year + " AND Status = 'PMA'"); //sql.AppendLine("where Status = 'PMA'"); com.CommandText = sql.ToString(); com.CommandType = CommandType.Text; com.Connection = con; com.CommandTimeout = int.MaxValue; con.Open(); try { DataTable dt = new DataTable(); ad.Fill(dt); return(dt); } catch (Exception ex) { throw; } finally { con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { int userId = Int32.Parse(Request.Form["userid"].ToString()); DataTable dt = SyncHelper.SyncGetCardWeb(userId); string result = "{"; if (dt.Rows.Count > 0) { result += "\"cardlist\":["; for (int i = 0; i < dt.Rows.Count; i++) { result += "{\"cardid\":\"" + dt.Rows[i]["CardID"].ToString() + "\","; result += "\"cardname\":\"" + dt.Rows[i]["CardName"].ToString() + "\","; result += "\"cardmoney\":\"" + dt.Rows[i]["CardMoney"].ToString() + "\","; result += "\"cardlive\":\"" + dt.Rows[i]["CardLive"].ToString() + "\"},"; } result = result.Substring(0, result.Length - 1); result += "]"; } else { result += "\"cardlist\":[]"; } result += "}"; Response.Write(result); Response.End(); }
public Response altaPromociones(Root json, Token token) { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); var configuration = builder.Build(); postCardAssignCatalog postCardAssign; Response responseContent; postCardAssign = new postCardAssignCatalog(); string AltaPromociones = string.Empty; AltaPromociones = configuration["AltaPromociones"]; try { var jsonString = JsonConvert.SerializeObject(json); var data = new StringContent(jsonString, Encoding.UTF8, "application/json"); responseContent = SyncHelper.RunSync <Response>(() => postCardAssign.postCardAssingCatalogAsync(data, AltaPromociones, token)); return(responseContent); } catch (Exception ex) { throw ex; } }
private void ExecuteSyncCommand() { Task.Run(() => { if (!SyncHelper.HasConnection()) { Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = true, Message = "No network. Unable to sync." }); System.Threading.Thread.Sleep(3000); Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = false, Message = "" }); return; } Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = true, Message = "Syncing..." }); if (PBISyncHelper.IsRunning) { PBISyncHelper.WaitForCompletion(); } PBISyncHelper.RunSync(); PBISyncHelper.WaitForCompletion(); Messenger.Default.Send <BusyMessage>(new BusyMessage { IsBusy = false, Message = "" }); }); }
private void timer1_Tick(object sender, EventArgs e) { if (_Sync == null) { this.simpleButtonChiusura.Enabled = false; this.simpleButtonForza.Enabled = false; this.marqueeProgressBarControl1.Properties.Stopped = false; _Sync = new SyncHelper(); _Sync.GoSync(); } else { if (_Sync != null && _Sync.SyncFinished && !_Sync.ResultProcessed) { _Sync.End(); if (_Sync.Result) { DialogResult = DialogResult.OK; } else { // retry or quit this.marqueeProgressBarControl1.Properties.Stopped = true; this.simpleButtonChiusura.Enabled = true; this.simpleButtonForza.Enabled = true; XtraMessageBox.Show("Errore durante la chiusura del programma.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public void TestMethod1() { var syncHelper = new SyncHelper(); syncHelper.Add(StoreType.Excel, 1, "Title 1e", "InternalId 1e", DateTime.Now); syncHelper.Add(StoreType.Excel, 2, "Title 2e", "InternalId 2e", DateTime.Now); syncHelper.Add(StoreType.Excel, 3, "Title 3e", "InternalId 3e", DateTime.Now); syncHelper.Add(StoreType.Outlook, 1, "Title 1o", "InternalId 1o", new DateTime(2005, 1, 1)); syncHelper.Add(StoreType.Outlook, 2, "Title 2o", "InternalId 2o", new DateTime(2025, 1, 1)); syncHelper.Add(StoreType.Outlook, 4, "Title 4o", "InternalId 4o", new DateTime(2025, 1, 1)); var result = syncHelper.GenerateSyncDictionary(); Assert.AreEqual(4, result.Count); Assert.AreEqual(OperationType.ToOutlook, result[1].OperationType); Assert.AreEqual("Title 1e", result[1].TfsActivity.Title); Assert.AreEqual(OperationType.ToExcel, result[2].OperationType); Assert.AreEqual("Title 2o", result[2].TfsActivity.Title); Assert.AreEqual(OperationType.NewToOutlook, result[3].OperationType); Assert.AreEqual("Title 3e", result[3].TfsActivity.Title); Assert.AreEqual(OperationType.NewToExcel, result[4].OperationType); Assert.AreEqual("Title 4o", result[4].TfsActivity.Title); }
internal static void FindReferrers(this SemanticContext context, ISymbol symbol, Predicate <ISymbol> definitionFilter = null, Predicate <SyntaxNode> nodeFilter = null) { var referrers = SyncHelper.RunSync(() => symbol.FindReferrersAsync(context.Document.Project, definitionFilter, nodeFilter)); if (referrers == null) { return; } var m = new SymbolMenu(context, SymbolListType.SymbolReferrers); m.Title.SetGlyph(ThemeHelper.GetImage(symbol.GetImageId())) .Append(symbol.ToDisplayString(CodeAnalysisHelper.MemberNameFormat), true) .Append(R.T_Referrers); var containerType = symbol.ContainingType; foreach (var(referrer, occurance) in referrers) { var s = referrer; var i = m.Menu.Add(s, false); i.Location = occurance.FirstOrDefault().Item2.Location; foreach (var item in occurance) { i.Usage |= item.Item1; } if (s.ContainingType != containerType) { i.Hint = (s.ContainingType ?? s).ToDisplayString(CodeAnalysisHelper.MemberNameFormat); } } m.Menu.ExtIconProvider = ExtIconProvider.Default.GetExtIconsWithUsage; m.Show(); }
void ViewClosed(object sender, EventArgs e) { _View.Selection.SelectionChanged -= Update; _View.TextBuffer.Changed -= TextBuffer_Changed; SyncHelper.CancelAndDispose(ref _cancellationSource, false); _View.Closed -= ViewClosed; }
public RClient(Uri uri, int timeOut = 3000) { if (string.IsNullOrEmpty(uri.Scheme) || string.Compare(uri.Scheme, "rpc", true) != 0) { ExceptionCollector.Add("Consumer.RClient.Init Error", new RPCSocketException("当前连接协议不正确,请使用格式rpc://ip:port")); return; } _timeOut = timeOut; _syncHelper = new SyncHelper <byte[]>(_timeOut); var ipPort = DNSHelper.GetIPPort(uri); _RContext = new RContext(); SocketOptionBuilder builder = SocketOptionBuilder.Instance; var option = builder.SetSocket() .UseIocp(_RContext) .SetIP(ipPort.Item1) .SetPort(ipPort.Item2) .SetReadBufferSize() .SetWriteBufferSize() .SetTimeOut(_timeOut) .Build(); _client = SocketFactory.CreateClientSocket(option); _client.OnReceive += OnReceived; _client.OnDisconnected += _client_OnDisConnected; }
private DataTable GetWizardApprovedDate() { SqlConnection con = SyncHelper.NewWizardConnection(); SqlCommand com = new SqlCommand(); SqlDataAdapter ad = new SqlDataAdapter(com); System.Text.StringBuilder sql = new System.Text.StringBuilder(); sql.AppendLine("SELECT FileID, CONVERT(nvarchar,AppLtrDate,103) AS 'AppLtrDate' "); //* ModifiedDate refer as MSCApprovalDate sql.AppendLine("FROM Wizard_EIRAppLtrDatesView"); com.CommandText = sql.ToString(); com.CommandType = CommandType.Text; com.Connection = con; com.CommandTimeout = int.MaxValue; con.Open(); try { DataTable dt = new DataTable(); ad.Fill(dt); return(dt); } catch (Exception ex) { throw; } finally { con.Close(); } }
private void startPump() { // Start the message loop mSyncProvider = new SyncHelper(mStart); mSyncProvider.Completed += mSyncProvider_Completed; Application.Run(mSyncProvider); }
private static Guid GetAccountTypeCID(Guid AccountID) { SqlConnection con = SyncHelper.NewCRMConnection(); SqlCommand com = new SqlCommand(); SqlDataAdapter ad = new SqlDataAdapter(com); System.Text.StringBuilder sql = new System.Text.StringBuilder(); sql.AppendLine("SELECT AccountTypeCID FROM Account WHERE AccountID = @AccountID"); com.CommandText = sql.ToString(); com.CommandType = CommandType.Text; com.Connection = con; com.CommandTimeout = int.MaxValue; try { con.Open(); com.Parameters.Add(new SqlParameter("@AccountID", AccountID)); DataTable dt = new DataTable(); ad.Fill(dt); return(new Guid(dt.Rows[0][0].ToString())); } catch (Exception ex) { throw; } finally { con.Close(); } }
[ExcludeFromCodeCoverage] //excluded from code coverage since this class is a 1 liner that starts up a background thread public virtual void CreateAndStart(Action action) { SyncHelper.ExecuteSafely(sync, () => spanProcessorTaskInstance == null || spanProcessorTaskInstance.Status == TaskStatus.Faulted, () => { spanProcessorTaskInstance = Task.Factory.StartNew(() => ActionWrapper(action), cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }); }
public override void onReleaseSkillSuccess(int skillId) { Message msg = new Message(MsgCmd.On_Skill_Release_Success, this); msg["skillId"] = skillId; msg.Send(); SyncHelper.syncSkill(this.UID, skillId); }
public override async Task ExecuteSteps(UnitOfWork uow, DateTime lastSyncTime) { await SyncHelper.SyncLoadScans(uow, this.Token); await SyncHelper.SyncTrucksTable(this.Token, uow); await SyncHelper.SyncModuleOwnershipTable(uow, lastSyncTime, this.Token); }
public void Dispose() { IsVisibleChanged -= _MemberMarker.OnIsVisibleChanged; Config.Updated -= Config_Updated; _MemberMarker.Dispose(); _SymbolReferenceMarker.Dispose(); SyncHelper.CancelAndDispose(ref _Cancellation, false); }
protected void Page_Load(object sender, EventArgs e) { int userId = Int32.Parse(Request.Form["userid"].ToString()); string userName = Request.Form["username"].ToString(); string userPassword = Request.Form["userpass"].ToString(); string userNickName = Request.Form["nickname"].ToString(); string userEmail = Request.Form["useremail"].ToString(); string userImage = Request.Form["userimage"].ToString(); string userFrom = Request.Form["userfrom"].ToString(); string userWorkDay = Request.Form["userworkday"].ToString(); string categoryRate = Request.Form["categoryrate"] ?? ""; if (userFrom.Length > 5) { userFrom = userFrom.Replace("_", ""); userFrom = userFrom.Insert(5, "_"); } UserEntity user = UserAccess.GetUserById(userId); user.UserName = userName; user.UserPassword = userPassword; user.UserNickName = userNickName; user.UserImage = userImage; user.UserEmail = userEmail; user.UserFrom = userFrom; user.UserWorkDay = userWorkDay; if (categoryRate != "") { user.CategoryRate = Double.Parse(categoryRate); } string result = "{"; bool login = SyncHelper.SyncCheckUserLogin(userName, userId); if (login) { result += UpdateUserInfo(user); } else { bool repeat = UserAccess.CheckUserRepeat(userName); if (repeat) { result += "\"result\":\"2\""; } else { result += UpdateUserInfo(user); } } result += "}"; Response.Write(result); Response.End(); }
public Task Stop() { return(SyncHelper.ExecuteSafelyAsync(_syncObj, () => IsStarted, () => { _spanProcessorTask.Stop(); IsStarted = false; return LogSubmittedSpans(); })); }
public Task Start() { SyncHelper.ExecuteSafely(_syncObj, () => !IsStarted, () => { _spanProcessorTask.Start(LogSubmittedSpans); IsStarted = true; }); return(Task.CompletedTask); }
static SpanCollector GetInstance(Uri uri, uint maxProcessorBatchSize) { SyncHelper.ExecuteSafely(syncObj, () => instance == null, () => { instance = new SpanCollector(uri, maxProcessorBatchSize); }); return(instance); }
protected void SyncIfNecessary() { if (PuckCache.ShouldSync && !PuckCache.IsSyncQueued) { PuckCache.IsSyncQueued = true; //was using HostingEnvironment.QueueBackgroundWorkItem and passing in cancellation token //can't do that in asp.net core so passing in a new cancellation token which is a bit pointless System.Threading.Tasks.Task.Factory.StartNew(() => SyncHelper.Sync(new CancellationToken())); } }
public void Should_server_close_client_connection() { using (var server = StartServer()) using (var client = OpenClientConnection()) { server.ActiveConnections.Single().Dispose(); SyncHelper.WaitUntil(() => !client.IsOpen); SyncHelper.WaitUntil(() => !server.ActiveConnections.Any()); } }
static void Main(string[] args) { var ver = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion; Console.Title = $"File Storage Sync Tool {ver}"; Console.WriteLine(ConsoleHelper.Header(ver)); var syncHelper = new SyncHelper(ItemClass.File, m_isDebug); syncHelper.SyncFileStorage(); }
protected void Page_Load(object sender, EventArgs e) { string openId = Request.Form["openid"].ToString(); string accessToken = Request.Form["accesstoken"].ToString(); string oAuthFrom = Request.Form["oauthfrom"].ToString(); int userId = Int32.Parse(Request.Form["userid"].ToString()); OAuthEntity oAuth = new OAuthEntity(); oAuth.OpenID = openId; oAuth.AccessToken = accessToken; oAuth.User = UserAccess.GetUserById(userId); oAuth.OAuthFrom = oAuthFrom; oAuth.OAuthBound = 1; string result = "{"; bool success = false; int bound = OAuthAccess.CheckOAuthBoundByOpenId(oAuth.OpenID); if (bound == 2) { success = SyncHelper.SyncInsertOAuth(oAuth); if (success) { result += "\"result\":\"1\""; } else { result += "\"result\":\"0\""; } } else if (bound == 0) { oAuth.OAuthBound = 1; success = SyncHelper.SyncUpdateOAuth(oAuth); if (success) { result += "\"result\":\"1\""; } else { result += "\"result\":\"0\""; } } else { result += "\"result\":\"2\""; } result += "}"; Response.Write(result); Response.End(); }
private void UpdateItemsInfo() { SyncHelper.UpdateAll().GetAwaiter().OnCompleted(() => { (Items.Find(x => x is ResinHomeItem) as ResinHomeItem)?.UpdateInfo(); (Items.Find(x => x is RealmCurrencyHomeItem) as RealmCurrencyHomeItem)?.UpdateInfo(); (Items.Find(x => x is ExpeditionHomeItem) as ExpeditionHomeItem)?.UpdateInfo <ExpeditionNoti>(); Utils.RefreshCollectionView(ListCollectionView, Items); }); }
public void Release() { if (--_refCount == 0) { _buffer.Changed -= OnChanged; //Stop and blow away the old scan (even if it didn't finish, the results are not interesting anymore). SyncHelper.CancelAndDispose(ref _Cancellation, false); _root = null; //Allow the old root to be GC'd } }
public Helper(SyncHelper parent) { this.parent = parent; zooKeeperHandle = parent.zooKeeperHandle; connectionString = parent.connectionString; }