コード例 #1
0
        public ActionResult DeleteLinkTable(IEnumerable <LinkTableViewModel> models)
        {
            var datasource = new DataSource <LinkTableViewModel>();

            if (ModelState.IsValid)
            {
                foreach (LinkTableViewModel model in models)
                {
                    var link = new LinkTable
                    {
                        Id = model.Id
                    };

                    _hrUnitOfWork.SalaryDesignRepository.Remove(link);
                }

                datasource.Errors = SaveChanges(Language);
                datasource.Total  = models.Count();
            }

            datasource.Data = models;

            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }
コード例 #2
0
        public void TestMissingExternSheetRecord_bug47001b()
        {
            Record[] recs =
            {
                SupBookRecord.CreateAddInFunctions(),
                new SSTRecord(),
            };
            List <Record>      recList = new List <Record>(recs);
            WorkbookRecordList wrl     = new WorkbookRecordList();

            LinkTable lt;

            try
            {
                lt = new LinkTable(recList, 0, wrl, new Dictionary <String, NameCommentRecord>());
            }
            catch (Exception e)
            {
                if (e.Message.Equals("Expected an EXTERNSHEET record but got (Npoi.Core.HSSF.record.SSTRecord)"))
                {
                    throw new AssertionException("Identified bug 47001b");
                }

                throw e;
            }
            Assert.IsNotNull(lt);
        }
コード例 #3
0
        public Npc(ShineNpc spoint)
        {
            IsAttackable = false;
            Point        = spoint;
            LinkTable lt = null;

            if (Point.Role == "Gate" && !DataProvider.Instance.NpcLinkTable.TryGetValue(spoint.RoleArg0, out lt))
            {
                Log.WriteLine(LogLevel.Warn, "Could not load LinkTable for NPC {0} LT {1}", Point.MobName,
                              Point.RoleArg0);
            }

            Gate = lt;

            ID       = DataProvider.Instance.GetMobIDFromName(Point.MobName);
            Position = new Vector2(spoint.CoordX, spoint.CoordY);
            if (spoint.Direct < 0)
            {
                Rotation = (byte)((360 + spoint.Direct) / 2);
            }
            else
            {
                Rotation = (byte)(spoint.Direct / 2);
            }
        }
コード例 #4
0
 public void Remove(LinkTable Link)
 {
     if (Context.Entry(Link).State == EntityState.Detached)
     {
         context.LinkTables.Attach(Link);
     }
     context.LinkTables.Remove(Link);
 }
コード例 #5
0
        //сохранение
        public async void AddItem(string longLink, string shortLink)
        {
            LinkTable newItem = new LinkTable();

            newItem.Longlink  = longLink;
            newItem.Shortlink = shortLink.ToString();
            newItem.Date      = DateTime.Now;
            newItem.Count     = 0;
            await linkscontext.Create(newItem);
        }
コード例 #6
0
ファイル: DBConnect.cs プロジェクト: liambrozik/SearchEngine
        public static CloudTable GetLinkTable()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"]);

            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

            LinkTable = tableClient.GetTableReference("linktable");
            LinkTable.CreateIfNotExists();

            return(LinkTable);
        }
コード例 #7
0
        /// <summary>
        /// Returns object1 from a link table entity given a Ria services change set and a find method.
        /// </summary>
        /// <typeparam name="TObject1"></typeparam>
        /// <typeparam name="TObject2"></typeparam>
        /// <param name="linkTableEntity"></param>
        /// <param name="changeSet"></param>
        /// <param name="find">function to find and retrieve an entity in a repository.</param>
        /// <returns></returns>
        public static TObject1 FetchObject1 <TObject1, TObject2>(
            this LinkTable <TObject1, TObject2> linkTableEntity, ChangeSet changeSet,
            Func <object[], TObject1> find)
            where TObject1 : class
            where TObject2 : class
        {
            var properties           = TypeDescriptor.GetProperties(linkTableEntity.GetType());
            var navProp              = properties["Object1"];
            var associationAttribute =
                navProp.Attributes.OfType <AssociationAttribute>().SingleOrDefault();

            return(Find(
                       linkTableEntity, linkTableEntity.Object1, changeSet, find, associationAttribute));
        }
コード例 #8
0
        /// <summary>
        /// Returns object1 from a link table entity given a Ria services change set and an EntityFramework DbContext.
        /// </summary>
        /// <typeparam name="TObject1"></typeparam>
        /// <typeparam name="TObject2"></typeparam>
        /// <param name="linkTableEntity"></param>
        /// <param name="changeSet"></param>
        /// <param name="dbContext"></param>
        /// <returns></returns>
        public static TObject1 FetchObject1 <TObject1, TObject2>(
            this LinkTable <TObject1, TObject2> linkTableEntity, ChangeSet changeSet,
            System.Data.Entity.DbContext dbContext)
            where TObject1 : class where TObject2 : class
        {
            var properties           = TypeDescriptor.GetProperties(linkTableEntity.GetType());
            var navProp              = properties["Object1"];
            var associationAttribute =
                navProp.Attributes.OfType <AssociationAttribute>().SingleOrDefault();

            return(Find(
                       linkTableEntity, linkTableEntity.Object1, changeSet, keys => dbContext.Set <TObject1>().Find(keys),
                       associationAttribute));
        }
コード例 #9
0
        //обработка и сохранение изменений
        public async Task <IActionResult> LinkSaved(string id, string LongLinkText, string ShortLinkText)
        {
            LinkTable newItem = new LinkTable();

            newItem.Id        = id;
            newItem.Longlink  = LongLinkText;
            newItem.Shortlink = ShortLinkText;
            newItem.Date      = DateTime.Now;
            await linkscontext.Update(newItem);

            ViewData["saved"] = "Изменения сохранены в " + DateTime.Now.TimeOfDay.ToString("hh\\:mm");
            List <LinkTable> fulltable = linkscontext.GetById(id);

            return(View("Link", fulltable[0]));
        }
コード例 #10
0
 private void SaveGrid2(LinkTableVM grid1, IEnumerable <KeyValuePair <string, ModelState> > state, InfoTable info)
 {
     if (grid1.inserted != null)
     {
         foreach (LinkTableViewModel model in grid1.inserted)
         {
             var range = new LinkTable();
             AutoMapper(new Models.AutoMapperParm {
                 Destination = range, Source = model
             });
             range.CreatedTime = DateTime.Now;
             range.CreatedUser = UserName;
             _hrUnitOfWork.SalaryDesignRepository.AddLinkTable(range);
         }
     }
 }
コード例 #11
0
        public void TestNameCommentRecordBetweenNameRecords()
        {
            Record[] recs =
            {
                new NameRecord(),
                new NameCommentRecord("name1","comment1"),
                new NameRecord(),
                new NameCommentRecord("name2","comment2"),
            };
            List <Record>      recList = new List <Record>(recs);
            WorkbookRecordList wrl     = new WorkbookRecordList();
            Dictionary <String, NameCommentRecord> commentRecords = new Dictionary <String, NameCommentRecord>();

            LinkTable lt = new LinkTable(recList, 0, wrl, commentRecords);

            Assert.IsNotNull(lt);

            Assert.AreEqual(2, commentRecords.Count);
            Assert.IsTrue(recs[1] == commentRecords["name1"]); //== is intentionally not .Equals()!
            Assert.IsTrue(recs[3] == commentRecords["name2"]); //== is intentionally not .Equals()!

            Assert.AreEqual(2, lt.NumNames);
        }
コード例 #12
0
        public void TestAddNameX()
        {
            WorkbookRecordList wrl = new WorkbookRecordList();

            wrl.Add(0, new BOFRecord());
            wrl.Add(1, new CountryRecord());
            wrl.Add(2, EOFRecord.instance);

            int       numberOfSheets = 3;
            LinkTable tbl            = new LinkTable(numberOfSheets, wrl);

            // creation of a new LinkTable insert two new records: SupBookRecord followed by ExternSheetRecord
            // assure they are in place:
            //    [BOFRecord]
            //    [CountryRecord]
            //    [SUPBOOK Internal References  nSheets= 3]
            //    [EXTERNSHEET]
            //    [EOFRecord]

            Assert.AreEqual(5, wrl.Records.Count);
            Assert.IsTrue(wrl[(2)] is SupBookRecord);
            SupBookRecord sup1 = (SupBookRecord)wrl[(2)];

            Assert.AreEqual(numberOfSheets, sup1.NumberOfSheets);
            Assert.IsTrue(wrl[(3)] is ExternSheetRecord);
            ExternSheetRecord extSheet = (ExternSheetRecord)wrl[(3)];

            Assert.AreEqual(0, extSheet.NumOfRefs);

            Assert.IsNull(tbl.GetNameXPtg("ISODD", -1));
            Assert.AreEqual(5, wrl.Records.Count);      //still have five records

            NameXPtg namex1 = tbl.AddNameXPtg("ISODD"); // Adds two new rercords

            Assert.AreEqual(0, namex1.SheetRefIndex);
            Assert.AreEqual(0, namex1.NameIndex);
            Assert.AreEqual(namex1.ToString(), tbl.GetNameXPtg("ISODD", -1).ToString());

            // Can only find on the right sheet ref, if restricting
            Assert.AreEqual(namex1.ToString(), tbl.GetNameXPtg("ISODD", 0).ToString());
            Assert.IsNull(tbl.GetNameXPtg("ISODD", 1));
            Assert.IsNull(tbl.GetNameXPtg("ISODD", 2));
            // assure they are in place:
            //    [BOFRecord]
            //    [CountryRecord]
            //    [SUPBOOK Internal References  nSheets= 3]
            //    [SUPBOOK Add-In Functions nSheets= 1]
            //    [EXTERNALNAME .name    = ISODD]
            //    [EXTERNSHEET]
            //    [EOFRecord]

            Assert.AreEqual(7, wrl.Records.Count);
            Assert.IsTrue(wrl[(3)] is SupBookRecord);
            SupBookRecord sup2 = (SupBookRecord)wrl[(3)];

            Assert.IsTrue(sup2.IsAddInFunctions);
            Assert.IsTrue(wrl[(4)] is ExternalNameRecord);
            ExternalNameRecord ext1 = (ExternalNameRecord)wrl[(4)];

            Assert.AreEqual("ISODD", ext1.Text);
            Assert.IsTrue(wrl[(5)] is ExternSheetRecord);
            Assert.AreEqual(1, extSheet.NumOfRefs);

            //check that
            Assert.AreEqual(0, tbl.ResolveNameXIx(namex1.SheetRefIndex, namex1.NameIndex));
            Assert.AreEqual("ISODD", tbl.ResolveNameXText(namex1.SheetRefIndex, namex1.NameIndex, null));

            Assert.IsNull(tbl.GetNameXPtg("ISEVEN", -1));
            NameXPtg namex2 = tbl.AddNameXPtg("ISEVEN");  // Adds two new rercords

            Assert.AreEqual(0, namex2.SheetRefIndex);
            Assert.AreEqual(1, namex2.NameIndex);  // name index increased by one
            Assert.AreEqual(namex2.ToString(), tbl.GetNameXPtg("ISEVEN", -1).ToString());
            Assert.AreEqual(8, wrl.Records.Count);
            // assure they are in place:
            //    [BOFRecord]
            //    [CountryRecord]
            //    [SUPBOOK Internal References  nSheets= 3]
            //    [SUPBOOK Add-In Functions nSheets= 1]
            //    [EXTERNALNAME .name    = ISODD]
            //    [EXTERNALNAME .name    = ISEVEN]
            //    [EXTERNSHEET]
            //    [EOFRecord]
            Assert.IsTrue(wrl[(3)] is SupBookRecord);
            Assert.IsTrue(wrl[(4)] is ExternalNameRecord);
            Assert.IsTrue(wrl[(5)] is ExternalNameRecord);
            Assert.AreEqual("ISODD", ((ExternalNameRecord)wrl[(4)]).Text);
            Assert.AreEqual("ISEVEN", ((ExternalNameRecord)wrl[(5)]).Text);
            Assert.IsTrue(wrl[(6)] is ExternSheetRecord);
            Assert.IsTrue(wrl[(7)] is EOFRecord);

            Assert.AreEqual(0, tbl.ResolveNameXIx(namex2.SheetRefIndex, namex2.NameIndex));
            Assert.AreEqual("ISEVEN", tbl.ResolveNameXText(namex2.SheetRefIndex, namex2.NameIndex, null));
        }
コード例 #13
0
        public void LoadMaps(List <ushort> toload = null)
        {
            MapsByID   = new Dictionary <ushort, MapInfo>();
            MapsByName = new Dictionary <string, MapInfo>();
            DataTable mapDataInf    = null;
            DataTable linktableData = null;
            DataTable shineNpcData  = null;

            using (var dbClient = Program.DatabaseManager.GetClient())
            {
                mapDataInf    = dbClient.ReadDataTable("SELECT  *FROM mapinfo");
                linktableData = dbClient.ReadDataTable("SELECT *FROM LinkTable");
                shineNpcData  = dbClient.ReadDataTable("SELECT *FROM ShineNpc");
            }

            if (mapDataInf != null)
            {
                foreach (DataRow row in mapDataInf.Rows)
                {
                    var info = MapInfo.Load(row);
                    info.NPCs = new List <ShineNpc>();
                    if (MapsByID.ContainsKey(info.ID))
                    {
                        Log.WriteLine(LogLevel.Debug, "Duplicate map ID {0} ({1})", info.ID, info.FullName);
                        MapsByID.Remove(info.ID);
                        MapsByName.Remove(info.ShortName);
                    }

                    if (toload == null || toload.Contains(info.ID))
                    {
                        MapsByID.Add(info.ID, info);
                        MapsByName.Add(info.ShortName, info);
                    }
                }
            }

            Blocks = new Dictionary <ushort, BlockInfo>();
            foreach (var map in MapsByID.Values)
            {
                DataTable blockData = null;
                using (var dbClient = Program.DatabaseManager.GetClient())
                {
                    blockData = dbClient.ReadDataTable("SELECT  *FROM blockinfo WHERE MapID='" + map.ID + "'");
                }

                if (blockData != null)
                {
                    if (blockData.Rows.Count > 0)
                    {
                        foreach (DataRow row in blockData.Rows)
                        {
                            var info = new BlockInfo(row, map.ID);

                            Blocks.Add(map.ID, info);
                        }
                    }
                    else
                    {
                        Log.WriteLine(LogLevel.Warn, "No BlockInfo for Map {0}", map.ShortName);
                    }
                }
            }

            NpcLinkTable = new Dictionary <string, LinkTable>();
            if (linktableData != null)
            {
                foreach (DataRow row in linktableData.Rows)
                {
                    var link = LinkTable.Load(row);
                    if (Program.IsLoaded(GetMapidFromMapShortName(link.MapClient)))
                    {
                        NpcLinkTable.Add(link.argument, link);
                    }
                }
            }

            if (shineNpcData != null)
            {
                foreach (DataRow row in shineNpcData.Rows)
                {
                    var     npc = ShineNpc.Load(row);
                    MapInfo mi  = null;
                    if (Program.IsLoaded(GetMapidFromMapShortName(npc.Map)) && MapsByName.TryGetValue(npc.Map, out mi))
                    {
                        mi.NPCs.Add(npc);
                    }
                }
            }

            Log.WriteLine(LogLevel.Info, "Loaded {0} maps.", MapsByID.Count);
        }
コード例 #14
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            if (!string.IsNullOrWhiteSpace(PropertyName))
            {
                code.AppendLine($@"['PropertyName'] = '{PropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PropertyName'] = nil,");
            }

            code.AppendLine($@"['IsCaption'] ={(IsCaption.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Alias))
            {
                code.AppendLine($@"['Alias'] = '{Alias.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Alias'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Group))
            {
                code.AppendLine($@"['Group'] = '{Group.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Group'] = nil,");
            }

            code.AppendLine($@"['CreateIndex'] ={(CreateIndex.ToString().ToLower())},");

            code.AppendLine($@"['IsPrimaryKey'] ={(IsPrimaryKey.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendKey'] ={(IsExtendKey.ToString().ToLower())},");

            code.AppendLine($@"['IsIdentity'] ={(IsIdentity.ToString().ToLower())},");

            code.AppendLine($@"['IsGlobalKey'] ={(IsGlobalKey.ToString().ToLower())},");

            code.AppendLine($@"['UniqueIndex'] ={UniqueIndex},");

            code.AppendLine($@"['IsRequired'] ={(IsRequired.ToString().ToLower())},");

            code.AppendLine($@"['IsUserReadOnly'] ={(IsUserReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['IsMemo'] ={(IsMemo.ToString().ToLower())},");


            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Prefix))
            {
                code.AppendLine($@"['Prefix'] = '{Prefix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Prefix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Suffix))
            {
                code.AppendLine($@"['Suffix'] = '{Suffix.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Suffix'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(InputType))
            {
                code.AppendLine($@"['InputType'] = '{InputType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['InputType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComboBoxUrl))
            {
                code.AppendLine($@"['ComboBoxUrl'] = '{ComboBoxUrl.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComboBoxUrl'] = nil,");
            }

            code.AppendLine($@"['IsMoney'] ={(IsMoney.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridAlign))
            {
                code.AppendLine($@"['GridAlign'] = '{GridAlign.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridAlign'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DataFormater))
            {
                code.AppendLine($@"['DataFormater'] = '{DataFormater.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataFormater'] = nil,");
            }

            code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},");

            code.AppendLine($@"['GridDetails'] ={(GridDetails.ToString().ToLower())},");

            code.AppendLine($@"['NoneGrid'] ={(NoneGrid.ToString().ToLower())},");

            code.AppendLine($@"['NoneDetails'] ={(NoneDetails.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(GridDetailsCode))
            {
                code.AppendLine($@"['GridDetailsCode'] = '{GridDetailsCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['GridDetailsCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppType))
            {
                code.AppendLine($@"['CppType'] = '{CppType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppType'] = nil,");
            }

            if (CppTypeObject != null)
            {
                code.AppendLine($@"['CppTypeObject'] ='{CppTypeObject}',");
            }

            if (!string.IsNullOrWhiteSpace(CppName))
            {
                code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CppLastType))
            {
                code.AppendLine($@"['CppLastType'] = '{CppLastType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CppLastType'] = nil,");
            }

            code.AppendLine($@"['IsIntDecimal'] ={(IsIntDecimal.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(CsType))
            {
                code.AppendLine($@"['CsType'] = '{CsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CsType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CustomType))
            {
                code.AppendLine($@"['CustomType'] = '{CustomType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CustomType'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(LastCsType))
            {
                code.AppendLine($@"['LastCsType'] = '{LastCsType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LastCsType'] = nil,");
            }

            if (EnumConfig != null)
            {
                code.AppendLine($@"['EnumConfig'] = {EnumConfig.GetLuaStruct()},");
            }

            code.AppendLine($@"['IsCompute'] ={(IsCompute.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ComputeGetCode))
            {
                code.AppendLine($@"['ComputeGetCode'] = '{ComputeGetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeGetCode'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ComputeSetCode))
            {
                code.AppendLine($@"['ComputeSetCode'] = '{ComputeSetCode.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ComputeSetCode'] = nil,");
            }

            code.AppendLine($@"['IsMiddleField'] ={(IsMiddleField.ToString().ToLower())},");

            code.AppendLine($@"['InnerField'] ={(InnerField.ToString().ToLower())},");

            code.AppendLine($@"['IsSystemField'] ={(IsSystemField.ToString().ToLower())},");

            code.AppendLine($@"['IsInterfaceField'] ={(IsInterfaceField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Initialization))
            {
                code.AppendLine($@"['Initialization'] = '{Initialization.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Initialization'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(EmptyValue))
            {
                code.AppendLine($@"['EmptyValue'] = '{EmptyValue.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['EmptyValue'] = nil,");
            }

            code.AppendLine($@"['DenyScope'] ='{DenyScope}',");

            code.AppendLine($@"['Nullable'] ={(Nullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(Max))
            {
                code.AppendLine($@"['Max'] = '{Max.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Max'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(Min))
            {
                code.AppendLine($@"['Min'] = '{Min.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['Min'] = nil,");
            }

            code.AppendLine($@"['UniqueString'] ={(UniqueString.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ColumnName))
            {
                code.AppendLine($@"['ColumnName'] = '{ColumnName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ColumnName'] = nil,");
            }

            code.AppendLine($@"['DbNullable'] ={(DbNullable.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DbType))
            {
                code.AppendLine($@"['DbType'] = '{DbType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbType'] = nil,");
            }

            code.AppendLine($@"['Precision'] ={Datalen},");

            if (!string.IsNullOrWhiteSpace(ArrayLen))
            {
                code.AppendLine($@"['ArrayLen'] = '{ArrayLen.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArrayLen'] = nil,");
            }

            code.AppendLine($@"['Scale'] ={Scale},");

            code.AppendLine($@"['DbIndex'] ={DbIndex},");

            code.AppendLine($@"['Unicode'] ={(Unicode.ToString().ToLower())},");

            code.AppendLine($@"['FixedLength'] ={(FixedLength.ToString().ToLower())},");

            code.AppendLine($@"['IsBlob'] ={(IsBlob.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(StorageProperty))
            {
                code.AppendLine($@"['StorageProperty'] = '{StorageProperty.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['StorageProperty'] = nil,");
            }

            code.AppendLine($@"['DbInnerField'] ={(DbInnerField.ToString().ToLower())},");

            code.AppendLine($@"['NoStorage'] ={(NoStorage.ToString().ToLower())},");

            code.AppendLine($@"['KeepStorageScreen'] ='{KeepStorageScreen}',");

            code.AppendLine($@"['CustomWrite'] ={(CustomWrite.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkField'] ={(IsLinkField.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkTable))
            {
                code.AppendLine($@"['LinkTable'] = '{LinkTable.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkTable'] = nil,");
            }

            code.AppendLine($@"['IsLinkKey'] ={(IsLinkKey.ToString().ToLower())},");

            code.AppendLine($@"['IsLinkCaption'] ={(IsLinkCaption.ToString().ToLower())},");

            code.AppendLine($@"['IsUserId'] ={(IsUserId.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(LinkField))
            {
                code.AppendLine($@"['LinkField'] = '{LinkField.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['LinkField'] = nil,");
            }

            code.AppendLine($@"['IsCustomCompute'] ={(IsCustomCompute.ToString().ToLower())},");

            code.AppendLine($@"['CanGet'] ={(CanGet.ToString().ToLower())},");

            code.AppendLine($@"['CanSet'] ={(CanSet.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(AccessType))
            {
                code.AppendLine($@"['AccessType'] = '{AccessType.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['AccessType'] = nil,");
            }

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            code.AppendLine($@"['CanInput'] ={(CanUserInput.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendRole))
            {
                code.AppendLine($@"['ExtendRole'] = '{ExtendRole.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendRole'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ValueSeparate))
            {
                code.AppendLine($@"['ValueSeparate'] = '{ValueSeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ValueSeparate'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ArraySeparate))
            {
                code.AppendLine($@"['ArraySeparate'] = '{ArraySeparate.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ArraySeparate'] = nil,");
            }

            code.AppendLine($@"['ExtendArray'] ={(ExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsKeyValueArray'] ={(IsKeyValueArray.ToString().ToLower())},");

            code.AppendLine($@"['IsRelation'] ={(IsRelation.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(ExtendPropertyName))
            {
                code.AppendLine($@"['ExtendPropertyName'] = '{ExtendPropertyName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendPropertyName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ExtendClassName))
            {
                code.AppendLine($@"['ExtendClassName'] = '{ExtendClassName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ExtendClassName'] = nil,");
            }

            code.AppendLine($@"['ExtendClassIsPredestinate'] ={(ExtendClassIsPredestinate.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationField'] ={(IsRelationField.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationValue'] ={(IsRelationValue.ToString().ToLower())},");

            code.AppendLine($@"['IsRelationArray'] ={(IsRelationArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendArray'] ={(IsExtendArray.ToString().ToLower())},");

            code.AppendLine($@"['IsExtendValue'] ={(IsExtendValue.ToString().ToLower())},");
        }
コード例 #15
0
        public void LoadMaps(List <ushort> toload = null)
        {
            MapsByID   = new Dictionary <ushort, MapInfo>();
            MapsByName = new Dictionary <string, MapInfo>();
            using (var file = new SHNFile(folder + @"\MapInfo.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MapInfo info = MapInfo.Load(reader);
                        info.NPCs = new List <ShineNPC>();
                        if (MapsByID.ContainsKey(info.ID))
                        {
                            Log.WriteLine(LogLevel.Debug, "Duplicate map ID {0} ({1})", info.ID, info.FullName);
                            MapsByID.Remove(info.ID);
                            MapsByName.Remove(info.ShortName);
                        }
                        if (toload == null || toload.Contains(info.ID))
                        {
                            MapsByID.Add(info.ID, info);
                            MapsByName.Add(info.ShortName, info);
                        }
                    }
                }
            }

            Blocks = new Dictionary <ushort, BlockInfo>();
            foreach (var map in MapsByID.Values)
            {
                string renderpath = folder + @"\BlockInfo\" + map.ShortName + ".shbd";
                if (File.Exists(renderpath))
                {
                    BlockInfo info = new BlockInfo(renderpath, map.ID);
                    Blocks.Add(map.ID, info);
                }
            }


            using (var tables = new ShineReader(folder + @"\NPC.txt"))
            {
                NpcLinkTable = new Dictionary <string, LinkTable>();
                using (DataTableReaderEx reader = new DataTableReaderEx(tables["LinkTable"]))
                {
                    while (reader.Read())
                    {
                        LinkTable link = LinkTable.Load(reader);
                        if (Program.IsLoaded(GetMapidFromMapShortName(link.MapClient)))
                        {
                            NpcLinkTable.Add(link.argument, link);
                        }
                    }
                }

                using (DataTableReaderEx reader = new DataTableReaderEx(tables["ShineNPC"]))
                {
                    while (reader.Read())
                    {
                        ShineNPC npc = ShineNPC.Load(reader);
                        MapInfo  mi  = null;
                        if (Program.IsLoaded(GetMapidFromMapShortName(npc.Map)) && MapsByName.TryGetValue(npc.Map, out mi))
                        {
                            mi.NPCs.Add(npc);
                        }
                    }
                }
            }

            Log.WriteLine(LogLevel.Info, "Loaded {0} maps.", MapsByID.Count);
        }
コード例 #16
0
 public DbEntityEntry <LinkTable> Entry(LinkTable Link)
 {
     return(Context.Entry(Link));
 }
コード例 #17
0
 public void AttachLinkTable(LinkTable Link)
 {
     context.LinkTables.Attach(Link);
 }
コード例 #18
0
 public void AddLinkTable(LinkTable range)
 {
     context.LinkTables.Add(range);
 }
コード例 #19
0
        public ActionResult CreateLinkTable(IEnumerable <LinkTableViewModel> models)
        {
            var result = new List <LinkTable>();

            var datasource = new DataSource <LinkTableViewModel>();

            datasource.Data  = models;
            datasource.Total = models.Count();

            if (ModelState.IsValid)
            {
                if (ServerValidationEnabled)
                {
                    var errors = _hrUnitOfWork.LookUpRepository.Check(new CheckParm
                    {
                        CompanyId    = CompanyId, //CompanyId,
                        ObjectName   = "LinkTables",
                        TableName    = "LinkTables",
                        ParentColumn = "GenTableId",
                        Columns      = Models.Utils.GetModifiedRows(ModelState),
                        Culture      = Language
                    });

                    if (errors.Count() > 0)
                    {
                        datasource.Errors = errors;
                        return(Json(datasource));
                    }
                }
                foreach (LinkTableViewModel c in models)
                {
                    var Link = new LinkTable
                    {
                        Id           = c.Id,
                        GenTableId   = c.GenTableId,
                        Basis        = c.Basis,
                        CellValue    = c.CellValue,
                        CreditGlAccT = c.CreditGlAccT != 0 ? c.CreditGlAccT :null,
                        DebitGlAccT  = c.DebitGlAccT != 0 ? c.DebitGlAccT :null,
                        DeptId       = c.DeptId != 0 ? c.DeptId : null,
                        FormulaId    = c.FormulaId != 0 ? c.FormulaId : null,
                        GradeId      = c.GradeId != 0 ? c.GradeId : null,
                        JobId        = c.JobId != 0 ? c.JobId : null,
                        GroupId      = c.GroupId != 0 ? c.GroupId : null,
                        BranchId     = c.BranchId != 0 ? c.BranchId : null,
                        PayDueId     = c.PayDueId != 0 ? c.PayDueId : null,
                        PersonType   = c.PersonType != 0 ? c.PersonType : null,
                        Performance  = c.Performance != 0 ? c.Performance : null,
                        SalItemId    = c.SalItemId != 0 ? c.SalItemId : null,
                        YesNoForm    = c.YesNoForm != 0 ? c.YesNoForm : null,
                        MinValue     = c.MinValue,
                        MaxValue     = c.MaxValue,
                        Grade        = c.Grade,
                        SubGrade     = c.SubGrade,
                        Point        = c.Point,
                        CreatedTime  = DateTime.Now,
                        CreatedUser  = UserName
                    };

                    result.Add(Link);
                    _hrUnitOfWork.SalaryDesignRepository.AddLinkTable(Link);
                }

                datasource.Errors = SaveChanges(Language);
            }
            else
            {
                datasource.Errors = Models.Utils.ParseErrors(ModelState.Values);
            }

            datasource.Data = (from c in models
                               select new LinkTableViewModel
            {
                Id = c.Id,
                GenTableId = c.GenTableId,
                Basis = c.Basis,
                CellValue = c.CellValue,
                CreditGlAccT = c.CreditGlAccT,
                DebitGlAccT = c.DebitGlAccT,
                DeptId = c.DeptId,
                FormulaId = c.FormulaId,
                Grade = c.Grade,
                GradeId = c.GradeId,
                JobId = c.JobId,
                GroupId = c.GroupId,
                MaxValue = c.MaxValue,
                BranchId = c.BranchId,
                MinValue = c.MinValue,
                PayDueId = c.PayDueId,
                PersonType = c.PersonType,
                Point = c.Point,
                Performance = c.Performance,
                SalItemId = c.SalItemId,
                SubGrade = c.SubGrade,
                YesNoForm = c.YesNoForm
            }).ToList();

            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }
コード例 #20
0
        public ActionResult UpdateLinkTable(IEnumerable <LinkTableViewModel> models, IEnumerable <OptionsViewModel> options)
        {
            var datasource = new DataSource <LinkTableViewModel>();

            datasource.Data  = models;
            datasource.Total = models.Count();

            if (ModelState.IsValid)
            {
                if (ServerValidationEnabled)
                {
                    var errors = _hrUnitOfWork.LookUpRepository.Check(new CheckParm
                    {
                        CompanyId    = CompanyId,
                        ObjectName   = "LinkTables",
                        TableName    = "LinkTables",
                        ParentColumn = "GenTableId",
                        Columns      = Models.Utils.GetModifiedRows(ModelState.Where(a => a.Key.Contains("models"))),
                        Culture      = Language
                    });

                    if (errors.Count() > 0)
                    {
                        datasource.Errors = errors;
                        return(Json(datasource));
                    }
                }

                for (var i = 0; i < models.Count(); i++)
                {
                    var item = models.ElementAtOrDefault(i);
                    var Link = new LinkTable();
                    AutoMapper(new AutoMapperParm()
                    {
                        ObjectName = "LinkTables", Destination = Link, Source = item, Version = 0, Options = options.ElementAtOrDefault(i)
                    });
                    Link.CreditGlAccT = item.CreditGlAccT != 0 ? item.CreditGlAccT : null;
                    Link.DebitGlAccT  = item.DebitGlAccT != 0 ? item.DebitGlAccT : null;
                    Link.DeptId       = item.DeptId != 0 ? item.DeptId : null;
                    Link.FormulaId    = item.FormulaId != 0 ? item.FormulaId : null;
                    Link.GradeId      = item.GradeId != 0 ? item.GradeId : null;
                    Link.JobId        = item.JobId != 0 ? item.JobId : null;
                    Link.GroupId      = item.GroupId != 0 ? item.GroupId : null;
                    Link.BranchId     = item.BranchId != 0 ? item.BranchId : null;
                    Link.PayDueId     = item.PayDueId != 0 ? item.PayDueId : null;
                    Link.PersonType   = item.PersonType != 0 ? item.PersonType : null;
                    Link.Performance  = item.Performance != 0 ? item.Performance : null;
                    Link.SalItemId    = item.SalItemId != 0 ? item.SalItemId : null;
                    Link.YesNoForm    = item.YesNoForm != 0 ? item.YesNoForm : null;
                    Link.ModifiedTime = DateTime.Now;
                    Link.ModifiedUser = UserName;
                    _hrUnitOfWork.SalaryDesignRepository.AttachLinkTable(Link);
                    _hrUnitOfWork.SalaryDesignRepository.Entry(Link).State = EntityState.Modified;
                }

                datasource.Errors = SaveChanges(Language);
            }
            else
            {
                datasource.Errors = Models.Utils.ParseErrors(ModelState.Values);
            }

            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }