public static string Get(ShareType shareType) { if (ShareTypeCache.TryGetValue(shareType, out string enumString) == false) { enumString = shareType.ToString(); ShareTypeCache.Add(shareType, enumString); } return(enumString); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("shareType"); writer.WriteStringValue(ShareType.ToString()); writer.WritePropertyName("storageType"); writer.WriteStringValue(StorageType.ToString()); if (Optional.IsDefined(ShareSizeInGB)) { writer.WritePropertyName("shareSizeInGB"); writer.WriteNumberValue(ShareSizeInGB.Value); } writer.WriteEndObject(); }
//eventClick public static void ClickShare(ShareType shareType, string type, string objectId, string title) { if (Application.isEditor) { return; } var mEventId = "Click_Event_Share"; var extras = new Dictionary <string, string>(); extras.Add("shareType", shareType.ToString()); extras.Add("type", type); extras.Add("id", objectId); extras.Add("title", title); JAnalyticsPlugin.CountEvent(mEventId, extras); }
public static AnalyticsResult SocialShareAccept(ShareType shareType, SocialNetwork socialNetwork, string senderId = null, string recipientId = null, IDictionary <string, object> eventData = null) { AnalyticsEvent.m_EventData.Clear(); AnalyticsEvent.m_EventData.Add("share_type", AnalyticsEvent.RenameEnum(shareType.ToString())); AnalyticsEvent.m_EventData.Add("social_network", AnalyticsEvent.RenameEnum(socialNetwork.ToString())); if (!string.IsNullOrEmpty(senderId)) { AnalyticsEvent.m_EventData.Add("sender_id", senderId); } if (!string.IsNullOrEmpty(recipientId)) { AnalyticsEvent.m_EventData.Add("recipient_id", recipientId); } AnalyticsEvent.AddCustomEventData(eventData); return(AnalyticsEvent.Custom("social_share_accept", AnalyticsEvent.m_EventData)); }
public static async Task <string> GetRandomShareIdAsync(PictureparkClient client, ShareType shareType, int limit) { var shareId = string.Empty; var request = new ShareSearchRequest { Limit = limit, Filter = new TermFilter { Field = "shareType", Term = shareType.ToString() } }; var result = await client.Shares.SearchAsync(request); var shares = result.Results; if (shares.Count > 0) { var randomNumber = new Random().Next(0, shares.Count); shareId = shares.Skip(randomNumber).First().Id; } return(shareId); }
public static void OpenRequest( ClientGuidType clientGuidType, PathNameType pathNameType, CreateType createType, ShareType shareType, AppInstanceIdType appInstanceIdType) { Condition.IsTrue(State == ModelState.Connected); Condition.IsNotNull(Open); // Isolate below params to limite the expanded test cases. Combination.Isolated(clientGuidType == ClientGuidType.SameClientGuid); Combination.Isolated(pathNameType == PathNameType.DifferentPathName); Combination.Isolated(shareType == ShareType.DifferentShareDifferentLocal); Combination.Isolated(shareType == ShareType.DifferentShareSameLocal); Combination.Isolated(appInstanceIdType == AppInstanceIdType.InvalidAppInstanceId); Combination.Isolated(appInstanceIdType == AppInstanceIdType.NoAppInstanceId); // "AppInstanceId is zero" is only applicable for the first Create Request. // For the second Create Request, only valid/notvalid/none make sense. Condition.IsFalse(appInstanceIdType == AppInstanceIdType.AppInstanceIdIsZero); // CreateDurableThenDisconnect is only applicable for the first Create Request. Condition.IsFalse(createType == CreateType.CreateDurableThenDisconnect); // If the client doesn't disconnect from the server after sending the first Create Request, // then the second Create Request does not need to contain reconnect context. // And vice versa. Condition.IfThen(Open.CreateTypeWhenPrepare != CreateType.CreateDurableThenDisconnect, createType != CreateType.ReconnectDurable); Condition.IfThen(Open.CreateTypeWhenPrepare == CreateType.CreateDurableThenDisconnect, createType == CreateType.ReconnectDurable); if (createType == CreateType.ReconnectDurable) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: If the create request also includes the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context, " + "the server MUST process the SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context as specified in section 3.3.5.9.12, " + "and this section MUST be skipped."); ModelHelper.Log(LogType.TestInfo, "SMB2_CREATE_DURABLE_HANDLE_RECONNECT_V2 create context is included."); return; } if (!ModelUtility.IsSmb3xFamily(MaxSmbVersionSupported)) { ModelHelper.Log(LogType.Requirement, "2.2.13.2.13: The SMB2_CREATE_APP_INSTANCE_ID context is valid only for the SMB 3.x dialect family."); ModelHelper.Log(LogType.TestInfo, "The dialect version of the server is {0}.", MaxSmbVersionSupported); return; } if (appInstanceIdType == AppInstanceIdType.ValidAppInstanceId && Open.AppInstanceId != AppInstanceIdType.NoAppInstanceId && pathNameType == PathNameType.SamePathName && shareType == ShareType.SameShare && clientGuidType == ClientGuidType.DifferentClientGuid) { ModelHelper.Log(LogType.Requirement, "3.3.5.9.13: The server MUST attempt to locate an Open in GlobalOpenTable where:"); ModelHelper.Log(LogType.Requirement, "\tAppInstanceId in the request is equal to Open.AppInstanceId."); ModelHelper.Log(LogType.Requirement, "\tTarget path name is equal to Open.PathName."); ModelHelper.Log(LogType.Requirement, "\tOpen.TreeConnect.Share is equal to TreeConnect.Share."); ModelHelper.Log(LogType.Requirement, "\tOpen.Session.Connection.ClientGuid is not equal to the current Connection.ClientGuid."); ModelHelper.Log(LogType.TestInfo, "All the above conditions are met."); ModelHelper.Log(LogType.Requirement, "If an Open is found, the server MUST calculate the maximal access that the user, " + "identified by Session.SecurityContext, has on the file being opened<277>. " + "If the maximal access includes GENERIC_READ access, the server MUST close the open as specified in 3.3.4.17."); // The user used in this model is administrator, so maximal access always includes GENERIC_READ access. ModelHelper.Log(LogType.TestInfo, "The maximal access includes GENERIC_READ access. So open is closed."); // close open Open = null; } else { ModelHelper.Log(LogType.TestInfo, "appInstanceIdType is {0}.", appInstanceIdType.ToString()); ModelHelper.Log(LogType.TestInfo, "pathNameType is {0}.", pathNameType.ToString()); ModelHelper.Log(LogType.TestInfo, "shareType is {0}.", shareType.ToString()); ModelHelper.Log(LogType.TestInfo, "clientGuidType is {0}.", clientGuidType.ToString()); ModelHelper.Log(LogType.TestInfo, "All the above conditions do not match the requirement, so open will not be closed."); ModelHelper.Log(LogType.TestTag, TestTag.UnexpectedFields); } }
/// <summary> /// Liest die Ordnerinfos der freigegebenen Ordner aus und speichert diese in der Datenbank /// </summary> /// <param name="share">Das Share Element der Freigabe</param> /// <param name="displayname">Der Name als die der Server angezeigt werden soll</param> internal static void GetSharesSecurity(Share share, string displayname) { if (share.NetName != "Install") { return; } DirectoryInfo dInfo = new DirectoryInfo(share.ToString()); if (dInfo == null) { return; } //baut eine SQL Verbindung auf MsSql mssql = new MsSql(); mssql.Open(); // Der volle Pfad (UNC Pfad) string _unc_path_name = dInfo.FullName; // Der Pfad auf dem lokalen System (z.b: x:\\Install string _path_name = share.Path; // Berechnet den Hash und speichert ihn string _path_hash = Helper.Hash(_unc_path_name); // Der Name der in ARPS angezeigt werden soll string _display_name = displayname; // Die Beschreibung der Freigabe string _remark = share.Remark; // Der ShareType ShareType _share_type = share.ShareType; // Ob es eine versteckte Freigabe ist oder nicht bool _hidden = CheckIsShareHidden(share); Console.WriteLine("Share: " + share + " - " + share.Remark); #region Prüfung ob schon vorhanden ist // Der SQL Befehl zum überprüfen ob der jeweilige Eintrag schon vorhanden ist string sql = $"SELECT _path_id FROM {MsSql.TBL_tmp_FS_Shares} WHERE _path_hash = @PathHash"; SqlCommand cmd = new SqlCommand(sql, mssql.Con); // Der Hash wird als Parameter an den SQL Befehl gehängt cmd.Parameters.AddWithValue("@PathHash", _path_hash); // Öffnet die SQL Verbindung, führt die Abfrage durch und schließt die Verbindung wieder mssql.Open(); // Falls es den abgefragten Datensatz schon gibt, bekommt man in index die ID des Datensatzen, sonnst null var _path_id = cmd.ExecuteScalar(); mssql.Close(); #endregion #region Größenberechnung // Es gibt die Zeile long _size; if (_path_id != null) { sql = $"SELECT _size FROM {MsSql.TBL_tmp_FS_Shares} WHERE _path_id = @PathId"; cmd = new SqlCommand(sql, mssql.Con); // Der Hash wird als Parameter an den SQL Befehl gehängt cmd.Parameters.AddWithValue("@PathId", _path_id); // Öffnet die SQL Verbindung, führt die Abfrage durch und schließt die Verbindung wieder mssql.Open(); // Falls es den abgefragten Datensatz schon gibt, bekommt man in index die ID des Datensatzen, sonnst null var size = cmd.ExecuteScalar(); mssql.Close(); if ((long)size == 0 || size == null) { _size = DirSize(dInfo); } else { _size = (long)size; } } else { _size = DirSize(dInfo); } #endregion // Liest alle Unterordner in ein Array DirectoryInfo[] childs; try { childs = dInfo.GetDirectories(); } catch (Exception) { childs = new DirectoryInfo[1]; } // Liest die Infos über den Besitzer aus string _owner_sid = "0"; DirectorySecurity dSecurity = null; try { dSecurity = dInfo.GetAccessControl(); IdentityReference owner = dSecurity.GetOwner(typeof(SecurityIdentifier)); // FÜR SID _owner_sid = owner.Value; } catch (Exception) { } // Ob der Ordner Unterordner hat oder nicht int _has_children = (childs.Length > 0) ? 1 : 0; // Hash ist noch nicht vorhanden if (_path_id == null) { // Der SQL Befehl zum INSERT in die Datenbank sql = $"INSERT INTO {MsSql.TBL_tmp_FS_Shares}(_unc_path_name, _owner_sid, _has_children, _size, _path_hash, _path_name, _display_name, _remark, _share_type, _hidden) " + $"OUTPUT INSERTED._path_id " + $"VALUES (@UncPathName, @OwnerSid, @HasChildren, @Size, @PathHash, @PathName, @DisplayName, @Remark, @ShareType, @Hidden) "; cmd = new SqlCommand(sql, mssql.Con); // Hängt die Parameter an cmd.Parameters.AddWithValue("@UncPathName", _unc_path_name); cmd.Parameters.AddWithValue("@OwnerSid", _owner_sid); cmd.Parameters.AddWithValue("@HasChildren", _has_children); cmd.Parameters.AddWithValue("@Size", _size); cmd.Parameters.AddWithValue("@PathHash", _path_hash); cmd.Parameters.AddWithValue("@PathName", _path_name); cmd.Parameters.AddWithValue("@DisplayName", _display_name); cmd.Parameters.AddWithValue("@Remark", _remark); cmd.Parameters.AddWithValue("@ShareType", _share_type.ToString()); cmd.Parameters.AddWithValue("@Hidden", _hidden); // Öffnet die SQL Verbindung mssql.Open(); // Führt die Query aus _path_id = (int)cmd.ExecuteScalar(); //Schließt die Verbindung mssql.Close(); } // Hash ist noch nicht vorhanden else { // SQL Befehl zum Updaten des Eintrags sql = $"UPDATE {MsSql.TBL_tmp_FS_Shares} " + $"SET _unc_path_name = @UncPathName, _owner_sid = @OwnerSid, _has_children = @HasChildren, _size = @Size, _path_hash = @PathHash, " + $"_path_name = @PathName, _display_name = @DisplayName, _remark = @Remark, _share_type = @ShareType, _hidden = @Hidden " + $"WHERE _path_id = @PathId"; cmd = new SqlCommand(sql, mssql.Con); // Hängt die Parameter an cmd.Parameters.AddWithValue("@UncPathName", _unc_path_name); cmd.Parameters.AddWithValue("@OwnerSid", _owner_sid); cmd.Parameters.AddWithValue("@HasChildren", _has_children); cmd.Parameters.AddWithValue("@Size", _size); cmd.Parameters.AddWithValue("@PathHash", _path_hash); cmd.Parameters.AddWithValue("@PathName", _path_name); cmd.Parameters.AddWithValue("@DisplayName", _display_name); cmd.Parameters.AddWithValue("@Remark", _remark); cmd.Parameters.AddWithValue("@ShareType", _share_type); cmd.Parameters.AddWithValue("@Hidden", _hidden); cmd.Parameters.AddWithValue("@PathId", (int)_path_id); // Öffnet die SQL Verbindung mssql.Open(); // Führt die Query aus cmd.ExecuteNonQuery(); //Schließt die Verbindung mssql.Close(); } // Ruft die ACL zum jeweiligen Ordner ab und schreib diese in die Datenbank if (dSecurity != null) { GetACEs(dSecurity, (int)_path_id, 1); } // Geht über alle Unterordner (Kinder) und ruft die Funktion rekursiv auf foreach (DirectoryInfo child in childs) { GetDirectorySecurity(child, (int)_path_id); } }
public string GetLocalizedShareType() { return(typeof(ShareType).GetField(ShareType.ToString()).GetCustomAttributes(typeof(DisplayAttribute), true).Cast <DisplayAttribute>().Single().GetName()); }