Ejemplo n.º 1
0
 public AttendanceController(IAttendanceData attendanceData, IMemberData memberData, IWorshipData worshipData, ICodeMasterData codeMasterData)
 {
     _attendanceData = attendanceData;
     _memberData     = memberData;
     _worshipData    = worshipData;
     _codeMasterData = codeMasterData;
 }
Ejemplo n.º 2
0
 public void SetCurrentMemberChat(IMemberData currentMember)
 {
     lock (_currentMemberLocker)
     {
         _currentChatMember = currentMember;
     }
 }
Ejemplo n.º 3
0
 public ScoresController(PogiDbContext context, IScoreInfo scoreInfo,
                         SignInManager <ApplicationUser> signInManager,
                         UserManager <ApplicationUser> userManager, IMemberData memberData, ICourseData courseData,
                         ICourseDetail courseDetail,
                         IHandicap handicap,
                         ITourInfo tourInfo,
                         ITourDay tourDayInfo,
                         ITeeTimeInfo teeTimeInfo,
                         IHttpContextAccessor httpContextAccessor,
                         IActivity activity,
                         IDateTime dateTime)
 {
     _context             = context;
     _scoreInfo           = scoreInfo;
     _signInManager       = signInManager;
     _userManager         = userManager;
     _memberData          = memberData;
     _courseData          = courseData;
     _courseDetail        = courseDetail;
     _handicap            = handicap;
     _tourInfo            = tourInfo;
     _tourDayInfo         = tourDayInfo;
     _teeTimeInfo         = teeTimeInfo;
     _httpContextAccessor = httpContextAccessor;
     _activity            = activity;
     _dateTime            = dateTime;
 }
Ejemplo n.º 4
0
        public IMessage GeneratePictureMessage(string[] args, IMemberData source, IMemberData destination)
        {
            Bitmap img = null;

            if (args.Length == 1) // == /picture
            {
                img = takeScreenShot();
            }
            else
            {
                img = loadImage(args[1]);
            }
            try
            {
                if (img != null)
                {
                    return(new ImageMessage(img, (UserData)source, (UserData)destination));
                }
            }
            catch
            {
                return(null);
            }
            return(null);
        }
Ejemplo n.º 5
0
 InputOutputRelation(ITestStepParent inputObject, IMemberData inputMember, ITestStepParent outputObject, IMemberData outputMember)
 {
     this.outputObject = outputObject;
     this.inputObject  = inputObject;
     this.outputMember = outputMember;
     this.inputMember  = inputMember;
 }
Ejemplo n.º 6
0
        private void WriteAMessage(IMemberData currentChatMember)
        {
            string msg = clientData.Inputter.GetUserInput();

            if (msg.ToLower() == "/exit")
            {
                _chatRoomExitToken = true;
                _messageReceiver.SetCurrentMemberChat(null);
                return;
            }
            if (msg.ToLower() == "/help")
            {
                clientData.Outputter.DisplayText(clientData.commandManager.GetCommandHelp());
                return;
            }
            if (msg.StartsWith("/"))
            {
                _messageSender.HandleUserCommands(msg, MyData, currentChatMember);
                return;
            }
            if (currentChatMember.GetType() == typeof(GroupData))
            {
                _messageSender.SendNewMessage(msg, currentChatMember, currentChatMember, MyData);
            }
            else
            {
                _messageSender.SendNewMessage(msg, currentChatMember, MyData, MyData);
            }
        }
Ejemplo n.º 7
0
        public void ThrowsArgumentNullException_When_SemanticModelIsNull()
        {
            IMemberData   member        = GetClass("class Test { }");
            SemanticModel?semanticModel = null;

            Assert.Throws <ArgumentNullException>(() => semanticModel !.GetUsedNamespaces(member.Declaration, Compilation));
        }
Ejemplo n.º 8
0
 internal ResourceNode(IResource resource, IMemberData prop, IEnumerable <IResource> weakDeps, IEnumerable <IResource> strongDeps)
 {
     this.Resource           = resource;
     this.Depender           = prop;
     this.WeakDependencies   = weakDeps.ToList();
     this.StrongDependencies = strongDeps.ToList();
 }
Ejemplo n.º 9
0
        bool loadScopeParameter(Guid scope, ITestStep step, IMemberData member, string parameter)
        {
            ITestStepParent parent;

            if (scope == Guid.Empty)
            {
                parent = step.GetParent <TestPlan>();
            }
            else
            {
                ITestStep subparent = step.Parent as ITestStep;
                while (subparent != null)
                {
                    if (subparent.Id == scope)
                    {
                        break;
                    }
                    subparent = subparent.Parent as ITestStep;
                }
                parent = subparent;
            }

            if (parent == null)
            {
                return(false);
            }
            member.Parameterize(parent, step, parameter);
            return(true);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Checks whether a given property is enabled according to the <see cref="EnabledIfAttribute"/>.
        /// </summary>
        /// <param name="at">The attribute enabling this property.</param>
        /// <param name="instance">Instance of the object that has 'property'.</param>
        /// <returns>true if property dependent property has the correct value.</returns>
        internal static bool IsEnabled(EnabledIfAttribute at, object instance)
        {
            IMemberData depedentProp = TypeData.GetTypeData(instance).GetMember(at.PropertyName);

            if (depedentProp == null)
            {
                // We cannot be sure that the step developer has used this attribute correctly
                // (could just be a typo in the (weakly typed) property name), thus we need to
                // provide a good error message that leads the developer to where the error is.
                log.Warning("Could not find property '{0}' on '{1}'. EnabledIfAttribute can only refer to properties of the same class as the property it is decorating.", at.PropertyName, instance.GetType().Name);
                return(false);
            }

            var depValue = depedentProp.GetValue(instance);

            try
            {
                return(calcEnabled(at, depValue));
            }
            catch (ArgumentException)
            {
                // CompareTo throws ArgumentException when obj is not the same type as this instance.
                return(false);
            }
        }
Ejemplo n.º 11
0
        void updatePropertyFromName()
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                return;
            }
            else
            {
                string[] parts = propertyName.Split('|');
                if (parts.Length == 1)
                {
                    if (Step != null)
                    {
                        ITypeData stepType = TypeData.GetTypeData(Step);
                        Property = stepType.GetMember(parts[0]);
                    }
                    else
                    {
                        Property = null;
                    }
                }
                else
                {
                    var       typename = parts[0];
                    ITypeData stepType = TypeData.GetTypeData(typename);
                    Property = stepType.GetMember(parts[1]);
                }
            }

            if (Property != null)
            {
                propertyName = null;
            }
        }
        public void ThrowsArgumentNullException_When_SemanticModelIsNull()
        {
            IMemberData   member        = GetClass("class Test { }");
            SemanticModel?semanticModel = null;

            Assert.Throws <ArgumentNullException>(() => semanticModel !.GetAttribute(member.Declaration, AttributeSymbol));
        }
Ejemplo n.º 13
0
 public UserModel(UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager
                  , IMemberData memberData)
 {
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.memberData    = memberData;
 }
        public void SendCustomMessage(IMemberData destinationUser, string msg)
        {
            User        userInGroup    = _serverDTO.MembersDB.GetUser(destinationUser.UID);
            TextMessage privateMessage = new TextMessage(msg, _serverDTO.AdminData, (UserData)destinationUser);

            SendMessageToUser(userInGroup.nwStream, privateMessage);
        }
Ejemplo n.º 15
0
        private void CollectDirectlyUsedBy(IMemberData member)
        {
            var method = member as MethodData;
            if (method == null)
                return; // stub

            this.CollectDirectlyUsedBy(method);
        }
Ejemplo n.º 16
0
 /// <summary> Parameterizes a member from one object unto another.
 /// If the name matches an existing parameter, the member will be added to that. </summary>
 /// <param name="target"> The object on which to add a new member. </param>
 /// <param name="member"> The member to forward. </param>
 /// <param name="source"> The owner of the forwarded member. </param>
 /// <param name="name"> The name of the new property. If null, the name of the source member will be used.</param>
 /// <returns>The parameterization of the member..</returns>
 public static ParameterMemberData Parameterize(this IMemberData member, object target, object source, string name)
 {
     if (member.GetParameter(target, source) != null)
     {
         throw new Exception("Member is already parameterized.");
     }
     return(DynamicMember.ParameterizeMember(target, member, source, name));
 }
Ejemplo n.º 17
0
 public IMenuModel CreateModel(IMemberData member)
 {
     if (member.DeclaringType.DescendsTo(typeof(ITestStepParent)))
     {
         return(new TestStepMenuModel(member));
     }
     return(null);
 }
Ejemplo n.º 18
0
 public DetailModel(IProductData productData, IMemberData memberData,
                    UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager)
 {
     this.productData   = productData;
     this.memberData    = memberData;
     this.userManager   = userManager;
     this.signInManager = signInManager;
 }
Ejemplo n.º 19
0
        public static void RemovedDynamicMember(object target, IMemberData member)
        {
            var members =
                (IMemberData[])DynamicMemberTypeDataProvider.TestStepTypeData.DynamicMembers.GetValue(target);

            members = members.Where(x => !Equals(x, member)).ToArray();
            DynamicMemberTypeDataProvider.TestStepTypeData.DynamicMembers.SetValue(target, members);
        }
Ejemplo n.º 20
0
        private void Collect(IMemberData member)
        {
            if (!this.filter(member))
                return;

            if (!this.Collected.Add(member))
                return;
            this.queued.Enqueue(member);
        }
 public void SendNewMessage(string msg, IMemberData destinationMember, IMemberData sourceMember, UserData messageAuthor)
 {
     if (destinationMember.GetType() == typeof(GroupData))
     {
         SendNewGroupMessage(msg, messageAuthor, (GroupData)sourceMember, (GroupData)destinationMember);
         return;
     }
     SendNewTextMessage(msg, (UserData)sourceMember, (UserData)destinationMember);
 }
Ejemplo n.º 22
0
 public static IEnumerable <ScopeMember> GetScopeMembers(IMemberData member)
 {
     if (member is ParameterMemberData fwd)
     {
         return(fwd.ParameterizedMembers
                .Select(x => new ScopeMember((ITestStep)x.Source, x.Member)));
     }
     return(Enumerable.Empty <ScopeMember>());
 }
Ejemplo n.º 23
0
        private void CollectAllUsedBy(IMemberData member)
        {
            this.CollectDirectlyUsedBy(member);

            while (this.queued.Count > 0) {
                var item = this.queued.Dequeue();
                this.CollectAllUsedBy(item);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Returns a <see cref="string"/> representing the fully qualified name of the <paramref name="member"/> that can be used in the XML documentation.
        /// </summary>
        /// <param name="member"><see cref="IMemberData"/> to get the fully qualified name of.</param>
        /// <exception cref="ArgumentNullException"><paramref name="member"/> is <see langword="null"/>.</exception>
        public static string GetXmlFullyQualifiedName(this IMemberData member)
        {
            if (member is null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            return(AnalysisUtilities.ConvertFullyQualifiedNameToXml(member.Symbol.ToString()));
        }
Ejemplo n.º 25
0
        public void SettingOfExternalParametersOnTestReferencePlan()
        {
            double defaultValue = 0.7;         //seconds
            double newValue     = 7.0;         //seconds
            //double tolerance = Math.Abs(newValue * .0000001); // The tolerance for variation in their delay double values
            int    stepsCount            = 20; // how many delay steps should be generated and tested
            string externalParameterName = "External Delay";
            string filePath = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".TapPlan";

            GenerateTestPlanWithNDelaySteps(stepsCount, filePath, defaultValue, externalParameterName);

            try
            {
                // Create a test plan
                TestPlan testPlan = new TestPlan();

                // Create a ReferencePlanStep and add it to the test plan
                TestPlanReference tpr = new TestPlanReference();
                MacroString       ms  = new MacroString(tpr)
                {
                    Text = filePath
                };
                tpr.Filepath = ms; // automatically calls LoadTesPlan
                testPlan.ChildTestSteps.Add(tpr);

                Assert.AreEqual(1, testPlan.ChildTestSteps.Count);
                Assert.AreEqual(stepsCount, tpr.ChildTestSteps.Count);

                // ----------------------------------------------------------------------------------------------------
                // This is how to get access to a TestPlanReference loaded test plan's children's external paramters:
                ITypeData ti = TypeData.GetTypeData(tpr);
                // IMemberInfo mi = ti.GetMember(externalParameterName); <- not possible to get property by its name in case the property name contains characters not valid of a C# property name
                IMemberData mi = ti.GetMembers().FirstOrDefault(m => m.Attributes.Any(xa => (xa as DisplayAttribute)?.Name == externalParameterName)); // <- the right approach
                // ----------------------------------------------------------------------------------------------------

                Assert.IsNotNull(mi);
                Assert.AreEqual(defaultValue, mi.GetValue(tpr));
                mi.SetValue(tpr, newValue);

                // Test that the new value has been set on all the inner delay steps
                for (int i = 0; i < stepsCount; i++)
                {
                    DelayStep delayStep = tpr.ChildTestSteps[i] as DelayStep;
                    Assert.IsNotNull(delayStep);
                    //Assert.IsTrue(Math.Abs(newValue - delayStep.DelaySecs) <= tolerance);
                    Assert.AreEqual(newValue, delayStep.DelaySecs);
                }
            }
            finally
            {
                // delete the temporary file in the end
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Returns full namespace of the target <paramref name="member"/>.
        /// </summary>
        /// <param name="member"><see cref="IMemberData"/> to get the parent namespace of.</param>
        /// <returns>The full namespace of the target <paramref name="member"/>. -or- <see langword="null"/> if the <paramref name="member"/> is not contained withing a namespace. -or- <paramref name="member"/> is contained within global namespace.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="member"/> is <see langword="null"/>.</exception>
        public static string?JoinNamespaces(this IMemberData member)
        {
            if (member is null)
            {
                throw new ArgumentNullException(nameof(member));
            }

            return(member.GetContainingNamespaces().JoinNamespaces());
        }
Ejemplo n.º 27
0
 /// <summary> Creates an immutable instance of this class. </summary>
 public ResourceReference(object obj, IMemberData prop)
 {
     Instance = obj;
     Member   = prop;
     if (prop is MemberData md)
     {
         Property = md.Member as PropertyInfo;
     }
 }
Ejemplo n.º 28
0
        /// <summary> Serialization implementation. </summary>
        public override bool Serialize(XElement elem, object obj, ITypeData expectedType)
        {
            if (currentNode.Contains(elem))
            {
                return(false);
            }


            var objSerializer = Serializer.SerializerStack.OfType <IConstructingSerializer>().FirstOrDefault();

            if (objSerializer?.CurrentMember == null || false == objSerializer.Object is ITestStep)
            {
                return(false);
            }


            ITestStep step = (ITestStep)objSerializer.Object;

            var member = objSerializer.CurrentMember;
            // here I need to check if any of its parent steps are forwarding
            // its member data.

            ITestStepParent parameterParemt = step.Parent;
            IMemberData     parameterMember = null;

            while (parameterParemt != null && parameterMember == null)
            {
                var members = TypeData.GetTypeData(parameterParemt).GetMembers().OfType <IParameterMemberData>();
                parameterMember = members.FirstOrDefault(x => x.ParameterizedMembers.Any(y => y.Source == step && y.Member == member));
                if (parameterMember == null)
                {
                    parameterParemt = parameterParemt.Parent;
                }
            }

            if (parameterMember == null)
            {
                return(false);
            }

            elem.SetAttributeValue(Parameter, parameterMember.Name);
            if (parameterParemt is ITestStep parentStep)
            {
                elem.SetAttributeValue(Scope, parentStep.Id.ToString());
            }
            // skip
            try
            {
                currentNode.Add(elem);
                return(Serializer.Serialize(elem, obj, expectedType));
            }
            finally
            {
                currentNode.Remove(elem);
            }
        }
Ejemplo n.º 29
0
 public BasketModel(UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager
                    , IMemberData memberData, IProductData productData, IOrderData orderData, IProductService productService)
 {
     this.userManager    = userManager;
     this.signInManager  = signInManager;
     this.memberData     = memberData;
     this.productData    = productData;
     this.orderData      = orderData;
     this.productService = productService;
 }
Ejemplo n.º 30
0
 public PlayerController(PogiDbContext context, SignInManager <ApplicationUser> signInManager,
                         UserManager <ApplicationUser> userManager, IMemberData memberData,
                         ITeeTimeInfo teeTimeInfo)
 {
     _context       = context;
     _signInManager = signInManager;
     _userManager   = userManager;
     _memberData    = memberData;
     _teeTimeInfo   = teeTimeInfo;
 }
Ejemplo n.º 31
0
        public static void AddDynamicMember(object target, IMemberData member)
        {
            var members =
                (IMemberData[])DynamicMemberTypeDataProvider.TestStepTypeData.DynamicMembers.GetValue(target) ?? new IMemberData[0];


            Array.Resize(ref members, members.Length + 1);
            members[members.Length - 1] = member;
            DynamicMemberTypeDataProvider.TestStepTypeData.DynamicMembers.SetValue(target, members);
        }
Ejemplo n.º 32
0
        private void CollectAllUsedBy(IMemberData member)
        {
            this.CollectDirectlyUsedBy(member);

            while (this.queued.Count > 0)
            {
                var item = this.queued.Dequeue();
                this.CollectAllUsedBy(item);
            }
        }
Ejemplo n.º 33
0
        private void CollectDirectlyUsedBy(IMemberData member)
        {
            var method = member as MethodData;

            if (method == null)
            {
                return; // stub
            }
            this.CollectDirectlyUsedBy(method);
        }
        public IServiceResponse AddMember(IMemberData data, string authToken)
        {
            IServiceResponse serviceResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(AddMemberUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(AddMemberUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    //currently creates all as member only and sends email (could be altered)
                    JObject jsonProv = new JObject(
                        new JProperty("new_members",
                            new JArray(
                                new JObject(
                                    new JProperty("member_email", data.Email),
                                    new JProperty("member_given_name", data.FirstName),
                                    new JProperty("member_surname", data.LastName),
                                    new JProperty("send_welcome_email", data.SendWelcomeEmail),
                                    new JProperty("role",
                                        new JObject(
                                            new JProperty(".tag", data.RoleName)
                                        )
                                    )
                                )
                            )
                        ),
                        new JProperty("force_async", false)
                    );
                    request.AddParameter("application/json", jsonProv, ParameterType.RequestBody);
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    serviceResponse = new ServiceResponse(response.StatusCode, response.Content);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                serviceResponse = new ServiceResponse(HttpStatusCode.InternalServerError, e.Message);
            }
            return serviceResponse;
        }
Ejemplo n.º 35
0
 public MemberDataCache(IMemberData dataStore)
 {
     DataStore = dataStore;
     MembersCache = new Dictionary<int, Member>();
     MemberShipCache = new Dictionary<int, MemberShip>();
 }
Ejemplo n.º 36
0
 public object Explain(IMemberData data)
 {
     return "It is not possible to explain this smell in current version.";
 }
        public IServiceResponse RemoveMember(IMemberData data, string authToken)
        {
            IServiceResponse serviceResponse = null;
            bool wipeData = true;
            if (data.KeepAccount)
            {
                wipeData = false;
            }
            try
            {
                if (!string.IsNullOrEmpty(RemoveMemberUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(RemoveMemberUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    JObject jsonProv = new JObject(
                        new JProperty("user",
                                new JObject(
                                    new JProperty(".tag", "email"),
                                    new JProperty("email", data.Email)
                                )
                        ),
                        new JProperty("wipe_data", wipeData),
                        new JProperty("keep_account", data.KeepAccount)
                    );
                    request.AddParameter("application/json", jsonProv, ParameterType.RequestBody);
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    serviceResponse = new ServiceResponse(response.StatusCode, response.ErrorMessage);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                serviceResponse = new ServiceResponse(HttpStatusCode.InternalServerError, e.Message);
            }
            return serviceResponse;
        }
        public IDataResponse ListMembersContinuation(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(ListMembersContinuationUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(ListMembersContinuationUrl, Method.POST);

                    //add headers
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    JObject json = new JObject(
                        new JProperty("cursor", data.Cursor)
                    );
                    request.AddParameter("application/json", json, ParameterType.RequestBody);
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse GetUsage(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(GetUsageUrl))
                {
                    RestClient client = new RestClient(
                           string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                       );
                    RestRequest request = new RestRequest(GetUsageUrl, Method.POST);
                    //add headers
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Dropbox-API-Select-User", data.MemberId);

                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
                else {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse GetGroups(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(GetGroupsUrl))
                {
                    RestClient client = new RestClient(
                           string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                       );
                    RestRequest request = new RestRequest(GetGroupsUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    if (String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                        new JProperty("limit", 1000)
                       );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }

                    if (!String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                        new JProperty("cursor", data.Cursor)
                       );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);

                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse DumpDevices(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(DumpDevicesUrl))
                {
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(DumpDevicesUrl, Method.POST);

                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    string ClientType = data.ClientType;
                    string ClientTypeAPI = string.Empty;
                    if (ClientType == "Desktop")
                    {
                        ClientTypeAPI = "desktop_client";
                    }
                    if (ClientType == "Web")
                    {
                        ClientTypeAPI = "web_session";
                    }
                    if (ClientType == "Mobile")
                    {
                        ClientTypeAPI = "mobile_client";
                    }
                    //set up properties for JSON to the API
                    //if desktop client, do a delete_on_unlink set to true to delete all files of account
                    if (ClientTypeAPI == "desktop_client")
                    {
                        JObject jsonSearch = new JObject(
                            new JProperty(".tag", ClientTypeAPI),
                            new JProperty("session_id", data.SessionId),
                            new JProperty("team_member_id", data.MemberId),
                            new JProperty("delete_on_unlink", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    if (ClientTypeAPI == "web_session" || ClientTypeAPI == "mobile_client")
                    {
                        JObject jsonSearch = new JObject(
                            new JProperty(".tag", ClientTypeAPI),
                            new JProperty("session_id", data.SessionId),
                            new JProperty("team_member_id", data.MemberId)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse FindDevices(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(GetDevicesUrl))
                {
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(GetDevicesUrl, Method.POST);

                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    if (String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API
                        JObject jsonSearch = new JObject(
                            new JProperty("include_web_sessions", true),
                            new JProperty("include_desktop_clients", true),
                            new JProperty("include_mobile_clients", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    if (!String.IsNullOrEmpty(data.Cursor))
                    {
                        //set up properties for JSON to the API with cursor for continuation
                        JObject jsonSearch = new JObject(
                            new JProperty("cursor", data.Cursor),
                            new JProperty("include_web_sessions", true),
                            new JProperty("include_desktop_clients", true),
                            new JProperty("include_mobile_clients", true)
                        );
                        request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    }
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IDataResponse DumpFile(IMemberData data, string outputFolder, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(FileDumpUrl))
                {
                    //added this to be able to get files with ASCII characters in them.
                    Byte[] encodedBytes = System.Text.Encoding.ASCII.GetBytes(data.Path);
                    string newPath = System.Text.Encoding.ASCII.GetString(encodedBytes);

                    string pathString = string.Concat(@"{""path"":""", newPath, @"""}");
                    string url = string.Format("{0}/{1}/", _baseUrl, _apiVersion);
                    RestClient client = new RestClient(url);
                    RestRequest request = new RestRequest(FileDumpUrl, Method.GET);
                    client.UserAgent = UserAgentVersion;
                    //add headers, include user authentication we pass in with admin privileges
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Dropbox-API-Select-User", data.MemberId);
                    request.AddHeader("Dropbox-API-Arg", pathString);

                    //download file by using raw bytes returned
                    byte[] jsonResponseDump = client.DownloadData(request);

                    // strip out email prefix as folder name.
                    int index = data.Email.IndexOf("@");
                    string folderName = data.Email.Substring(0, index);

                    if (!data.ZipFiles)
                    {
                        //get the Dropbox folder structure so we can recreate correct folder structure locally under user folder below
                        String dbdirName = Path.GetDirectoryName(data.Path);
                        dbdirName = dbdirName.Remove(0, 1);

                        //combine Dropbox subdirectory to email username
                        if (!string.IsNullOrEmpty(dbdirName))
                        {
                            folderName = folderName + "\\" + dbdirName;
                        }
                        string fullOutputFolder = Path.Combine(outputFolder, folderName);

                        if (!Directory.Exists(fullOutputFolder))
                        {
                            Directory.CreateDirectory(fullOutputFolder);
                        }
                        string outputPath = Path.Combine(fullOutputFolder, data.FileName);
                        File.WriteAllBytes(outputPath, jsonResponseDump);
                    }
                         
                    //Added 5/5/16 - Zip file if needed. If first file create the zipfile, if not just add to existing zip file  
                    if (data.ZipFiles)
                    {
                        string fullOutputFolder = Path.Combine(outputFolder, folderName);
                        if (!Directory.Exists(fullOutputFolder))
                        {
                            Directory.CreateDirectory(fullOutputFolder);
                        }
                        string outputPath = Path.Combine(fullOutputFolder, data.FileName);
                        File.WriteAllBytes(outputPath, jsonResponseDump);

                        string dateString = DateTime.Now.ToString("-M.dd.yyyy");
                        string zipName = Path.Combine(fullOutputFolder, (folderName + dateString + ".zip"));
                        if (File.Exists(zipName))
                        {
                            using (ZipArchive modFile = ZipFile.Open(zipName, ZipArchiveMode.Update))
                            {
                                modFile.CreateEntryFromFile(outputPath, data.FileName, CompressionLevel.Fastest);
                            }
                        }
                        if (!File.Exists(zipName))
                        {
                            using (ZipArchive newFile = ZipFile.Open(zipName, ZipArchiveMode.Create))
                            {
                                newFile.CreateEntryFromFile(outputPath, data.FileName, CompressionLevel.Fastest);
                            }
                        }
                        File.Delete(outputPath);
                    }         
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }
        public IServiceResponse DeleteMemberGroup(IMemberData data, string email, string authToken)
        {
            IServiceResponse serviceResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(DeleteMemberGroupUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(DeleteMemberGroupUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    JObject json = new JObject(
                        new JProperty("group",
                                        new JObject(
                                            new JProperty(".tag", "group_id"),
                                            new JProperty("group_id", data.GroupId)
                                        )
                                    ),
                        new JProperty("users",
                            new JArray(
                                new JObject(
                                    new JProperty(".tag", "email"),
                                    new JProperty("email", email)
                                )
                            )
                        ),
                        new JProperty("return_members", false)
                    );
                    request.AddParameter("application/json", json, ParameterType.RequestBody);
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    serviceResponse = new ServiceResponse(response.StatusCode, response.ErrorMessage);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                serviceResponse = new ServiceResponse(HttpStatusCode.InternalServerError, e.Message);
            }
            return serviceResponse;
        }
        public IServiceResponse SetProfile(IMemberData data, string authToken)
        {
            IServiceResponse serviceResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(SetProfileUrl))
                {
                    RestClient client = new RestClient(
                        string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                    );
                    RestRequest request = new RestRequest(SetProfileUrl, Method.POST);
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");

                    //if we are updating external id also
                    if (!string.IsNullOrEmpty(data.NewExternalId))
                    {
                        JObject jsonProv = new JObject(
                        new JProperty("user",
                                new JObject(
                                    new JProperty(".tag", "email"),
                                    new JProperty("email", data.Email)
                                )
                        ),
                        new JProperty("new_email", data.NewEmail),
                        new JProperty("new_external_id", data.NewExternalId)
                        );
                        request.AddParameter("application/json", jsonProv, ParameterType.RequestBody);
                    }
                    //if we are not updating external id
                    if (string.IsNullOrEmpty(data.NewExternalId))
                    {
                        JObject jsonProv = new JObject(
                        new JProperty("user",
                                new JObject(
                                    new JProperty(".tag", "email"),
                                    new JProperty("email", data.Email)
                                )
                        ),
                        new JProperty("new_email", data.NewEmail)
                        );
                        request.AddParameter("application/json", jsonProv, ParameterType.RequestBody);
                    }       
                    request.RequestFormat = DataFormat.Json;
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    serviceResponse = new ServiceResponse(response.StatusCode, response.ErrorMessage);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                serviceResponse = new ServiceResponse(HttpStatusCode.InternalServerError, e.Message);
            }
            return serviceResponse;
        }
 public new bool ShouldSelect(IMemberData method, ISelectionContext context)
 {
     return base.ShouldSelect(method, context);
 }
Ejemplo n.º 47
0
        private IAssemblyData GetDeclaringAssembly(IMemberData member)
        {
            var declaringType = member.DeclaringType;
            if (declaringType == null)
                return member.Assembly;

            return declaringType.Assembly;
        }
Ejemplo n.º 48
0
 public MemberShipController(IMemberData data)
 {
     memberData = data;
 }
Ejemplo n.º 49
0
 static DataSource()
 {
     data = DataLevelConfig.RegisterData();
 }
        public IDataResponse SearchFiles(IMemberData data, string authToken)
        {
            IDataResponse dataResponse = null;
            try
            {
                if (!string.IsNullOrEmpty(SearchFilesUrl))
                {
                    RestClient client = new RestClient(
                           string.Format("{0}/{1}/", _baseUrl, _apiVersion)
                       );
                    RestRequest request = new RestRequest(SearchFilesUrl, Method.POST);
                    //add headers
                    request.AddHeader("Authorization", "Bearer " + authToken);
                    request.AddHeader("Content-Type", "application/json");
                    request.AddHeader("Dropbox-API-Select-User", data.MemberId);

                    //set up properties for JSON to the API
                    JObject jsonSearch = new JObject(
                        new JProperty("path", ""),
                        new JProperty("query", data.SearchText),
                        new JProperty("max_results", data.SearchLimit),
                        new JProperty("mode", data.SearchMode)
                    );
                    request.AddParameter("application/json", jsonSearch, ParameterType.RequestBody);
                    client.UserAgent = UserAgentVersion;
                    IRestResponse response = client.Execute(request);
                    dataResponse = new DataResponse(response.StatusCode, response.ErrorMessage, response.Content);
                }
                else
                {
                    throw new ArgumentNullException("Missing service url");
                }
            }
            catch (Exception e)
            {
                dataResponse = new DataResponse(HttpStatusCode.InternalServerError, e.Message, null);
            }
            return dataResponse;
        }