public ActionResult AddOrEdit(MVCContactModel mvcContactModel)
        {
            mvcContactModel.Addeddate = Convert.ToDateTime(DateTime.Now.ToShortDateString());

            if (mvcContactModel.ContactsId == null)
            {
                mvcContactModel.Company_Id = Convert.ToInt32(Session["CompayID"]);
                mvcContactModel.UserId     = 1;
                mvcContactModel.Addeddate  = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                mvcContactModel.Type       = mvcContactModel.Type;
                HttpResponseMessage response = GlobalVeriables.WebApiClient.PostAsJsonAsync("ApiConatacts", mvcContactModel).Result;
                return(Json(response.StatusCode, JsonRequestBehavior.AllowGet));
            }
            else
            {
                mvcContactModel.UserId    = 1;
                mvcContactModel.Addeddate = Convert.ToDateTime(System.DateTime.Now.ToShortDateString());
                HttpResponseMessage response   = GlobalVeriables.WebApiClient.PutAsJsonAsync("ApiConatacts/" + mvcContactModel.ContactsId, mvcContactModel).Result;
                HttpResponseMessage directory  = GlobalVeriables.WebApiClient.GetAsync("CheckForDirectoryExist/" + mvcContactModel.ContactsId).Result;
                DirectoryTable      _Directory = new DirectoryTable();
                if (directory.StatusCode == System.Net.HttpStatusCode.OK)
                {
                }
                else
                {
                    _Directory.IsActive      = true;
                    _Directory.DirectoryPath = CreatDirectoryClass.CreateDirecotyFolder((int)mvcContactModel.ContactsId, mvcContactModel.ContactName, "Client");
                    _Directory.RefrenceId    = mvcContactModel.ContactsId;

                    HttpResponseMessage directoryResponse = GlobalVeriables.WebApiClient.PostAsJsonAsync("CreateDirecoty", _Directory).Result;
                }
            }

            return(RedirectToAction("Index"));
        }
示例#2
0
        public static void PerformanceTestMixed()
        {
            try
            {
                System.IO.Directory.Delete(CurrentDirectory + "/Persons2", true);
                System.IO.Directory.Delete(CurrentDirectory + "/Persons3", true);
            }
            catch { }
            var Persons2 = new DirectoryTable <Person2, string>(
                CurrentDirectory + "/Persons2",
                (person) => person.Name, false, true);
            var count = 1000000;
            Array <ActionOn> Actions = new Array <ActionOn>();

            for (int i = 0; i < count; i++)
            {
                var CurrentAction = new ActionOn()
                {
                    Id = i
                };
                CurrentAction.Insert = true;
                //CurrentAction.Update = true;
                CurrentAction.Delete = true;
                Actions.Insert(CurrentAction);
            }

            Array <string> Inserted = new Array <string>();
            Random         random   = new Random();

            while (Actions.Length > 0)
            {
                var i  = random.Next(0, Actions.Length - 1);
                var Ac = Actions[i];
                if (Ac.Insert)
                {
                    Persons2.Insert((c) => c.Name = Ac.Id.ToString());
                    Ac.Insert = false;
                }
                else if (Ac.Update)
                {
                    Persons2.Update((c) => c.Name = Ac.Id.ToString(), (c) => c.id = Ac.Id);
                    Ac.Update = false;
                }
                else
                {
                    Persons2.Delete((c) => c.Name = Ac.Id.ToString());
                    Actions.DeleteByPosition(i);
                }
            }

            Console.ReadKey();
        }
        /// <summary>
        /// Adds a resource directory and all its sub entries to the buffer.
        /// </summary>
        /// <param name="directory">The directory to ad..</param>
        public void AddDirectory(IResourceDirectory directory)
        {
            DirectoryTable.AddEntry(directory);
            if (directory.Name != null)
            {
                NameTable.AddEntry(directory.Name);
            }

            foreach (var entry in directory.Entries)
            {
                AddEntry(entry);
            }
        }
示例#4
0
 public void AddDirectory(ImageResourceDirectory directory, int level)
 {
     // TODO: add entry names
     DirectoryTable.AddResourceDirectory(directory, level);
     foreach (var entry in directory.Entries)
     {
         if (entry.HasData)
         {
             DataDirectoryTable.AddDataEntry(entry.DataEntry);
             DataTable.GetDataSegment(entry.DataEntry);
         }
         else
         {
             AddDirectory(entry.SubDirectory, level + 1);
         }
     }
 }
示例#5
0
文件: Fat.cs 项目: vrilly/FatBoy
        public void writeImage()
        {
            foreach (HeaderObject element in VolumeBootRecord)
            {
                element.write(imageFile);
            }

            clusterMap     = new ClusterMap(files.ToArray());
            directoryTable = new DirectoryTable(files.ToArray());
            clusterMap.write(imageFile);
            directoryTable.write(imageFile, 0x2600);
            imageFile.Seek((2880 * 512) - 1, SeekOrigin.Begin);
            imageFile.WriteByte(0x00);
            foreach (FatFile file in files)
            {
                file.writeFileToImage(imageFile);
            }
        }
        public IHttpActionResult POSTtDirEctory(DirectoryTable _directory)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.DirectoryTables.Add(_directory);
                    db.SaveChanges();
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(NotFound());

                throw ex;
            }
        }
示例#7
0
        public static void Test()
        {
            //PerformanceTest();
            try { System.IO.File.Delete(CurrentDirectory + "/Persons/Data"); } catch { }
            try { System.IO.File.Delete(CurrentDirectory + "/Persons/PK"); } catch { }
            try { System.IO.File.Delete(CurrentDirectory + "/Products/Data"); } catch { }
            try { System.IO.File.Delete(CurrentDirectory + "/Products/PK"); } catch { }

            var Persons = new DirectoryTable <Person, string>(
                CurrentDirectory + "/Persons",
                (person) => person.Name, true, true);

            var Products = new DirectoryTable <Product, string>(
                CurrentDirectory + "/Products",
                (Product) => (string)Product.Name, true, true);

            //(Products.Relation((c) => c.Person_1_1), Persons.Relation((c) => c.Product_1_1)).Join();//1 to 1
            (Products.Relation((c) => c.Persons_M_N), Persons.Relation((c) => c.Products_M_N)).Join(); //m to n
                                                                                                       //(Products.Relation((c) => c.Person_1_X), Persons.Relation((c) => c.Products_X_1)).Join();// 1 to n

            var X = Persons.AsEnumerable().ToArray();
            var Y = Products.AsEnumerable().ToArray();


            Persons.Delete();
            Products.Delete();


            Persons.Insert((c) => c.Name = "ali");

            Products.Insert((c) =>
            {
                c.Name = "p1";
            });

            Products.GetItem((c) => c.Name = "p1").Value.
            Persons_M_N.Accept("ali");    //m to n

            //Products.Update((c) => c.Name = "p1", (c) =>
            //{
            //    c.Person_1_1.Key = "ali";
            //});//1 to 1
            //Products.Update((c) => c.Name = "p1",
            //    (c) => c.Person_1_X.Value = Persons.GetItem((c2) => c2.Name = "ali"));//n to 1
            //                                                                          //Persons.GetItem("ali").Value.
            //                                                                          //    Products_X_1.Accept(Products.GetItem(0));



            //Products.Delete();
            //Persons.Delete();

            Products.Update((c) => c.Name = "p2");
            Persons.Update((c) => c.Name  = "ahmad");

            var Ips1 = Persons.First();
            var Ipr1 = Products.GetItem(0);

            //Products.Delete(0);
            //Products.Update((c) => c.Name = "p2");
            //Persons.Update((c) => c.Name = "ahmad");

            var Ipr = Products.GetItem(0);

            //var Ips = Persons.First();

            //Console.WriteLine(Ipr.Person_1_1.Value.Name);
            //Console.WriteLine(Ips.Product_1_1.Value.Name);

            //Console.WriteLine(Ips.Products_M_N.First().Name);
            //Console.WriteLine(Ipr.Persons_M_N.First().Name);

            X = Persons.AsEnumerable().ToArray();

            Console.ReadKey();
        }
示例#8
0
        public static void PerformanceTest()
        {
            try
            {
                System.IO.Directory.Delete(CurrentDirectory + "/Persons2", true);
                System.IO.Directory.Delete(CurrentDirectory + "/Persons3", true);
            }
            catch { }
            var Persons = new DirectoryTable <Person2, string>(
                CurrentDirectory + "/Persons2",
                (person) => person.Name, false, true);
            var Count = 10000;

            var InsertTime = Timing.run(() =>
            {
                for (int i = Count - 1; i > -1; i--)
                {
                    Persons.Insert((c) => { c.Name = i.ToString(); c.id = i; });
                }
            });

            var Inserts_Per_Second     = (int)(Count / InsertTime.TotalSeconds);
            var EveryInsert            = (InsertTime.TotalSeconds / Count).ToString("0.##########");
            var EveryInsert_Milisecond = ((InsertTime.TotalSeconds / Count) * 1000).ToString("0.##########");

            var UpdateTime = Timing.run(() =>
            {
                for (int i = 0; i < Count; i++)
                {
                    Persons.Update((c) => { c.Name = i.ToString(); c.id = i; }, (c) => { c.Name = i.ToString(); c.id = i; });
                }
            });
            var Update1_Per_Second = (int)(Count / UpdateTime.TotalSeconds);

            var UpdateTime2 = Timing.run(() =>
            {
                for (int i = 0; i < Count; i++)
                {
                    Persons.Update(new Person2()
                    {
                        Name = i.ToString(), id = i
                    }, (c) => { c.Name = i.ToString(); c.id = i; });
                }
            });
            var Update2_Per_Second = (int)(Count / UpdateTime2.TotalSeconds);

            var GetTime = Timing.run(() =>
            {
                for (int i = 0; i < Count; i++)
                {
                    var c = Persons.GetItem(i);
                    if (c == null)
                    {
                        throw new Exception();
                    }
                }
            });
            var GetT_Per_Second = (int)(Count / GetTime.TotalSeconds);

            var DeleteTime = Timing.run(() =>
            {
                for (int i = 0; i < Count; i++)
                {
                    Persons.Delete(new Person2()
                    {
                        Name = i.ToString()
                    });
                }
            });
            var Delete_Per_Second = (int)(Count / DeleteTime.TotalSeconds);

            Console.ReadKey();
        }
示例#9
0
        public static void Test2()
        {
            //PerformanceTest();
            System.IO.Directory.Delete(CurrentDirectory + "/Test2/", true);

            var Persons = new DirectoryTable <Person, string>(
                CurrentDirectory + "/Test2/Persons",
                (person) => person.Name, true, true);

            var Products = new DirectoryTable <Product, string>(
                CurrentDirectory + "/Test2/Products",
                (Product) => (string)Product.Name, true, true);

            var Products2 = new DirectoryTable <Product2, string>(
                CurrentDirectory + "/Test2/Products2",
                (Product) => (string)Product.Name, true, true);


            (Products.Relation((c) => c.Persons_M_N), Persons.Relation((c) => c.Products_M_N)).
            Join();    //m to n



            (Products2.Relation((c) => c.Persons_M_N),
             Persons.Relation((c) => c.Products)).
            Join(Products, (c) => c.Persons_M_N, (c) => c.Product2);    // 1 to n
            (Products2.Relation((c) => c.Product), Products.Relation((c) => c.Product2)).
            Join(Persons, (c) => c.Products_M_N, (c) => c.Products);    // 1 to n

            RelationItemInfo.ReadyFill();

            Persons.Delete();
            Products.Delete();


            Persons.Insert((c) => c.Name = "ali");

            Products.Insert((c) =>
            {
                c.Name = "p1";
            });
            Products2.Insert((c) =>
            {
                c.Name = "p2";
            });

            Products.GetItem((c) => c.Name = "p1").Value.
            Persons_M_N.Accept("ali");    //m to n
            Products.GetItem((c) => c.Name = "p1").Value.
            Product2.Accept("p2");        //m to n


            var Ips1 = Persons.First();
            var Ipr1 = Products.GetItem(0);

            //Products.Delete(0);
            //Products.Update((c) => c.Name = "p2");
            //Persons.Update((c) => c.Name = "ahmad");

            var Ipr = Products2.GetItem(0);

            //var Ips = Persons.First();

            //Console.WriteLine(Ipr.Person_1_1.Value.Name);
            //Console.WriteLine(Ips.Product_1_1.Value.Name);

            //Console.WriteLine(Ips.Products_M_N.First().Name);
            //Console.WriteLine(Ipr.Persons_M_N.First().Name);

            Console.ReadKey();
        }
示例#10
0
 /// <summary>
 /// Construct a CachingBuilder.
 /// </summary>
 public CachingBuilder(DirectoryTable table, NameTable.Builder pathTableBuilder) : base(table)
 {
     PathTableBuilder = pathTableBuilder;
 }