Exemple #1
0
        static private bool Init(string db, string user)
        {
            if (Context == null)
            {
                IModelsRepository modelsRepository = new ModelsRepository();
                Context = modelsRepository.GetModelContext(db);
                if (Context != null)
                {
                    Licence.InitLicence(Context.Kernel, null);
                    SetUser(Context, user);
                }
                else
                {
                    return(false);
                }
            }


            /*
             *
             * if (CreateTransFile == null)
             * {
             *  CreateTransFile = new CreateTransFile();
             *  CreateTransFile.Init(Context);
             * }
             */
            return(true);
        }
Exemple #2
0
        public async Task <Licence> UpdateAsync(Licence objet)
        {
            _context.Entry(await _context.Licence.FirstOrDefaultAsync(x => x.Id == objet.Id)).CurrentValues.SetValues(objet);
            await _context.SaveChangesAsync();

            return(objet);
        }
Exemple #3
0
        public async Task <Licence> CreateAsync(Licence objet)
        {
            using (var db = _context)
            {
                var strategy = db.Database.CreateExecutionStrategy();
                strategy.Execute(() =>
                {
                    using (var context = _context)
                    {
                        //BeginTransaction
                        using (var transaction = context.Database.BeginTransaction())
                        {
                            try
                            {
                                //Insert Amende
                                context.Licence.Add(objet);
                                context.SaveChanges();

                                //End Transaction
                                transaction.Commit();
                            }
                            catch (Exception ex)
                            {
                                _logger.WriteError(new LogItem()
                                {
                                    Exception = ex, Message = ex.Message, Layer = "Repository"
                                });
                                transaction.Rollback();
                            }
                        }
                    }
                });
            }
            return(objet);
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ApplicationId,OrganisationName")] Licence licence)
        {
            if (id != licence.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(licence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LicenceExists(licence.Id))
                    {
                        return(NotFound());
                    }
                    throw;
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(licence));
        }
Exemple #5
0
        public static LicenceVM GetLicenceInfo(Licence licence)
        {
            validate.secretPhase = CommonConstants.SECRET_PHASE;
            validate.Key         = licence.key;

            LicenceVM LicenceInfo = new LicenceVM();

            LicenceInfo.Id          = licence.Id;
            LicenceInfo.enable      = licence.enable;
            LicenceInfo.machineCode = machineCode;
            LicenceInfo.key         = licence.key;
            LicenceInfo.isValid     = validate.IsValid;
            if (LicenceInfo.isValid)
            {
                LicenceInfo.CreationDate = validate.CreationDate;
                LicenceInfo.ExpireDate   = validate.ExpireDate;
                if (LicenceInfo.ExpireDate < DateTime.Now)
                {
                    LicenceInfo.isExpired = true;
                }
                else
                {
                    LicenceInfo.isExpired = false;
                }
                LicenceInfo.TimeSet  = validate.SetTime;
                LicenceInfo.DaysLeft = validate.DaysLeft;
            }
            return(LicenceInfo);
        }
        /// <summary>
        /// Save or update Licencess
        /// </summary>
        /// <param name="sender">click</param>
        /// <param name="e">event</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            int iteration = 0;

            foreach (DataGridViewRow gr in dgvLicence.Rows)
            {
                Licence tblLicence = new Licence();
                if (!string.IsNullOrEmpty(gr.Cells["ExePath"].Value.ToString()))
                {
                    tblLicence.ExePath = gr.Cells["ExePath"].Value.ToString();
                }
                else
                {
                    SingletonLogger.Instance.Warning("Please Fill exe name in Row number:" + iteration + 1 + " or delete row number:" + iteration + 1 + "");
                    return;
                }
                tblLicence.OldExePath         = iteration >= _ActiveLicences.Count?gr.Cells["ExePath"].Value.ToString(): _ActiveLicences[iteration].OldExePath;
                tblLicence.Type               = (LicenceType)Enum.Parse(typeof(LicenceType), gr.Cells["Type"].Value.ToString());
                tblLicence.MaxTime            = Convert.ToInt32(gr.Cells["MaxTime"].Value);
                tblLicence.Enabled            = Convert.ToBoolean(gr.Cells["Enabled"].Value);
                tblLicence.TimeInterval       = Convert.ToInt32(gr.Cells["TimeInterval"].Value);
                tblLicence.ConcurrentLicences = Convert.ToInt32(gr.Cells["ConcurrentLicences"].Value);
                tblLicence.InsertAndUpdate();
                iteration = iteration + 1;
            }
            BindLicences();
            SingletonLogger.Instance.Info("All Licencess has updated or saved");
        }
Exemple #7
0
        internal static LicenceDTO MapDataToDTO(Licence objet)
        {
            LicenceDTO rtn = new LicenceDTO();

            if (null != objet)
            {
                rtn.Id               = objet.Id;
                rtn.Adresse1         = objet.Adresse1;
                rtn.Adresse2         = objet.Adresse2;
                rtn.AnneeLicence     = objet.AnneeLicence;
                rtn.CodePostal       = objet.CodePostal;
                rtn.DateCreation     = objet.DateCreation;
                rtn.DateModification = objet.DateModification;
                rtn.Email            = objet.Email;
                rtn.Indicatif        = objet.Indicatif;
                rtn.IsDeleted        = objet.IsDeleted;
                rtn.Nom              = objet.Nom;
                rtn.Prenom           = objet.Prenom;
                rtn.QraLocator       = objet.QraLocator;
                rtn.SuppressorId     = objet.SuppressorId;
                rtn.UserId           = objet.UserId;
                rtn.Ville            = objet.Ville;
                rtn.Website          = objet.Website;
            }
            return(rtn);
        }
Exemple #8
0
        private void authorizeButton_Click(object sender, EventArgs e)
        {
            Licence.Update(licenceTextBox.Text);

            if (Licence.Valid && Licence.Expiration > DateTime.Now)
            {
                if (Searcher.SetCredentials(consumerKeyTextBox.Text, consumerSecretTextBox.Text, accessTokenTextBox.Text, accessSecretTextBox.Text))
                {
                    consumerKeyTextBox.Enabled    = false;
                    consumerSecretTextBox.Enabled = false;
                    accessTokenTextBox.Enabled    = false;
                    accessSecretTextBox.Enabled   = false;
                    licenceTextBox.Enabled        = false;

                    mainTabPage_1.Enabled = true;
                    mainTabPage_2.Enabled = true;

                    authorizeButton.Enabled        = false;
                    resetCredentialsButton.Enabled = true;
                    searchExplorerButton.Enabled   = true;

                    MetroMessageBox.Show(this, "\nSe autorizó correctamente la aplicación.", "Conexión aceptada", MessageBoxButtons.OK, MessageBoxIcon.Information, 125);
                }
                else
                {
                    MetroMessageBox.Show(this, "\nNo se pudo establecer conexión con Twitter.\nVerifique las credenciales y la conexión a Internet.", "Conexión rechazada", MessageBoxButtons.OK, MessageBoxIcon.Error, 150);
                }
            }
            else
            {
                MetroMessageBox.Show(this, "\nSe rechazó la licencia actual.\nPara saber mas acerca del por qué fue rechazada, haga clic en el botón \"Información sobre licencia\".", "Licencia rechazada", MessageBoxButtons.OK, MessageBoxIcon.Error, 175);
            }
        }
Exemple #9
0
        /// <summary>
        /// Invoke executable file, insert GUID and EXE information into Transaction table.
        /// </summary>
        /// <param name="exePath">Executable file path</param>
        /// <param name="systemGuid">System GUIID</param>
        /// <param name="triggerFilePath">Trigger file path</param>
        public void InvokeExeAndDatabaseInsertion(string exePath, string systemGuid)
        {
            try
            {
                #region Make an entry in table that EXE is running now
                Transaction newTransaction = new Transaction(systemGuid);
                newTransaction.ExeName     = Path.GetFileName(exePath);
                newTransaction.Application = "NA";
                newTransaction.StartedAt   = DateTime.Now;
                newTransaction.Enabled     = true;
                var IsNewCreated = newTransaction.Save(true);
                #endregion

                #region Call EXE using trigger file
                SingletonLogger.Instance.Debug("Service start executing the " + exePath);
                TimeIntervalBasedInvoke    timeIntervalInvoker = new TimeIntervalBasedInvoke(exePath, systemGuid);
                System.Diagnostics.Process proc = timeIntervalInvoker.Invoke();
                SingletonLogger.Instance.Debug("Service successfully executed the " + exePath);
                if (IsNewCreated)
                {
                    newTransaction.ProcessId = proc.Id;
                    newTransaction.Save();
                    Licence.UpdateLastRunStartTime(exePath, proc.StartTime);
                    SingletonLogger.Instance.Debug("Service successfully inserted information in Transaction table.");
                }


                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception("Error while invoking " + exePath, ex);
            }
        }
Exemple #10
0
        public void AddCurrent(OperatorModel operatorModel)
        {
            operatorModel.LoginFlag = System.DateTime.Now.ToString("yyyyMMddHHmmss");
            string mid = operatorModel.UserCode;

            if (!string.IsNullOrEmpty(operatorModel.AssistantID))
            {
                mid = operatorModel.AssistantID;
            }
            if (UserList.ContainsKey(mid))
            {
                UserList[mid] = operatorModel.LoginFlag;
            }
            else
            {
                UserList.Add(mid, operatorModel.LoginFlag);
            }


            if (LoginProvider == "Cookie")
            {
                //WebHelper.WriteCookie(LoginUserKey, DESEncrypt.Encrypt(operatorModel.ToJson()), 2);
                WebHelper.WriteCookie("token", operatorModel.LoginToken, 30);
                WebHelper.WriteCookie("LoginFlag", operatorModel.LoginFlag, 30);
            }
            else
            {
                WebHelper.WriteSession(LoginUserKey, DESEncrypt.Encrypt(operatorModel.ToJson()));
            }
            WebHelper.WriteCookie("nfine_mac", Md5.md5(Net.Net.GetMacByNetworkInterface().ToJson(), 32));
            WebHelper.WriteCookie("nfine_licence", Licence.GetLicence());
        }
Exemple #11
0
        static private bool Init(string db, string user)
        {
            if (Context == null)
            {
                IModelsRepository modelsRepository = new ModelsRepository();
                Context = modelsRepository.GetModelContext(db);
                if (Context != null)
                {
                    Licence.InitLicence(Context.Kernel, null);
                    SetUser(Context, user);
                }
                else
                {
                    return(false);
                }
            }

            if (ClipperApi == null)
            {
                ClipperApi = new ClipperApi();
                ClipperApi.InitAlmaCam(Context);
            }

            return(true);
        }
 private SourcingWorkersViewModel SourcingWorkersResolver(Licence licence)
 {
     return(new SourcingWorkersViewModel
     {
         WorkerSource = licence.WorkerSource
     });
 }
Exemple #13
0
        /// <summary>
        /// Invoke executable file, insert GUID and EXE information into Transaction table.
        /// </summary>
        /// <param name="exePath">Executable file path</param>
        /// <param name="systemGuid">System GUIID</param>
        /// <param name="triggerFilePath">Trigger file path</param>
        public void InvokeExeAndDatabaseInsertion(string exePath, string systemGuid, string triggerFilePath)
        {
            TriggerFileReader objTriggerFileReader = new TriggerFileReader();

            objTriggerFileReader.TriggerFileLocaton = triggerFilePath;
            var triggerFileDetail = objTriggerFileReader.GetTriggerFileDetail();

            #region Make an entry in table that EXE is running now
            Transaction newTransaction = new Transaction(systemGuid);
            newTransaction.ExeName     = Path.GetFileName(exePath);
            newTransaction.Application = triggerFileDetail.ApplicationName != null ? triggerFileDetail.ApplicationName : "NA";
            newTransaction.StartedAt   = DateTime.Now;
            newTransaction.Enabled     = true;
            var IsNewCreated = newTransaction.Save(true);
            #endregion

            #region Call EXE using trigger file
            SingletonLogger.Instance.Debug("Service start executing the " + exePath);
            TriggerBasedInvoke         triggerInvoker = new TriggerBasedInvoke(exePath, triggerFilePath, systemGuid);
            System.Diagnostics.Process proc           = triggerInvoker.Invoke();
            SingletonLogger.Instance.Debug("Service successfully executed the " + exePath);
            if (IsNewCreated)
            {
                newTransaction.ProcessId = proc.Id;
                newTransaction.Save();
                Licence.UpdateLastRunStartTime(exePath, proc.StartTime);
                SingletonLogger.Instance.Debug("Service successfully inserted information in Transaction table.");
            }
            #endregion
        }
        public void it_should_map_the_licence_entity_to_the_organisation_view_model()
        {
            var input = new Licence
            {
                SuppliesWorkersOutsideLicensableAreas = true,
                OtherSector = "other",
                HasWrittenAgreementsInPlace = true,
                IsPSCControlled             = true,
                PSCDetails        = "psc deets",
                HasMultiples      = true,
                OtherMultiple     = "other multiple",
                NumberOfMultiples = 10,
                IsShellfish       = true
            };

            var result = this.mapper.Map <OrganisationViewModel>(input);

            Assert.AreEqual(input.SuppliesWorkersOutsideLicensableAreas, result.OutsideSectorsViewModel.SuppliesWorkersOutsideLicensableAreas);
            Assert.AreEqual(input.OtherSector, result.OutsideSectorsViewModel.OtherSector);
            Assert.AreEqual(input.HasWrittenAgreementsInPlace, result.WrittenAgreementViewModel.HasWrittenAgreementsInPlace);
            Assert.AreEqual(input.IsPSCControlled, result.PscControlledViewModel.IsPSCControlled);
            Assert.AreEqual(input.PSCDetails, result.PscControlledViewModel.PSCDetails);
            Assert.AreEqual(input.HasMultiples, result.MultipleBranchViewModel.HasMultiples);
            Assert.AreEqual(input.OtherMultiple, result.MultipleBranchViewModel.OtherMultiple);
            Assert.AreEqual(input.NumberOfMultiples, result.MultipleBranchViewModel.NumberOfMultiples);
        }
Exemple #15
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Validite,Tarif,Niveau,Categorie,UserId")] Licence licence)
        {
            if (id != licence.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(licence);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LicenceExists(licence.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(licence));
        }
Exemple #16
0
        public async Task <IActionResult> New(LicenceViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(model);

                Licence licence = new Licence
                {
                    EmployeeNumber = model.EmployeeNumber,
                    Email          = model.Email,
                    EmployeeName   = model.EmployeeName,
                    LicenceNumber  = model.LicenceNumber,
                    IssuedDate     = model.IssuedDate,
                    ExpiredDate    = model.ExpiredDate,
                    RenewedDate    = model.RenewedDate,
                    Department     = model.Department,
                    ProfilePicture = uniqueFileName,
                };
                _context.Add(licence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemple #17
0
        public async Task <LicenceDTO> UpdateAsync(LicenceDTO objet)
        {
            Licence entite = MapLicence.ToEntity(objet, false);
            var     lRet   = await _repo.UpdateAsync(entite);

            return(MapLicenceDTO.MapDataToDTO(lRet));
        }
Exemple #18
0
 static void start()
 {
     Licence.createLicence();
     if (Licence.verifyLicence())
     {
         if (!Utils.verifyParametre())
         {
             if (!ServeurBLL.CreateServeur(Serveur.getServeurDefault()))
             {
                 return;
             }
         }
         if (Connexion.isConnection())
         {
             new Acces();
             new Form_Parent().Show();
             //new Form_Login().Show();
             Application.Run();
         }
         else
         {
             if (Database.createDb())
             {
                 new Acces();
                 new Form_Parent().Show();
                 //new Form_Login().Show();
                 Application.Run();
             }
         }
     }
     else
     {
         Messages.ShowErreur("Vous devez activer votre compte");
     }
 }
Exemple #19
0
        public void AddReferee()
        {
            Referee referee = new Referee();

            referee.FirstName   = _addReferee.FirstNameTextBox.Text;
            referee.LastName    = _addReferee.LastNameTextBox.Text;
            referee.Address     = _addReferee.AddressTextBox.Text;
            referee.Description = _addReferee.DescriptionTextBox.Text;
            referee.Contact     = _addReferee.ContactTextBox.Text;

            ComboBoxItem selectedCity = (ComboBoxItem)_addReferee.CityComboBox.SelectedItem;
            City         city         = _cityRepository.GetCityById((long)selectedCity.Tag);

            referee.City = city;

            ComboBoxItem selectedLicence = (ComboBoxItem)_addReferee.LicenceComboBox.SelectedItem;
            Licence      licence         = _licenceRepository.GetLicenceById((long)selectedLicence.Tag);

            referee.Licence = licence;

            _refereeRepository.AddReferee(referee);

            _addReferee.Close();
            ReloadListOfReferees();
        }
Exemple #20
0
 /// <summary>
 /// 数据类型
 /// </summary>
 /// <param name="connType">连接类型</param>
 /// <param name="cmdType">执行</param>
 /// <param name="paramType">参数</param>
 protected DataBase(Type connType, Type cmdType, Type paramType)
 {
     Licence.Checking();
     this.connType  = connType;
     this.cmdType   = cmdType;
     this.paramType = paramType;
 }
 private WorkerSupplyMethodViewModel SupplyWorkersResolver(Licence licence)
 {
     return(new WorkerSupplyMethodViewModel
     {
         WorkerSupplyMethod = licence.WorkerSupplyMethod,
         WorkerSupplyOther = licence.WorkerSupplyOther,
         AvailableSources = new List <SelectListItem>
         {
             new SelectListItem
             {
                 Text = "Employee",
                 Value = "1"
             },
             new SelectListItem
             {
                 Text = "Self Employed",
                 Value = "2"
             },
             new SelectListItem
             {
                 Text = "Other",
                 Value = "3"
             }
         }
     });
 }
        public void it_should_create_a_new_address_entity_if_one_is_not_present_and_update_the_address_from_the_address_view_model()
        {
            const int    expectedId       = 1;
            const string expectedLine1    = "Line 1";
            const int    expectedCounty   = 1;
            const int    expectedCountry  = 1;
            const string expectedPostcode = "BA2 3DQ";
            var          licence          = new Licence {
                Id = expectedId, Address = null
            };
            var model = new AddressViewModel
            {
                AddressLine1 = expectedLine1,
                CountyId     = expectedCounty,
                CountryId    = expectedCountry,
                Postcode     = expectedPostcode
            };

            licenceRepository.GetById(expectedId).Returns(licence);
            repository.Create <Address>().Returns(new Address());

            var pdh = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider);

            pdh.UpdateAddress(expectedId, l => l, model);

            repository.Received(1).Create <Address>();
            repository.Received(1).Upsert(Arg.Is <Licence>(l =>
                                                           l.Address.AddressLine1.Equals(expectedLine1) && l.Address.CountyId == expectedCounty &&
                                                           l.Address.CountryId == expectedCountry && l.Address.Postcode.Equals(expectedPostcode)));
        }
        public void it_should_create_and_update_a_new_entity_with_an_address_if_one_does_not_exist_with_the_specified_id_and_it_is_addressable()
        {
            const int    expectedId   = 1;
            const string expectedName = "Name";
            var          licence      = new Licence
            {
                Id = expectedId,
                DirectorOrPartners = new List <DirectorOrPartner>()
            };
            var model = new FullNameViewModel
            {
                FullName = expectedName
            };

            licenceRepository.GetById(expectedId).Returns(licence);
            repository.Create <DirectorOrPartner>().Returns(new DirectorOrPartner {
                Id = expectedId
            });
            repository.Create <Address>().Returns(new Address {
                Id = expectedId
            });
            repository.Upsert(Arg.Any <DirectorOrPartner>()).Returns(expectedId);

            var pdh    = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider);
            var result = pdh.Update(expectedId, l => l.DirectorOrPartners, model, expectedId);

            Assert.AreEqual(expectedId, result);
            repository.Received(1).Create <Address>();
            repository.Received(1).Upsert(Arg.Is <DirectorOrPartner>(a => a.Id == expectedId && a.FullName.Equals(expectedName) && a.Address.Id == expectedId));
        }
 private WorkerContractViewModel WorkerContractResolver(Licence licence)
 {
     return(new WorkerContractViewModel
     {
         SelectedContract = licence.WorkerContract,
         AvailableContracts = new List <AvailableContract>
         {
             new AvailableContract
             {
                 Id = 1,
                 Name = "Contract of employment",
                 Checked = false,
                 EnumMappedTo = WorkerContract.ContractOfEmployment
             },
             new AvailableContract
             {
                 Id = 2,
                 Name = "Contract for Services",
                 Checked = false,
                 EnumMappedTo = WorkerContract.ContractForServices
             },
             new AvailableContract
             {
                 Id = 3,
                 Name = "None",
                 Checked = false,
                 EnumMappedTo = WorkerContract.None
             }
         }
     });
 }
        public void it_should_update_an_entity_in_a_collection_by_its_id()
        {
            const int    expectedId   = 1;
            const string expectedName = "Name";
            var          licence      = new Licence
            {
                Id = expectedId,
                NamedIndividuals = new List <NamedIndividual>
                {
                    new NamedIndividual
                    {
                        Id       = expectedId,
                        FullName = string.Empty
                    }
                }
            };
            var model = new FullNameViewModel
            {
                FullName = expectedName
            };

            licenceRepository.GetById(expectedId).Returns(licence);
            repository.Upsert(Arg.Any <NamedIndividual>()).Returns(expectedId);

            var pdh    = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider);
            var result = pdh.Update(expectedId, l => l.NamedIndividuals, model, expectedId);

            Assert.AreEqual(expectedId, result);
            repository.Received(1).Upsert(Arg.Is <NamedIndividual>(a => a.Id == expectedId && a.FullName.Equals(expectedName)));
        }
        public void it_should_create_and_update_a_new_entity_if_one_does_not_exist_with_the_specified_id()
        {
            const int    expectedId   = 1;
            const string expectedName = "Name";
            var          licence      = new Licence
            {
                Id = expectedId,
                NamedIndividuals = new List <NamedIndividual>()
            };
            var model = new FullNameViewModel
            {
                FullName = expectedName
            };

            licenceRepository.GetById(expectedId).Returns(licence);
            repository.Create <NamedIndividual>().Returns(new NamedIndividual {
                Id = expectedId
            });
            repository.Upsert(Arg.Any <NamedIndividual>()).Returns(expectedId);

            var pdh    = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider);
            var result = pdh.Update(expectedId, l => l.NamedIndividuals, model, expectedId);

            Assert.AreEqual(expectedId, result);
            repository.Received(1).Upsert(Arg.Is <NamedIndividual>(a => a.Id == expectedId && a.FullName.Equals(expectedName)));
        }
Exemple #27
0
        /// <summary>
        /// Create a job manager task for an azure job. The job manager task controls
        /// creation and distribution of tasks which get run on the compute nodes.
        /// </summary>
        /// <param name="job">Job parameters.</param>
        private JobManagerTask CreateJobManagerTask(JobParameters job)
        {
            Licence licence = new Licence(AzureSettings.Default.LicenceFilePath);
            var     cmd     = string.Format("cmd.exe /c {0} job-manager {1} {2} {3} {4} {5} {6} {7} {8} {9}",
                                            BatchConstants.GetJobManagerPath(job.ID),
                                            licence.BatchUrl,
                                            licence.BatchAccount,
                                            licence.BatchKey,
                                            licence.StorageAccount,
                                            licence.StorageKey,
                                            job.ID,
                                            BatchConstants.GetModelPath(job.ID),
                                            job.JobManagerShouldSubmitTasks,
                                            job.AutoScale
                                            );

            return(new JobManagerTask
            {
                CommandLine = cmd,
                DisplayName = "Job manager task",
                KillJobOnCompletion = true,
                Id = BatchConstants.JobManagerName,
                RunExclusive = false,
                ResourceFiles = GetJobManagerResourceFiles().ToList()
            });
        }
Exemple #28
0
        private void _generateButton_Click(object sender, EventArgs e)
        {
            if (_serialTextbox.Text == string.Empty)
            {
                MessageBox.Show("serial can not be empty!!!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_customerTextbox.Text == string.Empty)
            {
                MessageBox.Show("customer name can not be empty!!!", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (_LicenceTypeCombobox.SelectedIndex == -1)
            {
                MessageBox.Show("please select licence type.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            LicenceType licenceType;

            licenceType = (LicenceType)_LicenceTypeCombobox.SelectedIndex;
            var licence = new Licence
            {
                CustomerName = _customerTextbox.Text,
                Trial        = _trialCheckbox.Checked,
                CreationDate = DateTime.Now,
                TrialDays    = (int)_trialDaysNumericUpDown.Value,
                Type         = licenceType
            };
            var licencePackString = _licenceGenerator.Generate(licence, _serialTextbox.Text);

            setInDatabase(licencePackString);
            saveLicencePackAsFile(licencePackString);
        }
Exemple #29
0
 public ActionResult SetAuthorizationCode(string authCode)
 {
     try
     {
         string tip;
         if (!Licence.IsLicence(authCode, out tip))
         {
             return(Content(new AjaxResult {
                 state = ResultType.error.ToString(), message = tip
             }.ToJson()));
         }
         try
         {
             Configs.SetValue("LicenceKey", authCode);
         }
         catch (Exception ex)
         {
             LogFactory.GetLogger("AuthController").Error("授权错误1:" + ex.ToString());
             return(Content(new AjaxResult {
                 state = ResultType.error.ToString(), message = "授权码无法写入,请检查文件权限"
             }.ToJson()));
         }
         return(Content(new AjaxResult {
             state = ResultType.success.ToString(), message = "授权成功"
         }.ToJson()));
     }
     catch (Exception ex)
     {
         LogFactory.GetLogger("AuthController").Error("授权错误2:" + ex.ToString());
         return(Content(new AjaxResult {
             state = ResultType.error.ToString(), message = "授权码错误"
         }.ToJson()));
     }
 }
Exemple #30
0
            public void CreateLicenseFile(Licence dto, string fileName)
            {
                var ms = new MemoryStream();

                new XmlSerializer(typeof(PizzaDelivery.Licence)).Serialize(ms, dto);

                // Create a new CspParameters object to specify
                // a key container.

                // Create a new RSA signing key and save it in the container.
                RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider();

                rsaKey.FromXmlString(PrivateKey);

                // Create a new XML document.
                XmlDocument xmlDoc = new XmlDocument();

                // Load an XML file into the XmlDocument object.
                xmlDoc.PreserveWhitespace = true;
                ms.Seek(0, SeekOrigin.Begin);
                xmlDoc.Load(ms);

                // Sign the XML document.
                SignXml(xmlDoc, rsaKey);

                // Save the document.
                xmlDoc.Save(fileName);
            }
 private void ChangeCurrentRow(LicencePresenter licencePresenter, LicenceEditPresenter licenceEdit,
   Licence obj)
 {
     Licence licence = ((Licence)licenceEdit.View.DataContext);
     obj.assign_fixed_asset = licence.assign_fixed_asset;
     obj.comment = licence.comment;
     obj.created_by = licence.created_by;
     obj.id_kind = licence.id_kind;
     obj.id_number = licence.id_number;
     obj.inventory_number = licence.inventory_number;
     obj.last_modified_date = licence.last_modified_date;
     obj.last_modified_login = licence.last_modified_login;
     obj.licence_number = licence.licence_number;
     obj.name = licence.name;
     licencePresenter.View.dataGridLicences.Items.Refresh();
 }
 private void ReadLicence()
 {
     _licence = new Licence();
     string licenceStr;
     _user.RawSsoAttributes.TryGetValue("http://schemas.rm.com/identity/claims/applicence", out licenceStr);
     if (!string.IsNullOrEmpty(licenceStr))
     {
         Match match = licenceRegex.Match(licenceStr);
         if (match.Success)
         {
             _licence.isFreeTrial = bool.Parse(match.Groups[1].Value);
             _licence.isSsoConnector = bool.Parse(match.Groups[2].Value);
             string description = match.Groups[3].Value.Trim();
             _licence.description = string.IsNullOrEmpty(description) ? null : description;
         }
     }
 }
 private void btnUpdate_Click(object sender, RoutedEventArgs e)
 {
      try
     {
         LicencePresenter licencePresenter = (LicencePresenter)this.DataContext;
         Licence licence = new Licence();
         DeepClone.CopyTo((Licence)(licencePresenter.View.dataGridLicences.SelectedItem), licence);
         LicenceEditPresenter subgroupEditPresenter = new LicenceEditPresenter(new LicenceEditView(), licence);
         subgroupEditPresenter.View.Label_AddOrEditLicence.Content = "Edytowanie licencji";
         if (subgroupEditPresenter.View.ShowDialog() == true)
         {
             licencePresenter.SaveLicence(licence, true);
             Licence temp = (Licence)licencePresenter.View.dataGridLicences.SelectedItem;
             ChangeCurrentRow(licencePresenter, subgroupEditPresenter, temp);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }