Example #1
0
    public static void LoadInfo(InfoContainer info)
    {
        if (info != null)
        {
            AllCells           = info.AllCells.ToList();
            GameScore          = info.GameScore;
            GameHighScore      = info.GameHighScore;
            PreviousScore      = info.PreviousScore;
            isUndone           = info.IsUndone;
            GameField          = info.GameField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            PreviousMoveField  = info.PreviousMoveField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            TemporaryMoveField = info.TemporaryMoveField ?? new Cell[Config.FieldHeight, Config.FieldWidth];
            CellFactory.Load(info.CurrentId);
            for (int i = 0; i < Config.FieldHeight; i++)
            {
                for (int j = 0; j < Config.FieldWidth; j++)
                {
                    if (GameField[i, j] != null)
                    {
                        GameField[i, j] = AllCells.Find(c => GameField[i, j].id == c.id);
                    }
                }
            }

            foreach (var cell in AllCells)
            {
                cell.isNew = true;
            }
        }
        //GarbageCollect();
    }
Example #2
0
 private Query GetQuery(InfoContainer cont, string method, DbValue[] keys, Func <string> creator)
 {
     if (CacheQuerys)
     {
         var sb = new StringBuilder();
         sb.Append(method);
         if (keys != null)
         {
             foreach (var k in keys)
             {
                 sb.Append(GetMod(k.Comp));
                 sb.Append(k.Key);
             }
         }
         var key = sb.ToString();
         if (cont.QueryBuffer.ContainsKey(key))
         {
             return(cont.QueryBuffer[key]);
         }
         var q = db.Create(creator());
         cont.QueryBuffer.Add(key, q);
         return(q);
     }
     else
     {
         lastQuery?.Dispose();
         return(lastQuery = db.Create(creator()));
     }
 }
Example #3
0
        void Init()
        {
            RefreshThread             = Thread.CurrentThread;
            HUDBackgroundBrush        = new SolidBrush(Color.FromArgb(COL_BACKGROUND));
            HUDSize                   = Settings.Default.HUDSize;
            HUDBitmap                 = new Bitmap((HUDSize.Width + HUDSize.Height) * 18 + 4, HUDSize.Height * 18 + 4);
            HUDGraphics               = Graphics.FromImage(HUDBitmap);
            HUDGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            HUDGraphics.DrawLines(new Pen(Color.FromArgb(COL_EDGE), 4), new Point[] { new Point(2, HUDBitmap.Height), new Point(HUDSize.Height * 9 + 2, 2), new Point(HUDSize.Width * 18 + HUDSize.Height * 9 + 2, 2), new Point(HUDBitmap.Width - 2, HUDBitmap.Height) });
            HUDGraphics.FillPolygon(HUDBackgroundBrush, new Point[] { new Point(2, HUDBitmap.Height), new Point(HUDSize.Height * 9 + 2, 2), new Point(HUDSize.Width * 18 + HUDSize.Height * 9 + 2, 2), new Point(HUDBitmap.Width - 2, HUDBitmap.Height) });
            HUDGraphics.Flush(FlushIntention.Sync);
            HUDRectangle   = new Rectangle(Point.Empty, HUDBitmap.Size);
            HUDTexture     = new Texture(XDevice, HUDBitmap, Usage.None, Pool.Managed);
            HUDGrid        = new Point(HUDSize.Height * 9 + 2, 4);
            HUDPosition    = new Point(XDevice.DisplayMode.Width / 2 - HUDBitmap.Width / 2, XDevice.DisplayMode.Height);
            HUDState       = HUDBitmap.Height;
            HUDHeight      = HUDBitmap.Height;
            InfoContainers = new List <InfoContainer>();
            foreach (string item in Settings.Default.HUDObjects.Split(new char[] { '|' }))
            {
                string   name     = item.Split(new char[] { ':' })[0];
                string[] position = item.Split(new char[] { ':' })[1].Split(new char[] { ',' });

                InfoContainer IC = new InfoContainer();
                IC.Object      = LoadInfoObject(name);
                IC.Location    = new Point(Convert.ToInt32(position[0]) * 18, Convert.ToInt32(position[1]) * 18);
                IC.NextRefresh = 0;
                InfoContainers.Add(IC);
            }
            RefreshTimer  = new Timer(RefreshCallback, null, 100, Timeout.Infinite);
            RefreshThread = null;
        }
        private void Init(IRootMain rootMain)
        {
            Dependencies.Cache(this);

            infoContainer = CreateChild <InfoContainer>("info", 0);
            {
                infoContainer.Anchor   = AnchorType.BottomStretch;
                infoContainer.Pivot    = PivotType.Top;
                infoContainer.RawWidth = 0f;
                infoContainer.Height   = Mathf.Min(infoContainer.FullDetailHeight, rootMain.Resolution.y - InfoDetailedYDiff);
                infoContainer.Y        = InfoBriefY;
            }
            versionContainer = CreateChild <VersionContainer>("version", 1);
            {
                versionContainer.Anchor   = AnchorType.TopStretch;
                versionContainer.Pivot    = PivotType.Top;
                versionContainer.RawWidth = 0;
                versionContainer.Y        = 0f;
                versionContainer.Height   = 160f;
            }

            infoDetailAni = new Anime();
            infoDetailAni.AnimateFloat(y => infoContainer.Y = y)
            .AddTime(0f, () => infoContainer.Y)
            .AddTime(0.25f, infoContainer.Height)
            .Build();

            infoBriefAni = new Anime();
            infoBriefAni.AnimateFloat(y => infoContainer.Y = y)
            .AddTime(0f, () => infoContainer.Y)
            .AddTime(0.25f, InfoBriefY)
            .Build();

            OnEnableInited();
        }
        /// <summary>
        /// Analyse the data
        /// </summary>
        /// <param name="webView">WebView in which the sheet is rendered.</param>
        /// <param name="ct">Token which is used to cancel the task.</param>
        /// <returns></returns>
        private async Task Analyse(WebView webView, CancellationToken ct)
        {
            while (!ct.IsCancellationRequested)
            {
                //if (DevFlags.LoggingEnabled) Logger.AnalyzerLog("Looping");
                if (ResultBuffer.Peek() != null)
                {
                    if (DevFlags.LoggingEnabled)
                    {
                        Logger.AnalyzerLog("Analysing");
                    }
                    ct.ThrowIfCancellationRequested();
                    var data = ResultBuffer.Get();
                    if (data != null)
                    {
                        var song = CompareWithSheet(data);

                        //Hack: In case something failed in CompareWithSheet skip this cycle, hopefully the next one will work
                        if (song == null)
                        {
                            continue;
                        }
                        AnalysedData.Push(song);
                        if (song.Type == Highlight.Chord)
                        {
                            InfoContainer.HitNote();
                            if (DevFlags.LoggingEnabled)
                            {
                                Logger.AnalyzerLog("Highlighting " + song.WebId);
                            }
                            string scriptName = $"HighlightCorrectChord('" + song.WebId + "')";

                            MainThread.BeginInvokeOnMainThread(async() =>
                            {
                                await webView.EvaluateJavaScriptAsync(scriptName);
                            });
                        }
                        else if (song.Type == Highlight.Note)
                        {
                            InfoContainer.HitNote();
                            if (DevFlags.LoggingEnabled)
                            {
                                Logger.AnalyzerLog("Highlighting " + song.WebId);
                            }
                            string scriptName = $"HighlightCorrectNote('" + song.WebId + "')";

                            MainThread.BeginInvokeOnMainThread(async() =>
                            {
                                await webView.EvaluateJavaScriptAsync(scriptName);
                            });
                        }
                    }
                }
            }
            ct.ThrowIfCancellationRequested();
        }
Example #6
0
    private void Start()
    {
        EventSystem.OnCurrentSwipeDirectionChanged += OnSwipe;
        EventSystem.OnRestart += OnRestart;
        EventSystem.OnUndo    += OnUndo;
        //PlayerPrefs.DeleteAll();
        InfoContainer container =
            JsonConvert.DeserializeObject <InfoContainer>(PlayerPrefs.GetString(Config.PlayerInfoKey));

        GameModel.LoadInfo(container);
        Init();
        isAlreadyWon = container.IsAlreadyWon;
        if (container.IsGameover)
        {
            EventSystem.OnGameOverInvoke();
        }
    }
Example #7
0
        public async Task <InfoContainer> getClientInfoContainerByIDAsync(Guid clientID)
        {
            InfoContainer logicRelationshipContainer = await santaContext.Clients
                                                       .Select(client => new InfoContainer()
            {
                agentID = client.ClientId,
                notes   = client.Notes.Select(note => new Logic.Objects.Base_Objects.Note()
                {
                    noteID       = note.NoteId,
                    noteSubject  = note.NoteSubject,
                    noteContents = note.NoteContents
                }).ToList(),
                assignments = client.ClientRelationXrefSenderClients.Select(xref => new RelationshipMeta()
                {
                    relationshipClient   = Mapper.MapClientMeta(xref.RecipientClient),
                    eventType            = Mapper.MapEvent(xref.EventType),
                    clientRelationXrefID = xref.ClientRelationXrefId,
                    assignmentStatus     = Mapper.MapAssignmentStatus(xref.AssignmentStatus),
                    tags      = new List <Logic.Objects.Tag>(),
                    removable = xref.ChatMessages.Count > 0 ? false : true
                }).ToList(),
                senders = client.ClientRelationXrefRecipientClients.Select(xref => new RelationshipMeta()
                {
                    relationshipClient   = Mapper.MapClientMeta(xref.SenderClient),
                    eventType            = Mapper.MapEvent(xref.EventType),
                    clientRelationXrefID = xref.ClientRelationXrefId,
                    assignmentStatus     = Mapper.MapAssignmentStatus(xref.AssignmentStatus),
                    tags      = new List <Logic.Objects.Tag>(),
                    removable = xref.ChatMessages.Count > 0 ? false : true
                }).ToList(),

                responses = client.SurveyResponses.Select(surveyResponse => new Response()
                {
                    surveyResponseID = surveyResponse.SurveyResponseId,
                    clientID         = surveyResponse.ClientId,
                    surveyID         = surveyResponse.SurveyId,
                    surveyOptionID   = surveyResponse.SurveyOptionId,
                    responseText     = surveyResponse.ResponseText,
                    responseEvent    = Mapper.MapEvent(surveyResponse.Survey.EventType),
                    surveyQuestion   = Mapper.MapQuestion(surveyResponse.SurveyQuestion)
                }).ToList()
            }).AsNoTracking().FirstOrDefaultAsync(c => c.agentID == clientID);

            return(logicRelationshipContainer);
        }
        /// <summary>
        /// Compares the Essentia data with the musical data based on timing and value of note. Uses the <see cref="SongHelper"/>.
        /// </summary>
        /// <param name="essentiaData">Data that shall be compared with the current note.</param>
        /// <returns></returns>
        public SongObject CompareWithSheet(EssentiaModel essentiaData)
        {
            string     noteToCompare = GetNoteFromData(essentiaData);
            SongObject songObject    = SongHelper.GetNext();

            //SongHelper.GetNext() sometimes returns an invalid object
            //Temporary Hack (not even working...)
            if (songObject == null)
            {
                if (DevFlags.LoggingEnabled)
                {
                    Logger.AnalyzerLog("songObject couldn't be loaded - " + songObject.ToString());
                }
                return(null);
            }

            //if(DevFlags.LoggingEnabled) Logger.AnalyzerLog("Comparing: " + songObject.Name + " - " + noteToCompare);
            if (CompareNamesOf(songObject.Name, noteToCompare) &&
                InRange(songObject.TimePosition, essentiaData.time))
            {
                if (DevFlags.LoggingEnabled)
                {
                    Logger.AnalyzerLog("Equal");
                }
            }
            else
            {
                songObject.Type = Highlight.None;
                if (DevFlags.LoggingEnabled)
                {
                    Logger.AnalyzerLog("Not equal");
                }
            }

            if (SongHelper.IncreaseIndex(essentiaData.time, songObject))
            {
                //End of Song
                InfoContainer.DisplayResults();
                Logger.Log("Analyzer: END OF SONG, now crashing?");
                throw new Exception("End of Song");
            }

            return(songObject);
        }
Example #9
0
        private void LoadInfo(Type type)
        {
            var cont = new InfoContainer();

            cont.ClassType      = type;
            cont.ClassAttribute = type.GetCustomAttribute <DbClassAttribute>();
            if (cont.ClassAttribute == null)
            {
                throw new TypeAccessException("type doesn't contains DbClassAttribute");
            }
            foreach (var prop in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                var attr = prop.GetCustomAttribute <DbPropAttribute>();
                if (attr == null)
                {
                    continue;
                }
                if (attr.DbPropName == null)
                {
                    attr.DbPropName = prop.Name;
                }
                cont.Properties[attr.DbPropName]     = prop;
                cont.PropAttributes[attr.DbPropName] = attr;
                cont.PropertyType[attr.DbPropName]   = getPropType(prop);
                cont.SetMethods[attr.DbPropName]     = Helper.FastInvoke.BuildUntypedSetter <object>(prop);
                cont.GetMethods[attr.DbPropName]     = Helper.FastInvoke.BuildUntypedGetter <object>(prop);
            }
            List <string> nl = new List <string>(cont.PropAttributes.Count), pl = new List <string>(cont.PropAttributes.Count);

            foreach (var e in cont.PropAttributes)
            {
                nl.Add(e.Value.DbPropName);
                if (e.Value.PrimaryKey)
                {
                    pl.Add(e.Value.DbPropName);
                }
            }
            cont.NameTable   = nl.ToArray();
            cont.PrimaryKeys = pl.ToArray();
            storedTypes.Add(type, cont);
            LoadQuerys(cont);
        }
Example #10
0
 public void Init()
 {
     this.m_info = new InfoContainer();
     InvokeRepeating("SetInfoGfx", 1.0f, 1.0f);
 }
Example #11
0
 private void FillKnowProp <T>(InfoContainer cont, string name, object target, PropertyInfo prop, bool resultIsNull, object nullValue, T defaultNullValue, Func <T> getValue)
 {
     cont.SetMethods[name](target, resultIsNull ? nullValue is T ? nullValue : defaultNullValue : getValue());
     //prop.SetValue(target, resultIsNull ? nullValue is T ? nullValue : defaultNullValue : getValue());
 }
Example #12
0
        private void LoadQuerys(InfoContainer cont)
        {
            var sb = new StringBuilder();

            sb.Append("SELECT ");
            for (int i = 0; i < cont.NameTable.Length; ++i)
            {
                if (i != 0)
                {
                    sb.Append(", ");
                }
                sb.Append(cont.NameTable[i]);
            }
            sb.Append(" FROM ");
            sb.Append(cont.ClassAttribute.TableName);
            cont.selectAllQuery = sb.ToString();

            sb.Clear();
            sb.Append("UPDATE ");
            sb.Append(cont.ClassAttribute.TableName);
            sb.Append(" SET ");
            int valCount = 0;

            for (int i = 0; i < cont.NameTable.Length; ++i)
            {
                if (!cont.PrimaryKeys.Contains(cont.NameTable[i]))
                {
                    if (valCount++ != 0)
                    {
                        sb.Append(", ");
                    }
                    sb.Append(cont.NameTable[i]);
                    sb.Append("=?");
                }
            }
            sb.Append(" WHERE ");
            for (int i = 0; i < cont.PrimaryKeys.Length; ++i)
            {
                if (i != 0)
                {
                    sb.Append(" AND ");
                }
                sb.Append(cont.PrimaryKeys[i]);
                sb.Append("=?");
            }
            cont.updateQuery = sb.ToString();

            sb.Clear();
            sb.Append("INSERT INTO ");
            sb.Append(cont.ClassAttribute.TableName);
            sb.Append(" (");
            valCount = 0;
            for (int i = 0; i < cont.NameTable.Length; ++i)
            {
                if (!cont.PropAttributes[cont.NameTable[i]].AutoGenerated)
                {
                    if (valCount++ > 0)
                    {
                        sb.Append(',');
                    }
                    sb.Append(cont.NameTable[i]);
                }
            }
            sb.Append(") VALUES (");
            for (int i = 0; i < valCount; ++i)
            {
                if (i != 0)
                {
                    sb.Append(',');
                }
                sb.Append('?');
            }
            sb.Append(")");
            cont.addQuery = sb.ToString();
        }
Example #13
0
 // Ensure that the instance is destroyed when the game is stopped in the editor.
 void OnApplicationQuit()
 {
     s_Instance = null;
 }
        public static void ConvertingCarPartRemainsToDb(BusinessContext bc, string path)
        {
            path = Reports.Helpers.ConvertXlsToXlsx(path);

            var existingFile = new FileInfo(path);

            using (var package = new ExcelPackage(existingFile))
            {
                var workBook = package.Workbook;
                if (workBook != null)
                {
                    if (workBook.Worksheets.Count > 0)
                    {
                        for (var date = new DateTime(2015, 9, 1); date <= new DateTime(2015, 10, 1); date = date.AddMonths(1))
                        {
                            var sheet = workBook.Worksheets.First(s => s.Name == date.ToString("MMMM yyyy"));

                            var carParts      = bc.GetDirectoryCarParts().ToList();
                            var excelCarParts = new List <DirectoryCarPart>();
                            var excelRemains  = new List <InfoLastMonthDayRemain>();

                            int indexRow = 3;

                            using (var sw = new StreamWriter("articles.txt"))
                            {
                                sw.WriteLine();
                            }

                            string article = GetValue(sheet.Cells[indexRow, 1].Value);
                            while (!string.IsNullOrWhiteSpace(article))
                            {
                                int indexDigit = -1;
                                for (int i = 0; i < article.Length; i++)
                                {
                                    if (char.IsDigit(article[i]))
                                    {
                                        indexDigit = i;
                                    }
                                    else if (char.IsLetter(article[i]) && indexDigit != -1)
                                    {
                                        indexDigit = i - 1;
                                        break;
                                    }
                                }

                                string newArticle = article.Substring(0, indexDigit + 1);
                                string mark       = indexDigit != (article.Length - 1)
                                    ? article.Substring(indexDigit + 1)
                                    : null;


                                var equalCarPart = carParts.FirstOrDefault(p => ((p.Article + p.Mark) == article) ||
                                                                           (p.Mark == null &&
                                                                            p.Article == newArticle));
                                if (equalCarPart == null)
                                {
                                    equalCarPart = bc.AddDirectoryCarPart(newArticle, mark,
                                                                          GetValue(sheet.Cells[indexRow, 5].Value),
                                                                          null, null, null, null, null, null, string.IsNullOrWhiteSpace(mark));

                                    using (var sw = new StreamWriter("articles.txt", true))
                                    {
                                        sw.WriteLine(equalCarPart.Article + equalCarPart.Mark);
                                    }
                                }

                                int remain = int.Parse(GetValue(sheet.Cells[indexRow, 6].Value) ?? "0");

                                excelCarParts.Add(equalCarPart);

                                excelRemains.Add(new InfoLastMonthDayRemain
                                {
                                    Count = remain,
                                    DirectoryCarPartId = equalCarPart.Id,
                                    Date = date
                                });

                                indexRow++;
                                article = GetValue(sheet.Cells[indexRow, 1].Value);
                            }

                            int indexColumn = 7;

                            var containers = new List <InfoContainer>();

                            while (GetValue(sheet.Cells[2, indexColumn].Value) != "И того приход")
                            {
                                var containerName = GetValue(sheet.Cells[2, indexColumn].Value);
                                if (containerName != null)
                                {
                                    if (!containerName.Contains("от"))
                                    {
                                        indexColumn++;
                                        continue;
                                    }
                                    string name = containerName.Substring(0, containerName.IndexOf("от")).Trim();

                                    DateTime dateContainer;

                                    if (containerName.IndexOf(" ", containerName.IndexOf("от") + 3) != -1)
                                    {
                                        dateContainer = DateTime.Parse(containerName.Substring(containerName.IndexOf("от") + 3,
                                                                                               containerName.IndexOf(" ", containerName.IndexOf("от") + 3) -
                                                                                               (containerName.IndexOf("от") + 3))
                                                                       .Replace(",", ".").Trim(new[] { ' ', '.' }));
                                    }
                                    else
                                    {
                                        dateContainer = DateTime.Parse(containerName.Substring(containerName.IndexOf("от") + 3));
                                    }

                                    string description;
                                    if (dateContainer.Date < date)
                                    {
                                        dateContainer = date;
                                        description   = containerName.Substring(containerName.IndexOf("от") + 3).Replace(",", " ").Trim();
                                    }
                                    else
                                    {
                                        description = containerName.Substring(containerName.IndexOf("от") + 11).Replace(",", " ").Trim();
                                    }

                                    var containerCarParts = new List <CurrentContainerCarPart>();
                                    for (int row = 3; row < 1227; row++)
                                    {
                                        var countCarPart = GetValue(sheet.Cells[row, indexColumn].Value);
                                        int result;
                                        if (int.TryParse(countCarPart, out result))
                                        {
                                            containerCarParts.Add(new CurrentContainerCarPart
                                            {
                                                CountCarParts      = result,
                                                DirectoryCarPartId = excelCarParts[row - 3].Id,
                                            });
                                        }
                                    }

                                    var container = new InfoContainer
                                    {
                                        DatePhysical = dateContainer,
                                        DateOrder    = dateContainer,
                                        IsIncoming   = true,
                                        Name         = name,
                                        Description  = description,
                                        CarParts     = containerCarParts
                                    };
                                    containers.Add(container);
                                }
                                indexColumn++;
                            }

                            indexColumn++;

                            while (GetValue(sheet.Cells[2, indexColumn].Value) != "Расход")
                            {
                                var containerName = GetValue(sheet.Cells[2, indexColumn].Value);
                                if (containerName != null)
                                {
                                    if (!containerName.Contains("от"))
                                    {
                                        indexColumn++;
                                        continue;
                                    }
                                    string   name = containerName.Substring(0, containerName.IndexOf("от")).Trim();
                                    DateTime dateContainer;

                                    if (containerName.IndexOf(" ", containerName.IndexOf("от") + 3) != -1)
                                    {
                                        dateContainer = DateTime.Parse(containerName.Substring(containerName.IndexOf("от") + 3,
                                                                                               containerName.IndexOf(" ", containerName.IndexOf("от") + 3) -
                                                                                               (containerName.IndexOf("от") + 3))
                                                                       .Replace(",", ".").Trim(new[] { ' ', '.' }));
                                    }
                                    else
                                    {
                                        dateContainer = DateTime.Parse(containerName.Substring(containerName.IndexOf("от") + 3));
                                    }

                                    string description;
                                    if (dateContainer.Date < date)
                                    {
                                        dateContainer = date;
                                        description   = containerName.Substring(containerName.IndexOf("от") + 3).Replace(",", " ").Trim();
                                    }
                                    else
                                    {
                                        description = containerName.Substring(containerName.IndexOf("от") + 11).Replace(",", " ").Trim();
                                    }

                                    var containerCarParts = new List <CurrentContainerCarPart>();
                                    for (int row = 3; row < 1227; row++)
                                    {
                                        var countCarPart = GetValue(sheet.Cells[row, indexColumn].Value);
                                        if (countCarPart != null)
                                        {
                                            int result;
                                            if (int.TryParse(countCarPart, out result))
                                            {
                                                containerCarParts.Add(new CurrentContainerCarPart
                                                {
                                                    CountCarParts      = result,
                                                    DirectoryCarPartId = excelCarParts[row - 3].Id,
                                                });
                                            }
                                        }
                                    }


                                    var container = new InfoContainer
                                    {
                                        DatePhysical = dateContainer,
                                        DateOrder    = dateContainer,
                                        IsIncoming   = false,
                                        Name         = name,
                                        Description  = description,
                                        CarParts     = containerCarParts
                                    };
                                    containers.Add(container);
                                }
                                indexColumn++;
                            }

                            bc.RemoveInfoLastMonthDayRemains(date.Year, date.Month);
                            bc.DataContext.BulkInsert(excelRemains);

                            bc.RemoveContainers(date.Year, date.Month);
                            bc.DataContext.BulkInsert(containers);

                            var containersDB = bc.GetInfoContainers(containers).ToList();

                            foreach (var container in containersDB)
                            {
                                var c = container;

                                bc.DataContext.BulkInsert(c.CarParts.Select(p => new CurrentContainerCarPart
                                {
                                    CountCarParts      = p.CountCarParts,
                                    DirectoryCarPartId = p.DirectoryCarPartId,
                                    InfoContainerId    = c.Id
                                }));
                            }
                        }
                    }
                }
            }
        }
Example #15
0
 public TestTarget()
 {
     Info = new InfoContainer();
 }