/// <summary> /// Cria o comando de salvamento de alterações para o <see cref="ConnectorBase"/> /// especificado. /// </summary> /// <param name="conn">O <see cref="ConnectorBase"/> a ter seus dados salvos.</param> /// <param name="dbConn">A conexão a ser utilizada</param> /// <param name="trans">A transação ativa</param> public CommitChangesCommand(ConnectorBase conn, AdpConnection dbConn, AdpTransaction trans) : this(conn) { this.disposeDBObjects = false; this.dbConn = dbConn; this.trans = trans; }
static public void UserLoggedIn(Int64 AppUserId, DateTime PreviousLastLogin) { DateTime dateTime = DateTime.UtcNow; if (PreviousLastLogin.Year == dateTime.Year && PreviousLastLogin.Month == dateTime.Month && PreviousLastLogin.Day == dateTime.Day && PreviousLastLogin.Hour == dateTime.Hour) { return; } try { using (ConnectorBase conn = ConnectorBase.NewInstance()) { //dateTime = dateTime.AddMilliseconds(-dateTime.Millisecond).AddSeconds(-dateTime.Second).AddMinutes(-dateTime.Minute); //Query qryUpdate = Query.New<AppUserHourlyActivity>() // .Update(AppUserHourlyActivity.Columns.ActiveUsers, conn.EncloseFieldName(AppUserHourlyActivity.Columns.ActiveUsers) + @"+" + 1) // .Where(AppUserHourlyActivity.Columns.Date, dateTime); //if (qryUpdate.Execute(conn) == 0) //{ // Query qryInsert = Query.New<AppUserHourlyActivity>() // .Insert(AppUserHourlyActivity.Columns.ActiveUsers, conn.EncloseFieldName(AppUserHourlyActivity.Columns.ActiveUsers) + @"+" + 1) // .Insert(AppUserHourlyActivity.Columns.Date, dateTime); // try // { // qryInsert.Execute(); // } // catch // { // qryUpdate.Execute(); // } //} } } catch { } }
public override void Insert(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Insert(Columns.Name, Name); qry.Insert(Columns.Rate, Rate); qry.Insert(Columns.Content, Content); qry.Insert(Columns.AppUserId, AppUserId); qry.Insert(Columns.SupplierId, SupplierId); qry.Insert(Columns.BidId, BidId); qry.Insert(Columns.Status, Status); qry.Insert(Columns.CreateDate, CreateDate); qry.Insert(Columns.ApproveDate, ApproveDate); object lastInsert = null; if (qry.Execute(conn, out lastInsert) > 0) { CommentId = Convert.ToInt64((lastInsert)); MarkOld(); } }
public void CollapseSubNodes(bool clickednode) { IGraphNode thisNode = this as IGraphNode; if (thisNode != null) { ICollection edgesLeaving = thisNode.EdgesLeaving; if (edgesLeaving != null) { // Convert to collection of IGraphEdges type. foreach (IGraphEdge curEdge in edgesLeaving) { // Get from IGraphEdge link. ConnectorBase outlink = curEdge as ConnectorBase; if (outlink != null) { // Set connected link as invisible too. Node node1 = outlink.ToNode as Node; if (node1 != null) { // Set current symbol as invisible. node1.Visible = false; } outlink.Visible = false; } } } } // If this symbol is node under mouse click set node state as // expaned by make plus vertical line visibly. if (clickednode && HasChild()) { // Set symbol shapes to indicate a collapsed state. m_bExpanded = false; } }
public override void Insert(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Insert(Columns.IsDiscount, IsDiscount); qry.Insert(Columns.PrecentDiscount, PrecentDiscount); qry.Insert(Columns.IsGift, IsGift); qry.Insert(Columns.CampaignName, CampaignName); qry.Insert(Columns.Remarks, Remarks); qry.Insert(Columns.StartDate, StartDate); qry.Insert(Columns.EndDate, EndDate); qry.Insert(Columns.DestinationCount, DestinationCount); qry.Insert(Columns.DestinationSum, DestinationSum); qry.Insert(Columns.ImplemationCount, ImplemationCount); object lastInsert = null; if (qry.Execute(conn, out lastInsert) > 0) { CampaignId = Convert.ToInt64((lastInsert)); MarkOld(); } }
public ClientMonitoringModel() { _nameToNode = new Dictionary <string, MonitoringNodeBase>(); Nodes = new ObservableCollection <MonitoringNodeBase>(); Products = new ObservableCollection <ProductViewModel>(); _connectionAddress = $"{ConfigProvider.Instance.ConnectionInfo.Address}:{ConfigProvider.Instance.ConnectionInfo.Port}"; _sensorsClient = new GrpcClientConnector(_connectionAddress); _connectionsStatus = ConnectionsStatus.Init; _uiContext = SynchronizationContext.Current; if (IsClientCertificateDefault) { string defaultCAPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, CommonConstants.DefaultCertificatesFolderName, CommonConstants.DefaultCACrtCertificateName); X509Certificate2 defaultCA = new X509Certificate2(defaultCAPath); CertificatesProcessor.AddCertificateToTrustedRootCA(defaultCA); } StartTreeThread(); }
public override void Update(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Update(Columns.SpecialInstructions, SpecialInstructions); qry.Update(Columns.AppUserId, AppUserId); qry.Update(Columns.DonationId, DonationId); qry.Update(Columns.BidId, BidId); qry.Update(Columns.CampaignId, CampaignId); qry.Update(Columns.IsSendRecived, IsSendRecived); qry.Update(Columns.IsSendRateSupplier, IsSendRateSupplier); qry.Update(Columns.Last4Digits, Last4Digits); qry.Update(Columns.ExpiryDate, ExpiryDate); qry.Update(Columns.SupplierRemarks, SupplierRemarks); qry.Update(Columns.Transaction, Transaction); qry.Update(Columns.TransactionErrorMessage, TransactionErrorMessage); qry.Update(Columns.TransactionResponseCode, TransactionResponseCode); qry.Update(Columns.TransactionStatus, TransactionStatus); qry.Update(Columns.PaySupplierStatus, PaySupplierStatus); qry.Update(Columns.UserPaySupplierStatus, UserPaySupplierStatus); qry.Update(Columns.SuppliedDate, SuppliedDate); qry.Update(Columns.ReceivedDate, ReceivedDate); qry.Update(Columns.TotalPrice, TotalPrice); qry.Update(Columns.PriceAfterDiscount, PriceAfterDiscount); qry.Update(Columns.PrecentDiscount, PrecentDiscount); qry.Update(Columns.Remarks, Remarks); qry.Update(Columns.CreateDate, CreateDate); qry.Update(Columns.SupplierId, SupplierId); qry.Update(Columns.Gifts, Gifts); qry.Update(Columns.AuthNumber, AuthNumber); qry.Update(Columns.NumOfPayments, NumOfPayments); qry.Where(Columns.OrderId, OrderId); Helpers.LogState(this); qry.Execute(conn); }
public override void Update(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Update(Columns.Email, Email); qry.Update(Columns.UniqueIdString, UniqueIdString); qry.Update(Columns.LastLogin, LastLogin); qry.Update(Columns.CreateDate, CreateDate); qry.Update(Columns.IsLocked, IsLocked); qry.Update(Columns.IsVerified, IsVerified); qry.Update(Columns.BadLoginTries, BadLoginTries); qry.Update(Columns.FacebookId, FacebookId); qry.Update(Columns.FacebookToken, FacebookToken); qry.Update(Columns.Password, Password); qry.Update(Columns.PasswordSalt, PasswordSalt); qry.Update(Columns.PasswordRecoveryKey, PasswordRecoveryKey); qry.Update(Columns.PasswordRecoveryDate, PasswordRecoveryDate); qry.Update(Columns.LangCode, LangCode); qry.Update(Columns.Gender, Gender); qry.Update(Columns.UnreadNotificationCount, UnreadNotificationCount); qry.Update(Columns.ProfileImage, ProfileImage); qry.Update(Columns.FirstName, FirstName); qry.Update(Columns.LastName, LastName); qry.Update(Columns.HouseNum, HouseNum); qry.Update(Columns.Street, Street); qry.Update(Columns.CityId, CityId); qry.Update(Columns.ApartmentNumber, ApartmentNumber); qry.Update(Columns.Phone, Phone); qry.Update(Columns.Floor, Floor); qry.Update(Columns.AddressLocation, AddressLocation); qry.Update(Columns.IsAdv, IsAdv); qry.Update(Columns.IsDeleted, IsDeleted); qry.Update(Columns.OrderDisplay, OrderDisplay); qry.Where(Columns.AppUserId, AppUserId); qry.Execute(conn); }
public override void Insert(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Insert(Columns.ToList, ToList); qry.Insert(Columns.CcList, CcList); qry.Insert(Columns.BccList, BccList); qry.Insert(Columns.FromName, FromName); qry.Insert(Columns.FromEmail, FromEmail); qry.Insert(Columns.MailPriority, (Int32)MailPriority); qry.Insert(Columns.Subject, Subject); qry.Insert(Columns.Body, Body); qry.Insert(Columns.DeliveryDate, DeliveryDate); qry.Insert(Columns.Status, Status); qry.Insert(Columns.Exception, Exception); object lastInsert = null; if (qry.Execute(conn, out lastInsert) > 0) { EmailLogId = Convert.ToInt64((lastInsert)); MarkOld(); } }
protected override void ProcessPOST(ConnectorBase Connector, Package package) { try { DataItemAdded todoAdded = XmlSerializationHelper.Desirialize <DataItemAdded>(package.Data); Todo newTodo = new Todo() { pId = todoAdded.PK }; if (newTodo.pId == null) { newTodo.pId = Guid.NewGuid(); } lock (dataListLock) { dataList.Add(newTodo.pId, newTodo); } } catch (Exception ex) { RaiseLogEvent(LogType.Error, "TodoNetList.ProcessPOST()" + ex.Message); } //base.ProcessPOST(t14Lab.MessageTree.Connector, package); }
public override void Update(ConnectorBase conn) { Query qry = new Query(TableSchema); qry.Update(Columns.Name, Name); qry.Update(Columns.FromDate, FromDate); qry.Update(Columns.ToDate, ToDate); qry.Update(Columns.MinFrequency, MinFrequency); qry.Update(Columns.MaxFrequency, MaxFrequency); qry.Update(Columns.AreaId, AreaId); qry.Update(Columns.GroupId, Group); qry.Update(Columns.Priority, Priority); qry.Update(Columns.AnimalTypeId, AnimalTypeId); qry.Update(Columns.Deleted, Deleted); qry.Update(Columns.Created, Created); qry.Update(Columns.AdImageUrl, AdImageUrl); qry.Update(Columns.MessageTemplate, MessageTemplate); qry.Update(Columns.IsAuto, IsAuto); qry.Update(Columns.LastRun, LastRun); qry.Update(Columns.RunEvery, RunEvery); qry.Where(Columns.Id, Id); qry.Execute(conn); }
public static void UpdateUnreadNotificationCount(int Increment) { List <Int64> AppSuppliersIds = new List <Int64>(); using (ConnectorBase conn = ConnectorBase.NewInstance()) { Query q1 = Query.New <AppSupplierGcmToken>() .Select(AppSupplierGcmToken.Columns.SupplierId); using (DataReaderBase reader = q1.ExecuteReader()) { while (reader.Read()) { AppSuppliersIds.Add(Convert.ToInt64(reader.GetString(0))); } } } using (ConnectorBase conn = ConnectorBase.NewInstance()) { Query q2 = Query.New <AppSupplierAPNSToken>() .Select(AppSupplierAPNSToken.Columns.SupplierId); using (DataReaderBase reader = q2.ExecuteReader()) { while (reader.Read()) { AppSuppliersIds.Add(Convert.ToInt64(reader.GetString(0))); } } } AppSuppliersIds = AppSuppliersIds.Distinct().ToList(); Query.New <AppSupplier>() .Update(AppSupplier.Columns.UnreadNotificationCount, new dg.Sql.Phrases.Add(AppSupplier.Columns.UnreadNotificationCount, Increment)) .Where(AppSupplier.TableSchema.SchemaName, AppSupplier.Columns.SupplierId, WhereComparision.In, AppSuppliersIds) .Execute(); }
public static void GeneratePointsForLastCheckin( ConnectorBase conn, Int64 AppUserId, out CheckinPointsAction[] PointsGenerated) { object checkinsRes = Query.New <AppUserBalance>() .Select(AppUserBalance.Columns.Checkins) .Where(AppUserBalance.Columns.AppUserId, AppUserId) .ExecuteScalar(); if (checkinsRes.IsNull()) { PointsGenerated = null; return; } else { string pointsKey = null; AppUserPointsReason pointsReason = AppUserPointsReason.Unknown; int checkins = Convert.ToInt32(checkinsRes); switch (checkins) { case 10: pointsKey = Settings.PointsSettings.CHECKIN_10th; pointsReason = AppUserPointsReason.Checkin10th; break; case 25: pointsKey = Settings.PointsSettings.CHECKIN_25th; pointsReason = AppUserPointsReason.Checkin25th; break; case 50: pointsKey = Settings.PointsSettings.CHECKIN_50th; pointsReason = AppUserPointsReason.Checkin50th; break; case 75: pointsKey = Settings.PointsSettings.CHECKIN_75th; pointsReason = AppUserPointsReason.Checkin75th; break; case 100: pointsKey = Settings.PointsSettings.CHECKIN_100th; pointsReason = AppUserPointsReason.Checkin100th; break; case 250: pointsKey = Settings.PointsSettings.CHECKIN_250th; pointsReason = AppUserPointsReason.Checkin250th; break; case 500: pointsKey = Settings.PointsSettings.CHECKIN_500th; pointsReason = AppUserPointsReason.Checkin500th; break; case 750: pointsKey = Settings.PointsSettings.CHECKIN_750th; pointsReason = AppUserPointsReason.Checkin750th; break; case 1000: pointsKey = Settings.PointsSettings.CHECKIN_1000th; pointsReason = AppUserPointsReason.Checkin1000th; break; } List <CheckinPointsAction> pointsList = new List <CheckinPointsAction>(); pointsList.Add(new CheckinPointsAction(Settings.GetPoints(Settings.PointsSettings.CHECKIN), AppUserPointsReason.Checkin)); if (pointsKey != null) { pointsList.Add(new CheckinPointsAction(Settings.GetPoints(pointsKey), pointsReason)); } pointsList.RemoveAll((CheckinPointsAction action) => { return(action.Points == 0); }); foreach (CheckinPointsAction action in pointsList) { Query.New <AppUserPoints>() .Insert(AppUserPoints.Columns.AppUserId, AppUserId) .Insert(AppUserPoints.Columns.Date, DateTime.UtcNow) .Insert(AppUserPoints.Columns.Points, action.Points) .Insert(AppUserPoints.Columns.Reason, action.Reason) .Execute(); } PointsGenerated = pointsList.ToArray(); } }
public CommitTableChangesCommand(ConnectorBase conn, AdpConnection dbConn, AdpTransaction trans) : base(conn, dbConn, trans) { }
public static void Process(string coonnectionString, Filter filter, string logFile, CancellationToken ct) { try { ConnectorBase Connector = ConnectorFactory.CreateConnector(coonnectionString); Connector.Connect(); Package package; if (logFile != null && logFile != string.Empty) { logFileFileStream = new FileStream(logFile, FileMode.OpenOrCreate); logFileStreamWriter = new StreamWriter(logFileFileStream); } bool first = true; int packagesCount = 0; var sw = new Stopwatch(); while (true) { Thread.Sleep(1); while (Connector.Receive(out package)) { packagesCount++; if (first) { sw.Start(); first = false; } try { bool processMessage = filter.applyFilter(package); if (processMessage) { package.PrintToConsole(packagesCount, ConsoleColor.Green); if (logFileStreamWriter != null) { logFileStreamWriter.WriteLine("{0}", package.ToString()); } } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(string.Format("SendMessages Exception: {0}", ex.Message)); Console.ForegroundColor = ConsoleColor.Green; return; } if (packagesCount == 1000) { sw.Stop(); Console.WriteLine("{0} Packages in {1} Milliseconds ~ {2} packages per millisecond and {3} packages per second.", packagesCount, sw.ElapsedMilliseconds, packagesCount / sw.ElapsedMilliseconds, (packagesCount / sw.ElapsedMilliseconds) * 1000); } if (ct.IsCancellationRequested) { break; } } if (ct.IsCancellationRequested) { break; } } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console.ForegroundColor = ConsoleColor.Green; } return; }
void OnSceneGUI() { var e = Event.current; ConnectorBase connect = target as ConnectorBase; // override default control Tools.current = Tool.None; HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); if (e.type == EventType.MouseDown) { GameObject selection = GetSelectionAt(e.mousePosition); if (selection != null) { selectionPrev = selection; selectionNext = null; } } if (e.type == EventType.MouseDrag || e.type == EventType.MouseUp) { GameObject selection = GetSelectionAt(e.mousePosition); if (selection != null) { if (selectionPrev != selection) { selectionNext = selection; } } } if (e.type == EventType.MouseUp) { Undo.RecordObject(connect, "Point Connection"); if (selectionPrev != null && selectionNext != null) { Undo.SetTransformParent(connect.transform, selectionPrev.transform, "Point Connection"); Undo.RecordObject(connect.transform, "Point Connection"); connect.transform.localPosition = Vector3.zero; var p1 = selectionPrev.GetComponent <IConnectorPoint>(); var p2 = selectionNext.GetComponent <IConnectorPoint>(); Undo.RecordObject((MonoBehaviour)p1, "Point Connection"); Undo.RecordObject((MonoBehaviour)p2, "Point Connection"); if (p1 is PointController) { ((PointController)p1).important = true; } if (p2 is PointController) { ((PointController)p2).important = true; } EditorUtility.SetDirty((MonoBehaviour)p1); EditorUtility.SetDirty((MonoBehaviour)p2); Undo.RecordObject(connect, "Point Connection"); connect.connectionA = selectionPrev; connect.connectionB = selectionNext; EditorUtility.SetDirty(connect); } else { selectionPrev = connect.connectionA; selectionNext = connect.connectionB; } } if (selectionPrev != null && selectionNext != null) { Handles.DrawLine(selectionPrev.transform.position, selectionNext.transform.position); } Tools.current = Tool.None; Selection.activeGameObject = connect.gameObject; }
public ConnectorBaseProxy(object connectorBase) { ConnectorBase = connectorBase as ConnectorBase; }
public static void CreateOrUpgrade() { using (ConnectorBase conn = ConnectorBase.NewInstance()) { conn.BeginTransaction(); foreach (TableSchema schema in Schemas) { if (!conn.CheckIfTableExists(schema.SchemaName)) { try { new Query(schema).CreateTable().Execute(conn); } catch { } try { if (schema.Indexes.Count > 0 || schema.ForeignKeys.Count > 0) { conn.ExecuteScript(new Query(schema).CreateIndexes().ToString()); } } catch { } } else { foreach (TableSchema.Column col in schema.Columns) { try { new Query(schema).AddColumn(col).Execute(conn); } catch { } try { new Query(schema).ChangeColumn(col).Execute(conn); } catch { } } foreach (TableSchema.Index idx in schema.Indexes) { try { new Query(schema).CreateIndex(idx).Execute(conn); } catch { } } foreach (TableSchema.ForeignKey key in schema.ForeignKeys) { try { new Query(schema).CreateForeignKey(key).Execute(conn); } catch { } } } } foreach (string key in Permissions.SystemPermissionKeys) { try { if (PermissionCollection.Where(Permission.Columns.Key, key).Count == 0) { new Permission(key).Save(conn); } } catch { } } string dropTriggers = @" DROP TRIGGER IF EXISTS tg_trempmember_CountersInsert; DROP TRIGGER IF EXISTS tg_trempmember_CountersUpdate; DROP TRIGGER IF EXISTS tg_trempmember_CountersDelete; DROP TRIGGER IF EXISTS tg_trempjoinrequest_CountersInsert; DROP TRIGGER IF EXISTS tg_trempjoinrequest_CountersUpdate; DROP TRIGGER IF EXISTS tg_trempjoinrequest_CountersDelete; DROP TRIGGER IF EXISTS tg_groupmemberrequest_CountersInsert; DROP TRIGGER IF EXISTS tg_groupmemberrequest_CountersUpdate; DROP TRIGGER IF EXISTS tg_groupmemberrequest_CountersDelete; DROP TRIGGER IF EXISTS tg_groupadminrequest_CountersInsert; DROP TRIGGER IF EXISTS tg_groupadminrequest_CountersUpdate; DROP TRIGGER IF EXISTS tg_groupadminrequest_CountersDelete; DROP TRIGGER IF EXISTS tg_tremprequestmatch_CountersInsert; DROP TRIGGER IF EXISTS tg_tremprequestmatch_CountersUpdate; DROP TRIGGER IF EXISTS tg_tremprequestmatch_CountersDelete; DROP TRIGGER IF EXISTS tg_groupmember_CountersInsert; DROP TRIGGER IF EXISTS tg_groupmember_CountersUpdate; DROP TRIGGER IF EXISTS tg_groupmember_CountersDelete; DROP TRIGGER IF EXISTS tg_tremp_Insert; DROP TRIGGER IF EXISTS tg_tremp_Update; DROP TRIGGER IF EXISTS tg_tremp_Delete; DROP TRIGGER IF EXISTS tg_tremprequest_Insert; DROP TRIGGER IF EXISTS tg_tremprequest_Update; DROP TRIGGER IF EXISTS tg_tremprequest_Delete; "; string createTriggers = @" DELIMITER $$ CREATE TRIGGER tg_trempmember_CountersInsert AFTER INSERT ON tbl_trempmember FOR EACH ROW BEGIN set @TrempId=NEW.TrempId; UPDATE tbl_tremp SET BookedSeatsCount = BookedSeatsCount + 1 WHERE TrempId = @TrempId; END $$ CREATE TRIGGER tg_trempmember_CountersUpdate AFTER UPDATE ON tbl_trempmember FOR EACH ROW BEGIN set @TrempId=NEW.TrempId; set @OldTrempId=OLD.TrempId; IF (@TrempId <> @TrempId) THEN UPDATE tbl_tremp SET BookedSeatsCount = BookedSeatsCount - 1 WHERE TrempId = @OldTrempId; UPDATE tbl_tremp SET BookedSeatsCount = BookedSeatsCount + 1 WHERE TrempId = @TrempId; END IF; END $$ CREATE TRIGGER tg_trempmember_CountersDelete AFTER DELETE ON tbl_trempmember FOR EACH ROW BEGIN set @OldTrempId=OLD.TrempId; UPDATE tbl_tremp SET BookedSeatsCount = BookedSeatsCount - 1 WHERE TrempId = @OldTrempId; END $$ CREATE TRIGGER tg_trempjoinrequest_CountersInsert AFTER INSERT ON tbl_trempjoinrequest FOR EACH ROW BEGIN set @TrempId=NEW.TrempId; UPDATE tbl_tremp SET MemberRequestsCount = MemberRequestsCount + 1 WHERE TrempId = @TrempId; END $$ CREATE TRIGGER tg_trempjoinrequest_CountersUpdate AFTER UPDATE ON tbl_trempjoinrequest FOR EACH ROW BEGIN set @TrempId=NEW.TrempId; set @OldTrempId=OLD.TrempId; IF (@TrempId <> @TrempId) THEN UPDATE tbl_tremp SET MemberRequestsCount = MemberRequestsCount - 1 WHERE TrempId = @OldTrempId; UPDATE tbl_tremp SET MemberRequestsCount = MemberRequestsCount + 1 WHERE TrempId = @TrempId; END IF; END $$ CREATE TRIGGER tg_trempjoinrequest_CountersDelete AFTER DELETE ON tbl_trempjoinrequest FOR EACH ROW BEGIN set @OldTrempId=OLD.TrempId; UPDATE tbl_tremp SET MemberRequestsCount = MemberRequestsCount - 1 WHERE TrempId = @OldTrempId; END $$ CREATE TRIGGER tg_groupmemberrequest_CountersInsert AFTER INSERT ON tbl_groupmemberrequest FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; UPDATE tbl_group SET MemberRequestsCount = MemberRequestsCount + 1 WHERE GroupId = @GroupId; END $$ CREATE TRIGGER tg_groupmemberrequest_CountersUpdate AFTER UPDATE ON tbl_groupmemberrequest FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; set @OldGroupId=OLD.GroupId; IF (@GroupId <> @GroupId) THEN UPDATE tbl_group SET MemberRequestsCount = MemberRequestsCount - 1 WHERE GroupId = @OldGroupId; UPDATE tbl_group SET MemberRequestsCount = MemberRequestsCount + 1 WHERE GroupId = @GroupId; END IF; END $$ CREATE TRIGGER tg_groupmemberrequest_CountersDelete AFTER DELETE ON tbl_groupmemberrequest FOR EACH ROW BEGIN set @OldGroupId=OLD.GroupId; UPDATE tbl_group SET MemberRequestsCount = MemberRequestsCount - 1 WHERE GroupId = @OldGroupId; END $$ CREATE TRIGGER tg_groupadminrequest_CountersInsert AFTER INSERT ON tbl_groupadminrequest FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; UPDATE tbl_group SET AdminRequestsCount = AdminRequestsCount + 1 WHERE GroupId = @GroupId; END $$ CREATE TRIGGER tg_groupadminrequest_CountersUpdate AFTER UPDATE ON tbl_groupadminrequest FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; set @OldGroupId=OLD.GroupId; IF (@GroupId <> @GroupId) THEN UPDATE tbl_group SET AdminRequestsCount = AdminRequestsCount - 1 WHERE GroupId = @OldGroupId; UPDATE tbl_group SET AdminRequestsCount = AdminRequestsCount + 1 WHERE GroupId = @GroupId; END IF; END $$ CREATE TRIGGER tg_groupadminrequest_CountersDelete AFTER DELETE ON tbl_groupadminrequest FOR EACH ROW BEGIN set @OldGroupId=OLD.GroupId; UPDATE tbl_group SET AdminRequestsCount = AdminRequestsCount - 1 WHERE GroupId = @OldGroupId; END $$ CREATE TRIGGER tg_tremprequestmatch_CountersInsert AFTER INSERT ON tbl_tremprequestmatch FOR EACH ROW BEGIN set @TrempRequestId=NEW.TrempRequestId; UPDATE tbl_tremprequest SET FoundMatchesCount = FoundMatchesCount + 1 WHERE TrempRequestId = @TrempRequestId; END $$ CREATE TRIGGER tg_tremprequestmatch_CountersUpdate AFTER UPDATE ON tbl_tremprequestmatch FOR EACH ROW BEGIN set @TrempRequestId=NEW.TrempRequestId; set @OldTrempRequestId=OLD.TrempRequestId; IF (@TrempRequestId <> @TrempRequestId) THEN UPDATE tbl_tremprequest SET FoundMatchesCount = FoundMatchesCount - 1 WHERE TrempRequestId = @OldTrempRequestId; UPDATE tbl_tremprequest SET FoundMatchesCount = FoundMatchesCount + 1 WHERE TrempRequestId = @TrempRequestId; END IF; END $$ CREATE TRIGGER tg_tremprequestmatch_CountersDelete AFTER DELETE ON tbl_tremprequestmatch FOR EACH ROW BEGIN set @OldTrempRequestId=OLD.TrempRequestId; UPDATE tbl_tremprequest SET FoundMatchesCount = FoundMatchesCount - 1 WHERE TrempRequestId = @OldTrempRequestId; END $$ CREATE TRIGGER tg_groupmember_CountersInsert AFTER INSERT ON tbl_groupmember FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; UPDATE tbl_group SET MemberCount = MemberCount + 1 WHERE GroupId = @GroupId; END $$ CREATE TRIGGER tg_groupmember_CountersUpdate AFTER UPDATE ON tbl_groupmember FOR EACH ROW BEGIN set @GroupId=NEW.GroupId; set @OldGroupId=OLD.GroupId; IF (@GroupId <> @GroupId) THEN UPDATE tbl_group SET MemberCount = MemberCount - 1 WHERE GroupId = @OldGroupId; UPDATE tbl_group SET MemberCount = MemberCount + 1 WHERE GroupId = @GroupId; END IF; END $$ CREATE TRIGGER tg_groupmember_CountersDelete AFTER DELETE ON tbl_groupmember FOR EACH ROW BEGIN set @OldGroupId=OLD.GroupId; UPDATE tbl_group SET MemberCount = MemberCount - 1 WHERE GroupId = @OldGroupId; END $$ CREATE TRIGGER tg_tremp_Insert AFTER INSERT ON tbl_Tremp FOR EACH ROW BEGIN SET @TrempId=NEW.TrempId; SET @FromAddressLatitude=NEW.FromAddressLatitude; SET @FromAddressLongitude=NEW.FromAddressLongitude; SET @ToAddressLatitude=NEW.ToAddressLatitude; SET @ToAddressLongitude=NEW.ToAddressLongitude; IF (@FromAddressLatitude IS NOT NULL AND @FromAddressLongitude IS NOT NULL AND @ToAddressLatitude IS NOT NULL AND @ToAddressLongitude IS NOT NULL) THEN INSERT INTO tbl_SpatialTremp (TrempId, FromAddress, ToAddress) VALUES(@TrempId,POINT(@FromAddressLatitude,@FromAddressLongitude),POINT(@ToAddressLatitude,@ToAddressLongitude)); END IF; END $$ CREATE TRIGGER tg_tremp_Update AFTER UPDATE ON tbl_Tremp FOR EACH ROW BEGIN SET @TrempId=NEW.TrempId; SET @FromAddressLatitude=NEW.FromAddressLatitude; SET @FromAddressLongitude=NEW.FromAddressLongitude; SET @ToAddressLatitude=NEW.ToAddressLatitude; SET @ToAddressLongitude=NEW.ToAddressLongitude; SET @OldTrempId=OLD.TrempId; SET @OldFromAddressLatitude=OLD.FromAddressLatitude; SET @OldFromAddressLongitude=OLD.FromAddressLongitude; SET @OldToAddressLatitude=OLD.ToAddressLatitude; SET @OldToAddressLongitude=OLD.ToAddressLongitude; IF (@TrempId <> @OldTrempId OR @FromAddressLatitude <> @OldFromAddressLatitude OR @FromAddressLongitude <> @OldFromAddressLongitude OR @ToAddressLatitude <> @OldToAddressLatitude OR @ToAddressLongitude <> @OldToAddressLongitude) THEN DELETE FROM tbl_SpatialTremp WHERE TrempId = @OldTrempId; IF (@FromAddressLatitude IS NOT NULL AND @FromAddressLongitude IS NOT NULL AND @ToAddressLatitude IS NOT NULL AND @ToAddressLongitude IS NOT NULL) THEN INSERT INTO tbl_SpatialTremp (TrempId, FromAddress, ToAddress) VALUES(@TrempId,POINT(@FromAddressLatitude,@FromAddressLongitude),POINT(@ToAddressLatitude,@ToAddressLongitude)); END IF; END IF; END $$ CREATE TRIGGER tg_tremp_Delete AFTER DELETE ON tbl_Tremp FOR EACH ROW BEGIN SET @OldTrempId=OLD.TrempId; DELETE FROM tbl_SpatialTremp WHERE TrempId = @OldTrempId; END $$ CREATE TRIGGER tg_tremprequest_Insert AFTER INSERT ON tbl_TrempRequest FOR EACH ROW BEGIN SET @TrempRequestId=NEW.TrempRequestId; SET @FromAddressLatitude=NEW.FromAddressLatitude; SET @FromAddressLongitude=NEW.FromAddressLongitude; SET @ToAddressLatitude=NEW.ToAddressLatitude; SET @ToAddressLongitude=NEW.ToAddressLongitude; IF (@FromAddressLatitude IS NOT NULL AND @FromAddressLongitude IS NOT NULL AND @ToAddressLatitude IS NOT NULL AND @ToAddressLongitude IS NOT NULL) THEN INSERT INTO tbl_SpatialTrempRequest (TrempRequestId, FromAddress, ToAddress) VALUES(@TrempRequestId,POINT(@FromAddressLatitude,@FromAddressLongitude),POINT(@ToAddressLatitude,@ToAddressLongitude)); END IF; END $$ CREATE TRIGGER tg_tremprequest_Update AFTER UPDATE ON tbl_TrempRequest FOR EACH ROW BEGIN SET @TrempRequestId=NEW.TrempRequestId; SET @FromAddressLatitude=NEW.FromAddressLatitude; SET @FromAddressLongitude=NEW.FromAddressLongitude; SET @ToAddressLatitude=NEW.ToAddressLatitude; SET @ToAddressLongitude=NEW.ToAddressLongitude; SET @OldTrempRequestId=OLD.TrempRequestId; SET @OldFromAddressLatitude=OLD.FromAddressLatitude; SET @OldFromAddressLongitude=OLD.FromAddressLongitude; SET @OldToAddressLatitude=OLD.ToAddressLatitude; SET @OldToAddressLongitude=OLD.ToAddressLongitude; IF (@TrempRequestId <> @OldTrempRequestId OR @FromAddressLatitude <> @OldFromAddressLatitude OR @FromAddressLongitude <> @OldFromAddressLongitude OR @ToAddressLatitude <> @OldToAddressLatitude OR @ToAddressLongitude <> @OldToAddressLongitude) THEN DELETE FROM tbl_SpatialTrempRequest WHERE TrempRequestId = @OldTrempRequestId; IF (@FromAddressLatitude IS NOT NULL AND @FromAddressLongitude IS NOT NULL AND @ToAddressLatitude IS NOT NULL AND @ToAddressLongitude IS NOT NULL) THEN INSERT INTO tbl_SpatialTrempRequest (TrempRequestId, FromAddress, ToAddress) VALUES(@TrempRequestId,POINT(@FromAddressLatitude,@FromAddressLongitude),POINT(@ToAddressLatitude,@ToAddressLongitude)); END IF; END IF; END $$ CREATE TRIGGER tg_tremprequest_Delete AFTER DELETE ON tbl_TrempRequest FOR EACH ROW BEGIN SET @OldTrempRequestId=OLD.TrempRequestId; DELETE FROM tbl_SpatialTrempRequest WHERE TrempRequestId = @OldTrempRequestId; END $$ DELIMITER ;"; conn.ExecuteScript(dropTriggers); conn.ExecuteScript(createTriggers); conn.CommitTransaction(); } }
/// <summary> /// Cria o comando de salvamento de alterações para o <see cref="ConnectorBase"/> /// especificado. /// </summary> /// <param name="conn">O <see cref="ConnectorBase"/> a ter seus dados salvos.</param> public CommitChangesCommand(ConnectorBase conn) { this.conn = conn; }
/// <summary> /// Cria o comando de salvamento de alterações para o <see cref="ConnectorBase"/> /// especificado. /// </summary> /// <param name="conn">O <see cref="ConnectorBase"/> a ter seus dados salvos.</param> public CommitChangesCommand(ConnectorBase conn) { this.conn = conn; }
protected void btnBackup_Click(object sender, EventArgs e) { if (Page.IsValid) { try { using (ConnectorBase conn = ConnectorBase.NewInstance()) { Response.Clear(); Response.AddHeader(@"content-disposition", @"attachment;filename=MySqlBackup_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + (chkBackupToGzip.Checked ? @".gz" : ".sql")); Response.Charset = @"UTF-8"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Cache.SetCacheability(HttpCacheability.NoCache); if (chkBackupToGzip.Checked) { Response.ContentType = @"application/x-gzip"; } else { Response.ContentType = @"application/octet-stream"; } MySqlBackup.BackupOptions options = new MySqlBackup.BackupOptions(); options.BOM = true; options.WrapInTransaction = true; options.ExportTableCreate = true; options.ExportTableDrop = true; options.ExportTableData = true; options.ExportRoutines = true; options.ExportTriggers = true; if (chkBackupToGzip.Checked) { using (GZipStream gzipStream = new GZipStream(Response.OutputStream, CompressionMode.Compress)) { MySqlBackup.GenerateBackup((MySqlConnector)conn, gzipStream, options); } } else { MySqlBackup.GenerateBackup((MySqlConnector)conn, Response.OutputStream, options); } Response.End(); } } catch (DbException ex) { Response.ContentType = @"text/html"; try { Response.Headers.Remove(@"content-disposition"); } catch { Response.ClearHeaders(); } Response.Clear(); Master.MessageCenter.DisplayErrorMessage(ex.Message); } } }
internal static List <Point> GetConnectionLine(ConnectorBase source, ConnectorBase sink, bool showLastLine) { List <Point> linePoints = new List <Point>(); Rect rectSource = source.GetParentRectWithMargin(Margin); Rect rectSink = sink.GetParentRectWithMargin(Margin); Point startPoint = GetOffsetPoint(source, rectSource); Point endPoint = GetOffsetPoint(sink, rectSink); linePoints.Add(startPoint); Point currentPoint = startPoint; if (!rectSink.Contains(currentPoint) && !rectSource.Contains(endPoint)) { while (true) { #region source node if (IsPointVisible(currentPoint, endPoint, new Rect[] { rectSource, rectSink })) { linePoints.Add(endPoint); currentPoint = endPoint; break; } Point neighbour = GetNearestVisibleNeighborSink(currentPoint, endPoint, sink, rectSource, rectSink); if (!double.IsNaN(neighbour.X)) { linePoints.Add(neighbour); linePoints.Add(endPoint); currentPoint = endPoint; break; } if (currentPoint == startPoint) { bool flag; Point n = GetNearestNeighborSource(source, endPoint, rectSource, rectSink, out flag); linePoints.Add(n); currentPoint = n; if (!IsRectVisible(currentPoint, rectSink, new Rect[] { rectSource })) { Point n1, n2; GetOppositeCorners(source.Placemement, rectSource, out n1, out n2); if (flag) { linePoints.Add(n1); currentPoint = n1; } else { linePoints.Add(n2); currentPoint = n2; } if (!IsRectVisible(currentPoint, rectSink, new Rect[] { rectSource })) { if (flag) { linePoints.Add(n2); currentPoint = n2; } else { linePoints.Add(n1); currentPoint = n1; } } } } #endregion #region sink node else // from here on we jump to the sink node { Point n1, n2; // neighbour corner Point s1, s2; // opposite corner GetNeighborCorners(sink.Placemement, rectSink, out s1, out s2); GetOppositeCorners(sink.Placemement, rectSink, out n1, out n2); bool n1Visible = IsPointVisible(currentPoint, n1, new Rect[] { rectSource, rectSink }); bool n2Visible = IsPointVisible(currentPoint, n2, new Rect[] { rectSource, rectSink }); if (n1Visible && n2Visible) { if (rectSource.Contains(n1)) { linePoints.Add(n2); if (rectSource.Contains(s2)) { linePoints.Add(n1); linePoints.Add(s1); } else { linePoints.Add(s2); } linePoints.Add(endPoint); currentPoint = endPoint; break; } if (rectSource.Contains(n2)) { linePoints.Add(n1); if (rectSource.Contains(s1)) { linePoints.Add(n2); linePoints.Add(s2); } else { linePoints.Add(s1); } linePoints.Add(endPoint); currentPoint = endPoint; break; } if ((Distance(n1, endPoint) <= Distance(n2, endPoint))) { linePoints.Add(n1); if (rectSource.Contains(s1)) { linePoints.Add(n2); linePoints.Add(s2); } else { linePoints.Add(s1); } linePoints.Add(endPoint); currentPoint = endPoint; break; } else { linePoints.Add(n2); if (rectSource.Contains(s2)) { linePoints.Add(n1); linePoints.Add(s1); } else { linePoints.Add(s2); } linePoints.Add(endPoint); currentPoint = endPoint; break; } } else if (n1Visible) { linePoints.Add(n1); if (rectSource.Contains(s1)) { linePoints.Add(n2); linePoints.Add(s2); } else { linePoints.Add(s1); } linePoints.Add(endPoint); currentPoint = endPoint; break; } else { linePoints.Add(n2); if (rectSource.Contains(s2)) { linePoints.Add(n1); linePoints.Add(s1); } else { linePoints.Add(s2); } linePoints.Add(endPoint); currentPoint = endPoint; break; } } #endregion } } else { linePoints.Add(endPoint); } linePoints = OptimizeLinePoints(linePoints, new Rect[] { rectSource, rectSink }, source.Placemement, sink.Placemement); CheckPathEnd(source, sink, showLastLine, linePoints); return(linePoints); }
public CommitTableChangesCommand(ConnectorBase conn) : base(conn) { }
public CommitRowChangesCommand(ConnectorBase conn) : base(conn) { }
private static void SendGcmNotification(Int64 SupplierId, string CollapseKey, Int32 Badge, string ActionType, Dictionary <string, object> CustomItems, string timeToLive = null) { List <string> tokens = new List <string>(); using (ConnectorBase conn = ConnectorBase.NewInstance()) { Query qry = Query.New <AppSupplierGcmToken>() .Select(AppSupplierGcmToken.Columns.Token) .Where(AppSupplierGcmToken.Columns.SupplierId, SupplierId); using (DataReaderBase reader = qry.ExecuteReader()) { while (reader.Read()) { tokens.Add(reader.GetString(0)); } } } if (tokens.Count > 0) { dg.Utilities.GoogleCloudMessaging.HttpNotificationPayload payload = new dg.Utilities.GoogleCloudMessaging.HttpNotificationPayload(tokens.ToArray()); payload.CollapseKey = CollapseKey; payload.RestrictedPackageName = GcmServiceSupplier.PackageName; payload.AddCustom("badge", Badge); if (timeToLive != null) { payload.TimeToLive = Convert.ToInt32(timeToLive) * 60; } if (ActionType != null) { payload.AddCustom("app-action", ActionType); } if (CustomItems != null) { foreach (string key in CustomItems.Keys) { if (CustomItems[key] == null) { continue; } payload.AddCustom(key, CustomItems[key]); } } HttpNotificationService service = GcmServiceSupplier.SharedInstance; service.SendMessage(payload, delegate(NotificationDeliveryResult x) { if (x.HttpStatusCode == HttpStatusCode.OK) { try { JObject response = JObject.Parse(x.Response); if (response != null) { if (response.Value <int>("failure") > 0 || response.Value <int>("canonical_ids") > 0) { JArray results = response["results"] as JArray; int resultIndex = 0; foreach (JObject result in results) { JToken jToken; if (result.TryGetValue("registration_id", out jToken)) { Query.New <AppSupplierGcmToken>() .Update(AppSupplierGcmToken.Columns.Token, jToken.Value <string>()) .Where(AppSupplierGcmToken.Columns.Token, payload.RegistrationIds[resultIndex]) .Execute(); } else { if (result.TryGetValue("error", out jToken)) { if (jToken.Value <string>() == "NotRegistered") { Query.New <AppSupplierGcmToken>() .Delete() .Where(AppSupplierGcmToken.Columns.Token, payload.RegistrationIds[resultIndex]) .Execute(); } } } resultIndex++; } } } } catch (Exception) { } } }); } }
public CommitTableChangesCommand(ConnectorBase conn) : base(conn) { }
private static Point GetNearestVisibleNeighborSink(Point currentPoint, Point endPoint, ConnectorBase sink, Rect rectSource, Rect rectSink) { Point s1, s2; // neighbors on sink side GetNeighborCorners(sink.Placemement, rectSink, out s1, out s2); bool flag1 = IsPointVisible(currentPoint, s1, new Rect[] { rectSource, rectSink }); bool flag2 = IsPointVisible(currentPoint, s2, new Rect[] { rectSource, rectSink }); if (flag1) // s1 visible { if (flag2) // s1 and s2 visible { if (rectSink.Contains(s1)) { return(s2); } if (rectSink.Contains(s2)) { return(s1); } if ((Distance(s1, endPoint) <= Distance(s2, endPoint))) { return(s1); } else { return(s2); } } else { return(s1); } } else // s1 not visible { if (flag2) // only s2 visible { return(s2); } else // s1 and s2 not visible { return(new Point(double.NaN, double.NaN)); } } }
private static void SendApnsNotification(Int64 SupplierId, string MessageLocKey, object[] MessageLocArgs, Int32 Badge, string Sound, string ActionType, Dictionary <string, object> CustomItems) { List <string> tokens = new List <string>(); using (ConnectorBase conn = ConnectorBase.NewInstance()) { Query qry = Query.New <AppSupplierAPNSToken>() .Select(AppSupplierAPNSToken.Columns.Token) .Where(AppSupplierAPNSToken.Columns.SupplierId, SupplierId); using (DataReaderBase reader = qry.ExecuteReader()) { while (reader.Read()) { tokens.Add(reader.GetString(0)); } } } NotificationAlert alert = new NotificationAlert(); alert.LocalizedKey = MessageLocKey; if (MessageLocArgs != null) { alert.LocalizedArgs.AddRange(MessageLocArgs); } Dictionary <string, object[]> customItems = null; if (ActionType != null) { customItems = new Dictionary <string, object[]>(); customItems[@"app-action"] = new object[] { ActionType }; } if (CustomItems != null) { foreach (string key in CustomItems.Keys) { if (CustomItems[key] == null) { continue; } if (customItems == null) { customItems = new Dictionary <string, object[]>(); } customItems[key] = new object[] { CustomItems[key] }; } } foreach (string token in tokens) { NotificationService service = APNSServiceSupplier.SharedInstance; service.SendMessage(token, alert, Badge, (Sound == null || Sound.Length == 0) ? @"default" : Sound, customItems, delegate() { Query qry = Query.New <AppSupplierAPNSToken>().Delete() .Where(AppSupplierAPNSToken.Columns.Token, token); }); } }
public ConnectorBaseProxy GetConnector(string connectionType) { ConnectorBase connectorBase = ConnectionServiceProvider.GetConnector(connectionType); return(new ConnectorBaseProxy(connectorBase)); }
/// <summary> /// send data to connector /// </summary> /// <typeparam name="T">return type data</typeparam> /// <param name="connector">connetor for send data</param> /// <param name="callInfo">method for send</param> /// <returns></returns> #if (NET40 || NET35) internal static T SendData <T>(this ConnectorBase connector, MethodCallInfo callInfo) { string data = SendData(connector, callInfo);
private static string SendData(this ConnectorBase connector, MethodCallInfo callInfo) { //TryAgain: bool isIgnorePriority = false; try { TaskCompletionSource <MethodCallbackInfo> valueData = new TaskCompletionSource <MethodCallbackInfo>(); CancellationTokenSource ct = new CancellationTokenSource(); ct.Token.Register(() => valueData.TrySetCanceled(), useSynchronizationContext: false); bool added = WaitedMethodsForResponse.TryAdd(callInfo.Guid, valueData); object service = connector.Services.ContainsKey(callInfo.ServiceName) ? connector.Services[callInfo.ServiceName] : null; //#if (PORTABLE) MethodInfo method = service?.GetType().FindMethod(callInfo.MethodName); //#else // var method = service?.GetType().FindMethod(callInfo.MethodName, RuntimeTypeHelper.GetMethodTypes(service.GetType(), callInfo).ToArray()); //#endif // isIgnorePriority = method?.GetCustomAttributes <PriorityCallAttribute>().Count() > 0; connector.SendData(callInfo); MethodCallbackInfo result = valueData.Task.Result; if (result == null) { if (connector.IsDisposed) { throw new ObjectDisposedException("Provider"); } if (!connector.IsConnected) { throw new Exception("client disconnected"); } return(null); } if (result.IsException) { throw new Exception("server exception:" + ClientSerializationHelper.DeserializeObject <string>(result.Data)); } else if (result.IsAccessDenied && result.Data == null) { throw new Exception("server permission denied exception."); } return(result.Data); } catch (Exception ex) { if (connector.IsConnected && !connector.SendPingAndWaitToReceive()) { connector.Disconnect(); } throw ex; } finally { WaitedMethodsForResponse.Remove(callInfo.Guid); } }
public CommitRowChangesCommand(ConnectorBase conn, AdpConnection dbConn, AdpTransaction trans) : base(conn, dbConn, trans) { }
public CommitRowChangesCommand(ConnectorBase conn) : base(conn) { }