예제 #1
0
 public AccountLoginB(string nAccountName,
                      uint nAccountMgrId)
 {
     mAccountId    = GenerateId._runNameId(nAccountName);
     mAccountName  = nAccountName;
     mAccountMgrId = nAccountMgrId;
 }
예제 #2
0
        /*revisar!!*/
        public JsonResult PostMessage(Comment comment, string url, string id)
        {
            var userId   = User.Identity.GetUserId();
            var userName = us.Users.Where(x => x.Id == userId).Select(x => x.Nombre).SingleOrDefault();

            GenerateId generator = new GenerateId();

            comment.CommentId = generator.generateID();
            comment.Fk_Post   = id;
            comment.Fk_User   = userId;
            comment.Date      = DateTime.Now;
            if (comment.CommentMessage != null)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
            }
            var mail = us.Users.Where(x => x.Id == userId).Select(x => x.Email).SingleOrDefault();
            var foto = us.Users.Where(x => x.Id == userId).Select(x => x.Foto).SingleOrDefault();
            var obj  = new
            {
                date    = comment.Date,
                message = comment.CommentMessage,
                user    = userName,
                mail    = mail,
                foto    = foto,
                url     = url
            };

            return(Json(new { data = obj, postId = comment.CommentId }, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public void _addDeviceType(uint nDeviceType)
        {
            long         id_           = GenerateId._runId(@"account");
            DeviceStatus deviceStatus_ =
                new DeviceStatus(id_, nDeviceType);

            mDeviceStatus[nDeviceType] = deviceStatus_;
        }
예제 #4
0
        public Account _getAccount(string nAccountName)
        {
            uint       hashName_        = GenerateId._runTableId(nAccountName);
            uint       accountMgrIndex_ = hashName_ % mAccountMgrCount;
            AccountMgr accountMgr_      = mAccountMgrs[accountMgrIndex_];

            return(accountMgr_._getAccount(nAccountName));
        }
예제 #5
0
        public void _getAccountInfo(out uint nAccountMgrId,
                                    out uint nAccountId, string nAccountName)
        {
            uint hashName_ = GenerateId._runTableId(nAccountName);

            nAccountMgrId = hashName_ % mAccountMgrCount;
            nAccountId    = GenerateId._runNameId(nAccountName);
        }
예제 #6
0
        public AccountLoginC _loginAccount(string nAccountName,
                                           string nPassward, uint nDeviceType)
        {
            uint       hashName_        = GenerateId._runTableId(nAccountName);
            uint       accountMgrIndex_ = hashName_ % mAccountMgrCount;
            AccountMgr accountMgr_      = mAccountMgrs[accountMgrIndex_];

            return(accountMgr_._loginAccount(nAccountName,
                                             nPassward, nDeviceType));
        }
예제 #7
0
        public void RemoveStudentFromCourse_shouldThrow_ifPassedStudentIsNotFound()
        {
            var      id               = new GenerateId(0, 100).Generate();
            var      name             = "student name";
            IStudent testInputStudent = new Student(name, id);

            ICourse testCourse = new Course(courseName, courseMaximumCapacity);

            testCourse.RemoveStudentFromCourse(testInputStudent);
        }
예제 #8
0
        public int _createAccount(int nPlatform, string nAccountName,
                                  string nNickname, string nPassward, string nGetPassward)
        {
            uint       hashName_        = GenerateId._runTableId(nAccountName);
            uint       accountMgrIndex_ = hashName_ % mAccountMgrCount;
            AccountMgr accountMgr_      = mAccountMgrs[accountMgrIndex_];

            return(accountMgr_._createAccount(nPlatform, nAccountName,
                                              nNickname, nPassward, nGetPassward));
        }
예제 #9
0
        public Account _getAccount(string nAccountName)
        {
            Account result_    = null;
            uint    accountId_ = GenerateId._runNameId(nAccountName);

            if (mAccounts.ContainsKey(accountId_))
            {
                result_ = mAccounts[accountId_];
            }
            return(result_);
        }
예제 #10
0
 public StatusCreateB(Account nAccount, uint nTableId, uint nAccountMgrId, StatusCreateS nStatusCreateS)
 {
     mAccountMgrId = nAccountMgrId;
     mTableId      = nTableId;
     mAccountId    = nAccount._getId();
     mText         = nStatusCreateS.m_tText;
     mType         = (uint)nStatusCreateS.m_tStatusType;
     mAttachments  = nStatusCreateS.m_tAttachments;
     mTicks        = DateTime.Now.Ticks;
     mStatusId     = GenerateId._runId(mAccountId);
 }
예제 #11
0
        public void AddStudentToCourse_shouldThrow_ifPassedADuplicateStudent()
        {
            var      id               = new GenerateId(0, 100).Generate();
            var      name             = "student name";
            IStudent testInputStudent = new Student(name, id);

            ICourse testCourse = new Course(courseName, courseMaximumCapacity);

            testCourse.AddStudentToCourse(testInputStudent);
            testCourse.AddStudentToCourse(testInputStudent);
        }
예제 #12
0
        public void AddStudentToCourse_shouldReturnTrue_ifPassedAValidArgument()
        {
            var      id               = new GenerateId(0, 100).Generate();
            var      name             = "student name";
            IStudent testInputStudent = new Student(name, id);

            ICourse testCourse = new Course(courseName, courseMaximumCapacity);

            var actual = testCourse.AddStudentToCourse(testInputStudent);

            Assert.IsTrue(actual);
        }
예제 #13
0
 public AccountCreateB(int nPlatform, string nAccountName, string nNickname,
                       string nPassward, string nGetPassward, uint nAccountMgrId)
 {
     mAccountId    = GenerateId._runNameId(nAccountName);
     mPlatform     = nPlatform;
     mAccountName  = nAccountName;
     mAccountMgrId = nAccountMgrId;
     mNickName     = nNickname;
     mPassward     = nPassward;
     mGetPassward  = nGetPassward;
     mTicks        = DateTime.Now.Ticks;
 }
예제 #14
0
        public void AddStudentToCourse_shouldThrow_ifCourseHasMaximumAllowedStudentsEnrolled()
        {
            ICourse testCourse = new Course(courseName, courseMaximumCapacity);

            for (int i = 0; i < courseMaximumCapacity + 1; i++)
            {
                var      studentId        = new GenerateId(0, 100).Generate();
                var      studentName      = "student name";
                IStudent testInputStudent = new Student(studentName, studentId);

                testCourse.AddStudentToCourse(testInputStudent);
            }
        }
예제 #15
0
        public object createTag()
        {
            IGeneratorId igenId = new GenerateId();

            DB_repository.Tag tag = new DB_repository.Tag()
            {
                Id        = ObjectId.GenerateNewId().ToString(),
                Tag_id    = igenId.generateTagId(),
                Tag_label = igenId.generateLabel(),
                Tag_time  = DateTime.Now.ToUniversalTime()
            };
            return(tag);
        }
예제 #16
0
        public int _logoutAccount(int nPlatformId, string nAccountName,
                                  uint nStamp, uint nDeviceId, int nServerId)
        {
            int result_ = this._checkServerId(nServerId);

            if (AccountError_.mSucess_ == result_)
            {
                uint       hashName_        = GenerateId._runTableId(nAccountName);
                uint       accountMgrIndex_ = hashName_ % mAccountMgrCount;
                AccountMgr accountMgr_      = mAccountMgrs[accountMgrIndex_];
                result_ = accountMgr_._logoutAccount(nAccountName,
                                                     nStamp, nDeviceId);
            }
            return(result_);
        }
예제 #17
0
        public JsonResult Create([Bind(Include = "TypeId,TypeName")] WarehouseType warehouseClassification)
        {
            GenerateId generator = new GenerateId();

            warehouseClassification.TypeId = generator.generateID();
            db.WarehouseTypes.Add(warehouseClassification);
            db.SaveChanges();

            var tipo = new
            {
                TypeId   = warehouseClassification.TypeId,
                TypeName = warehouseClassification.TypeName
            };

            return(Json(new { data = tipo }, JsonRequestBehavior.AllowGet));
        }
예제 #18
0
        public JsonResult Create([Bind(Include = "ConditionID,ConditionName")] Condition condition)
        {
            GenerateId generator = new GenerateId();

            condition.ConditionID = generator.generateID();
            db.Conditions.Add(condition);
            db.SaveChanges();

            var condicion = new
            {
                ConditionID   = condition.ConditionID,
                ConditionName = condition.ConditionName
            };

            return(Json(new { data = condicion }, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
    // Called during instantiation
    public void Awake()
    {
        if (CompareTag("ActiveItem"))
        {
            if (_transistorEntity == null)
            {
                _transistorEntity = new TransistorPNPEntity();
            }
            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[10]++;
            _name += script.generatedIds[10].ToString();
        }
    }
예제 #20
0
        public JsonResult Create([Bind(Include = "DestinationId,DestinationName")] Destination destination)
        {
            GenerateId generator = new GenerateId();

            destination.DestinationId = generator.generateID();
            db.Destinations.Add(destination);
            db.SaveChanges();

            var destino = new
            {
                DestinationId   = destination.DestinationId,
                DestinationName = destination.DestinationName
            };

            return(Json(new { data = destino }, JsonRequestBehavior.AllowGet));
        }
예제 #21
0
        public JsonResult Create([Bind(Include = "CompanyID,CompanyName")] DeliveryCompany deliveryCompany)
        {
            GenerateId generator = new GenerateId();

            deliveryCompany.CompanyID = generator.generateID();
            db.DeliveryCompanies.Add(deliveryCompany);
            db.SaveChanges();

            var delivery = new
            {
                Id          = deliveryCompany.CompanyID,
                CompanyName = deliveryCompany.CompanyName
            };

            return(Json(new { data = delivery }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Create([Bind(Include = "AccountClasificationID,ClasificationName")] AccountClasification classification)
        {
            GenerateId generator = new GenerateId();

            classification.AccountClasificationID = generator.generateID();
            db.AccountClasifications.Add(classification);
            db.SaveChanges();

            var clasificacion = new
            {
                Id             = classification.AccountClasificationID,
                Classification = classification.ClasificationName
            };

            return(Json(new { data = clasificacion }, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
    // Called during instantiation
    public void Awake()
    {
        if (CompareTag("ActiveNode"))
        {
            if (_nodeEntity == null)
            {
                _nodeEntity = new NodeEntity();
            }

            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[5]++;
            _name += script.generatedIds[5].ToString();
        }
    }
예제 #24
0
        /// <summary>
        /// 存储文件,如果是图片文件则生成缩略图
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="fileBuffers"></param>
        /// <exception cref="Exception"></exception>
        private void SaveFile(string fileName, byte[] fileBuffers)
        {
            string folder = DateTime.Now.ToString("yyyyMMdd");

            //判断文件是否为空
            if (string.IsNullOrEmpty(fileName))
            {
                throw new Exception("文件名不能为空");
            }

            //判断文件是否为空
            if (fileBuffers.Length < 1)
            {
                throw new Exception("文件不能为空");
            }

            var uploadPath = Path.Combine(_filePath, folder);

            _logger.LogInformation("文件写入:" + uploadPath);
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }

            var    ext     = Path.GetExtension(fileName).ToLower();
            string newName = GenerateId.GenerateOrderNumber() + ext;

            using (var fs = new FileStream(Path.Combine(uploadPath, newName), FileMode.Create))
            {
                fs.Write(fileBuffers, 0, fileBuffers.Length);
                fs.Close();

                //生成缩略图
                if (ext.Contains(".jpg") || ext.Contains(".jpeg") || ext.Contains(".png") || ext.Contains(".bmp") ||
                    ext.Contains(".gif"))
                {
                    string thumbnailName = GenerateId.GenerateOrderNumber() + ext;
                    ImgHelper.MakeThumbnail(Path.Combine(uploadPath, newName), Path.Combine(uploadPath, thumbnailName));
                    _dbThumbnail = Path.Combine(folder, thumbnailName);
                }


                _dbFilePath = Path.Combine(folder, newName);
            }
        }
예제 #25
0
    // Called during instantiation
    public void Awake()
    {
        if (CompareTag("ActiveItem"))
        {
            if (_zenerEntity == null)
            {
                _zenerEntity = new ZenerDiodeEntity();
            }
            diodeComponent = new ZenerElm();

            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[9]++;
            _name += script.generatedIds[9].ToString();
        }
    }
예제 #26
0
        public void CreateUserPost(String PostId, String UserId)
        {
            // First is needed to check if the relation alredy exist
            var Relation = db.PostUsers.Where(x => x.Fk_Post == PostId && x.Fk_User == UserId).Select(x => x.PostUserID);

            if (Relation.Count() == 0 && PostId != null && UserId != null)
            {
                GenerateId generator = new GenerateId();

                PostUser postRelation = new PostUser();

                postRelation.PostUserID = generator.generateID();
                postRelation.Fk_Post    = PostId;
                postRelation.Fk_User    = UserId;
                db.PostUsers.Add(postRelation);
                db.SaveChanges();
            }
        }
예제 #27
0
 // Called during instantiation
 public override void Awake()
 {
     if (CompareTag("ActiveItem"))
     {
         id = idCounter++;
         if (_analogSwitchEntity == null)
         {
             _analogSwitchEntity = new AnalogSwitchEntity {TurnedOff = DefaultState};
         }
         _analogSwitchComponent = new SwitchSPST();
         SetAndInitializeConnectors();
         
         GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
         GenerateId script = componentIdManager.GetComponent<GenerateId>();
         script.generatedIds[7]++;
         _name += script.generatedIds[7].ToString();
     }
 }
예제 #28
0
    // Called during instantiation
    public override void Awake()
    {
        if (CompareTag("ActiveItem"))
        {
            id = idCounter++;
            if (_lampEntity == null)
            {
                _lampEntity = new LampEntity();
            }

            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[2]++;
            _name += script.generatedIds[2].ToString();
        }
    }
예제 #29
0
    // Called during instantiation
    public override void Awake()
    {
        if (CompareTag("ActiveItem"))
        {
            id = idCounter++;
            if (_inductorEntity == null)
            {
                _inductorEntity = new InductorEntity {
                    IsTrapezoidal = DefaultIsTrapezoidal, Inductance = DefaultInductance
                };
            }
            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[4]++;
            _name += script.generatedIds[4].ToString();
        }
    }
예제 #30
0
    // Called during instantiation
    public override void Awake()
    {
        if (CompareTag("ActiveItem"))
        {
            id = idCounter++;
            if (_ampermeterEntity == null)
            {
                _ampermeterEntity = new AmpermeterEntity();
            }
            //just for handling null references before we start the simulation
            ResistorComponent = new Resistor();

            SetAndInitializeConnectors();

            GameObject componentIdManager = GameObject.Find("_ComponentIdManager");
            GenerateId script             = componentIdManager.GetComponent <GenerateId>();
            script.generatedIds[1]++;
            _name += script.generatedIds[1].ToString();
        }
    }