Example #1
0
 public string DeleteExistingChain(String firstBlockGUID)
 {
     var jss = new JavaScriptSerializer();
     List<ServiceFlow> sfs;
     String errorMessage;
     if (GetServiceFlows(out sfs, out errorMessage))
     {
         foreach (ServiceFlow serviceFlow in sfs)
         {
             if (serviceFlow.FirstBlockGUID == firstBlockGUID)
             {
                 try
                 {
                     UserProfile profile = UserProfile.GetUserProfile(User.Identity.Name);
                     List<ServiceFlow> newServiceFlows = new List<ServiceFlow>(sfs);
                     newServiceFlows.Remove(serviceFlow);
                     profile.ServiceFlows = newServiceFlows.SerializeAndZip();
                     profile.Save();
                     return jss.Serialize("Chain Deleted Successfully");
                 }
                 catch (Exception exception)
                 {
                     return jss.Serialize("Problem deleting chain - " + exception.Message);
                 }
             }
         }
         return jss.Serialize("Error - Chain not found");
     }
     return jss.Serialize(errorMessage);
 }
Example #2
0
 private string SaveServiceFlow(List<ServiceFlow> serviceFlows, ServiceFlow serviceflow)
 {
     string errorMessage;
     //TODO: Re-enable conflict detection
     //if (DetectConflict(serviceFlows, serviceflow, out errorMessage))
     //    return "Conflict Detected - " + errorMessage;
     try
     {
         UserProfile profile = UserProfile.GetUserProfile(User.Identity.Name);
         serviceFlows.Add(serviceflow);
         profile.ServiceFlows = serviceFlows.SerializeAndZip();
         profile.Save();
         return "Chain Saved Successfully";
     }
     catch (Exception exception)
     {
         return "Problem saving chain - " + exception.Message;
     }
 }
Example #3
0
        private bool GetServiceFlows(out List<ServiceFlow> flows, out String errorMessage)
        {
            if (Session != null)
            {
                UserProfile profile = UserProfile.GetUserProfile(User.Identity.Name);
                try
                {
                    flows = profile.ServiceFlows.UnzipAndDeserialize<List<ServiceFlow>>();

                    /*Delete profile flows
                    flows = new List<ServiceFlow>();
                    profile.ServiceFlows = flows.Serialize();
                    profile.Save();*/

                    errorMessage = "Success";
                    return true;
                }
                catch (Exception e)
                {
                    errorMessage = "Could not retrieve list of service flows from profile";
                    flows = new List<ServiceFlow>();
                    profile.ServiceFlows = flows.SerializeAndZip();
                    profile.Save();

                    return false;
                }
            }
            errorMessage = "Error - Could not ID session - please login again";
            flows = new List<ServiceFlow>();
            return false;
        }