示例#1
0
        internal string rehost(string slcode, string recipient)
        {
            string     info   = null;
            HaspStatus status = Hasp.Transfer(safeNetEntity.actionRehost.Replace("{slcode}", slcode), safeNetEntity.scopeRehost.Replace("{slcode}", slcode), safeNetEntity.vendorCode, recipient, ref info);

            return(status == HaspStatus.StatusOk ? info : ((int)status + status.ToString()));
        }
示例#2
0
        public static string CancelDetachViaLicensingApi(string parentKeyId)
        {
            var myId = GetInfo(Variables.scopeForLocal, Variables.formatForGetId);

            string info = null;

            HaspStatus myCancelDetachStatus = Hasp.Transfer(Variables.actionForCancelDetach.Replace("{KEY_ID}", parentKeyId), Variables.scopeForSpecificKeyId.Replace("{KEY_ID}", parentKeyId), Variables.vendorCode[Variables.vendorCode.Keys.Where(k => k.Key == Variables.currentBatchCode).FirstOrDefault()], myId, ref info);

            return(myCancelDetachStatus.ToString());
        }
示例#3
0
        private void buttonDetach_Click(object sender, EventArgs e)
        {
            var myId = MyGlobalMethods.GetInfo(Variables.scopeForLocal, Variables.formatForGetId);

            string info          = null;
            int    detachingTime = (Convert.ToInt32(numericUpDownDaysForDetach.Value) * 24 * 60 * 60);

            HaspStatus myDetachStatus = Hasp.Transfer(Variables.actionForDetach.Replace("{PRODUCT_ID}", productId).Replace("{NUMBER_OF_SECONDS}", detachingTime.ToString()), Variables.scopeForSpecificKeyId.Replace("{KEY_ID}", parentKeyId), Variables.vendorCode[Variables.vendorCode.Keys.Where(k => k.Key == Variables.currentBatchCode).FirstOrDefault()], myId, ref info);

            if (myDetachStatus == HaspStatus.StatusOk)
            {
                // hasp_update
                string     ack            = null;
                HaspStatus myUpdateStatus = Hasp.Update(info, ref ack);

                if (myUpdateStatus == HaspStatus.StatusOk)
                {
                    //handle success
                    var tmpAvaliablesKeys = XDocument.Parse(MyGlobalMethods.GetInfo(Variables.scopeForLocal, Variables.formatForGetAvailableLicenses));
                    foreach (var el in tmpAvaliablesKeys.Root.Elements("hasp"))
                    {
                        foreach (var el2 in el.Elements("feature"))
                        {
                            if (el2.Attribute("id").Value == Variables.myFeature.FeatureId.ToString())
                            {
                                childKeyId = el.Attribute("id").Value;
                                break;
                            }
                        }

                        if (String.IsNullOrEmpty(childKeyId))
                        {
                            break;
                        }
                    }

                    MessageBox.Show(MultiLanguage.ErrorMessageReplacer(language.Key, "Current status of the opperation is: {0} \nPlease, re-login in application, for using LOCALLY license.").Replace("{0}", myUpdateStatus.ToString()), MultiLanguage.ErrorMessageReplacer(language.Key, "Successfully Detached!"));
                }
                else
                {
                    //handle error
                    MessageBox.Show(myUpdateStatus.ToString(), MultiLanguage.ErrorMessageReplacer(language.Key, "Detaching apply update error!"));
                }
            }
            else
            {
                if (myDetachStatus == HaspStatus.InvalidDuration)
                {
                    try
                    {
                        var tmpAvaliablesKeys = XDocument.Parse(MyGlobalMethods.GetInfo(Variables.scopeForLocal, Variables.formatForGetAvailableLicenses));
                        foreach (var el in tmpAvaliablesKeys.Root.Elements("hasp"))
                        {
                            foreach (var el2 in el.Elements("feature"))
                            {
                                if (el2.Attribute("id").Value == Variables.myFeature.FeatureId.ToString())
                                {
                                    childKeyId = el.Attribute("id").Value;
                                    break;
                                }
                            }

                            if (String.IsNullOrEmpty(childKeyId))
                            {
                                break;
                            }
                        }

                        string myCancelDetachStatus = Variables.useUrl ? MyGlobalMethods.CancelDetachViaUrl(productId, childKeyId) : MyGlobalMethods.CancelDetachViaLicensingApi(childKeyId);

                        if (myCancelDetachStatus == HttpStatusCode.OK.ToString() || myCancelDetachStatus == HaspStatus.StatusOk.ToString())
                        {
                            myDetachStatus = Hasp.Transfer(Variables.actionForDetach.Replace("{PRODUCT_ID}", productId).Replace("{NUMBER_OF_SECONDS}", detachingTime.ToString()), Variables.scopeForSpecificKeyId.Replace("{KEY_ID}", parentKeyId), Variables.vendorCode[Variables.vendorCode.Keys.Where(k => k.Key == Variables.currentBatchCode).FirstOrDefault()], myId, ref info);

                            if (myDetachStatus == HaspStatus.StatusOk)
                            {
                                // hasp_update
                                string     ack            = null;
                                HaspStatus myUpdateStatus = Hasp.Update(info, ref ack);

                                if (myUpdateStatus == HaspStatus.StatusOk)
                                {
                                    //handle success
                                    MessageBox.Show(MultiLanguage.ErrorMessageReplacer(language.Key, "Current status of the opperation is: {0} \nPlease, re-login in application, for using LOCALLY license.").Replace("{0}", myUpdateStatus.ToString()), MultiLanguage.ErrorMessageReplacer(language.Key, "Successfully Detached!"));
                                }
                                else
                                {
                                    //handle error
                                    MessageBox.Show(myUpdateStatus.ToString(), MultiLanguage.ErrorMessageReplacer(language.Key, "Detaching apply update error!"));
                                }
                            }
                            else
                            {
                                //handle error
                                MessageBox.Show(myDetachStatus.ToString(), MultiLanguage.ErrorMessageReplacer(language.Key, "Re-Detaching error!"));
                            }
                        }
                        else
                        {
                            //handle error
                            MessageBox.Show(MultiLanguage.ErrorMessageReplacer(language.Key, "Status request: {0} \nSomething goes wrong... Please, try again later!").Replace("{0}", myCancelDetachStatus), MultiLanguage.ErrorMessageReplacer(language.Key, "Cancel Detaching error (In Re-Detach)!"));
                        }
                    }
                    catch
                    {
                        // do nothing...
                        MessageBox.Show(myDetachStatus.ToString(), MultiLanguage.ErrorMessageReplacer(language.Key, "Detaching error!"));
                    }
                }
                else
                {
                    //handle error
                    MessageBox.Show(myDetachStatus.ToString(), MultiLanguage.ErrorMessageReplacer(language.Key, "Detaching error!"));
                }
            }
        }