Example #1
0
 public Provider()
 {
     if (context == null)
     {
         context = new DataAccessDataContext();
     }
 }
        public static IList<ss_Requests_DashboardResult> GetRequestDashboardForStaffUser(StaffRequestDashboardQuery query, DataAccessDataContext context)
        {
            DateTime? requestDate = null;

            if (query.RequestDate == DateTime.MinValue)
            {
                requestDate = null;
            }
            else
            {
                requestDate = query.RequestDate;
            }

            string labelsForQuery = string.Empty;

            IList<ss_Requests_DashboardResult> results = context.ss_Requests_Dashboard(query.RequestNumber,
                                                                                        requestDate,
                                                                                        query.RequestedBy,
                                                                                        query.LanugagesAsStringList,
                                                                                        query.StatusAsStringList,
                                                                                        query.RequestASAP,
                                                                                        query.GetLabelsForQuery(),
                                                                                        query.LabelsShowOnlyUnlabeled,
                                                                                        query.OrderBy_ForQuery,
                                                                                        query.PageSize,
                                                                                        query.PageNumber).ToList();

            return results;
        }
Example #3
0
        /// <summary>
        /// Attemps to place the spot, it's associated Production Order and Job back into their previous state based off of each of their completed dates
        /// </summary>
        /// <param name="spot"></param>
        /// <param name="context"></param>
        public static void CancelSpotReRecordRequest(IASpot spot, DataAccessDataContext context)
        {
            spot = SetSpotToPreviousStatus(spot, context);

            bool allSpotsFinishedWithinPO = ProductionOrdersService.AreAllSpotsFinished(spot.IAProductionOrder, context);
            bool allProductionOrdersComplete = JobsService.AreAllProducitonOrdersComplete(spot.IAProductionOrder.IAJob, context);
            bool jobWasPreviouslyCompleted = spot.IAProductionOrder.IAJob.WasJobPreviouslyCompleted();
            JobStatus jobStatus = JobStatus.Incomplete;
            ProductionOrderStatus productionOrderStatus = ProductionOrderStatus.Incomplete;

            if (allSpotsFinishedWithinPO && allProductionOrdersComplete)
            {
                //Production orders and spots are completed, if the job was previously completed, then fast forward it back to that
                jobStatus = jobWasPreviouslyCompleted ? JobStatus.Complete : JobStatus.CompleteNeedsProduction;
                productionOrderStatus = ProductionOrderStatus.Complete;
            }
            else if (allSpotsFinishedWithinPO && !allProductionOrdersComplete)
            {
                //At least one PO isn't complete within the parent job, but all the spots within this PO are completed
                jobStatus = JobStatus.Incomplete;
                productionOrderStatus = ProductionOrderStatus.Complete;
            }
            else if (!allSpotsFinishedWithinPO && !allProductionOrdersComplete)
            {
                //This PO and maybe others are still not completed
                jobStatus = JobStatus.Incomplete;
                productionOrderStatus = ProductionOrderStatus.Incomplete;
            }

            spot.IAProductionOrder.IAJob.IAJobStatusID = JobsService.GetStatusOption(jobStatus, context).ID;
            spot.IAProductionOrder.IAProductionOrderStatusID = ProductionOrdersService.GetStatusOption(productionOrderStatus, context).ID;
            context.SubmitChanges();
        }
        public static List<SpotFileType> GetSpotFileTypes(DataAccessDataContext context)
        {
            List<SpotFileType> fees;

            if (HttpContext.Current.Cache[CacheItemKey] == null)
            {
                fees = (from n in context.IASpotFileTypes
                        orderby n.IASpotFileTypeID
                        select new SpotFileType
                        {
                            SpotFileTypeId = n.IASpotFileTypeID,
                            Name = n.Name
                        }).ToList();

                if (fees != null)
                {
                    HttpContext.Current.Cache.Add(CacheItemKey, fees, null, DateTime.Now.AddSeconds(14400), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
                }
            }
            else
            {
                fees = (List<SpotFileType>)HttpContext.Current.Cache[CacheItemKey];
            }

            return fees;
        }
Example #5
0
        static void GetSubCities()
        {
            DataAccessDataContext dadc = new DataAccessDataContext();
            StringBuilder         sb   = new StringBuilder();

            foreach (CLCity city in dadc.CLCities)
            {
                WebClient    wc  = new WebClient();
                string       ret = wc.DownloadString("http://" + city.Name + ".craigslist.org/search/sss");
                HtmlDocument hd  = new HtmlDocument();
                hd.LoadHtml(ret);
                HtmlNodeCollection nodes = hd.DocumentNode.SelectNodes("//select[@id='subArea']/option[@value and string-length(@value)]");

                if (nodes == null)
                {
                    continue;
                }

                foreach (HtmlNode hn in nodes)
                {
                    sb.AppendLine(hn.Attributes["value"].Value + ", " + city.Name);
                }
                File.WriteAllText("SubCities.txt", sb.ToString());
            }
        }
 public static IAMusic GetMusicSample(int id, DataAccessDataContext context)
 {
     IAMusic musicSample = (from n in context.IAMusics
                            where n.IAMusicID == id
                            select n).SingleOrDefault();
     return musicSample;
 }
        public static List<TalentType> GetTalentTypes(DataAccessDataContext context)
        {
            List<TalentType> talentTypes;

            if (HttpContext.Current.Cache[CacheItemKey] == null)
            {
                talentTypes = (from n in context.IATalentTypes
                        orderby n.Sort
                        select new TalentType
                        {
                            TalentTypeId = n.IATalentTypeID,
                            Name = n.Name,
                            SortOrder = n.Sort
                        }).ToList();

                if (talentTypes != null)
                {
                    HttpContext.Current.Cache.Add(CacheItemKey, talentTypes, null, DateTime.Now.AddSeconds(14400), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
                }
            }
            else
            {
                talentTypes = (List<TalentType>)HttpContext.Current.Cache[CacheItemKey];
            }

            return talentTypes;
        }
Example #8
0
 private static List<StatusOption> GetJobStatusesFromDB(DataAccessDataContext context)
 {
     List<StatusOption> jobStatuses = (from n in context.IAJobStatus
                                        select new StatusOption
                                        {
                                            ID = n.IAJobStatusID,
                                            Name = n.Name
                                        }).ToList();
     return jobStatuses;
 }
Example #9
0
        protected void Application_Start(object sender, EventArgs e)
        {
            var oDataAccess = new DataAccessDataContext(ConfigurationManager.ConnectionStrings["MemberProtectConnectionString"].ConnectionString);

             // Maintenance Tasks
             // 1. Remove all companies/orgs for which they have no users
             oDataAccess.sp_System_PurgeCompanies();

             XmlConfigurator.Configure();
        }
Example #10
0
 private static List<StatusOption> GetProductionOrderStatusesFromDB(DataAccessDataContext context)
 {
     List<StatusOption> productionOrderStatuses = (from n in context.IAProductionOrderStatus
                                        select new StatusOption
                                        {
                                            ID = n.IAProductionOrderStatusID,
                                            Name = n.Name
                                        }).ToList();
     return productionOrderStatuses;
 }
Example #11
0
 private static List<StatusOption> GetRequestStatusesFromDB(DataAccessDataContext context)
 {
     List<StatusOption> requestStatuses = (from n in context.IARequestStatus
                                           orderby n.SortOrder
                                                   select new StatusOption
                                                   {
                                                       ID = n.IARequestStatusID,
                                                       Name = n.Name
                                                   }).ToList();
     return requestStatuses;
 }
        /// <summary>
        /// Pull the user's dashboard perferences from the DB
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private static StaffRequestDashboardQuery GetRequestDashboardQueryFromDB(Guid userID, DataAccessDataContext context)
        {
            StaffRequestDashboardQuery query = new StaffRequestDashboardQuery();
            IAUserSettingsGrid oIAUserSettingsGrid = context.IAUserSettingsGrids.SingleOrDefault(row => row.MPUserID == userID && row.Name == "Staff Requests");
            if (oIAUserSettingsGrid != null)
            {
                query = ParseRequestsDashboardQuery(oIAUserSettingsGrid.Filters, oIAUserSettingsGrid.SortExpression);
            }

            return query;
        }
Example #13
0
        public static int GetNextJobSequenceNumberForRequest(int requestID, DataAccessDataContext context)
        {
            int sequence = 1;
            IAJob job = context.IAJobs.Where(row => row.IARequestID == requestID).OrderByDescending(row => row.Sequence).Take(1).SingleOrDefault();
            if (job != null)
            {
                sequence = job.Sequence + 1;
            }

            return sequence;
        }
        public static DataAccessDataContext CurrentDB()
        {
            const string itemKey = "CurrentDB";
            if (HttpContext.Current.Items[itemKey] == null)
            {
                DataAccessDataContext currentDB = new DataAccessDataContext(Settings.ConnectionString);
                HttpContext.Current.Items[itemKey] = currentDB;
                return currentDB;
            }

            return (DataAccessDataContext)HttpContext.Current.Items[itemKey];
        }
        public static bool AreAllSpotsFinished(IAProductionOrder po, DataAccessDataContext context)
        {
            StatusOption completeStatus = SpotService.GetStatusOption(SpotStatus.Finished, context);
            int totalSpots = po.IASpots.Count();
            int spotsFinished = po.IASpots.Where(row => row.IASpotStatusID == completeStatus.ID).Count();

            if (totalSpots == spotsFinished)
            {
                return true;
            }

            return false;
        }
Example #16
0
        /// <summary>
        /// Retrieve City Details
        /// </summary>
        /// <returns></returns>
        public IList<CityPoint> RetrieveCityDetails()
        {
            IList<CityPoint> cityList = new List<CityPoint>();
            DataAccessDataContext ctx = new DataAccessDataContext();
            var cities = ctx.Cities.Where(@w => @w.Active).ToList();

            foreach (var city in cities)
            {
                cityList.Add(new CityPoint { Name = city.Name, Code = city.Number, Server = city.Server });
            }

            return cityList;
        }
Example #17
0
        public static bool AreAllProducitonOrdersComplete(IAJob job, DataAccessDataContext context)
        {
            StatusOption completeStatus = ProductionOrdersService.GetStatusOption(ProductionOrderStatus.Complete, context);

            int completedProductionOrders = job.IAProductionOrders.Where(row => row.IAProductionOrderStatusID == completeStatus.ID).Count();
            int totalProductionOrders = job.IAProductionOrders.Count();

            if (totalProductionOrders == completedProductionOrders)
            {
                return true;
            }

            return false;
        }
Example #18
0
        static void GetDomainAddresses()
        {
            DataAccessDataContext dadc = new DataAccessDataContext();
            StringBuilder         sb   = new StringBuilder();

            foreach (CLCity city in dadc.CLCities)
            {
                IPHostEntry ipe = Dns.GetHostEntry(city.Name + ".craigslist.org");
                sb.AppendLine(city.Name.PadRight(15) + string.Join <IPAddress>(", ", ipe.AddressList));
                city.IP = ipe.AddressList.FirstOrDefault().ToString();
            }
            dadc.SubmitChanges();
            File.WriteAllText("CityAddresses.txt", sb.ToString());
        }
Example #19
0
        public int AuthenticateUser(string key)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            bool isExists = ctx.Auths.Where(@w => @w.Key == key).Count() == 1;

            if (isExists)
            {
                return 201;
            }
            else
            {
                return 101;
            }
        }
Example #20
0
        public static void MarkSpotForReRecord(IASpot spot, DataAccessDataContext context)
        {
            spot.IAProductionOrder.IAJob.IAJobStatusID = JobsService.GetStatusOption(JobStatus.Incomplete, context).ID;
            spot.IAProductionOrder.IAProductionOrderStatusID = ProductionOrdersService.GetStatusOption(ProductionOrderStatus.Incomplete, context).ID;
            spot.IASpotStatusID = GetStatusOption(SpotStatus.NeedsFix, context).ID;

            // For each file in the spot that is a talent file, mark them as not deletable
            SpotFileType spotFileType = SpotFileTypeService.GetSpotTypeByName("Talent", context);
            foreach (IASpotFile oIASpotFile in spot.IASpotFiles.Where(row => row.IASpotFileTypeID == spotFileType.SpotFileTypeId))
            {
                oIASpotFile.IsDeletable = false;
            }

            context.SubmitChanges();
        }
Example #21
0
        public static IList<Talent> GetAllTalents(DataAccessDataContext context)
        {
            IList<Talent> talents;

            if (HttpContext.Current.Cache[CacheItemKeyTalentList] == null)
            {
                talents = GetTalentsFromDB(context);
                HttpContext.Current.Cache.Add(CacheItemKeyTalentList, talents, null, DateTime.Now.AddSeconds(3600), TimeSpan.Zero, CacheItemPriority.Normal, null);
            }
            else
            {
                talents = (IList<Talent>)HttpContext.Current.Cache[CacheItemKeyTalentList];
            }

            return talents;
        }
Example #22
0
        public static List<RequestNote> GetNotesForRequest(int requestID, DataAccessDataContext context)
        {
            var query = from n in context.IARequestNotes
                        where n.IARequestID == requestID
                        join u in context.MPUserDatas on n.MPUserID equals u.MPUserID
                        orderby n.CreatedDateTime
                        select new RequestNote
                        {
                            FirstName = u.FirstName,
                            LastName = u.LastName,
                            Note = n.Note,
                            CreatedDateTime = n.CreatedDateTime
                        };

            return query.ToList();
        }
Example #23
0
        public int SignupUser(string name, string mobile, string cityCode)
        {
            DataAccessDataContext ctx = new DataAccessDataContext();
            bool isExists = ctx.Users.Where(@w => @w.Name == name && @w.Mobile == mobile).Count() == 1;

            if (isExists)
            {
                return 102;
            }
            else
            {
                Random rm = new Random();
                int vc = rm.Next(1000, 9999);
                SendSMS(mobile, vc);
                return vc;
            }
        }
        /// <summary>
        /// Will pull the specified user's dashboard query from cache (if availale) or the DB and then cache it
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public static StaffRequestDashboardQuery GetStaffRequestDashboardSettings(Guid userID, DataAccessDataContext context)
        {
            StaffRequestDashboardQuery query = new StaffRequestDashboardQuery();
            string cacheKey = string.Format("{0}-{1}", CacheKey, userID);

            if (HttpContext.Current.Cache[cacheKey] == null)
            {
                query = GetRequestDashboardQueryFromDB(userID, context);
                CacheDashboardQuery(userID, query);
            }
            else
            {
                query = (StaffRequestDashboardQuery)HttpContext.Current.Cache[cacheKey];
            }

            return query;
        }
        public CreditCardService(Guid customerMemberProtectUserId, MemberProtect memberProtect, DataAccessDataContext dataContext, SitePropertiesService siteProperties)
        {
            _memberProtect = memberProtect;
             _dataContext = dataContext;
             _siteProperties = siteProperties;

             _enableDebug = siteProperties.AuthorizeNetIsDebug;
             _loginId = _memberProtect.Cryptography.Decrypt(_siteProperties.AuthorizeNetLoginID);
             _transactionKey = _memberProtect.Cryptography.Decrypt(_siteProperties.AuthorizeNetTransactionKey);
             _customerMemberProtectUserId = customerMemberProtectUserId;

             // audit
             if (memberProtect.CurrentUser.UserID != customerMemberProtectUserId)
             {
            // log that user is access customer credit card data?
             }
        }
Example #26
0
        public static IEnumerable<fn_Producer_GetLabelFilterResult> GetLabelsForFilterDropDown(DataAccessDataContext context)
        {
            IEnumerable<fn_Producer_GetLabelFilterResult> labels;
            string sCacheItemKey = "LabelsForFilterDropDown";

            if (HttpContext.Current.Cache[sCacheItemKey] == null)
            {
                labels = context.fn_Producer_GetLabelFilter().OrderBy(row => row.SortID).ThenBy(row => row.Text);
                HttpContext.Current.Cache.Add(sCacheItemKey, labels, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.Normal, null);
            }
            else
            {
                labels = (IEnumerable<fn_Producer_GetLabelFilterResult>)HttpContext.Current.Cache[sCacheItemKey];
            }

            return labels;
        }
Example #27
0
        public static IList<Talent> GetTalentsInTalentType(int talentTypeId, DataAccessDataContext context)
        {
            Dictionary<int, IList<Talent>> talentsInTypes = GetTalentListsFromCache();
            IList<Talent> talentInType;

            if (talentsInTypes.ContainsKey(talentTypeId))
            {
                talentInType = talentsInTypes[talentTypeId];
            }
            else
            {
                talentInType = FindTalentsInTypeFromFullList(talentTypeId, context);
                talentsInTypes.Add(talentTypeId, talentInType);

                UpdateTalentListsInCache(talentsInTypes);
            }

            return talentInType;
        }
Example #28
0
        public static Dictionary<StatusType, List<StatusOption>> GetStatuses(DataAccessDataContext context)
        {
            Dictionary<StatusType, List<StatusOption>> statues = new Dictionary<StatusType, List<Models.StatusOption>>();

            if (HttpContext.Current.Cache[CacheItemKey] == null)
            {
                statues.Add(StatusType.JobStatus, GetJobStatusesFromDB(context));
                statues.Add(StatusType.ProductionOrderStatus, GetProductionOrderStatusesFromDB(context));
                statues.Add(StatusType.RequestStatus, GetRequestStatusesFromDB(context));
                statues.Add(StatusType.SpotStatus, GetSpotStatusesFromDB(context));
                HttpContext.Current.Cache.Add(CacheItemKey, statues, null, DateTime.Now.AddSeconds(14400), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
            }
            else
            {
                statues = (Dictionary<StatusType, List<StatusOption>>)HttpContext.Current.Cache[CacheItemKey];
            }

            return statues;
        }
        public static IList<IATalentSchedule> GetTalentSchedules(DataAccessDataContext context)
        {
            IList<IATalentSchedule> talentSchedules;

            if (HttpContext.Current.Cache[CacheItemKey] == null)
            {
                talentSchedules = context.IATalentSchedules.ToList();

                if (talentSchedules != null)
                {
                    HttpContext.Current.Cache.Add(CacheItemKey, talentSchedules, null, DateTime.Now.AddSeconds(3600), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Normal, null);
                }
            }
            else
            {
                talentSchedules = (IList<IATalentSchedule>)HttpContext.Current.Cache[CacheItemKey];
            }

            return talentSchedules;
        }
Example #30
0
        private static IList<Talent> FindTalentsInTypeFromFullList(int talentTypeId, DataAccessDataContext context)
        {
            IList<Talent> talents = GetAllTalents(context);
            IList<Talent> talentInType = new List<Talent>();

            foreach (Talent talent in talents)
            {
                if (talent.TalentTypes != null)
                {
                    foreach (TalentType talentType in talent.TalentTypes)
                    {
                        if (talentType.TalentTypeId == talentTypeId)
                        {
                            talentInType.Add(talent);
                            break;
                        }
                    }
                }
            }

            return talentInType;
        }
        public DataAdapter()
        {
           _ExchangeConnectionString= GetConnectionString();

           _ExchangeContext = new DataAccessDataContext(_ExchangeConnectionString);
        }
Example #32
0
 public static StatusOption GetStatusOption(JobStatus status, DataAccessDataContext context)
 {
     return StatusService.GetStatuses(context)[StatusType.JobStatus].Where(s => s.SystemName == status.ToString()).SingleOrDefault();
 }
Example #33
0
        private void InsertCordinateMetadata(Guid wardId, IList <CordinatePoint> cordinates, DataAccessDataContext context)
        {
            IList <Cordinate> cordinateList = new List <Cordinate>();

            foreach (var cordinate in cordinates)
            {
                Cordinate cordinatePoint = new Cordinate
                {
                    Id        = Guid.NewGuid(),
                    Latitude  = cordinate.Latitude,
                    Longitude = cordinate.Longitude,
                    WardId    = wardId,
                    Rank      = cordinate.Rank
                };

                cordinateList.Add(cordinatePoint);
            }

            context.Cordinates.InsertAllOnSubmit(cordinateList.AsEnumerable());
            SubmitData();
        }
Example #34
0
        private Guid InsertWardMetadata(Guid zoneId, int wardNumber, string wardName, CordinatePoint top, CordinatePoint left, CordinatePoint bottom, CordinatePoint right, DataAccessDataContext context)
        {
            Guid wardId = Guid.NewGuid();

            Ward ward = new Ward
            {
                Id              = wardId,
                Number          = wardNumber,
                Name            = wardName,
                ZoneId          = zoneId,
                TopCordinate    = top.Latitude + "," + top.Longitude,
                LeftCordinate   = left.Latitude + "," + left.Longitude,
                BottomCordinate = bottom.Latitude + "," + bottom.Longitude,
                RightCordinate  = right.Latitude + "," + right.Longitude
            };

            context.Wards.InsertOnSubmit(ward);
            SubmitData();

            return(wardId);
        }
 public RequestStatusLookup(DataAccessDataContext dataContext)
 {
     _dataContext = dataContext;
 }
Example #36
0
        private byte[] ValidatePacket(long auth_key_id, byte[] msg_key, byte[] data)
        {
            int SessionTimeOutInSeccond    = 8640000;//100 days
            int packetTimeOutInMiliSeccond = 100 * 1000;

            var db = new DataAccessDataContext(connectionString);

            if (!db.MBProto_user_sessionTbls.Any(c => c.authKeyID == auth_key_id))
            {
                throw new Exceptions.AuthException(new Exceptions.AuthException.AuthKeyInvalid());
            }

            var se = db.MBProto_user_sessionTbls.Single(c => c.authKeyID == auth_key_id);

            if (se.UserTbl.status != (byte)DeleteStatus.Active)
            {
                throw new Exceptions.AuthException(new Exceptions.AuthException.UserNotRegistered());
            }


            var dt     = se.regDate;
            var nextDT = dt.AddSeconds(SessionTimeOutInSeccond);

            if (dt > nextDT)
            {
                db.MBProto_user_sessionTbls.DeleteOnSubmit(se);
                db.SubmitChanges();
                throw new Exceptions.AuthException(new Exceptions.AuthException.SessionExpired());
            }

            byte[] DiffKey = Convert.FromBase64String(se.diffKey);

            byte[] preRuntimeAESKey = new byte[DiffKey.Length + msg_key.Length];

            Buffer.BlockCopy(DiffKey, 0, preRuntimeAESKey, 0, DiffKey.Length);
            Buffer.BlockCopy(msg_key, 0, preRuntimeAESKey, DiffKey.Length, msg_key.Length);

            byte[] runtimeAESKey = SHA256.Create().ComputeHash(preRuntimeAESKey);

            byte[] plainData = new AES(runtimeAESKey).Decrypt(data);

            MemoryStream ms = new MemoryStream(plainData);

            using (BinaryReader messageReader = new BinaryReader(ms))
            {
                long salt      = messageReader.ReadInt64();
                long sessionID = messageReader.ReadInt64();
                long time      = messageReader.ReadInt64();
                int  length    = messageReader.ReadInt32();
                long sequence  = messageReader.ReadInt64();

                if (se.sessionID != sessionID)
                {
                    throw new Exceptions.AuthException(new Exceptions.AuthException.PacketInvalid());
                }

                byte[] saltArray      = BitConverter.GetBytes(salt);
                byte[] sessionIDArray = BitConverter.GetBytes(sessionID);
                byte[] timeArray      = BitConverter.GetBytes(time);
                byte[] lengthArray    = BitConverter.GetBytes(length);
                byte[] sequenceArray  = BitConverter.GetBytes(sequence);

                byte[] clearMsgKey = new byte
                                     [saltArray.Length
                                      + sessionIDArray.Length
                                      + timeArray.Length
                                      + lengthArray.Length
                                      + sequenceArray.Length];

                Buffer.BlockCopy(saltArray, 0, clearMsgKey, 0, saltArray.Length);
                Buffer.BlockCopy(sessionIDArray, 0, clearMsgKey, saltArray.Length, sessionIDArray.Length);
                Buffer.BlockCopy(timeArray, 0, clearMsgKey, saltArray.Length + sessionIDArray.Length, timeArray.Length);
                Buffer.BlockCopy(lengthArray, 0, clearMsgKey, saltArray.Length + sessionIDArray.Length + timeArray.Length, lengthArray.Length);
                Buffer.BlockCopy(sequenceArray, 0, clearMsgKey, saltArray.Length + sessionIDArray.Length + lengthArray.Length + timeArray.Length, sequenceArray.Length);

                byte[] generatedMsgKey = SHA256.Create().ComputeHash(clearMsgKey).Take(16).ToArray();

                long now     = (long)Convert.ToInt64((DateTime.UtcNow - new DateTime(1970, 1, 1)).Milliseconds);
                long expDate = time + (long)packetTimeOutInMiliSeccond;

                if (now > expDate)
                {
                    throw new Exceptions.AuthException(new Exceptions.AuthException.PacketInvalid());
                }

                byte[] plainBytes = messageReader.ReadBytes((int)messageReader.BaseStream.Length - (int)messageReader.BaseStream.Position);

                MemoryStream mst = new MemoryStream(plainBytes);
                using (BinaryReader messageReadert = new BinaryReader(mst))
                {
                    uint code = messageReadert.ReadUInt32();
                    plainBytes = messageReadert.ReadBytes((int)messageReadert.BaseStream.Length - (int)messageReadert.BaseStream.Position);
                    byte[] codeArray = BitConverter.GetBytes(code);
                    byte[] result    = new byte[plainBytes.Length + sessionIDArray.Length + codeArray.Length];
                    Buffer.BlockCopy(codeArray, 0, result, 0, codeArray.Length);
                    Buffer.BlockCopy(sessionIDArray, 0, result, codeArray.Length, sessionIDArray.Length);
                    Buffer.BlockCopy(plainBytes, 0, result, codeArray.Length + sessionIDArray.Length, plainBytes.Length);
                    return(result);
                }
            }
        }