Пример #1
0
        public SqlPreCommand DeleteSqlSync(Entity ident, string comment = null)
        {
            var pre = OnPreDeleteSqlSync(ident);
            var collections = (from tml in this.TablesMList()
                               select new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                                   .FormatWith(tml.Name, tml.BackReference.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()))).Combine(Spacing.Simple);

            var main = new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                    .FormatWith(Name, this.PrimaryKey.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()));

            return SqlPreCommand.Combine(Spacing.Simple, pre, collections, main);
        }
Пример #2
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            var claimer = (Hf == null ? Entity?.ToString() : Hf.ToString());

            if (Claim.HasValue)
            {
                switch (Claims[Claim.Value])
                {
                case "heirloom":
                    return($"{timestring} {Artifact} was made a family heirloom by {claimer}");

                case "treasure":
                    return($"{timestring} {Artifact} was claimed by {claimer}");

                case "symbol":
                    return($"{timestring} {Artifact} was made a symbol of the king by {claimer}");

                default:
                    return($"{timestring} {Artifact} was claimed by {claimer}");
                }
            }
            return($"{timestring} {Artifact} was claimed by {claimer}");
        }
Пример #3
0
 public void ActivateAutocomplete()
 {
     if (CanAutocomplete() && autocompleteTextBox.Visibility != Visibility.Visible)
     {
         autocompleteTextBox.Visibility = Visibility.Visible;
         autocompleteTextBox.Text       = Entity?.ToString();
         autocompleteTextBox.SelectAndFocus();
     }
 }
Пример #4
0
 public string CreateChanges(Entity entity)
 {
     var display = entity.ToString();
     var joinedKeyValue = "#" + entity.JoinedKeyValue;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Created " + display;
 }
Пример #5
0
 public string DeleteChanges(Entity entity, IDictionary<string, object> existingRecord)
 {
     var display = entity.ToString();
     var joinedKeyValue = "#" + entity.JoinedKeyValue;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Deleted " + display;
 }
Пример #6
0
        private PointSet method_1(ObjectId[] objectId_0, double double_1)
        {
            if (objectId_0 == null)
            {
                return(null);
            }
            Editor        arg_14_0        = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Database      workingDatabase = HostApplicationServices.WorkingDatabase;
            PointSet      pointSet        = new PointSet();
            PointSet      pointSet2       = new PointSet();
            ProgressMeter progressMeter   = new ProgressMeter();

            progressMeter.SetLimit(objectId_0.Length);
            progressMeter.Start("Computing points on entities");
            try
            {
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    for (int i = 0; i < objectId_0.Length; i++)
                    {
                        progressMeter.MeterProgress();
                        if (i % 10000 == 0)
                        {
                            System.Windows.Forms.Application.DoEvents();
                        }
                        Entity entity = (Entity)objectId_0[i].GetObject((OpenMode)0);
                        string text   = entity.ToString();
                        if (text.ToUpper().Contains("POLYLINE"))
                        {
                            text = "PLINE";
                        }
                        string key;
                        switch (key = text)
                        {
                        case "Autodesk.AutoCAD.DatabaseServices.Line":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Line dbl = (Autodesk.AutoCAD.DatabaseServices.Line)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = PointGeneration.SubdivideLine(dbl, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.DBText":
                        {
                            DBText dbtext_ = (DBText)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_2(dbtext_);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Circle":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Circle circle_ = (Autodesk.AutoCAD.DatabaseServices.Circle)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_3(circle_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Ellipse":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Ellipse ellipse_ = (Autodesk.AutoCAD.DatabaseServices.Ellipse)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_4(ellipse_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Arc":
                        {
                            Autodesk.AutoCAD.DatabaseServices.Arc arc_ = (Autodesk.AutoCAD.DatabaseServices.Arc)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_5(arc_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Spline":
                        {
                            Spline spline_ = (Spline)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_6(spline_, double_1);
                            break;
                        }

                        case "Autodesk.AutoCAD.DatabaseServices.Face":
                        {
                            Face face_ = (Face)transaction.GetObject(objectId_0[i], (OpenMode)0, true);
                            pointSet2 = this.method_7(face_);
                            break;
                        }

                        case "PLINE":
                        {
                            DBObject @object = transaction.GetObject(objectId_0[i], (OpenMode)0);
                            pointSet2 = PointGeneration.SubdividePolyline(@object, transaction, double_1);
                            break;
                        }
                        }
                        if (pointSet2 != null)
                        {
                            pointSet.Add(pointSet2);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                progressMeter.Stop();
                throw;
            }
            progressMeter.Stop();
            if (pointSet.Count == 0)
            {
                return(null);
            }
            pointSet.RemoveMultiplePoints3d();
            return(pointSet);
        }
Пример #7
0
        public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
        {
            bool isDocked = msg.ReadBoolean();

            for (int i = 0; i < 2; i++)
            {
                if (hulls[i] == null)
                {
                    continue;
                }
                item.linkedTo.Remove(hulls[i]);
                hulls[i].Remove();
                hulls[i] = null;
            }

            if (gap != null)
            {
                item.linkedTo.Remove(gap);
                gap.Remove();
                gap = null;
            }

            if (isDocked)
            {
                ushort dockingTargetID = msg.ReadUInt16();

                bool isLocked = msg.ReadBoolean();

                Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
                if (targetEntity == null || !(targetEntity is Item))
                {
                    DebugConsole.ThrowError("Invalid docking port network event (can't dock to " + targetEntity?.ToString() ?? "null" + ")");
                    return;
                }

                DockingTarget = (targetEntity as Item).GetComponent <DockingPort>();
                if (DockingTarget == null)
                {
                    DebugConsole.ThrowError("Invalid docking port network event (" + targetEntity + " doesn't have a docking port component)");
                    return;
                }

                Dock(DockingTarget);
                if (joint == null)
                {
                    string errorMsg = "Error while reading a docking port network event (Dock method did not create a joint between the ports)." +
                                      " Submarine: " + (item.Submarine?.Name ?? "null") +
                                      ", target submarine: " + (DockingTarget.item.Submarine?.Name ?? "null");
                    if (item.Submarine?.DockedTo.Contains(DockingTarget.item.Submarine) ?? false)
                    {
                        errorMsg += "\nAlready docked.";
                    }
                    if (item.Submarine == DockingTarget.item.Submarine)
                    {
                        errorMsg += "\nTrying to dock the submarine to itself.";
                    }
                    GameAnalyticsManager.AddErrorEventOnce("DockingPort.ClientRead:JointNotCreated", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
                }

                if (isLocked)
                {
                    Lock(isNetworkMessage: true, forcePosition: true);
                }
            }
            else
            {
                Undock();
            }
        }
Пример #8
0
    void when_created()
    {
        Entity e = null;

        before = () => {
            e = this.CreateEntity();
        };

        it["has component of type when component of that type was added"] = () => {
            e.AddComponentA();
            e.HasComponentA().should_be_true();
        };

        it["doesn't have component of type when no component of that type was added"] = () => {
            e.HasComponentA().should_be_false();
        };

        it["doesn't have components of types when no components of these types were added"] = () => {
            e.HasComponents(new [] { CID.ComponentA }).should_be_false();
        };

        it["doesn't have components of types when not all components of these types were added"] = () => {
            e.AddComponentA();
            e.HasComponents(new [] { CID.ComponentA, CID.ComponentB }).should_be_false();
        };

        it["has components of types when all components of these types were added"] = () => {
            e.AddComponentA();
            e.AddComponentB();
            e.HasComponents(new [] { CID.ComponentA, CID.ComponentB }).should_be_true();
        };

        it["doesn't have any components of types when no components of these types were added"] = () => {
            e.HasAnyComponent(new [] { CID.ComponentA }).should_be_false();
        };

        it["has any components of types when any component of these types was added"] = () => {
            e.AddComponentA();
            e.HasAnyComponent(new [] {
                CID.ComponentA,
                CID.ComponentB
            }).should_be_true();
        };

        it["removes a component of type"] = () => {
            e.AddComponentA();
            e.RemoveComponentA();
            e.HasComponentA().should_be_false();
        };

        it["gets a component of type"] = () => {
            e.AddComponentA();
            e.GetComponentA().should_be_same(Component.A);
        };

        it["replaces existing component"] = () => {
            e.AddComponentA();
            var newComponentA = new ComponentA();
            e.ReplaceComponentA(newComponentA);
            e.GetComponentA().should_be_same(newComponentA);
        };

        it["replacing a non existing component adds component"] = () => {
            var newComponentA = new ComponentA();
            e.ReplaceComponentA(newComponentA);
            e.GetComponentA().should_be_same(newComponentA);
        };

        it["gets empty array of components when no components were added"] = () => {
            e.GetComponents().should_be_empty();
        };

        it["gets empty array of component indices when no components were added"] = () => {
            e.GetComponentIndices().should_be_empty();
        };

        it["gets all components"] = () => {
            e.AddComponentA();
            e.AddComponentB();
            var allComponents = e.GetComponents();
            allComponents.should_contain(Component.A);
            allComponents.should_contain(Component.B);
            allComponents.Length.should_be(2);
        };

        it["gets all component indices"] = () => {
            e.AddComponentA();
            e.AddComponentB();
            var allComponentIndices = e.GetComponentIndices();
            allComponentIndices.should_contain(CID.ComponentA);
            allComponentIndices.should_contain(CID.ComponentB);
            allComponentIndices.Length.should_be(2);
        };

        it["removes all components"] = () => {
            e.AddComponentA();
            e.AddComponentB();
            e.RemoveAllComponents();
            e.HasComponentA().should_be_false();
            e.HasComponentB().should_be_false();
            e.GetComponents().should_be_empty();
            e.GetComponentIndices().should_be_empty();
        };

        it["can ToString"] = () => {
            e.AddComponentA();
            e.AddComponentB();
            e.ToString().should_be("Entity(ComponentA, ComponentB)");
        };

        context["events"] = () => {
            Entity     eventEntity    = null;
            int        eventIndex     = CID.None;
            IComponent eventComponent = null;

            before = () => {
                eventEntity    = null;
                eventIndex     = CID.None;
                eventComponent = null;
            };

            it["dispatches OnComponentAdded when adding a component"] = () => {
                e.OnComponentAdded += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };
                e.OnComponentReplaced      += (entity, index, component) => this.Fail();
                e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail();
                e.OnComponentRemoved       += (entity, index, component) => this.Fail();

                e.AddComponentA();
                eventEntity.should_be_same(e);
                eventIndex.should_be(CID.ComponentA);
                eventComponent.should_be_same(Component.A);
            };

            it["dispatches OnComponentRemoved when removing a component"] = () => {
                e.AddComponentA();
                e.OnComponentAdded    += (entity, index, component) => this.Fail();
                e.OnComponentReplaced += (entity, index, component) => this.Fail();
                e.OnComponentRemoved  += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };

                e.RemoveComponentA();
                eventEntity.should_be_same(e);
                eventIndex.should_be(CID.ComponentA);
                eventComponent.should_be_same(Component.A);
            };

            it["dispatches OnComponentWillBeRemoved when removing a component"] = () => {
                e.AddComponentA();
                e.OnComponentWillBeRemoved += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };

                e.RemoveComponentA();
                eventEntity.should_be_same(e);
                eventIndex.should_be(CID.ComponentA);
                eventComponent.should_be_same(Component.A);
            };

            it["dispatches OnComponentReplaced when replacing a component"] = () => {
                e.AddComponentA();
                var newComponentA = new ComponentA();
                var didReplace    = 0;
                e.OnComponentAdded    += (entity, index, component) => this.Fail();
                e.OnComponentReplaced += (entity, index, component) => {
                    entity.should_be_same(entity);
                    index.should_be(CID.ComponentA);
                    component.should_be_same(newComponentA);
                    didReplace++;
                };
                e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail();
                e.OnComponentRemoved       += (entity, index, component) => this.Fail();

                e.ReplaceComponentA(newComponentA);
                didReplace.should_be(1);
            };

            it["dispatches OnComponentWillBeRemoved when called manually and component exists"] = () => {
                e.AddComponentA();
                e.OnComponentWillBeRemoved += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };

                e.WillRemoveComponent(CID.ComponentA);
                eventEntity.should_be_same(e);
                eventIndex.should_be(CID.ComponentA);
                eventComponent.should_be_same(Component.A);
            };

            it["doesn't dispatch OnComponentWillBeRemoved when called manually and entity doesn't have"] = () => {
                e.OnComponentWillBeRemoved += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };

                e.WillRemoveComponent(CID.ComponentA);
                eventEntity.should_be_null();
                eventIndex.should_be(CID.None);
                eventComponent.should_be_null();
            };

            it["dispatches OnComponentAdded when attempting to replace a component which hasn't been added"] = () => {
                e.OnComponentAdded += (entity, index, component) => {
                    eventEntity    = entity;
                    eventIndex     = index;
                    eventComponent = component;
                };
                e.OnComponentReplaced      += (entity, index, component) => this.Fail();
                e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail();
                e.OnComponentRemoved       += (entity, index, component) => this.Fail();

                var newComponentA = new ComponentA();
                e.ReplaceComponentA(newComponentA);
                eventEntity.should_be_same(e);
                eventIndex.should_be(CID.ComponentA);
                eventComponent.should_be_same(newComponentA);
            };

            it["dispatches OnComponentRemoved when removing all components"] = () => {
                var removed = 0;
                e.AddComponentA();
                e.AddComponentB();
                e.OnComponentRemoved += (entity, index, component) => removed++;
                e.RemoveAllComponents();
                removed.should_be(2);
            };
        };

        context["invalid operations"] = () => {
            it["throws when adding a component of the same type twice"] = expect <EntityAlreadyHasComponentException>(() => {
                e.AddComponentA();
                e.AddComponentA();
            });

            it["throws when attempting to remove a component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => {
                e.RemoveComponentA();
            });

            it["throws when attempting to get component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => {
                e.GetComponentA();
            });
        };

        context["internal caching"] = () => {
            context["components"] = () => {
                it["caches components"] = () => {
                    e.AddComponentA();
                    var c = e.GetComponents();
                    e.GetComponents().should_be_same(c);
                };

                it["updates cache when a new component was added"] = () => {
                    e.AddComponentA();
                    var c = e.GetComponents();
                    e.AddComponentB();
                    e.GetComponents().should_not_be_same(c);
                };

                it["updates cache when a component was removed"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponents();
                    e.RemoveComponentA();
                    e.GetComponents().should_not_be_same(c);
                };

                it["updates cache when a component was replaced"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponents();
                    e.ReplaceComponentA(new ComponentA());
                    e.GetComponents().should_not_be_same(c);
                };

                it["doesn't update cache when a component was replaced with same component"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponents();
                    e.ReplaceComponentA(Component.A);
                    e.GetComponents().should_be_same(c);
                };

                it["updates cache when all components were removed"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponents();
                    e.RemoveAllComponents();
                    e.GetComponents().should_not_be_same(c);
                };
            };

            context["component indices"] = () => {
                it["caches component indices"] = () => {
                    e.AddComponentA();
                    var c = e.GetComponentIndices();
                    e.GetComponentIndices().should_be_same(c);
                };

                it["updates cache when a new component was added"] = () => {
                    e.AddComponentA();
                    var c = e.GetComponentIndices();
                    e.AddComponentB();
                    e.GetComponentIndices().should_not_be_same(c);
                };

                it["updates cache when a component was removed"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponentIndices();
                    e.RemoveComponentA();
                    e.GetComponentIndices().should_not_be_same(c);
                };

                it["doesn't update cache when a component was replaced"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponentIndices();
                    e.ReplaceComponentA(new ComponentA());
                    e.GetComponentIndices().should_be_same(c);
                };

                it["updates cache when adding a new component with ReplaceComponent"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponentIndices();
                    e.ReplaceComponentC(Component.C);
                    e.GetComponentIndices().should_not_be_same(c);
                };

                it["updates cache when all components were removed"] = () => {
                    e.AddComponentA();
                    e.AddComponentB();
                    var c = e.GetComponentIndices();
                    e.RemoveAllComponents();
                    e.GetComponentIndices().should_not_be_same(c);
                };
            };
        };
    }
Пример #9
0
        public void InitFuncEn(UAC uac, Entity en)
        {
            if (en.EnMap.EnType == EnType.View)
            {
                uac.Readonly();
            }

            //this.AddLab("Lab_Key1","标题:"+en.EnDesc);
            if (uac.IsInsert)
            {
                if (en.EnMap.EnType != EnType.Dtl)
                {
                    this.AddBtn(NamesOfBtn.New, "新建(N)");
                    this.GetBtnByID(NamesOfBtn.New).UseSubmitBehavior = false;
                    this.GetBtnByID(NamesOfBtn.New).OnClientClick     = "this.disabled=true;"; //this.disabled='disabled'; return true;";
                }
            }

            if (uac.IsUpdate)
            {
                this.AddBtn(NamesOfBtn.Save, "保存(S)");
                this.AddBtn(NamesOfBtn.SaveAndClose, "保存并关闭");

                this.GetBtnByID(NamesOfBtn.Save).UseSubmitBehavior = false;
                this.GetBtnByID(NamesOfBtn.Save).OnClientClick     = "this.disabled=true;"; //this.disabled='disabled'; return true;";
                // this.AddBtn(NamesOfBtn.SaveAndClose, this.ToE("SaveAndClose", "保存并关闭(C)")   );
            }

            if (uac.IsInsert && uac.IsUpdate)
            {
                if (en.EnMap.EnType != EnType.Dtl)
                {
                    this.AddBtn(NamesOfBtn.SaveAndNew, "保存并新建(R)");

                    this.GetBtnByID(NamesOfBtn.SaveAndNew).UseSubmitBehavior = false;
                    this.GetBtnByID(NamesOfBtn.SaveAndNew).OnClientClick     = "this.disabled=true;"; //this.disabled='disabled'; return true;";
                    //this.AddBtn(NamesOfBtn.SaveAndClose );
                }
            }

            string pkval = en.PKVal.ToString();

            if (uac.IsDelete && pkval != "0" && pkval.Length >= 1)
            {
                this.AddBtn(NamesOfBtn.Delete, "删除(D)");

                //  this.GetBtnByID(NamesOfBtn.Delete).UseSubmitBehavior = false;
                // this.GetBtnByID(NamesOfBtn.Delete).OnClientClick = "this.disabled=true;"; //this.disabled='disabled'; return true;";
            }

            if (uac.IsAdjunct)
            {
                this.AddBtn(NamesOfBtn.Adjunct);
                if (en.IsEmpty == false)
                {
                    int i = DBAccess.RunSQLReturnValInt("select COUNT(*) from Sys_FileManager WHERE RefTable='" + en.ToString() + "' AND RefKey='" + en.PKVal + "'");
                    if (i != 0)
                    {
                        this.GetBtnByID(NamesOfBtn.Adjunct).Text += "-" + i;
                    }
                }
            }
        }
Пример #10
0
 /// <summary>
 /// Prints the description for an individual entity on its own line.
 /// </summary>
 /// <param name="entity"></param>
 private static void PrintEntity( Entity entity )
 {
     Console.Out.WriteLine( entity.GetID() + " - " + entity.ToString() + " [" + entity.m_Type.ToString() + "]" );
 }
Пример #11
0
        /// <summary>
        /// 安装包
        /// </summary>
        public static void DoInstallDataBase(string lang, string yunXingHuanjing)
        {
            ArrayList al   = null;
            string    info = "BP.En.Entity";

            al = BP.En.ClassFactory.GetObjects(info);

            #region 1, 修复表
            foreach (Object obj in al)
            {
                Entity en = null;
                en = obj as Entity;
                if (en == null)
                {
                    continue;
                }

                if (en.ToString() == null)
                {
                    continue;
                }

                if (en.ToString().Contains("BP.Port."))
                {
                    continue;
                }

                string table = null;
                try
                {
                    table = en.EnMap.PhysicsTable;
                    if (table == null)
                    {
                        continue;
                    }
                }
                catch
                {
                    continue;
                }

                switch (table)
                {
                case "WF_EmpWorks":
                case "WF_GenerEmpWorkDtls":
                case "WF_GenerEmpWorks":
                case "WF_NodeExt":
                    continue;

                case "Sys_Enum":
                    en.CheckPhysicsTable();
                    break;

                default:
                    en.CheckPhysicsTable();
                    break;
                }

                en.PKVal = "123";
                try
                {
                    en.RetrieveFromDBSources();
                }
                catch (Exception ex)
                {
                    Log.DebugWriteWarning(ex.Message);
                    en.CheckPhysicsTable();
                }
            }
            #endregion 修复

            #region 2, 注册枚举类型 sql
            // 2, 注册枚举类型。
            BP.Sys.Xml.EnumInfoXmls xmls = new BP.Sys.Xml.EnumInfoXmls();
            xmls.RetrieveAll();
            foreach (BP.Sys.Xml.EnumInfoXml xml in xmls)
            {
                BP.Sys.SysEnums ses = new BP.Sys.SysEnums();
                ses.RegIt(xml.Key, xml.Vals);
            }
            #endregion 注册枚举类型

            #region 3, 执行基本的 sql
            string sqlscript = SystemConfig.PathOfWebApp + "\\GPM\\SQLScript\\Port_Inc_CH_BPM.sql";
            /*孙战平将RunSQLScript改为RunSQLScriptGo*/
            BP.DA.DBAccess.RunSQLScript(sqlscript);
            #endregion 修复

            #region 5, 初始化数据。

            sqlscript = SystemConfig.PathOfWebApp + "\\GPM\\SQLScript\\InitPublicData.sql";
            BP.DA.DBAccess.RunSQLScript(sqlscript);

            //sqlscript = SystemConfig.PathOfWebApp + "\\Data\\Install\\SQLScript\\GO.sql";
            //BP.DA.DBAccess.RunSQLScriptGo(sqlscript);
            #endregion 初始化数据

            #region 6, 创建视图。

            if (DBAccess.IsExitsObject("V_GPM_EmpGroup"))
            {
                BP.DA.DBAccess.RunSQL("DROP VIEW V_GPM_EmpGroup");
            }

            if (DBAccess.IsExitsObject("V_GPM_EmpGroupMenu"))
            {
                BP.DA.DBAccess.RunSQL("DROP VIEW V_GPM_EmpGroupMenu");
            }

            if (DBAccess.IsExitsObject("V_GPM_EmpStationMenu"))
            {
                BP.DA.DBAccess.RunSQL("DROP VIEW V_GPM_EmpStationMenu");
            }

            if (DBAccess.IsExitsObject("V_GPM_EmpMenu_GPM"))
            {
                BP.DA.DBAccess.RunSQL("DROP VIEW V_GPM_EmpMenu_GPM");
            }

            if (DBAccess.IsExitsObject("V_GPM_EmpMenu"))
            {
                BP.DA.DBAccess.RunSQL("DROP VIEW V_GPM_EmpMenu");
            }



            sqlscript = SystemConfig.PathOfWebApp + "\\GPM\\SQLScript\\MSSQL_GPM_VIEW.sql";

            //MySQL 语法有所区别
            if (BP.Sys.SystemConfig.AppCenterDBType == DBType.MySQL)
            {
                sqlscript = SystemConfig.PathOfWebApp + "\\GPM\\SQLScript\\MySQL_GPM_VIEW.sql";
            }
            //Oracle 语法有所区别
            if (BP.Sys.SystemConfig.AppCenterDBType == DBType.Oracle)
            {
                sqlscript = SystemConfig.PathOfWebApp + "\\GPM\\SQLScript\\Oracle_GPM_VIEW.sql";
            }
            BP.DA.DBAccess.RunSQLScriptGo(sqlscript);
            #endregion 创建视图

            #region 7, 初始化系统访问权限
            //查询出来系统
            Apps apps = new Apps();
            apps.RetrieveAll();

            //查询出来人员.
            Emps emps = new Emps();
            emps.RetrieveAllFromDBSource();
            //查询出来菜单
            Menus menus = new Menus();
            menus.RetrieveAllFromDBSource();

            //删除数据.
            BP.DA.DBAccess.RunSQL("DELETE FROM GPM_EmpApp");
            BP.DA.DBAccess.RunSQL("DELETE FROM GPM_EmpMenu");


            foreach (Emp emp in emps)
            {
                #region 初始化系统访问权限.
                foreach (App app in apps)
                {
                    EmpApp me = new EmpApp();
                    me.Copy(app);
                    me.FK_Emp = emp.No;
                    me.FK_App = app.No;
                    me.Name   = app.Name;
                    me.MyPK   = app.No + "_" + me.FK_Emp;
                    me.Insert();
                }
                #endregion 初始化系统访问权限.

                #region 初始化人员菜单权限
                foreach (Menu menu in menus)
                {
                    EmpMenu em = new EmpMenu();
                    em.Copy(menu);
                    em.FK_Emp  = emp.No;
                    em.FK_App  = menu.FK_App;
                    em.FK_Menu = menu.No;
                    em.MyPK    = menu.No + "_" + emp.No;
                    em.Insert();
                }
                #endregion
            }
            #endregion
        }
Пример #12
0
 public override string ToString()
 {
     return($"{Entity.ToString()} moving to {destinationCell}");
 }
Пример #13
0
 public override void OnUpdate(Entity entity, ref T state)
 {
     base.OnUpdate(entity, ref state);
     Debug.LogFormat("{0} Update state {1}", entity.ToString(), state.GetType().Name);
 }
Пример #14
0
 public override void OnExit(Entity entity, ref T state)
 {
     base.OnExit(entity, ref state);
     Debug.LogFormat("{0} exit from state {1}", entity.ToString(), state.GetType().Name);
 }
Пример #15
0
 public override string ToString()
 {
     return(Entity.ToString() + ", " + BoundingVolume.ToString() + ", " + Tolerance.ToString());
 }
Пример #16
0
        public void MAIN_OnPlayerConnect(Entity player)
        {
            if (ConfigValues.HUD_ALIVE)
            {
                hud_counter(player);
            }
            try
            {
                player.SetField("spawnevent", 0);
                player.SetField("isConnecting", 0);
                GroupsDatabase.Group playergroup = player.GetGroup(database);
                WriteLog.Info("# Player " + player.Name + " from group \"" + playergroup.group_name + "\" connected.");
                WriteLog.Info("# GUID: " + player.GUID.ToString() + " IP: " + player.IP.ToString());
                WriteLog.Info("# HWID: " + player.GetHWID() + " ENTREF: " + player.GetEntityNumber());
                if (string.IsNullOrEmpty(player.GetXNADDR().Value))
                {
                    throw new Exception("Bad xnaddr");
                }
                WriteLog.Info("# XNADDR(12): " + player.GetXNADDR().ToString());
                if (!player.IsPlayer || player.GetHWID().IsBadHWID())
                {
                    throw new Exception("Invalid entref/hwid");
                }
            }
            catch (Exception)
            {
                WriteLog.Info("# Haxor connected. Could not retrieve/set player info. Kicking...");
                try
                {
                    HaxLog.WriteInfo("----STARTREPORT----");
                    HaxLog.WriteInfo("BAD PLAYER");
                    HaxLog.WriteInfo(player.ToString());
                }
                catch (Exception ex)
                {
                    HaxLog.WriteInfo("ERROR ON TOSTRING");
                    HaxLog.WriteInfo(ex.ToString());
                }
                finally
                {
                    HaxLog.WriteInfo("----ENDREPORT----");
                }
                AfterDelay(100, () =>
                {
                    ExecuteCommand("dropclient " + player.GetEntityNumber() + " \"Something went wrong. Please restart TeknoMW3 and try again.\"");
                });
            }

            if (bool.Parse(Sett_GetString("settings_enable_connectmessage")) == true)
            {
                WriteChatToAll(Sett_GetString("format_connectmessage").Format(new Dictionary <string, string>()
                {
                    { "<player>", player.Name },
                    { "<playerf>", player.GetFormattedName(database) },
                }));
            }

            string line = "[CONNECT] " + string.Format("{0} : {1}, {2}, {3}, {4}, {5}", player.Name.ToString(), player.GetEntityNumber().ToString(), player.GUID, player.IP.Address.ToString(), player.GetHWID().Value, player.GetXNADDR().ToString());

            line.LogTo(PlayersLog, MainLog);
        }
Пример #17
0
 private void Log(Entity entity, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "")
 => Log(entity.ToString(), memberName, sourceFilePath);
Пример #18
0
        static void Main(string[] args)
        {
            //Enable HighPrecisionTimer to achieve 1ms internal clock = Thread.Sleep will be able to sleep for 1ms instead of 15.6ms
            HighPrecisionTimer.Enable();

            //Creating server node
            Master = new AuthoryMaster();



            //For debugging purposes
            Console.WriteLine("Is High Resolution timer enabled: " + Stopwatch.IsHighResolution);
            ConsoleKey key;

            while ((key = Console.ReadKey().Key) != ConsoleKey.Escape && AuthoryMaster.Instance.NodeUp)
            {
                try
                {
                    foreach (var map in Master.MapServers)
                    {
                        Console.WriteLine(map.MapIndex);
                    }

                    int mapIndex = Master.MapServers.Count > 1 ? int.Parse(Console.ReadLine()) : 0;

                    switch (key)
                    {
                    case ConsoleKey.G:
                        foreach (var map in AuthoryMaster.Instance.MapServers)
                        {
                            Console.WriteLine("------------------");
                            Console.WriteLine(map.MapName);
                            Console.WriteLine(map.MapIndex);
                            Console.WriteLine(map.Data.PlayersById.Count);
                            Console.WriteLine();
                        }
                        break;

                    case ConsoleKey.L:
                        Console.WriteLine();
                        Console.WriteLine("List by grid cells");
                        foreach (var entitiesContainer in Master.MapServers[mapIndex].Data.Grid)
                        {
                            foreach (var player in entitiesContainer.PlayersById.Values)
                            {
                                Console.WriteLine(player);
                            }
                        }
                        Console.WriteLine("---------------------------");
                        Console.WriteLine("List by DataHandler");
                        foreach (var player in Master.MapServers[mapIndex].Data.PlayersById.Values)
                        {
                            Console.WriteLine(player);
                        }
                        Console.WriteLine("Player count: " + GridCell.AllPlayerCount);
                        Console.WriteLine("Entity count: " + GridCell.AllEntityCount);
                        break;

                    case ConsoleKey.Q:
                        foreach (var grid in Master.MapServers[mapIndex].Data.Grid)
                        {
                            foreach (var mob in grid.MobEntities.Values)
                            {
                                Console.WriteLine(mob.Id + ": " + mob);
                            }
                        }
                        break;

                    case ConsoleKey.O:
                        Console.Write("\nEnter the ID of the entity: ");
                        int    id     = int.Parse(Console.ReadLine());
                        Entity entity = Master.MapServers[mapIndex].Data.Get((ushort)id);

                        Console.WriteLine("Id: {0}", entity.ToString());
                        break;

                    case ConsoleKey.P:
                        Console.WriteLine();
                        for (int i = 0; i < 100; i++)
                        {
                            Master.MapServers[mapIndex].AddPlayerForTesting(new Vector3(new Random().Next(100, 1900), 0, new Random().Next(100, 1900)));
                        }
                        break;

                    case ConsoleKey.M:
                        Console.WriteLine();
                        Master.MapServers[mapIndex].AddMobsForTesting();
                        break;

                    case ConsoleKey.S:
                        Console.WriteLine();
                        Master.MapServers[mapIndex].ShowNextStatistic();
                        break;

                    case ConsoleKey.V:
                        Console.WriteLine();
                        Console.WriteLine($"Number of players: {Master.MapServers[mapIndex].Data.PlayersById.Count} ");
                        Console.WriteLine($"Number of mobs: {GridCell.AllEntityCount - GridCell.AllPlayerCount} ");
                        break;

                    case ConsoleKey.X:
                        AuthoryMaster.Instance.Shutdown();
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }

            //Server.Shutdown();
            Console.WriteLine("Press Enter to close the window!");
            Console.ReadLine();

            HighPrecisionTimer.Disable();
        }
        public void ClientRead(ServerNetObject type, Lidgren.Network.NetBuffer msg, float sendingTime)
        {
            bool isDocked = msg.ReadBoolean();

            if (isDocked)
            {
                ushort dockingTargetID = msg.ReadUInt16();

                bool isLocked = msg.ReadBoolean();

                if (isLocked)
                {
                    hullIds[0] = msg.ReadUInt16();
                    hullIds[1] = msg.ReadUInt16();
                    gapId      = msg.ReadUInt16();
                }

                Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
                if (targetEntity == null || !(targetEntity is Item))
                {
                    DebugConsole.ThrowError("Invalid docking port network event (can't dock to " + targetEntity.ToString() + ")");
                    return;
                }

                dockingTarget = (targetEntity as Item).GetComponent <DockingPort>();
                if (dockingTarget == null)
                {
                    DebugConsole.ThrowError("Invalid docking port network event (" + targetEntity + " doesn't have a docking port component)");
                    return;
                }

                Dock(dockingTarget);

                if (isLocked)
                {
                    Lock(true);

                    hulls[0].ID = (ushort)hullIds[0];
                    hulls[1].ID = (ushort)hullIds[1];
                    gap.ID      = (ushort)gapId;
                }
            }
            else
            {
                Undock();
            }
        }
        public void BindEns(Entities ens, string ctrlId)
        {
            this.Title = "单据查询";
            this.UCSys1.Controls.Clear();
            Entity myen   = ens.GetNewEntity;
            string pk     = myen.PK;
            string clName = myen.ToString();
            Attrs  attrs  = myen.EnMap.Attrs;

            #region  生成标题
            this.UCSys1.Add("<Table border='1' align=left width='20%' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='#C0C0C0'>");
            this.UCSys1.AddTR();
            this.UCSys1.AddTDTitle("序");
            foreach (Attr attr in attrs)
            {
                if (attr.IsRefAttr || attr.UIVisible == false || attr.Key == "MyNum")
                {
                    continue;
                }
                this.UCSys1.AddTDTitle(attr.Desc);
            }
            #endregion  生成标题

            bool isRefFunc = false;
            isRefFunc = true;
            int  pageidx = this.PageIdx - 1;
            int  idx     = SystemConfig.PageSize * pageidx;
            bool is1     = false;

            #region 用户界面属性设置
            string focusField = "Title";
            int    WinCardH   = 500;
            int    WinCardW   = 400;
            #endregion 用户界面属性设置

            #region 数据输出.
            this.UCSys1.AddTDTitle("功能");
            this.UCSys1.AddTREnd();
            string urlExt = "";
            foreach (Entity en in ens)
            {
                #region 处理keys
                string style = WebUser.Style;
                string url   = this.GenerEnUrl(en, attrs);
                #endregion

                this.UCSys1.AddTR();

                #region 输出字段。
                idx++;
                this.UCSys1.AddTDIdx(idx);
                string val = "";
                foreach (Attr attr in attrs)
                {
                    if (attr.Key == "FK_NY")
                    {
                        this.UCSys1.AddTD(en.GetValStrByKey(attr.Key));
                        continue;
                    }


                    if (attr.IsRefAttr || attr.UIVisible == false || attr.Key == "MyNum")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        this.UCSys1.AddTD(en.GetValRefTextByKey(attr.Key));
                        continue;
                    }

                    if (attr.UIHeight != 0)
                    {
                        this.UCSys1.AddTDDoc("...", "...");
                        return;
                    }

                    string str = en.GetValStrByKey(attr.Key);
                    if (focusField == attr.Key)
                    {
                        str = "<b><font color='blue' >" + str + "</font></a>";
                    }
                    switch (attr.MyDataType)
                    {
                    case DataType.AppDate:
                    case DataType.AppDateTime:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }
                        this.UCSys1.AddTD(str);
                        break;

                    case DataType.AppString:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }

                        if (attr.UIHeight != 0)
                        {
                            this.UCSys1.AddTDDoc(str, str);
                        }
                        else
                        {
                            this.UCSys1.AddTD(str);
                        }
                        break;

                    case DataType.AppBoolean:
                        if (str == "1")
                        {
                            this.UCSys1.AddTD("是");
                        }
                        else
                        {
                            this.UCSys1.AddTD("否");
                        }
                        break;

                    case DataType.AppFloat:
                    case DataType.AppInt:
                    case DataType.AppRate:
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(str);
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDNum(decimal.Parse(str).ToString("0.00"));
                        break;

                    default:
                        throw new Exception("no this case ...");
                    }
                }
                #endregion 输出字段。

                //相关功能.
                string ext = "";
                ext += "<a href=\"javascript:WinOpen('Bill.aspx?DoType=Print&MyPK=" + en.PKVal + "','tdr');\" ><img src='./../Img/book.gif' />打印</a>";
                ext += "-<a href=\"javascript:WinOpen('../Chart.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + en.GetValStringByKey("WorkID") + "&FID=" + en.GetValStringByKey("FID") + "','tr');\" ><img src='./../Img/track.png' />轨迹图</a>";
                // ext += "-<a href=\"javascript:WinOpen('./../WFRpt.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + en.GetValStringByKey("WorkID") + "&FID=" + en.GetValStringByKey("FID") + "','tdr');\" >工作报告</a>";

                this.UCSys1.AddTD(ext);
                this.UCSys1.AddTREnd();
            }
            #endregion 数据输出.

            #region  求合计代码写在这里。
            bool IsHJ = false;
            foreach (Attr attr in attrs)
            {
                if (attr.MyFieldType == FieldType.RefText)
                {
                    continue;
                }

                if (attr.UIContralType == UIContralType.DDL)
                {
                    continue;
                }

                if (attr.Key == "OID" ||
                    attr.Key == "MID" ||
                    attr.Key == "FID" ||
                    attr.Key.ToUpper() == "WORKID")
                {
                    continue;
                }

                switch (attr.MyDataType)
                {
                case DataType.AppDouble:
                case DataType.AppFloat:
                case DataType.AppInt:
                case DataType.AppMoney:
                    IsHJ = true;
                    break;

                default:
                    break;
                }
            }

            if (IsHJ)
            {
                this.UCSys1.Add("<TR class='TRSum' >");
                this.UCSys1.AddTD("合计");
                foreach (Attr attr in attrs)
                {
                    if (attr.Key == "MyNum")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        this.UCSys1.AddTD();
                        continue;
                    }

                    if (attr.UIVisible == false)
                    {
                        continue;
                    }

                    if (attr.Key == "OID" || attr.Key == "MID" || attr.Key.ToUpper() == "WORKID")
                    {
                        this.UCSys1.AddTD(attr.Key);
                        continue;
                    }

                    switch (attr.MyDataType)
                    {
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppFloat:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppInt:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDJE(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    default:
                        this.UCSys1.AddTD();
                        break;
                    }
                } /*结束循环*/
                this.UCSys1.AddTD();
                this.UCSys1.AddTREnd();
            }
            #endregion

            this.UCSys1.AddTableEnd();
        }
Пример #21
0
    public void Bind()
    {
        #region 生成标题
        Entity en    = this.HisEn;
        Map    map   = this.HisEn.EnMap;
        EnCfg  cfg   = new EnCfg(en.ToString());
        Attrs  attrs = map.Attrs;
        if (attrs.Count >= 4)
        {
            this.ucsys1.Add("<table border=0 cellpadding='0'  style='border-collapse: collapse;width:100%' cellspacing='0'  >");
        }
        else
        {
            this.ucsys1.Add("<table border=0 cellpadding='0'  style='border-collapse: collapse;width:50%' cellspacing='0'  >");
        }

        this.ucsys1.AddTR();
        CheckBox cb   = new CheckBox();
        string   str1 = "<INPUT id='checkedAll' onclick='SelectAll()' type='checkbox' name='checkedAll'>";
        this.ucsys1.AddTDGroupTitle(str1);
        foreach (Attr attr in attrs)
        {
            if (attr.UIVisible == false)
            {
                continue;
            }
            this.ucsys1.AddTDGroupTitle(attr.Desc);
        }

        if (map.IsHaveFJ)
        {
            this.ucsys1.AddTDGroupTitle("附件");
        }
        this.ucsys1.AddTDGroupTitle();
        this.ucsys1.AddTREnd();
        #endregion 生成标题

        this.Title = en.EnDesc;
        Entities    ens = this.HisEns;
        QueryObject qo  = new QueryObject(ens);

        #region 用户界面属性设置
        BP.Web.Comm.UIRowStyleGlo tableStyle = (UIRowStyleGlo)ens.GetEnsAppCfgByKeyInt("UIRowStyleGlo"); // 界面风格。
        bool   IsEnableDouclickGlo           = ens.GetEnsAppCfgByKeyBoolen("IsEnableDouclickGlo");       // 是否启用双击
        bool   IsEnableRefFunc    = ens.GetEnsAppCfgByKeyBoolen("IsEnableRefFunc");                      // 是否显示相关功能。
        bool   IsEnableFocusField = ens.GetEnsAppCfgByKeyBoolen("IsEnableFocusField");                   //是否启用焦点字段。
        bool   isShowOpenICON     = ens.GetEnsAppCfgByKeyBoolen("IsEnableOpenICON");                     //是否启用 OpenICON 。
        string FocusField         = null;
        if (IsEnableFocusField)
        {
            FocusField = ens.GetEnsAppCfgByKeyString("FocusField");
        }

        int WinCardH = ens.GetEnsAppCfgByKeyInt("WinCardH"); // 弹出窗口高度
        int WinCardW = ens.GetEnsAppCfgByKeyInt("WinCardW"); // 弹出窗口宽度
        #endregion 用户界面属性设置


        #region 生成翻页
        try
        {
            this.ucsys2.Clear();
            this.ucsys2.BindPageIdx(qo.GetCount(), BP.SystemConfig.PageSize, this.PageIdx, "Ens.aspx?EnsName=" + this.EnsName);
            qo.DoQuery(en.PK, BP.SystemConfig.PageSize, this.PageIdx, false);
        }
        catch (Exception ex)
        {
            ens.GetNewEntity.CheckPhysicsTable();
            return;
        }
        #endregion 生成翻页

        en.PKVal = "0";
        ens.AddEntity(en);
        DDL  ddl = new DDL();
        bool is1 = false;

        #region 生成数据
        int i = 0;
        foreach (Entity dtl in ens)
        {
            string urlExt = "\"javascript:ShowEn('./RefFunc/UIEn.aspx?EnsName=" + ens.ToString() + "&PK=" + dtl.PKVal + "', 'cd');\"";
            i++;
            if (dtl.PKVal == "0")
            {
                this.ucsys1.AddTRSum();
                this.ucsys1.AddTDIdx("<b>*</b>");
            }
            else
            {
                is1     = this.ucsys1.AddTR(is1, "ondblclick=" + urlExt);
                cb      = new CheckBox();
                cb.ID   = "IDX_" + dtl.PKVal;
                cb.Text = i.ToString();
                this.ucsys1.AddTDIdx(cb);
            }
            foreach (Attr attr in attrs)
            {
                if (attr.UIVisible == false)
                {
                    continue;
                }

                if (attr.Key == "OID")
                {
                    continue;
                }

                string val = dtl.GetValByKey(attr.Key).ToString();
                switch (attr.UIContralType)
                {
                case UIContralType.TB:
                    TB tb = new TB();
                    tb.LoadMapAttr(attr);
                    this.ucsys1.AddTD(tb);
                    tb.ID = "TB_" + attr.Key + "_" + dtl.PKVal;
                    switch (attr.MyDataType)
                    {
                    case DataType.AppMoney:
                    case DataType.AppRate:
                        tb.TextExtMoney = decimal.Parse(val);
                        break;

                    default:
                        tb.Text = val;
                        break;
                    }

                    if (attr.IsNum && attr.IsFKorEnum == false)
                    {
                        if (tb.Enabled)
                        {
                            // OnKeyPress="javascript:return VirtyNum(this);"
                            //  tb.Attributes["OnKeyDown"] = "javascript:return VirtyNum(this);";
                            // tb.Attributes["onkeyup"] += "javascript:C" + dtl.PKVal + "();C" + attr.Key + "();";
                            tb.Attributes["class"] = "TBNum";
                        }
                        else
                        {
                            //   tb.Attributes["onpropertychange"] += "C" + attr.Key + "();";
                            tb.Attributes["class"] = "TBNumReadonly";
                        }
                    }
                    break;

                case UIContralType.DDL:
                    if (attr.UIIsReadonly)
                    {
                        ddl = new DDL();
                        ddl.LoadMapAttr(attr);
                        ddl.ID = "DDL_" + attr.Key + "_" + dtl.PKVal;
                        //  this.ucsys1.AddTD(ddl);
                        this.ucsys1.AddTD(ddl);
                        ddl.SetSelectItem(val);
                    }
                    else
                    {
                        this.ucsys1.AddTD(dtl.GetValRefTextByKey(attr.Key));
                    }
                    break;

                case UIContralType.CheckBok:
                    cb    = new CheckBox();
                    cb.ID = "CB_" + attr.Key + "_" + dtl.PKVal;
                    //cb.Text = attr.Name;
                    if (val == "1")
                    {
                        cb.Checked = true;
                    }
                    else
                    {
                        cb.Checked = false;
                    }
                    this.ucsys1.AddTDCenter(cb);
                    break;

                default:
                    break;
                }
            }
            if (map.IsHaveFJ)
            {
                string ext = dtl.GetValStrByKey("MyFileExt");
                if (ext == null || ext.Length > 1)
                {
                    this.ucsys1.AddTD("<a href='" + cfg.FJWebPath + "/" + dtl.PKVal + "." + ext + "' target=_blank ><img src='../Images/FileType/" + dtl.GetValStrByKey("MyFileExt") + ".gif' border=0/>" + dtl.GetValStrByKey("MyFileName") + "</a>");
                }
                else
                {
                    this.ucsys1.AddTD();
                }
            }
            if (isShowOpenICON)
            {
                this.ucsys1.Add("<TD class='TD' style='cursor:hand;' nowrap=true><a href=" + urlExt + " ><img src='/WF/Img/Btn/Open.gif' border=0/></a></TD>");
            }
            else
            {
                this.ucsys1.AddTD();
            }
            this.ucsys1.AddTREnd();
        }

        #region 生成合计
        if (false)
        {
            this.ucsys1.AddTRSum();
            this.ucsys1.AddTD("colspan=1", "合计");
            foreach (Attr attr in attrs)
            {
                if (attr.UIVisible == false)
                {
                    continue;
                }

                if (attr.IsNum && attr.IsFKorEnum == false)
                {
                    TB tb = new TB();
                    tb.ID        = "TB_" + attr.Key;
                    tb.Text      = attr.DefaultVal.ToString();
                    tb.ShowType  = attr.HisTBType;
                    tb.ReadOnly  = true;
                    tb.Font.Bold = true;
                    tb.BackColor = System.Drawing.Color.FromName("infobackground");

                    switch (attr.MyDataType)
                    {
                    case DataType.AppRate:
                    case DataType.AppMoney:
                        tb.TextExtMoney = ens.GetSumDecimalByKey(attr.Key);
                        break;

                    case DataType.AppInt:
                        tb.TextExtInt = ens.GetSumIntByKey(attr.Key);
                        break;

                    case DataType.AppFloat:
                        tb.TextExtFloat = ens.GetSumFloatByKey(attr.Key);
                        break;

                    default:
                        break;
                    }
                    this.ucsys1.AddTD(tb);
                }
                else
                {
                    this.ucsys1.AddTD();
                }
            }

            if (map.IsHaveFJ)
            {
                this.ucsys1.AddTD();
            }

            this.ucsys1.AddTD();
            this.ucsys1.AddTREnd();
        }
        #endregion 生成合计

        #endregion 生成数据

        this.ucsys1.AddTableEnd();
    }
Пример #22
0
        /// <summary>
        /// 单据生成
        /// </summary>
        /// <param name="cfile">模板文件</param>
        /// <param name="path">生成路径</param>
        /// <param name="file">生成文件</param>
        /// <param name="isOpen">是否用IE打开?</param>
        public void MakeDoc(string cfile, string path, string file, string replaceVals, bool isOpen)
        {
            string str = Cash.GetBillStr(cfile, false).Substring(0);

            if (this.HisEns.Count == 0)
            {
                if (this.HisGEEntity == null)
                {
                    throw new Exception("@您没有为报表设置数据源...");
                }
            }

            this.ensStrs = "";
            if (this.HisEns.Count != 0)
            {
                foreach (Entity en in this.HisEns)
                {
                    ensStrs += en.ToString();
                }
            }
            else
            {
                ensStrs = this.HisGEEntity.ToString();
            }

            string error = "";

            string[] paras = null;
            if (this.HisGEEntity != null)
            {
                paras = Cash.GetBillParas(cfile, ensStrs, this.HisGEEntity);
            }
            else
            {
                paras = Cash.GetBillParas(cfile, ensStrs, this.HisEns);
            }

            this.TempFilePath = path + file;
            try
            {
                string key = "";
                string ss  = "";

                #region 主表
                foreach (string para in paras)
                {
                    if (para == null || para == "")
                    {
                        continue;
                    }
                    try
                    {
                        if (para.Contains("ImgAth"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueByKey(para));
                        }
                        else if (para.Contains("Siganture"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueByKey(para));
                        }
                        else if (para.Contains("Img@AppPath"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueImgStrs(para));
                        }
                        else if (para.Contains(".BPPaint"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueBPPaintStrs(para));
                        }
                        else if (para.Contains(".M2M"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueM2MStrs(para));
                        }
                        else
                        {
                            str = str.Replace("<" + para + ">", this.GetCode(this.GetValueByKey(para)));
                        }
                    }
                    catch (Exception ex)
                    {
                        error += "取参数[" + para + "]出现错误:有以下情况导致此错误;1你用Text取值时间,此属性不是外键。2,类无此属性。<br>更详细的信息:<br>" + ex.Message;
                        if (SystemConfig.IsDebug)
                        {
                            throw new Exception(error);
                        }
                        Log.DebugWriteError(error);
                    }
                }
                #endregion

                #region 从表
                string    shortName = "";
                ArrayList al        = this.EnsDataDtls;
                foreach (Entities dtls in al)
                {
                    //  shortName = dtls.GetNewEntity.ToString().Substring(dtls.GetNewEntity.ToString().LastIndexOf(".") + 1);

                    Entity dtl       = dtls.GetNewEntity;
                    string dtlEnName = dtl.ToString();
                    shortName = dtlEnName.Substring(dtlEnName.LastIndexOf(".") + 1);

                    if (str.IndexOf(shortName) == -1)
                    {
                        continue;
                    }

                    int pos_rowKey = str.IndexOf(shortName);
                    int row_start = -1, row_end = -1;
                    if (pos_rowKey != -1)
                    {
                        row_start = str.Substring(0, pos_rowKey).LastIndexOf("\\row");
                        row_end   = str.Substring(pos_rowKey).IndexOf("\\row");
                    }

                    if (row_start != -1 && row_end != -1)
                    {
                        string row = str.Substring(row_start, (pos_rowKey - row_start) + row_end);
                        str = str.Replace(row, "");

                        Map map = dtls.GetNewEntity.EnMap;
                        int i   = dtls.Count;
                        while (i > 0)
                        {
                            i--;
                            string rowData = row.Clone() as string;
                            dtl = dtls[i];
                            foreach (Attr attr in map.Attrs)
                            {
                                switch (attr.MyDataType)
                                {
                                case DataType.AppDouble:
                                case DataType.AppFloat:
                                case DataType.AppRate:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStringByKey(attr.Key));
                                    break;

                                case DataType.AppMoney:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValDecimalByKey(attr.Key).ToString("0.00"));
                                    break;

                                case DataType.AppInt:
                                    if (attr.MyDataType == DataType.AppBoolean)
                                    {
                                        rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStrByKey(attr.Key));
                                        int v = dtl.GetValIntByKey(attr.Key);
                                        if (v == 1)
                                        {
                                            rowData = rowData.Replace("<" + shortName + "." + attr.Key + "Text>", "是");
                                        }
                                        else
                                        {
                                            rowData = rowData.Replace("<" + shortName + "." + attr.Key + "Text>", "否");
                                        }
                                    }
                                    else
                                    {
                                        rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStrByKey(attr.Key));
                                    }
                                    break;

                                default:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", GetCode(dtl.GetValStrByKey(attr.Key)));
                                    break;
                                }
                            }
                            str = str.Insert(row_start, rowData);
                        }
                    }
                }
                #endregion 从表

                #region 明细 合计信息。
                al = this.EnsDataDtls;
                foreach (Entities dtls in al)
                {
                    Entity dtl       = dtls.GetNewEntity;
                    string dtlEnName = dtl.ToString();
                    shortName = dtlEnName.Substring(dtlEnName.LastIndexOf(".") + 1);
                    //shortName = dtls.ToString().Substring(dtls.ToString().LastIndexOf(".") + 1);
                    Map map = dtl.EnMap;
                    foreach (Attr attr in map.Attrs)
                    {
                        switch (attr.MyDataType)
                        {
                        case DataType.AppDouble:
                        case DataType.AppFloat:
                        case DataType.AppMoney:
                        case DataType.AppRate:
                            key = "<" + shortName + "." + attr.Key + ".SUM>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumFloatByKey(attr.Key).ToString());
                            }

                            key = "<" + shortName + "." + attr.Key + ".SUM.RMB>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumFloatByKey(attr.Key).ToString("0.00"));
                            }

                            key = "<" + shortName + "." + attr.Key + ".SUM.RMBDX>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key,
                                                  GetCode(DA.DataType.ParseFloatToCash(dtls.GetSumFloatByKey(attr.Key))));
                            }
                            break;

                        case DataType.AppInt:
                            key = "<" + shortName + "." + attr.Key + ".SUM>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumIntByKey(attr.Key).ToString());
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                #endregion 从表合计

                #region 要替换的字段
                if (replaceVals != null && replaceVals.Contains("@"))
                {
                    string[] vals = replaceVals.Split('@');
                    foreach (string val in vals)
                    {
                        if (val == null || val == "")
                        {
                            continue;
                        }

                        if (val.Contains("=") == false)
                        {
                            continue;
                        }

                        string myRep = val.Clone() as string;

                        myRep = myRep.Trim();
                        myRep = myRep.Replace("null", "");
                        string[] myvals = myRep.Split('=');
                        str = str.Replace("<" + myvals[0] + ">", "<" + myvals[1] + ">");
                    }
                }
                #endregion

                StreamWriter wr = new StreamWriter(this.TempFilePath, false, Encoding.ASCII);
                str = str.Replace("<", "");
                str = str.Replace(">", "");
                wr.Write(str);
                wr.Close(); //88901381
            }
            catch (Exception ex)
            {
                string msg = "";
                if (SystemConfig.IsDebug)
                {  // 异常可能与单据的配置有关系。
                    try
                    {
                        this.CyclostyleFilePath = SystemConfig.PathOfDataUser + "\\CyclostyleFile\\" + cfile;
                        str = Cash.GetBillStr(cfile, false);
                        string s = RepBill.RepairBill(this.CyclostyleFilePath);
                        msg = "@已经成功的执行修复线  RepairLineV2,您重新发送一次或者,退后重新在发送一次,是否可以解决此问题。@" + s;
                    }
                    catch (Exception ex1)
                    {
                        msg = "执行修复线失败.  RepairLineV2 " + ex1.Message;
                    }
                }
                throw new Exception("生成文档失败:单据名称[" + this.CyclostyleFilePath + "] 异常信息:" + ex.Message + " @自动修复单据信息:" + msg);
            }
            if (isOpen)
            {
                PubClass.Print(System.Web.HttpContext.Current.Request.ApplicationPath + "Temp/" + file);
            }
        }
Пример #23
0
        public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
        {
            bool isDocked = msg.ReadBoolean();

            for (int i = 0; i < 2; i++)
            {
                if (hulls[i] == null)
                {
                    continue;
                }
                item.linkedTo.Remove(hulls[i]);
                hulls[i].Remove();
                hulls[i] = null;
            }

            if (gap != null)
            {
                item.linkedTo.Remove(gap);
                gap.Remove();
                gap = null;
            }

            if (isDocked)
            {
                ushort dockingTargetID = msg.ReadUInt16();

                bool isLocked = msg.ReadBoolean();

                Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
                if (targetEntity == null || !(targetEntity is Item))
                {
                    DebugConsole.ThrowError("Invalid docking port network event (can't dock to " + targetEntity?.ToString() ?? "null" + ")");
                    return;
                }

                DockingTarget = (targetEntity as Item).GetComponent <DockingPort>();
                if (DockingTarget == null)
                {
                    DebugConsole.ThrowError("Invalid docking port network event (" + targetEntity + " doesn't have a docking port component)");
                    return;
                }

                Dock(DockingTarget);

                if (isLocked)
                {
                    Lock(isNetworkMessage: true, forcePosition: true);
                }
            }
            else
            {
                Undock();
            }
        }
Пример #24
0
		string GetUniqueName( Set<string> names, Entity entity )
		{
			string name = entity.Name;
			if( string.IsNullOrEmpty( name ) )
				name = entity.ToString();
			string uniqueName;
			for( int n = 1; ; n++ )
			{
				uniqueName = name;
				if( n != 1 )
					uniqueName += n.ToString();
				if( !names.Contains( uniqueName ) )
					break;
			}
			return uniqueName;
		}
Пример #25
0
        protected override string LegendsDescription()
        {
            var timestring = base.LegendsDescription();

            var location = "in ";

            if (Subregion != null)
            {
                location += Subregion.ToString();
            }
            else
            {
                location += Site.AltName;
            }

            var devourertext = "an unknown creature";

            if (Hf_Devourer != null)
            {
                devourertext = $"the {Hf_Devourer.Race.ToString().ToLower()} {Hf_Devourer}";
            }

            if (Hf_Victim == null)
            {
                return
                    ($"{timestring} {devourertext} devoured a {VictimRace?.ToString()?.ToLower() ?? "UNKNOWN"} of {Entity?.ToString() ?? ""} in {location}.");
            }
            if (Entity == null)
            {
                return
                    ($"{timestring} {devourertext} devoured the {VictimRace.ToString().ToLower()} {Hf_Victim} {location}.");
            }


            return($"{timestring} the {"UNKNOWN"} {"UNKNOWN"} devoured the {"UNKNOWN"} {"UNKNOWN"} {location}.");
        }
Пример #26
0
 public override string ToString()
 {
     return(caster?.ToString() + "\n\n" + item?.ToString() + "\n\n" + action?.ToString());
 }
Пример #27
0
        public void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
        {
            bool launch = msg.ReadBoolean();

            if (launch)
            {
                ushort userId = msg.ReadUInt16();
                User = Entity.FindEntityByID(userId) as Character;
                Vector2 simPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle());
                float   rotation    = msg.ReadSingle();
                if (User != null)
                {
                    Shoot(User, simPosition, simPosition, rotation, ignoredBodies: User.AnimController.Limbs.Where(l => !l.IsSevered).Select(l => l.body.FarseerBody).ToList(), createNetworkEvent: false);
                }
                else
                {
                    Launch(User, simPosition, rotation);
                }
            }

            bool isStuck = msg.ReadBoolean();

            if (isStuck)
            {
                ushort  submarineID = msg.ReadUInt16();
                ushort  hullID      = msg.ReadUInt16();
                Vector2 simPosition = new Vector2(
                    msg.ReadSingle(),
                    msg.ReadSingle());
                Vector2 axis = new Vector2(
                    msg.ReadSingle(),
                    msg.ReadSingle());
                UInt16 entityID = msg.ReadUInt16();

                Entity    entity    = Entity.FindEntityByID(entityID);
                Submarine submarine = Entity.FindEntityByID(submarineID) as Submarine;
                Hull      hull      = Entity.FindEntityByID(hullID) as Hull;
                item.Submarine   = submarine;
                item.CurrentHull = hull;
                item.body.SetTransform(simPosition, item.body.Rotation);
                if (entity is Character character)
                {
                    byte limbIndex = msg.ReadByte();
                    if (limbIndex >= character.AnimController.Limbs.Length)
                    {
                        DebugConsole.ThrowError($"Failed to read a projectile update from the server. Limb index out of bounds ({limbIndex}, character: {character.ToString()})");
                        return;
                    }
                    if (character.Removed)
                    {
                        return;
                    }
                    var limb = character.AnimController.Limbs[limbIndex];
                    StickToTarget(limb.body.FarseerBody, axis);
                }
                else if (entity is Structure structure)
                {
                    byte bodyIndex = msg.ReadByte();
                    if (bodyIndex == 255)
                    {
                        bodyIndex = 0;
                    }
                    if (bodyIndex >= structure.Bodies.Count)
                    {
                        DebugConsole.ThrowError($"Failed to read a projectile update from the server. Structure body index out of bounds ({bodyIndex}, structure: {structure.ToString()})");
                        return;
                    }
                    var body = structure.Bodies[bodyIndex];
                    StickToTarget(body, axis);
                }
                else if (entity is Item item)
                {
                    if (item.Removed)
                    {
                        return;
                    }
                    var door = item.GetComponent <Door>();
                    if (door != null)
                    {
                        StickToTarget(door.Body.FarseerBody, axis);
                    }
                    else if (item.body != null)
                    {
                        StickToTarget(item.body.FarseerBody, axis);
                    }
                }
                else if (entity is  Submarine sub)
                {
                    StickToTarget(sub.PhysicsBody.FarseerBody, axis);
                }
                else
                {
                    DebugConsole.ThrowError($"Failed to read a projectile update from the server. Invalid stick target ({entity?.ToString() ?? "null"}, {entityID})");
                }
            }
            else
            {
                Unstick();
            }
        }
Пример #28
0
 public override string ToString()
 {
     return(Entity?.ToString() ?? string.Format("null {0}", nameof(EHandle)));
 }
Пример #29
0
        public string GetRecordName(ItemType itemType, int itemId)
        {
            Entity itemRec = GetRecord(itemType, itemId);

            return((itemRec == null) ? string.Empty : itemRec.ToString());
        }
Пример #30
0
        public void ToStringTest()
        {
            Entity entity = new Entity(NAME);

            Assert.AreEqual(entity.ToString(), NAME);
        }
Пример #31
0
        public SqlPreCommand DeleteSqlSync(Entity ident, string comment = null)
        {
            var pre         = OnPreDeleteSqlSync(ident);
            var collections = (from tml in this.TablesMList()
                               select new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                                                              .FormatWith(tml.Name, tml.BackReference.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()))).Combine(Spacing.Simple);

            var main = new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                                               .FormatWith(Name, this.PrimaryKey.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()));

            return(SqlPreCommand.Combine(Spacing.Simple, pre, collections, main));
        }
Пример #32
0
    static void RunTest(Store testlist, Entity test, bool shouldSucceed, int mode)
    {
        string inputpath = null, outputpath = null,
            inputformat = null, outputformat = null,
            inputbase = null, outputbase = null;

        if (mode == 0) {
            inputformat = "xml";
            outputformat = "n3";

            string uribase = "http://www.w3.org/2000/10/rdf-tests/rdfcore/";
            Resource input = testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#inputDocument")[0];
            inputbase = input.Uri;
            inputpath = input.Uri.Substring(uribase.Length);

            if (testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#outputDocument").Length > 0) {
                Resource output = testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#outputDocument")[0];
                outputpath = output.Uri.Substring(uribase.Length);
                outputbase = output.Uri;
            }
        } else if (mode == 1) {
            inputformat = "n3";
            outputformat = "n3";
            inputbase = "file:/home/syosi/cvs-trunk/WWW/2000/10/swap/test/n3parser.tests";

            string uribase = "http://www.example.org/";

            if (testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#inputDocument").Length == 0) return;
            Resource input = testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#inputDocument")[0];
            inputpath = input.Uri.Substring(uribase.Length);

            if (testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#outputDocument").Length > 0) {
                Resource output = testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#outputDocument")[0];
                outputpath = output.Uri.Substring(uribase.Length);
            }
        }

        string desc = test.ToString();
        try {
            desc += " " + ((Literal)testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#description")[0]).Value;
        } catch (Exception e) {
        }

        try {
            total++;

            RdfReader reader = RdfReader.Create(inputformat, Path.Combine(basepath, inputpath));
            reader.BaseUri = inputbase;

            MemoryStore inputmodel = new MemoryStore(reader);
            if (reader.Warnings.Count > 0) {
                string warnings = String.Join("; ", (string[])((ArrayList)reader.Warnings).ToArray(typeof(string)));
                throw new ParserException(warnings);
            }
            if (!shouldSucceed) {
                Console.WriteLine(desc + ": Should Not Have Passed **\n");
                badpass++;
                return;
            }

            if (shouldSucceed && outputpath != null) {
                RdfReader reader2 = RdfReader.Create(outputformat, Path.Combine(basepath, outputpath));
                reader2.BaseUri = outputbase;
                MemoryStore outputmodel = new MemoryStore(reader2);

                CompareModels(inputmodel, outputmodel);
            }
        } catch (System.IO.FileNotFoundException ex) {
            Console.WriteLine(inputpath + " Not Found");
            error++;
        } catch (System.IO.DirectoryNotFoundException ex) {
            Console.WriteLine(inputpath + " Not Found");
            error++;
        } catch (ParserException ex) {
            if (shouldSucceed) {
                Console.WriteLine(desc + ": " + ex.Message + " **");
                Console.WriteLine();
                badfail++;
            }
        }
    }
Пример #33
0
        public void BindEns(Entities ens, string ctrlId)
        {
            MapData md = new MapData(this.EnsName);

            this.Title = md.Name + " - 流程通用查询";

            this.UCSys1.Controls.Clear();
            Entity myen   = ens.GetNewEntity;
            string pk     = myen.PK;
            string clName = myen.ToString();
            Attrs  attrs  = myen.EnMap.Attrs;

            #region 求出可显示的属性。
            Attrs    selectedAttrs = new Attrs();
            string   attrKeyShow   = md.AttrsInTable;
            string[] strs          = md.AttrsInTable.Split('@');
            foreach (string str in strs)
            {
                if (str == null || str == "")
                {
                    continue;
                }

                string[] kv = str.Split('=');
                if (kv[0] == "MyNum")
                {
                    continue;
                }
                selectedAttrs.Add(myen.EnMap.GetAttrByKey(kv[0]));
            }
            #endregion 求出可显示的属性.

            #region  生成标题
            this.UCSys1.AddTable();
            this.UCSys1.AddTR();
            this.UCSys1.AddTDTitle("序");
            this.UCSys1.AddTDTitle("标题");
            foreach (Attr attr in selectedAttrs)
            {
                if (attr.IsRefAttr || attr.Key == "Title")
                {
                    continue;
                }
                this.UCSys1.AddTDTitle(attr.Desc);
            }
            #endregion  生成标题

            bool isRefFunc = false;
            isRefFunc = true;
            int  pageidx = this.PageIdx - 1;
            int  idx     = SystemConfig.PageSize * pageidx;
            bool is1     = false;

            #region 用户界面属性设置
            string focusField = "Title";
            int    WinCardH   = 500;
            int    WinCardW   = 400;
            #endregion 用户界面属性设置

            #region 数据输出.
            this.UCSys1.AddTREnd();
            string urlExt = "";
            foreach (Entity en in ens)
            {
                #region 处理keys
                string style = WebUser.Style;
                string url   = this.GenerEnUrl(en, attrs);
                #endregion

                this.UCSys1.AddTR();

                #region 输出字段。
                idx++;
                this.UCSys1.AddTDIdx(idx);
                this.UCSys1.AddTD("<a href=\"javascript:WinOpen('./../WFRpt.aspx?FK_Flow=" + this.FK_Flow + "&WorkID=" + en.GetValStrByKey("OID") + "&FID=" + en.GetValStrByKey("FID") + "','tdr');\" ><img src='../Img/Track.png' border=0 />" + en.GetValByKey("Title") + "</a>");
                string val = "";
                foreach (Attr attr in selectedAttrs)
                {
                    if (attr.IsRefAttr || attr.Key == "MyNum" || attr.Key == "Title")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        string s = en.GetValRefTextByKey(attr.Key);
                        if (s == null || s == "")
                        {
                            switch (attr.Key)
                            {
                            case "FK_NY":
                                s = en.GetValStringByKey(attr.Key);
                                break;

                            default:
                                break;
                            }
                        }
                        this.UCSys1.AddTD(s);
                        continue;
                    }

                    if (attr.UIHeight != 0)
                    {
                        this.UCSys1.AddTDDoc("...", "...");
                        return;
                    }

                    string str = en.GetValStrByKey(attr.Key);
                    if (focusField == attr.Key)
                    {
                        //str = "<b><font color='blue' ><a href=" + urlExt + ">" + str + "</font></b></a>";
                        str = "<b><font color='blue' >" + str + "</font></a>";
                    }
                    switch (attr.MyDataType)
                    {
                    case DataType.AppDate:
                    case DataType.AppDateTime:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }
                        this.UCSys1.AddTD(str);
                        break;

                    case DataType.AppString:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }

                        if (attr.UIHeight != 0)
                        {
                            this.UCSys1.AddTDDoc(str, str);
                        }
                        else
                        {
                            this.UCSys1.AddTD(str);
                        }
                        break;

                    case DataType.AppBoolean:
                        if (str == "1")
                        {
                            this.UCSys1.AddTD("是");
                        }
                        else
                        {
                            this.UCSys1.AddTD("否");
                        }
                        break;

                    case DataType.AppFloat:
                    case DataType.AppInt:
                    case DataType.AppRate:
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(str);
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDNum(decimal.Parse(str).ToString("0.00"));
                        break;

                    default:
                        throw new Exception("no this case ...");
                    }
                }
                #endregion 输出字段。


                this.UCSys1.AddTREnd();
            }
            #endregion 数据输出.

            #region  求合计代码写在这里。
            bool IsHJ = false;
            foreach (Attr attr in selectedAttrs)
            {
                if (attr.MyFieldType == FieldType.RefText || attr.Key == "Title")
                {
                    continue;
                }

                if (attr.UIContralType == UIContralType.DDL)
                {
                    continue;
                }

                if (attr.Key == "OID" ||
                    attr.Key == "MID" ||
                    attr.Key == "FID" ||
                    attr.Key.ToUpper() == "WORKID")
                {
                    continue;
                }

                switch (attr.MyDataType)
                {
                case DataType.AppDouble:
                case DataType.AppFloat:
                case DataType.AppInt:
                case DataType.AppMoney:
                    IsHJ = true;
                    break;

                default:
                    break;
                }
            }

            if (IsHJ)
            {
                this.UCSys1.Add("<TR class='Sum' >");
                this.UCSys1.AddTD("合计");
                this.UCSys1.AddTD();
                foreach (Attr attr in selectedAttrs)
                {
                    if (attr.Key == "MyNum")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        this.UCSys1.AddTD();
                        continue;
                    }

                    if (attr.UIVisible == false)
                    {
                        continue;
                    }

                    if (attr.Key == "OID" || attr.Key == "MID" || attr.Key.ToUpper() == "WORKID" || attr.Key == "FID")
                    {
                        this.UCSys1.AddTD();
                        continue;
                    }

                    switch (attr.MyDataType)
                    {
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppFloat:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppInt:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDJE(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    default:
                        this.UCSys1.AddTD();
                        break;
                    }
                } /*结束循环*/
                this.UCSys1.AddTREnd();
            }
            #endregion

            this.UCSys1.AddTableEnd();
        }
Пример #34
0
        private void HandleReceiveEntity(Entity ent)
        {
            if (ent is Response)
                HandleResponse(ent as Response);
            else if (ent is Request)
                HandleRequest(ent as Request);
            else if (ent is Notice)
                HandleNotice(ent as Notice);
            else
                Console.WriteLine("TEBPProvicer received an invalid entity (ignored).");

            if (ent.RequiresAnswer && !ent.Responded)
                throw new NotSupportedException("The entity " + ent.ToString() + " has not been responded to.");
        }
Пример #35
0
        /// <summary>
        /// 绑定实体集合.
        /// </summary>
        /// <param name="ens"></param>
        /// <param name="ctrlId"></param>
        public void BindEns(Entities ens, string ctrlId)
        {
            #region 定义变量.
            MapData md = new MapData(this.RptNo);
            if (this.Page.Title == "")
            {
                this.Page.Title = md.Name;
            }

            this.UCSys1.Controls.Clear();
            Entity myen   = ens.GetNewEntity;
            string pk     = myen.PK;
            string clName = myen.ToString();
            Attrs  attrs  = myen.EnMap.Attrs;
            #endregion 定义变量.

            this.UCSys1.AddTable("class='Table' cellspacing='0' cellpadding='0' border='0' style='width:100%;line-height:22px'");

            #region  生成表格标题
            this.UCSys1.AddTR();
            this.UCSys1.AddTDGroupTitle("style='text-align:center;width:40px;'", "序");
            this.UCSys1.AddTDGroupTitle("标题");

            foreach (Attr attr in attrs)
            {
                if (attr.IsRefAttr ||
                    attr.Key == "Title" ||
                    attr.Key == "MyNum")
                {
                    continue;
                }

                this.UCSys1.AddTDGroupTitle(attr.Desc);
            }

            this.UCSys1.AddTREnd();
            #endregion  生成表格标题

            #region 用户界面属性设置

            int pageidx = this.PageIdx - 1;
            int idx     = SystemConfig.PageSize * pageidx;
            #endregion 用户界面属性设置

            #region 数据输出.

            foreach (Entity en in ens)
            {
                #region 输出字段。

                idx++;
                this.UCSys1.AddTR();
                this.UCSys1.AddTDIdx(idx);
                this.UCSys1.AddTD("<a href=\"javascript:WinOpen('" + BP.WF.Glo.CCFlowAppPath + "WF/WFRpt.aspx?FK_Flow=" + this.currMapRpt.FK_Flow + "&WorkID=" + en.GetValStrByKey("OID") + "','tdr');\" >" + en.GetValByKey("Title") + "</a>");

                foreach (Attr attr in attrs)
                {
                    if (attr.IsRefAttr || attr.Key == "MyNum" || attr.Key == "Title")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        string s = en.GetValRefTextByKey(attr.Key);
                        if (string.IsNullOrEmpty(s))
                        {
                            switch (attr.Key)
                            {
                            case "FK_NY":     // 2012-01
                                s = en.GetValStringByKey(attr.Key);
                                break;

                            default:     //其他的情况,把编码输出出来.
                                s = en.GetValStringByKey(attr.Key);
                                break;
                            }
                        }
                        this.UCSys1.AddTD(s);
                        continue;
                    }

                    string str = en.GetValStrByKey(attr.Key);

                    switch (attr.MyDataType)
                    {
                    case DataType.AppDate:
                    case DataType.AppDateTime:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }
                        this.UCSys1.AddTD(str);
                        break;

                    case DataType.AppString:
                        if (str == "" || str == null)
                        {
                            str = "&nbsp;";
                        }

                        if (attr.UIHeight != 0)
                        {
                            this.UCSys1.AddTDDoc(str, str);
                        }
                        else
                        {
                            this.UCSys1.AddTD(str);
                        }
                        break;

                    case DataType.AppBoolean:
                        if (str == "1")
                        {
                            this.UCSys1.AddTD("是");
                        }
                        else
                        {
                            this.UCSys1.AddTD("否");
                        }
                        break;

                    case DataType.AppFloat:
                    case DataType.AppInt:
                    case DataType.AppRate:
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(str);
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDNum(decimal.Parse(str).ToString("0.00"));
                        break;

                    default:
                        throw new Exception("no this case ...");
                    }
                }

                this.UCSys1.AddTREnd();
                #endregion 输出字段。
            }
            #endregion 数据输出.

            #region 计算一下是否可以求出合计,主要是判断是否有数据类型在这个Entities中。

            bool IsHJ = false;
            foreach (Attr attr in attrs)
            {
                if (attr.IsRefAttr ||
                    attr.Key == "Title" ||
                    attr.Key == "MyNum")
                {
                    continue;
                }

                if (attr.UIVisible == false)
                {
                    continue;
                }

                if (attr.UIContralType == UIContralType.DDL)
                {
                    continue;
                }

                if (attr.Key == "OID" ||
                    attr.Key == "MID" ||
                    attr.Key == "FID" ||
                    attr.Key == "PWorkID" ||
                    attr.Key.ToUpper() == "WORKID")
                {
                    continue;
                }

                switch (attr.MyDataType)
                {
                case DataType.AppDouble:
                case DataType.AppFloat:
                case DataType.AppInt:
                case DataType.AppMoney:
                    IsHJ = true;
                    break;

                default:
                    break;
                }

                if (IsHJ)
                {
                    break;
                }
            }
            #endregion 计算一下是否可以求出合计,主要是判断是否有数据类型在这个Entities中。

            #region  输出合计。
            //edited by liuxc,2015.5.14,解决合计行错列问题
            if (IsHJ)
            {
                this.UCSys1.Add("<TR class='Sum' >");
                this.UCSys1.AddTD();
                this.UCSys1.AddTD("合计");
                foreach (Attr attr in attrs)
                {
                    //if (attr.Key == "MyNum")
                    //    continue;
                    if (attr.MyFieldType == FieldType.RefText ||
                        attr.Key == "Title" ||
                        attr.Key == "MyNum")
                    {
                        continue;
                    }

                    if (attr.UIContralType == UIContralType.DDL)
                    {
                        this.UCSys1.AddTD();
                        continue;
                    }

                    //if (attr.UIVisible == false)
                    //    continue;

                    if (attr.Key == "OID" || attr.Key == "MID" ||
                        attr.Key.ToUpper() == "WORKID" ||
                        attr.Key == "FID")
                    {
                        this.UCSys1.AddTD();
                        continue;
                    }

                    switch (attr.MyDataType)
                    {
                    case DataType.AppDouble:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppFloat:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppInt:
                        this.UCSys1.AddTDNum(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    case DataType.AppMoney:
                        this.UCSys1.AddTDJE(ens.GetSumDecimalByKey(attr.Key));
                        break;

                    default:
                        this.UCSys1.AddTD();
                        break;
                    }
                }
                /*结束循环*/
                //this.UCSys1.AddTD();
                this.UCSys1.AddTREnd();
            }

            #endregion

            this.UCSys1.AddTableEnd();
        }
 public override string ToString()
 {
     return(Entity?.ToString());
 }
Пример #37
0
        /// <summary>
        /// 生成单据根据
        /// </summary>
        /// <param name="templeteFile">模板文件</param>
        /// <param name="saveToFile"></param>
        /// <param name="mainDT"></param>
        /// <param name="dtls"></param>
        public void MakeDoc(string templeteFile, string saveToFile, DataTable mainDT, DataSet dtlsDS)
        {
            this.mainDT = mainDT;
            this.dtlsDS = dtlsDS;


            #region 生成参数。

            string str = Cash.GetBillStr(templeteFile, false).Substring(0);

            string   error = "";
            string[] paras = null;

            DataSet dsTemp = new DataSet();
            dsTemp.Tables.Add(mainDT);
            foreach (DataTable dttemp in dsTemp.Tables)
            {
                dsTemp.Tables.Add(dttemp);
            }

            Attrs attrs = new Attrs();
            foreach (DataTable dt in dsTemp.Tables)
            {
                foreach (DataColumn dc in dt.Columns)
                {
                    Attr attr = new Attr();
                    attr.Field = dc.ColumnName;
                    attr.Key   = dc.ColumnName;

                    switch (dc.DataType.ToString())
                    {
                    case "int":
                        attr.MyDataType = DataType.AppInt;
                        break;

                    case "decimal":
                    case "float":
                        attr.MyDataType = DataType.AppFloat;
                        break;

                    case "string":
                    default:
                        attr.MyDataType = DataType.AppString;
                        break;
                    }
                }
            }
            paras = Cash.GetBillParas_Gener(templeteFile, attrs);
            #endregion

            try
            {
                string key = "";
                string ss  = "";

                #region 主表
                foreach (string para in paras)
                {
                    if (para == null || para == "")
                    {
                        continue;
                    }
                    try
                    {
                        if (para.Contains("ImgAth"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueByKey(para));
                        }
                        else if (para.Contains("Siganture"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueByKey(para));
                        }
                        else if (para.Contains("Img@AppPath"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueImgStrs(para));
                        }
                        else if (para.Contains(".BPPaint"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueBPPaintStrs(para));
                        }
                        else if (para.Contains(".M2M"))
                        {
                            str = str.Replace("<" + para + ">", this.GetValueM2MStrs(para));
                        }
                        else
                        {
                            str = str.Replace("<" + para + ">", this.GetCode(this.GetValueByKey(para)));
                        }
                    }
                    catch (Exception ex)
                    {
                        error += "取参数[" + para + "]出现错误:有以下情况导致此错误;1你用Text取值时间,此属性不是外键。2,类无此属性。<br>更详细的信息:<br>" + ex.Message;
                        if (SystemConfig.IsDebug)
                        {
                            throw new Exception(error);
                        }
                        Log.DebugWriteError(error);
                    }
                }
                #endregion

                #region 从表
                string    shortName = "";
                ArrayList al        = this.EnsDataDtls;
                foreach (Entities dtls in al)
                {
                    //  shortName = dtls.GetNewEntity.ToString().Substring(dtls.GetNewEntity.ToString().LastIndexOf(".") + 1);

                    Entity dtl       = dtls.GetNewEntity;
                    string dtlEnName = dtl.ToString();
                    shortName = dtlEnName.Substring(dtlEnName.LastIndexOf(".") + 1);

                    if (str.IndexOf(shortName) == -1)
                    {
                        continue;
                    }

                    int pos_rowKey = str.IndexOf(shortName);
                    int row_start = -1, row_end = -1;
                    if (pos_rowKey != -1)
                    {
                        row_start = str.Substring(0, pos_rowKey).LastIndexOf("\\row");
                        row_end   = str.Substring(pos_rowKey).IndexOf("\\row");
                    }

                    if (row_start != -1 && row_end != -1)
                    {
                        string row = str.Substring(row_start, (pos_rowKey - row_start) + row_end);
                        str = str.Replace(row, "");

                        Map map = dtls.GetNewEntity.EnMap;
                        int i   = dtls.Count;
                        while (i > 0)
                        {
                            i--;
                            string rowData = row.Clone() as string;
                            dtl = dtls[i];
                            foreach (Attr attr in map.Attrs)
                            {
                                switch (attr.MyDataType)
                                {
                                case DataType.AppDouble:
                                case DataType.AppFloat:
                                case DataType.AppRate:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStringByKey(attr.Key));
                                    break;

                                case DataType.AppMoney:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValDecimalByKey(attr.Key).ToString("0.00"));
                                    break;

                                case DataType.AppInt:
                                    if (attr.MyDataType == DataType.AppBoolean)
                                    {
                                        rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStrByKey(attr.Key));
                                        int v = dtl.GetValIntByKey(attr.Key);
                                        if (v == 1)
                                        {
                                            rowData = rowData.Replace("<" + shortName + "." + attr.Key + "Text>", "是");
                                        }
                                        else
                                        {
                                            rowData = rowData.Replace("<" + shortName + "." + attr.Key + "Text>", "否");
                                        }
                                    }
                                    else
                                    {
                                        rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", dtl.GetValStrByKey(attr.Key));
                                    }
                                    break;

                                default:
                                    rowData = rowData.Replace("<" + shortName + "." + attr.Key + ">", GetCode(dtl.GetValStrByKey(attr.Key)));
                                    break;
                                }
                            }
                            str = str.Insert(row_start, rowData);
                        }
                    }
                }
                #endregion 从表

                #region 明细 合计信息。
                al = this.EnsDataDtls;
                foreach (Entities dtls in al)
                {
                    Entity dtl       = dtls.GetNewEntity;
                    string dtlEnName = dtl.ToString();
                    shortName = dtlEnName.Substring(dtlEnName.LastIndexOf(".") + 1);
                    //shortName = dtls.ToString().Substring(dtls.ToString().LastIndexOf(".") + 1);
                    Map map = dtl.EnMap;
                    foreach (Attr attr in map.Attrs)
                    {
                        switch (attr.MyDataType)
                        {
                        case DataType.AppDouble:
                        case DataType.AppFloat:
                        case DataType.AppMoney:
                        case DataType.AppRate:
                            key = "<" + shortName + "." + attr.Key + ".SUM>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumFloatByKey(attr.Key).ToString());
                            }

                            key = "<" + shortName + "." + attr.Key + ".SUM.RMB>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumFloatByKey(attr.Key).ToString("0.00"));
                            }

                            key = "<" + shortName + "." + attr.Key + ".SUM.RMBDX>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key,
                                                  GetCode(DA.DataType.ParseFloatToCash(dtls.GetSumFloatByKey(attr.Key))));
                            }
                            break;

                        case DataType.AppInt:
                            key = "<" + shortName + "." + attr.Key + ".SUM>";
                            if (str.IndexOf(key) != -1)
                            {
                                str = str.Replace(key, dtls.GetSumIntByKey(attr.Key).ToString());
                            }
                            break;

                        default:
                            break;
                        }
                    }
                }
                #endregion 从表合计

                StreamWriter wr = new StreamWriter(this.TempFilePath, false, Encoding.ASCII);
                str = str.Replace("<", "");
                str = str.Replace(">", "");
                wr.Write(str);
                wr.Close();
            }
            catch (Exception ex)
            {
                string msg = "";
                if (SystemConfig.IsDebug)
                {  // 异常可能与单据的配置有关系。
                    try
                    {
                        this.CyclostyleFilePath = SystemConfig.PathOfDataUser + "\\CyclostyleFile\\" + templeteFile;
                        str = Cash.GetBillStr(templeteFile, false);
                        string s = RepBill.RepairBill(this.CyclostyleFilePath);
                        msg = "@已经成功的执行修复线  RepairLineV2,您重新发送一次或者,退后重新在发送一次,是否可以解决此问题。@" + s;
                    }
                    catch (Exception ex1)
                    {
                        msg = "执行修复线失败.  RepairLineV2 " + ex1.Message;
                    }
                }
                throw new Exception("生成文档失败:单据名称[" + this.CyclostyleFilePath + "] 异常信息:" + ex.Message + " @自动修复单据信息:" + msg);
            }
        }