예제 #1
0
        public GovernorProxy(Svc.Governor dto)
            : base()
        {
            if (dto == null)
            {
                throw new InvalidOperationException("Governor dto");
            }

            this.Id        = dto.Id;
            this.CompanyId = dto.CompanyId;
            this.Company   = ProxyActivator.CreateProxy <Svc.Company, Company>(dto.Company);
            this.ShortName = dto.ShortName;

            this._dto             = dto;
            this.PropertyChanged += ProxyActivator.ReflectChangedProperty;
        }
예제 #2
0
파일: Program.cs 프로젝트: koder05/fogel-ba
        static void Main(string[] args)
        {
            OAuthProvider.Behavior = Activator.CreateInstance(OAuthConfiguration.Configuration.ClientSettings.WcfDSBehaviorType) as IOAuthBehavior;
            Logon.Page = new LogonProc();
            var ctx = new WebApiCtx();
            FilterParameterCollection fc = new FilterParameterCollection();
            fc.Add("ShortName", "магомед ук");
            SortParameterCollection sc = new SortParameterCollection();
            sc.Add(null, "Company.Name", System.ComponentModel.ListSortDirection.Ascending);
            sc.Add(null, "Id", System.ComponentModel.ListSortDirection.Ascending);

            //var val = ctx.Governors.AddFilters(fc).AddOrders(sc).First();
            //var val = ctx.Governors.First();
            //val.Company.lawFormValue = 6;
            Guid g = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505");
            //var val = ctx.Governors.Where(gov => gov.Id == g).FirstOrDefault();
            Guid g2 = new Guid("CEB5254F-5FFE-469B-ABC5-09AB388E6505");
            Governor val2 = null;
            //ctx.TryGetEntity(new Uri("http://localhost:555/Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')"), out val2);
            //Governor val2 = ctx.Governors.Where(gov => gov.Id == g2).FirstOrDefault();
            //val2 = ctx.Entities.FirstOrDefault(e => e.Identity.Contains("Governors(guid'ceb5254f-5ffe-469b-abc5-09ab388e6505')")).Entity as Governor;
            //val2 = ctx.Governors.GetById(g);

            ctx.Governors.ToList();

            //Console.WriteLine(ctx.Governors.TotalCount());

            //var ass = ctx.Assets.Where(a => a.Id == new Guid("D3B67671-87C5-4B33-8DF1-7D83947E5FB8")).First();

            var ass = new AssetValue();
            ass.Id = Guid.NewGuid();
            ass.InsuranceTypeValue = 1;
            ass.TakingDate = DateTime.Today;
            ass.Value = 3344434.56m;
            ass.GovernorId = g2;

            string s = JsonConvert.SerializeObject(ass);
            var list = new List<string>();
            list.Add(s);

            UriBuilder urib = new UriBuilder(ctx.BaseUri);
            //urib.Path = string.Format("{0}/CreateBatch", ctx.Assets.RequestUri.PathAndQuery);
            //var r = ctx.Execute<bool>(urib.Uri, "POST", true, new BodyOperationParameter("Values", list)).FirstOrDefault();

            //ctx.AddToAssets(ass);
            //ctx.SetLink(ass, "Governor", val2);

            //ctx.SaveChanges();
            //ctx.AttachLink(ass, "Governor", val2);

            //Guid g = new Guid("32D3F7C1-97E1-4A69-8C8A-E3706490329E");
            //var val = ctx.Holidays.Where(h => h.Id == g).FirstOrDefault();

            //val.Comment = "Test Comment";


            var newc = new Company();
            newc.Id = Guid.NewGuid();
            newc.Name = "Test Governor Company Name";
            var newg = new Governor();
            newg.Id = Guid.NewGuid();
            newg.ShortName = "Test Governor Name";
            newg.Company = newc;
            ctx.AddToGovernors(newg);
            ctx.SaveChanges();
            newg.ShortName = "Test Governor Name Updated";
            ctx.UpdateObject(newg);
            //ctx.SaveChanges(SaveChangesOptions.PatchOnUpdate);
            System.Threading.Thread.Sleep(1000);
            ctx.SaveChanges(SaveChangesOptions.ReplaceOnUpdate);
            ctx.DeleteObject(newg);
            ctx.SaveChanges();

            //var serviceCreds = new NetworkCredential("Administrator", "SecurePassword");
            //var cache = new CredentialCache();
            //var serviceUri = new Uri("http://ipv4.fiddler:333/api/issue");
            //cache.Add(serviceUri, "Basic", serviceCreds);
            //ctx.Credentials = cache;
            //var r = ctx.Execute(new Uri("http://ipv4.fiddler:333/api/issue"), "POST", new BodyOperationParameter("rst", new TokenRequest() { GrantType = "client_credentials", Scope = "http://localhost" }));
            Console.ReadLine();
        }