Exemplo n.º 1
0
        public void Create()
        {
            // SqlGuid (Byte[])
            byte[] b = new byte[16];
            b[0] = 100;
            b[1] = 200;

            try
            {
                SqlGuid Test = new SqlGuid(b);

                // SqlGuid (Guid)
                Guid TestGuid = new Guid(b);
                Test = new SqlGuid(TestGuid);

                // SqlGuid (string)
                Test = new SqlGuid("12345678-1234-1234-1234-123456789012");

                // SqlGuid (int, short, short, byte, byte, byte, byte, byte, byte, byte, byte)
                Test = new SqlGuid(10, 1, 2, 13, 14, 15, 16, 17, 19, 20, 21);
            }
            catch (Exception e)
            {
                Assert.False(true);
            }
        }
Exemplo n.º 2
0
        public static void AddContainerACL(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString containerName,
            SqlString containerPublicReadAccess,
            SqlString accessPolicyId,
            SqlDateTime start, SqlDateTime expiry,
            SqlBoolean canRead,
            SqlBoolean canWrite,
            SqlBoolean canDeleteBlobs,
            SqlBoolean canListBlobs,
            SqlGuid LeaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Enumerations.ContainerPublicReadAccess cpraNew;
            if(!Enum.TryParse<Enumerations.ContainerPublicReadAccess>(containerPublicReadAccess.Value, out cpraNew))
            {
                StringBuilder sb = new StringBuilder("\"" + containerPublicReadAccess.Value + "\" is an invalid ContainerPublicReadAccess value. Valid values are: ");
                foreach (string s in Enum.GetNames(typeof(Enumerations.ContainerPublicReadAccess)))
                    sb.Append("\"" + s + "\" ");
                throw new ArgumentException(sb.ToString());
            }

            AzureBlobService abs = new AzureBlobService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            Container cont = abs.GetContainer(containerName.Value);

            Enumerations.ContainerPublicReadAccess cpra;
            SharedAccessSignature.SharedAccessSignatureACL sasACL = cont.GetACL(out cpra,
                LeaseId.IsNull ? (Guid?)null : LeaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            string strPermissions = "";
            if (canRead.IsTrue)
                strPermissions += "r";
            if (canWrite.IsTrue)
                strPermissions += "w";
            if (canDeleteBlobs.IsTrue)
                strPermissions += "d";
            if (canListBlobs.IsTrue)
                strPermissions += "l";

            SharedAccessSignature.AccessPolicy ap = new SharedAccessSignature.AccessPolicy()
            {
                Start = start.Value,
                Expiry = expiry.Value,
                Permission = strPermissions
            };

            sasACL.SignedIdentifier.Add(new SharedAccessSignature.SignedIdentifier()
                {
                    AccessPolicy = ap,
                    Id = accessPolicyId.Value
                });

            cont.UpdateContainerACL(cpraNew, sasACL,
                LeaseId.IsNull ? (Guid?)null : LeaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);
        }
Exemplo n.º 3
0
    public static SqlInt32 Sales_LicenseKeys_Activations(SqlGuid licenseKeyId)
    {
        string sql = "select isnull(count(*),0) from Sales_LicenseKeyActivations where LicenseKeyId=@Id";
          SqlCommand cmd = new SqlCommand(sql);
          cmd.Parameters.AddWithValue("@Id", licenseKeyId);

          int count = 0;
          using (SqlConnection con = new SqlConnection("context connection=true"))
          {
               try
               {
                    cmd.Connection = con;
                    con.Open();
                    count = (int)cmd.ExecuteScalar();
               }
               catch (Exception ex)
               {
                    throw ex;
               }
               finally
               {
                    if (con != null)
                         con.Close();
               }
          }
          return new SqlInt32(count);
    }
Exemplo n.º 4
0
 public static SqlGuid OrGuid3(
     SqlGuid value0,
     SqlGuid value1,
     SqlGuid value2)
 {
     return OrSqlGuid(value0, value1, value2);
 }
 override public void SetCapacity(int capacity) {
     SqlGuid[] newValues = new SqlGuid[capacity];
     if (null != values) {
         Array.Copy(values, 0, newValues, 0, Math.Min(capacity, values.Length));
     }
     values = newValues;
 }
Exemplo n.º 6
0
        public static void ChangeContainerPublicAccessMethod(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString containerName,
            SqlString containerPublicReadAccess,            
            SqlGuid LeaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Enumerations.ContainerPublicReadAccess cpraNew;
            if (!Enum.TryParse<Enumerations.ContainerPublicReadAccess>(containerPublicReadAccess.Value, out cpraNew))
            {
                StringBuilder sb = new StringBuilder("\"" + containerPublicReadAccess.Value + "\" is an invalid ContainerPublicReadAccess value. Valid values are: ");
                foreach (string s in Enum.GetNames(typeof(Enumerations.ContainerPublicReadAccess)))
                    sb.Append("\"" + s + "\" ");
                throw new ArgumentException(sb.ToString());
            }

            AzureBlobService abs = new AzureBlobService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            Container cont = abs.GetContainer(containerName.Value);

            Enumerations.ContainerPublicReadAccess cpra;
            SharedAccessSignature.SharedAccessSignatureACL sasACL = cont.GetACL(out cpra,
                LeaseId.IsNull ? (Guid?)null : LeaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            cont.UpdateContainerACL(cpraNew, sasACL,
                LeaseId.IsNull ? (Guid?)null : LeaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);
        }
Exemplo n.º 7
0
 public static SqlGuid OrGuid4(
     SqlGuid value0,
     SqlGuid value1,
     SqlGuid value2,
     SqlGuid value3)
 {
     return OrSqlGuid(value0, value1, value2, value3);
 }
Exemplo n.º 8
0
        public static void AddInputEndpointToPersistentVM(
            SqlString certificateThumbprint,
            SqlGuid sgSubscriptionId,
            SqlString serviceName,
            SqlString deploymentSlots,
            SqlString vmName,
            SqlString EndpointName,
            SqlInt32 LocalPort,
            SqlBoolean EnableDirectServerReturn,
            SqlInt32 Port,
            SqlString Protocol,
            SqlString Vip,
            SqlBoolean fBlocking)
        {
            X509Certificate2 certificate = RetrieveCertificateInStore(certificateThumbprint.Value);
            Azure.Management.Deployment result = Azure.Internal.Management.GetDeployments(
                certificate,
                sgSubscriptionId.Value,
                serviceName.Value,
                deploymentSlots.Value);

            var vmToAdd = (ITPCfSQL.Azure.Management.PersistentVMRole)result.RoleList.FirstOrDefault(item => item.RoleName.Equals(vmName.Value, StringComparison.InvariantCultureIgnoreCase));

            if (vmToAdd == null)
                throw new ArgumentException("No PersistentVMRole with name " + vmName.Value + " found in sgSubscriptionId = " +
                    sgSubscriptionId.Value + ", serviceName = " + serviceName.Value + ", deploymentSlots = "
                    + deploymentSlots.Value + ".");

            ITPCfSQL.Azure.Management.DeploymentRoleConfigurationSetsConfigurationSetInputEndpoint[] driiesTemp = new
                    ITPCfSQL.Azure.Management.DeploymentRoleConfigurationSetsConfigurationSetInputEndpoint[vmToAdd.ConfigurationSets.ConfigurationSet.InputEndpoints.Length + 1];

            Array.Copy(vmToAdd.ConfigurationSets.ConfigurationSet.InputEndpoints, driiesTemp, vmToAdd.ConfigurationSets.ConfigurationSet.InputEndpoints.Length);

            driiesTemp[driiesTemp.Length - 1] = new ITPCfSQL.Azure.Management.DeploymentRoleConfigurationSetsConfigurationSetInputEndpoint()
            {
                Name = EndpointName.Value,
                LocalPort = LocalPort.Value,
                EnableDirectServerReturn = EnableDirectServerReturn.Value,
                Port = Port.Value,
                Protocol = Protocol.Value,
                Vip = Vip.Value
            };

            vmToAdd.ConfigurationSets.ConfigurationSet.InputEndpoints = driiesTemp;

            var output = ITPCfSQL.Azure.Internal.Management.UpdatePersistentVMRole(
                certificate,
                sgSubscriptionId.Value,
                serviceName.Value,
                result.Name,
                vmToAdd);

            PushOperationStatus(
                certificate,
                sgSubscriptionId.Value,
                new Guid(output[ITPCfSQL.Azure.Internal.Constants.HEADER_REQUEST_ID]),
                fBlocking.IsNull ? false : fBlocking.Value);
        }
Exemplo n.º 9
0
 public static void DropTable(
     SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
     SqlString tableName,
     SqlGuid xmsclientrequestId)
 {
     ITPCfSQL.Azure.AzureTableService ats = new AzureTableService(accountName.Value, sharedKey.Value, useHTTPS.Value);
     ats.GetTable(tableName.Value).Drop(
         xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);
 }
Exemplo n.º 10
0
 public static SqlGuid OrGuid5(
     SqlGuid value0,
     SqlGuid value1,
     SqlGuid value2,
     SqlGuid value3,
     SqlGuid value4)
 {
     return OrSqlGuid(value0, value1, value2, value3, value4);
 }
Exemplo n.º 11
0
 public static void CreateQueue(
     SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
     SqlString queueName,
     SqlInt32 timeoutSeconds,
     SqlGuid xmsclientrequestId)
 {
     ITPCfSQL.Azure.AzureQueueService aqs = new AzureQueueService(accountName.Value, sharedKey.Value, useHTTPS.Value);
     aqs.CreateQueue(queueName.Value, timeoutSeconds.Value,
         xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);
 }
Exemplo n.º 12
0
        public int CompareTo(object value)
        {
            if (!(value is SqlGuid))
            {
                throw ADP.WrongType(value.GetType(), typeof(SqlGuid));
            }
            SqlGuid guid = (SqlGuid)value;

            return(this.CompareTo(guid));
        }
        public static SqlBoolean NotEquals(SqlGuid x, SqlGuid y)
        {
            SqlBoolean res = Equals(x, y);

            if (res.IsFalse)
            {
                return(SqlBoolean.True);
            }
            return(SqlBoolean.False);
        }
Exemplo n.º 14
0
        // IComparable
        // Compares this object to another object, returning an integer that
        // indicates the relationship.
        // Returns a value less than zero if this < object, zero if this = object,
        // or a value greater than zero if this > object.
        // null is considered to be less than any instance.
        // If object is not of same type, this method throws an ArgumentException.
        public int CompareTo(object value)
        {
            if (value is SqlGuid)
            {
                SqlGuid i = (SqlGuid)value;

                return(CompareTo(i));
            }
            throw ADP.WrongType(value.GetType(), typeof(SqlGuid));
        }
Exemplo n.º 15
0
 protected CmsFile(Guid fileTypeID)
 {
     this.fileTypeID = fileTypeID;
     this.state = CmsState.Unsaved;
     this.version = 1;
     this.id = Guid.NewGuid();
     this.fileID = id;
     dateCreated = DateTime.Now;
     dateModified = dateCreated;
     this.revisionSourceID = SqlGuid.Null;
 }
Exemplo n.º 16
0
        public static void CreateQueue_Embedded(
            SqlString logicalConnectionName,
            SqlString queueName,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            CreateQueue(config.AccountName, config.SharedKey, config.UseHTTPS,
                queueName, timeoutSeconds, xmsclientrequestId);
        }
Exemplo n.º 17
0
        public static void DequeueMessage_Embedded(
            SqlString logicalConnectionName,
            SqlString queueName,
            SqlInt32 visibilityTimeoutSeconds, // we won't support peek so we should do it fast
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            DequeueMessage(config.AccountName, config.SharedKey, config.UseHTTPS,
                queueName, visibilityTimeoutSeconds, timeoutSeconds, xmsclientrequestId);
        }
Exemplo n.º 18
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="connectionString">Connection string to be used when accessing the database.</param>
        /// <param name="col_Ord_GuidID">[To be supplied.]</param>
        public tblOrder_Record(string connectionString, System.Data.SqlTypes.SqlGuid col_Ord_GuidID)
        {
#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                string DebugConnectionString = connectionString;

                if (DebugConnectionString == System.String.Empty)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromConfigurationFile;
                }

                if (DebugConnectionString == System.String.Empty)
                {
                    DebugConnectionString = OlymarsDemo.DataClasses.Information.GetConnectionStringFromRegistry;
                }

                if (DebugConnectionString != String.Empty)
                {
                    System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection(DebugConnectionString);

                    sqlConnection.Open();

                    System.Data.SqlClient.SqlCommand sqlCommand = sqlConnection.CreateCommand();

                    sqlCommand.CommandType = System.Data.CommandType.Text;
                    sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'tblOrder'";

                    int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                    sqlConnection.Close();

                    int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                    if (CurrentRevision != OriginalRevision)
                    {
                        throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}", "tblOrder", CurrentRevision, OriginalRevision));
                    }
                }
            }
#endif

            this.recordWasLoadedFromDB = true;
            this.recordIsLoaded        = false;

            this.connectionString        = connectionString;
            this.lastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.ConnectionString;

            this.col_Ord_GuidID = col_Ord_GuidID;
        }
        public static SqlBoolean GreaterThanOrEqual(SqlGuid x, SqlGuid y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            int res = x.CompareTo(y);

            if (res >= 0)
            {
                return(SqlBoolean.True);
            }
            return(SqlBoolean.False);
        }
        public static SqlBoolean LessThan(SqlGuid x, SqlGuid y)
        {
            if (x.IsNull || y.IsNull)
            {
                return(SqlBoolean.Null);
            }

            int res = x.CompareTo(y);

            if (res < 0)
            {
                return(SqlBoolean.True);
            }
            return(SqlBoolean.False);
        }
Exemplo n.º 21
0
        public static void AcquireBlobInfiniteLease_Embedded(
            SqlString logicalConnectionName,
            SqlString containerName,
            SqlString blobName,
            SqlGuid proposedLeaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            AcquireBlobInfiniteLease(
                config.AccountName, config.SharedKey, config.UseHTTPS,
                containerName, blobName,
                proposedLeaseId, timeoutSeconds, xmsclientrequestId);
        }
Exemplo n.º 22
0
        public override bool Equals(object value)
        {
            if (!(value is SqlGuid))
            {
                return(false);
            }
            SqlGuid guid = (SqlGuid)value;

            if (guid.IsNull || this.IsNull)
            {
                return(guid.IsNull && this.IsNull);
            }
            SqlBoolean flag = this == guid;

            return(flag.Value);
        }
Exemplo n.º 23
0
        // Comparison operators
        private static EComparison Compare(SqlGuid x, SqlGuid y)
        {
            //Swap to the correct order to be compared
            for (int i = 0; i < SizeOfGuid; i++)
            {
                byte b1, b2;

                b1 = x.m_value[s_rgiGuidOrder[i]];
                b2 = y.m_value[s_rgiGuidOrder[i]];
                if (b1 != b2)
                {
                    return((b1 < b2) ? EComparison.LT : EComparison.GT);
                }
            }
            return(EComparison.EQ);
        }
Exemplo n.º 24
0
 private static EComparison Compare(SqlGuid x, SqlGuid y)
 {
     for (int i = 0; i < SizeOfGuid; i++)
     {
         byte num3 = x.m_value[x_rgiGuidOrder[i]];
         byte num2 = y.m_value[x_rgiGuidOrder[i]];
         if (num3 != num2)
         {
             if (num3 >= num2)
             {
                 return(EComparison.GT);
             }
             return(EComparison.LT);
         }
     }
     return(EComparison.EQ);
 }
Exemplo n.º 25
0
 public static SqlString GetName(SqlGuid id)
 {
     string val = "";
       SqlConnection connection = new SqlConnection("context connection=true");
       connection.Open();
       GetFieldFromTable(connection, id, "Firstname,LastName", "System_Users", ref val);
       GetFieldFromTable(connection, id, "Name", "Logistics_Organizations", ref val);
       GetFieldFromTable(connection, id, "FirstName,LastName", "HR_Staff", ref val);
       GetFieldFromTable(connection, id, "Name", "Accounting_Accounts", ref val);
       GetFieldFromTable(connection, id, "Memo", "Accounting_LedgerItems", ref val);
       GetFieldFromTable(connection, id, "PrimaryContactNameFirst,PrimaryContactNameLast", "Sales_Orders", ref val);
       GetFieldFromTable(connection, id, "Name", "Logistics_Addresses", ref val);
       GetFieldFromTable(connection, id, "Right(Number, 4) as 'Number'", "Accounting_CreditCards", ref val);
       GetFieldFromTable(connection, id, "SUBSTRING(Memo, 1, 10) as 'Memo', '- ARB Rule' as 'ARB'", "Accounting_RecurringBillables", ref val);
       GetFieldFromTable(connection, id, "Name", "Logistics_Features", ref val);
       return val ?? "";
 }
Exemplo n.º 26
0
        // Compares this instance with a specified object
        public override bool Equals(object value)
        {
            if (!(value is SqlGuid))
            {
                return(false);
            }

            SqlGuid i = (SqlGuid)value;

            if (i.IsNull || IsNull)
            {
                return(i.IsNull && IsNull);
            }
            else
            {
                return((this == i).Value);
            }
        }
Exemplo n.º 27
0
        public static void AcquireBlobInfiniteLease(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString containerName,
            SqlString blobName,
            SqlGuid proposedLeaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            AzureBlobService abs = new AzureBlobService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            Container cont = abs.GetContainer(containerName.Value);
            Blob blob = cont.GetBlob(blobName.Value);

            Responses.LeaseBlobResponse lbr = blob.AcquireInfiniteLease(
                proposedLeaseId.IsNull ? (Guid?)null : proposedLeaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            PushLeaseBlobResponse(lbr);
        }
Exemplo n.º 28
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="sqlTransaction">A valid System.Data.SqlClient.SqlTransaction object.</param>
        /// <param name="col_Ord_GuidID">[To be supplied.]</param>
        public tblOrder_Record(SqlTransaction sqlTransaction, System.Data.SqlTypes.SqlGuid col_Ord_GuidID)
        {
#if OLYMARS_DEBUG
            object olymarsDebugCheck = System.Configuration.ConfigurationSettings.AppSettings["OlymarsDebugCheck"];
            if (olymarsDebugCheck == null || (string)olymarsDebugCheck == "True")
            {
                bool NotAlreadyOpened = false;
                if (sqlTransaction.Connection.State == System.Data.ConnectionState.Closed)
                {
                    NotAlreadyOpened = true;
                    sqlTransaction.Connection.Open();
                }

                System.Data.SqlClient.SqlCommand sqlCommand = sqlTransaction.Connection.CreateCommand();

                sqlCommand.CommandType = System.Data.CommandType.Text;
                sqlCommand.CommandText = "Select sysobjects.schema_ver from sysobjects where sysobjects.name = 'tblOrder'";
                sqlCommand.Transaction = sqlTransaction;

                int CurrentRevision = (int)sqlCommand.ExecuteScalar();

                if (NotAlreadyOpened)
                {
                    sqlTransaction.Connection.Close();
                }

                int OriginalRevision = ((OlymarsDemo.DataClasses.OlymarsInformationAttribute)System.Attribute.GetCustomAttribute(this.GetType(), typeof(OlymarsDemo.DataClasses.OlymarsInformationAttribute), false)).SqlObjectDependancyRevision;
                if (CurrentRevision != OriginalRevision)
                {
                    throw new System.InvalidOperationException(System.String.Format("OLYMARS: This code is not in sync anymore with [{0}]. It was generated when [{0}] version was: {2}. Current [{0}] version is: {1}{3}{3}You can either regenerate the code for this class so that it will be based on the new version or edit the configuration file of the class caller application and paste the following code:{3}{3}<?xml version=\"1.0\" encoding=\"utf-8\" ?>{3}<configuration>{3}\t<appSettings>{3}\t\t<add key=\"OlymarsDebugCheck\" value=\"False\" />{3}\t</appSettings>{3}</configuration>{3}{3}You will need to reload the caller application if it is a Windows Forms based application.", "tblOrder", CurrentRevision, OriginalRevision, System.Environment.NewLine));
                }
            }
#endif

            this.recordWasLoadedFromDB = true;
            this.recordIsLoaded        = false;

            this.sqlTransaction          = sqlTransaction;
            this.lastKnownConnectionType = OlymarsDemo.DataClasses.ConnectionType.SqlTransaction;

            this.col_Ord_GuidID = col_Ord_GuidID;
        }
Exemplo n.º 29
0
                public void GetReady() 
                {
                	byte [] b1 = new byte [16];
                	byte [] b2 = new byte [16];
                	byte [] b3 = new byte [16];
                	byte [] b4 = new byte [16];

                	b1 [0] = 1;
                	b1 [1] = 10;
                	b2 [0] = 100;
                	b2 [1] = 15;
                	b3 [0] = 100;
                	b3 [1] = 15;
                	b4 [0] = 250;
                	b4 [1] = 250;

                   	Test1 = new SqlGuid (b1);
			Test2 = new SqlGuid (b2);
                	Test3 = new SqlGuid (b3);
                	Test4 = new SqlGuid (b4);
                }
Exemplo n.º 30
0
        public SqlGuidTest()
        {
            byte[] b1 = new byte[16];
            byte[] b2 = new byte[16];
            byte[] b3 = new byte[16];
            byte[] b4 = new byte[16];

            b1[0] = 1;
            b1[1] = 10;
            b2[0] = 100;
            b2[1] = 15;
            b3[0] = 100;
            b3[1] = 15;
            b4[0] = 250;
            b4[1] = 250;

            _test1 = new SqlGuid(b1);
            _test2 = new SqlGuid(b2);
            _test3 = new SqlGuid(b3);
            _test4 = new SqlGuid(b4);
        }
Exemplo n.º 31
0
        public string ClassifyBusinessNeed(string id, string xml)
        {
            string rez = string.Empty;
            string json = string.Empty;
            XmlDocument xm = new XmlDocument();
            SqlGuid gid = new SqlGuid();
            try
            {
                gid = SqlGuid.Parse(id);
            }
            catch { };

            using (SqlConnection con = new SqlConnection(connectionString()))
            {

                con.Open();
                SqlCommand command = new SqlCommand("dbo.ClassifyBusinessNeed", con);
                command.Parameters.Add("@Id", SqlDbType.UniqueIdentifier).Value = gid;
                command.Parameters.Add("@InXml", SqlDbType.Xml).Value = xml;

                command.Parameters.Add("@OutXML", SqlDbType.Xml).Direction = ParameterDirection.Output;
                command.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter da = new SqlDataAdapter(command);
                int ret = command.ExecuteNonQuery();
                try
                {
                    rez = (string)command.Parameters["@OutXML"].Value;
                    xm.LoadXml(rez);
                    json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(xm);
                }
                catch
                {
                    json = string.Empty;
                }
                con.Close();
            }
            return json;
        }
Exemplo n.º 32
0
        public int CompareTo(SqlGuid value)
        {
            // If both Null, consider them equal.
            // Otherwise, Null is less than anything.
            if (IsNull)
            {
                return(value.IsNull ? 0 : -1);
            }
            else if (value.IsNull)
            {
                return(1);
            }

            if (this < value)
            {
                return(-1);
            }
            if (this > value)
            {
                return(1);
            }
            return(0);
        }
Exemplo n.º 33
0
        public static void DequeueMessage(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString queueName,
            SqlInt32 visibilityTimeoutSeconds, // we won't support peek so we should do it fast
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            ITPCfSQL.Azure.AzureQueueService aqs = new AzureQueueService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            ITPCfSQL.Azure.Queue q = aqs.GetQueue(queueName.Value);
            Message msg = q.Get(visibilityTimeoutSeconds.Value, timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            if (msg == null) // empty queue
                return;

            msg.Delete(timeoutSeconds.Value,
                 xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            try // try to convert it to XML, if it fails, return a simple string
            {
                SqlXml xml;
                using (System.IO.StringReader sr = new System.IO.StringReader(msg.Body))
                {
                    using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(sr))
                    {
                        xml = new SqlXml(reader);
                    }
                }

                Utils.PushSingleRecordResult(xml.Value, System.Data.SqlDbType.Xml);
            }
            catch (Exception exce)
            {
                SqlContext.Pipe.Send("Cannot parse as XML:" + exce.Message);
                Utils.PushSingleRecordResult(msg.Body, System.Data.SqlDbType.NVarChar);
            }
        }
Exemplo n.º 34
0
 //-------------------------------------------------------------------------------------------
 public static void GetFieldFromTable(SqlConnection connection, SqlGuid id, string fields, string tablename, ref string val)
 {
     if (val == null || val.Trim() == "")
       {
            string sql = "select top 1 " + fields + " from " + tablename + " where id=@id";
            using (SqlCommand command = new SqlCommand(sql, connection))
            {
                 command.Parameters.AddWithValue("@id", id);
                 SqlDataReader reader = command.ExecuteReader();
                 if (reader.Read())
                 {
                      for (int i = 0; i < reader.FieldCount; i++)
                      {
                           val += reader[i].ToString();
                           if (i < reader.FieldCount - 1)
                           {
                                val += " "; // add spacing for readability
                           }
                      }
                 }
                 reader.Close();
            }
       }
 }
Exemplo n.º 35
0
 public int CompareTo(SqlGuid value)
 {
     if (this.IsNull)
     {
         if (!value.IsNull)
         {
             return(-1);
         }
         return(0);
     }
     if (value.IsNull)
     {
         return(1);
     }
     if (SqlBoolean.op_True(this < value))
     {
         return(-1);
     }
     if (SqlBoolean.op_True(this > value))
     {
         return(1);
     }
     return(0);
 }
Exemplo n.º 36
0
        public static void BreakBlobLeaseImmediately_Embedded(
            SqlString logicalConnectionName,
            SqlString containerName,
            SqlString blobName,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            BreakBlobLeaseImmediately(
                config.AccountName, config.SharedKey, config.UseHTTPS,
                containerName, blobName,
                timeoutSeconds, xmsclientrequestId);
        }
Exemplo n.º 37
0
        public static void BreakBlobLeaseWithGracePeriod(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString containerName,
            SqlString blobName,
            SqlInt32 leaseBreakPeriod,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            AzureBlobService abs = new AzureBlobService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            Container cont = abs.GetContainer(containerName.Value);
            Blob blob = cont.GetBlob(blobName.Value);

            Responses.LeaseBlobResponse lbr = blob.BreakLeaseWithGracePeriod(
                leaseBreakPeriod.IsNull ? 0 : leaseBreakPeriod.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            PushLeaseBlobResponse(lbr);
        }
Exemplo n.º 38
0
        internal static SqlGuid GetSqlGuid( SmiEventSink_Default sink, ITypedGettersV3 getters, int ordinal, SmiMetaData metaData ) {
            SqlGuid result;
            if ( CanAccessGetterDirectly( metaData, ExtendedClrTypeCode.SqlGuid ) ) {
                if ( IsDBNull_Unchecked( sink, getters, ordinal ) ) {
                    result = SqlGuid.Null;
                }
                else {
                    Guid temp = GetGuid_Unchecked( sink, getters, ordinal );
                    result = new SqlGuid( temp );
                }
            }
            else {
                object obj = GetSqlValue( sink, getters, ordinal, metaData, null  );
                if (null == obj) {
                    throw ADP.InvalidCast();
                }
                result = (SqlGuid) obj;
            }

            return result;
        }
Exemplo n.º 39
0
        //  implements SqlClient 1.1-compatible GetSqlValue() semantics for everything except output parameters
        internal static object GetSqlValue(
            SmiEventSink_Default    sink,
            ITypedGettersV3         getters,
            int                     ordinal,
            SmiMetaData             metaData,
            SmiContext              context
            ) {
            object result = null;
            if ( IsDBNull_Unchecked( sink, getters, ordinal ) ) {
                if (SqlDbType.Udt == metaData.SqlDbType) {
                    result = NullUdtInstance(metaData);
                }
                else {
                    result = __typeSpecificNullForSqlValue[(int)metaData.SqlDbType];
                }
            }
            else {
                switch( metaData.SqlDbType ) {
                    case SqlDbType.BigInt:
                        result = new SqlInt64( GetInt64_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Binary:
                        result = GetSqlBinary_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.Bit:
                        result = new SqlBoolean( GetBoolean_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Char:
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.DateTime:
                        result = new SqlDateTime( GetDateTime_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Decimal:
                        result = GetSqlDecimal_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.Float:
                        result = new SqlDouble( GetDouble_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Image:
                        result = GetSqlBinary_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.Int:
                        result = new SqlInt32( GetInt32_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Money:
                        result = GetSqlMoney_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.NChar: 
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.NText: 
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.NVarChar: 
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Real:
                        result = new SqlSingle( GetSingle_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.UniqueIdentifier:
                        result = new SqlGuid( GetGuid_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.SmallDateTime:
                        result = new SqlDateTime( GetDateTime_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.SmallInt:
                        result = new SqlInt16( GetInt16_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.SmallMoney:
                        result = GetSqlMoney_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.Text:
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Timestamp:
                        result = GetSqlBinary_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.TinyInt:
                        result = new SqlByte( GetByte_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.VarBinary:
                        result = GetSqlBinary_Unchecked( sink, getters, ordinal );
                        break;
                    case SqlDbType.VarChar:
                        result = new SqlString( GetString_Unchecked( sink, getters, ordinal ) );
                        break;
                    case SqlDbType.Variant:
                        metaData = getters.GetVariantType( sink, ordinal );
                        sink.ProcessMessagesAndThrow();
                        Debug.Assert( SqlDbType.Variant != metaData.SqlDbType, "Variant-within-variant causes endless recursion!" );
                        result = GetSqlValue( sink, getters, ordinal, metaData, context );
                        break;
                    case SqlDbType.Xml: 
                        result = GetSqlXml_Unchecked( sink, getters, ordinal, context );
                        break;
                    case SqlDbType.Udt:
                        result = GetUdt_LengthChecked( sink, getters, ordinal, metaData );
                        break;
                }
            }

            return result;
        }
Exemplo n.º 40
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <returns>[To be supplied.]</returns>
        public bool Refresh()
        {
            this.displayName = null;

            this.col_Oit_GuidOrderIDWasUpdated = false;
            this.col_Oit_GuidOrderIDWasSet     = false;
            this.col_Oit_GuidOrderID           = System.Data.SqlTypes.SqlGuid.Null;

            this.col_Oit_GuidProductIDWasUpdated = false;
            this.col_Oit_GuidProductIDWasSet     = false;
            this.col_Oit_GuidProductID           = System.Data.SqlTypes.SqlGuid.Null;

            this.col_Oit_LngAmountWasUpdated = false;
            this.col_Oit_LngAmountWasSet     = false;
            this.col_Oit_LngAmount           = System.Data.SqlTypes.SqlInt32.Null;

            bool alreadyOpened = false;

            Params.spS_tblOrderItem Param = new Params.spS_tblOrderItem(true);
            Param.CommandTimeOut = this.selectCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            if (!this.col_Oit_GuidID.IsNull)
            {
                Param.Param_Oit_GuidID = this.col_Oit_GuidID;
            }


            System.Data.SqlClient.SqlDataReader sqlDataReader = null;
            SPs.spS_tblOrderItem Sp = new SPs.spS_tblOrderItem(false);
            if (Sp.Execute(ref Param, out sqlDataReader))
            {
                if (sqlDataReader.Read())
                {
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex))
                    {
                        this.col_Oit_GuidOrderID = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidOrderID.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex))
                    {
                        this.col_Oit_GuidProductID = sqlDataReader.GetSqlGuid(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_GuidProductID.ColumnIndex);
                    }
                    if (!sqlDataReader.IsDBNull(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex))
                    {
                        this.col_Oit_LngAmount = sqlDataReader.GetSqlInt32(SPs.spS_tblOrderItem.Resultset1.Fields.Column_Oit_LngAmount.ColumnIndex);
                    }

                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = true;

                    return(true);
                }
                else
                {
                    if (sqlDataReader != null && !sqlDataReader.IsClosed)
                    {
                        sqlDataReader.Close();
                    }

                    CloseConnection(Sp.Connection, alreadyOpened);

                    this.recordIsLoaded = false;

                    return(false);
                }
            }
            else
            {
                if (sqlDataReader != null && !sqlDataReader.IsClosed)
                {
                    sqlDataReader.Close();
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrderItem_Record", "Refresh");
            }
        }
 public static SqlBoolean op_LessThanOrEqual(SqlGuid x, SqlGuid y)
 {
     return(LessThanOrEqual(x, y));
 }
Exemplo n.º 42
0
 // Alternative method for operator >=
 public static SqlBoolean GreaterThanOrEqual(SqlGuid x, SqlGuid y)
 {
     return(x >= y);
 }
Exemplo n.º 43
0
        public static void RenewContainerLease_Embedded(
            SqlString logicalConnectionName,
            SqlString containerName,
            SqlGuid leaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            RenewContainerLease(
                config.AccountName, config.SharedKey, config.UseHTTPS,
                containerName,
                leaseId,
                timeoutSeconds, xmsclientrequestId);
        }
 public static SqlBoolean op_GreaterThanOrEqual(SqlGuid x, SqlGuid y)
 {
     return(GreaterThanOrEqual(x, y));
 }
Exemplo n.º 45
0
 // Alternative method for operator <=
 public static SqlBoolean LessThanOrEqual(SqlGuid x, SqlGuid y)
 {
     return(x <= y);
 }
Exemplo n.º 46
0
 // Alternative method for operator <
 public static SqlBoolean LessThan(SqlGuid x, SqlGuid y)
 {
     return(x < y);
 }
Exemplo n.º 47
0
 // Alternative method for operator !=
 public static SqlBoolean NotEquals(SqlGuid x, SqlGuid y)
 {
     return(x != y);
 }
Exemplo n.º 48
0
        //--------------------------------------------------
        // Alternative methods for overloaded operators
        //--------------------------------------------------

        // Alternative method for operator ==
        public static SqlBoolean Equals(SqlGuid x, SqlGuid y)
        {
            return(x == y);
        }
Exemplo n.º 49
0
        public static void BreakContainerLeaseWithGracePeriod_Embedded(
            SqlString logicalConnectionName,
            SqlString containerName,
            SqlInt32 leaseBreakPeriod,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            Configuration.EmbeddedConfiguration config = Configuration.EmbeddedConfiguration.GetConfigurationFromEmbeddedFile(logicalConnectionName.Value);

            BreakContainerLeaseWithGracePeriod(
                config.AccountName, config.SharedKey, config.UseHTTPS,
                containerName,
                leaseBreakPeriod,
                timeoutSeconds, xmsclientrequestId);
        }
 public static SqlBoolean op_Inequality(SqlGuid x, SqlGuid y)
 {
     return(NotEquals(x, y));
 }
Exemplo n.º 51
0
        public static void RenewContainerLease(
            SqlString accountName, SqlString sharedKey, SqlBoolean useHTTPS,
            SqlString containerName,
            SqlGuid leaseId,
            SqlInt32 timeoutSeconds,
            SqlGuid xmsclientrequestId)
        {
            AzureBlobService abs = new AzureBlobService(accountName.Value, sharedKey.Value, useHTTPS.Value);
            Container cont = abs.GetContainer(containerName.Value);

            Responses.LeaseBlobResponse lbr = cont.RenewLease(
                leaseId.IsNull ? Guid.Empty : leaseId.Value,
                timeoutSeconds.IsNull ? 0 : timeoutSeconds.Value,
                xmsclientrequestId.IsNull ? (Guid?)null : xmsclientrequestId.Value);

            PushLeaseBlobResponse(lbr);
        }
 public SqlGuid ToSqlGuid()
 {
     return(SqlGuid.op_Explicit(this));
 }
Exemplo n.º 53
0
 // Alternative method for operator >
 public static SqlBoolean GreaterThan(SqlGuid x, SqlGuid y)
 {
     return(x > y);
 }
 public static Guid op_Explicit(SqlGuid x)
 {
     return(x.Value);
 }
Exemplo n.º 55
0
 public SqlGuid Adjust(SqlGuid value)
 {
     if (SqlDbType.UniqueIdentifier != SqlDbType)
         ThrowInvalidType();
     return value;
 }
Exemplo n.º 56
0
 static SqlGuid()
 {
     SizeOfGuid     = 0x10;
     x_rgiGuidOrder = new int[] { 10, 11, 12, 13, 14, 15, 8, 9, 6, 7, 4, 5, 0, 1, 2, 3 };
     Null           = new SqlGuid(true);
 }