コード例 #1
0
    void OnTriggerExit2D(Collider2D other)
    {
        WeightData newObj = other.gameObject.GetComponent <WeightData>();

        if (newObj != null)
        {
            objectsOnFloor.Remove(newObj);
            DetermineWeight();
        }
    }
コード例 #2
0
        public ActionResult CalcWeight(WeightData weightCalculation)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Result = false, Calc = weightCalculation }));
            }

            weightCalc.Calculate(weightCalculation);

            return(Json(new { Result = true, Calc = weightCalculation }));
        }
コード例 #3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            TreeNode node = this.WDMTree.SelectedNode;

            if (node == null || node.Level != 1)
            {
                MessageBox.Show("请选择机型");
                return;
            }

            WDMIntegrationModule.Air     air    = airs[Convert.ToInt32(node.Tag)];
            WDMIntegrationModule.TOper[] topers = WDMIntegrationModule.GetOpers(node.Name);
            //Random r = new Random();

            List <WeightData> lstWeightData = new List <WeightData>();
            WeightData        parentWD      = new WeightData();

            parentWD.weightName = air.MC;
            parentWD.nID        = 0;

            parentWD.nParentID = -1;
            lstWeightData.Add(parentWD);

            //int i = r.Next(10);
            double weightValueSum = 0;

            for (int i = 0; i < topers.Length; i++)
            {
                WDMIntegrationModule.TOper toper = topers[i];
                if (node.Name == air.ID)
                {
                    WeightData wd = new WeightData();
                    wd.weightName  = toper.MC;
                    wd.nID         = i + 1;// Convert.ToInt32(toper.ID);
                    wd.weightValue = this.actualDataRadio.Checked ?
                                     (toper.SCW == 0 && this.useTestData.Checked ?
                                      toper.ZTW : toper.SCW) : toper.ZTW;
                    wd.nParentID = 0;

                    // 添加重量数据至重量数据列表
                    lstWeightData.Add(wd);

                    weightValueSum += wd.weightValue;
                }
            }
            parentWD.weightValue = weightValueSum;
            WeightSortData wsd = new WeightSortData();

            wsd.lstWeightData = lstWeightData;
            ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(wsd, 2);

            this.Close();
        }
コード例 #4
0
    // When another objects collider interacts with this collider,
    void OnTriggerEnter2D(Collider2D other)
    {
        WeightData newObj = other.gameObject.GetComponent <WeightData>();

        if (newObj != null)
        {
            damagePartSyst.Play();

            objectsOnFloor.Add(newObj);
            hitByHeavyObject = true;
            DetermineWeight();
        }
    }
コード例 #5
0
        private void btnQueryDone_Click(object sender, RoutedEventArgs e)
        {
            DateTime startDate = (DateTime)dpStartDate.SelectedDate;
            DateTime endDate   = (DateTime)dpEndDate.SelectedDate;
            //string[] members = new string[] { UserName };
            string sql = "select 我方文号,客户名称,申请类型,任务名称,任务属性,任务标识,承办人,初稿日,完成日 from Tasks,Cases where Tasks.案件ID=Cases.案件ID and 任务名称 not in ('请求实审') and (承办人='" + UserName + "') and (完成日 ";

            WeightData wtdt = new WeightData();

            wtdt = CalculateWeight2(startDate, endDate, sql);
            Firstdg.ItemsSource = wtdt.ResultTable.DefaultView;
            tbTotalWeight.Text  = wtdt.Totalweight.ToString();
        }
コード例 #6
0
        private void tbkDoneWeight_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WindowWeightDetail wd = new WindowWeightDetail();
            NormalClass        nc = new NormalClass();

            nc.Path = CurrentDir;
            nc.Done_ThisMonth(UserName);
            WeightData wtdt = new WeightData();

            wtdt = CalculateWeight(nc.DtResult);
            wd.Firstdg.ItemsSource = wtdt.ResultTable.DefaultView;
            wd.tbTotalWeight.Text  = wtdt.Totalweight.ToString();
            wd.Show();
        }
コード例 #7
0
ファイル: Deadline.xaml.cs プロジェクト: jiayushd/WpfWithNet
        private void OutofLimitByHand_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WindowWeightDetail wd = new WindowWeightDetail();
            NormalClass        nc = new NormalClass();

            nc.Path = CurrentDir;
            nc.OutofLimit();
            WeightData wtdt = new WeightData();

            wd.Firstdg.ItemsSource = wtdt.ResultTable.DefaultView;
            wd.tbTotalWeight.Text  = wtdt.Count.ToString();
            wd.Title = "部门超期案件列表";
            wd.Show();
        }
コード例 #8
0
ファイル: FromWDM.cs プロジェクト: algz/DesignAndEstimateSoft
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            TreeNode node = this.WDMTree.SelectedNode;
            if (node==null||node.Level != 1)
            {
                MessageBox.Show("请选择机型");
                return;
            }

            WDMIntegrationModule.Air air = airs[Convert.ToInt32(node.Tag)];
            WDMIntegrationModule.TOper[] topers = WDMIntegrationModule.GetOpers(node.Name);
            //Random r = new Random();

            List<WeightData> lstWeightData = new List<WeightData>();
            WeightData parentWD = new WeightData();
            parentWD.weightName = air.MC;
            parentWD.nID = 0;

            parentWD.nParentID = -1;
            lstWeightData.Add(parentWD);

            //int i = r.Next(10);
            double weightValueSum = 0;
            for(int i=0;i<topers.Length;i++)
            {
                WDMIntegrationModule.TOper toper = topers[i];
                if (node.Name == air.ID)
                {
                    WeightData wd = new WeightData();
                    wd.weightName = toper.MC;
                    wd.nID = i+1;// Convert.ToInt32(toper.ID);
                    wd.weightValue = this.actualDataRadio.Checked ?
                        (toper.SCW == 0 && this.useTestData.Checked ?
                        toper.ZTW : toper.SCW) : toper.ZTW;
                    wd.nParentID = 0;

                    // 添加重量数据至重量数据列表
                    lstWeightData.Add(wd);

                    weightValueSum += wd.weightValue;
                }
            }
            parentWD.weightValue = weightValueSum;
            WeightSortData wsd = new WeightSortData();
            wsd.lstWeightData = lstWeightData;
            ((WeightAssessmentForm)this.Owner).saveWeightDataGridView(wsd, 2);

            this.Close();
        }
コード例 #9
0
        private void tbkOverStock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            WindowWeightDetail wd = new WindowWeightDetail();
            NormalClass        nc = new NormalClass();

            nc.Path = CurrentDir;
            nc.OverStock();
            WeightData wtdt = new WeightData();

            wtdt = CalculateWeight(nc.DtResult);
            wd.Firstdg.ItemsSource = wtdt.ResultTable.DefaultView;
            wd.tbTotalWeight.Text  = wtdt.Count.ToString();
            wd.Title = "部门积压案件列表";
            wd.Show();
        }
コード例 #10
0
        private void btnGroupDone_Click(object sender, RoutedEventArgs e)
        {
            DateTime startDate = (DateTime)dpStartDate.SelectedDate;
            DateTime endDate   = (DateTime)dpEndDate.SelectedDate;
            //string[] members = new string[] { UserName };
            string members = "'舒丁', '熊文杰', '何茹玥', '刘赏源', '张杨', '王红红', '魏亮', '陈隆', '姚许', '虞凌霄', '郭小满', '罗美红', '吴黎丽' ";

            string sql = "select 我方文号,客户名称,申请类型,任务名称,任务属性,任务标识,承办人,初稿日,完成日 from Tasks,Cases where Tasks.案件ID=Cases.案件ID and 任务名称 not in ('请求实审') and (承办人 in (" + members + ")) and (完成日 ";

            WeightData wtdt = new WeightData();

            wtdt = CalculateWeight2(startDate, endDate, sql);
            Firstdg.ItemsSource = wtdt.ResultTable.DefaultView;
            tbTotalWeight.Text  = wtdt.Totalweight.ToString();
        }
コード例 #11
0
ファイル: Dijkstra.cs プロジェクト: polianadias/Trains
        /// <summary>
        /// Finds the node that has minimum weight calculated.
        /// </summary>
        /// <returns></returns>
        private char FindMinimumWeightNodeFromEdge()
        {
            int  minWeight = int.MaxValue;
            char result    = '\0';

            foreach (char node in edge)
            {
                WeightData data = weight.Find(d => d.Node.Equals(node));
                if (data != null && minWeight >= data.Weight)
                {
                    minWeight = data.Weight;
                    result    = data.Node;
                }
            }
            return(result);
        }
コード例 #12
0
        private void WriteTreeDataToList(TreeNode node, ref List <WeightData> wdList, ref int nNodeID)
        {
            int nParentID = nNodeID;

            foreach (TreeNode subnode in node.Nodes)
            {
                WeightData wd = new WeightData();
                wd.nID        = ++nNodeID;
                wd.weightName = subnode.Text;
                wd.strRemark  = subnode.ToolTipText;
                wd.nParentID  = nParentID;
                wdList.Add(wd);

                WriteTreeDataToList(subnode, ref wdList, ref nNodeID);
            }
        }
コード例 #13
0
    public void RemoveID(string name, int EventID)
    {
        List <WeightData> list = this.weightList[name];
        int num   = 0;
        int count = list.Count;

        while (num < count)
        {
            WeightData item = list[num];
            if (item.EventID == EventID)
            {
                list.Remove(item);
                break;
            }
            num++;
        }
    }
コード例 #14
0
        /// <summary>
        /// 判断是否为最后一个节点的重量数据
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="weightSortData"></param>
        /// <returns></returns>
        private bool IsLastWeightNode(WeightData weight, WeightSortData weightSortData)
        {
            bool IsLast = true;

            if (weightSortData.lstWeightData.Count > 0)
            {
                foreach (WeightData data in weightSortData.lstWeightData)
                {
                    if (weight.nID == data.nParentID)
                    {
                        return(false);
                    }
                }
            }

            return(IsLast);
        }
コード例 #15
0
        /// <summary>
        /// WeightSortData
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static WeightSortData clsStringToWeightSortData(string str)
        {
            // 创建临时重量分类数据对象
            WeightSortData tempWeightSortData = null;

            // 创建重量数据列表对象
            List<WeightData> lstWeightData = null;
            //判断是否为空字符串
            if (str == null || str == string.Empty)
            {
                return null;
            }
            // 新重量分类数据
            tempWeightSortData = new WeightSortData();
            lstWeightData = new List<WeightData>();
            string[] tempStrings = str.Split('|');
            foreach (string tempString in tempStrings)
            {
                if (tempString == tempStrings[0])
                {
                    tempWeightSortData.sortName = tempString;
                }
                else
                {
                    // 获取重量数据
                    string[] tempInnerStrings = tempString.Split('、');
                    if (tempInnerStrings.Length > 1)
                    {
                        // 创建重量数据对象
                        WeightData tempWeightData = new WeightData();

                        tempWeightData.weightName = tempInnerStrings[0];
                        tempWeightData.nID = Convert.ToInt32(tempInnerStrings[1]);
                        tempWeightData.weightValue = Convert.ToDouble(tempInnerStrings[3]);
                        tempWeightData.nParentID = Convert.ToInt32(tempInnerStrings[4]);

                        // 添加重量数据至重量数据列表
                        lstWeightData.Add(tempWeightData);
                    }
                }
            }
            // 添加重量数据列表至重量分类
            tempWeightSortData.lstWeightData = lstWeightData;
            return tempWeightSortData;
        }
コード例 #16
0
ファイル: Dijkstra.cs プロジェクト: polianadias/Trains
        /// <summary>
        /// Sets the weight of a path to a node in weight list.
        /// </summary>
        /// <param name="minNode">Node that has the minimun weight at the moment.</param>
        /// <param name="node">Node to set the weight.</param>
        private void SetWeight(Node minNode, Node node)
        {
            WeightData minChargeData = weight.Find(c => c.Node.Equals(minNode.Label));
            Edge       conn          = minNode.edges.Find(n => n.NodeLabel.Equals(node.Label));

            WeightData data = weight.Find(c => c.Node.Equals(node.Label));

            if (data == null)
            {
                weight.Add(new WeightData {
                    Node = node.Label, Weight = minChargeData.Weight + conn.Weight
                });
            }
            else
            {
                data.Weight = minChargeData.Weight + conn.Weight;
            }
        }
コード例 #17
0
        public async Task <ActionResult <WeightResponse> > getWeightOnDay(string username, DateTime date)
        {
            if (await userRepository.getUser(username) == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "User not found!"));
            }

            WeightData data = await weightDataRepository.getWeightOnDay(username, date);

            if (data == null)
            {
                return(Ok(null));
            }
            else
            {
                return(Ok(WeightMapper.minimize(data)));
            }
        }
コード例 #18
0
        internal static WeightData CreateData(byte[] data)
        {
            var instance = new WeightData
            {
                Id            = (int)data[8],
                Lane          = (int)data[17],
                VehicleType   = ByteHelper.CreateIntFromBytes(data[20], data[21]),
                VehicleLength = ByteHelper.CreateIntFromBytes(data[22], data[23]),
                Speed         = ByteHelper.CreateIntFromBytes(data[24], data[25]),
                VehicleGap    = ByteHelper.CreateIntFromBytes(data[26], data[27]),
                Volation      = ByteHelper.CreateIntFromBytes(data[28], data[29]),
                TotalLoad     = ByteHelper.CreateIntFromBytes(data[30], data[31]),
            };
            var year       = ByteHelper.CreateIntFromBytes(data[10], data[11]);
            var milisecond = ByteHelper.CreateIntFromBytes(data[17], data[18]);

            instance.WeightDate = new DateTime(DateTime.Now.Year, data[12],
                                               data[13], data[14], data[15], data[16], milisecond);
            return(instance);
        }
コード例 #19
0
ファイル: Mesh.cs プロジェクト: Sewer56/sa_tools
 public void UpdateSelection(int selected)
 {
     if (selected != -1)
     {
         for (int i = 0; i < weights.Count; i++)
         {
             if (weights[i] != null)
             {
                 WeightData weight = weights[i].SingleOrDefault(a => a.Index == selected);
                 vertexBuffer[i].SetColor(GetColor(weight?.Weight ?? 0));
             }
             else
             {
                 foreach (T v in vertexBuffer)
                 {
                     v.SetColor(System.Drawing.Color.White);
                 }
             }
         }
     }
 }
コード例 #20
0
    void ISerializationCallbackReceiver.OnBeforeSerialize()
    {
        if (weights == null)
        {
            weights = new WeightData[thresholds == null ? 0 : thresholds.Length];

            if (weights.Length > 0)
            {
                for (int i = weights.Length - 1; i > 0;)
                {
                    weights[i] = new WeightData(thresholds[i].Key, thresholds[i].Value - thresholds[--i].Value);
                }
                weights[0] = new WeightData(thresholds[0]);

                sumWeights = 0;
            }


            thresholds = null;
        }
    }
コード例 #21
0
        public async Task <ActionResult> addWeight(WeightData data)
        {
            if (await userRepository.getUser(data.Username) == null)
            {
                return(StatusCode(StatusCodes.Status404NotFound, "User does not exist!"));
            }

            if (DateAndTime.Now.CompareTo(data.Date) < 0)
            {
                return(StatusCode(StatusCodes.Status403Forbidden, "Invalid date!"));
            }

            WeightData existing = await weightDataRepository.getWeightOnDay(data.Username, data.Date);

            if (existing == null)
            {
                if (await weightDataRepository.addWeight(data))
                {
                    return(Ok("Successfully added!"));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Some internal server error occurred while attempting to add your data!"));
                }
            }
            else
            {
                existing.Weight = data.Weight;
                existing.Height = data.Height;

                if (await weightDataRepository.updateWeight(existing))
                {
                    return(Ok("Successfully updated existing record!"));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, "Some internal server error occurred while attempting to edit your data!"));
                }
            }
        }
コード例 #22
0
        public ProfileModel(HttpContext context)
        {
            if (!context.HasValidUserAccount())
            {
                Name   = "";
                Weight = new WeightData();
                return;
            }

            var userAccount = context.UserAccount();

            Name = userAccount.DisplayName;

            Weight = DefaultWeightData();
            var userPref = ((object)userAccount).UserPrefs().Latest();

            if (userPref != null)
            {
                Weight.Units = userPref.WeightUnits;
                switch (Weight.Units)
                {
                case "kg":
                    Weight.Kg = userPref.Weight;
                    break;

                case "lbs":
                case "st":
                    Weight.Lbs   = userPref.Weight;
                    Weight.Units = "lbs";
                    break;
                }
                Weight.UpdateFromUnits();
                if (userPref.WeightUnits == "st")
                {
                    Weight.Units = "st";
                }
            }

            DistUnits = (int)context.UserDistanceUnits();
        }
コード例 #23
0
        private void showWeight()
        {
            WeightData  wtdt = new WeightData();
            NormalClass nc   = new NormalClass();

            nc.Path = CurrentDir;

            //计算个人初稿
            nc.FirstVirsion_ThisMonth(UserName);
            wtdt = CalculateWeight(nc.DtResult);
            tbkFirstVirsionTotalWeight.Text = wtdt.Totalweight.ToString();

            //计算个人递交
            nc.Done_ThisMonth(UserName);
            wtdt = CalculateWeight(nc.DtResult);
            tbkDoneWeight.Text = wtdt.Totalweight.ToString();

            //计算部门初稿
            nc.FirstVirsion_Group_ThisMonth();
            wtdt = CalculateWeight(nc.DtResult);
            tbkFirstVirsionGroupTotalWeight.Text = wtdt.Totalweight.ToString();

            //计算部门递交
            nc.Done_Group_ThisMonth();
            wtdt = CalculateWeight(nc.DtResult);
            tbkGroupDoneWeight.Text = wtdt.Totalweight.ToString();

            //计算积案
            nc.OverStock();
            wtdt = CalculateWeight(nc.DtResult);
            tbkOverStock.Text = wtdt.Count.ToString();

            //计算超期案件
            nc.OutofLimit();
            wtdt = CalculateWeight(nc.DtResult);
            tbkOutofLimit.Text = wtdt.Count.ToString();
        }
コード例 #24
0
        /// <summary>
        /// 获取修正后的重量数据
        /// </summary>
        /// <param name="jHSortData"></param>
        /// <param name="techSortData"></param>
        private WeightSortData GetModifyWeightData(WeightSortData jHSortData, WeightSortData techSortData)
        {
            WeightSortData sortData = null;
            if (jHSortData != null && jHSortData.lstWeightData.Count > 0
                && techSortData != null && techSortData.lstWeightData.Count > 0)
            {
                sortData = basicWeightData.Clone();

                List<WeightData> lstJHWeightData = WeightSortData.GetListWeightData(jHSortData);
                List<WeightData> lstTeachWeightData = WeightSortData.GetListWeightData(techSortData);

                List<WeightData> lstModifyWeightData = new List<WeightData>();

                foreach (WeightData data in lstJHWeightData)
                {
                    foreach (WeightData weight in lstTeachWeightData)
                    {
                        if (data.nID == weight.nID)
                        {
                            WeightData newWeight = new WeightData();

                            newWeight.nID = data.nID;
                            newWeight.nParentID = data.nParentID;
                            newWeight.weightName = data.weightName;
                            newWeight.weightValue = data.weightValue * weight.weightValue;
                            newWeight.strRemark = data.strRemark;
                            lstModifyWeightData.Add(newWeight);

                            break;
                        }
                    }
                }

                if (sortData != null && lstModifyWeightData.Count > 0)
                {
                    foreach (WeightData data in sortData.lstWeightData)
                    {
                        foreach (WeightData weight in lstModifyWeightData)
                        {
                            if (data.nID == weight.nID)
                            {
                                data.weightValue = weight.weightValue;
                                break;
                            }
                        }
                    }

                    //求和
                    foreach (WeightData data in sortData.lstWeightData)
                    {
                        WeightSortData.GetSortDataTotal(data, sortData);
                    }
                }

            }

            return sortData;
        }
コード例 #25
0
        private WeightSortData GetSortData(string strFilePath)
        {
            string path = string.Empty;
            XmlNode node = null;

            WeightSortData sortData = new WeightSortData();

            if (!File.Exists(strFilePath))
            {
                return sortData;
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(strFilePath);

            //重量分类名称
            path = "重量分类/重量分类名称";
            node = doc.SelectSingleNode(path);
            sortData.sortName = node.InnerText;

            //重量分类名称备注
            path = "重量分类/重量分类备注";
            node = doc.SelectSingleNode(path);
            sortData.strRemark = node.InnerText;

            //重量数据列表
            path = "重量分类/重量数据列表";
            node = doc.SelectSingleNode(path);

            List<WeightData> lstWeightData = new List<WeightData>();
            for (int m = 0; m < node.ChildNodes.Count; m++)
            {
                WeightData weightData = new WeightData();
                weightData.weightName = node.ChildNodes[m].ChildNodes[0].InnerText;
                weightData.strRemark = node.ChildNodes[m].ChildNodes[3].InnerText;

                lstWeightData.Add(weightData);
            }
            sortData.lstWeightData = lstWeightData;

            return sortData;
        }
コード例 #26
0
        /// <summary>
        /// Xml文件转换成WeightSortData类型
        /// </summary>
        /// <param name="strPath">文件路径</param>
        /// <returns>返回WeightSortData类型</returns>
        public static WeightSortData GetXmlImporSortData(string strPath)
        {
            WeightSortData sortData = null;

            try
            {
                if (!File.Exists(strPath))
                {
                    return sortData;
                }
                sortData = new WeightSortData();

                string path = string.Empty;
                XmlNode node = null;

                XmlDocument doc = new XmlDocument();
                doc.Load(strPath);

                //重量分类名称
                path = "重量分类/重量分类名称";
                node = doc.SelectSingleNode(path);
                sortData.sortName = (node == null ? string.Empty : node.InnerText);

                //重量分类备注
                path = "重量分类/重量分类备注";
                node = doc.SelectSingleNode(path);
                sortData.strRemark = (node == null ? string.Empty : node.InnerText);

                //重量列表
                path = "重量分类/重量数据列表";
                node = doc.SelectSingleNode(path);

                XmlNodeList nodelist = (node == null ? null : node.ChildNodes);

                if (nodelist != null && nodelist.Count > 0)
                {
                    List<WeightData> lstWeightData = new List<WeightData>();
                    foreach (XmlNode childNode in node.ChildNodes)
                    {
                        WeightData data = new WeightData();

                        data.nID = Convert.ToInt32(childNode.ChildNodes[0].InnerText);
                        data.weightName = childNode.ChildNodes[1].InnerText;
                        data.weightValue = Convert.ToDouble(childNode.ChildNodes[3].InnerText);
                        data.strRemark = childNode.ChildNodes[4].InnerText;
                        data.nParentID = Convert.ToInt32(childNode.ChildNodes[5].InnerText);

                        lstWeightData.Add(data);
                    }
                    sortData.lstWeightData = lstWeightData;
                }
            }
            catch
            {
                XLog.Write("导入文件\"" + strPath + "\"格式错误");
                MessageBox.Show("导入文件\"" + strPath + "\"格式错误");
                return null;
            }
            return sortData;
        }
コード例 #27
0
        private void WriteTreeDataToList(TreeNode node, ref List<WeightData> wdList, ref int nNodeID)
        {
            int nParentID = nNodeID;
            foreach (TreeNode subnode in node.Nodes)
            {
                WeightData wd = new WeightData();
                wd.nID = ++nNodeID;
                wd.weightName = subnode.Text;
                wd.strRemark = subnode.ToolTipText;
                wd.nParentID = nParentID;
                wdList.Add(wd);

                WriteTreeDataToList(subnode, ref wdList, ref nNodeID);
            }
        }
コード例 #28
0
        public static void ReadMeshData(Stream stream, Pmo pmo, int MeshNumber = 0)
        {
            // Go to mesh position.
            if (MeshNumber == 0)
            {
                stream.Seek(pmo.PMO_StartPosition + pmo.header.MeshOffset0, SeekOrigin.Begin);
            }
            else
            {
                stream.Seek(pmo.PMO_StartPosition + pmo.header.MeshOffset1, SeekOrigin.Begin);
            }

            UInt16 VertCnt = 0xFFFF;

            while (VertCnt > 0)
            {
                MeshChunks meshChunk = new MeshChunks();
                meshChunk.MeshNumber = MeshNumber;

                meshChunk.SectionInfo = Mapping.ReadObject <MeshSection>(stream);

                // Exit if Vertex Count is zero.
                if (meshChunk.SectionInfo.VertexCount <= 0)
                {
                    break;
                }

                meshChunk.TextureID = meshChunk.SectionInfo.TextureID;
                VertexFlags flags = GetFlags(meshChunk.SectionInfo);

                bool isColorFlagRisen = flags.UniformDiffuseFlag;

                if (pmo.header.SkeletonOffset != 0)
                {
                    meshChunk.SectionInfo_opt1 = Mapping.ReadObject <MeshSectionOptional1>(stream);
                }
                if (isColorFlagRisen)
                {
                    meshChunk.SectionInfo_opt2 = Mapping.ReadObject <MeshSectionOptional2>(stream);
                }
                if (meshChunk.SectionInfo.TriangleStripCount > 0)
                {
                    meshChunk.TriangleStripValues = new UInt16[meshChunk.SectionInfo.TriangleStripCount];
                    for (int i = 0; i < meshChunk.SectionInfo.TriangleStripCount; i++)
                    {
                        meshChunk.TriangleStripValues[i] = stream.ReadUInt16();
                    }
                }

                // Get Formats.
                CoordinateFormat TexCoordFormat       = flags.TextureCoordinateFormat;
                CoordinateFormat VertexPositionFormat = flags.PositionFormat;
                CoordinateFormat WeightFormat         = flags.WeightFormat;
                ColorFormat      ColorFormat          = flags.ColorFormat;
                UInt32           SkinningWeightsCount = flags.SkinningWeightsCount;
                BinaryReader     r = new BinaryReader(stream);
                long             positionAfterHeader = stream.Position;

                if (meshChunk.SectionInfo.TriangleStripCount > 0)
                {
                    int vertInd = 0;
                    for (int p = 0; p < meshChunk.SectionInfo.TriangleStripCount; p++)
                    {
                        for (int s = 0; s < (meshChunk.TriangleStripValues[p] - 2); s++)
                        {
                            if (s % 2 == 0)
                            {
                                meshChunk.Indices.Add(vertInd + s + 0);
                                meshChunk.Indices.Add(vertInd + s + 1);
                                meshChunk.Indices.Add(vertInd + s + 2);
                            }
                            else
                            {
                                meshChunk.Indices.Add(vertInd + s + 0);
                                meshChunk.Indices.Add(vertInd + s + 2);
                                meshChunk.Indices.Add(vertInd + s + 1);
                            }
                        }

                        vertInd += meshChunk.TriangleStripValues[p];
                    }
                }
                else
                {
                    if (flags.Primitive == PrimitiveType.PRIMITIVE_TRIANGLE_STRIP)
                    {
                        for (int s = 0; s < (meshChunk.SectionInfo.VertexCount - 2); s++)
                        {
                            if (s % 2 == 0)
                            {
                                meshChunk.Indices.Add(s + 0);
                                meshChunk.Indices.Add(s + 1);
                                meshChunk.Indices.Add(s + 2);
                            }
                            else
                            {
                                meshChunk.Indices.Add(s + 1);
                                meshChunk.Indices.Add(s + 0);
                                meshChunk.Indices.Add(s + 2);
                            }
                        }
                    }
                }

                for (int v = 0; v < meshChunk.SectionInfo.VertexCount; v++)
                {
                    long vertexStartPos       = stream.Position;
                    int  vertexIncreaseAmount = 0;

                    // Vertex Weights.
                    if (pmo.header.SkeletonOffset != 0 && WeightFormat != CoordinateFormat.NO_VERTEX)
                    {
                        WeightData WeightList = new WeightData();
                        WeightList.weights      = new List <float>();
                        WeightList.coordFormart = WeightFormat;

                        for (int i = 0; i < (SkinningWeightsCount + 1); i++)
                        {
                            switch (WeightFormat)
                            {
                            case CoordinateFormat.NORMALIZED_8_BITS:
                                WeightList.weights.Add(stream.ReadByte() / 128.0f);
                                break;

                            case CoordinateFormat.NORMALIZED_16_BITS:
                                WeightList.weights.Add(stream.ReadUInt16() / 32768.0f);
                                break;

                            case CoordinateFormat.FLOAT_32_BITS:
                                WeightList.weights.Add(stream.ReadFloat());
                                break;

                            case CoordinateFormat.NO_VERTEX:
                                break;
                            }
                        }

                        meshChunk.jointWeights.Add(WeightList);
                    }

                    Vector2 currentTexCoord = new Vector2(0, 0);

                    switch (TexCoordFormat)
                    {
                    case CoordinateFormat.NORMALIZED_8_BITS:
                        currentTexCoord.X = stream.ReadByte() / 128.0f;
                        currentTexCoord.Y = stream.ReadByte() / 128.0f;
                        meshChunk.textureCoordinates.Add(currentTexCoord);
                        break;

                    case CoordinateFormat.NORMALIZED_16_BITS:
                        vertexIncreaseAmount = ((0x2 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x1)) & 0x1);
                        stream.Seek(vertexIncreaseAmount, SeekOrigin.Current);

                        currentTexCoord.X = stream.ReadUInt16() / 32768.0f;
                        currentTexCoord.Y = stream.ReadUInt16() / 32768.0f;
                        meshChunk.textureCoordinates.Add(currentTexCoord);
                        break;

                    case CoordinateFormat.FLOAT_32_BITS:
                        vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3);
                        stream.Seek(vertexIncreaseAmount, SeekOrigin.Current);

                        currentTexCoord.X = stream.ReadFloat();
                        currentTexCoord.Y = stream.ReadFloat();
                        meshChunk.textureCoordinates.Add(currentTexCoord);
                        break;

                    case CoordinateFormat.NO_VERTEX:
                        meshChunk.textureCoordinates.Add(currentTexCoord);
                        break;
                    }

                    Vector4 col;

                    if (isColorFlagRisen)
                    {
                        uint c = meshChunk.SectionInfo_opt2.DiffuseColor;
                        col.X = c % 0x100;
                        col.Y = (c >> 8) % 0x100;
                        col.Z = (c >> 16) % 0x100;
                        col.W = (c >> 24) % 0x100;

                        meshChunk.colors.Add(col);
                    }
                    else
                    {
                        switch (ColorFormat)
                        {
                        case Pmo.ColorFormat.NO_COLOR:
                            meshChunk.colors.Add(new Vector4(0xFF, 0xFF, 0xFF, 0xFF));
                            break;

                        case Pmo.ColorFormat.BGR_5650_16BITS:
                            stream.ReadUInt16();
                            break;

                        case Pmo.ColorFormat.ABGR_5551_16BITS:
                            stream.ReadUInt16();
                            break;

                        case Pmo.ColorFormat.ABGR_4444_16BITS:
                            stream.ReadUInt16();
                            break;

                        case Pmo.ColorFormat.ABGR_8888_32BITS:
                            vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3);
                            stream.Seek(vertexIncreaseAmount, SeekOrigin.Current);

                            col.X = stream.ReadByte();
                            col.Y = stream.ReadByte();
                            col.Z = stream.ReadByte();
                            col.W = stream.ReadByte();
                            meshChunk.colors.Add(col);
                            break;
                        }
                    }

                    Vector3 currentVertex;

                    // Handle triangles and triangle strips.
                    switch (VertexPositionFormat)
                    {
                    case CoordinateFormat.NORMALIZED_8_BITS:
                        currentVertex.X = r.ReadSByte() / 128.0f;
                        currentVertex.Y = r.ReadSByte() / 128.0f;
                        currentVertex.Z = r.ReadSByte() / 128.0f;
                        meshChunk.vertices.Add(currentVertex);
                        break;

                    case CoordinateFormat.NORMALIZED_16_BITS:
                        vertexIncreaseAmount = ((0x2 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x1)) & 0x1);
                        stream.Seek(vertexIncreaseAmount, SeekOrigin.Current);

                        currentVertex.X = (float)stream.ReadInt16() / 32768.0f;
                        currentVertex.Y = (float)stream.ReadInt16() / 32768.0f;
                        currentVertex.Z = (float)stream.ReadInt16() / 32768.0f;
                        meshChunk.vertices.Add(currentVertex);
                        break;

                    case CoordinateFormat.FLOAT_32_BITS:
                        vertexIncreaseAmount = ((0x4 - (Convert.ToInt32(stream.Position - vertexStartPos) & 0x3)) & 0x3);
                        stream.Seek(vertexIncreaseAmount, SeekOrigin.Current);

                        currentVertex.X = stream.ReadFloat();
                        currentVertex.Y = stream.ReadFloat();
                        currentVertex.Z = stream.ReadFloat();
                        meshChunk.vertices.Add(currentVertex);
                        break;
                    }

                    stream.Seek(vertexStartPos + meshChunk.SectionInfo.VertexSize, SeekOrigin.Begin);

                    if (flags.Primitive == PrimitiveType.PRIMITIVE_TRIANGLE)
                    {
                        meshChunk.Indices.Add(v);
                    }
                }

                VertCnt = meshChunk.SectionInfo.VertexCount;
                pmo.Meshes.Add(meshChunk);

                // Find position of next data chunk.
                stream.Seek(positionAfterHeader + (meshChunk.SectionInfo.VertexCount * meshChunk.SectionInfo.VertexSize), SeekOrigin.Begin);
                stream.Seek(stream.Position % 4, SeekOrigin.Current);
            }
        }
コード例 #29
0
        /// <summary>
        ///xls文件转换成WeightSortData类型
        /// </summary>
        /// <param name="strFilePath">文件路径</param>
        /// <returns>返回WeightSortData类型</returns>
        public static WeightSortData GetXlsImportSortData(string strFilePath)
        {
            WeightSortData sortData = null;
            try
            {
                if (File.Exists(strFilePath))
                {
                    ExcelLib OpExcel = new ExcelLib();
                    //指定操作的文件
                    OpExcel.OpenFileName = strFilePath;
                    //打开文件
                    if (OpExcel.OpenExcelFile() == false)
                    {
                        return sortData;
                    }
                    //取得所有的工作表名称
                    string[] strSheetsName = OpExcel.getWorkSheetsName();

                    //默认操作第一张表
                    OpExcel.SetActiveWorkSheet(1);
                    System.Data.DataTable table;
                    table = OpExcel.getAllCellsValue();
                    OpExcel.CloseExcelApplication();

                    int count = table.Rows.Count;
                    if (count > 0)
                    {
                        sortData = new WeightSortData();
                        sortData.sortName = table.Rows[0][0].ToString();

                        List<WeightData> lstWeightData = new List<WeightData>();
                        for (int i = 0; i < count; i++)
                        {
                            WeightData data = new WeightData();

                            data.nID = Convert.ToInt32(table.Rows[i][1].ToString());
                            data.weightName = table.Rows[i][2].ToString();
                            data.weightValue = Convert.ToDouble(table.Rows[i][4].ToString());
                            data.strRemark = table.Rows[i][5].ToString();
                            data.nParentID = Convert.ToInt32(table.Rows[i][6].ToString());

                            lstWeightData.Add(data);
                        }
                        sortData.lstWeightData = lstWeightData;
                    }
                }
            }
            catch
            {
                XLog.Write("导入文件\"" + strFilePath + "\"格式错误");
                MessageBox.Show("导入文件\"" + strFilePath + "\"格式错误");
                return null;
            }
            return sortData;
        }
コード例 #30
0
 public WHOData()
 {
     weightPercentile = WeightData.getWeightData();
     heightPercentile = HeightData.getHeightData();
     headPercentile   = HeadCData.getHeadCData();
 }
コード例 #31
0
 public async Task <bool> updateWeight(WeightData weight)
 {
     context.Update(weight);
     return((await context.SaveChangesAsync()) > 0);
 }
コード例 #32
0
        /// <summary>
        /// 从XML文件中读取数据并转换成List<TypeWeightData>类型
        /// </summary>
        /// <param name="strFileName"></param>
        /// <returns></returns>
        private List<TypeWeightData> GetListTypeWeightDataExt(string strFileName)
        {
            List<TypeWeightData> lstWeightData = new List<TypeWeightData>();

            if (!File.Exists(strFileName))
            {
                return lstWeightData;
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(strFileName);//加载XML

            //机型列表
            XmlNodeList modelList=doc.SelectNodes("edccategory/inclass/node1");

            //XmlNodeList lstNodeDB = doc.GetElementsByTagName("inclass");

            //string dbId = string.Empty;
            //if (lstNodeDB != null && lstNodeDB.Count > 0)
            //{
            //    dbId = lstNodeDB[0].Attributes["id"].Value;
            //    lstNode1 = doc.GetElementsByTagName("node1"); //机型
            //    lstNode2 = doc.GetElementsByTagName("node2"); //参数类:第一个,基本数据;第二个,重量分类
            //    lstNode3 = doc.GetElementsByTagName("node3"); //重量分类-重量分类参数
            //    lstModel = doc.GetElementsByTagName("model"); //基本数据-参数名-值
            //}
            int count = bllTypeWeight.GetMaxId() + 1;
            //机型循环
            foreach (XmlNode modelNode in modelList)
            {
                TypeWeightData data = new TypeWeightData();
                data.Id = count++;

                XmlNodeList node2List = modelNode.SelectNodes("node2");

                //重量分类
                WeightSortData sortData = new WeightSortData();
                sortData.lstWeightData = new List<WeightData>();

                //基础信息
                data.Helicopter_Name = modelNode.Attributes["name"].Value;//直升机名称
                if(node2List[0]!=null)
                {
                    XmlNode childNode = node2List[0].SelectSingleNode("model");
                    if (childNode.Attributes["zsjlx"].Value != null)//直升机类型
                    {
                        data.Helicopter_Type = childNode.Attributes["zsjlx"].Value;
                    }
                    if (childNode.Attributes["zsjgj"].Value !=null)//直升机国籍
                    {
                        data.Helicoter_Country = childNode.Attributes["zsjgj"].Value;
                    }
                    if (childNode.Attributes["zsjkjzl"].Value !=null)//直升机空机重量
                    {
                        data.EmptyWeight = childNode.Attributes["zsjkjzl"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["zsjkjzl"].Value);
                    }
                    if (childNode.Attributes["zdqfzl"].Value!=null)//最大起飞重量
                    {
                        data.MaxTaking_Weight = childNode.Attributes["zdqfzl"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["zdqfzl"].Value);
                    }
                    if (childNode.Attributes["zsjsjqfzl"].Value != null)// "设计起飞重量"
                    {
                        data.DesignTaking_Weight = childNode.Attributes["zsjsjqfzl"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["zsjsjqfzl"].Value);
                    }
                    if (childNode.Attributes["updated"].Value != null)//"最后修改时间"
                    {
                        data.Last_ModifyTime = childNode.Attributes["updated"].Value;
                    }
                    if (childNode.Attributes["zlflmc"].Value != null )//"重量分类名称"
                    {
                        sortData.sortName = childNode.Attributes["zlflmc"].Value;
                    }
                }

                //层次结构
                //" zlid="0" zlmc="空机重量" zldw="千克" zlsz="3138.502" zlfjd="-1"
                XmlNode levelData=node2List[1];
                XmlNode topNode = levelData.SelectNodes("model")[0];//顶层结构结点
                XmlNodeList node3List = levelData.SelectNodes("node3");

                WeightData weightData = new WeightData();
                weightData.nID = int.Parse(topNode.Attributes["zlid"].Value);// "xlID"
                weightData.nParentID = int.Parse(topNode.Attributes["zlfjd"].Value); //"zlparentId"
                weightData.weightName = topNode.Attributes["zlmc"].Value; //"zlName"
                //weightData.weightUnit = topNode.Attributes["zldw"].Value;
                weightData.weightValue = topNode.Attributes["zlsz"].Value == null ? 0 : Convert.ToDouble(topNode.Attributes["zlsz"].Value);//zlsz
                //weightData.strRemark = topNode.Attributes["remarks"].Value;//zldesc
                List<WeightData> wdList= new List<WeightData>();
                wdList.Add(weightData);
                generateStruct(node3List,wdList);
                sortData.lstWeightData = wdList;
                sortData.lstWeightData = sortData.lstWeightData.OrderBy(s => s.nID).ToList();
                data.MainSystem_Name = GetMainSystemWeight(sortData);

                lstWeightData.Add(data);
            }

            return lstWeightData;
        }
コード例 #33
0
        /// <summary>
        /// 确定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string strSortName = txtWeightSortName.Text.Trim();

            if (strSortName.Length == 0)
            {
                MessageBox.Show("重量分类名称为空!");
                return;
            }
            else
            {
                if (Verification.IsCheckString(strSortName))
                {
                    MessageBox.Show("重量分类名称含有非法字符!");
                    return;
                }
            }

            if (treeViewWeightStructure.Nodes.Count == 0)
            {
                MessageBox.Show("重量分类必须有根节点!");
                return;
            }

            WeightSortData ws = null;
            if (strType == "edit" || strType == "readOnlyEdit")
            {
                foreach (WeightSortData tempwsd in WeightSortManageForm.GetListWeightSortData())
                {
                    if (tempwsd.sortName == strSortName)
                    {
                        ws = tempwsd;
                        ws.lstWeightData.Clear();
                    }
                }
                if (ws == null)
                {
                    MessageBox.Show("未知错误!");
                    return;
                }
            }
            else
            {
                ws = new WeightSortData();
            }
            ws.sortName = strSortName;

            int nNodeID = -1;
            for (int k = 0; k < treeViewWeightStructure.Nodes.Count; k++)
            {
                TreeNode subnode = treeViewWeightStructure.Nodes[k];
                List<WeightData> lstWeightData = ws.lstWeightData;

                //添加根节点
                WeightData rootWeightData = new WeightData();
                rootWeightData.nID = ++nNodeID;
                rootWeightData.weightName = subnode.Text;
                rootWeightData.strRemark = subnode.ToolTipText;
                rootWeightData.nParentID = -1;

                lstWeightData.Add(rootWeightData);

                WriteTreeDataToList(subnode, ref lstWeightData, ref nNodeID);
            }

            if (WeightSortManageForm.SaveHccFile(ws, strType != "edit" && strType != "readOnlyEdit"))
            {
                if (strType == "edit" || strType == "readOnlyEdit")
                {
                    XLog.Write("编辑重量分类成功");
                }
                else
                {
                    if (strType == "new")
                    {
                        XLog.Write("新建重量分类成功");
                    }
                    if (strType == "JYNew")
                    {
                        XLog.Write("基于新建重量分类成功");
                    }
                    WeightSortManageForm.GetListWeightSortData().Add(ws);
                }
                DialogResult = DialogResult.OK;
                this.Close();
            }
        }
コード例 #34
0
        private WeightData CalculateWeight(System.Data.DataTable dt)
        {
            WeightData wtdt = new WeightData();

            wtdt.Totalweight = 0;

            dt.Columns.Add("权值", typeof(double));
            foreach (DataRow dr in dt.Rows)
            {
                string taskType   = dr["申请类型"].ToString() + dr["任务名称"].ToString() + dr["任务属性"].ToString() + dr["任务标识"].ToString();
                double taskWeight = 0;
                switch (taskType)
                {
                case "PCT国际申请撰写":
                    taskWeight = 1.2;
                    break;

                case "PCT国际申请新申请":
                    taskWeight = 1.2;
                    break;

                case "PCT国际申请改写":
                    taskWeight = 0.5;
                    break;

                case "发明新申请撰写":
                case "发明新申请":
                    taskWeight = 1;
                    break;

                case "实用新型新申请":
                case "实用新型新申请撰写":
                    taskWeight = 0.7;
                    break;

                case "发明OA答复一通实质(S)":
                    taskWeight = 0.4;
                    break;

                case "发明OA答复二通实质(S)":
                case "实用新型OA答复一通实质(S)":
                    taskWeight = 0.2;
                    break;

                case "发明OA答复三通实质(S)":
                case "发明OA答复四通实质(S)":
                    taskWeight = 0.1;
                    break;

                case "发明OA答复一通形式-非本人失误(XN)":
                case "发明OA答复二通形式-非本人失误(XN)":
                case "发明OA答复三通形式-非本人失误(XN)":
                case "实用新型OA答复一通形式-非本人失误(XN)":
                case "实用新型OA答复二通形式-非本人失误(XN)":
                    taskWeight = 0.1;
                    break;

                default:
                    taskWeight = 0;
                    break;
                }
                dr["权值"] = taskWeight;


                wtdt.Totalweight = wtdt.Totalweight + taskWeight;
            }
            wtdt.ResultTable = dt;
            wtdt.Count       = dt.Rows.Count;
            return(wtdt);
        }
コード例 #35
0
        public ActionResult AutoCalcCalories(string date, int?route, double?distance)
        {
            WeightData weight = null;

            if (HttpContext.HasValidUserAccount(dataCache) && date != null)
            {
                var userAccount = HttpContext.UserAccount(dataCache);

                DateTime onDate;
                if (!DateTime.TryParseExact(date, "ddd, d MMM yyyy HH':'mm':'ss 'UTC'", null, DateTimeStyles.AssumeUniversal, out onDate))
                {
                    onDate = DateTime.UtcNow;
                }

                weight = ProfileModel.DefaultWeightData();
                var userPref = ((object)userAccount).UserPrefs().Latest(onDate);
                if (userPref != null)
                {
                    weight.Units = userPref.WeightUnits;
                    switch (weight.Units)
                    {
                    case "kg":
                        weight.Kg = userPref.Weight;
                        break;

                    case "lbs":
                    case "st":
                        weight.Lbs   = userPref.Weight;
                        weight.Units = "lbs";
                        break;
                    }
                    weight.UpdateFromUnits();
                    if (userPref.WeightUnits == "st")
                    {
                        weight.Units = "st";
                    }
                }
            }

            if (weight == null || weight.UnitWeight == 0 || (!route.HasValue && !distance.HasValue))
            {
                return(Json(new { Result = false }));
            }

            Distance actualDistance = null;

            if (route.HasValue && route.Value > 0)
            {
                var dbRoute = MassiveDB.Current.FindRoute(route.Value);
                if (dbRoute != null)
                {
                    actualDistance = new Distance((double)dbRoute.Distance, (DistanceUnits)dbRoute.DistanceUnits).ConvertTo(HttpContext.UserDistanceUnits(dataCache));
                }
            }

            if (distance.HasValue && distance.Value > 0)
            {
                actualDistance = new Distance(distance.Value, HttpContext.UserDistanceUnits(dataCache));
            }

            if (actualDistance == null)
            {
                return(Json(new { Result = false }));
            }

            return(Json(new { Result = true, Calories = caloriesCalc.Calculate(actualDistance, weight) }));
        }
コード例 #36
0
 public SpeedData(WeightData weight, PositionData position)
 {
     this.weight   = weight;
     this.position = position;
 }
コード例 #37
0
        private WeightData CalculateWeight2(DateTime startDate, DateTime endDate, string sql)
        {
            WeightData wtdt = new WeightData();

            wtdt.Totalweight = 0;


            sql = sql + "between #" + startDate + "# and #" + endDate + "#)";
            AccessCUID acuid = new AccessCUID();

            System.Data.DataTable dt = acuid.Query(sql, CurrentDir + "MyData\\dataset.accdb");
            dt.Columns.Add("权值", typeof(double));
            foreach (DataRow dr in dt.Rows)
            {
                string taskType   = dr["申请类型"].ToString() + dr["任务名称"].ToString() + dr["任务属性"].ToString() + dr["任务标识"].ToString();
                double taskWeight = 0;
                switch (taskType)
                {
                case "PCT国际申请新申请":
                    taskWeight = 1.2;
                    break;

                case "PCT国际申请撰写":
                    taskWeight = 1.2;
                    break;

                case "PCT国际申请改写":
                    taskWeight = 0.5;
                    break;

                case "发明新申请":
                case "发明新申请撰写":
                    taskWeight = 1;
                    break;

                case "实用新型新申请":
                case "实用新型新申请撰写":
                    taskWeight = 0.7;
                    break;

                case "发明OA答复一通实质(S)":
                    taskWeight = 0.4;
                    break;

                case "发明OA答复二通实质(S)":
                case "实用新型OA答复一通实质(S)":
                    taskWeight = 0.2;
                    break;

                case "发明OA答复三通实质(S)":
                case "发明OA答复四通实质(S)":
                    taskWeight = 0.1;
                    break;

                case "发明OA答复一通形式-非本人失误(XN)":
                case "发明OA答复二通形式-非本人失误(XN)":
                case "发明OA答复三通形式-非本人失误(XN)":
                case "实用新型OA答复一通形式-非本人失误(XN)":
                case "实用新型OA答复二通形式-非本人失误(XN)":
                    taskWeight = 0.1;
                    break;

                default:
                    taskWeight = 0;
                    break;
                }
                dr["权值"] = taskWeight;


                wtdt.Totalweight = wtdt.Totalweight + taskWeight;
            }
            wtdt.ResultTable = dt;
            return(wtdt);
        }
コード例 #38
0
        private List<TypeWeightData> GetListTypeWeightData(string strFileName)
        {
            List<TypeWeightData> lstWeightData = new List<TypeWeightData>();

            if (!File.Exists(strFileName))
            {
                return lstWeightData;
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(strFileName);

            XmlNodeList lstNodeDB = doc.GetElementsByTagName("inclass");

            string dbId = string.Empty;
            if (lstNodeDB != null && lstNodeDB.Count > 0)
            {
                dbId = lstNodeDB[0].Attributes["id"].Value;
                lstNode1 = doc.GetElementsByTagName("node1"); //机型
                lstNode2 = doc.GetElementsByTagName("node2"); //参数类:第一个,基本数据;第二个,重量分类
                lstNode3 = doc.GetElementsByTagName("node3"); //重量分类-重量分类参数
                lstModel = doc.GetElementsByTagName("model"); //基本数据-参数名-值
            }
            int count = 0;
            //机型循环
            foreach (XmlNode typeNode in lstNode1)
            {
                TypeWeightData data = new TypeWeightData();

                string strID = string.Empty;

                //型号ID
                if (typeNode.Attributes["pid"].Value == dbId)
                {
                    strID = typeNode.Attributes["id"].Value;
                    data.Id = bllTypeWeight.GetMaxId() + count;
                    count++;

                    string strSortName = string.Empty;
                    foreach (XmlNode node in lstNode2)
                    {
                        //基本信息
                        if (node.Attributes["pid"].Value == strID && node.Attributes["name"].Value == "基本信息" )
                        {
                            //机型名称
                            data.Helicopter_Name = typeNode.Attributes["name"].Value;
                            string strBasicId = node.Attributes["id"].Value;

                            foreach (XmlNode childNode in lstModel)
                            {
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "类型")
                                {
                                    data.Helicopter_Type = childNode.Attributes["value"].Value;
                                }
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "国籍")
                                {
                                    data.Helicoter_Country = childNode.Attributes["value"].Value;
                                }
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "空机重量")
                                {
                                    data.EmptyWeight = childNode.Attributes["value"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["value"].Value);
                                }
                                //if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "直升机名称")
                                //{
                                //    data.Helicopter_Name = childNode.Attributes["value"].Value;
                                //}
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "最大起飞重量")
                                {
                                    data.MaxTaking_Weight = childNode.Attributes["value"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["value"].Value);
                                }
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "设计起飞重量")
                                {
                                    data.DesignTaking_Weight = childNode.Attributes["value"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["value"].Value);
                                }
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "最后修改时间")
                                {
                                    data.Last_ModifyTime = childNode.Attributes["value"].Value;
                                }
                                if (childNode.Attributes["pid"].Value == strBasicId && childNode.Attributes["name"].Value == "重量分类名称")
                                {
                                   strSortName = childNode.Attributes["value"].Value;
                                }
                            }
                        }

                        //重量数据
                        if (node.Attributes["pid"].Value == strID && node.Attributes["name"].Value == "空机重量")
                        {
                            WeightSortData sortData = new WeightSortData();
                            sortData.lstWeightData = new List<WeightData>();
                            //重量分类名称
                            sortData.sortName = strSortName;

                            foreach (XmlNode node3 in lstNode3)
                            {
                                if (node3.Attributes["pid"].Value == node.Attributes["id"].Value)
                                {
                                    foreach (XmlNode childNode in lstModel)
                                    {
                                        if (childNode.Attributes["pid"].Value == node3.Attributes["id"].Value)
                                        {
                                            WeightData weightData = new WeightData();
                                            weightData.nID = int.Parse(childNode.Attributes["ID"].Value);// "xlID"
                                            weightData.nParentID = int.Parse(childNode.Attributes["PARENTID"].Value); //"zlparentId"
                                            weightData.weightName = childNode.Attributes["name"].Value; //"zlName"
                                            weightData.weightValue = childNode.Attributes["value"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["value"].Value);//zlsz
                                            weightData.strRemark = childNode.Attributes["remarks"].Value;//zldesc

                                            sortData.lstWeightData.Add(weightData);
                                            break;
                                        }
                                    }
                                }
                            }
                            foreach (XmlNode childNode in lstModel)
                            {
                                //空机重量
                                if (childNode.Attributes["pid"].Value == node.Attributes["id"].Value && childNode.Attributes["xlID"].Value == "0")//xlID
                                {
                                    WeightData weightData = new WeightData();
                                    weightData.nID = int.Parse(childNode.Attributes["ID"].Value);//xlID
                                    weightData.nParentID = int.Parse(childNode.Attributes["PARENTID"].Value);//zlparentId
                                    weightData.weightName = childNode.Attributes["name"].Value;//zlName
                                    weightData.weightValue = childNode.Attributes["value"].Value == null ? 0 : Convert.ToDouble(childNode.Attributes["value"].Value);//zlsz
                                    weightData.strRemark = childNode.Attributes["remarks"].Value;//zldesc

                                    sortData.lstWeightData.Add(weightData);
                                    break;
                                }
                            }
                            sortData.lstWeightData = sortData.lstWeightData.OrderBy(s => s.nID).ToList();
                            data.MainSystem_Name = GetMainSystemWeight(sortData);
                        }
                    }
                }
                lstWeightData.Add(data);
            }

            return lstWeightData;
        }
コード例 #39
0
ファイル: Deadline.xaml.cs プロジェクト: jiayushd/WpfWithNet
        private void namelist_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItem cbitem = new ComboBoxItem();

            cbitem = (ComboBoxItem)namelist.SelectedItem;
            //WindowWeightDetail wd = new WindowWeightDetail();
            int countsOfOutofLimitByHand;
            int countsOfNewApp_Total;


            WeightData  wtdt = new WeightData();
            NormalClass nc   = new NormalClass();

            nc.Path = CurrentDir;
            string name;

            name = cbitem.Content.ToString();
            name = name.Substring(2);
            //计算经手超期量
            nc.OutofLimitByHand(name);
            countsOfOutofLimitByHand = nc.Count;
            tbOutofLimitByHand.Text  = nc.Count.ToString();
            double daysOfOutofLimit = 0;

            foreach (DataRow dr in nc.DtResult.Rows)
            {
                if (!(dr["初稿日"] is DBNull) && (DateTime)dr["初稿日"] > (DateTime)dr["初稿期限(内)"] && (DateTime)dr["初稿期限(内)"] - (DateTime)dr["配案日"] > TimeSpan.FromDays(20))//初稿日没有
                {
                    daysOfOutofLimit += (double)dr["超期天数1"];
                }

                if (!(dr["初稿日"] is DBNull) && (DateTime)dr["初稿日"] > (DateTime)dr["初稿期限(内)"] && (DateTime)dr["初稿期限(内)"] - (DateTime)dr["配案日"] <= TimeSpan.FromDays(20) && (DateTime)dr["初稿日"] - (DateTime)dr["配案日"] > TimeSpan.FromDays(20))//初稿日没有
                {
                    daysOfOutofLimit += (double)dr["超期天数4"];
                }

                if (dr["初稿日"] is DBNull && dr["完成日"] is DBNull && DateTime.Now.Date - (DateTime)dr["配案日"] > TimeSpan.FromDays(20) && DateTime.Now.Date > (DateTime)dr["初稿期限(内)"])//初稿日没有
                {
                    daysOfOutofLimit += (double)dr["超期天数3"];
                }

                if (dr["初稿日"] is DBNull && !(dr["完成日"] is DBNull) && (DateTime)dr["完成日"] > (DateTime)dr["定稿期限(内)"])//初稿日没有
                {
                    daysOfOutofLimit += (double)dr["超期天数2"];
                }
            }
            tbDaysOfOutofLimit.Text = daysOfOutofLimit.ToString();

            //计算总量
            nc.NewApp_Total(name);
            countsOfNewApp_Total = nc.Count;
            tbNewApp_Total.Text  = nc.Count.ToString();

            //计算超期率
            double portionOfOutofLimit;

            portionOfOutofLimit = (double)countsOfOutofLimitByHand * 100 / countsOfNewApp_Total;
            portionOfOutofLimit = Math.Round(portionOfOutofLimit, 1);
            string txt_portionOfOutofLimit;

            if (portionOfOutofLimit != 0)
            {
                txt_portionOfOutofLimit = portionOfOutofLimit.ToString() + "%";
                //txt_portionOfOutofLimit = txt_portionOfOutofLimit.Substring(0, 4) + "%";
            }
            else
            {
                txt_portionOfOutofLimit = "0%";
            }
            if (portionOfOutofLimit < 0.1)
            {
                tbPortionOfOutofLimit.Foreground = new SolidColorBrush(Colors.Green);
            }

            tbPortionOfOutofLimit.Text = txt_portionOfOutofLimit;

            double scoreofdone = 0;



            //计算初稿权值
            nc.NewAppTotalWeight(name);
            wtdt = CalculateWeight(nc.DtResult);
            tbNewAppTotalWeight.Text = wtdt.Totalweight.ToString();
            scoreofdone = wtdt.Totalweight * 10;

            //计算OA数量
            nc.OACount(name);
            tbOACount.Text = nc.Count.ToString();
            scoreofdone    = scoreofdone + nc.Count * 3;

            tbScoreOfDone.Text = scoreofdone.ToString();
        }
コード例 #40
0
 public async Task <bool> addWeight(WeightData weight)
 {
     context.Add(weight);
     return((await context.SaveChangesAsync()) > 0);
 }
コード例 #41
0
        private void generateStruct(XmlNodeList nodeList, List<WeightData> wdList)
        {
            foreach (XmlNode node in nodeList)
            {
                XmlNode modelNode = node.SelectSingleNode("model");//顶层结构结点
                WeightData weightData = new WeightData();
                weightData.nID = int.Parse(modelNode.Attributes["zlid"].Value);// "xlID"
                weightData.nParentID = int.Parse(modelNode.Attributes["zlfjd"].Value); //"zlparentId"
                weightData.weightName = modelNode.Attributes["zlmc"].Value; //"zlName"
                //weightData.weightUnit = topNode.Attributes["zldw"].Value;
                weightData.weightValue = modelNode.Attributes["zlsz"].Value == null ? 0 : Convert.ToDouble(modelNode.Attributes["zlsz"].Value);//zlsz
                //weightData.strRemark = topNode.Attributes["remarks"].Value;//zldesc

                wdList.Add(weightData);

                XmlNodeList temList = node.SelectNodes("*[contains(name(),'node')]");
                if (temList.Count != 0)
                {
                    generateStruct(temList, wdList);
                }

            }
        }
コード例 #42
0
        /// <summary>
        /// 求重量分类的和
        /// </summary>
        /// <param name="data"></param>
        /// <param name="sortData"></param>
        /// <returns></returns>
        public static void GetSortDataTotal(WeightData data, WeightSortData sortData)
        {
            IEnumerable<WeightData> selection = from wd in sortData.lstWeightData where wd.nParentID == data.nID select wd;

            if (selection.Count() > 0)
            {
                foreach (WeightData weight in selection)
                {
                    GetSortDataTotal(weight, sortData);
                }
            }
            else
            {
                IEnumerable<WeightData> parentSelection = from wd in sortData.lstWeightData where wd.nID == data.nParentID select wd;
                IEnumerable<WeightData> childSelection = from wd in sortData.lstWeightData where wd.nParentID == data.nParentID select wd;

                double childValue = 0;
                foreach (WeightData weight in childSelection)
                {
                    childValue += weight.weightValue;
                }

                if (parentSelection.Count() > 0)
                {
                    foreach (WeightData weight in sortData.lstWeightData)
                    {
                        if (weight.nID == parentSelection.ToList()[0].nID)
                        {
                            weight.weightValue = childValue;
                        }
                    }
                }
            }
        }