Beispiel #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            BaseProfile baseProfile = db.BaseProfiles.Find(id);

            db.BaseProfiles.Remove(baseProfile);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public void AddDataObject(string key, BaseProfile obj)
        {
            if (_datas.ContainsKey(key))
            {
                _datas.Remove(key);
            }

            _datas.Add(key, obj);
        }
Beispiel #3
0
        private static void RunProgram(ProgramArgs args)
        {
            if (!Directory.Exists(args.InputDirectory))
            {
                throw new Exception($"Non-existent input directory: {args.InputDirectory}");
            }

            if (!Directory.Exists(args.OutputDirectory))
            {
                Directory.CreateDirectory(args.OutputDirectory);
            }

            new ModuleLoader("VaultLib.Support.*.dll").Load();
            HashManager.LoadDictionary(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "hashes.txt"));

            List <BaseProfile> profiles = new List <BaseProfile>
            {
                new MostWantedProfile(),
                new CarbonProfile(),
                new ProStreetProfile(),
                new UndercoverProfile(),
                new WorldProfile(),
            };

            BaseProfile profile = profiles.Find(p => p.GetName() == args.ProfileName);

            if (profile == null)
            {
                Console.WriteLine("ERROR: Unknown profile {0}", args.ProfileName);
                Console.WriteLine("AVAILABLE PROFILES:");
                foreach (var baseProfile in profiles)
                {
                    Console.WriteLine("\tNAME: {0}", baseProfile.GetName());
                }

                return;
            }

            switch (args.Mode)
            {
            case OperationMode.Pack:
                RunPack(args, profile);
                break;

            case OperationMode.Unpack:
                RunUnpack(args, profile);
                break;

            case OperationMode.ApplyModScript:
                RunApplyModScript(args, profile);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #4
0
        public T GetDataObject <T>(string key) where T : class
        {
            BaseProfile tmp = new BaseProfile();

            if (_datas.TryGetValue(key, out tmp))
            {
                return(tmp as T);
            }
            return(null);
        }
Beispiel #5
0
 public ActionResult Edit([Bind(Include = "BaseProfileId,FirstName,LastName,MiddleName,Phone,Email")] BaseProfile baseProfile)
 {
     if (ModelState.IsValid)
     {
         db.Entry(baseProfile).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BaseProfileId = new SelectList(db.Customers, "CustomerId", "CustomerId", baseProfile.BaseProfileId);
     return(View(baseProfile));
 }
 /// ///////////////////////////////////////
 /// 以下为本Package自己的任务
 private void CollectEventsInOtherPackage(BaseProfile profile)
 {
     // 整合别的包里面的Action
     foreach (Type type in profile.GetAllTypes())
     {
         if (type.IsSubclassOf(typeof(BaseEvent)))
         {
             EventsManagement.AddEventType(type.Name, type);
         }
     }
 }
Beispiel #7
0
 /// <summary>
 /// 查询历史记录(单条)
 /// </summary>
 /// <param 查询时间点="timePoint"></param>
 /// <param 返回数据对象="baseprofile"></param>
 /// <returns></returns>
 public bool ReadBaseProfile(string timePoint, string tableName, out BaseProfile baseprofile)
 {
     baseprofile = AccessDBApply.select_baseprofile(timePoint, tableName);
     if (baseprofile == null)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Beispiel #8
0
 public ActionResult Form(int id = 0)
 {
     if (id == 0)
     {
         return(PartialView(new BaseProfile()));
     }
     else
     {
         BaseProfile model = db.BaseProfiles.Find(id);
         return(PartialView(model));
     }
 }
Beispiel #9
0
 private void EnsureBackups(BaseProfile profile)
 {
     foreach (var sdb in profile)
     {
         var orig = sdb.FullPath;
         var back = $"{orig}.bacc";
         if (!File.Exists(back))
         {
             File.Copy(orig, back, true);
         }
     }
 }
        public void SingleExecution(BaseProfile profile)
        {
            var collection = this.GetManualCollection(this._filename, this._manager, this._gcareer, profile);

            if (collection is GCareer gcareer)
            {
                gcareer.CloneCollection(this._to, this._from, this._root);
            }
            else
            {
                throw new Exception($"Object {this._gcareer} is not a GCareer");
            }
        }
Beispiel #11
0
        public ActionResult Create([Bind(Include = "BaseProfileId,FirstName,LastName,MiddleName,Phone,Email")] BaseProfile baseProfile)
        {
            if (ModelState.IsValid)
            {
                baseProfile.BaseProfileId = Guid.NewGuid();
                db.BaseProfiles.Add(baseProfile);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BaseProfileId = new SelectList(db.Customers, "CustomerId", "CustomerId", baseProfile.BaseProfileId);
            return(View(baseProfile));
        }
Beispiel #12
0
        public void SingleExecution(BaseProfile profile)
        {
            var collection = this.GetManualCollection(this._filename, this._manager, this._str, profile);

            if (collection is STRBlock str)
            {
                str.AddRecord(this._key, this._label, this._text);
            }
            else
            {
                throw new Exception($"Object {this._str} is not a STRBlock");
            }
        }
Beispiel #13
0
        public string AddDataObject(BaseProfile obj)
        {
            string key = Utilities.GuidHelper.GenKey(_datas);

            if (_datas.ContainsKey(key))
            {
                _datas.Remove(key);
            }

            _datas.Add(key, obj);

            return(key);
        }
        public async Task <bool> AddStudentAsync(AddStudentModel profile)
        {
            try
            {
                DbUser user = new DbUser
                {
                    UserName    = profile.Email /*profile.UserName*/,
                    Email       = profile.Email,
                    PhoneNumber = profile.PhoneNumber,
                };
                BaseProfile prof = new BaseProfile
                {
                    Name               = profile.Name,
                    LastName           = profile.LastName,
                    Surname            = profile.Surname,
                    Adress             = profile.Adress,
                    DateOfBirth        = Convert.ToDateTime(profile.DateOfBirth),
                    PassportString     = profile.PassportString,
                    IdentificationCode = profile.IdentificationCode
                };
                string password = PasswordGenerator.GenerationPassword();
                await _userManager.CreateAsync(user, password);

                await _userManager.AddToRoleAsync(user, "Student");

                prof.Id = user.Id;
                await _context.BaseProfiles.AddAsync(prof);

                await _context.SaveChangesAsync();

                await _context.StudentProfiles.AddAsync(new StudentProfile { Id = prof.Id });

                await _context.SaveChangesAsync();

                if (profile.GroupId != 0)
                {
                    await _context.GroupsToStudents.AddAsync(new GroupToStudent
                    {
                        GroupId   = profile.GroupId,
                        StudentId = user.Id
                    });

                    await _context.SaveChangesAsync();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #15
0
        // GET: BaseProfiles/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseProfile baseProfile = db.BaseProfiles.Find(id);

            if (baseProfile == null)
            {
                return(HttpNotFound());
            }
            return(View(baseProfile));
        }
Beispiel #16
0
        public void SingleExecution(BaseProfile profile)
        {
            var collection = this.GetManualCollection(this._filename, this._manager, this._collection, profile);

            if (this._expand is null)
            {
                collection.SetValue(this._property, this._value);
            }
            else
            {
                var part = collection.GetSubPart(this._subpart, this._expand);
                part.SetValue(this._property, this._value);
            }
        }
Beispiel #17
0
        public virtual ActionResult Create(Feedback model)
        {
            ViewBag.FeedbackSubjects = repository.All <FeedbackSubject>();
            if (ModelState.IsValid)
            {
                try
                {
                    model.PublishDate = DateTime.UtcNow;
                    this.repository.Insert(model);
                    this.repository.Save();

                    emailResult result;
                    var         admins = Roles.GetUsersInRole(BaseApplication.AdminRole).Select(x =>
                    {
                        BaseProfile profile;
                        if (BaseApplication.IsSimpleMembershipProviderConfigured())
                        {
                            profile = BaseProfile.CreateProfile(this.repository, x);
                        }
                        else
                        {
                            profile = BaseProfile.CreateProfile(x);
                        }
                        return(profile != null ? profile.Email : string.Empty);
                    }).Where(x => !string.IsNullOrEmpty(x));

                    var subject = this.repository.Find <FeedbackSubject>(model.FeedbackSubjectId).Subject;
                    mailer.Send(string.Join(",", admins), "Feedback submitted",
                                string.Format(@"<h3>A new comment with the category <em>{0}</em> has been posted</h3>
<strong>Submitted by</strong>: {1}<br /><strong>Reply to</strong>: {2}<p>{3}</p>", subject,
                                              model.Name, model.Email, model.Comment), out result);
                }
                catch (Exception ex)
                {
                    return(HttpStatusCode(System.Net.HttpStatusCode.InternalServerError, ex));
                }
                return(Json(new
                {
                    success = true,
                    message = FormMessages.FeedbackPostSuccess,
                    content = this.RenderPartialViewToString("list",
                                                             this.repository.AllIncluding <Feedback>(x => x.FeedbackSubject).OrderByDescending(x => x.PublishDate))
                }));
            }
            else
            {
                return(HttpStatusCode(System.Net.HttpStatusCode.BadRequest, new InvalidOperationException(
                                          string.Join("; ", ModelState.Values.SelectMany(x => x.Errors.Select(e => e.ErrorMessage))))));
            }
        }
 /// ///////////////////////////////////////
 /// 以下为本Package自己的任务
 private void CollectActionsInOtherPackage(BaseProfile profile)
 {
     // 整合别的包里面的Action
     foreach (Type type in profile.GetAllTypes())
     {
         if (type.IsSubclassOf(typeof(BaseAction)))
         {
             ActionsManagement.AddActionType(type.Name, type);
         }
         else if (type.IsSubclassOf(typeof(DataSource)))
         {
             DataSourceManagement.AddDataSourceType(type.Name, type);
         }
     }
 }
Beispiel #19
0
        // GET: BaseProfiles/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BaseProfile baseProfile = db.BaseProfiles.Find(id);

            if (baseProfile == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BaseProfileId = new SelectList(db.Customers, "CustomerId", "CustomerId", baseProfile.BaseProfileId);
            return(View(baseProfile));
        }
Beispiel #20
0
        private void HandleReciveDataEvent(byte[] s)
        {
            BaseProfile _baseprofile = new BaseProfile();

            _baseprofile.Temperature         = (s[0] + (s[1] << 8)) / 10.0; //温度
            _baseprofile.Humidity            = s[2] + (s[3] << 8);          //湿度
            _baseprofile.remainSolderPercent = s[4] + (s[5] << 8);          //剩余量
            _baseprofile.usedSolderNum       = s[6] + (s[7] << 8);          //已使用瓶数
            _baseprofile.addTimes            = s[8] + (s[9] << 8);          //次数
            _baseprofile.startTime           = s[10] + (s[11] << 8);        //启动时间
            _baseprofile.powerOffTime        = s[11] + (s[12] << 8);        //开机时间

            _baseprofile.TimePoint = DateTime.Now;                          //数据点时间

            baseProfile = _baseprofile;
        }
Beispiel #21
0
        public async Task <ApiResponseResult <ProfileResponse> > CreateProfile(BaseProfile profile)
        {
            try
            {
                var request = GetAuthorizedRequest(HttpMethod.Post, "vpn/profiles");
                request.Content    = GetJsonContent(profile);
                using var response = await _client.SendAsync(request).ConfigureAwait(false);

                var body = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                return(Logged(ApiResponseResult <ProfileResponse>(body, response.StatusCode), "Create profile"));
            }
            catch (Exception e) when(e.IsApiCommunicationException())
            {
                throw new HttpRequestException(e.Message, e);
            }
        }
Beispiel #22
0
        public JsonResult Delete(int id = 0)
        {
            BaseProfile model = db.BaseProfiles.Find(id);

            if (model != null)
            {
                model.BaseActions.Clear();
                model.BaseProfileMenus.Clear();
                model.BaseWidgets.Clear();
                model.BaseWidgets1.Clear();
                model.BaseGraphs.Clear();
                model.BaseUsers.Clear();
                db.BaseProfiles.Remove(model);
                db.SaveChanges();
            }
            return(Json("ok", JsonRequestBehavior.AllowGet));
        }
Beispiel #23
0
        public async Task <IActionResult> Patch(string objectId, [FromBody][Required] BaseProfile userToUpdate)
        {
            try
            {
                await _userService.UpdateUserByIdAsync(objectId, userToUpdate);

                return(NoContent());
            }
            catch (ApplicationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Beispiel #24
0
        public void SingleExecution(BaseProfile profile)
        {
            var collection = this.GetManualCollection(this._filename, this._manager, this._tpk, profile);

            if (collection is TPKBlock tpk)
            {
                var key = this._texture.IsHexString()
                                        ? Convert.ToUInt32(this._texture, 16)
                                        : this._texture.BinHash();

                tpk.RemoveTexture(key, KeyType.BINKEY);
            }
            else
            {
                throw new Exception($"Object {this._tpk} is not a TPKBlock");
            }
        }
Beispiel #25
0
        private static void RunUnpack(ProgramArgs args, BaseProfile profile)
        {
            var database = new Database(new DatabaseOptions(profile.GetGame(), profile.GetDatabaseType()));
            var files    = profile.LoadFiles(database, args.InputDirectory);

            database.CompleteLoad();
            var stopwatch = Stopwatch.StartNew();

            var serializer = new DatabaseSerializer(database, args.OutputDirectory);

            serializer.Serialize(files);

            stopwatch.Stop();

            Console.WriteLine("Exported database to {2} in {0}ms ({1:f2}s)", stopwatch.ElapsedMilliseconds,
                              stopwatch.ElapsedMilliseconds / 1000f, args.OutputDirectory);
        }
Beispiel #26
0
        public void SingleExecution(BaseProfile profile)
        {
            var collection = this.GetManualCollection(this._filename, this._manager, this._str, profile);

            if (collection is STRBlock str)
            {
                var key = this._record.IsHexString()
                                        ? Convert.ToUInt32(this._record, 16)
                                        : this._record.BinHash();

                str.RemoveRecord(key);
            }
            else
            {
                throw new Exception($"Object {this._str} is not a STRBlock");
            }
        }
Beispiel #27
0
        /// <inheritdoc />
        public async Task UpdateUserByIdAsync(string id, BaseProfile model)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            try
            {
                await _azureClient.PatchUser(id, model.Adapt <AzureUser>());

                var usersInCache = _cache.Get <List <AzureUser> >(Consts.Cache.UsersKey);
                var user         = usersInCache.FirstOrDefault(x => x.ObjectId == id);
                if (user != null)
                {
                    MergeObjects(model.Adapt <AzureUser>(), user);
                    if (string.IsNullOrEmpty(model.State))
                    {
                        model.State = user.State;
                    }
                }
                else
                {
                    usersInCache.Add(model.Adapt <AzureUser>());
                }

                _cache.Set(Consts.Cache.UsersKey, usersInCache);

                if (!string.IsNullOrEmpty(model.City) && !string.IsNullOrEmpty(model.State))
                {
                    await _localtionService.SetCity(model.City, model?.State);

                    await _localtionService.SetState(model.State);
                }
            }
            catch (ApplicationException)
            {
                throw;
            }
        }
Beispiel #28
0
        public void SingleExecution(BaseProfile profile)
        {
            var sdb = profile[this._filename];

            if (sdb is null)
            {
                throw new LookupFailException($"File {this._filename} was never loaded");
            }

            var manager = sdb.Database.GetManager(this._manager);

            if (manager is null)
            {
                throw new LookupFailException($"Manager named {this._manager} does not exist");
            }

            manager.Remove(this._collection);
        }
Beispiel #29
0
 public JsonResult Save(BaseProfile model)
 {
     if (model.id != 0)
     {
         if (ModelState.IsValid)
         {
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     else
     {
         model.creationDate = DateTime.Now;
         db.BaseProfiles.Add(model);
         db.SaveChanges();
     }
     return(Json(model.id));
 }
Beispiel #30
0
        /// <summary>
        /// Upsert user fields that containse in model
        /// </summary>
        /// <returns></returns>
        public async Task <ResponseModel> UpdateUserByIdAsync(string id, BaseProfile model)
        {
            using (HttpClient client = new HttpClient())
            {
                SetAuthHeader(client);
                var content  = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json");
                var response = await client.PatchAsync($"{_options.ServiceUrl}/{Const.IndentityApi.UserEntity}", content);

                if (!response.IsSuccessStatusCode)
                {
                    throw new ApplicationException("Can not create user with current parameters");
                }

                return(new ResponseModel()
                {
                    StatusCode = HttpStatusCode.OK, Message = "User successefully updated"
                });
            }
        }