public void MSOXORULE_S04_TC02_AddModifyDeleteExtendedRule_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User1Name, this.User1ESSDN, this.User1Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User1ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); // Get the store object's entry ID. this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); RopCreateFolderResponse createFolderResponse; string newFolderName = Common.GenerateResourceName(this.Site, Constants.FolderDisplayName); uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(publicfolderHandler, newFolderName, Constants.FolderComment, out createFolderResponse); ulong newFolderID = createFolderResponse.FolderId; Site.Assert.AreEqual <uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed."); #endregion #region TestUser1 creates an FAI message. RopCreateMessageResponse ropCreateMessageResponse; uint extendedRuleMessageHandle = this.OxoruleAdapter.RopCreateMessage(newFolderHandle, newFolderID, Convert.ToByte(true), out ropCreateMessageResponse); Site.Assert.AreEqual <uint>(0, ropCreateMessageResponse.ReturnValue, "Creating the first FAI message should succeed."); #endregion #region TestUser1 adds the extended rule with NamedProperty successfully. string ruleConditionSubjectNameForAdd = Constants.RuleConditionSubjectContainString; NamedPropertyInfo namedPropertyInfo = new NamedPropertyInfo { NoOfNamedProps = 2, PropId = new uint[2] { 0x8001, 0x8002 } }; PropertyName testPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x01, Name = Encoding.Unicode.GetBytes(Constants.NameOfPropertyName + "\0") }; // 0x01 means the property is identified by the name property. testPropertyName.NameSize = (byte)testPropertyName.Name.Length; PropertyName secondPropertyName = new PropertyName { Guid = System.Guid.NewGuid().ToByteArray(), Kind = 0x00, LID = 0x88888888 }; // 0x00 means the property is identified by the LID. namedPropertyInfo.NamedProperty = new PropertyName[2] { testPropertyName, secondPropertyName }; namedPropertyInfo.NamedPropertiesSize = (uint)(testPropertyName.Serialize().Length + secondPropertyName.Serialize().Length); string ruleName = Common.GenerateResourceName(this.Site, Constants.ExtendRulename1); TaggedPropertyValue[] extendedRulePropertiesForAdd = AdapterHelper.GenerateExtendedRuleTestData(ruleName, 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectNameForAdd, namedPropertyInfo); // Set properties for extended rule FAI message. RopSetPropertiesResponse ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRulePropertiesForAdd); Site.Assert.AreEqual <uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for Extended rule FAI message should succeed."); // Save changes of message. RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); Site.Assert.AreEqual <uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving Extend rule message should succeed."); // Specify the properties to be got. PropertyTag[] propertyTagArray = new PropertyTag[1]; // PidTagRuleMessageProvider propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagRuleMessageProvider; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypString; // Get the specific properties of the extended rule. RopGetPropertiesSpecificResponse ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.AreEqual <uint>(0, ropGetPropertiesSpecificResponse.ReturnValue, "Getting specific properties operation should succeed."); string pidTagRuleMessageProviderData = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); Site.Assert.AreEqual <string>(Constants.PidTagRuleProvider, pidTagRuleMessageProviderData, "The rule provider data should be RuleOrganizer."); #endregion #region Modify the created rule. ruleName = Common.GenerateResourceName(this.Site, Constants.ExtendRulename2); TaggedPropertyValue[] extendedRulePropertiesForModify = AdapterHelper.GenerateExtendedRuleTestData(ruleName, 0, (uint)RuleState.ST_ENABLED, Constants.PidTagRuleProvider, ActionType.OP_MARK_AS_READ, new DeleteMarkReadActionData(), ruleConditionSubjectNameForAdd, namedPropertyInfo); // Set properties for extended rule FAI message. ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(extendedRuleMessageHandle, extendedRulePropertiesForModify); Site.Assert.AreEqual <uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for Extended rule FAI message should succeed."); // Save changes of message. ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(extendedRuleMessageHandle); Site.Assert.AreEqual <uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving Extend rule message should succeed."); // PidTagSubject propertyTagArray[0].PropertyId = (ushort)PropertyId.PidTagRuleMessageName; propertyTagArray[0].PropertyType = (ushort)PropertyType.PtypString; // Get the specific properties of the extended rule. ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.AreEqual <uint>(0, ropGetPropertiesSpecificResponse.ReturnValue, "Getting specific properties operation should succeed."); string messageName = AdapterHelper.PropertyValueConvertToString(ropGetPropertiesSpecificResponse.RowData.PropertyValues[0].Value); Site.Assert.AreEqual <string>(ruleName, messageName, "The rule subject should be {0}.", ruleName); #endregion #region Release the created message to delete the created rule. this.OxoruleAdapter.ReleaseRop(extendedRuleMessageHandle); // Get the specific properties of the extended rule. ropGetPropertiesSpecificResponse = this.OxoruleAdapter.RopGetPropertiesSpecific(extendedRuleMessageHandle, propertyTagArray); Site.Assert.IsNull(ropGetPropertiesSpecificResponse.RowData, "The property value of the extended rule should be null!"); #endregion #region Delete the folder. RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(publicfolderHandler, newFolderID); Site.Assert.AreEqual <uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed."); #endregion }
public void MSOXORULE_S04_TC03_ServerExecuteRule_Action_OP_TAG_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User1Name, this.User1ESSDN, this.User1Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User1ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); // Get the store object's entry ID. this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); RopCreateFolderResponse createFolderResponse; string newFolderName = Common.GenerateResourceName(this.Site, Constants.FolderDisplayName); uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(publicfolderHandler, newFolderName, Constants.FolderComment, out createFolderResponse); ulong newFolderID = createFolderResponse.FolderId; Site.Assert.AreEqual <uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed."); #endregion #region TestUser1 prepares value for ruleProperties variable. RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameTag); #endregion #region TestUser1 adds an OP_TAG rule to the new created folder. TagActionData tagActionData = new TagActionData(); PropertyTag tagActionDataPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagImportance, PropertyType = (ushort)PropertyType.PtypInteger32 }; tagActionData.PropertyTag = tagActionDataPropertyTag; tagActionData.PropertyValue = BitConverter.GetBytes(1); RuleData ruleOpTag = AdapterHelper.GenerateValidRuleData(ActionType.OP_TAG, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, tagActionData, ruleProperties, null); RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(newFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleOpTag }); Site.Assert.AreEqual <uint>(0, modifyRulesResponse.ReturnValue, "Adding OP_TAG rule should succeed."); #endregion #region TestUser1 creates a message. RopCreateMessageResponse ropCreateMessageResponse; uint messageHandle = this.OxoruleAdapter.RopCreateMessage(newFolderHandle, newFolderID, Convert.ToByte(false), out ropCreateMessageResponse); Site.Assert.AreEqual <uint>(0, ropCreateMessageResponse.ReturnValue, "Creating message should succeed."); #endregion #region TestUser1 saves the subject property of the message to trigger the rule. string subjectName = Common.GenerateResourceName(this.Site, ruleProperties.ConditionSubjectName + "Title"); TaggedPropertyValue subjectProperty = new TaggedPropertyValue(); PropertyTag pidTagSubjectPropertyTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagSubject, PropertyType = (ushort)PropertyType.PtypString }; subjectProperty.PropertyTag = pidTagSubjectPropertyTag; subjectProperty.Value = Encoding.Unicode.GetBytes(subjectName + "\0"); // Set properties for the created message to trigger the rule. RopSetPropertiesResponse ropSetPropertiesResponse = this.OxoruleAdapter.RopSetProperties(messageHandle, new TaggedPropertyValue[] { subjectProperty }); Site.Assert.AreEqual <uint>(0, ropSetPropertiesResponse.ReturnValue, "Setting property for the created message should succeed."); // Save changes of message. RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.OxoruleAdapter.RopSaveChangesMessage(messageHandle); Site.Assert.AreEqual <uint>(0, ropSaveChangesMessagResponse.ReturnValue, "Saving the created message should succeed."); // Wait for the message to be saved and the rule to take effect. Thread.Sleep(this.WaitForTheRuleToTakeEffect); #endregion #region TestUser1 gets the message and its properties to verify the rule evaluation. PropertyTag[] propertyTagList = new PropertyTag[2]; propertyTagList[0].PropertyId = (ushort)PropertyId.PidTagImportance; propertyTagList[0].PropertyType = (ushort)PropertyType.PtypInteger32; propertyTagList[1].PropertyId = (ushort)PropertyId.PidTagSubject; propertyTagList[1].PropertyType = (ushort)PropertyType.PtypString; uint contentTableHandle = 0; uint rowCount = 0; RopQueryRowsResponse getMailMessageContent = this.GetExpectedMessage(newFolderHandle, ref contentTableHandle, propertyTagList, ref rowCount, 1, subjectName); Site.Assert.AreEqual <uint>(1, rowCount, @"The message number in the specific folder should be 1."); Site.Assert.AreEqual <int>(1, BitConverter.ToInt32(getMailMessageContent.RowData.PropertyRows[(int)rowCount - 1].PropertyValues[0].Value, 0), "If the rule is executed, the PidTagImportance property of the message should be the value set by the rule."); RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(publicfolderHandler, newFolderID); Site.Assert.AreEqual <uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed."); #endregion }
private string GetFileLocation(params object[] modelLocatorInfo) { return(AdapterHelper.GetFileLocation(this.FileExtension, modelLocatorInfo)); }
public void Initialize() { this.adapterHelper = new AdapterHelper(); }
/// <summary> /// 获取到本支部已审批预算总数 /// </summary> /// <param name="OID"></param> /// <returns></returns> public int GetAuditApplyNum(string YG_OID) { AuditApplySqlComand.Parameters[0].Value = YG_OID; return(AdapterHelper.ExecuteScalar <Int32>(AuditApplySqlComand)); }
/// <summary> /// 删除本支部已审批预算通知 /// </summary> /// <param name="OID"></param> /// <returns></returns> public int DeleteAuditApply(string YG_OID) { DeleteAuditApplySqlComand.Parameters[0].Value = YG_OID; return(AdapterHelper.ExecuteCommand(DeleteAuditApplySqlComand)); }
/// <summary> /// 删除支部月度预算 /// </summary> /// <param name="OID"></param> /// <returns></returns> public int MyDelete(string OID) { MyDeleteSqlComand.Parameters[0].Value = OID; return(AdapterHelper.ExecuteCommand(MyDeleteSqlComand)); }
/// <summary> /// 实体列表适配器 /// </summary> /// <typeparam name="C">转换前列表中实体泛型</typeparam> /// <typeparam name="T">转换后列表中实体泛型</typeparam> /// <param name="objList">转换前实体列表</param> /// <param name="defaultEntityList">默认值:如果转换失败在返回该默认值</param> /// <param name="mapping">属性映射配置</param> /// <param name="ignoreProperties">列外属性:这些属性将不被转换</param> /// <returns>转换后的实体列表</returns> public static List <T> MappingAdapter <C, T>(this List <C> objList, List <T> defaultEntityList, Dictionary <string, string> mapping, params string[] ignoreProperties) where T : class, new() where C : class, new() { return(AdapterHelper.Adapter(objList, defaultEntityList, mapping, ignoreProperties)); }
/// <summary> /// The NspiQueryRows method returns a number of rows from a specified table to the client. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A STAT block that describes a logical position in a specific address book container.</param> /// <param name="tableCount">A DWORD value that contains the number values in the input parameter table. /// This value is limited to 100,000.</param> /// <param name="table">An array of DWORD values, representing an Explicit Table.</param> /// <param name="count">A DWORD value that contains the number of rows the client is requesting.</param> /// <param name="propTags">The value NULL or a reference to a PropertyTagArray_r value, /// containing a list of the proptags of the properties that the client requires to be returned for each row returned.</param> /// <param name="rows">A nullable PropertyRowSet_r value, it contains the address book container rows that the server returns in response to the request.</param> /// <param name="needRetry">A bool value indicates if need to retry to get an expected result. This parameter is designed to avoid meaningless retry when an error response is expected.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue NspiQueryRows(uint flags, ref STAT stat, uint tableCount, uint[] table, uint count, PropertyTagArray_r?propTags, out PropertyRowSet_r?rows, bool needRetry = true) { int result; IntPtr ptrRows = IntPtr.Zero; IntPtr ptrPropTags = IntPtr.Zero; IntPtr ptrStat = AdapterHelper.AllocStat(stat); if (propTags != null) { ptrPropTags = AdapterHelper.AllocPropertyTagArray_r(propTags.Value); } int retryCount = 0; do { try { result = OxnspiInterop.NspiQueryRows(this.contextHandle, flags, ref stat, tableCount, table, count, ptrPropTags, out ptrRows); } catch (SEHException e) { result = (int)NativeMethods.RpcExceptionCode(e); this.site.Log.Add(LogEntryKind.Comment, "RPC component throws exception, the error code is {0}, the error message is: {1}", result, new Win32Exception(result).ToString()); } if ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && needRetry) { Thread.Sleep(this.waitTime); } else { break; } retryCount++; }while ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && retryCount < this.maxRetryCount); if (!Enum.IsDefined(typeof(ErrorCodeValue), (uint)result)) { throw new ArgumentException(string.Format("An unknown error is returned, the error code is: {0} and the error message is: {1}", result, new Win32Exception(result).ToString())); } if (propTags != null) { Marshal.FreeHGlobal(ptrPropTags); } // Parse rows according to ptrRows. if (ptrRows == IntPtr.Zero) { rows = null; } else { rows = AdapterHelper.ParsePropertyRowSet_r(ptrRows); } // Free stat. Marshal.FreeHGlobal(ptrStat); return((ErrorCodeValue)result); }
/// <summary> /// The NspiBind method initiates a session between a client and the server. /// </summary> /// <param name="flags">A DWORD value that contains a set of bit flags.</param> /// <param name="stat">A pointer to a STAT block that describes a logical position in a specific address book container.</param> /// <param name="serverGuid">The value NULL or a pointer to a GUID value that is associated with the specific server.</param> /// <param name="needRetry">A Boolean value indicates if need to retry to get an expected result. This parameter is designed to avoid meaningless retry when an error response is expected.</param> /// <returns>Status of NSPI method.</returns> public ErrorCodeValue NspiBind(uint flags, STAT stat, ref FlatUID_r?serverGuid, bool needRetry = true) { int result; IntPtr ptrServerGuid = IntPtr.Zero; IntPtr ptrStat = AdapterHelper.AllocStat(stat); if (serverGuid.HasValue && serverGuid.Value.Ab != null) { ptrServerGuid = AdapterHelper.AllocFlatUID_r(serverGuid.Value); } int retryCount = 0; do { try { result = OxnspiInterop.NspiBind(this.rpcBinding, flags, ref stat, ptrServerGuid, ref this.contextHandle); } catch (SEHException e) { result = (int)NativeMethods.RpcExceptionCode(e); this.site.Log.Add(LogEntryKind.Comment, "RPC component throws exception, the error code is {0}, the error message is: {1}", result, new Win32Exception(result).ToString()); } if ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && needRetry) { Thread.Sleep(this.waitTime); } else { break; } retryCount++; }while ((ErrorCodeValue)result == ErrorCodeValue.GeneralFailure && retryCount < this.maxRetryCount); if (!Enum.IsDefined(typeof(ErrorCodeValue), (uint)result)) { throw new ArgumentException(string.Format("An unknown error is returned, the error code is: {0} and the error message is: {1}", result, new Win32Exception(result).ToString())); } // Parse ServerGuid from ptrServerGuid. if (ptrServerGuid == IntPtr.Zero) { serverGuid = null; } else { serverGuid = AdapterHelper.ParseFlatUID_r(ptrServerGuid); } // Free allocated memory for serverGuid. if (serverGuid.HasValue) { if (serverGuid.Value.Ab != null) { Marshal.FreeHGlobal(ptrServerGuid); } } // Free allocated memory for stat. Marshal.FreeHGlobal(ptrStat); return((ErrorCodeValue)result); }
/// <summary> /// 实体适配器:把一种实体转换为另一种实体 /// </summary> /// <typeparam name="T">转换后实体泛型</typeparam> /// <param name="obj">转换前的实体</param> /// <param name="defaultObjectEntity">默认值:如果转换失败在返回该默认值</param> /// <param name="mapping">属性映射配置</param> /// <param name="ignoreProperties">列外属性:这些属性将不被转换</param> /// <returns>转换后的实体</returns> public static T MappingAdapter <T>(this object obj, T defaultObjectEntity, Dictionary <string, string> mapping, params string[] ignoreProperties) where T : class, new() { return(AdapterHelper.Adapter(obj, defaultObjectEntity, mapping, ignoreProperties)); }
/// <summary> /// 实体列表适配器 /// </summary> /// <typeparam name="C">转换前列表中实体泛型</typeparam> /// <typeparam name="T">转换后列表中实体泛型</typeparam> /// <param name="objList">转换前实体列表</param> /// <param name="defaultObjectEntitys">默认值:如果转换失败在返回该默认值</param> /// <param name="ignoreProperties">列外属性:这些属性将不被转换</param> /// <returns>转换后的实体列表</returns> public static List <T> Adapter <C, T>(this List <C> objList, List <T> defaultEntityList, params string[] ignoreProperties) where T : class, new() where C : class, new() { return(AdapterHelper.Adapter(objList, defaultEntityList, ignoreProperties)); }
/// <summary> /// 实体适配器:把一种实体转换为另一种实体 /// </summary> /// <typeparam name="T">转换后实体泛型</typeparam> /// <param name="obj">转换前的实体</param> /// <param name="defaultObjectEntity">默认值:如果转换失败在返回该默认值</param> /// <param name="ignoreProperties">列外属性:这些属性将不被转换</param> /// <returns>转换后的实体</returns> public static T Adapter <T>(this object obj, T defaultObjectEntity, params string[] ignoreProperties) where T : class, new() { return(AdapterHelper.Adapter(obj, defaultObjectEntity, ignoreProperties)); }
public void MSOXORULE_S04_TC04_AddNotSupportedRule_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser2 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User2Name, this.User2ESSDN, this.User2Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User2ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); ulong publicFolderID = logonResponse.FolderIds[1]; #endregion #region TestUser2 tests the unsupported rules in public folder. #region TestUser2 prepares value for ruleProperties variable. RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameDeferredAction); #endregion #region TestUser2 adds a Rule set Action Type to OP_DEFER_ACTION. DeferredActionData deferredActionData = new DeferredActionData { Data = Common.GetBytesFromBinaryHexString(Constants.DeferredActionBufferData) }; RuleData deferredActionRuleData = AdapterHelper.GenerateValidRuleData(ActionType.OP_DEFER_ACTION, TestRuleDataType.ForAdd, 5, RuleState.ST_ENABLED, deferredActionData, ruleProperties, null); RopModifyRulesResponse ropModifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { deferredActionRuleData }); #endregion // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R258: server returned value is {0}", ropModifyRulesResponse.ReturnValue); // Verify MS-OXORULE requirement: MS-OXORULE_R258. // If the ReturnValue is not 0x00000000, it means the server failed to add a public folder rule with this OP_DEFER_ACTION Type action. // So it is not used in a public folder rule. bool isVerifyR258 = ropModifyRulesResponse.ReturnValue != 0x00000000; Site.CaptureRequirementIfIsTrue( isVerifyR258, 258, @"[In ActionBlock Structure] The meaning of action type OP_DEFER_ACTION: MUST NOT be used in a public folder rule (2)."); #region TestUser2 prepares rules' data. MoveCopyActionData moveCopyActionData = new MoveCopyActionData(); // Get the Inbox folder entry ID. byte[] folderEId = this.OxoruleAdapter.GetFolderEntryId(StoreObjectType.PublicFolder, publicfolderHandler, publicFolderID); // Get the store object's entry ID. byte[] storeEId = this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); moveCopyActionData.FolderEID = folderEId; moveCopyActionData.StoreEID = storeEId; moveCopyActionData.FolderEIDSize = (ushort)folderEId.Length; moveCopyActionData.StoreEIDSize = (ushort)storeEId.Length; #endregion #region TestUser2 prepares value for ruleProperties variable. ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameMoveOne); #endregion #region TestUser2 adds OP_MOVE rule to the public folder. ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveOne); RuleData ruleForMove = AdapterHelper.GenerateValidRuleData(ActionType.OP_MOVE, TestRuleDataType.ForAdd, 0, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null); RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForMove }); #endregion // Add the debug information. Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R839: server returned value is {0}", modifyRulesResponse.ReturnValue); // Verify MS-OXORULE requirement: MS-OXORULE_R839. // If the returnValue is not 0x00000000, it means this OP_MOVE Type used in a public folder rule is failed, // so it is not used in a public folder rule. bool isVerifyR839 = modifyRulesResponse.ReturnValue != 0x00000000; Site.CaptureRequirementIfIsTrue( isVerifyR839, 839, @"[In ActionBlock Structure] The meaning of action type OP_MOVE: MUST NOT be used in a public folder rule (2)."); #region TestUser2 adds OP_COPY rule to the public folder. ruleProperties.Name = Common.GenerateResourceName(this.Site, Constants.RuleNameMoveTwo); RuleData ruleForCopy = AdapterHelper.GenerateValidRuleData(ActionType.OP_COPY, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, moveCopyActionData, ruleProperties, null); modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(publicfolderHandler, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForCopy }); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXORULE_R840: server returned value is {0}", modifyRulesResponse.ReturnValue); // Verify MS-OXORULE requirement: MS-OXORULE_R840. // If the ReturnValue is not 0x00000000, it means this OP_COPY Type used in a public folder rule is failed, // so it is not used in a public folder rule. bool isVerifyR840 = modifyRulesResponse.ReturnValue != 0x00000000; Site.CaptureRequirementIfIsTrue( isVerifyR840, 840, @"[In ActionBlock Structure] The meaning of action type OP_COPY: MUST NOT be used in a public folder rule (2)."); #endregion }
/// <summary> /// 获取到等待审核中的预算申请总数 /// </summary> /// <param name="OID"></param> /// <returns></returns> public int GetNoAuditApplyNum() { return(AdapterHelper.ExecuteScalar <Int32>(NoAuditApplySqlComand)); }
public void MSOXORULE_S04_TC01_AddModifyDeleteStandardRule_OnPublicFolder() { this.CheckMAPIHTTPTransportSupported(); #region TestUser1 logs on to the public folder. RopOpenFolderResponse openFolderResponse; RopLogonResponse logonResponse; bool ret = this.OxoruleAdapter.Connect(ConnectionType.PublicFolderServer, this.User1Name, this.User1ESSDN, this.User1Password); Site.Assert.IsTrue(ret, "connect to public folder server should be successful"); uint publicFolderLogonHandler = this.OxoruleAdapter.RopLogon(LogonType.PublicFolder, this.User1ESSDN, out logonResponse); // Assert the client to log on to the public folder successfully. Site.Assert.AreEqual <uint>(0, logonResponse.ReturnValue, "Logon the public folder should be successful."); // Folder index 1 is the Interpersonal Messages subtree, and this is defined in MS-OXCSTOR. uint publicfolderHandler = this.OxoruleAdapter.RopOpenFolder(publicFolderLogonHandler, logonResponse.FolderIds[1], out openFolderResponse); // Get the store object's entry ID. this.GetStoreObjectEntryID(StoreObjectType.PublicFolder, this.Server, this.User1ESSDN); RopCreateFolderResponse createFolderResponse; string newFolderName = Common.GenerateResourceName(this.Site, Constants.FolderDisplayName); uint newFolderHandle = this.OxoruleAdapter.RopCreateFolder(publicfolderHandler, newFolderName, Constants.FolderComment, out createFolderResponse); Site.Assert.AreEqual <uint>(0, createFolderResponse.ReturnValue, "Creating folder operation should succeed."); #endregion #region TestUser1 prepares value for rule properties variable. RuleProperties ruleProperties = AdapterHelper.GenerateRuleProperties(this.Site, Constants.RuleNameDelete); RuleData ruleForDelete = AdapterHelper.GenerateValidRuleData(ActionType.OP_DELETE, TestRuleDataType.ForAdd, 1, RuleState.ST_ENABLED, new DeleteMarkReadActionData(), ruleProperties, null); #endregion #region TestUser1 adds rule OP_Delelte. RopModifyRulesResponse modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(newFolderHandle, ModifyRuleFlag.Modify_ReplaceAll, new RuleData[] { ruleForDelete }); Site.Assert.AreEqual <uint>(0, modifyRulesResponse.ReturnValue, "Adding Delete rule should succeed."); #endregion #region TestUser1 gets rule ID of the created rule. RopGetRulesTableResponse ropGetRulesTableResponse; uint ruleTableHandle = this.OxoruleAdapter.RopGetRulesTable(newFolderHandle, TableFlags.Normal, out ropGetRulesTableResponse); Site.Assert.AreEqual <uint>(0, ropGetRulesTableResponse.ReturnValue, "Getting rule table should succeed."); PropertyTag ruleIDTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagRuleId, PropertyType = (ushort)PropertyType.PtypInteger64 }; RopQueryRowsResponse queryRowsResponse = this.OxoruleAdapter.QueryPropertiesInTable(ruleTableHandle, new PropertyTag[1] { ruleIDTag }); Site.Assert.AreEqual <uint>(0, queryRowsResponse.ReturnValue, "Retrieving rows from the rule table should succeed."); // Only one rule added in this folder, so the row count in the rule table should be 1. Site.Assert.AreEqual <uint>(1, queryRowsResponse.RowCount, "The rule number in the rule table is {0}", queryRowsResponse.RowCount); this.VerifyRuleTable(); ulong ruleId = BitConverter.ToUInt64(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[0].Value, 0); #endregion #region TestUser1 modifies the created rule. ruleProperties.Name = Common.GenerateResourceName(this.Site, "RuleNameForModify"); ruleForDelete = AdapterHelper.GenerateValidRuleData(ActionType.OP_DELETE, TestRuleDataType.ForModify, 1, RuleState.ST_ENABLED, new DeleteMarkReadActionData(), ruleProperties, ruleId); modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(newFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { ruleForDelete }); Site.Assert.AreEqual <uint>(0, modifyRulesResponse.ReturnValue, "Modifying the OP_DELETE rule should be success"); #endregion #region TestUser1 calls RopGetRulesTable with valid TableFlags. ruleTableHandle = this.OxoruleAdapter.RopGetRulesTable(newFolderHandle, TableFlags.Normal, out ropGetRulesTableResponse); #endregion #region TestUser1 retrieves rule information for the modified rule. PropertyTag ruleNameTag = new PropertyTag { PropertyId = (ushort)PropertyId.PidTagRuleName, PropertyType = (ushort)PropertyType.PtypString }; // Retrieves rows from the rule table. queryRowsResponse = this.OxoruleAdapter.QueryPropertiesInTable(ruleTableHandle, new PropertyTag[2] { ruleIDTag, ruleNameTag }); Site.Assert.AreEqual <uint>(0, queryRowsResponse.ReturnValue, "Retrieving rows from the rule table should succeed."); // Only one rule added in this folder, so the row count in the rule table should be 1. Site.Assert.AreEqual <uint>(1, queryRowsResponse.RowCount, "The rule number in the rule table is {0}", queryRowsResponse.RowCount); this.VerifyRuleTable(); ulong ruleIdModified = BitConverter.ToUInt64(queryRowsResponse.RowData.PropertyRows[0].PropertyValues[0].Value, 0); bool isSameRuleId = ruleId == ruleIdModified; Site.Assert.IsTrue(isSameRuleId, "The original rule Id is {0} and the modified rule Id is {1}", ruleId, ruleIdModified); string modifiedRuleName = AdapterHelper.PropertyValueConvertToString(queryRowsResponse.RowData.PropertyRows.ToArray()[0].PropertyValues[1].Value); Site.Assert.AreEqual <string>(ruleProperties.Name, modifiedRuleName, "The actual rule name {0} should be equal to the expected rule name {1}.", modifiedRuleName, ruleProperties.Name); #endregion #region TestUser1 deletes the created rule. ruleForDelete = AdapterHelper.GenerateValidRuleData(ActionType.OP_DELETE, TestRuleDataType.ForRemove, 1, RuleState.ST_ENABLED, null, ruleProperties, ruleId); modifyRulesResponse = this.OxoruleAdapter.RopModifyRules(newFolderHandle, ModifyRuleFlag.Modify_OnExisting, new RuleData[] { ruleForDelete }); Site.Assert.AreEqual <uint>(0, modifyRulesResponse.ReturnValue, "Deleting the OP_DELETE rule should succeed."); RopDeleteFolderResponse deleteFolder = this.OxoruleAdapter.RopDeleteFolder(publicfolderHandler, createFolderResponse.FolderId); Site.Assert.AreEqual <uint>(0, deleteFolder.ReturnValue, "Deleting folder should succeed."); #endregion }
public void Initialize() { this.adapterHelper = new AdapterHelper(); this.appendableLogger = new AppendableLogger(); }