Exemplo n.º 1
0
        public GetListResponse<Contact> GetContactListByParentId(IDRequest request)
        {
            try
            {
                var response = new GetListResponse<Contact>();
                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Contact>());

                bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive);
                int topn = request.Get<int>("TopN", int.MaxValue);
                int contactType = request.Get<int>("ContactType", 0);
                Guid parentId = request.Get("ParentId", Guid.Empty);
                using (IDataReader dr = db.ExecuteDataReader("SPGetContactListByParentId", includeInactive, request.CompanyID, topn, contactType, parentId))
                {
                    response.List = new List<Contact>();
                    while (dr.Read())
                    {
                        response.List.Add(GetFromData<Contact>(dr));
                    }

                    return response;
                }

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<Contact>>(ex);
            }
        }
        public GetListResponse<ApplicationFeature> GetApplicationFeatureListByOwnerID(IDRequest request)
        {
            try
            {
                var response = new GetListResponse<ApplicationFeature>();
                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<ApplicationFeature>());

                bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive);
                int topn = request.Get<int>("TopN", int.MaxValue);

                Guid ownerid = Guid.Empty;
                request.Get<Guid>("OwnerID", out ownerid);

                using (IDataReader dr = db.ExecuteDataReader("SPGetApplicationFeatureListByOwnerID", includeInactive, topn, request.CompanyID, ownerid))
                {
                    response.List = new List<ApplicationFeature>();
                    while (dr.Read())
                    {
                        response.List.Add(GetFromData<ApplicationFeature>(dr));
                    }

                    return response;
                }

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<ApplicationFeature>>(ex);
            }
        }
Exemplo n.º 3
0
        public GetItemResponse<SecurityEntity> GetSecurityEntity(IDRequest request)
        {
            var response = new GetItemResponse<SecurityEntity>();
            try
            {
                response = GenericGetEntity<SecurityEntity>(request);
                if (response != null && response.Item != null)
                {
                    SecurityEntity entity = response.Item;

                    Guid applicationID;
                    request.Get<Guid>("appid", out applicationID);

                    //fill in permission list
                    entity.PermissionList = GetSecurityPermissionList(applicationID, entity);

                    // fill in the parent id list
                    entity.ImmediateParentsIds = GetEntityRelationships(entity.ID);

                    response.Item = entity;
                }
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetItemResponse<SecurityEntity>>(ex);
            }
            return response;
        }
Exemplo n.º 4
0
 public GetListResponse<SecurityEntry> GetEntitySecurityEntryListForIac(IDRequest request)
 {
     try
     {
         Guid applicationID;
         request.Get<Guid>("appid", out applicationID);
         return GenericGetEntityList<SecurityEntry>("EntitySecurityEntryForIAC", true, applicationID, request.ID);
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle<GetListResponse<SecurityEntry>>(ex);
     }
 }
Exemplo n.º 5
0
 public GetListResponse<LogonLog> GetTopNLogonLogListBySecurityEntityID(IDRequest request)
 {
     var response = new GetListResponse<LogonLog>();
     response.List = new List<LogonLog>();
     try
     {
         var db = ImardaDatabase.CreateDatabase(Util.GetConnName<LogonLog>());
         int topN = request.Get("TopN", 50);
                         using (IDataReader dr = db.ExecuteDataReader("SPGetTopNLogonLogListBySecurityEntityID", request.ID, topN))
                         {
                             while (dr.Read()) response.List.Add(GetFromData<LogonLog>(dr));
                             return response;
                         }
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle<GetListResponse<LogonLog>>(ex);
     }
 }
Exemplo n.º 6
0
        public GetListResponse<UsageLog> GetUsageLogSummary(IDRequest request)
        {
            try
            {
                bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive);
                var companyID = request.CompanyID;
                var apiID = request.Get("ApiID", Guid.Empty);
                return ImardaDatabase.GetList<UsageLog>("SPGetUsageLogListSummary", includeInactive, companyID, apiID);

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<UsageLog>>(ex);
            }
        }
Exemplo n.º 7
0
        public GetListResponse<UsageLog> GetUsageLogSummaryByDateRange(IDRequest request)
        {
            try
            {
                bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive);
                var startDate = request.Get("StartDate", DateTime.UtcNow.Date.AddMonths(-3));
                var endDate = request.Get("EndDate", DateTime.UtcNow.Date);
                var companyID = request.CompanyID;
                var apiID = request.Get("ApiID", Guid.Empty);
                return ImardaDatabase.GetList<UsageLog>("SPGetUsageLogListSummary", includeInactive, startDate, endDate, companyID, apiID);

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<UsageLog>>(ex);
            }
        }
Exemplo n.º 8
0
        public GetListResponse<SecurityObject> GetSecurityObjectsByApplicationID(IDRequest request)
        {
            var response = new GetListResponse<SecurityObject>();
            try
            {
                Guid applicationID;
                request.Get<Guid>("appid", out applicationID);

                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityObject>());
                object[] args = new object[] { applicationID };
                using (IDataReader dr = db.ExecuteDataReader("SPGetSecurityObjectsByApplicationID", args))
                {
                    response.List = new List<SecurityObject>();
                    while (dr.Read())
                    {
                        response.List.Add(GetFromData<SecurityObject>(dr));
                    }

                    return response;
                }

            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetListResponse<SecurityObject>>(ex);
            }
        }
Exemplo n.º 9
0
        public GetItemResponse<SecurityEntity> GetSecurityEntityByLoginUserName(IDRequest request)
        {
            try
            {
                var response = new GetItemResponse<SecurityEntity>();
                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<SecurityEntity>());
                string username = request.Get("username", string.Empty);

                using (IDataReader dr = db.ExecuteDataReader("SPGetSecurityEntityByLoginUserName", username,0))
                {
                    if (dr.Read())
                    {
                        response.Item = GetFromData<SecurityEntity>(dr, false);
                    }
                    else
                    {
                        //failed to find login username
                        response.Status = false;
                        response.StatusMessage = "User name [" + username + "] was not found.";
                    }
                    return response;
                }
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetItemResponse<SecurityEntity>>(ex);
            }
        }
Exemplo n.º 10
0
        private void RemoveUnownedSecurityObjects(
			ImardaSecurityBusiness.IImardaSecurity service,
			IDRequest request,
			GetListResponse<SecurityObject> response)
        {
            if (ServiceMessageHelper.IsSuccess(response))
            {
                Guid callerSecurityEntityID;
                if (request.Get<Guid>("UserID", out callerSecurityEntityID))
                {
                    GetListResponse<SecurityObject> resp1 = service.GetKnownSecurityObjects(new IDRequest(callerSecurityEntityID));
                    ErrorHandler.Check(resp1);
                    if (resp1.List != null)
                    {
                        List<Guid> maxlist = resp1.List.Select(known => known.ID).ToList();
                        response.List.RemoveAll(so => !maxlist.Contains(so.ID));
                    }
                }

                //Include APIAccessPermission only for companies
                if (request.Get("Owner", "User") == "User")
                    response.List.Remove(response.List.Find(so => so.ID == APIAccessPermission));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Send an email or sms
        /// </summary>
        /// <param name="request">.ID=Notification.ID, ["PersonID"] = Person.ID, ["Data"]=typedDataKV, ["TZ"]=Windows time zone name, ["Type"]="email" or "sms"</param>
        /// <returns></returns>
        public SolutionMessageResponse SendNotification(IDRequest request)
        {
            try
            {
                SolutionMessageResponse appResponse = null;
                var service = ImardaProxyManager.Instance.IImardaCRMProxy;
                ChannelInvoker.Invoke(delegate(out IClientChannel channel)
                {
                    channel = service as IClientChannel;
                    Guid notificationItemID = request.ID;
                    var data = request.GetString("Data");
                    var tzid = request.GetString("TZ");
                    var personID = request.Get("PersonID", Guid.Empty);
                    var req = new GenericRequest(personID, notificationItemID, request.CompanyID, data, tzid);
                    string type = request.GetString("Type");
                    BusinessMessageResponse response = null;
                    if (type == "email")
                    {
                        response = service.SendNotificationEmail(req);
                    }
                    else if (type == "sms")
                    {
                        response = service.SendNotificationSMS(req);
                    }
                    else throw new ArgumentException("'Type' missing: 'sms' or 'email'");

                    ErrorHandler.Check(response);
                    //TODO more stuff here...?
                    appResponse = new SolutionMessageResponse();
                });
                return appResponse;
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<SolutionMessageResponse>(ex);
            }
        }