Пример #1
0
        /// <summary>
        /// Called when a property needs to be published to client(s). Publishes a <see cref="MmoObjectEventMessage"/> on the <see cref="MmoObject.EventChannel"/>.
        /// Filters builtProperties which are private and ignores them.
        /// </summary>
        /// <param name="propertyCode"></param>
        /// <param name="value"></param>
        protected override void PublishProperty(PropertyCode propertyCode, object value)
        {
            switch (propertyCode)
            {
            // unchanged builtProperties
            // case PropertyCode.Name:
            // case PropertyCode.Species:
            // case PropertyCode.Class:
            // case PropertyCode.NpcType:

            // public builtProperties
            case PropertyCode.Level:
            case PropertyCode.MaxHp:
            case PropertyCode.CurrHp:
            case PropertyCode.UnitState:
            case PropertyCode.Alignment:
                break;                         // break

            // private builtProperties
            case PropertyCode.MaxPow:
            case PropertyCode.CurrPow:
                return;                         // return

            default:
                Logger.WarnFormat("PublishProperty.UnlistedProperty={0}", propertyCode);
                break;                         // break
            }

            // publish builtProperties on the event channel
            base.PublishProperty(propertyCode, value);
        }
Пример #2
0
        public PropertyCode ReturnCodeInfo(string propertyId)
        {
            PropertyCode retVal = new PropertyCode();
            Dal          dal    = new Dal();

            try
            {
                dal.ConnectionString = ReturnConnString();
                dal.Connect();
                DataSet ds = dal.ReturnDatasetFromStoredProcByPropID("ReturnCodeByPropID", propertyId);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        retVal.PropertyId = propertyId;
                        retVal.Maplot     = String.IsNullOrEmpty(dr["MapTaxLot"].ToString())
                            ? string.Empty : dr["MapTaxLot"].ToString();

                        retVal.CodeArea = String.IsNullOrEmpty(dr["CodeArea"].ToString())
                            ? string.Empty : dr["CodeArea"].ToString();

                        retVal.MaintenanceArea = String.IsNullOrEmpty(dr["Maint"].ToString())
                            ? string.Empty : dr["Maint"].ToString();
                    }
                    dal.Disconnect();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(retVal);
        }
Пример #3
0
 public void PropertyBook(Dictionary<string, string> hotelDictionary, string Browser)
 {
     Thread.Sleep(WDEx.delaySml);
     PropertyCode.SendKeys(hotelDictionary["HotelName"]);
     WDEx.dateSelector(webDriver, CheckIn, Browser, hotelDictionary["FromDate"]);
     WDEx.dateSelector(webDriver, CheckOut, Browser, hotelDictionary["ToDate"]);            
 }
Пример #4
0
 void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteAttributeString("code", PropertyCode.ToString());
     writer.WriteAttributeString("name", Name);
     writer.WriteAttributeString("columnName", ColumnName);
     writer.WriteAttributeString("type", PropertyType);
     writer.WriteAttributeString("direction", Direction.ToString());
     writer.WriteAttributeString("parameterType", ParameterType.ToString());
     writer.WriteAttributeString("isVolatile", IsVolatile.ToString().ToLower());
 }
Пример #5
0
        /// <summary>
        /// Called when a property needs to be published to client(s). Publishes a <see cref="MmoObjectEventMessage"/> on the <see cref="EventChannel"/>
        /// by default with the changed property.
        /// </summary>
        protected virtual void PublishProperty(PropertyCode propertyCode, object value)
        {
            var setProperty = new ObjectProperty
            {
                ObjectId       = this.Guid,
                PropertiesCode = (byte)propertyCode,
                EventData      = value
            };

            var msg = new MmoObjectEventMessage(this, setProperty, new MessageParameters {
                ChannelId = PeerSettings.MmoObjectEventChannel
            });

            this.EventChannel.Publish(msg);
        }
Пример #6
0
 private void WriteProperty(StringWriter writer, PropertyCode property, int tabs)
 {
     writer.WriteLineTabs($"public {property.Type} {property.Name} " + "{ get; set; }", tabs);
 }
Пример #7
0
    //=========================================================================
    /// <summary>
    /// Create and return a C# proxy class based on the specified DescriptionXML.
    /// </summary>
    public static string CreateProxyClassForDLL(string TypeName, string ClassName, string DLLFileName)
    {
        string DescriptionXML = "";

        try {
            DescriptionXML = ProbeDLLForDescriptionXML(TypeName, DLLFileName);
        } catch (Exception e) {
            Console.WriteLine(e.Message);
        }

        if (DescriptionXML != "")
        {
            string      ClassCode = "";
            XmlDocument Doc       = new XmlDocument();
            Doc.LoadXml(DescriptionXML);

            String  compClass = "";
            XmlNode classNode = XmlHelper.Find(Doc.DocumentElement, "class");
            if (classNode != null)
            {
                String typeName    = classNode.InnerText;
                int    firstPeriod = typeName.IndexOf('.');
                compClass = firstPeriod == -1 ? typeName : typeName.Substring(0, firstPeriod);
            }
            if (compClass == "")
            {
                compClass = Path.GetFileNameWithoutExtension(DLLFileName);
            }

            if (compClass.Length > 0)
            {
                ClassCode = "[ComponentType(\"" + compClass + "\")]\r\n";
            }
            ClassCode += "public class $CLASSNAME$ : ModelFramework.Component\r\n" +
                         "   {\r\n" +
                         "   public $CLASSNAME$(string _FullName, object _Comp) : base (_FullName, _Comp) {}\r\n";

            // Write all properties
            foreach (XmlNode Node in XmlHelper.ChildNodes(Doc.DocumentElement, "property"))
            {
                if (XmlHelper.Name(Node).IndexOfAny("{}/\\ ".ToCharArray()) == -1)
                {
                    string PropertyCode;
                    if (XmlHelper.Attribute(Node, "access") == "none")
                    {
                        continue;
                    }
                    if (XmlHelper.Attribute(Node, "access") == "read")
                    {
                        PropertyCode = "$DESCRIPTION$ $UNITS$ public $TYPE$ $NAME$ {$GETTER$}\r\n";
                    }
                    else
                    {
                        PropertyCode = "   public $TYPE$ $NAME$ \r\n" +
                                       "      {\r\n" +
                                       "$GETTER$\r\n" +
                                       "$SETTER$\r\n" +
                                       "      }\r\n";
                    }
                    string GetterCode = "      get {return Variable(\"$NAME$\").To$DOTNETTYPE$();}";
                    string SetterCode = "      set {Variable(\"$NAME$\").Set(value);}";

                    XmlNode TypeNode = XmlHelper.Find(Node, "type");
                    if (TypeNode != null &&
                        XmlHelper.Attribute(TypeNode, "kind") != "" &&
                        XmlHelper.Attribute(TypeNode, "kind") != "defined" &&
                        XmlHelper.ChildNodes(TypeNode, "field").Count == 0)
                    {
                        string PropertyTypeName = GetDotNetType(TypeNode);
                        string Description      = XmlHelper.Attribute(TypeNode, "description");
                        if (Description == "")
                        {
                            Description = XmlHelper.Attribute(Node, "descr");
                            if (Description == "")
                            {
                                XmlNode descriptionNode = XmlHelper.Find(Node, "Description");
                                if (descriptionNode != null)
                                {
                                    Description = descriptionNode.InnerText;
                                }
                            }
                        }
                        if (Description != "")
                        {
                            Description = "   [Description(\"" + Description + "\")]";
                        }
                        string Units = XmlHelper.Attribute(TypeNode, "unit");
                        if (Units != "")
                        {
                            Units = "   [Units(\"" + Units + "\")]";
                        }
                        if (XmlHelper.Attribute(Node, "access") == "read" ||
                            XmlHelper.Attribute(Node, "access") == "both")
                        {
                            PropertyCode = PropertyCode.Replace("$GETTER$", GetterCode);
                        }
                        else
                        {
                            PropertyCode = PropertyCode.Replace("$GETTER$\r\n", "");
                        }

                        if (XmlHelper.Attribute(Node, "access") == "write" ||
                            XmlHelper.Attribute(Node, "access") == "both")
                        {
                            PropertyCode = PropertyCode.Replace("$SETTER$", SetterCode);
                        }
                        else
                        {
                            PropertyCode = PropertyCode.Replace("$SETTER$\r\n", "");
                        }

                        string PropertyName = XmlHelper.Name(Node);
                        string DotNetType   = GetDotNetTypeName(TypeNode);
                        if (PropertyName == "today")
                        {
                            PropertyName     = "Today";
                            PropertyTypeName = "DateTime";
                            DotNetType       = "DateTime";
                        }

                        PropertyCode = PropertyCode.Replace("$TYPE$", PropertyTypeName);
                        PropertyCode = PropertyCode.Replace("$DOTNETTYPE$", DotNetType);
                        PropertyCode = PropertyCode.Replace("$NAME$", PropertyName);
                        PropertyCode = PropertyCode.Replace("$DESCRIPTION$", Description);
                        PropertyCode = PropertyCode.Replace("$UNITS$", Units);
                        ClassCode   += PropertyCode;
                    }
                }
            }

            // Write all events
            foreach (XmlNode Node in XmlHelper.ChildNodes(Doc.DocumentElement, "event"))
            {
                string EventName = XmlHelper.Name(Node);
                string EventCode = "";
                bool   NullType  = (XmlHelper.ChildNodes(Node, "field").Count == 0);
                if (XmlHelper.Attribute(Node, "kind") == "subscribed")
                {
                    if (XmlHelper.Find(Node, "param1_name") == null)  // make sure its not an Apsim Variant.
                    {
                        if (!NullType)
                        {
                            // Create a method that takes a structure for an argument.
                            string CamelName = StringManip.CamelCase(EventName + "Type");
                            if (XmlHelper.Attribute(Node, "typename") != "")
                            {
                                CamelName = StringManip.CamelCase(XmlHelper.Attribute(Node, "typename") + "Type");
                            }
                            // Ugly hack to prevent ambiguity between stock "buy" and supplement "buy"
                            else if (EventName.Equals("Buy", StringComparison.OrdinalIgnoreCase) &&
                                     compClass.Equals("Supplement", StringComparison.OrdinalIgnoreCase))
                            {
                                CamelName = "SupplementBuyType";
                            }
                            else
                            {
                                XmlNode TypeNode = XmlHelper.Find(Node, "type");
                                if (TypeNode != null && XmlHelper.Attribute(TypeNode, "typename") != "")
                                {
                                    CamelName = StringManip.CamelCase(XmlHelper.Attribute(TypeNode, "typename") + "Type");
                                }
                            }
                            EventCode += "   public void $CAMELEVENTNAME$(" + CamelName + " Data)\r\n";
                            EventCode += "      {\r\n";
                            EventCode += "      Publish(\"$EVENTNAME$\", Data);\r\n";
                            EventCode += "      }\r\n";
                        }
                        if (!IsComplexType(Node))
                        {
                            // SIMPLE EVENTS

                            // Simple structure - no nesting of types.
                            EventCode += "   public void $CAMELEVENTNAME$(";
                            bool First = true;
                            foreach (XmlNode Field in XmlHelper.ChildNodes(Node, "field"))
                            {
                                if (!First)
                                {
                                    EventCode += ", ";
                                }
                                string FieldTypeName = GetDotNetType(Field);
                                EventCode += FieldTypeName + " " + XmlHelper.Name(Field);
                                First      = false;
                            }
                            EventCode += ")\r\n";
                            EventCode += "      {\r\n";
                            EventCode += "      GenericType Data = new GenericType();\r\n";

                            foreach (XmlNode Field in XmlHelper.ChildNodes(Node, "field"))
                            {
                                EventCode += "      Data.Add(new $TYPENAME$Type ($NAME$));\r\n";
                                EventCode  = EventCode.Replace("$NAME$", XmlHelper.Name(Field));

                                EventCode = EventCode.Replace("$TYPE$", GetDotNetType(Field));
                                EventCode = EventCode.Replace("$TYPENAME$", GetDotNetTypeName(Field));
                            }
                            string DDML = MakeDDML(Node);
                            DDML       = DDML.Replace("\"", "\\\"");
                            EventCode += "      Data.SetDDML(\"" + DDML + "\");\r\n";
                            EventCode += "      Publish(\"$EVENTNAME$\", Data);\r\n";
                            EventCode += "      }\r\n";
                        }
                    }
                    EventCode = EventCode.Replace("$CAMELEVENTNAME$", StringManip.CamelCase(EventName));
                    string EventTypeName = XmlHelper.Attribute(Node, "typename");
                    if (EventTypeName == "")
                    {
                        EventTypeName = StringManip.CamelCase(EventName);
                    }
                    EventTypeName += "Type";
                    EventCode      = EventCode.Replace("$EVENTTYPE$", EventTypeName);
                }
                else
                {
                    // published event.
                    if (NullType || EventName.ToLower() == "error")
                    {
                        EventCode += "   [Event] public event NullTypeDelegate $EVENTNAME$;\r\n";
                    }
                    else
                    {
                        // Create a method that takes a structure for an argument.
                        string CamelName = StringManip.CamelCase(EventName) + "Delegate";;
                        if (XmlHelper.Attribute(Node, "typename") != "")
                        {
                            CamelName = StringManip.CamelCase(XmlHelper.Attribute(Node, "typename") + "Delegate");
                        }
                        else
                        {
                            XmlNode TypeNode = XmlHelper.Find(Node, "type");
                            if (TypeNode != null && XmlHelper.Attribute(TypeNode, "typename") != "")
                            {
                                CamelName = StringManip.CamelCase(XmlHelper.Attribute(TypeNode, "typename") + "Delegate");
                            }
                        }
                        EventCode += "   [Event] public event $CAMELDELEGATENAME$ $EVENTNAME$;\r\n";
                        EventCode  = EventCode.Replace("$CAMELDELEGATENAME$", CamelName);
                    }
                }
                EventCode  = EventCode.Replace("$EVENTNAME$", EventName);
                ClassCode += EventCode;
            }

            ClassCode += "   }\r\n";

            ClassCode = ClassCode.Replace("$CLASSNAME$", StringManip.CamelCase(ClassName));
            return(ClassCode);
        }
        else
        {
            return("");
        }
    }
Пример #8
0
        public CMCResponse UploadExcelFile()
        {
            try {
                //保存文件
                var    file     = System.Web.HttpContext.Current.Request.Files[0];
                string fullPath = HttpContext.Current.Server.MapPath("~/ExcelUpload/") + file.FileName;
                file.SaveAs(fullPath);

                //获取文件数据
                using (FileStream fs = new FileStream(fullPath, FileMode.Open))
                {
                    IWorkbook workbook     = new XSSFWorkbook(fs);
                    ISheet    sheet        = workbook.GetSheetAt(0);
                    int       lastRowIndex = sheet.LastRowNum;

                    //第一行获取活动名称
                    IRow   row          = sheet.GetRow(0);
                    int    rowLastIndex = row.LastCellNum - 1;
                    string activeName   = row.GetCell(rowLastIndex).StringCellValue;
                    int    lastColumn   = 0;
                    switch (activeName)
                    {
                    case "激活":
                        lastColumn = 9;

                        break;

                    case "营销":
                        lastColumn = 12;

                        break;

                    case "消费者":
                        lastColumn = 16;

                        break;

                    case "资产":
                        lastColumn = 18;

                        break;

                    case "资产领用":
                        lastColumn = 21;

                        break;

                    default:
                        Response.status  = 1;
                        Response.message = "上传活动名称有误";
                        return(Response);
                    }
                    //第3/4行获取名称基本信息
                    //List<string> nameList = new List<string>();
                    //List<string> basicInfo = new List<string>();
                    //for (int nameIndex = 0; nameIndex < lastColumn; nameIndex++)
                    //{
                    //    row = sheet.GetRow(2);
                    //    nameList.Add(row.GetCell(nameIndex).StringCellValue);
                    //}

                    //生成上传活动信息存入数据库
                    byte[] byteArray = new byte[file.ContentLength];
                    file.InputStream.Read(byteArray, 0, file.ContentLength);
                    //fs.Read(byteArray, 0, Convert.ToInt32(fs.Length));

                    IRow       row3       = sheet.GetRow(3);
                    CodeActive codeActive = new CodeActive();
                    codeActive.AppId           = "Excel文件上传";
                    codeActive.CorpCode        = row3.GetCell(5).StringCellValue;
                    codeActive.CorpName        = row3.GetCell(4).StringCellValue;
                    codeActive.SubCorpCode     = row3.GetCell(6).StringCellValue;
                    codeActive.ProductCode     = row3.GetCell(8).StringCellValue;
                    codeActive.ProductName     = row3.GetCell(7).StringCellValue;
                    codeActive.ProduceWorkline = row3.GetCell(6).StringCellValue;
                    codeActive.ActivityName    = activeName;
                    codeActive.Amount          = Convert.ToString(lastRowIndex - 2);
                    codeActive.ActualQuantity  = Convert.ToString(lastRowIndex - 2);
                    codeActive.UploadDate      = DateTime.Now;
                    codeActive.Uploader        = "CMC后台";
                    codeActive.ProcessType     = 3;
                    codeActive.Memo            = row3.GetCell(9).StringCellValue;
                    codeActive.ApplyId         = 0;

                    int activeID = CodeActiveUploadFactory.Instance.InsertNewActive(codeActive, byteArray);
                    if (activeName == "激活")
                    {
                        List <ActiveCode> alist = new List <ActiveCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            ActiveCode c = new ActiveCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            try
                            {
                                c.Code = row.GetCell(0).StringCellValue;
                            }
                            catch
                            {
                                c.Code = row.GetCell(0).NumericCellValue.ToString();
                            }
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode = row.GetCell(8).StringCellValue;
                            c.ProductName = row.GetCell(7).StringCellValue;
                            c.Memo        = row.GetCell(9).StringCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <ActiveCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                    if (activeName == "营销")
                    {
                        List <SalesCode> alist = new List <SalesCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            SalesCode c = new SalesCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            try
                            {
                                c.Code = row.GetCell(0).StringCellValue;
                            }
                            catch
                            {
                                c.Code = row.GetCell(0).NumericCellValue.ToString();
                            }
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode       = row.GetCell(8).StringCellValue;
                            c.ProductName       = row.GetCell(7).StringCellValue;
                            c.Memo              = row.GetCell(9).StringCellValue;
                            c.ActiveDescription = row.GetCell(10).StringCellValue;
                            c.ActiveStartDate   = row.GetCell(11).DateCellValue;
                            c.ActiveEndDate     = row.GetCell(12).DateCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <SalesCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                    if (activeName == "消费者")
                    {
                        List <CustomerCode> alist = new List <CustomerCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            CustomerCode c = new CustomerCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            try
                            {
                                c.Code = row.GetCell(0).StringCellValue;
                            }
                            catch
                            {
                                c.Code = row.GetCell(0).NumericCellValue.ToString();
                            }
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode       = row.GetCell(8).StringCellValue;
                            c.ProductName       = row.GetCell(7).StringCellValue;
                            c.Memo              = row.GetCell(9).StringCellValue;
                            c.ActiveDescription = row.GetCell(10).StringCellValue;
                            c.ActiveStartDate   = row.GetCell(11).DateCellValue;
                            c.ActiveEndDate     = row.GetCell(12).DateCellValue;
                            c.CustomerOpenID    = row.GetCell(13).StringCellValue;
                            c.CustomerTime      = row.GetCell(14).DateCellValue;
                            c.CustomerLocatio   = row.GetCell(15).StringCellValue;
                            c.WhatActive        = row.GetCell(16).StringCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <CustomerCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                    if (activeName == "消费者")
                    {
                        List <CustomerCode> alist = new List <CustomerCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            CustomerCode c = new CustomerCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            c.Code           = row.GetCell(0).NumericCellValue.ToString();
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode       = row.GetCell(8).StringCellValue;
                            c.ProductName       = row.GetCell(7).StringCellValue;
                            c.Memo              = row.GetCell(9).StringCellValue;
                            c.ActiveDescription = row.GetCell(10).StringCellValue;
                            c.ActiveStartDate   = row.GetCell(11).DateCellValue;
                            c.ActiveEndDate     = row.GetCell(12).DateCellValue;
                            c.CustomerOpenID    = row.GetCell(13).StringCellValue;
                            c.CustomerTime      = row.GetCell(14).DateCellValue;
                            c.CustomerLocatio   = row.GetCell(15).StringCellValue;
                            c.WhatActive        = row.GetCell(16).StringCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <CustomerCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                    if (activeName == "资产")
                    {
                        List <PropertyCode> alist = new List <PropertyCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            PropertyCode c = new PropertyCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            try
                            {
                                c.Code = row.GetCell(0).StringCellValue;
                            }
                            catch
                            {
                                c.Code = row.GetCell(0).NumericCellValue.ToString();
                            }
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode         = row.GetCell(8).StringCellValue;
                            c.ProductName         = row.GetCell(7).StringCellValue;
                            c.Memo                = row.GetCell(9).StringCellValue;
                            c.ProductProvider     = row.GetCell(17).StringCellValue;
                            c.ProductPurcheseDate = row.GetCell(18).DateCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <PropertyCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                    if (activeName == "资产领用")
                    {
                        List <PropertyUseCode> alist = new List <PropertyUseCode>();
                        //第4行开始获取数据
                        for (int index = 3; index <= lastRowIndex; index++)
                        {
                            //获取当前行
                            row = sheet.GetRow(index);
                            //生成Mongo对象存码信息

                            PropertyUseCode c = new PropertyUseCode();
                            c.ActiveName     = activeName;
                            c.CreateDate     = row.GetCell(2).DateCellValue;
                            c.ApplyId        = codeActive.ApplyId;
                            c.CodeActivityId = activeID;
                            c.CorpCode       = codeActive.CorpCode;
                            c.SubCorpCode    = codeActive.SubCorpCode;
                            c.CorpName       = codeActive.CorpName;
                            try
                            {
                                c.Code = row.GetCell(0).StringCellValue;
                            }
                            catch
                            {
                                c.Code = row.GetCell(0).NumericCellValue.ToString();
                            }
                            //c.MaskCode = row.GetCell(1).NumericCellValue.ToString();
                            c.ProductCode     = row.GetCell(8).StringCellValue;
                            c.ProductName     = row.GetCell(7).StringCellValue;
                            c.Memo            = row.GetCell(9).StringCellValue;
                            c.ClaimDepartment = row.GetCell(19).StringCellValue;
                            c.ClaimPerson     = row.GetCell(20).StringCellValue;
                            c.ClaimDate       = row.GetCell(21).DateCellValue;
                            alist.Add(c);
                        }
                        string res = ReportFactory.Instance.SplitMongoInster <PropertyUseCode>(alist);
                        if (res == "数据插入MongoDB失败")
                        {
                            Response.status       = 0;
                            this.Response.message = res + ",检查MongoDB是否正常";
                            return(Response);
                        }
                    }
                }

                //删除文件
                System.IO.File.Delete(fullPath);

                Response.status  = 1;
                Response.message = "上传成功";
            }
            catch (Exception e)
            {
                Response.status  = 0;
                Response.message = e.Message;
            }

            return(Response);
        }
Пример #9
0
 /// <summary>
 /// Called when a property needs to be published to client(s). Publishes a <see cref="MmoObjectEventMessage"/> on the <see cref="MmoObject.EventChannel"/>
 /// by default with the changed property.
 /// </summary>
 protected override sealed void PublishProperty(PropertyCode propertyCode, object value)
 {
     // usually we wont have any builtProperties to publish but for future sake let the base class handle it
     base.PublishProperty(propertyCode, value);
 }