private void CallbackProcessStatus(IAsyncResult ar)
        {
            // Retrieve the delegate.
            ProcessState                result       = (ProcessState)ar.AsyncState;
            OrderChangelogAsync         caller       = result.Request;
            ChangelogIdentificationType returnResult = caller.EndInvoke(ar);

            result.Result    = returnResult;
            result.Completed = true;
        }
        private ChangelogIdentificationType OrderChangelogAsyncCaller(ChangelogOrderType order)
        {
            int id = -1;

            int.TryParse(order.datasetId, out id);
            IChangelogProvider changelogprovider;
            OrderChangelog     resp;
            int    startindex = -1;
            int    count      = -1;
            string initType;
            var    datasets = from d in db.Datasets where d.DatasetId == id select d;

            initType = datasets.First().DatasetProvider;
            //Initiate provider from config/dataset
            Type providerType = Assembly.GetExecutingAssembly().GetType(initType);

            changelogprovider = Activator.CreateInstance(providerType) as IChangelogProvider;
            changelogprovider.Intitalize(id);


            int.TryParse(order.startIndex, out startindex);
            int.TryParse(order.count, out count);

            if (startindex == -1)
            {
                throw new Exception("MissingParameterValue : startindex");
            }
            if (count == -1)
            {
                throw new Exception("MissingParameterValue : count");
            }

            if (datasets.First().ServerMaxCount.HasValue&& (datasets.First().ServerMaxCount < count || count == 0))
            {
                count = (int)datasets.First().ServerMaxCount;
            }

            resp = changelogprovider.CreateChangelog(startindex, count, "", id);

            // Create the delegate.
            OrderChangelogAsync caller = OrderChangeLogAsync;
            ProcessState        state  = new ProcessState(resp.changelogId);

            state.Request = caller;

            caller.BeginInvoke(changelogprovider, startindex, count, "", id,
                               CallbackProcessStatus, state);

            ChangelogIdentificationType res = new ChangelogIdentificationType();

            res.changelogId = resp.changelogId;
            return(res);
        }
 public ChangelogStatusType GetChangelogStatus(ChangelogIdentificationType changelogid)
 {
     try
     {
         ChangelogManager mng = new ChangelogManager(db);
         return(mng.GetChangelogStatus(changelogid.changelogId));
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
 public void CancelChangelog(ChangelogIdentificationType changelogid)
 {
     try
     {
         ChangelogManager mng = new ChangelogManager(db);
         mng.AcknowledgeChangelogDownloaded(changelogid.changelogId);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
        public ChangelogIdentificationType OrderChangeLogAsync(IChangelogProvider changelogprovider,
                                                               int startindex, int count, string to_doFilter, int datasetID)
        {
            try
            {
                var resp = changelogprovider.OrderChangelog(startindex, count, "", datasetID);
                ChangelogIdentificationType res = new ChangelogIdentificationType();
                res.changelogId = resp.changelogId;
                return(res);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, ex.Message);

                return(null);
            }
        }