Esempio n. 1
0
        public static void GetNumberOfServerRegiesterd(string licPath, out int serverCount, out int deviceCount)
        {
            Stream          stream1     = File.Open(licPath, FileMode.Open, FileAccess.ReadWrite);
            BinaryFormatter bformatter1 = new BinaryFormatter();
            RegistrationInf wqe         = (RegistrationInf)bformatter1.Deserialize(stream1);
            DataTable       dt          = wqe.LicenceDataTable;
            int             count       = dt.Rows.Count;

            stream1.Close();
            stream1.Dispose();
            int rows = dt.Rows.Count;

            //get count of server and device regiesterd.
            serverCount = 0;
            deviceCount = 0;
            string value = string.Empty;

            for (int i = 0; i < rows; i++)
            {
                value = RegistrationInf.DecodeString(dt.Rows[i]["CLIENT_CODE"].ToString());
                if (!string.IsNullOrEmpty(value))
                {
                    if (value.StartsWith("S"))
                    {
                        serverCount = serverCount + 1;
                    }
                    if (value.StartsWith("C"))
                    {
                        deviceCount = deviceCount + 1;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Determines whether [is activation exist] [the specified lic path2].
        /// </summary>
        /// <param name="licPath2">The lic path2.</param>
        /// <param name="activativationCodeExist">The activativation code exist.</param>
        /// <returns>
        ///   <c>true</c> if [is activation exist] [the specified lic path2]; otherwise, <c>false</c>.
        /// </returns>
        public static bool isActivationExist(string licPath2, string activativationCodeExist)
        {
            bool activationCode = false;

            Stream          stream1     = File.Open(licPath2, FileMode.Open);
            BinaryFormatter bformatter1 = new BinaryFormatter();
            RegistrationInf wqe         = (RegistrationInf)bformatter1.Deserialize(stream1);
            DataTable       dt          = wqe.LicenceDataTable;

            stream1.Close();
            stream1.Dispose();
            int rows = dt.Rows.Count;

            ArrayList arrayList = new ArrayList();

            for (int rowIndex = 0; rowIndex < rows; rowIndex++)
            {
                arrayList.Add(RegistrationInf.DecodeString(dt.Rows[rowIndex]["ACTIVATION_CODE"].ToString())); // Where ACTIVATION_CODE is the name of fields from  PR.dat
            }

            if (arrayList.Contains(activativationCodeExist))
            {
                activationCode = true;
            }

            return(activationCode);
        }
Esempio n. 3
0
        /// <summary>
        /// Determines whether [is client code exist] [the specified lic path2].
        /// </summary>
        /// <param name="licPath2">The lic path2.</param>
        /// <param name="deviceIp">The device ip.</param>
        /// <returns>
        ///   <c>true</c> if [is client code exist] [the specified lic path2]; otherwise, <c>false</c>.
        /// </returns>
        public static bool isClientCodeExist(string licPath2, string deviceIp)
        {
            bool clientCode = false;
            // deviceIp = "172.29.241.40";
            Stream          stream1     = File.Open(licPath2, FileMode.Open);
            BinaryFormatter bformatter1 = new BinaryFormatter();
            RegistrationInf wqe         = (RegistrationInf)bformatter1.Deserialize(stream1);
            DataTable       dt          = wqe.LicenceDataTable;
            int             count       = dt.Rows.Count;

            stream1.Close();
            stream1.Dispose();
            int          rows          = dt.Rows.Count;
            DbDataReader deviceDetails = DataManager.Provider.Device.ProvideDeviceDetails(deviceIp);

            string deviceClientCode = string.Empty;
            string deviceSerial     = string.Empty;
            string deviceModel      = string.Empty;
            string clientCodeOld    = string.Empty;
            string serialold        = string.Empty;
            string modelold         = string.Empty;

            try
            {
                if (deviceDetails.HasRows)
                {
                    deviceDetails.Read();
                    clientCodeOld = deviceClientCode = Convert.ToString(deviceDetails["MFP_SERIALNUMBER"], CultureInfo.CurrentCulture) + Convert.ToString(deviceDetails["MFP_MODEL"], CultureInfo.CurrentCulture);
                    serialold     = deviceSerial = Convert.ToString(deviceDetails["MFP_SERIALNUMBER"], CultureInfo.CurrentCulture);
                    modelold      = deviceModel = Convert.ToString(deviceDetails["MFP_MODEL"], CultureInfo.CurrentCulture);

                    if (!string.IsNullOrEmpty(deviceClientCode))
                    {
                        deviceClientCode = SerialIdentity(deviceClientCode);
                    }

                    if (!string.IsNullOrEmpty(deviceSerial))
                    {
                        deviceSerial = SerialIdentity(deviceSerial);
                    }

                    if (!string.IsNullOrEmpty(deviceModel))
                    {
                        deviceModel = SerialIdentity(deviceModel);
                    }
                    if (!string.IsNullOrEmpty(clientCodeOld))
                    {
                        clientCodeOld = SerialIdentityOld(clientCodeOld);
                    }

                    if (!string.IsNullOrEmpty(serialold))
                    {
                        serialold = SerialIdentityOld(serialold);
                    }

                    if (!string.IsNullOrEmpty(modelold))
                    {
                        modelold = SerialIdentityOld(modelold);
                    }
                }
                deviceDetails.Close();
                ArrayList arrayList = new ArrayList();
                for (int rowIndex = 0; rowIndex < rows; rowIndex++)
                {
                    arrayList.Add(RegistrationInf.DecodeString(dt.Rows[rowIndex]["CLIENT_CODE"].ToString())); // Where CLIENT_CODE is the name of fields from  PR.dat
                }

                if (arrayList.Contains(deviceClientCode) || arrayList.Contains(deviceSerial) || arrayList.Contains(deviceModel) || arrayList.Contains(clientCodeOld) || arrayList.Contains(serialold) || arrayList.Contains(modelold))
                {
                    clientCode = true;
                }

                if (arrayList.Contains(clientCodeOld) || arrayList.Contains(serialold) || arrayList.Contains(modelold))
                {
                    clientCode = true;
                }
            }
            catch (Exception ex)
            {
                LogManager.RecordMessage("isClientCodeExist", "isClientCodeExist", LogManager.MessageType.Success, ex.Message, "", "", "");
            }

            return(clientCode);
        }