public static void DynamicOverride(object dataAccess, FaultHandler handler)
		{
			// Goofy code to change MongoDataAccess to use TestMongoRepositoryFactory implementation instead of default
			// TestMongoRepositoryFactory is a decorator over the default implementation and includes fault injection logic
			PropertyInfo repoFactoryInfo;
			object factories;
			var repoFactory = ExtractRepoFactory(dataAccess, out repoFactoryInfo, out factories);
			var newRepoFactory = new TestMongoRepositoryFactory(repoFactory, handler);
			repoFactoryInfo.SetValue(factories, newRepoFactory, null);
		}
        public static void DynamicOverride(object dataAccess, FaultHandler handler)
        {
            // Goofy code to change MongoDataAccess to use TestMongoRepositoryFactory implementation instead of default
            // TestMongoRepositoryFactory is a decorator over the default implementation and includes fault injection logic
            PropertyInfo repoFactoryInfo;
            object       factories;
            var          repoFactory    = ExtractRepoFactory(dataAccess, out repoFactoryInfo, out factories);
            var          newRepoFactory = new TestMongoRepositoryFactory(repoFactory, handler);

            repoFactoryInfo.SetValue(factories, newRepoFactory, null);
        }
        private void HandleFault(NetMessage message)
        {
            string msgDest = message.Action.FaultMessage.Detail;

            if (message.Action.FaultMessage.Code.Equals(NetFault.PollTimeoutErrorMessage.Action.FaultMessage.Code) ||
                message.Action.FaultMessage.Code.Equals(NetFault.NoMessageInQueueErrorMessage.Action.FaultMessage.Code))
            {
                lock (this.syncSubscriptions)
                {
                    if (syncSubscriptions.ContainsKey(msgDest))
                    {
                        PollRequest request = syncSubscriptions[msgDest];
                        if (message.Action.FaultMessage.Code.Equals(NetFault.PollTimeoutErrorMessage.Action.FaultMessage.Code))
                        {
                            request.Handover.Offer(UnblockNotification);
                        }
                        else
                        {
                            request.Handover.Offer(NoMessageNotification);
                        }
                    }
                    return;
                }
            }

            message.Action.FaultMessage.Headers = message.Headers;

            if (!PendingAcceptRequestsManager.MessageFailed(message.Action.FaultMessage))
            {
                FaultHandler handler = OnFault;
                if (handler != null)
                {
                    OnFault(message.Action.FaultMessage);
                }
            }
        }
Beispiel #4
0
 public IEnumerable <Course> ListCategoryByIds(IEnumerable <int> categoryId)
 {
     return(FaultHandler <Course> .Protect(() => new CourseDomain().ListByCategoryIds(categoryId)));
 }
Beispiel #5
0
 public IEnumerable <Course> ListCoursesByIds(IEnumerable <int> courseIds)
 {
     return(FaultHandler <Course> .Protect(() => new CourseDomain().ListByCourseIds(courseIds)));
 }
Beispiel #6
0
 public IEnumerable <string> ListByPrefix(string prefix)
 {
     return(FaultHandler <string> .Protect(() => new CourseDomain().ListByPrefix(prefix)));
 }
    public virtual Differences VisitFaultHandler(FaultHandler faultHandler1, FaultHandler faultHandler2){
      Differences differences = new Differences(faultHandler1, faultHandler2);
      if (faultHandler1 == null || faultHandler2 == null){
        if (faultHandler1 != faultHandler2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      FaultHandler changes = (FaultHandler)faultHandler2.Clone();
      FaultHandler deletions = (FaultHandler)faultHandler2.Clone();
      FaultHandler insertions = (FaultHandler)faultHandler2.Clone();

      Differences diff = this.VisitBlock(faultHandler1.Block, faultHandler2.Block);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.Block = diff.Changes as Block;
      deletions.Block = diff.Deletions as Block;
      insertions.Block = diff.Insertions as Block;
      Debug.Assert(diff.Changes == changes.Block && diff.Deletions == deletions.Block && diff.Insertions == insertions.Block);
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Beispiel #8
0
 public Responder(ResultHandler resultHandler, FaultHandler faultHandler)
 {
     _resultHandler = resultHandler;
     _faultHandler = faultHandler;
 }
 public override Statement VisitFaultHandler(FaultHandler faultHandler)
 {
   throw new ApplicationException("unimplemented");
 }
Beispiel #10
0
 public override Statement VisitFaultHandler(FaultHandler faultHandler)
 {
     if (faultHandler == null) return null;
     return base.VisitFaultHandler((FaultHandler)faultHandler.Clone());
 }
Beispiel #11
0
 public virtual Statement VisitFaultHandler(FaultHandler faultHandler1, FaultHandler faultHandler2)
 {
     if (faultHandler1 == null) return null;
     if (faultHandler2 == null)
         faultHandler1.Block = this.VisitBlock(faultHandler1.Block, null);
     else
         faultHandler1.Block = this.VisitBlock(faultHandler1.Block, faultHandler2.Block);
     return faultHandler1;
 }
 public TestMongoRepositoryFactory(IMongoRepositoryFactory repositoryFactory,
                                   FaultHandler faultHandler)
 {
     this.repositoryFactory = repositoryFactory;
     this.faultHandler      = faultHandler;
 }
Beispiel #13
0
 public Responder(ResultHandler resultHandler, FaultHandler faultHandler)
 {
     _resultHandler = resultHandler;
     _faultHandler  = faultHandler;
 }
Beispiel #14
0
 public override Statement VisitFaultHandler(FaultHandler faultHandler)
 {
     throw new ApplicationException("unimplemented");
 }
Beispiel #15
0
        /// <summary>
        /// Fill the various structures with step data from the BPEL XML file
        /// </summary>
        /// <param name="workflowContext"> workflowcontextModel class</param>
        /// <param name="startElement">Integer value representing the starting element in the nodeList.</param>
        /// <param name="nodeList">XmlNodeList containing the BPEL data from the BPEL file</param>
        /// <param name="cancelEventHandlerName">cancelEventHandlerName</param>
        private void FillStepList(WorkflowContext workflowContext, List <IWorkflowStep> workflowStepList, int startElement, XmlNodeList nodeList, ref string cancelEventHandlerName)
        {
            for (int i = startElement; i < nodeList.Count; i++)
            {
                var currentStep = nodeList[i];

                if (!string.IsNullOrEmpty(currentStep.Prefix))
                {
                    currentStep.Prefix = "bpel";
                }

                if (currentStep is XmlComment)
                {
                    continue;
                }

                if (currentStep.LocalName == "invoke")
                {
                    var workflowStep = new InvokeStep(currentStep.Attributes);
                    workflowStepList.Add(workflowStep);
                }
                else if (currentStep.LocalName == "sequence")
                {
                    var sequenceStep = new SequenceStep(currentStep.Attributes);
                    workflowStepList.Add(sequenceStep);
                    FillStepList(workflowContext, sequenceStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "scope")
                {
                    // can't get tool to produce invoke without having it enclosed in a scope.
                    // just ignore scope for now but get the internals as if at the same level.
                    FillStepList(workflowContext, workflowStepList, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "receive")
                {
                    var receiveStep = new ReceiveStep(currentStep.Attributes);
                    workflowStepList.Add(receiveStep);
                    string messageName = String.Empty;
                    string timesetTime = String.Empty;
                    if (currentStep.Attributes != null)
                    {
                        foreach (XmlAttribute attrib in currentStep.Attributes)
                        {
                            if (attrib.LocalName == "timeout")
                            {
                                timesetTime = attrib.Value;
                            }
                            if (attrib.LocalName == "variable")
                            {
                                messageName = attrib.Value;
                            }
                        }
                    }
                    if (!timeoutParameters.ContainsKey(messageName))
                    {
                        timeoutParameters.Add(messageName, timesetTime);
                    }
                }
                else if (currentStep.LocalName == "switch")
                {
                    var switchStep = new SwitchStep(currentStep.Attributes);
                    workflowStepList.Add(switchStep);

                    // Fill case/otherwise steps inside of switch step
                    FillStepList(workflowContext, switchStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "case")
                {
                    var caseStep = new CaseStep(currentStep.Attributes, false);
                    workflowStepList.Add(caseStep);
                    FillStepList(workflowContext, caseStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "otherwise")
                {
                    var caseStep = new CaseStep(currentStep.Attributes, true);
                    workflowStepList.Add(caseStep);
                    FillStepList(workflowContext, caseStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "while")
                {
                    var whileStep = new WhileStep(currentStep.Attributes);
                    workflowStepList.Add(whileStep);
                    FillStepList(workflowContext, whileStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "pick")
                {
                    var pickStep = new PickStep(currentStep.Attributes);
                    workflowStepList.Add(pickStep);
                    FillStepList(workflowContext, pickStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "eventHandlers")
                {
                    //we will handle this section as same as handl scope
                    FillStepList(workflowContext, workflowStepList, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "onMessage")
                {
                    var messageStep = new OnMessageStep(currentStep.Attributes);
                    workflowStepList.Add(messageStep);

                    string messageName = String.Empty;
                    string timesetTime = String.Empty;
                    if (currentStep.Attributes != null)
                    {
                        foreach (XmlAttribute attrib in currentStep.Attributes)
                        {
                            if (attrib.LocalName == "timeout")
                            {
                                timesetTime = attrib.Value;
                            }
                            if (attrib.LocalName == "variable")
                            {
                                messageName = attrib.Value;
                            }
                        }
                    }
                    if (!timeoutParameters.ContainsKey(messageName))
                    {
                        timeoutParameters.Add(messageName, timesetTime);
                    }

                    FillStepList(workflowContext, messageStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "onEvent")
                {
                    var onEventStep = new OnEventStep(currentStep.Attributes);
                    workflowContext.MessageTimeoutEventHanlderDict.Add(onEventStep.EventKey, onEventStep.StepId);
                    workflowStepList.Add(onEventStep);
                    FillStepList(workflowContext, onEventStep.WorkflowSteps, 0, currentStep.ChildNodes, ref cancelEventHandlerName);
                }
                else if (currentStep.LocalName == "partnerLinks")
                {
                    FillPartnerLinkList(workflowContext, currentStep);
                }
                else if (currentStep.LocalName == "variables")
                {
                    FillVariableList(workflowContext, currentStep);
                }
                else if (currentStep.LocalName == "faultHandlers")
                {
                    foreach (XmlNode childNode in currentStep.ChildNodes)
                    {
                        var faultHandler = new FaultHandler(childNode);
                        workflowStepList.Add(faultHandler);
                        FillStepList(workflowContext, faultHandler.WorkflowSteps, 0, childNode.ChildNodes, ref cancelEventHandlerName);
                    }
                }
                else
                {
                    Debug.Fail("Unhandled " + currentStep.Name + " of " + currentStep.InnerText);
                }
            }
        }
Beispiel #16
0
 public void UpdateCourse(Course item)
 {
     FaultHandler <Course> .Protect(() => new CourseDomain().Update(item));
 }
Beispiel #17
0
 public void UpdateCourseStatusSendEmail(Course item)
 {
     FaultHandler <Course> .Protect(() => new CourseDomain().UpdateCourseStatusSendEmail(item));
 }
Beispiel #18
0
 public virtual void VisitFaultHandler(FaultHandler faultHandler)
 {
   if (faultHandler == null) return;
   this.VisitBlock(faultHandler.Block);
 }
Beispiel #19
0
 public virtual Statement VisitFaultHandler(FaultHandler faultHandler){
   if (faultHandler == null) return null;
   faultHandler.Block = this.VisitBlock(faultHandler.Block);
   return faultHandler;
 }
Beispiel #20
0
 public Course CreateCourse(Course item)
 {
     return(FaultHandler <Course> .Protect(() => new CourseDomain().Create(item)));
 }
 public virtual FaultHandler GetClosestMatch(FaultHandler/*!*/ nd1, FaultHandlerList/*!*/ list1, FaultHandlerList list2, int list1pos, ref int list2start,
   TrivialHashtable/*!*/ matchedNodes, out Differences closestDifferences, out int list2pos) {
   closestDifferences = null; list2pos = -1;
   if (list2 == null) return null;
   if (nd1 == null || list1 == null || matchedNodes == null || list1pos < 0 || list1pos >= list1.Count || list2start < 0 || list2start >= list2.Count) {
     Debug.Assert(false); return null;
   }
   FaultHandler closest = null;
   Differences winnerSoFar = null;
   for (int j = list2start, m = list2.Count; j < m; j++){
     FaultHandler nd2 = list2[j];
     if (list2start == j) list2start++;
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     Differences diff = this.GetDifferences(nd1, nd2);
     if (diff == null){Debug.Assert(false); continue;}
     if (diff.Similarity <= 0.5){
       //Not a good enough match
       if (list2start == j+1) list2start--; //The next call to GetClosestMatch will start looking at list2start, so this node will be considered then
       continue; //ignore it for the rest of this call
     }
     if (winnerSoFar != null && winnerSoFar.Similarity >= diff.Similarity) continue;
     winnerSoFar = closestDifferences = diff;
     closest = nd2;
     list2pos = j;
     if (diff.NumberOfDifferences == 0) return closest; //Perfect match, no need to look for other matches
   }
   if (closest != null){
     //^ assert winnerSoFar != null;
     //closest is closer to nd1 than any other node in list2, but this is no good if some other node in list1 has a better claim on closest
     for (int i = list1pos+1, n = list1.Count; i < n; i++){
       FaultHandler nd1alt = list1[i];
       if (nd1alt == null) continue;
       if (matchedNodes[nd1alt.UniqueKey] != null) continue;
       Differences diff = this.GetDifferences(nd1alt, closest);
       if (diff == null){Debug.Assert(false); continue;}
       if (diff.Similarity <= winnerSoFar.Similarity) continue;
       //nd1alt has a better claim on closest. See if it wants closest.
       Differences diff2;
       int j, k = list2start;
       FaultHandler nd2alt = this.GetClosestMatch(nd1alt, list1, list2, i, ref k,  matchedNodes, out diff2, out j);
       if (nd2alt != closest){
         Debug.Assert(nd2alt != null && diff2 != null && diff2.Similarity >= diff.Similarity);
         continue; //nd1alt prefers nd2alt to closest, so closest is still available
       }
       //nd1alt wants closest, take it out of the running
       matchedNodes[closest.UniqueKey] = nd1alt;
       //Now that closest is out of the running, try again
       k = list2start;
       FaultHandler newClosest = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out winnerSoFar, out list2pos);
       //put closest back in the running so that the next call to this routine will pick it up
       matchedNodes[closest.UniqueKey] = closest;
       closest = newClosest;
       break;
     }
   }
   closestDifferences = winnerSoFar;
   return closest;
 }
Beispiel #22
0
 public Course GetCourse(int id)
 {
     return(FaultHandler <Course> .Protect(() => new CourseDomain().Get(id)));
 }
Beispiel #23
0
 public virtual FaultHandler VisitFaultHandler(FaultHandler faultHandler, FaultHandler changes, FaultHandler deletions, FaultHandler insertions){
   this.UpdateSourceContext(faultHandler, changes);
   if (faultHandler == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
       faultHandler.Block = this.VisitBlock(faultHandler.Block, changes.Block, deletions.Block, insertions.Block);
     }
   }else if (deletions != null)
     return null;
   return faultHandler;
 }
Beispiel #24
0
 public IEnumerable <Course> ListCourses(int trainerId)
 {
     return(FaultHandler <Course> .Protect(() => new CourseDomain().List(trainerId)));
 }