Пример #1
0
 public GetListResponse<MessageItem> GetMessageListByUser(IDRequest request)
 {
     try
     {
         return ImardaDatabase.GetList<MessageItem>("SPGetMessageListByUser", new Guid(request.GetString("userid")), request.GetString("ViewDate"));
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle<GetListResponse<MessageItem>>(ex);
     }
 }
Пример #2
0
        public GetItemResponse<Contact> GetContactByName(IDRequest request)
        {
            try
            {
                var response = new GetItemResponse<Contact>();
                var db = ImardaDatabase.CreateDatabase(Util.GetConnName<Contact>());
                string custName = request.GetString("custName");

                using (IDataReader dr = db.ExecuteDataReader("SPGetContactByName", request.ID, custName))
                {
                    response = new GetItemResponse<Contact>();

                    if (dr.Read())
                    {
                        response.Item = (GetFromData<Contact>(dr));
                    }

                    return response;
                }
            }
            catch (Exception ex)
            {
                return ErrorHandler.Handle<GetItemResponse<Contact>>(ex);
            }
        }
Пример #3
0
 public BusinessMessageResponse DeleteAttributeDefinition(IDRequest request)
 {
     var response = new BusinessMessageResponse();
     try
     {
         var entityName = request.GetString("EntityName");
         var attribName = request.GetString("AttributeName");
         return GenericDeleteEntity<AttributeDefinition>("AttributeDefinition", request.ID, entityName, attribName);
     }
     catch (Exception ex)
     {
         response.Status = false;
         response.ErrorCode = ex.StackTrace + ", " + ex.Message;
         response.StatusMessage = ex.StackTrace + ", " + ex.Message;
         return response;
     }
 }
Пример #4
0
 public BusinessMessageResponse SaveMessageViewedByUser(IDRequest request)
 {
     try
     {
         bool deleted = false;
         if (!string.IsNullOrEmpty(request.GetString("deleted")))
             deleted = true;
         object[] properties = new object[]{
             new Guid(request.GetString("userid")),
             new Guid(request.GetString("messageid")),
             deleted
         };
         return GenericSaveEntity<MessageItem>("MessageViewedByUser", properties);
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle(ex);
     }
 }
Пример #5
0
 public GetItemResponse<Route> GetRouteByExternalID(IDRequest request)
 {
     try
     {
         bool includeInactive = request.HasSome(RetrievalOptions.IncludeInactive);
         Guid companyID = request.CompanyID;
         string externalID = request.GetString("ExternalID");
         return ImardaDatabase.GetItem<Route>("SPGetRouteByExternalID", request.ID, includeInactive, externalID);
     }
     catch (Exception ex)
     {
         return ErrorHandler.Handle<GetItemResponse<Route>>(ex);
     }
 }
Пример #6
0
        public GetListResponse<Contact> SearchContactList(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);
                string searchContent = request.GetString("SearchContent") ?? "";
                using (IDataReader dr = db.ExecuteDataReader("SPSearchContactList", includeInactive, request.CompanyID, topn, contactType, searchContent))
                {
                    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);
            }
        }
        /// <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);
            }
        }