예제 #1
0
        public static async Task <dynamic> UpdateChannel(string id, string address, string comment)
        {
            CommunicationServiceProxy csvc = new CommunicationServiceProxy();
            Communication             c    = await csvc.LoadEntityByKeyAsync(Cntx, id);

            if (c == null)
            {
                return new { ok = false, msg = ResourceUtils.GetString("2d092e365fe439f4e11223a6aac685df", "Channel not found!") }
            }
            ;
            c.Comment = await csvc.LoadEntityCommentAsync(Cntx, c.ID);

            c.IsCommentLoaded = true;
            c.AddressInfo     = address;
            c.Comment         = comment;
            if (c.IsAddressInfoModified || c.IsCommentModified)
            {
                var result = await csvc.AddOrUpdateEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });

                if ((result.ChangedEntities[0].OpStatus & (int)EntityOpStatus.Updated) > 0)
                {
                    return new { ok = true, msg = "" }
                }
                ;
                else
                {
                    return new { ok = false, msg = ResourceUtils.GetString("2cf8b4eaefa665e42735c359a1072a9c", "Update failed!") }
                };
            }
            else
            {
                return new { ok = true, msg = "" }
            };
        }
예제 #2
0
        public static async Task <dynamic> AddChannel(string id, int typeId, string address, string comment)
        {
            CommunicationServiceProxy csvc = new CommunicationServiceProxy();
            Communication             c    = new Communication();

            c.ID            = Guid.NewGuid().ToString();
            c.TypeID        = typeId;
            c.UserID        = id;
            c.ApplicationID = ApplicationContext.App.ID;
            c.AddressInfo   = address;
            c.Comment       = comment;
            var result = await csvc.AddOrUpdateEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });

            if ((result.ChangedEntities[0].OpStatus & (int)EntityOpStatus.Added) > 0)
            {
                c = result.ChangedEntities[0].UpdatedItem;
                c.CommunicationTypeRef = await csvc.MaterializeCommunicationTypeRefAsync(Cntx, c);

                var dc = new { id = c.ID, label = c.DistinctString, addr = c.AddressInfo, comment = c.Comment, typeId = c.CommunicationTypeRef.TypeName };
                return(new { ok = true, msg = "", data = dc });
            }
            else
            {
                return new { ok = false, msg = ResourceUtils.GetString("954122aa46fdc842a03ed8b89acdd125", "Add failed!") }
            };
        }
예제 #3
0
 public ServicesViewModel(IMessageService <bool> messageService) : base(messageService)
 {
     try
     {
         _tokens = new Dictionary <ServiceDescriptionDto, CancellationTokenSource>();
         _proxy  = new CommunicationServiceProxy(this);
         _proxy.ExecuteAsync(p => p.GetServicesInfo());
     }
     catch (Exception ex)
     {
         MessageService.ShowError(ex.Message);
     }
 }
예제 #4
0
        public static async Task <dynamic> DeleteChannel(string id)
        {
            CommunicationServiceProxy csvc = new CommunicationServiceProxy();
            Communication             c    = await csvc.LoadEntityByKeyAsync(Cntx, id);

            if (c == null)
            {
                return new { ok = false, msg = ResourceUtils.GetString("2d092e365fe439f4e11223a6aac685df", "Channel not found!") }
            }
            ;
            await csvc.DeleteEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });

            return(new { ok = true, msg = "" });
        }
    }
예제 #5
0
        public static async Task <UserDetailsVM> GetUserDetails(string id, bool direct = false)
        {
            UserDetailServiceProxy udsvc = new UserDetailServiceProxy();
            var cntx = Cntx;

            cntx.DirectDataAccess = direct;

            var details = await udsvc.LoadEntityByKeyAsync(cntx, GuidMix(ApplicationContext.App.ID, id));

            UserDetailsVM m = null;

            if (details != null)
            {
                if (!details.IsDescriptionLoaded)
                {
                    details.Description         = udsvc.LoadEntityDescription(cntx, GuidMix(ApplicationContext.App.ID, id));
                    details.IsDescriptionLoaded = true;
                }
                m = new UserDetailsVM {
                    Details = details
                };
                m.IsPhotoAvailable = !string.IsNullOrEmpty(details.PhotoMime);
            }
            else
            {
                m = new UserDetailsVM();
                m.IsPhotoAvailable = false;
            }
            UserDetailSet uds = new UserDetailSet();

            m.Genders = uds.GenderValues;
            QueryExpresion qexpr = new QueryExpresion();

            qexpr.OrderTks = new List <QToken>(new QToken[] {
                new QToken {
                    TkName = "ID"
                },
                new QToken {
                    TkName = "asc"
                }
            });
            CommunicationTypeServiceProxy ctsvc = new CommunicationTypeServiceProxy();
            var lct = await ctsvc.QueryDatabaseAsync(Cntx, new CommunicationTypeSet(), qexpr);

            m.ChannelTypes = lct.ToArray();
            CommunicationServiceProxy csvc = new CommunicationServiceProxy();
            var fkeys = new CommunicationSetConstraints
            {
                ApplicationIDWrap = new ForeignKeyData <string> {
                    KeyValue = ApplicationContext.App.ID
                },
                TypeIDWrap = null, // no restriction on types
                UserIDWrap = new ForeignKeyData <string> {
                    KeyValue = id
                }
            };
            var lc = await csvc.ConstraintQueryAsync(Cntx, new CommunicationSet(), fkeys, null);

            foreach (var c in lc)
            {
                c.Comment = await csvc.LoadEntityCommentAsync(Cntx, c.ID);

                c.IsCommentLoaded      = true;
                c.CommunicationTypeRef = await csvc.MaterializeCommunicationTypeRefAsync(Cntx, c);

                m.Channels.Add(new { id = c.ID, label = c.DistinctString, addr = c.AddressInfo, comment = c.Comment, typeId = c.CommunicationTypeRef.TypeName });
            }
            return(m);
        }
예제 #6
0
 public static async Task<UserDetailsVM> GetUserDetails(string id, bool direct = false)
 {
     UserDetailServiceProxy udsvc = new UserDetailServiceProxy();
     var cntx = Cntx;
     cntx.DirectDataAccess = direct;
     var details = await udsvc.LoadEntityByKeyAsync(cntx, ApplicationContext.App.ID, id);
     UserDetailsVM m = null;
     if (details != null)
     {
         if (!details.IsDescriptionLoaded)
         {
             details.Description = udsvc.LoadEntityDescription(cntx, ApplicationContext.App.ID, id);
             details.IsDescriptionLoaded = true;
         }
         m = new UserDetailsVM { Details = details };
         m.IsPhotoAvailable = !string.IsNullOrEmpty(details.PhotoMime);
     }
     else
     {
         m = new UserDetailsVM();
         m.IsPhotoAvailable = false;
     }
     UserDetailSet uds = new UserDetailSet();
     m.Genders = uds.GenderValues;
     QueryExpresion qexpr = new QueryExpresion();
     qexpr.OrderTks = new List<QToken>(new QToken[] { 
         new QToken { TkName = "ID" },
         new QToken { TkName = "asc" }
     });
     CommunicationTypeServiceProxy ctsvc = new CommunicationTypeServiceProxy();
     var lct = await ctsvc.QueryDatabaseAsync(Cntx, new CommunicationTypeSet(), qexpr);
     m.ChannelTypes = lct.ToArray();
     CommunicationServiceProxy csvc = new CommunicationServiceProxy();
     //qexpr = new QueryExpresion();
     //qexpr.OrderTks = new List<QToken>(new QToken[] { 
     //    new QToken { TkName = "TypeID" },
     //    new QToken { TkName = "asc" }
     //});
     //qexpr.FilterTks = new List<QToken>(new QToken[] { 
     //    new QToken { TkName = "UserID" },
     //    new QToken { TkName = "==" },
     //    new QToken { TkName = "\"" + id + "\"" },
     //    new QToken { TkName = "&&" },
     //    new QToken { TkName = "ApplicationID" },
     //    new QToken { TkName = "==" },
     //    new QToken { TkName = "\"" + ApplicationContext.App.ID + "\"" }
     //});
     //var lc = await csvc.QueryDatabaseAsync(Cntx, new CommunicationSet(), qexpr);
     var fkeys = new CommunicationSetConstraints
     {
         ApplicationIDWrap = new ForeignKeyData<string> { KeyValue = ApplicationContext.App.ID },
         TypeIDWrap = null, // no restriction on types
         UserIDWrap = new ForeignKeyData<string> { KeyValue = id }
     };
     var lc = await csvc.ConstraintQueryAsync(Cntx, new CommunicationSet(), fkeys, null);
     foreach (var c in lc)
     {
         c.Comment = await csvc.LoadEntityCommentAsync(Cntx, c.ID);
         c.IsCommentLoaded = true;
         c.CommunicationTypeRef = await csvc.MaterializeCommunicationTypeRefAsync(Cntx, c);
         m.Channels.Add(new { id = c.ID, label = c.DistinctString, addr = c.AddressInfo, comment = c.Comment, typeId = c.CommunicationTypeRef.TypeName });
     }
     return m;
 }
예제 #7
0
 public static async Task<dynamic> DeleteChannel(string id)
 {
     CommunicationServiceProxy csvc = new CommunicationServiceProxy();
     Communication c = await csvc.LoadEntityByKeyAsync(Cntx, id);
     if (c == null)
         return new { ok = false, msg = ResourceUtils.GetString("2d092e365fe439f4e11223a6aac685df", "Channel not found!") };
     await csvc.DeleteEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });
     return new { ok = true, msg = "" };
 }
예제 #8
0
 public static async Task<dynamic> UpdateChannel(string id, string address, string comment)
 {
     CommunicationServiceProxy csvc = new CommunicationServiceProxy();
     Communication c = await csvc.LoadEntityByKeyAsync(Cntx, id);
     if (c == null)
         return new { ok = false, msg = ResourceUtils.GetString("2d092e365fe439f4e11223a6aac685df", "Channel not found!") };
     c.Comment = await csvc.LoadEntityCommentAsync(Cntx, c.ID);
     c.IsCommentLoaded = true;
     c.AddressInfo = address;
     c.Comment = comment;
     if (c.IsAddressInfoModified || c.IsCommentModified)
     {
         var result = await csvc.AddOrUpdateEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });
         if ((result.ChangedEntities[0].OpStatus & (int)EntityOpStatus.Updated) > 0)
             return new { ok = true, msg = "" };
         else
             return new { ok = false, msg = ResourceUtils.GetString("2cf8b4eaefa665e42735c359a1072a9c", "Update failed!") };
     }
     else
         return new { ok = true, msg = "" };
 }
예제 #9
0
 public static async Task<dynamic> AddChannel(string id, int typeId, string address, string comment)
 {
     CommunicationServiceProxy csvc = new CommunicationServiceProxy();
     Communication c = new Communication();
     c.ID = Guid.NewGuid().ToString();
     c.TypeID = typeId;
     c.UserID = id;
     c.ApplicationID = ApplicationContext.App.ID;
     c.AddressInfo = address;
     c.Comment = comment;
     var result = await csvc.AddOrUpdateEntitiesAsync(Cntx, new CommunicationSet(), new Communication[] { c });
     if ((result.ChangedEntities[0].OpStatus & (int)EntityOpStatus.Added) > 0)
     {
         c = result.ChangedEntities[0].UpdatedItem;
         c.CommunicationTypeRef = await csvc.MaterializeCommunicationTypeRefAsync(Cntx, c);
         var dc = new { id = c.ID, label = c.DistinctString, addr = c.AddressInfo, comment = c.Comment, typeId = c.CommunicationTypeRef.TypeName };
         return new { ok = true, msg = "", data = dc };
     }
     else
         return new { ok = false, msg = ResourceUtils.GetString("954122aa46fdc842a03ed8b89acdd125", "Add failed!") };
 }