示例#1
0
        /// <summary>
        /// Gets the session provider.
        /// </summary>
        /// <returns></returns>
        private GenericRemoteSyncProvider <EntityObjectHierarchy> GetSessionProvider()
        {
            //if (SessionPrincipal == null || SessionPrincipal.UserID == -1)
            //{
            //    throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
            //                                          new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.NotAuthRequest, "not auth request"),
            //                                          false);
            //}

            Authenticate(null);

            if (SessionProviderType == eSyncProviderType.Undef)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.ProviderNotSpecified, "provider not specified"),
                                                      false);
            }

            GenericRemoteSyncProvider <EntityObjectHierarchy> retVal = null;

            retVal = EntitySyncProviderManager.GetProvider(SessionPrincipal.UserID, SessionProviderType);

            if (retVal == null)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, "provider not found"),
                                                      false);
            }

            return(retVal);
        }
示例#2
0
        public byte[] ProcessFullEnumerationChangeBatch(int resolutionPolicy, byte[] sourceChanges,
                                                        byte[] rawChangeDataRetriever, byte[] changeApplierInfo)
        {
            GenericRemoteSyncProvider <EntityObjectHierarchy> provider = GetSessionProvider();

            byte[] retVal = null;
            try
            {
                FullEnumerationChangeBatch sourceChangeBatch =
                    FullEnumerationChangeBatch.Deserialize(provider.IdFormats, sourceChanges);
                CachedChangeDataRetriever chachedDataRetriever =
                    SerializerHelper.BinaryDeserialize <CachedChangeDataRetriever>(rawChangeDataRetriever);
                retVal = provider.ProcessRemoteFullEnumerationChangeBatch((ConflictResolutionPolicy)resolutionPolicy, sourceChangeBatch,
                                                                          chachedDataRetriever, changeApplierInfo);
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }

            return(retVal);
        }
示例#3
0
        /// <summary>
        /// Authenticates the specified credentials.
        /// </summary>
        /// <param name="credentials">The credentials.</param>
        private void Authenticate(NetworkCredential credentials)
        {
            try
            {
                string    sUserLight  = "userlight";
                UserLight currentUser = SessionPrincipal;
                if (currentUser == null)
                {
                    // check user's name and password here
                    currentUser = Security.GetUser(credentials.UserName, credentials.Password);

                    //store user to web service session
                    SessionPrincipal = currentUser;
                }

                if (HttpContext.Current.Items.Contains(sUserLight))
                {
                    HttpContext.Current.Items.Remove(sUserLight);
                }

                HttpContext.Current.Items.Add(sUserLight, currentUser);
                HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(currentUser.Login), null);

                DataContext.Current.CurrentUserId       = Security.CurrentUser.UserID;
                DataContext.Current.CurrentUserTimeZone = Security.CurrentUser.CurrentTimeZone;
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.AuthFailed, e),
                                                      false);
            }
        }
示例#4
0
        public byte[] GetChangeBatch(uint batchSize, byte[] rawDestinationKnowledge,
                                     out byte[] changeDataRetriever)
        {
            GenericRemoteSyncProvider <EntityObjectHierarchy> provider = GetSessionProvider();

            byte[] retVal = null;
            try
            {
                SyncKnowledge             destinationKnowledge = SyncKnowledge.Deserialize(provider.IdFormats, rawDestinationKnowledge);
                object                    dataRetriever;
                ChangeBatch               changeBatch = provider.GetChangeBatch(batchSize, destinationKnowledge, out dataRetriever);
                CachedChangeDataRetriever cachedChangeDataRetriever =
                    new CachedChangeDataRetriever(dataRetriever as IChangeDataRetriever, changeBatch);
                string debugCachedRetr = SerializerHelper.XmlSerialize(cachedChangeDataRetriever);
                changeDataRetriever = SerializerHelper.BinarySerialize(cachedChangeDataRetriever);
                retVal = changeBatch.Serialize();
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }
            return(retVal);
        }
示例#5
0
        public void BeginSession()
        {
            GenericRemoteSyncProvider <EntityObjectHierarchy> provider = GetSessionProvider();

            try
            {
                provider.BeginSession(SyncProviderPosition.Unknown, null);
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }
        }
示例#6
0
        public void GetSyncBatchParameters(out uint batchSize, out byte[] rawKnowledge)
        {
            GenericRemoteSyncProvider <EntityObjectHierarchy> provider = GetSessionProvider();

            try
            {
                SyncKnowledge knowledge;
                provider.GetSyncBatchParameters(out batchSize, out knowledge);
                rawKnowledge = knowledge.Serialize();
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }
        }
示例#7
0
        public byte[] GetFullEnumerationChangeBatch(uint batchSize, byte[] lowerEnumerationBoundRaw,
                                                    byte[] rawKnowledgeForDataRetrieval,
                                                    out byte[] changeDataRetriever)
        {
            GenericRemoteSyncProvider <EntityObjectHierarchy> provider = GetSessionProvider();

            byte[] retVal = null;
            try
            {
                SyncKnowledge knowledgeForDataRetrieval = SyncKnowledge.Deserialize(provider.IdFormats,
                                                                                    rawKnowledgeForDataRetrieval);
                SyncId lowerEnumerationBound = new SyncId(lowerEnumerationBoundRaw, false);
                object dataRetriever;
                FullEnumerationChangeBatch changeBatch = provider.GetFullEnumerationChangeBatch(batchSize,
                                                                                                lowerEnumerationBound,
                                                                                                knowledgeForDataRetrieval,
                                                                                                out dataRetriever);
                CachedChangeDataRetriever cachedChangeDataRetriever =
                    new CachedChangeDataRetriever(dataRetriever as IChangeDataRetriever, changeBatch);
                changeDataRetriever = SerializerHelper.BinarySerialize(cachedChangeDataRetriever);
                retVal = changeBatch.Serialize();
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }

            return(retVal);
        }
示例#8
0
        public byte[] GetIdFormats()
        {
            KnowledgeSyncProvider provider = GetSessionProvider();

            byte[] retVal = null;
            try
            {
                retVal = SerializerHelper.BinarySerialize(provider.IdFormats);
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }

            return(retVal);
        }