int IServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { ////int hr = HRESULT.E_NOINTERFACE; //if (guidService == IID_IAuthenticate && riid == IID_IAuthenticate) //{ // ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate)); // this as IAuthenticate; // // //if (ppvObject != null) { // // hr = HRESULT.S_OK; // //} //} //else //{ // ppvObject = IntPtr.Zero; //} ////return hr; int nRet = guidService.CompareTo(IID_IAuthenticate); // Zero //returned if the compared objects are equal if (nRet == 0) { nRet = riid.CompareTo(IID_IAuthenticate); // Zero //returned if the compared objects are equal if (nRet == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate)); return S_OK; } } ppvObject = new IntPtr(); return INET_E_DEFAULT_ACTION; }
protected override Guid ExportAttachments(JsonTextWriter jsonWriter, Guid lastEtag) { var totalCount = 0; while (true) { var array = GetAttachments(totalCount, lastEtag); if (array.Length == 0) { var databaseStatistics = GetStats(); if (lastEtag.CompareTo(databaseStatistics.LastAttachmentEtag) < 0) { lastEtag = Etag.Increment(lastEtag, smugglerOptions.BatchSize); ShowProgress("Got no results but didn't get to the last attachment etag, trying from: {0}", lastEtag); continue; } ShowProgress("Done with reading attachments, total: {0}", totalCount); return lastEtag; } totalCount += array.Length; ShowProgress("Reading batch of {0,3} attachments, read so far: {1,10:#,#;;0}", array.Length, totalCount); foreach (var item in array) { item.WriteTo(jsonWriter); } lastEtag = new Guid(array.Last().Value<string>("Etag")); } }
/// <summary> /// Create table with 4 records per page /// </summary> private void CreatePopulateAndTestTable() { Api.JetBeginTransaction(this.sesId); EseInteropTestHelper.ConsoleWriteLine("Create and popluate table."); JET_TABLECREATE tc = this.CreateTable(this.tableName); for (int i = 0; i < 10000; i++) { this.InsertRecord(tc.tableid, System.Guid.NewGuid()); if ((i % 100) == 0) { if ((i % 2000) == 0) { EseInteropTestHelper.ConsoleWriteLine("Added another 2000 Guids."); } Api.JetCommitTransaction(this.sesId, CommitTransactionGrbit.None); Api.JetBeginTransaction(this.sesId); } } EseInteropTestHelper.ConsoleWriteLine("Finished inserting first set of values in index."); Guid guidPrev; Guid guidCur; Api.JetMove(this.sesId, tc.tableid, JET_Move.First, MoveGrbit.None); int bytesRead; byte[] data = new byte[16]; Api.JetRetrieveColumn(this.sesId, tc.tableid, this.columnIdKey1, data, data.Length, out bytesRead, 0, null); guidPrev = new System.Guid(data); for (int i = 1; i < 10000; i++) { Api.JetMove(this.sesId, tc.tableid, JET_Move.Next, MoveGrbit.None); Api.JetRetrieveColumn(this.sesId, tc.tableid, this.columnIdKey1, data, data.Length, out bytesRead, 0, null); guidCur = new System.Guid(data); Assert.IsTrue(guidCur.CompareTo(guidPrev) > 0); guidPrev = guidCur; } Api.JetCommitTransaction(this.sesId, CommitTransactionGrbit.None); EseInteropTestHelper.ConsoleWriteLine("Finished testing .Net Guid sort order on inserted values"); Api.JetCloseTable(this.sesId, tc.tableid); }
public static bool IsSqlProj(EnvDTE.Project project) { if (project != null) { string kind = project.Kind; if (string.IsNullOrEmpty(kind) == false) { Guid thisProjectGuid = new Guid(kind); Guid databaseProjectGuid = new Guid(GuidList.guidSqlProjProjectString); if (thisProjectGuid.CompareTo(databaseProjectGuid) == 0) { return true; } } } return false; }
public bool PosTest1() { bool retVal = true; Guid g1; Guid g2; int a; short b; short c; byte[] d; int compare; TestLibrary.TestFramework.BeginScenario("PosTest1: Guid.CompareTo(Guid) always equals"); try { d = new byte[8]; for(int i=0;i<d.Length; i++) d[i] = TestLibrary.Generator.GetByte(-55); a = TestLibrary.Generator.GetInt32(-55); b = TestLibrary.Generator.GetInt16(-55); c = TestLibrary.Generator.GetInt16(-55); g1 = new Guid(a, b, c, d); // equals g2 = new Guid(a, b, c, d); compare = g1.CompareTo(g2); if (0 != compare) { TestLibrary.TestFramework.LogError("000", "Guid1: " + g1); TestLibrary.TestFramework.LogError("001", "Guid2: " + g2); TestLibrary.TestFramework.LogError("002", "Compare mismatch: Exepcted(0) Actual("+compare+")"); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e); retVal = false; } return retVal; }
private bool IsStaleByEtag(string entityName, DateTime? cutOff) { var lastIndexedEtag = new Guid( Api.RetrieveColumn(session, IndexesStats, tableColumnsCache.IndexesStatsColumns["last_indexed_etag"]) ); Api.JetSetCurrentIndex(session, Documents, "by_etag"); if (!Api.TryMoveLast(session, Documents)) { return false; } do { var lastEtag = new Guid(Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["etag"])); if (lastEtag.CompareTo(lastIndexedEtag) <= 0) break; if (entityName != null) { var metadata = Api.RetrieveColumn(session, Documents, tableColumnsCache.DocumentsColumns["metadata"]). ToJObject(); if (metadata.Value<string>("Raven-Entity-Name") != entityName) continue; } if (cutOff != null) { var lastIndexedTimestamp = Api.RetrieveColumnAsDateTime(session, IndexesStats, tableColumnsCache.IndexesStatsColumns["last_indexed_timestamp"]) .Value; if (cutOff.Value > lastIndexedTimestamp) return true; } else { return true; } } while (Api.TryMovePrevious(session, Documents)); return false; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1: Call CompareTo to compare with guid itself"); try { Guid guid = new Guid(); int result = guid.CompareTo(guid); if ( result != 0) { TestLibrary.TestFramework.LogError("001.1", "Call CompareTo to compare with guid itself does not return 0"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid = " + guid + ", result = " + result); retVal = false; } byte[] bytes = new byte[c_GUID_BYTE_ARRAY_SIZE]; TestLibrary.Generator.GetBytes(-55, bytes); guid = new Guid(bytes); result = guid.CompareTo(guid); if (result != 0) { TestLibrary.TestFramework.LogError("001.2", "Call CompareTo to compare with guid itself does not return 0"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid = " + guid + ", result = " + result); retVal = false; } } catch (Exception e) { TestLibrary.TestFramework.LogError("001.0", "Unexpected exception: " + e); TestLibrary.TestFramework.LogInformation(e.StackTrace); retVal = false; } return retVal; }
public static IList<EnvDTE.Project> GetDatabaseProjects(DTE2 applicationObject) { IList<EnvDTE.Project> foundProjects = new List<EnvDTE.Project>(); foreach (EnvDTE.Project proj in applicationObject.Solution.Projects) { EnvDTE.Project thisProject = proj as EnvDTE.Project; if (thisProject != null) { string kind = thisProject.Kind; if (string.IsNullOrEmpty(kind) == false) { Guid thisProjectGuid = new Guid(kind); Guid databaseProjectGuid = new Guid(GuidList.guidSqlProjProjectString); if (thisProjectGuid.CompareTo(databaseProjectGuid) == 0) { foundProjects.Add(thisProject); } } } } return foundProjects; }
static StackObject *CompareTo_10(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.Guid @value = (System.Guid) typeof(System.Guid).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method); System.Guid instance_of_this_method = (System.Guid) typeof(System.Guid).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); var result_of_this_method = instance_of_this_method.CompareTo(@value); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); WriteBackInstance(__domain, ptr_of_this_method, __mStack, ref instance_of_this_method); __intp.Free(ptr_of_this_method); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method; return(__ret + 1); }
public static bool IsTestProject(Guid projectKind) { return projectKind.CompareTo(new Guid("{3AC096D0-A1C2-E12C-1390-A8335801FDAB}")) == 0; }
/// <summary> /// Возвращает ссылку на выбранный в списке товар /// </summary> /// <returns>ссылка на товар</returns> private CCalcOrder GetSelectedCalcOrder() { CCalcOrder objRet = null; try { if ((((DevExpress.XtraGrid.Views.Grid.GridView)gridControlProductList.MainView).RowCount > 0) && (((DevExpress.XtraGrid.Views.Grid.GridView)gridControlProductList.MainView).FocusedRowHandle >= 0)) { System.Guid uuidID = (System.Guid)(((DevExpress.XtraGrid.Views.Grid.GridView)gridControlProductList.MainView)).GetFocusedRowCellValue("ID"); if ((m_objCalcOrderList != null) && (m_objCalcOrderList.Count > 0) && (uuidID.CompareTo(System.Guid.Empty) != 0)) { foreach (CCalcOrder objCalcOrder in m_objCalcOrderList) { if (objCalcOrder.ID.CompareTo(uuidID) == 0) { objRet = objCalcOrder; break; } } } } }//try catch (System.Exception f) { SendMessageToLog("Ошибка поиска выбранного расчета. Текст ошибки: " + f.Message); } finally { } return(objRet); }
/// <summary> /// Gets the GUID value of the node. /// </summary> /// <param name="propid">A __VSHPROPID or __VSHPROPID2 value of the guid property</param> /// <param name="guid">The guid to return for the property.</param> /// <returns>A success or failure value.</returns> public override int GetGuidProperty(int propid, out Guid guid) { guid = Guid.Empty; if ((__VSHPROPID)propid == __VSHPROPID.VSHPROPID_ProjectIDGuid) { guid = this.ProjectIDGuid; } else if (propid == (int)__VSHPROPID.VSHPROPID_CmdUIGuid) { guid = this.ProjectGuid; } else if ((__VSHPROPID2)propid == __VSHPROPID2.VSHPROPID_ProjectDesignerEditor && this.SupportsProjectDesigner) { guid = this.ProjectDesignerEditor; } else { base.GetGuidProperty(propid, out guid); } if (guid.CompareTo(Guid.Empty) == 0) { return VSConstants.DISP_E_MEMBERNOTFOUND; } return VSConstants.S_OK; }
public int CompareTo(Transaction other) { return(Id.CompareTo(other.Id)); }
/// <summary> /// Compares the current instance to the object. /// </summary> /// <remarks> /// Enables this object type to be compared to other types of object. /// </remarks> public int CompareTo(object obj) { // check for null. if (Object.ReferenceEquals(obj, null)) { return(-1); } // check for reference comparisons. if (Object.ReferenceEquals(this, obj)) { return(0); } ushort namespaceIndex = this.m_namespaceIndex; IdType idType = this.m_identifierType; object id = null; // check for expanded node ids. NodeId nodeId = obj as NodeId; if (nodeId != null) { namespaceIndex = nodeId.NamespaceIndex; idType = nodeId.IdType; id = nodeId.IdentifierPart; } else { UInt32?uid = obj as UInt32?; // check for numeric contains. if (uid != null) { if (namespaceIndex != 0 || idType != IdType.Numeric_0) { return(-1); } uint id1 = (uint)m_identifierPart; uint id2 = uid.Value; if (id1 == id2) { return(0); } return((id1 < id2) ? -1 : +1); } ExpandedNodeId expandedId = obj as ExpandedNodeId; if (!Object.ReferenceEquals(expandedId, null)) { if (expandedId.IsAbsolute) { return(-1); } namespaceIndex = expandedId.NamespaceIndex; idType = expandedId.IdType; id = expandedId.IdentifierPart; } } // check for different namespace. if (namespaceIndex != m_namespaceIndex) { return((m_namespaceIndex < namespaceIndex) ? -1 : +1); } // check for different id type. if (idType != m_identifierType) { return((m_identifierType < idType) ? -1 : +1); } // check for two nulls. if (IdentifierPart == null && id == null) { return(0); } // check for a single null. if (IdentifierPart == null && id != null) { switch (idType) { case IdType.String_1: string stringId = id as string; if (stringId.Length == 0) { return(0); } break; case IdType.Opaque_3: byte[] opaqueId = id as byte[]; if (opaqueId.Length == 0) { return(0); } break; case IdType.Numeric_0: uint?numericId = id as uint?; if (numericId.Value == 0) { return(0); } break; } return(-1); } else if (IdentifierPart != null && id == null) // check for a single null. { switch (idType) { case IdType.String_1: string stringId = IdentifierPart as string; if (stringId.Length == 0) { return(0); } break; case IdType.Opaque_3: byte[] opaqueId = IdentifierPart as byte[]; if (opaqueId.Length == 0) { return(0); } break; case IdType.Numeric_0: uint?numericId = IdentifierPart as uint?; if (numericId.Value == 0) { return(0); } break; } return(+1); } // compare ids. switch (idType) { case IdType.Numeric_0: { uint id1 = (uint)IdentifierPart; uint id2 = (uint)id; if (id1 == id2) { return(0); } return((id1 < id2) ? -1 : +1); } case IdType.String_1: { string id1 = (string)IdentifierPart; string id2 = (string)id; return(String.CompareOrdinal(id1, id2)); } case IdType.Guid_2: { System.Guid id1 = (System.Guid)IdentifierPart; return(id1.CompareTo(id)); } case IdType.Opaque_3: { byte[] id1 = (byte[])IdentifierPart; byte[] id2 = (byte[])id; if (id1.Length == id2.Length) { for (int ii = 0; ii < id1.Length; ii++) { if (id1[ii] != id2[ii]) { return((id1[ii] < id2[ii]) ? -1 : +1); } } return(0); } return((id1.Length < id2.Length) ? -1 : +1); } } // invalid id type - should never get here. return(+1); }
public void CompareToGuid () { Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g2 = new Guid (0x00010204, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g3 = new Guid (0x00010203, 0x0405, 0x0607, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g4 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f); Assert.IsTrue (g1.CompareTo (g2) < 0, "A1"); Assert.IsTrue (g1.CompareTo (g3) < 0, "A2"); Assert.IsTrue (g1.CompareTo (g4) < 0, "A3"); Assert.IsTrue (g2.CompareTo (g1) > 0, "A4"); Assert.IsTrue (g3.CompareTo (g1) > 0, "A5"); Assert.IsTrue (g4.CompareTo (g1) > 0, "A6"); Assert.IsTrue (g1.CompareTo (g1) == 0, "A7"); }
private bool VerificationHelper(Guid guid1, Guid guid2, bool greaterThanZero, string errorNo) { bool retVal = true; int result = guid1.CompareTo(guid2); bool actual = result > 0; if (actual != greaterThanZero) { TestLibrary.TestFramework.LogError(errorNo, "Call CompareTo to compare with guid itself does not return 0"); TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] guid1 = " + guid1 + ", guid2 = " + guid2 + ", greaterThanZero = " + greaterThanZero + ", result = " + result + ", actual = " + actual); retVal = false; } return retVal; }
public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { if (guidService.CompareTo(Win32.IID_IAuthenticate) == 0 && riid.CompareTo(Win32.IID_IAuthenticate) == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(Win32.IAuthenticate)); return Win32.S_OK; } else { ppvObject = IntPtr.Zero; return Win32.INET_E_DEFAULT_ACTION; } }
public void StopMonitoring(Guid subscriptionToken) { if (subscriptionToken.CompareTo(_subscriptionToken) != 0) { throw new InvalidOperationException("Invalid subscription token. Cannot stop monitoring."); } }
private Guid ExportDocuments(SmugglerOptions options, JsonTextWriter jsonWriter, Guid lastEtag) { int totalCount = 0; while (true) { var watch = Stopwatch.StartNew(); var documents = GetDocuments(lastEtag); watch.Stop(); if (documents.Length == 0) { var databaseStatistics = GetStats(); if(lastEtag.CompareTo(databaseStatistics.LastDocEtag) < 0) { lastEtag = Etag.Increment(lastEtag, smugglerOptions.BatchSize); ShowProgress("Got no results but didn't get to the last doc etag, trying from: {0}",lastEtag); continue; } ShowProgress("Done with reading documents, total: {0}", totalCount); return lastEtag; } var currentProcessingTime = watch.Elapsed; ModifyBatchSize(options, currentProcessingTime); var final = documents.Where(options.MatchFilters).ToList(); final.ForEach(item => item.WriteTo(jsonWriter)); totalCount += final.Count; ShowProgress("Reading batch of {0,3} documents, read so far: {1,10:#,#;;0}", documents.Length, totalCount); lastEtag = new Guid(documents.Last().Value<RavenJObject>("@metadata").Value<string>("@etag")); } }
public void TestCompareTo () { Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g2 = new Guid (0x00010204, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g3 = new Guid (0x00010203, 0x0405, 0x0607, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g4 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f); bool exception; Assert ("A1", g1.CompareTo (g2) < 0); Assert ("A2", g1.CompareTo (g3) < 0); Assert ("A3", g1.CompareTo (g4) < 0); Assert ("A4", g2.CompareTo (g1) > 0); Assert ("A5", g3.CompareTo (g1) > 0); Assert ("A6", g4.CompareTo (g1) > 0); Assert ("A7", g1.CompareTo (g1) == 0); Assert ("A8", g1.CompareTo (null) > 0); try { g1.CompareTo ("Say what?"); exception = false; } catch (ArgumentException) { exception = true; } Assert ("A9", exception); }
/// <summary> /// Возвращает таблицу с накладными за указанный период /// </summary> /// <param name="objProfile">профайл</param> /// <param name="cmdSQL">SQL-команда</param> /// <param name="IntWaybill_Guid">УИ документа</param> /// <param name="IntWaybill_DateBegin">начало периода для выборки</param> /// <param name="IntWaybill_DateEnd">конец периода для выборки</param> /// <param name="IntWaybill_SrcCompanyGuid">УИ компании "Откуда"</param> /// <param name="IntWaybill_SrcStockGuid">УИ склада "Откуда"<</param> /// <param name="IntWaybill_DstCompanyGuid">УИ компании "Куда"</param> /// <param name="IntWaybill_DstStockGuid">УИ склада "Куда"<</param> /// <param name="Waybill_PaymentTypeGuid">УИ формы оплаты</param> /// <param name="strErr">текст ошибки</param> /// <param name="SelectIntWaybillInfoFromIntOrder">признак "информация для накладной запрашивается из заказа"</param> /// <param name="OnlyUnShippedWaybills">признак "запрос только НЕ отгруженных накладных"</param> /// <returns>таблицу</returns> public static System.Data.DataTable GetWaybillTable(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL, System.Guid IntWaybill_Guid, System.DateTime IntWaybill_DateBegin, System.DateTime IntWaybill_DateEnd, System.Guid IntWaybill_SrcCompanyGuid, System.Guid IntWaybill_SrcStockGuid, System.Guid IntWaybill_DstCompanyGuid, System.Guid IntWaybill_DstStockGuid, System.Guid Waybill_PaymentTypeGuid, ref System.String strErr, System.Boolean SelectIntWaybillInfoFromIntOrder = false, System.Boolean OnlyUnShippedWaybills = false ) { System.Data.DataTable dtReturn = new System.Data.DataTable(); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("IntOrder_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_IsActive", typeof(System.Boolean))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcStock_IsTrade", typeof(System.Boolean))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcWarehouse_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcWarehouseType_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Acronym", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("SrcCompany_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_IsActive", typeof(System.Boolean))); dtReturn.Columns.Add(new System.Data.DataColumn("DstStock_IsTrade", typeof(System.Boolean))); dtReturn.Columns.Add(new System.Data.DataColumn("DstWarehouse_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("DstWarehouseType_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Acronym", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("DstCompany_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("Currency_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("Currency_Abbr", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("Depart_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("Depart_Code", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("PaymentType_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("PaymentType_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillShipMode_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Id", typeof(System.Int32))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillState_Name", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Num", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("RetailWaybill_Num", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_BeginDate", typeof(System.DateTime))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybillParent_Guid", typeof(System.Guid))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_ShipDate", typeof(System.DateTime))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Description", typeof(System.String))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_CurrencyRate", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_AllPrice", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_RetailAllPrice", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_AllDiscount", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_TotalPrice", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Quantity", typeof(System.Double))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_ForStock", typeof(System.Boolean))); dtReturn.Columns.Add(new System.Data.DataColumn("IntWaybill_Send", typeof(System.Boolean))); System.Data.SqlClient.SqlConnection DBConnection = null; System.Data.SqlClient.SqlCommand cmd = null; try { if (cmdSQL == null) { DBConnection = objProfile.GetDBSource(); if (DBConnection == null) { strErr += ("Не удалось получить соединение с базой данных."); return(dtReturn); } cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = DBConnection; cmd.CommandType = System.Data.CommandType.StoredProcedure; } else { cmd = cmdSQL; cmd.Parameters.Clear(); } if (IntWaybill_Guid.CompareTo(System.Guid.Empty) == 0) { cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybillList]", objProfile.GetOptionsDllDBName()); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DateBegin", System.Data.DbType.Date)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DateEnd", System.Data.DbType.Date)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@OnlyUnShippedWaybills", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_DateBegin"].Value = IntWaybill_DateBegin; cmd.Parameters["@IntWaybill_DateEnd"].Value = IntWaybill_DateEnd; cmd.Parameters["@OnlyUnShippedWaybills"].Value = OnlyUnShippedWaybills; if (IntWaybill_SrcCompanyGuid.CompareTo(System.Guid.Empty) != 0) { cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_SrcCompanyGuid", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_SrcCompanyGuid"].Value = IntWaybill_SrcCompanyGuid; } if (IntWaybill_SrcStockGuid.CompareTo(System.Guid.Empty) != 0) { cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_SrcStockGuid", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_SrcStockGuid"].Value = IntWaybill_SrcStockGuid; } if (IntWaybill_DstCompanyGuid.CompareTo(System.Guid.Empty) != 0) { cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DstCompanyGuid", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_DstCompanyGuid"].Value = IntWaybill_DstCompanyGuid; } if (IntWaybill_DstStockGuid.CompareTo(System.Guid.Empty) != 0) { cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_DstStockGuid", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_DstStockGuid"].Value = IntWaybill_DstStockGuid; } if (Waybill_PaymentTypeGuid.CompareTo(System.Guid.Empty) != 0) { cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Waybill_PaymentTypeGuid", System.Data.DbType.Guid)); cmd.Parameters["@Waybill_PaymentTypeGuid"].Value = Waybill_PaymentTypeGuid; } } else { if (SelectIntWaybillInfoFromIntOrder == true) { cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybillFromIntOrder]", objProfile.GetOptionsDllDBName()); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntOrder_Guid", System.Data.DbType.Guid)); cmd.Parameters["@IntOrder_Guid"].Value = IntWaybill_Guid; } else { cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_GetIntWaybill]", objProfile.GetOptionsDllDBName()); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_Guid", System.Data.DbType.Guid)); cmd.Parameters["@IntWaybill_Guid"].Value = IntWaybill_Guid; } } cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000) { Direction = System.Data.ParameterDirection.Output }); System.Data.SqlClient.SqlDataReader rs = cmd.ExecuteReader(); System.Int32 iRecordCount = 0; if (rs.HasRows) { System.Data.DataRow newRow = null; while (rs.Read()) { iRecordCount++; newRow = dtReturn.NewRow(); newRow["IntWaybill_Guid"] = ((rs["IntWaybill_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybill_Guid"] : System.Guid.Empty); newRow["IntWaybillParent_Guid"] = ((rs["IntWaybillParent_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntWaybillParent_Guid"] : System.Guid.Empty); newRow["IntOrder_Guid"] = ((rs["IntOrder_Guid"] != System.DBNull.Value) ? (System.Guid)rs["IntOrder_Guid"] : System.Guid.Empty); newRow["IntWaybill_Id"] = ((rs["IntWaybill_Id"] != System.DBNull.Value) ? (System.Int32)rs["IntWaybill_Id"] : 0); newRow["SrcStock_Guid"] = ((rs["SrcStock_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcStock_Guid"] : System.Guid.Empty); newRow["SrcStock_Id"] = ((rs["SrcStock_Id"] != System.DBNull.Value) ? (System.Int32)rs["SrcStock_Id"] : 0); newRow["SrcStock_Name"] = ((rs["SrcStock_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcStock_Name"]) : System.String.Empty); newRow["SrcStock_IsActive"] = ((rs["SrcStock_IsActive"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["SrcStock_IsActive"]) : false); newRow["SrcStock_IsTrade"] = ((rs["SrcStock_IsTrade"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["SrcStock_IsTrade"]) : false); newRow["SrcCompany_Guid"] = ((rs["SrcCompany_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcCompany_Guid"] : System.Guid.Empty); newRow["SrcCompany_Id"] = ((rs["SrcCompany_Id"] != System.DBNull.Value) ? (System.Int32)rs["SrcCompany_Id"] : 0); newRow["SrcCompany_Acronym"] = ((rs["SrcCompany_Acronym"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcCompany_Acronym"]) : System.String.Empty); newRow["SrcCompany_Name"] = ((rs["SrcCompany_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["SrcCompany_Name"]) : System.String.Empty); newRow["SrcWarehouse_Guid"] = ((rs["SrcWarehouse_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcWarehouse_Guid"] : System.Guid.Empty); newRow["SrcWarehouseType_Guid"] = ((rs["SrcWarehouseType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["SrcWarehouseType_Guid"] : System.Guid.Empty); newRow["DstStock_Guid"] = ((rs["DstStock_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstStock_Guid"] : System.Guid.Empty); newRow["DstStock_Id"] = ((rs["DstStock_Id"] != System.DBNull.Value) ? (System.Int32)rs["DstStock_Id"] : 0); newRow["DstStock_Name"] = ((rs["DstStock_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstStock_Name"]) : System.String.Empty); newRow["DstStock_IsActive"] = ((rs["DstStock_IsActive"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["DstStock_IsActive"]) : false); newRow["DstStock_IsTrade"] = ((rs["DstStock_IsTrade"] != System.DBNull.Value) ? System.Convert.ToBoolean(rs["DstStock_IsTrade"]) : false); newRow["DstWarehouse_Guid"] = ((rs["DstWarehouse_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstWarehouse_Guid"] : System.Guid.Empty); newRow["DstWarehouseType_Guid"] = ((rs["DstWarehouseType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstWarehouseType_Guid"] : System.Guid.Empty); newRow["DstCompany_Guid"] = ((rs["DstCompany_Guid"] != System.DBNull.Value) ? (System.Guid)rs["DstCompany_Guid"] : System.Guid.Empty); newRow["DstCompany_Id"] = ((rs["DstCompany_Id"] != System.DBNull.Value) ? (System.Int32)rs["DstCompany_Id"] : 0); newRow["DstCompany_Acronym"] = ((rs["DstCompany_Acronym"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstCompany_Acronym"]) : System.String.Empty); newRow["DstCompany_Name"] = ((rs["DstCompany_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["DstCompany_Name"]) : System.String.Empty); newRow["Depart_Guid"] = ((rs["Depart_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Depart_Guid"] : System.Guid.Empty); newRow["Depart_Code"] = ((rs["Depart_Code"] != System.DBNull.Value) ? System.Convert.ToString(rs["Depart_Code"]) : System.String.Empty); newRow["Currency_Guid"] = ((rs["Currency_Guid"] != System.DBNull.Value) ? (System.Guid)rs["Currency_Guid"] : System.Guid.Empty); newRow["Currency_Abbr"] = ((rs["Currency_Abbr"] != System.DBNull.Value) ? System.Convert.ToString(rs["Currency_Abbr"]) : System.String.Empty); newRow["PaymentType_Guid"] = ((rs["PaymentType_Guid"] != System.DBNull.Value) ? (System.Guid)rs["PaymentType_Guid"] : System.Guid.Empty); newRow["PaymentType_Name"] = ((rs["PaymentType_Name"] != System.DBNull.Value) ? System.Convert.ToString(rs["PaymentType_Name"]) : System.String.Empty); newRow["IntWaybillState_Guid"] = rs["IntWaybillState_Guid"]; newRow["IntWaybillState_Id"] = rs["IntWaybillState_Id"]; newRow["IntWaybillState_Name"] = rs["IntWaybillState_Name"]; newRow["IntWaybillShipMode_Guid"] = rs["IntWaybillShipMode_Guid"]; newRow["IntWaybillShipMode_Id"] = rs["IntWaybillShipMode_Id"]; newRow["IntWaybillShipMode_Name"] = rs["IntWaybillShipMode_Name"]; newRow["IntWaybill_BeginDate"] = ((rs["IntWaybill_BeginDate"] != System.DBNull.Value) ? rs["IntWaybill_BeginDate"] : System.DBNull.Value); newRow["IntWaybill_ShipDate"] = ((rs["IntWaybill_ShipDate"] != System.DBNull.Value) ? rs["IntWaybill_ShipDate"] : System.DBNull.Value); newRow["IntWaybill_Num"] = rs["IntWaybill_Num"]; newRow["RetailWaybill_Num"] = rs["RetailWaybill_Num"]; newRow["IntWaybill_Description"] = rs["IntWaybill_Description"]; newRow["IntWaybill_AllPrice"] = rs["IntWaybill_AllPrice"]; newRow["IntWaybill_RetailAllPrice"] = rs["IntWaybill_RetailAllPrice"]; newRow["IntWaybill_AllDiscount"] = rs["IntWaybill_AllDiscount"]; newRow["IntWaybill_Quantity"] = System.Convert.ToDecimal(rs["IntWaybill_Quantity"]); newRow["IntWaybill_ForStock"] = rs["IntWaybill_ForStock"]; newRow["IntWaybill_Send"] = rs["IntWaybill_Send"]; dtReturn.Rows.Add(newRow); } dtReturn.AcceptChanges(); } rs.Dispose(); if (cmdSQL == null) { cmd.Dispose(); DBConnection.Close(); } } catch (System.Exception f) { strErr += (String.Format("\nНе удалось получить таблицу с накладными.\nТекст ошибки: {0}", f.Message)); } return(dtReturn); }
public void TestDotNetGuidSortOrder() { if (!EsentVersion.SupportsWindows8Features) { return; } // Create table with GUID column and index over GUID column. this.CreatePopulateAndTestTable(); Api.JetCloseDatabase(this.sesId, this.databaseId, CloseDatabaseGrbit.None); Api.JetDetachDatabase(this.sesId, this.database); #if !MANAGEDESENT_ON_WSA // Not exposed in MSDK EseInteropTestHelper.ConsoleWriteLine("Compact database."); Api.JetAttachDatabase(this.sesId, this.database, Windows8Grbits.PurgeCacheOnAttach); Api.JetCompact(this.sesId, this.database, Path.Combine(this.directory, "defragged.edb"), null, null, CompactGrbit.None); Api.JetDetachDatabase(this.sesId, this.database); this.database = Path.Combine(this.directory, "defragged.edb"); Assert.IsTrue(EseInteropTestHelper.FileExists(this.database)); #endif // !MANAGEDESENT_ON_WSA Api.JetAttachDatabase(this.sesId, this.database, Windows8Grbits.PurgeCacheOnAttach); Api.JetOpenDatabase(this.sesId, this.database, null, out this.databaseId, OpenDatabaseGrbit.None); Api.JetOpenTable(this.sesId, this.databaseId, this.tableName, null, 0, OpenTableGrbit.None, out this.tableId); Api.JetBeginTransaction(this.sesId); EseInteropTestHelper.ConsoleWriteLine("Insert more values in index."); for (int i = 0; i < 10000; i++) { if ((i % 2000) == 0) { EseInteropTestHelper.ConsoleWriteLine("Added another 2000 Guids."); } Api.JetCommitTransaction(this.sesId, CommitTransactionGrbit.None); Api.JetBeginTransaction(this.sesId); this.InsertRecord(this.tableId, System.Guid.NewGuid()); } Api.JetCommitTransaction(this.sesId, CommitTransactionGrbit.None); EseInteropTestHelper.ConsoleWriteLine("Finished inserting more values in index."); // validate order after having closed the database and restarted Guid guidPrev; Guid guidCur; Api.JetMove(this.sesId, this.tableId, JET_Move.First, MoveGrbit.None); int bytesRead; byte[] data = new byte[16]; Api.JetRetrieveColumn(this.sesId, this.tableId, this.columnIdKey1, data, data.Length, out bytesRead, 0, null); guidPrev = new System.Guid(data); for (int i = 1; i < 10000; i++) { Api.JetMove(this.sesId, this.tableId, JET_Move.Next, MoveGrbit.None); Api.JetRetrieveColumn(this.sesId, this.tableId, this.columnIdKey1, data, data.Length, out bytesRead, 0, null); guidCur = new System.Guid(data); Assert.IsTrue(guidCur.CompareTo(guidPrev) > 0); guidPrev = guidCur; } EseInteropTestHelper.ConsoleWriteLine("Validated order."); // retrieve newly inserted GUID from index and compare values // to test denormalization logic Guid guidT = System.Guid.NewGuid(); EseInteropTestHelper.ConsoleWriteLine("Allocate random GUID..."); EseInteropTestHelper.ConsoleWriteLine(guidT.ToString()); this.InsertRecord(this.tableId, guidT); Api.JetSetCurrentIndex(this.sesId, this.tableId, this.secIndexName); EseInteropTestHelper.ConsoleWriteLine("Guid inserted is...."); EseInteropTestHelper.ConsoleWriteLine("{0}", guidT); byte[] keyArray = guidT.ToByteArray(); Api.JetMakeKey(this.sesId, this.tableId, keyArray, keyArray.Length, MakeKeyGrbit.NewKey); Api.JetSeek(this.sesId, this.tableId, SeekGrbit.SeekEQ); Api.JetSetCurrentIndex(this.sesId, this.tableId, this.secIndexName); keyArray = guidT.ToByteArray(); Api.JetMakeKey(this.sesId, this.tableId, keyArray, keyArray.Length, MakeKeyGrbit.NewKey); Api.JetSeek(this.sesId, this.tableId, SeekGrbit.SeekEQ); JET_wrn err = Api.JetRetrieveColumn(this.sesId, this.tableId, this.columnIdKey1, data, data.Length, out bytesRead, RetrieveColumnGrbit.RetrieveFromIndex, null); Assert.AreEqual(data.Length, bytesRead); EseInteropTestHelper.ConsoleWriteLine("Found random GUID in index..."); Guid guidTT = new System.Guid(data); Assert.AreEqual(guidT, guidTT); EseInteropTestHelper.ConsoleWriteLine("Found specific GUID in index"); // check retrieve from index for denormalization // by comparing guid inserted. They should match. Api.JetRetrieveColumn(this.sesId, this.tableId, this.columnIdKey1, data, data.Length, out bytesRead, RetrieveColumnGrbit.RetrieveFromIndex, null); guidCur = new System.Guid(data); EseInteropTestHelper.ConsoleWriteLine("Retrieved Guid is:"); EseInteropTestHelper.ConsoleWriteLine(guidCur.ToString()); Assert.IsTrue(guidCur.CompareTo(guidT) == 0); EseInteropTestHelper.ConsoleWriteLine("Retrieve from index matches inserted GUID"); Api.JetCloseTable(this.sesId, this.tableId); this.TestTempTableWithGuidDotNetSortOrder(); }
/// <include file='doc\Project.uex' path='docs/doc[@for="Project.GetGuidProperty"]/*' /> public override int GetGuidProperty(int propid, out Guid guid) { guid = Guid.Empty; switch ((__VSHPROPID)propid) { case __VSHPROPID.VSHPROPID_ProjectIDGuid: guid = ProjectIDGuid; break; case __VSHPROPID.VSHPROPID_CmdUIGuid: guid = VsMenus.guidStandardCommandSet2K; break; } //-2054, PreferredLanguageSID? CCITracing.TraceCall(String.Format("Property {0} not found", propid)); if (guid.CompareTo(Guid.Empty) == 0) return NativeMethods.DISP_E_MEMBERNOTFOUND; return NativeMethods.S_OK; }
/// <summary> /// Creates a temp table with GUID column and tests .Net sort order. /// </summary> private void TestTempTableWithGuidDotNetSortOrder() { // check temp table logic EseInteropTestHelper.ConsoleWriteLine("Create temp table on GUID column."); var columns = new[] { new JET_COLUMNDEF { coltyp = VistaColtyp.GUID, cp = JET_CP.Unicode, grbit = ColumndefGrbit.TTKey }, }; var columnids = new JET_COLUMNID[columns.Length]; var idxunicode = new JET_UNICODEINDEX { dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None), szLocaleName = "pt-br", }; var opentemporarytable = new JET_OPENTEMPORARYTABLE { cbKeyMost = SystemParameters.KeyMost, ccolumn = columns.Length, grbit = TempTableGrbit.Scrollable | Windows8Grbits.TTDotNetGuid, pidxunicode = idxunicode, prgcolumndef = columns, prgcolumnid = columnids, }; Windows8Api.JetOpenTemporaryTable2(this.sesId, opentemporarytable); Guid g = System.Guid.NewGuid(); EseInteropTestHelper.ConsoleWriteLine("Insert values in temp table."); for (int i = 0; i < 10000; i++) { if ((i % 2000) == 0) { EseInteropTestHelper.ConsoleWriteLine("Added another 2000 Guids."); } using (var update = new Update(this.sesId, opentemporarytable.tableid, JET_prep.Insert)) { Api.SetColumn(this.sesId, opentemporarytable.tableid, columnids[0], g); update.Save(); } g = System.Guid.NewGuid(); } EseInteropTestHelper.ConsoleWriteLine("Finished inserting values in temp table."); // validate order after having closed the database and restarted Api.JetMove(this.sesId, opentemporarytable.tableid, JET_Move.First, MoveGrbit.None); int bytesRead; byte[] data = new byte[16]; Api.JetRetrieveColumn(this.sesId, opentemporarytable.tableid, columnids[0], data, data.Length, out bytesRead, 0, null); Guid guidPrev = new System.Guid(data); EseInteropTestHelper.ConsoleWriteLine("Retrieved first value from temp table."); Guid guidCur; for (int i = 1; i < 10000; i++) { Api.JetMove(this.sesId, opentemporarytable.tableid, JET_Move.Next, MoveGrbit.None); Api.JetRetrieveColumn(this.sesId, opentemporarytable.tableid, columnids[0], data, data.Length, out bytesRead, 0, null); guidCur = new System.Guid(data); Assert.IsTrue(guidCur.CompareTo(guidPrev) > 0); guidPrev = guidCur; } EseInteropTestHelper.ConsoleWriteLine("Validated temp table order."); }
public void CompareToObject () { Guid g1 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g2 = new Guid (0x00010204, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g3 = new Guid (0x00010203, 0x0405, 0x0607, 0x09, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f); Guid g4 = new Guid (0x00010203, 0x0405, 0x0607, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f); // cast everything to object so the test still works under 2.0 Assert.IsTrue (g1.CompareTo ((object)g2) < 0, "A1"); Assert.IsTrue (g1.CompareTo ((object)g3) < 0, "A2"); Assert.IsTrue (g1.CompareTo ((object)g4) < 0, "A3"); Assert.IsTrue (g2.CompareTo ((object)g1) > 0, "A4"); Assert.IsTrue (g3.CompareTo ((object)g1) > 0, "A5"); Assert.IsTrue (g4.CompareTo ((object)g1) > 0, "A6"); Assert.IsTrue (g1.CompareTo ((object)g1) == 0, "A7"); Assert.IsTrue (g1.CompareTo ((object)null) > 0, "A8"); }
/// <summary> /// <c>QueryService</c>IServiceProvider interface method implementation /// </summary> /// <param name="guidService"></param> /// <param name="riid"></param> /// <param name="ppvObject"></param> /// <returns></returns> int Interfaces.IServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { ppvObject = new IntPtr(); try { int nRet = guidService.CompareTo(IID_IAuthenticate); // Zero //returned if the compared objects are equal if (nRet == 0) { nRet = riid.CompareTo(IID_IAuthenticate); // Zero //returned if the compared objects are equal if (nRet == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IAuthenticate)); return S_OK; } } } catch (Exception ex) { } return INET_E_DEFAULT_ACTION; }
protected string AudioGUIDToString(Guid guid) { if (guid.CompareTo(BDAudioGuids.AC3) == 0) return "AC3"; else if (guid.CompareTo(BDAudioGuids.DOLBY_DDPLUS) == 0) return "AC3+"; else if (guid.CompareTo(BDAudioGuids.DTS) == 0) return "DTS"; else if (guid.CompareTo(BDAudioGuids.DTS_HD) == 0) return "DTS-HD"; else if (guid.CompareTo(BDAudioGuids.DTSHD_MASTER) == 0) return "DTS-HD Master"; else if (guid.CompareTo(BDAudioGuids.LPCM) == 0) return "LPCM"; else if (guid.CompareTo(BDAudioGuids.DOLBY_TRUEHD) == 0) return "TrueHD"; else if (guid.CompareTo(MediaSubType.MPEG1Audio) == 0) return "MPEG1"; else if (guid.CompareTo(MediaSubType.Mpeg2Audio) == 0) return "MPEG2"; else return Strings.Unknown; }
/// <summary> /// Отгрузка товара по накладной /// </summary> /// <param name="objProfile">Профайл</param> /// <param name="cmdSQL">SQL-команда</param> /// <param name="IntWaybill_Guid">УИ накладной на отгрузку</param> /// <param name="IntWaybill_ShipDate">Дата отгрузки</param> /// <param name="SetIntWaybillShipMode_Guid">УИ варианта отгрузки</param> /// <param name="IntWaybillState_Guid">УИ текущего состояния накладной</param> /// <param name="ERROR_NUM">целочисленный код ошибки</param> /// <param name="ERROR_MES">текст ошибки</param> /// <returns>0 - накладная отгружена; <>0 - ошибка</returns> public static System.Int32 ShippedProductsByIntWaybill(UniXP.Common.CProfile objProfile, System.Data.SqlClient.SqlCommand cmdSQL, System.Guid IntWaybill_Guid, System.DateTime IntWaybill_ShipDate, System.Guid SetIntWaybillShipMode_Guid, ref System.Guid IntWaybillState_Guid, ref System.Int32 ERROR_NUM, ref System.String ERROR_MES) { System.Int32 iRet = -1; if (IntWaybill_Guid.CompareTo(System.Guid.Empty) == 0) { ERROR_MES += ("\nНе указан идентификатор накладной."); return(iRet); } if (IntWaybill_ShipDate.CompareTo(System.DateTime.MinValue) == 0) { ERROR_MES += ("\nУкажите, пожалуйста, дату отгрузки."); return(iRet); } System.Data.SqlClient.SqlConnection DBConnection = null; System.Data.SqlClient.SqlCommand cmd = null; try { if (cmdSQL == null) { DBConnection = objProfile.GetDBSource(); if (DBConnection == null) { ERROR_MES += ("\nНе удалось получить соединение с базой данных."); return(iRet); } cmd = new System.Data.SqlClient.SqlCommand(); cmd.Connection = DBConnection; cmd.CommandType = System.Data.CommandType.StoredProcedure; } else { cmd = cmdSQL; cmd.Parameters.Clear(); } cmd.CommandText = System.String.Format("[{0}].[dbo].[usp_ShipProductsByIntWaybill]", objProfile.GetOptionsDllDBName()); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_Guid", System.Data.SqlDbType.UniqueIdentifier)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybill_ShipDate", System.Data.SqlDbType.Date)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@SetIntWaybillShipMode_Guid", System.Data.SqlDbType.UniqueIdentifier)); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@IntWaybillState_Guid", System.Data.SqlDbType.UniqueIdentifier) { Direction = System.Data.ParameterDirection.Output }); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_NUM", System.Data.SqlDbType.Int, 8) { Direction = System.Data.ParameterDirection.Output }); cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ERROR_MES", System.Data.SqlDbType.NVarChar, 4000) { Direction = System.Data.ParameterDirection.Output }); cmd.Parameters["@IntWaybill_Guid"].Value = IntWaybill_Guid; cmd.Parameters["@IntWaybill_ShipDate"].Value = IntWaybill_ShipDate; cmd.Parameters["@SetIntWaybillShipMode_Guid"].Value = SetIntWaybillShipMode_Guid; iRet = cmd.ExecuteNonQuery(); iRet = System.Convert.ToInt32(cmd.Parameters["@ERROR_NUM"].Value); if (cmd.Parameters["@ERROR_NUM"].Value != System.DBNull.Value) { ERROR_NUM = (System.Convert.ToInt32(cmd.Parameters["@ERROR_NUM"].Value)); } if (cmd.Parameters["@ERROR_MES"].Value != System.DBNull.Value) { ERROR_MES += (System.Convert.ToString(cmd.Parameters["@ERROR_MES"].Value)); } if (cmd.Parameters["@IntWaybillState_Guid"].Value != System.DBNull.Value) { IntWaybillState_Guid = (System.Guid)cmd.Parameters["@IntWaybillState_Guid"].Value; } if (cmdSQL == null) { cmd.Dispose(); DBConnection.Close(); } } catch (System.Exception f) { ERROR_MES += (String.Format("\nНе удалось выполнить отгрузку накладной.\nТекст ошибки: {0}", f.Message)); } return(iRet); }
public MFTestResults Guid_CompareTo_Test9() { /// <summary> /// 1. Creates Guids with different values /// 2. Verifies their equality using CompareTo /// </summary> /// MFTestResults testResult = MFTestResults.Pass; Guid guid1 = Guid.Empty; Log.Comment("Verifing any instance of Guid, regardless of its value, is greater than null"); if (guid1.CompareTo(null) <= 0) { Log.Comment("Expected : " + guid1.ToString() + " is greater than null"); testResult = MFTestResults.Fail; } Byte[] _bArr = new Byte[16]; Log.Comment("Creating a Guid with all bytes zero"); Guid guid2 = new Guid(_bArr); if (guid1.CompareTo(guid2) != 0) { Log.Comment("Expected : " + guid1.ToString() + " equals " + guid2.ToString()); testResult = MFTestResults.Fail; } Guid guid3 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3d); if (guid3.CompareTo(guid1) <= 0) { Log.Comment("Expected : " + guid3.ToString() + " is greater than " + guid1.ToString()); testResult = MFTestResults.Fail; } Guid guid4 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3d); if (guid4.CompareTo(guid3) != 0) { Log.Comment("Expected : " + guid4.ToString() + " is equal to " + guid3.ToString()); testResult = MFTestResults.Fail; } Guid guid5 = new Guid(0x4dff36b5, 0x9dde, 0x4f76, 0x9a, 0x2a, 0x96, 0x43, 0x50, 0x47, 0x06, 0x3e); if (guid5.CompareTo(guid4) <= 0) { Log.Comment("Expected : " + guid5.ToString() + " is greater than " + guid4.ToString()); testResult = MFTestResults.Fail; } if (guid4.CompareTo(guid5) >= 0) { Log.Comment("Expected : " + guid4.ToString() + " is less than " + guid5.ToString()); testResult = MFTestResults.Fail; } return testResult; }
HRESULT Microsoft.WindowsAPICodePack.Controls.IServiceProvider.QueryService( ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { HRESULT hr = HRESULT.S_OK; if (guidService.CompareTo(new Guid(ExplorerBrowserIIDGuid.IExplorerPaneVisibility)) == 0) { // Responding to this SID allows us to control the visibility of the // explorer browser panes ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IExplorerPaneVisibility)); hr = HRESULT.S_OK; } else if (guidService.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser)) == 0) { // Responding to this SID allows us to hook up our ICommDlgBrowser // implementation so we get selection change events from the view. if (riid.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser)) == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(ICommDlgBrowser)); hr = HRESULT.S_OK; } else { ppvObject = IntPtr.Zero; hr = HRESULT.E_NOINTERFACE; } } else { IntPtr nullObj = IntPtr.Zero; ppvObject = nullObj; hr = HRESULT.E_NOINTERFACE; } return hr; }
public bool runTest() { Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer); int iCountErrors = 0; int iCountTestcases = 0; String strLoc = "Loc_000oo"; String strValue = String.Empty; Guid gd1; Guid gd2; Byte[] bytes; try { strLoc = "Loc_001oo"; gd1 = Guid.NewGuid(); strValue = "Hello World"; iCountTestcases++; try { gd1.CompareTo(strValue); iCountErrors++; Console.WriteLine( "Err_765sgs! Exception now thrown"); }catch(ArgumentException){ }catch (Exception exc) { iCountErrors++; Console.WriteLine( "Error_94f8v! Unexpected Exception, got exc=="+exc.GetType().Name); } strLoc = "Loc_001oo"; bytes = new Byte[16]; for(int i=0; i<bytes.Length; i++) bytes[i] = (byte)i; gd1 = new Guid(bytes); gd2 = new Guid(bytes); iCountTestcases++; if(gd1.CompareTo(gd2)!=0){ iCountErrors++; Console.WriteLine( "Error_8743dgs! wrong value returned"); } iCountTestcases++; if(gd1.CompareTo(gd1)!=0){ iCountErrors++; Console.WriteLine("Error_3276gg! wrong value returned"); } bytes = new Byte[16]; for(int i=0; i<bytes.Length; i++) bytes[i] = (byte)i; gd1 = new Guid(bytes); bytes = new Byte[16]; for(int i=0, j=16; i<bytes.Length; i++, j--) bytes[i] = (byte)j; gd2 = new Guid(bytes); iCountTestcases++; if(gd1.CompareTo(gd2)>=0){ iCountErrors++; Console.WriteLine("Error_9734sg! wrong value returned, \r\n {0} \r\n {1}", gd1.ToString(), gd2.ToString()); } bytes = new Byte[16]; for(int i=0; i<bytes.Length; i++) bytes[i] = (byte)i; gd1 = new Guid(bytes); bytes = new Byte[16]; for(int i=0, j=16; i<bytes.Length; i++, j--) bytes[i] = (byte)j; gd2 = new Guid(bytes); iCountTestcases++; if(gd2.CompareTo(gd1)<=0){ iCountErrors++; Console.WriteLine("Error_78934dg! wrong value returned"); } bytes = new Byte[16]; for(int i=0; i<bytes.Length; i++) bytes[i] = (byte)i; gd1 = new Guid(bytes); iCountTestcases++; if(gd2.CompareTo(null)<=0){ iCountErrors++; Console.WriteLine("Error_8473dsg! wrong value returned"); } } catch (Exception exc_general ) { ++iCountErrors; Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString()); } if ( iCountErrors == 0 ) { Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString()); return true; } else { Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums ); return false; } }
/// <summary> /// Gets properties whose values are GUIDs. /// </summary> /// <param name="propid">Identifier of the hierarchy property</param> /// <param name="guid"> Pointer to a GUID property specified in propid</param> /// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code.</returns> public override int GetGuidProperty(int propid, out Guid guid) { guid = Guid.Empty; switch ((__VSHPROPID)propid) { case __VSHPROPID.VSHPROPID_ProjectIDGuid: guid = this.projectInstanceGuid; break; default: return base.GetGuidProperty(propid, out guid); } CCITracing.TraceCall(String.Format(CultureInfo.CurrentCulture, "Guid for {0} property", propid)); if (guid.CompareTo(Guid.Empty) == 0) { return VSConstants.DISP_E_MEMBERNOTFOUND; } return VSConstants.S_OK; }
internal void connectToExistingLobby(Guid guid) { try { getServiceReady(); if (guid.CompareTo(new Guid()) != 0) { bool success = monopolyDealService.joinExistingGameLobby(guid.boxGuid(), thisClientGuid.boxGuid()); if (success) { gameLobbyGuid = guid; gameOnServiceGuid = guid; addToLog("Connected to game. Guid:" + gameLobbyGuid.ToString()); } else { addToLog("Failed to connect to game."); } } } catch (Exception ex) { addToLog(ex.Message); } }
public int CompareTo(Customer other) { return(Id.CompareTo(other.Id)); }
/// <summary> /// /// </summary> /// <param name="guidService">calling service</param> /// <param name="riid">requested interface guid</param> /// <param name="ppvObject">caller-allocated memory for interface pointer</param> /// <returns></returns> HResult GodLesZ.Library.Win7.Controls.IServiceProvider.QueryService( ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { HResult hr = HResult.Ok; if (guidService.CompareTo(new Guid(ExplorerBrowserIIDGuid.IExplorerPaneVisibility)) == 0) { // Responding to this SID allows us to control the visibility of the // explorer browser panes ppvObject = Marshal.GetComInterfaceForObject(this, typeof(IExplorerPaneVisibility)); hr = HResult.Ok; } else if (guidService.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser)) == 0) { if (riid.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser)) == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(ICommDlgBrowser3)); hr = HResult.Ok; } // The below lines are commented out to decline requests for the ICommDlgBrowser2 interface. // This interface is incorrectly marshaled back to unmanaged, and causes an exception. // There is a bug for this, I have not figured the underlying cause. // Remove this comment and uncomment the following code to enable the ICommDlgBrowser2 interface //else if (riid.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser2)) == 0) //{ // ppvObject = Marshal.GetComInterfaceForObject(this, typeof(ICommDlgBrowser3)); // hr = HResult.Ok; //} else if (riid.CompareTo(new Guid(ExplorerBrowserIIDGuid.ICommDlgBrowser3)) == 0) { ppvObject = Marshal.GetComInterfaceForObject(this, typeof(ICommDlgBrowser3)); hr = HResult.Ok; } else { ppvObject = IntPtr.Zero; hr = HResult.NoInterface; } } else { IntPtr nullObj = IntPtr.Zero; ppvObject = nullObj; hr = HResult.NoInterface; } return hr; }
/// <include file='doc\Hierarchy.uex' path='docs/doc[@for="HierarchyNode.GetGuidProperty1"]/*' /> public virtual int GetGuidProperty(int propid, out Guid guid) { guid = Guid.Empty; if (propid == (int)__VSHPROPID.VSHPROPID_TypeGuid) { switch (this.nodeType) { case HierarchyNodeType.Reference: case HierarchyNodeType.Root: case HierarchyNodeType.RefFolder: guid = Guid.Empty; break; case HierarchyNodeType.Folder: guid = HierarchyNode.guidItemTypePhysicalFolder; break; } } if (guid.CompareTo(Guid.Empty) == 0) return NativeMethods.DISP_E_MEMBERNOTFOUND; return NativeMethods.S_OK; }
public static void TestCompareTo(Guid guid, object obj, int expected) { if (obj is Guid) { Assert.Equal(expected, Math.Sign(guid.CompareTo((Guid)obj))); } IComparable comparable = guid; Assert.Equal(expected, Math.Sign(comparable.CompareTo(obj))); }
public void CompareToGuid_2 () { var g1 = new Guid ("d1c5088bc188464fb77b0fd2be2d005e"); var g2 = new Guid ("d2c5088bc188464fb77b0fd2be2d005e"); var g3 = new Guid ("00c5088bc188464fb77b0fd2be2d005e"); Assert.AreEqual (-1, g1.CompareTo (g2), "#1"); Assert.AreEqual (1, g1.CompareTo (g3), "#2"); Assert.AreEqual (1, g1.CompareTo (Guid.Empty), "#3"); }
public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject) { ppvObject = IntPtr.Zero; if (guidService.CompareTo(WebBrowserAPI.IID_IInternetSecurityManager) == 0) { // 自分から IID_IInternetSecurityManager を QueryInterface して返す var punk = Marshal.GetIUnknownForObject(this); return Marshal.QueryInterface(punk, ref riid, out ppvObject); } return HRESULT.E_NOINTERFACE; }
public static bool IsVisualCSharpProject(Guid projectKind) { return projectKind.CompareTo(new Guid("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")) == 0; }