Пример #1
0
        public int CreateEvent(string currentUsername, DataModel.Event baseEvent)
        {
            var usBusiness = new Business.Users(base.db);
            CityAngels.DataModel.User loggedUser = usBusiness.GetUser(currentUsername);

            // create event
            if (baseEvent.DateTo == DateTime.MinValue) baseEvent.DateTo = null;

            // standart schedule type (weekly)
            if (baseEvent.IsPeriodic)
            {
                baseEvent.EventSchedulingTypeId = (int)Data.Enum.ScheduleType.WEEKLY;
            }

            // baseEvent.RefEventId = null; <- non rimuovo il riferimento all'evento ripetuto, mi serve per non ripetere due volte l'evento nella giornata
            baseEvent.IsEnabled = true;
            baseEvent.CreateDate = DateTime.Now;
            baseEvent.CreatorUserId = loggedUser.UserId;
            baseEvent.UpdateDate = DateTime.Now;
            baseEvent.UpdateUserId = loggedUser.UserId;

            db.Events.Add(baseEvent);

            // log for other users
            Business.Logs log = new Business.Logs(base.db, Data.Enum.LogTypes.NEW, loggedUser);
            log.Push(baseEvent);

            db.SaveChanges();

            return baseEvent.EventId;
        }
Пример #2
0
        public override void Execute(DataModel context, ILog log)
        {
            var scannedLearners = context.ScannedInLearners.ToList().Where(s => DateTime.Now - s.TimeIn > TimeSpan.FromHours(5));
            var scans = scannedLearners.Select(scannedLearner =>
               new LearnerScan()
               {
                   CreatedAt = DateTime.Now,
                   Activity = "Scanned Out",
                   Details = "Out (Automatic Midnight)",
                   ScanType = "Attendance",
                   Division = scannedLearner.Division,
                   LearnerNumber = scannedLearner.LearnerNumber,
                   Username = "******",
                   Session = scannedLearner.Session,
                   PartnerID = scannedLearner.LinkID
               }
            ).ToList();

            context.LearnerScans.AddRange(scans);
            context.SaveChanges();

            foreach (var scan in scans)
            {
                log.Info($"Scanning out learner: {scan.LearnerNumber} from {scan.Division}");
                if (scan.PartnerID == null) continue;
                var partner = context.LearnerScans.FirstOrDefault(s => s.ID == scan.PartnerID);
                if (partner != null)
                {
                    partner.PartnerID = scan.ID;
                }
            }
            context.ScannedInLearners.RemoveRange(scannedLearners);

            context.SaveChanges();
        }
        public void PopulateDataModel(DataModel model)
        {
            Instruction[] dynamicMethodCalls = ExtractDynamicMethodCallInstructions();
            if (dynamicMethodCalls.Length == 0) { return; }

            Instruction[] cachedReflectedFields = ExtractInitialReflectedCachedFieldReferenceInstructions();
            if (cachedReflectedFields.Length == 0) { return; }

            var references = cachedReflectedFields
                .Select(field => field.ParseToFieldReferenceCreation())
                .Reverse<string>()
                .ToList<string>();

            if (references.Count != 2) { return; }

            string tableName = references[0];
            string columnName = references[1].Replace("FindBy", "");
            Type columnType = null;

            var actualCall = dynamicMethodCalls.Last();

            var current = actualCall.Previous;
            if(current.OpCode.Code == Code.Ldstr)
            {
                columnType = typeof (string);
            } 
            else if (current.OpCode.Code == Code.Ldc_I4_4) // etc
            {
                columnType = typeof(int);
            }

            model.Table(tableName)
                .Column(columnName)
                .SetType(columnType);
        }
Пример #4
0
 public void SaveConfig(DataModel.xTraceConfig xConfig)
 {
     localSettings.Values["ISFIRSTRUN"] = xConfig.ISFIRSTRUN;
     localSettings.Values["IPADDR"] = xConfig.IPADDR;
     localSettings.Values["PORT"] = xConfig.PORT;
     CurrentSettings = xConfig;
 }
    private void LoadDataFromJson(string json)
    {
        JSONNode rootNode = JSON.Parse(json);
        for (int i = 0; i < rootNode.Count; i++) {
            DataModel dm = new DataModel();
            dm.Name = rootNode[i]["name"];
            for (int j = 0; j < rootNode[i][0].Count; j++) {
                switch (j) {
                case 0:
                    dm.VolumeArmazenado = rootNode[i][0][j].AsFloat;
                break;
                case 1:
                    dm.PluviometriaDoDia = rootNode[i][0][j].AsFloat;
                    break;
                case 2:
                    dm.PluviometriaAcuMes = rootNode[i][0][j].AsFloat;
                    break;
                case 3:
                    dm.MediHistMes = rootNode[i][0][j].AsFloat;
                    break;
                }
            }
            AppDataManager.instance.dataModels.Add(dm);
        }

        StartCoroutine(LoadLevel());
    }
Пример #6
0
        private async Task InsertTodoItem(DataModel.TodoItem todoItem)
        {
            string errorString = string.Empty;

            if (media != null)
            {
                todoItem.ContainerName = "todoitemimages";
                todoItem.ResourceName = Guid.NewGuid().ToString();
            }

            await todoTable.InsertAsync(todoItem);

            if (!string.IsNullOrEmpty(todoItem.SasQueryString))
            {
                StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString);
                var imageUri = new Uri(todoItem.ImageUri);

                CloudBlobContainer container = new CloudBlobContainer(
                    new Uri(string.Format("https://{0}/{1}",
                        imageUri.Host, todoItem.ContainerName)), cred);

                using (var inputStream = await media.OpenReadAsync())
                {
                    CloudBlockBlob blobFromSASCredential =
                        container.GetBlockBlobReference(todoItem.ResourceName);
                    await blobFromSASCredential.UploadFromStreamAsync(inputStream);
                }
                
                await ResetCaptureAsync();
            }

            items.Add(todoItem);
        }
Пример #7
0
        private void notifyCompletedLearners(DataModel context, ILog log)
        {
            var learnersByDivision = Enrollment.CompletedToday(context)
                .Include(e => e.Learner)
                .Select(e => e.Learner)
                .Include(l => l.Division).ToList()
                .GroupBy(l => l.Division);

            foreach (var grouping in learnersByDivision)
            {
                var division = grouping.Key;

                var mail = new MailMessage("*****@*****.**", division.Email);
                var builder = new StringBuilder();
                builder.AppendLine("The following learners have completed their enrollments today:");
                foreach (var learner in grouping)
                {
                    log.Info($"Notified {learner.DivisionAbreviation} that learner {learner.LearnerNumber} completed their enrollment.");
                    builder.AppendLine($"{learner.DivisionAbreviation}{learner.LearnerNumber}\t{learner.Surname}, {learner.Name}");
                }
                mail.Subject = "Learners that have completed their enrollments";
                mail.Body = builder.ToString();

                var outbox = new Outbox();
                outbox.Send(mail);
            }
        }
Пример #8
0
 public Person(DataModel.Person data) {
   Data = data;
   Id = data.Id;
   Title = data.Name;
   IconName = "appbar_people";
   PeopleGroupId = data.PeopleGroupId;
 }
Пример #9
0
 /// <summary>
 /// Driver to find the proper translator for a particular object type
 /// </summary>
 /// <param name="iCalObjectName"></param>
 /// <param name="rawModel"></param>
 /// <returns></returns>
 private static IEnumerable<object> TranslateBlock(string iCalObjectName, DataModel.RawModel[] rawModel)
 {
     if (!_translators.ContainsKey(iCalObjectName))
         return null;
     var translator = _translators[iCalObjectName];
     return rawModel.Select(rm => translator(rm));
 }
 public ActionResult Index()
 {
     var dataModel = new DataModel {HiveQl = "SELECT * FROM sample_08 LIMIT 100;"};
     var dt = new DataTable();
     dataModel.Dt = dt;
     return View(dataModel);
 }
Пример #11
0
    public void GeneratePeopleAndCompute()
    {
        int numberOfPeople = 0;
        try { numberOfPeople = int.Parse(NumberOfPeopleField.text); } catch { NumberOfPeopleField.text = numberOfPeople.ToString(); }
        int startingYear = 1900;
        try { startingYear = int.Parse(StartingYearField.text); } catch { StartingYearField.text = startingYear.ToString(); }
        int endingYear = 2000;
        try { endingYear = int.Parse(EndingYearField.text); } catch { EndingYearField.text = endingYear.ToString(); }
        int maxLifespan = 100;
        try { maxLifespan = int.Parse(MaxLifespanField.text); } catch { MaxLifespanField.text = maxLifespan.ToString(); }

        if (startingYear > endingYear )
        {
            int temp = startingYear;
            startingYear = endingYear;
            endingYear = temp;
            StartingYearField.text = startingYear.ToString();
            EndingYearField.text = endingYear.ToString();
        }

        DataModel model = new DataModel(numberOfPeople, startingYear, endingYear, maxLifespan);

        PeopleView.PopulatePeopleView(model.People);

        int[] mappingOfPopulationToDate = DateComputation.ComputeNumberOfLivingForEachYear(model.People, startingYear, endingYear);
        Graph.PopulateGraph(startingYear, endingYear, numberOfPeople, mappingOfPopulationToDate);

        int mostPopulousYear = DateComputation.ComputeDateOfMostLiving(mappingOfPopulationToDate, startingYear);
        MostPopulousYearField.text = mostPopulousYear.ToString();
        PopulationField.text = mappingOfPopulationToDate[mostPopulousYear - startingYear].ToString();
    }
Пример #12
0
        public PlaylistItem(MPDSongResponseBlock block, DataModel dataModel)
        {
            Path = new Path(block.File);
            Position = block.Pos;
            Id = block.Id;

            if (Path.IsStream())
            {
                Artist = null;
                Album = null;
                AudioStream stream = dataModel.StreamsCollection.StreamByPath(Path);

                if (stream != null)
                {
                    Title = stream.Label;
                }
                else
                {
                    Title = block.Name ?? Path.ToString();
                }
            }
            else
            {
                Title = block.Title;
                Album = block.Album;

                if (Settings.Default.UseAlbumArtist)
                {
                    Artist = block.AlbumArtist ?? block.Artist;
                }

                Artist = block.Artist;
            }
        }
 public ActionResult ReturnAPage(string hiveQl)
 {
     var dataModel = new DataModel {HiveQl = hiveQl};
     DataTable dt = new HiveQueryDataService().GetDataFromHivet(dataModel.HiveQl);
     dataModel.Dt = dt;
     return View("Index", dataModel);
 }
Пример #14
0
        public static async Task<DataGroup> NewsGoVnGroup_Parse(string xmlString, DataModel.DataGroup group, int takeNum)
        {
            StringReader _stringReader = new StringReader(xmlString);
            XDocument _xdoc = XDocument.Load(_stringReader);
            var channelElement = _xdoc.Element("rss").Element("channel");
            if (channelElement != null)
            {
                group.Title = channelElement.Element("title").Value;
                group.Subtitle = channelElement.Element("title").Value;
                group.Description = channelElement.Element("description").Value;

                var items = channelElement.Elements("item");
                foreach (var item in items)
                {
                    if (group.Items.Count == takeNum && takeNum >= 0) break;

                    DataItem dataItem = new DataItem();
                    dataItem.Title = item.Element("title").Value;
                    dataItem.Description = StripHTML(item.Element("description").Value);
                    dataItem.Link = new Uri(item.Element("link").Value, UriKind.Absolute);
                    dataItem.PubDate = item.Element("pubDate").Value;

                    HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
                    htmlDoc.Load(new StringReader(item.Element("description").Value));

                    HtmlAgilityPack.HtmlNode imageLink = getFirstNode("img", htmlDoc.DocumentNode);
                    dataItem.ImageUri = new Uri(imageLink.GetAttributeValue("src", string.Empty).Replace("96.62.jpg", "240.155.jpg"), UriKind.Absolute);

                    dataItem.Group = group;
                    group.Items.Add(dataItem);
                }
            }

            return group;
        }
Пример #15
0
 public static IQueryable<Enrollment> ToBeCompleted(DataModel context)
 {
     var enrollmentIDs = context.Database.SqlQuery<long>(@"
         SELECT e.idEnrollments
         FROM enrollments e
         JOIN learner_details l ON l.learnerKey = e.learnerKey
         WHERE e.completed IS NULL
         AND (
           SELECT COUNT(*)
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
           AND lecom.moderated = 'yes'
         ) > 0
         AND 'Competent' = ALL (
           SELECT outcome
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
         )
         AND 'yes' = ALL (
           SELECT moderated
           FROM learnerEnrollmentComponents lecom
           WHERE lecom.idEnrollments = e.idEnrollments
         );
     ").ToList();
     return context.Enrollments.Where(e => enrollmentIDs.Contains(e.ID));
 }
Пример #16
0
        public UserEntity AddUser(DataModel.UserEntity user)
        {
            var userToUpdate = new User();
            userToUpdate.FirstName = user.FirstName;
            userToUpdate.LastName = user.LastName;
            userToUpdate.Email = user.Email;
            userToUpdate.PositionId = user.PositionId;
            userToUpdate.UserName = user.UserName;
            userToUpdate.Password = user.Password;

            if (user.Projects.Count > 0)
            {
                foreach (var item in user.Projects)
                {
                    Project p = dataContext.Projects.Where(q => q.ProjectId == item.ProjectId).First();
                    userToUpdate.Projects.Add(p);
                }
            }

            if (user.Rights.Count > 0)
            {
                foreach (var item in user.Rights)
                {
                    Right r = dataContext.Rights.First(c => c.RightId == item.RightId);
                    userToUpdate.Rights.Add(r);
                }
            }

            dataContext.Users.Add(userToUpdate);
            dataContext.SaveChanges();

            return user;
        }
Пример #17
0
        public override void Execute(DataModel context, ILog log)
        {
            var today = DateTime.Today;
            var scannedEmployees = context.ScannedInEmployees
                .Include(e => e.InScan)
                .Where(s => DbFunctions.TruncateTime(s.InScan.CreatedAt) < today)
                .ToList();
            foreach (var scannedEmployee in scannedEmployees)
            {
                var scanIn = context.EmployeeScans.Find(scannedEmployee.ScanID);
                var scan = new EmployeeScan()
                {
                    CreatedAt = scanIn.CreatedAt,
                    EmployeeNumber = scannedEmployee.EmployeeNumber,
                    Division = scanIn.Division,
                    Details = "Out (System)",
                    ScanType = "Type",
                    PartnerID = scanIn.ID,
                    Username = "******"
                };

                log.Info($"Scanning out Employee: {scan.EmployeeNumber} from {scan.Division}");
                context.EmployeeScans.Add(scan);
            }
            context.ScannedInEmployees.RemoveRange(scannedEmployees);
            context.SaveChanges();
        }
Пример #18
0
        /// <summary>
        ///     遍历列
        /// </summary>
        /// <param name="cols">列集合</param>
        /// <param name="format">模板</param>
        /// <returns></returns>
        public string ForEach(ColumnSchemaCollection cols, string format)
        {
            var sb = new StringBuilder();
            foreach (ColumnSchema col in cols)
            {
                bool isPrimaryKeyMember = col.IsPrimaryKeyMember; // 是否为主键列
                var m = new DataModel
                {
                    TableName = base.TableName,
                    TableComment = DbUtil.GetComment(base.Table.Description, base.TableName),
                    ColumnName = DbUtil.GetColumnName(col.Name, this.CutColumnName),
                    ColumnDbType = col.NativeType,
                    ColumnType = DbUtil.GetColumnType(col.SystemType),
                    ColumnLength = (col.Size < 0 ? int.MaxValue : col.Size).ToString(),
                    ColumnEnableNull = col.AllowDBNull,
                    ColumnIdentity = Convert.ToBoolean(col.ExtendedProperties["CS_IsIdentity"].Value.ToString())
                };

                m.ColumnComment = DbUtil.GetComment(col.Description, m.ColumnName);
                m.ColumnComment = isPrimaryKeyMember ? m.ColumnComment + " 主键" : m.ColumnComment;

                m.ColumnType = m.ColumnEnableNull ? m.ColumnType + "?" : m.ColumnType;

                sb.AppendLine(DbUtil.Format(format, m));
            }
            return sb.ToString();
        }
Пример #19
0
    public Viewer(DataModel.Viewer data) : this() {
      Data = data;
      Id = data.Id;
      Title = data.Name;

      LoadFolders(true);
      LoadFolders(false);
    }
Пример #20
0
 /// <summary>
 /// Converts object of class <see cref="DataModel.FileLink"/> into its 
 /// data transfer representation <see cref="FileLink"/>.
 /// </summary>
 /// <param name="link">
 /// An object to convert.
 /// </param>
 /// <returns>
 /// An instance of <see cref="FileLink"/> that corresponds value of <paramref name="link"/>
 /// </returns>
 public FileLink ToContract(DataModel.FileLink link)
 {
     return new FileLink
                {
                    Id = link.Id,
                    Metadata = new Dictionary<string, string>(link.Metadata)
                };
 }
Пример #21
0
 /// <summary>
 /// Converts object of class <see cref="DataModel.FileInfo"/> into its 
 /// data transfer representation <see cref="FileInfo"/>.
 /// </summary>
 /// <param name="info">
 /// An object to convert.
 /// </param>
 /// <returns>
 /// An instance of <see cref="FileInfo"/> that corresponds value of <paramref name="info"/>
 /// </returns>
 public FileInfo ToContract(DataModel.FileInfo info)
 {
     return new FileInfo
                {
                    Id = info.Id,
                    Name = info.Name
                };
 }
        public ActionResult ReturnAjson(string hiveQl)
        {
            var dataModel = new DataModel {HiveQl = hiveQl};
            DataTable dt = new HiveQueryDataService().GetDataFromHivet(dataModel.HiveQl);
            dataModel.Dt = dt;

            return new JsonNetResult(dataModel);
        }
Пример #23
0
 public static void UpdateDatabase()
 {
     using (var context = new DataModel())
     {
         var schemaHandler = context.GetSchemaHandler();
         EnsureDb(schemaHandler);
     }
 }
        public DataModel.WorkItemTypeEntity AddWorkItemType(DataModel.WorkItemTypeEntity workItemType)
        {
            WorkItemType _workItemType = new WorkItemType();
            _workItemType.Description = workItemType.Description;
            dataContext.WorkItemTypes.Add(_workItemType);
            dataContext.SaveChanges();

            return workItemType;
        }
Пример #25
0
        public DataModel.RightEntity AddRight(DataModel.RightEntity right)
        {
            Right newRight = new Right();
            newRight.Description = right.Description;
            db.Rights.Add(newRight);
            db.SaveChanges();

            return right;
        }
Пример #26
0
		public SpearmanCorrelation(DataModel dataModel) 
		{
			if (dataModel == null) 
			{
				throw new ArgumentNullException("dataModel is null");
			}
			this.rankingUserCorrelation = new PearsonCorrelation(dataModel);
			this.refreshLock = new ReentrantLock();
		}
Пример #27
0
		protected AbstractRecommender(DataModel dataModel) 
		{
			if (dataModel == null) 
            {
				throw new ArgumentNullException("dataModel is null");
			}
			this.dataModel = dataModel;
			this.refreshLock = new ReentrantLock();
		}
        public DataModel.PositionEntity SavePosition(DataModel.PositionEntity position)
        {
            Position newPosition = new Position();
            newPosition.Description = position.Description;
            dataContext.Positions.Add(newPosition);
            dataContext.SaveChanges();

            return position;
        }
Пример #29
0
        /// <summary>
        /// Creates a new SampleMatrix object, where each column corresponds
        /// to a variable and each row to an observation of those variables.
        /// </summary>
        /// <param name="matrix">The base matrix</param>
        /// <param name="model">The matrix model</param>
        public SampleMatrix(double[,] data, string name, DataModel model)
            : base(data)
        {
            if (model == DataModel.ColumnsAsObservations)
                this.baseArray = (double[][])this.Transpose();

            this.m_name = name;
            this.generateDefaultNames();
        }
Пример #30
0
        public DataModel.StatusEntity AddStatus(DataModel.StatusEntity status)
        {
            Status newStat = new Status();
            newStat.Description = status.Description;
            db.Status.Add(newStat);
            db.SaveChanges();

            return status;
        }
Пример #31
0
        // GET api/<controller>/5
        public Query Get(int id)
        {
            DataModel ObjModel = new DataModel();

            return(ObjModel.GetQueryByQueryId(id));
        }
Пример #32
0
        // POST api/<controller>
        public int Post(Query query)
        {
            DataModel ObjModel = new DataModel();

            return(ObjModel.InsertQuery(query));
        }
Пример #33
0
 public static DataTableJoin WithDataModel(this DataTableJoin dataTableJoin, DataModel dataModel)
 {
     dataTableJoin.DataModel = dataModel;
     return(dataTableJoin);
 }
Пример #34
0
 public void AddModelAlias(string alias, DataModel model)
 {
     modelAliases.Add(alias, model);
 }
Пример #35
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                throw new Exception("Antiforgery check failed.");
            }
            Init();
            if (ErpRequestContext.Page == null)
            {
                return(NotFound());
            }

            //Standard Page functionality
            var PostObject = (EntityRecord) new PageService().ConvertFormPostToEntityRecord(PageContext.HttpContext, entity: ErpRequestContext.Entity);

            DataModel.SetRecord(PostObject);

            var globalHookInstances = HookManager.GetHookedInstances <IPageHook>(HookKey);

            foreach (IPageHook inst in globalHookInstances)
            {
                var result = inst.OnPost(this);
                if (result != null)
                {
                    return(result);
                }
            }


            if (PageContext.HttpContext.Request.Query.ContainsKey("hookKey"))
            {
                //custom implementation hook
                try
                {
                    var hookInstances = HookManager.GetHookedInstances <IRecordCreatePageCustomImplHook>(HookKey);

                    if (!PostObject.Properties.ContainsKey("id"))
                    {
                        PostObject["id"] = Guid.NewGuid();
                    }

                    foreach (IRecordCreatePageCustomImplHook inst in hookInstances)
                    {
                        var result = inst.OnCreateRecord(PostObject, ErpRequestContext.Entity, this);
                        if (result != null)
                        {
                            return(result);
                        }
                    }

                    if (string.IsNullOrWhiteSpace(ReturnUrl))
                    {
                        return(Redirect($"/{ErpRequestContext.App.Name}/{ErpRequestContext.SitemapArea.Name}/{ErpRequestContext.SitemapNode.Name}/r/{PostObject["id"]}"));
                    }
                    else
                    {
                        return(Redirect(ReturnUrl));
                    }
                }
                catch (ValidationException valEx)
                {
                    Validation.Message = valEx.Message;
                    Validation.Errors.AddRange(valEx.Errors);
                    BeforeRender();
                    return(Page());
                }
            }
            else
            {
                ValidateRecordSubmission(PostObject, ErpRequestContext.Entity, Validation);
                if (Validation.Errors.Count == 0)
                {
                    if (!PostObject.Properties.ContainsKey("id"))
                    {
                        PostObject["id"] = Guid.NewGuid();
                    }

                    var hookInstances = HookManager.GetHookedInstances <IRecordCreatePageHook>(HookKey);

                    //pre create hooks
                    foreach (IRecordCreatePageHook inst in hookInstances)
                    {
                        List <ValidationError> errors = new List <ValidationError>();
                        var result = inst.OnPreCreateRecord(PostObject, ErpRequestContext.Entity, this, errors);
                        if (result != null)
                        {
                            return(result);
                        }
                        if (errors.Any())
                        {
                            Validation.Errors.AddRange(errors);
                            BeforeRender();
                            return(Page());
                        }
                    }

                    var createResponse = new RecordManager().CreateRecord(ErpRequestContext.Entity.MapTo <Entity>(), PostObject);
                    if (!createResponse.Success)
                    {
                        Validation.Message = createResponse.Message;
                        foreach (var error in createResponse.Errors)
                        {
                            Validation.Errors.Add(new ValidationError(error.Key, error.Message));
                        }

                        ErpRequestContext.PageContext = PageContext;
                        BeforeRender();
                        return(Page());
                    }

                    //post create hook
                    foreach (IRecordCreatePageHook inst in hookInstances)
                    {
                        var result = inst.OnPostCreateRecord(PostObject, ErpRequestContext.Entity, this);
                        if (result != null)
                        {
                            return(result);
                        }
                    }

                    if (string.IsNullOrWhiteSpace(ReturnUrl))
                    {
                        return(Redirect($"/{ErpRequestContext.App.Name}/{ErpRequestContext.SitemapArea.Name}/{ErpRequestContext.SitemapNode.Name}/r/{createResponse.Object.Data[0]["id"]}"));
                    }
                    else
                    {
                        return(Redirect(ReturnUrl));
                    }
                }
            }
            BeforeRender();
            return(Page());
        }
Пример #36
0
        // GET api/<controller>
        public IEnumerable <Query> Get()
        {
            DataModel ObjModel = new DataModel();

            return(ObjModel.GetAllQueries());
        }
Пример #37
0
 /// <summary>
 /// Constructs the builder object with the specified provider and model.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="model"></param>
 public DbDataProviderCommandBuilder(DbDataProvider provider, DataModel model)
     : this(provider)
 {
     DataModel = model;
 }
Пример #38
0
        public async Task <ActionResult> DiseaseList(DataModel model, int?page)
        {
            IPagedList <SP_TAKE_DISEASE_AND_TYPEResult> pagedDiseaseList = null;

            try
            {
                // Load list of specialities
                specialityList = await SpecialityUtil.LoadSpecialityAsync();

                ViewBag.SpecialityList = new SelectList(specialityList, Constants.SpecialityID, Constants.SpecialityName);

                // Check if page parameter is null
                if (page == null)
                {
                    page = 1;
                }

                #region Load data

                // Load list of service
                List <SP_TAKE_DISEASE_AND_TYPEResult> diseaseList =
                    new List <SP_TAKE_DISEASE_AND_TYPEResult>();
                if (model.IsPostBack == false)
                {
                    diseaseList = await model.LoadListOfDisease(null, true, 1, 0);

                    ViewBag.CurrentStatus = true;
                    ViewBag.CurrentMode   = 1;
                    ViewBag.CurrentOption = true;
                }
                else
                {
                    if (model.Option == false)
                    {
                        diseaseList = await model.LoadListOfDisease(
                            model.DiseaseName, model.IsActive, 0, 0);
                    }
                    else
                    {
                        if (model.Mode == 1)
                        {
                            if (model.SpecialityID == 0)
                            {
                                diseaseList = await model.LoadListOfDisease(
                                    model.DiseaseName, model.IsActive, 1, 0);
                            }
                            else
                            {
                                diseaseList = await model.LoadListOfDisease(
                                    model.DiseaseName, model.IsActive, 2, model.SpecialityID);
                            }
                        }
                        else
                        {
                            diseaseList = await model.LoadListOfDisease(
                                model.DiseaseName, model.IsActive, 3, 0);
                        }
                    }

                    ViewBag.CurrentStatus = model.IsActive;
                    ViewBag.CurrentMode   = model.Mode;
                    ViewBag.CurrentOption = model.Option;
                }

                #endregion

                #region Display notification

                // Pass value of previous adding service to view (if any)
                if (TempData[Constants.ProcessInsertData] != null)
                {
                    ViewBag.AddStatus = (int)TempData[Constants.ProcessInsertData];
                }

                // Pass value of previous updating service to view (if any)
                if (TempData[Constants.ProcessUpdateData] != null)
                {
                    ViewBag.UpdateStatus = (int)TempData[Constants.ProcessUpdateData];
                }

                // Pass value of previous updating service status to view (if any)
                if (TempData[Constants.ProcessStatusData] != null)
                {
                    ViewBag.ChangeStatus = (int)TempData[Constants.ProcessStatusData];
                }

                #endregion

                // Handle query string
                NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(Request.Url.Query);
                queryString.Remove(Constants.PageUrlRewriting);
                ViewBag.Query = queryString.ToString();

                // Return value to view
                pagedDiseaseList = diseaseList.ToPagedList(page.Value, Constants.PageSize);
                return(View(pagedDiseaseList));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
Пример #39
0
 public void ReverseVelocityExecuted()
 {
     DataModel.ReverseVelocity();
     MainViewModel.IsModified = true;
 }
Пример #40
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < teamsButton.Count; i++)
        {
            teamsButton[i].GetComponentInChildren <TextMeshProUGUI>().text = DataModel.GetTextScoreFromTeam(i);
        }

        if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
        {
            if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
            {
                DataModel.Scores[0] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
            {
                DataModel.Scores[1] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3))
            {
                DataModel.Scores[2] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4))
            {
                DataModel.Scores[3] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha5) || Input.GetKeyDown(KeyCode.Keypad5))
            {
                DataModel.Scores[4] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetKeyDown(KeyCode.Keypad6))
            {
                DataModel.Scores[5] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha7) || Input.GetKeyDown(KeyCode.Keypad7))
            {
                DataModel.Scores[6] += 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha8) || Input.GetKeyDown(KeyCode.Keypad8))
            {
                DataModel.Scores[7] += 1;
            }
        }

        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
        {
            if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
            {
                DataModel.Scores[0] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
            {
                DataModel.Scores[1] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3))
            {
                DataModel.Scores[2] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4))
            {
                DataModel.Scores[3] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha5) || Input.GetKeyDown(KeyCode.Keypad5))
            {
                DataModel.Scores[4] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetKeyDown(KeyCode.Keypad6))
            {
                DataModel.Scores[5] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha7) || Input.GetKeyDown(KeyCode.Keypad7))
            {
                DataModel.Scores[6] -= 1;
            }
            if (Input.GetKeyDown(KeyCode.Alpha8) || Input.GetKeyDown(KeyCode.Keypad8))
            {
                DataModel.Scores[7] -= 1;
            }
        }

        // Make joker appear or disappear
        for (int i = 0; i < DataModel.Jokers.Length; i++)
        {
            if (DataModel.Jokers[i])
            {
                GameObject.Find("Joker " + (i + 1)).GetComponent <CanvasGroup>().alpha = 1;
            }
            else
            {
                GameObject.Find("Joker " + (i + 1)).GetComponent <CanvasGroup>().alpha = 0;
            }
        }
    }
Пример #41
0
 internal DataModelListViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath)
     : base(dataModel, parent, dataModelPath)
 {
     _countDisplay = "0 items";
     _listChildren = new BindableCollection <DataModelVisualizationViewModel>();
 }
Пример #42
0
 public void SetDataModel(DataModel model)
 {
     _dataModel = model;
 }
 public PrivilegeRepository(DataModel context)
 {
     _context = context;
 }
Пример #44
0
    // [END data_model]
    public static void Main()
    {
        // [START data]
        DataModel data = new DataModel();
        // [END data]
        // [END program_part1]

        // [START solver]
        // Create the linear solver with the SCIP backend.
        Solver solver = Solver.CreateSolver("SCIP");

        // [END solver]

        // [START program_part2]
        // [START variables]
        Variable[,] x = new Variable[data.NumItems, data.NumBins];
        for (int i = 0; i < data.NumItems; i++)
        {
            for (int j = 0; j < data.NumBins; j++)
            {
                x[i, j] = solver.MakeIntVar(0, 1, $"x_{i}_{j}");
            }
        }
        // [END variables]

        // [START constraints]
        for (int i = 0; i < data.NumItems; ++i)
        {
            Constraint constraint = solver.MakeConstraint(0, 1, "");
            for (int j = 0; j < data.NumBins; ++j)
            {
                constraint.SetCoefficient(x[i, j], 1);
            }
        }

        for (int j = 0; j < data.NumBins; ++j)
        {
            Constraint constraint = solver.MakeConstraint(0, data.BinCapacities[j], "");
            for (int i = 0; i < data.NumItems; ++i)
            {
                constraint.SetCoefficient(x[i, j], DataModel.Weights[i]);
            }
        }
        // [END constraints]

        // [START objective]
        Objective objective = solver.Objective();

        for (int i = 0; i < data.NumItems; ++i)
        {
            for (int j = 0; j < data.NumBins; ++j)
            {
                objective.SetCoefficient(x[i, j], DataModel.Values[i]);
            }
        }
        objective.SetMaximization();
        // [END objective]

        // [START solve]
        Solver.ResultStatus resultStatus = solver.Solve();
        // [END solve]

        // [START print_solution]
        // Check that the problem has an optimal solution.
        if (resultStatus != Solver.ResultStatus.OPTIMAL)
        {
            Console.WriteLine("The problem does not have an optimal solution!");
            return;
        }
        Console.WriteLine("Total packed value: " + solver.Objective().Value());
        double TotalWeight = 0.0;

        for (int j = 0; j < data.NumBins; ++j)
        {
            double BinWeight = 0.0;
            double BinValue  = 0.0;
            Console.WriteLine("Bin " + j);
            for (int i = 0; i < data.NumItems; ++i)
            {
                if (x[i, j].SolutionValue() == 1)
                {
                    Console.WriteLine($"Item {i} weight: {DataModel.Weights[i]} values: {DataModel.Values[i]}");
                    BinWeight += DataModel.Weights[i];
                    BinValue  += DataModel.Values[i];
                }
            }
            Console.WriteLine("Packed bin weight: " + BinWeight);
            Console.WriteLine("Packed bin value: " + BinValue);
            TotalWeight += BinWeight;
        }
        Console.WriteLine("Total packed weight: " + TotalWeight);
        // [END print_solution]
    }
        /// <summary>
        /// Load Magnetic Values
        /// </summary>
        /// <param name="lat">Signed Latitude (Geodetic)</param>
        /// <param name="lng">Signed Longitude (Geodetic)</param>
        /// <param name="height">Height in Meters</param>
        /// <param name="semiMajorAxis">Semi-Major Axis</param>
        /// <param name="inverseFlattening">Inverse Flattening</param>
        /// <param name="date">Date Time</param>
        /// <param name="model">Data Model</param>
        private void Load(double lat, double lng, double height, double semiMajorAxis, double inverseFlattening, DateTime date, DataModel model)
        {
            this.semiMajorAxis     = semiMajorAxis;
            this.inverseFlattening = inverseFlattening;
            flattening             = 1 / inverseFlattening;            //Flattening
            eccentricitySquared    = flattening * (2 - flattening);    //Eccentricity  Squared
            semiMinorAxis          = semiMajorAxis * (1 - flattening); //Semi-minor axis

            nLatGD = lat.NormalizeDegrees360();
            nLngGD = lng.NormalizeDegrees360();

            radiusOfCurvature = semiMajorAxis / Math.Sqrt(1 - (eccentricitySquared * Math.Pow(Math.Sin(nLatGD.ToRadians()), 2)));
            northPolarAxis    = (radiusOfCurvature * (1 - eccentricitySquared) + height) * Math.Sin(nLatGD.ToRadians());
            pointOfInterest   = (radiusOfCurvature - height) * Math.Cos(nLatGD.ToRadians());
            radius            = Math.Sqrt(Math.Pow(pointOfInterest, 2) + Math.Pow(northPolarAxis, 2));

            nLatGC = Math.Asin(northPolarAxis / radius);
            nLngGC = nLngGD.ToRadians();

            TimeSpan ts = date - new DateTime(date.Year, 1, 1);
            int      ly = 365;

            if (DateTime.IsLeapYear(date.Year))
            {
                ly = 366;
            }
            decimalDate = date.Year + (ts.TotalDays / ly);


            points = new DataPoints(model, this);
            points.Load_Values(); //Load Calculated Values

            magneticFieldElements = new MagneticFieldElements(this);
            secularVariations     = new SecularVariations(this);
            uncertainty           = new Uncertainty(this);
        }
Пример #46
0
 public void ResetRotationVelocityExecuted()
 {
     DataModel.ResetRotationVelocity();
     MainViewModel.IsModified = true;
 }
Пример #47
0
 public OrdersProcessor(DataModel dataModel)
 {
     _dataModel = dataModel;
 }
Пример #48
0
 public void ReorientStationExecuted()
 {
     DataModel.ReorientStation();
     MainViewModel.IsModified = true;
 }
Пример #49
0
 // Adding a model alias to the current scope
 public void AddModelAlias(string alias, DataModel model)
 {
     CurrentScope.AddModelAlias(alias, model);
 }
Пример #50
0
 public void OptimizeObjectExecuted()
 {
     MainViewModel.OptimizeModel(this);
     IsSubsSystemNotReady = true;
     DataModel.InitializeAsync();
 }
Пример #51
0
 public void ConvertToShipExecuted()
 {
     DataModel.ConvertToShip();
     MainViewModel.IsModified = true;
 }
Пример #52
0
        // PUT api/<controller>/5
        public int Put(Query query)
        {
            DataModel ObjModel = new DataModel();

            return(ObjModel.UpdateQueryByQueryId(query));
        }
Пример #53
0
 public void ResetLinearVelocityExecuted()
 {
     DataModel.ResetLinearVelocity();
     MainViewModel.IsModified = true;
 }
Пример #54
0
 public IsWeaponEquipped(DataModel dataModel, bool negate = false, Mode mode = Mode.InstantCheck) :
     base(dataModel, negate, mode)
 {
 }
Пример #55
0
 public void RepairObjectExecuted()
 {
     DataModel.RepairAllDamage();
     MainViewModel.IsModified = true;
 }
Пример #56
0
 public void ConvertToStationExecuted()
 {
     DataModel.ConvertToStation();
     MainViewModel.IsModified = true;
 }
Пример #57
0
        public void CombineButtonTextTest()
        {
            DataModel dataModel = new DataModel();

            Assert.AreEqual(dataModel.CombineButtonText(0), "烤鯖魚押壽司" + Constant.WRAP + "$40元");
        }
Пример #58
0
 public void TestInitialize()
 {
     DataModel dataModel = new DataModel();
 }
Пример #59
0
    // Use this for initialization
    void Start()
    {
        /*
         *  Initialisation of gameobjects and variables
         */
        DisableTeam();
        counter = 0;

        teamContainer = GameObject.FindWithTag("teamcontainer");
        teamsButton   = teamContainer.GetComponentsInChildren <Button>().OrderBy(go => go.name).ToList();
        teamsCtrl     = teamContainer.GetComponentsInChildren <PlayerModel>().OrderBy(go => go.name).ToList();

        parent          = GameObject.Find("TopicContainer");
        parentTransform = parent.transform.GetComponent <RectTransform>();
        grid            = parent.transform.GetComponent <GridLayoutGroup>();

        Sprite sprite = Resources.Load <Sprite>("Images/" + DataModel.BackgroundName);

        GameObject.Find("Background").GetComponent <Image>().sprite = sprite;

        /*
         * We create a number of buttons equal to the number of topics in the current round
         */
        foreach (TopicData t in DataModel.CurRound().Topics)
        {
            topic      = Instantiate(Resources.Load <GameObject>("Prefabs/Topic"), parent.transform);
            topic.name = "Topic" + (counter + 1);
            topic.GetComponent <Button>().onClick.AddListener(() => SelectingTopic());
            counter++;
        }

        /*
         *  Adjust the size of the buttons to always fit the same space despite the number
         */
        float height = parentTransform.rect.height;
        float width  = parentTransform.rect.width;

        if (counter % 2 == 0)
        {
            grid.cellSize = new Vector2((width / 2) - grid.spacing.y, height / (counter / 2) - grid.spacing.x);
        }
        else
        {
            grid.cellSize = new Vector2((width / 2) - grid.spacing.y, height / ((counter + 1) / 2) - grid.spacing.x);
        }

        /*
         *  Initialisation of other gameobjects and variables
         */
        counter = 0;
        foreach (GameObject go in GameObject.FindGameObjectsWithTag("Topics"))
        {
            topicButtons.Add(go.GetComponent <Button>());
        }
        topicButtons.OrderBy(b => b.name);

        for (int i = 0; i < DataModel.Jokers.Length; i++)
        {
            DataModel.Jokers[i] = false;
        }

        foreach (Button b in teamsButton)
        {
            b.onClick.AddListener(() => b.gameObject.GetComponent <PlayerModel>().ActivateJoker());
        }
        for (int i = 0; i < teamsButton.Count; i++)
        {
            if (i < DataModel.NumberOfTeams)
            {
                teamsButton[i].GetComponentInChildren <TextMeshProUGUI>().text = DataModel.GetTextScoreFromTeam(i);
            }
            else
            {
                teamsButton[i].gameObject.SetActive(false);
            }
        }

        teamsButton = teamContainer.GetComponentsInChildren <Button>().OrderBy(go => go.name).ToList();

        foreach (Button b in topicButtons)
        {
            b.onClick.AddListener(() => SelectingTopic());
        }

        /*
         *  TopicMusic setup
         */
        topicSource        = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <AudioSource>();
        topicMusic         = (AudioClip)Resources.Load("Sounds/" + DataModel.TopicMusicName);
        topicSource.clip   = topicMusic;
        topicSource.loop   = true;
        topicSource.volume = 0.4f;
        topicSource.Play();

        DisplayText();

        // Erase topics already done
        foreach (TopicData t in DataModel.CurRound().Topics)
        {
            if (!t.IsAvailable)
            {
                foreach (Button b in topicButtons)
                {
                    if (b.GetComponentInChildren <TextMeshProUGUI>().text == t.Name)
                    {
                        b.gameObject.SetActive(false);
                    }
                }
            }
        }
    }
Пример #60
0
        public async Task <ActionResult> FacilityList(DataModel model, int?page)
        {
            IPagedList <SP_TAKE_FACILITY_AND_TYPEResult> pagedFacilityList = null;

            try
            {
                // Load list of service type
                facilityTypeList = await ServiceFacilityUtil.LoadFacilityTypeAsync();

                ViewBag.FacilityTypeList = new SelectList(facilityTypeList, Constants.TypeID, Constants.TypeName);

                // Check if page parameter is null
                if (page == null)
                {
                    page = 1;
                }

                #region Load data

                // Load list of service
                List <SP_TAKE_FACILITY_AND_TYPEResult> facilityList =
                    new List <SP_TAKE_FACILITY_AND_TYPEResult>();
                if (model.IsPostBack == false)
                {
                    facilityList = await model.LoadListOfFacility(null, 0, true);

                    ViewBag.CurrentStatus = true;
                }
                else
                {
                    facilityList = await model.LoadListOfFacility(
                        model.FacilityName, model.TypeID, model.IsActive);

                    ViewBag.CurrentStatus = model.IsActive;
                }

                #endregion

                #region Display notification

                // Pass value of previous adding facility to view (if any)
                if (TempData[Constants.ProcessInsertData] != null)
                {
                    ViewBag.AddStatus = (int)TempData[Constants.ProcessInsertData];
                }

                // Pass value of previous updating service to view (if any)
                if (TempData[Constants.ProcessUpdateData] != null)
                {
                    ViewBag.UpdateStatus = (int)TempData[Constants.ProcessUpdateData];
                }

                // Pass value of previous updating service status to view (if any)
                if (TempData[Constants.ProcessStatusData] != null)
                {
                    ViewBag.ChangeStatus = (int)TempData[Constants.ProcessStatusData];
                }

                #endregion

                // Handle query string
                NameValueCollection queryString = System.Web.HttpUtility.ParseQueryString(Request.Url.Query);
                queryString.Remove(Constants.PageUrlRewriting);
                ViewBag.Query = queryString.ToString();

                // Return value to view
                pagedFacilityList = facilityList.ToPagedList(page.Value, Constants.PageSize);
                return(View(pagedFacilityList));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }