コード例 #1
0
ファイル: MemberInfo.cs プロジェクト: PeterHuberSg/Storage
 /// <summary>
 /// constructor for simple data type, not enum
 /// </summary>
 public MemberInfo(
     string memberText,
     string name,
     string csvTypeString,
     MemberTypeEnum memberType,
     ClassInfo classInfo,
     bool isNullable,
     bool isReadOnly,
     string?comment,
     string?defaultValue,
     bool needsDictionary)
 {
     MemberText      = memberText;
     MemberName      = name;
     LowerMemberName = name[0..1].ToLowerInvariant() + name[1..];
コード例 #2
0
        private void ParseMemberEnd(ParseRecord pr)
        {
            MemberTypeEnum ee = pr.memberTypeEnum;

            if (ee == MemberTypeEnum.Field)
            {
                if (pr.memberValueEnum == MemberValueEnum.Nested)
                {
                    this.ParseObjectEnd(pr);
                }
            }
            else if (ee == MemberTypeEnum.Item)
            {
                this.ParseArrayMemberEnd(pr);
            }
            else
            {
                this.ParseError(pr, (ParseRecord)this.stack.Peek());
            }
        }
コード例 #3
0
 internal void Init()
 {
     this._isInitial               = false;
     this._count                   = 0;
     this._expectedType            = BinaryTypeEnum.ObjectUrt;
     this._expectedTypeInformation = null;
     this._name             = null;
     this._objectTypeEnum   = ObjectTypeEnum.Empty;
     this._memberTypeEnum   = MemberTypeEnum.Empty;
     this._memberValueEnum  = MemberValueEnum.Empty;
     this._dtType           = null;
     this._numItems         = 0;
     this._typeInformation  = null;
     this._memberLength     = 0;
     this._binaryTypeEnumA  = null;
     this._typeInformationA = null;
     this._memberNames      = null;
     this._memberTypes      = null;
     this._pr.Init();
 }
コード例 #4
0
 public void Init()
 {
     parseTypeEnum      = ParseTypeEnum.Empty;
     objectTypeEnum     = ObjectTypeEnum.Empty;
     arrayTypeEnum      = ArrayTypeEnum.Empty;
     memberTypeEnum     = MemberTypeEnum.Empty;
     memberValueEnum    = MemberValueEnum.Empty;
     objectPositionEnum = ObjectPositionEnum.Empty;
     name                   = null;
     value                  = null;
     keyDt                  = null;
     dtType                 = null;
     dtTypeCode             = PrimitiveTypeEnum.Invalid;
     objectId               = 0L;
     idRef                  = 0L;
     arrayElementTypeString = null;
     arrayElementType       = null;
     isArrayVariant         = false;
     arrayElementTypeCode   = PrimitiveTypeEnum.Invalid;
     rank                   = 0;
     lengthA                = null;
     lowerBoundA            = null;
     indexMap               = null;
     memberIndex            = 0;
     linearlength           = 0;
     rectangularMap         = null;
     isLowerBound           = false;
     isValueTypeFixup       = false;
     newObj                 = null;
     objectA                = null;
     primitiveArray         = null;
     objectInfo             = null;
     isRegistered           = false;
     memberData             = null;
     si = null;
     consecutiveNullArrayEntryCount = 0;
 }
コード例 #5
0
        /// <summary>
        /// uploads the skater picture to the skater picture folder and attaches it to the skater info.
        /// </summary>
        /// <param name="skater"></param>
        public static string UploadSkaterPicture(Guid skaterId, MemberTypeEnum memType)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "Images (*.JPG;*.JPEG;*.PNG)|*.JPG;*.JPEG;*.PNG";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                string filename = dlg.FileName;
                if (!String.IsNullOrEmpty(filename))
                {
                    try
                    {
                        Logger.Instance.logMessage("uploading ref picture: " + filename, LoggerEnum.message);
                        string destinationFilename = System.IO.Path.Combine(ScoreboardConfig.SAVE_SKATERS_PICTURE_FOLDER, skaterId.ToString().Replace("-", "") + System.IO.Path.GetExtension(filename));

                        DirectoryInfo dir = new DirectoryInfo(ScoreboardConfig.SAVE_SKATERS_PICTURE_FOLDER);
                        if (!dir.Exists)
                            dir.Create();

                        using (var im = System.Drawing.Image.FromFile(filename))
                        {

                            //800x800 width and heights
                            var imageTemp = Images.ScaleDownImage(im, ScoreboardConfig.DEFAULT_SIZE_OF_RESIZED_IMAGE, ScoreboardConfig.DEFAULT_SIZE_OF_RESIZED_IMAGE);
                            imageTemp.Save(destinationFilename);
                            //File.Copy(filename, destinationFilename, true);
                        }

                        if (Internet.CheckConnection())
                            GameViewModel.SendProfilePictureForMember(GameViewModel.Instance.GameId, skaterId, filename, memType);
                        return destinationFilename;
                    }
                    catch (Exception exception)
                    {
                        Logger.Instance.logMessage("tried uploading skater picture to game: " + exception.Message, LoggerEnum.error);
                        ErrorViewModel.Save(exception, exception.GetType(), null, null, null, Logger.Instance.getLoggedMessages());
                    }

                }

            }
            return String.Empty;
        }
コード例 #6
0
        private void ParseMember(ParseRecord pr)
        {
            ParseRecord onStack = (ParseRecord)this.stack.Peek();
            //string str = (onStack != null) ? onStack.name : null;
            MemberTypeEnum ee = pr.memberTypeEnum;

            if ((ee != MemberTypeEnum.Field) && (ee == MemberTypeEnum.Item))
            {
                this.ParseArrayMember(pr);
            }
            else
            {
                if ((pr.dtType == null) && onStack.objectInfo.IsTyped)
                {
                    pr.dtType = onStack.objectInfo.GetType(pr.name);
                    if (pr.dtType != null)
                    {
                        pr.dtTypeCode = Converter.ToCode(pr.dtType);
                    }
                }
                if (pr.memberValueEnum == MemberValueEnum.Null)
                {
                    onStack.objectInfo.AddValue(pr.name, null, ref onStack.si, ref onStack.memberData);
                }
                else if (pr.memberValueEnum == MemberValueEnum.Nested)
                {
                    this.ParseObject(pr);
                    this.stack.Push(pr);
                    if ((pr.objectInfo == null) || ((pr.objectInfo.ObjectType == null) || !pr.objectInfo.ObjectType.IsValueType))
                    {
                        onStack.objectInfo.AddValue(pr.name, pr.newObj, ref onStack.si, ref onStack.memberData);
                    }
                    else
                    {
                        pr.isValueTypeFixup = true;
                        this.ValueFixupStack.Push(new ValueFixup(onStack.newObj, pr.name, onStack.objectInfo));
                    }
                }
                else if (pr.memberValueEnum == MemberValueEnum.Reference)
                {
                    object obj2 = this.objectManager.GetObject(pr.idRef);
                    if (obj2 != null)
                    {
                        onStack.objectInfo.AddValue(pr.name, obj2, ref onStack.si, ref onStack.memberData);
                    }
                    else
                    {
                        onStack.objectInfo.AddValue(pr.name, null, ref onStack.si, ref onStack.memberData);
                        onStack.objectInfo.RecordFixup(onStack.objectId, pr.name, pr.idRef);
                    }
                }
                else if (pr.memberValueEnum != MemberValueEnum.InlineValue)
                {
                    this.ParseError(pr, onStack);
                }
                else if (object.ReferenceEquals(pr.dtType, Converter.s_typeofString))
                {
                    this.ParseString(pr, onStack);
                    onStack.objectInfo.AddValue(pr.name, pr.value, ref onStack.si, ref onStack.memberData);
                }
                else if (pr.dtTypeCode != PrimitiveTypeEnum.Invalid)
                {
                    object obj3 = pr.varValue ?? Converter.FromString(pr.value, pr.dtTypeCode);
                    onStack.objectInfo.AddValue(pr.name, obj3, ref onStack.si, ref onStack.memberData);
                }
                else if (pr.arrayTypeEnum == ArrayTypeEnum.Base64)
                {
                    onStack.objectInfo.AddValue(pr.name, Convert.FromBase64String(pr.value), ref onStack.si, ref onStack.memberData);
                }
                else
                {
                    if (object.ReferenceEquals(pr.dtType, Converter.s_typeofObject))
                    {
                        throw new SerializationException(RemotingResources.SerializationTypeMissing.Format(pr.name));
                    }
                    this.ParseString(pr, onStack);
                    if (object.ReferenceEquals(pr.dtType, Converter.s_typeofSystemVoid))
                    {
                        onStack.objectInfo.AddValue(pr.name, pr.dtType, ref onStack.si, ref onStack.memberData);
                    }
                    else if (onStack.objectInfo.IsSi)
                    {
                        onStack.objectInfo.AddValue(pr.name, pr.value, ref onStack.si, ref onStack.memberData);
                    }
                }
            }
        }
コード例 #7
0
        public static bool SendProfilePictureForMember(Guid gameId, Guid memberId, string pictureLocation, MemberTypeEnum memberType)
        {
            Task<bool>.Factory.StartNew(
                             () =>
                             {
                                 try
                                 {
                                     string urlToSend = ScoreboardConfig.SCOREBOARD_UPLOAD_MEMBER_PICTURE_URL;
                                     //urlToSend = "http://localhost:49534/scoreboard/UploadMemberPictureFromGame?k=" + ScoreboardConfig.KEY_FOR_UPLOAD;
                                     FileInfo picture = new FileInfo(pictureLocation);

                                     urlToSend += "&gameId=" + gameId.ToString();
                                     urlToSend += "&memId=" + memberId.ToString();
                                     urlToSend += "&fileName=" + picture.Name;
                                     urlToSend += "&memberType=" + memberType.ToString();

                                     WebClient client = new WebClient();
                                     client.UploadFile(urlToSend, pictureLocation);
                                     client.Dispose();

                                 }
                                 catch (Exception e)
                                 {
                                     ErrorViewModel.Save(e, e.GetType(), null, null, null, Logger.Instance.getLoggedMessages());
                                 }
                                 return true;
                             });
            return true;
        }
コード例 #8
0
ファイル: AccessorItem.cs プロジェクト: Black-Beard-Sdk/Core
 /// <summary>
 /// Initializes a new instance of the <see cref="AccessorItem"/> class.
 /// </summary>
 /// <param name="memberTypeEnum">The member type enum.</param>
 protected AccessorItem(MemberTypeEnum memberTypeEnum)
 {
     // TODO: Complete member initialization
     this.TypeEnum = memberTypeEnum;
 }
コード例 #9
0
ファイル: User.cs プロジェクト: mukhtiarlander/git_demo_torit
        public static bool AddMemberPhotoForGame(Guid gameId, Stream fileStream, string nameOfFile, Guid gameMemberId, MemberTypeEnum memberType)
        {
            try
            {
                var dc = new ManagementContext();
                string name = String.Empty;
                Guid id = new Guid();
                GameMember member = null;
                GameOfficial official = null;
                if (memberType == MemberTypeEnum.Skater)
                {
                    member = dc.GameMembers.Where(x => x.GameMemberId == gameMemberId && x.Team.Game.GameId == gameId).FirstOrDefault();
                    if (member == null)
                        return false;
                    name = member.MemberName;
                    id = member.MemberLinkId;
                }
                else if (memberType == MemberTypeEnum.Referee)
                {
                    official = dc.GameOfficials.Where(x => x.GameOfficialId == gameMemberId && x.Game.GameId == gameId).FirstOrDefault();
                    if (official == null)
                        return false;
                    name = official.MemberName;
                    id = official.MemberLinkId;
                }

                //time stamp for the save location
                DateTime timeOfSave = DateTime.UtcNow;
                FileInfo info = new FileInfo(nameOfFile);
                //the file name when we save it
                string url = "http://images.rdnation.com/games/" + timeOfSave.Year + "/" + timeOfSave.Month + "/" + timeOfSave.Day + "/";
                string imageLocationToSave = @"C:\WebSites\images.rdnation.com\games\" + timeOfSave.Year + @"\" + timeOfSave.Month + @"\" + timeOfSave.Day + @"\";
                //creates the directory for the image
                if (!Directory.Exists(imageLocationToSave))
                    Directory.CreateDirectory(imageLocationToSave);

                string fileName = RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(name + " roller derby-") + timeOfSave.ToFileTimeUtc() + info.Extension;
                string fileNameThumb = RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(name + " roller derby-thumb-") + timeOfSave.ToFileTimeUtc() + info.Extension;

                string urlMain = url + fileName;
                string urlThumb = url + fileNameThumb;
                string imageLocationToSaveMain = imageLocationToSave + fileName;
                string imageLocationToSaveThumb = imageLocationToSave + fileNameThumb;

                bool isLinkedToMainMember = false;

                if (id != new Guid())
                {
                    var memMain = dc.Members.Where(x => x.MemberId == id).FirstOrDefault();
                    if (memMain != null)
                    {
                        fileName = RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(memMain.DerbyName + " roller derby-") + timeOfSave.ToFileTimeUtc() + info.Extension;

                        fileNameThumb = RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(memMain.DerbyName + " roller derby-thumb-") + timeOfSave.ToFileTimeUtc() + info.Extension;

                        urlMain = url + fileName;
                        urlThumb = url + fileNameThumb;
                        imageLocationToSaveMain = imageLocationToSave + fileName;
                        imageLocationToSaveThumb = imageLocationToSave + fileNameThumb;

                        isLinkedToMainMember = true;

                        RDN.Library.DataModels.Member.MemberPhoto image = new RDN.Library.DataModels.Member.MemberPhoto();
                        image.ImageUrl = urlMain;
                        image.SaveLocation = imageLocationToSaveMain;
                        image.SaveLocationThumb = imageLocationToSaveThumb;
                        image.ImageUrlThumb = urlThumb;
                        image.IsPrimaryPhoto = false;
                        image.IsVisibleToPublic = true;
                        image.Member = memMain;
                        memMain.Photos.Add(image);
                    }
                }
                //if it is, we won't actually save the picture in the game member table..
                if (isLinkedToMainMember == false && member != null)
                {
                    url += fileName;
                    imageLocationToSave += fileName;

                    GameMemberPhoto image = new GameMemberPhoto();
                    image.ImageUrl = urlMain;
                    image.SaveLocation = imageLocationToSaveMain;
                    image.SaveLocationThumb = imageLocationToSaveThumb;
                    image.ImageUrlThumb = urlThumb;

                    image.IsPrimaryPhoto = true;
                    image.IsVisibleToPublic = true;
                    image.Member = member;
                    member.Photos.Add(image);
                }

                if (isLinkedToMainMember == false && official != null)
                {
                    url += fileName;
                    imageLocationToSave += fileName;

                    GameOfficialPhoto image = new GameOfficialPhoto();
                    image.ImageUrl = urlMain;
                    image.SaveLocation = imageLocationToSaveMain;
                    image.SaveLocationThumb = imageLocationToSaveThumb;
                    image.ImageUrlThumb = urlThumb;
                    image.IsPrimaryPhoto = true;
                    image.IsVisibleToPublic = true;
                    image.Official = official;
                    official.Photos.Add(image);
                }

                using (var newfileStream = new FileStream(imageLocationToSaveMain, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    fileStream.CopyTo(newfileStream);
                }
                Image thumbImg = Image.FromStream(fileStream);
                Image thumb = RDN.Utilities.Drawing.Images.ScaleDownImage(thumbImg, 300, 300);
                thumb.Save(imageLocationToSaveThumb);
                //saves the photo to the DB.
                dc.SaveChanges();

                return true;
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return false;
        }