Пример #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 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 = "" };
 }
Пример #4
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!") };
 }