Esempio n. 1
0
        /// <summary>
        /// The convert DTO.
        /// </summary>
        /// <param name="licenseDto">
        /// The license DTO.
        /// </param>
        /// <param name="instance">
        /// The instance.
        /// </param>
        /// <returns>
        /// The <see cref="CompanyLicense"/>.
        /// </returns>
        private CompanyLicense ConvertDto(CompanyLicenseDTO licenseDto, CompanyLicense instance)
        {
            instance = instance ?? new CompanyLicense();
            var licenseIsTransient = instance.IsTransient();

            if (licenseIsTransient)
            {
                instance.CreatedBy     = this.UserModel.GetOneById(licenseDto.createdBy).Value;
                instance.DateCreated   = DateTime.Now;
                instance.Company       = this.CompanyModel.GetOneById(licenseDto.companyId).Value;
                instance.LicenseNumber = Guid.NewGuid().ToString();
            }

            instance.Domain = licenseDto.domain;
            var expiryDate = licenseDto.expiryDate.ConvertFromUnixTimeStamp();

            instance.ExpiryDate             = expiryDate <= SqlDateTime.MinValue.Value ? licenseDto.isTrial ? DateTime.Now.AddDays(30) : DateTime.Now.AddYears(1) : expiryDate;
            instance.DateStart              = licenseDto.startDate.ConvertFromUnixTimeStamp();
            instance.TotalLicensesCount     = licenseDto.totalLicensesCount;
            instance.TotalParticipantsCount = licenseDto.totalParticipantsCount == 0 ? 100 : licenseDto.totalParticipantsCount;
            instance.DateModified           = DateTime.Now;
            instance.ModifiedBy             = this.UserModel.GetOneById(licenseDto.modifiedBy).Value;
            instance.LicenseStatus          = GetLicenseStatus(licenseDto);
            instance.HasApi = licenseDto.hasApi;

            return(instance);
        }
 private void RefreshForm()
 {
     _objRequestLicenseKey = new RequestLicenseKey();
     _objCompanyLicense    = new CompanyLicense();
     FillData();
     groupBuildLicense.Enabled = false;
 }
        private void gridView_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (e.RowHandle >= 0)
            {
                RefreshForm();
                bool valid = false;
                lblMsg.Text        = "";
                CompanyLicenseItem = (CompanyLicense)gridView.GetRow(e.RowHandle);
                if (CompanyLicenseItem != null)
                {
                    txtLicenseCode.Text           = CompanyLicenseItem.LicenseCode;
                    txtLicenseKey.Text            = CompanyLicenseItem.LicenseKey;
                    txtAPIKey.Text                = CompanyLicenseItem.LicenseTaxiAPI;
                    txtAPICode.Text               = CompanyLicenseItem.LicenseTaxiAPI_Code;
                    txtNote.Text                  = CompanyLicenseItem.Notes;
                    date_ExpDate.DateTime         = CompanyLicenseItem.ExpDate;
                    inputLookUp_Company.EditValue = CompanyLicenseItem.FK_CompanyID;
                    int requestID = CompanyLicense.Inst.GetRequestIDByCompanyLicenseId(CompanyLicenseItem.Id);
                    if (requestID > 0)
                    {
                        ResponsedItem = RequestLicenseResponsed.Inst.GetResponsedByID(requestID);
                        if (ResponsedItem != null)
                        {
                            lblCompanyName.Text = ResponsedItem.CompName;
                            lblCpuId.Text       = ResponsedItem.CPUID;
                            lblMacAddress.Text  = ResponsedItem.MacAddress;
                            lblPhone.Text       = ResponsedItem.PhoneNumber;

                            valid = true;
                        }
                    }

                    if (CompanyLicenseItem.IsActive)
                    {
                        btnActive.Text = "Deactive";
                    }
                    else
                    {
                        btnActive.Text = "Active";
                    }
                    btnActive.Enabled       = valid;
                    btnBuildLicense.Enabled = valid;
                    btnCopy.Enabled         = valid;
                    btnSave.Enabled         = valid;
                    if (!valid)
                    {
                        lblMsg.Text = "Request license not found";
                    }
                }
            }
        }
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            Company company = new Company();

            company.Id             = Convert.ToInt32(txt_CompId.Text);
            company.CompanyName    = Request.Form[txt_CompName.UniqueID];
            company.CompanyAddress = Request.Form[txt_Address.UniqueID];
            company.CompanyCountry = Request.Form[txt_Country.UniqueID];
            company.CompanyCity    = Request.Form[txt_City.UniqueID];
            company.CompanyZip     = Request.Form[txt_Zip.UniqueID];

            company.CompanyEmail     = Request.Form[txt_Email.UniqueID];
            company.CompanyTelephone = Request.Form[txt_Telephone.UniqueID];

            company.CompanyUserid   = Request.Form[txt_userid.UniqueID];
            company.CompanyPassword = Request.Form[txt_password.UniqueID];

            List <CompanyLicense> licenseList = new List <CompanyLicense>();

            if (txt_InventoryKey.Text != "")
            {
                CompanyLicense companyLicense = new CompanyLicense();
                companyLicense.LicenseKey = Request.Form[txt_InventoryKey.UniqueID];
                licenseList.Add(companyLicense);
            }
            if (txt_PurchaseKey.Text != "")
            {
                CompanyLicense companyLicense = new CompanyLicense();
                companyLicense.LicenseKey = Request.Form[txt_PurchaseKey.UniqueID];
                licenseList.Add(companyLicense);
            }
            if (txt_SaleKey.Text != "")
            {
                CompanyLicense companyLicense = new CompanyLicense();
                companyLicense.LicenseKey = Request.Form[txt_SaleKey.UniqueID];
                licenseList.Add(companyLicense);
            }
            company.CompanyLicense = licenseList;
            string result = companyService.UpdateCompany(company);

            MessageBox.Show(result);
            MessageBox.Show("You need to login again to apply changes");
            Response.Redirect("~/LoginRegistrationForm.aspx");
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompanyLicenseDTO"/> class.
 /// </summary>
 /// <param name="l">
 /// The l.
 /// </param>
 public CompanyLicenseDTO(CompanyLicense l)
 {
     this.companyLicenseId       = l.Id;
     this.companyId              = l.Company.Id;
     this.domain                 = l.Domain;
     this.licenseNumber          = l.LicenseNumber;
     this.createdBy              = l.CreatedBy.Id;
     this.modifiedBy             = l.ModifiedBy.Id;
     this.dateCreated            = l.DateCreated.With(x => x.ConvertToUnixTimestamp());
     this.dateModified           = l.DateModified.With(x => x.ConvertToUnixTimestamp());
     this.startDate              = l.DateStart.With(x => x.ConvertToUnixTimestamp());
     this.expiryDate             = l.ExpiryDate.With(x => x.ConvertToUnixTimestamp());
     this.totalLicensesCount     = l.TotalLicensesCount;
     this.totalParticipantsCount = l.TotalParticipantsCount;
     this.isTrial                = l.LicenseStatus == CompanyLicenseStatus.Trial;
     this.isPro        = l.LicenseStatus == CompanyLicenseStatus.Pro;
     this.isEnterprise = l.LicenseStatus == CompanyLicenseStatus.Enterprise;
     this.hasApi       = l.HasApi;
 }
 private void LoadCurrentLicense()
 {
     try
     {
         if (inputLookUp_Company.EditValue != null)
         {
             int companyID = 0;
             int.TryParse(inputLookUp_Company.EditValue.ToString(), out companyID);
             CompanyLicense objCompanyLicense = CompanyLicense.Inst.GetDataById(companyID);
             if (objCompanyLicense != null)
             {
                 txtCurrentLicense.Text = string.Format("License Code : {0}\r\nLicense Key : {1}\r\nAPI Key : {2}\r\nExp.Date : {3:dd/MM/yyyy}", objCompanyLicense.LicenseCode, objCompanyLicense.LicenseKey, objCompanyLicense.LicenseTaxiAPI_Code, objCompanyLicense.ExpDate);
             }
             else
             {
                 txtCurrentLicense.Text = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("BuildLicense_Form.LoadCurrentLicense", ex);
     }
 }
Esempio n. 7
0
        public Company GetCompany(int ComanyId)
        {
            using (SqlConnection connGetDistrict = ConnectionProvider.GetServerConnection())
            {
                try
                {
                    SqlCommand cmdDistrict = new SqlCommand("SP_License", connGetDistrict);
                    cmdDistrict.CommandType    = CommandType.StoredProcedure;
                    cmdDistrict.CommandTimeout = 250;
                    cmdDistrict.Parameters.Add("@flag", SqlDbType.NVarChar).Value   = "GetCompanyById";
                    cmdDistrict.Parameters.Add("@COMPANY_ID", SqlDbType.Char).Value = ComanyId;

                    SqlDataAdapter da = new SqlDataAdapter(cmdDistrict);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    Company company = new Company();
                    foreach (DataRow row in dt.Rows)
                    {
                        company.Id               = Convert.ToInt32(row["COMPANY_ID"]);
                        company.CompanyName      = row["COMPANY_NAME"].ToString();
                        company.CompanyAddress   = row["COMPANY_ADDRESS"].ToString();
                        company.CompanyCountry   = row["COMPANY_COUNTRY"].ToString();
                        company.CompanyCity      = row["COMPANY_CITY"].ToString();
                        company.CompanyZip       = row["COMPANY_ZIP"].ToString();
                        company.CompanyEmail     = row["COMPANY_EMAIL"].ToString();
                        company.CompanyUserid    = row["COMPANY_USER_ID"].ToString();
                        company.CompanyPassword  = row["COMPANY_PASSWORD"].ToString();
                        company.CompanyTelephone = row["COMPANY_TELEPHONE"].ToString();
                        company.UserCount        = row["COMPANY_TELEPHONE"].ToString();
                    }
                    cmdDistrict.Dispose();
                    cmdDistrict.Parameters.Clear();
                    cmdDistrict.CommandType    = CommandType.StoredProcedure;
                    cmdDistrict.CommandTimeout = 250;
                    cmdDistrict.Parameters.Add("@flag", SqlDbType.NVarChar).Value   = "GetLicensesById";
                    cmdDistrict.Parameters.Add("@COMPANY_ID", SqlDbType.Char).Value = ComanyId;
                    SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmdDistrict);
                    DataTable      dataTable      = new DataTable();
                    sqlDataAdapter.Fill(dataTable);
                    List <CompanyLicense> companyLicenses = new List <CompanyLicense>();
                    foreach (DataRow row in dataTable.Rows)
                    {
                        CompanyLicense companyLicense = new CompanyLicense();
                        companyLicense.LicenseId        = Convert.ToInt32(row["LICENSE_ID"]);
                        companyLicense.CompanyId        = Convert.ToInt32(row["COMPANY_ID"]);
                        companyLicense.LicenseKey       = row["LICENSE_KEY"].ToString();
                        companyLicense.Product          = row["PRODUCT"].ToString();
                        companyLicense.Status           = row["STATUS"].ToString();
                        companyLicense.RegistrationDate = Convert.ToDateTime(row["REGISTRATION_DATE"]);
                        companyLicense.ExpiryDate       = Convert.ToDateTime(row["EXPIRY_DATE"]);
                        companyLicense.NotificationDays = Convert.ToInt32(row["NOTIFICATION_DAY"]);
                        companyLicenses.Add(companyLicense);
                    }
                    company.CompanyLicense = companyLicenses;

                    return(company);
                }
                catch (Exception ex)
                {
                    return(null);
                }
                finally
                {
                    if (connGetDistrict.State == ConnectionState.Open)
                    {
                        connGetDistrict.Close();
                    }
                }
            }
        }