当前位置: 首页>>代码示例>>C#>>正文


C# List.Clear方法代码示例

本文整理汇总了C#中Model.List.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# List.Clear方法的具体用法?C# List.Clear怎么用?C# List.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.List的用法示例。


在下文中一共展示了List.Clear方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportPurchasePlanStatus

        /// <summary> 对引用的前置单据的状态进行更新的方法
        /// </summary>
        /// <param name="list_order"></param>
        void ImportPurchasePlanStatus(List<OrderImportStatus> list_order, List<OrderFinishInfo> list_orderinfo)
        {
            SysSQLString sysStringSql = new SysSQLString();
            sysStringSql.cmdType = CommandType.Text;
            List<SysSQLString> listSql = new List<SysSQLString>();
            Dictionary<string, string> dic = new Dictionary<string, string>();
            List<string> list_plan = new List<string>();
            string plan_ids = string.Empty;

            #region 更新前置单据的导入状态字段
            foreach (OrderImportStatus item in list_order)
            {
                if (item.importtype == "采购计划单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_purchase_plan set [email protected]_status where [email protected]_num;";
                    dic.Add("import_status", !item.isfinish ? "2" : "3");//单据导入状态,0正常,1占用,2锁定(部分导入), 3锁定(全部导入)
                    dic.Add("order_num", item.order_num);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
                else if (item.importtype == "销售订单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_sale_order set [email protected]_occupy where [email protected]_num;";
                    dic.Add("is_occupy", !item.isfinish ? "2" : "3");//单据导入状态,0正常,1占用,2锁定(部分导入), 3锁定(全部导入)
                    dic.Add("order_num", item.order_num);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
            } 
            #endregion
            
            #region 更新前置单据中的各个配件的已完成数量
            foreach (OrderFinishInfo item in list_orderinfo)
            {
                if (!list_plan.Contains(item.plan_id))
                {
                    list_plan.Add(item.plan_id);
                    plan_ids = plan_ids + "'" + item.plan_id + "',";
                }
                if (item.importtype == "采购计划单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_purchase_plan_p set [email protected]_counts where [email protected]_id and [email protected]_code;";
                    dic.Add("finish_counts", item.finish_num);
                    dic.Add("plan_id", item.plan_id);
                    dic.Add("parts_code", item.parts_code);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
                else if (item.importtype == "销售订单")
                {
                    sysStringSql = new SysSQLString();
                    sysStringSql.cmdType = CommandType.Text;
                    dic = new Dictionary<string, string>();
                    string sql1 = "update tb_parts_sale_order_p set [email protected]_count where [email protected]_order_id and [email protected]_code;";
                    dic.Add("finish_count", item.finish_num);
                    dic.Add("sale_order_id", item.plan_id);
                    dic.Add("parts_code", item.parts_code);
                    sysStringSql.sqlString = sql1;
                    sysStringSql.Param = dic;
                    listSql.Add(sysStringSql);
                }
            } 
            #endregion
            bool ret = DBHelper.BatchExeSQLStringMultiByTrans("提交宇通采购订单,更新引用的采购计划单或销售订单的导入状态", listSql);
            if (ret)
            {
                if (list_orderinfo.Count > 0)
                {
                    listSql.Clear();
                    plan_ids = plan_ids.Trim(',');
                    string TableName = string.Format(@"
                   (
                    select plan_id,sum(finish_counts) finish_counts,
                    sum(finish_counts*business_price) as finish_money 
                        from tb_parts_purchase_plan_p 
                    where plan_id in ({0})
                    group by plan_id
                    ) tb_purchase_finish", plan_ids);
                    DataTable dt = DBHelper.GetTable("查询采购计划单各配件完成数量和完成金额", TableName, "*", "", "", "");
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sysStringSql = new SysSQLString();
                            sysStringSql.cmdType = CommandType.Text;
//.........这里部分代码省略.........
开发者ID:caocf,项目名称:workspace-kepler,代码行数:101,代码来源:UCYTAddOrEdit.cs

示例2: adjustTable

 private void adjustTable(DataTable dt, ref string exception)
 {
     //给table添加prbComment栏
     dt.Columns.Add("PrbComment");
     dt.Columns.Add("PrbPassed");
     List<PostResponseBook> posts = new List<PostResponseBook>();
     foreach (DataRow dr in dt.Rows)
     {
         posts.Clear();
         //0:已提交 1:已审核 2:已保存
         if (PostResponseBookBLL.Select(dr["UiID"].ToString(), ref posts, ref exception))
         {
             dr["PrbComment"] = posts[0].PrbComment;
             if (posts[0].PrbPassed.ToString() == "0")
             {
                 dr["PrbPassed"] = "已提交";
             }
             else if (posts[0].PrbPassed.ToString() == "1")
             {
                 dr["PrbPassed"] = "已审核";
             }
             else
             {
                 dr["PrbPassed"] = "已保存";
             }
         }
         else
         {
             dr["PrbComment"] = "";
             dr["PrbPassed"] = "未制作";
         }
     }
 }
开发者ID:cntimothy,项目名称:TJEvaluationSystem,代码行数:33,代码来源:MakePostBook.aspx.cs

示例3: BuildRealPath

        private void BuildRealPath()
        {
            int horLength = map.GetLength(0);
            int vertLength = map.GetLength(1);
            Point currentPosition = Point.Empty;
            Point destination = Point.Empty;
            for (int i = 0; i < horLength; i++)
            {
                for (int j = 0; j < vertLength; j++)
                {
                    if (this.mapWithIdealPath[i, j] == MyRoadType.CurrentPosition)
                    {
                        currentPosition = new Point(i, j);
                    }

                    if (this.mapWithIdealPath[i, j] == MyRoadType.Destination)
                    {
                        destination = new Point(i, j);
                    }
                }
            }

            HashSet<Point> usedPoints = new HashSet<Point>();
            List<Point> currentLevel = new List<Point> { destination };
            List<Point> nextLevel = new List<Point>();
            Action<Point> addIfIdeal = p =>
                {
                    if (p.X >= 0 && p.X < horLength && p.Y >= 0 && p.Y < vertLength
                        && this.mapWithIdealPath[p.X, p.Y] == MyRoadType.IdealPath)
                    {
                        nextLevel.Add(p);
                    }
                };

            while (true)
            {
                foreach (var point in currentLevel)
                {
                    if (!usedPoints.Contains(point))
                    {
                        if (CanDriveFromTo(currentPosition, point))
                        {
                            this.nextPoint = new PointF((point.X + 0.5f) * MyTileSize, (point.Y + 0.5f) * MyTileSize);
                            return;
                        }

                        usedPoints.Add(point);
                        addIfIdeal(new Point(point.X - 1, point.Y - 1));
                        addIfIdeal(new Point(point.X, point.Y - 1));
                        addIfIdeal(new Point(point.X + 1, point.Y - 1));
                        addIfIdeal(new Point(point.X - 1, point.Y));
                        addIfIdeal(new Point(point.X + 1, point.Y));
                        addIfIdeal(new Point(point.X - 1, point.Y + 1));
                        addIfIdeal(new Point(point.X, point.Y + 1));
                        addIfIdeal(new Point(point.X + 1, point.Y + 1));
                    }
                }

                if (nextLevel.Count == 0)
                {
                    break;
                }

                currentLevel.Clear();
                currentLevel.AddRange(nextLevel);
                nextLevel.Clear();
            }

            // TODO: We should not be here but we are. Fix this!!!
            this.nextPoint = new PointF((destination.X + 0.5f) * MyTileSize, (destination.Y + 0.5f) * MyTileSize);
        }
开发者ID:zzz77,项目名称:RussianAiCup15,代码行数:71,代码来源:NavigatorModule.cs

示例4: SaveCustomerNotBatch

 /// <summary>
 /// 非批量保存车辆客户信息
 /// </summary>
 /// <param name="customerArr">车辆客户信息</param>
 /// <param name="updateCount">更新条数</param>
 /// <returns></returns>
 private static bool SaveCustomerNotBatch(QueryCustomer.customer[] customerArr, ref int updateCount)
 {
     string nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime).ToString();
     int customerIndex = 0;//列表索引
     int customerCount = 10000;//每批执行条数
     //customerCount = customerArr.Count();
     int customerSum = customerArr.Count() / customerCount + 1;//执行批数
     //int contactSum = 3;
     bool flag = true;//执行结果
     DateTime startDate = DateTime.Now;
     YuTongDic dic = new YuTongDic();
     //客户
     DataTable dtCustomer = DBHelper.GetTable("获取车辆客户ID", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_customer", "cust_id,cust_code", null, null, null);
     #region 生成表列
     DataTable dt = new DataTable();
     List<DataRow> listTbCustomer = new List<DataRow>();
     dt.Columns.Add(new DataColumn("cust_crm_guid", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_id", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_code", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_name", typeof(string)));
     dt.Columns.Add(new DataColumn("province", typeof(string)));
     dt.Columns.Add(new DataColumn("city", typeof(string)));
     dt.Columns.Add(new DataColumn("county", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_address", typeof(string)));
     dt.Columns.Add(new DataColumn("zip_code", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_phone", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_fax", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_email", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_website", typeof(string)));
     dt.Columns.Add(new DataColumn("credit_rating", typeof(string)));
     dt.Columns.Add(new DataColumn("enable_flag", typeof(string)));
     dt.Columns.Add(new DataColumn("data_source", typeof(string)));
     dt.Columns.Add(new DataColumn("cust_relation", typeof(string)));
     dt.Columns.Add(new DataColumn("indepen_legalperson", typeof(string)));
     dt.Columns.Add(new DataColumn("market_segment", typeof(string)));
     dt.Columns.Add(new DataColumn("institution_code", typeof(string)));
     dt.Columns.Add(new DataColumn("com_constitution", typeof(string)));
     dt.Columns.Add(new DataColumn("registered_capital", typeof(string)));
     dt.Columns.Add(new DataColumn("agency", typeof(string)));
     dt.Columns.Add(new DataColumn("status", typeof(string)));
     dt.Columns.Add(new DataColumn("sap_code", typeof(string)));
     dt.Columns.Add(new DataColumn("business_scope", typeof(string)));
     dt.Columns.Add(new DataColumn("ent_qualification", typeof(string)));
     dt.Columns.Add(new DataColumn("create_by", typeof(string)));
     dt.Columns.Add(new DataColumn("create_time", typeof(long)));
     #endregion
     for (int i = 0; i < customerSum; i++)
     {
         List<SysSQLString> list = new List<SysSQLString>();
         dt.Rows.Clear();
         listTbCustomer.Clear();
         for (int y = customerIndex; y < customerCount; y++)
         {
             int index = i * customerCount + y;
             if (index >= customerArr.Count())
             {
                 break;
             }
             QueryCustomer.customer item = customerArr[index];
             //bool isContactExist = DBHelper.IsExist("判断车辆客户信息是否存在", "tb_customer", "cust_code='" + item.cust_code + "'");
             string custID = null;
             if (dtCustomer != null && dtCustomer.Rows.Count > 0)
             {
                 DataRow[] drs = dtCustomer.Select("cust_code='" + item.cust_code + "'");
                 if (drs.Count() > 0)
                 {
                     custID = drs[0]["cust_id"].ToString();
                 }
             }
             string credit_rating = dic.GetLocalDicID("credit_rating", item.credit_rating);
             string cust_relation = dic.GetLocalDicID("cust_relation", item.cust_relation);
             string com_constitution = dic.GetLocalDicID("com_constitution", item.com_constitution);
             string ent_qualification = dic.GetLocalDicID("ent_qualification", item.ent_qualification);
             string market_segment = dic.GetLocalDicID("market_segment", item.market_segment);
             if (!string.IsNullOrEmpty(custID))
             {
                 #region 更新语句
                 SysSQLString sysSQLString = new SysSQLString();
                 sysSQLString.cmdType = CommandType.Text;
                 sysSQLString.Param = new Dictionary<string, string>();
                 sysSQLString.Param.Add("business_scope", item.business_scope);
                 StringBuilder strSql = new StringBuilder();
                 strSql.Append("update tb_customer set ");
                 strSql.AppendFormat(" cust_crm_guid= '{0}' , ", item.cust_crm_guid);
                 strSql.AppendFormat(" cust_code= '{0}' , ", item.cust_code);
                 strSql.AppendFormat(" cust_name= '{0}' , ", item.cust_name);
                 strSql.AppendFormat(" province= '{0}' , ", item.province);
                 strSql.AppendFormat(" city= '{0}' , ", item.city);
                 strSql.AppendFormat(" county= '{0}' , ", item.county);
                 strSql.AppendFormat(" cust_address= '{0}' , ", item.cust_address);
                 strSql.AppendFormat(" zip_code= '{0}' , ", item.zip_code);
                 strSql.AppendFormat(" cust_phone= '{0}' , ", item.cust_phone);
                 strSql.AppendFormat(" cust_fax= '{0}' , ", item.cust_fax);
                 strSql.AppendFormat(" cust_email= '{0}' , ", item.email);
//.........这里部分代码省略.........
开发者ID:caocf,项目名称:workspace-kepler,代码行数:101,代码来源:WebServ_YT_BasicData.cs

示例5: SavePartNotBatch


//.........这里部分代码省略.........
            dtTbPartsPrice.Columns.Add("sort_index", typeof(string));
            dtTbPartsPrice.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_time", typeof(long)));
            //替换配件表
            DataTable dtTbReplace = new DataTable();
            List<DataRow> listTbReplace = new List<DataRow>();
            dtTbReplace.Columns.Add(new DataColumn("replace_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_code", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_status", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_remark", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("change", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_time", typeof(long)));
            //单位设置
            DataTable dtTbPartsSetup = new DataTable();
            List<DataRow> listTbSetup = new List<DataRow>();
            dtTbPartsSetup.Columns.Add(new DataColumn("set_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("sale_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_purchase", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_sale", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_time", typeof(long)));
            dtTbPartsSetup.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            #endregion
            for (int i = 0; i < partSum; i++)
            {
                List<SysSQLString> list = new List<SysSQLString>();
                dtTbParts.Rows.Clear();
                dtTbReplace.Rows.Clear();
                listTbParts.Clear();
                listTbReplace.Clear();
                listTbPrice.Clear();
                listTbSetup.Clear();
                for (int y = partIndex; y < partCount; y++)
                {
                    int index = i * partCount + y;
                    if (index >= partArr.Count())
                    {
                        break;
                    }
                    #region 配件信息
                    QueryPart.part item = partArr[index];

                    string price3a = WebServUtil.GetEncField(item.price3a);//加密
                    string price2a = WebServUtil.GetEncField(item.price2a);//加密
                    string partType = dic.GetLocalDicID("part_type", item.part_type);//配件类型
                    string partsID = null;
                    bool isAdd = false;//是否新增
                    if (dicParts.ContainsKey(item.car_parts_code))
                    {
                        partsID = dicParts[item.car_parts_code];
                    }
                    if (!string.IsNullOrEmpty(partsID))
                    {
                        #region 更新语句
                        SysSQLString sysSQLString = new SysSQLString();
                        sysSQLString.cmdType = CommandType.Text;
                        sysSQLString.Param = new Dictionary<string, string>();
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(" update tb_parts set ");
开发者ID:caocf,项目名称:workspace-kepler,代码行数:67,代码来源:WebServ_YT_BasicData.cs

示例6: SaveUserNotBatch

        /// <summary>保存用户
        /// </summary>
        /// <param name="contactArr">用户</param>
        /// <param name="updateCount">更新条数</param>
        /// <returns>True OR False</returns>
        private static bool SaveUserNotBatch(QueryContact.contact[] contactArr, ref int updateCount)
        {
            string nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime).ToString();
            int contactIndex = 0;//联系人列表索引
            int contactCount = 10000;//每批执行条数
            //contactCount = contactArr.Count();
            int contactSum = contactArr.Count() / contactCount + 1;//执行批数
            //int contactSum = 3;
            bool flag = true;//执行结果
            DateTime startDate = DateTime.Now;
            YuTongDic dic = new YuTongDic();
            YTCustomer ytCustomer = new YTCustomer();
            //用户
            DataTable dtContacts = DBHelper.GetTable("", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "sys_user", "user_id,cont_crm_guid", "", "", "");
            #region 生成表列
            DataTable dt = new DataTable();
            List<DataRow> listTb = new List<DataRow>();
            dt.Columns.Add(new DataColumn("user_id", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_crm_guid", typeof(string)));
            dt.Columns.Add(new DataColumn("user_name", typeof(string)));
            dt.Columns.Add(new DataColumn("sex", typeof(string)));
            dt.Columns.Add(new DataColumn("nation", typeof(string)));
            dt.Columns.Add(new DataColumn("post", typeof(string)));
            //dt.Columns.Add(new DataColumn("cont_phone", typeof(string)));
            dt.Columns.Add(new DataColumn("user_phone", typeof(string)));
            //dt.Columns.Add(new DataColumn("post_remark", typeof(string)));
            //dt.Columns.Add(new DataColumn("parent_customer", typeof(string)));
            dt.Columns.Add(new DataColumn("status", typeof(string)));
            dt.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dt.Columns.Add(new DataColumn("create_by", typeof(string)));
            dt.Columns.Add(new DataColumn("create_time", typeof(long)));
            dt.Columns.Add(new DataColumn("data_sources", typeof(string)));
            //dt.Columns.Add("contacts_type", typeof(string));
            #endregion
            for (int i = 0; i <= contactSum; i++)
            {
                dt.Rows.Clear();
                listTb.Clear();
                List<SysSQLString> list = new List<SysSQLString>();
                for (int y = contactIndex; y < contactCount; y++)
                {
                    int index = i * contactCount + y;
                    if (index >= contactArr.Count())
                    {
                        break;
                    }
                    QueryContact.contact item = contactArr[index];

                    StringBuilder strSql = new StringBuilder();
                    DataRow[] drsCont = dtContacts.Select("cont_crm_guid='" + item.cont_crm_guid + "'");
                    bool isContactExist = false;
                    //bool isContactExist = DBHelper.IsExist("判断联系人信息是否存在", "tb_contacts", "cont_crm_guid='" + item.cont_crm_guid + "'");
                    string nation = dic.GetLocalDicID("nation", item.nation);//民族
                    string cont_post = dic.GetLocalDicID("cont_post", item.cont_post);//职务
                    int cont_type = 0;
                    if (!string.IsNullOrEmpty(item.doc_type))
                    {
                        cont_type = Convert.ToInt32(item.doc_type);
                        DataSources.ContactType contType = (DataSources.ContactType)cont_type;
                        if (contType != DataSources.ContactType.Server)
                        {
                            continue;
                        }
                    }
                    if (drsCont.Count() > 0)
                    {
                        isContactExist = true;
                    }
                    if (isContactExist)
                    {
                        #region 更新语句
                        SysSQLString sysSQLString = new SysSQLString();
                        sysSQLString.cmdType = CommandType.Text;
                        sysSQLString.Param = new Dictionary<string, string>();
                        strSql.Append("update sys_user set ");
                        strSql.AppendFormat(" user_name = '{0}' , ", item.cont_name);
                        strSql.AppendFormat(" sex = '{0}' , ", item.sex);
                        strSql.AppendFormat(" nation = '{0}' , ", nation);
                        strSql.AppendFormat(" post = '{0}' , ", item.cont_post);
                        //strSql.Append(" cont_phone = @cont_phone , ");
                        strSql.AppendFormat(" user_phone = {0} , ", item.cont_phone);
                        //strSql.AppendFormat(" post_remark = '{0}' , ", item.cont_post_remark);
                        //strSql.AppendFormat(" parent_customer = '{0}' , ", item.parent_customer);
                        //strSql.AppendFormat(" contacts_type={0},", cont_type);
                        strSql.AppendFormat(" status = '{0}' , ", item.status == "0" ? "1" : "0");
                        strSql.AppendFormat(" enable_flag = '{0}' , ", (int)DataSources.EnumEnableFlag.USING);
                        strSql.AppendFormat(" data_sources = '{0}' , ", (int)DataSources.EnumDataSources.YUTONG);
                        strSql.AppendFormat(" update_by = '{0}' , ", GlobalStaticObj_Server.Instance.UserID);
                        strSql.AppendFormat(" update_time = {0}  ", nowTicks);
                        strSql.AppendFormat(" where cont_crm_guid='{0}'  ", item.cont_crm_guid);
                        sysSQLString.sqlString = strSql.ToString();
                        list.Add(sysSQLString);
                        #endregion
                    }
                    else
//.........这里部分代码省略.........
开发者ID:caocf,项目名称:workspace-kepler,代码行数:101,代码来源:WebServ_YT_BasicData.cs

示例7: SaveBusNotBatch

        /// <summary>
        /// 非批量保存车辆信息
        /// </summary>
        /// <param name="busArr">车辆信息</param>
        /// <returns></returns>
        private static bool SaveBusNotBatch(QueryBus.Detail[] busArr, ref int updateCount)
        {
            string nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime).ToString();
            int busIndex = 0;//列表索引
            int busCount = 10000;//每批执行条数
            //busCount = busArr.Count();
            int busSum = busArr.Count() / busCount + 1;//执行批数
            int busSumCount = busArr.Count();
            //int contactSum = 3;
            bool flag = true;//执行结果
            DateTime startDate = DateTime.Now;
            YuTongDic dic = new YuTongDic();
            //车辆
            DataTable dtVehicle = DBHelper.GetTable("获取车辆信息车辆ID", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_vehicle", "v_id,turner", null, null, null);
            //车辆司机
            DataTable dtDriver = DBHelper.GetTable("获取车辆司机关系表中的司机ID", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tr_driver_vehicle", "driver_id,v_id", null, null, null);
            DataTable dtContacts = DBHelper.GetTable("获取联系人", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_contacts", "cont_id,cont_crm_guid,cont_name", "cont_crm_guid is not null", null, null);
            //品牌
            DataTable dtBrand = DBHelper.GetTable("获取品牌", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "sys_dictionaries a inner join sys_dictionaries b on a.dic_id=b.parent_id", "b.dic_id,b.dic_name", "a.dic_code='sys_vehicle_brand'", "", "");
            //车型
            DataTable dtVehicleModels = DBHelper.GetTable("获取车型信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_vehicle_models", "models_crm_id,vm_id", "isnull(models_crm_id,'')<>''", "", "");
            #region 初始化表列
            ///车辆表
            DataTable dt = new DataTable();
            List<DataRow> listTbVehicle = new List<DataRow>();
            dt.Columns.Add(new DataColumn("v_id", typeof(string)));
            dt.Columns.Add(new DataColumn("data_source", typeof(string)));
            dt.Columns.Add(new DataColumn("license_plate", typeof(string)));
            dt.Columns.Add(new DataColumn("v_brand", typeof(string)));
            dt.Columns.Add(new DataColumn("vin", typeof(string)));
            dt.Columns.Add(new DataColumn("v_model", typeof(string)));
            dt.Columns.Add(new DataColumn("carbuy_date", typeof(long)));
            dt.Columns.Add(new DataColumn("engine_num", typeof(string)));
            dt.Columns.Add(new DataColumn("turner", typeof(string)));
            dt.Columns.Add(new DataColumn("customer_unit", typeof(string)));
            dt.Columns.Add(new DataColumn("use_unit", typeof(string)));
            dt.Columns.Add(new DataColumn("vehicle_use", typeof(string)));
            dt.Columns.Add(new DataColumn("operating_line", typeof(string)));
            dt.Columns.Add(new DataColumn("point_departure", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_name", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_phone", typeof(string)));
            dt.Columns.Add(new DataColumn("place_arrival", typeof(string)));
            dt.Columns.Add(new DataColumn("warranty_period", typeof(int)));
            dt.Columns.Add("status", typeof(string));
            dt.Columns.Add(new DataColumn("warranty_mileage", typeof(decimal)));
            dt.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dt.Columns.Add(new DataColumn("create_by", typeof(string)));
            dt.Columns.Add(new DataColumn("create_time", typeof(long)));
            ///车辆司机表
            DataTable dtTbDriver = new DataTable();
            List<DataRow> listTbDriver = new List<DataRow>();
            dtTbDriver.Columns.Add(new DataColumn("driver_id", typeof(string)));
            dtTbDriver.Columns.Add(new DataColumn("driver_name", typeof(string)));
            dtTbDriver.Columns.Add(new DataColumn("driver_phone", typeof(string)));
            dtTbDriver.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbDriver.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbDriver.Columns.Add(new DataColumn("create_time", typeof(long)));
            ///车辆司机关联表
            DataTable dtTrDriver = new DataTable();
            List<DataRow> listTrDriver = new List<DataRow>();
            dtTrDriver.Columns.Add(new DataColumn("dir_v_id", typeof(string)));
            dtTrDriver.Columns.Add(new DataColumn("v_id", typeof(string)));
            dtTrDriver.Columns.Add(new DataColumn("driver_id", typeof(string)));
            #endregion
            for (int i = 0; i < busSum; i++)
            {
                List<SysSQLString> list = new List<SysSQLString>();
                dt.Rows.Clear();
                dtTbDriver.Rows.Clear();
                dtTrDriver.Rows.Clear();
                listTbDriver.Clear();
                listTbVehicle.Clear();
                listTrDriver.Clear();
                for (int y = busIndex; y < busCount; y++)
                {
                    int index = i * busCount + y;
                    if (index >= busSumCount)
                    {
                        break;
                    }
                    QueryBus.Detail item = busArr[index];
                    string v_id = null;
                    string dtCarBuyDate = "";
                    //购买日期为空处理
                    if (!String.IsNullOrEmpty(item.carbuy_date))
                    {
                        dtCarBuyDate = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(item.carbuy_date)).ToString();
                    }
                    string vehicle_use = dic.GetLocalDicID("vehicle_use", item.vehicle_use);
                    string cont_id = string.Empty;//联系人ID转换成本地ID
                    if (!string.IsNullOrEmpty(item.cont_name))
                    {
                        DataRow[] drsContacts = dtContacts.Select(string.Format("cont_crm_guid='{0}'", item.cont_name));
                        if (drsContacts.Count() > 0)
                        {
//.........这里部分代码省略.........
开发者ID:caocf,项目名称:workspace-kepler,代码行数:101,代码来源:WebServ_YT_BasicData.cs

示例8: ParseEmailData


//.........这里部分代码省略.........
                                            byte[] size = workbook.SaveDocument(DocumentFormat.Xlsx);
                                            tablesRepository.Find(t => t.Id == dataParsingRule.TableId_Id).Size = size.Length;
                                            tablesRepository.Commit();
                                            workbook.SaveDocument(path);
                                            SpreadsheetExtension.CloseDocument(name);
                                        }
                                    }
                                    else
                                    {
                                        worksheet.Rows.Insert(1);
                                        row = 1;
                                    }

                                    if (row != -1)
                                    {
                                        var author_Id = emailParsingRule.AuthorId_Id;
                                        foreach (var defaultValue in allDefaultValues)
                                        {
                                            if (emailParsingRule.Status != Model.Enums.RuleStatusEnums.Paused.ToString())
                                            {
                                                InsertEmailLink(emailId, defaultValue, row, author_Id, emailParsingRule.CopyRuleFromPreviousOrder);
                                            }
                                        }
                                        foreach (
                                            var dataParsing in
                                                emailParsingRule.EmailDataParsingRulesModels.Where(
                                                    w => w.TableId_Id == dataParsingRule.TableId_Id))
                                        {
                                            if (dataParsing.Status != Model.Enums.RuleStatusEnums.Paused.ToString())
                                            {
                                                if (emailParsingRule.IsUpdatingRule)
                                                {
                                                    foreach (var rowForUpdate in rows)
                                                    {
                                                        ParseCellValue(email, dataParsing, rowForUpdate, emailParsingRule.CopyRuleFromPreviousOrder);
                                                    }
                                                    rows.Clear();
                                                }
                                                else
                                                {
                                                    ParseCellValue(email, dataParsing, row, emailParsingRule.CopyRuleFromPreviousOrder);
                                                }
                                            }
                                        }

                                        tablesList.Add(new TablesList
                                        {
                                            IsChecked = true,
                                            TableId = (long)dataParsingRule.TableId_Id
                                        });
                                    }
                                }
                                catch
                                {
                                    AddLog("Table not found");
                                }
                            }
                        }
                    }
                    else if (allDefaultValues != null)
                    {
                        var tablesInallDefaultValues = allDefaultValues.GroupBy(a => a.TableId).Select(g => g.First());
                        foreach (var defaultValue in tablesInallDefaultValues)
                        {
                            try
                            {
                            var name = tablesRepository.Find(w => w.Name == defaultValue.TableId && w.AuthorId_Id == emailParsingRule.AuthorId_Id).Name;
                            var path = SpreadsheetHelper.GetSpreadsheetPathById(tablesRepository.Find(w => w.Name == defaultValue.TableId && w.AuthorId_Id == emailParsingRule.AuthorId_Id).Id);
                                SpreadsheetExtension.LoadDocument(name, path);

                                IWorkbook workbook = SpreadsheetExtension.GetCurrentDocument(name);

                                Worksheet worksheet =
                                    workbook.Worksheets[
                                        Convert.ToInt32(defaultValue.Worksheet)];

                                worksheet.Rows.Insert(1);
                                row = 1;

                                byte[] size = workbook.SaveDocument(DocumentFormat.Xlsx);
                                tablesRepository.Find(w => w.Name == defaultValue.TableId && w.AuthorId_Id == emailParsingRule.AuthorId_Id).Size = size.Length;
                                tablesRepository.Commit();

                                workbook.SaveDocument(path);

                                SpreadsheetExtension.CloseDocument(name);
                            }
                            catch (Exception ex)
                            {
                                AddLog(ex.Message);
                            }
                        }
                        foreach (var defaultValue in allDefaultValues)
                         {
                             InsertEmailLink(emailId, defaultValue, row, emailParsingRule.AuthorId_Id, emailParsingRule.CopyRuleFromPreviousOrder);
                         }
                    }
                }
            }
        }
开发者ID:Zowal,项目名称:Oasis,代码行数:101,代码来源:ParseHelper.cs

示例9: SaveContactNotBatch

        /// <summary> 保存联系人
        /// </summary>
        /// <param name="contactArr">联系人</param>
        /// <param name="updateCount">更新条数</param>
        /// <returns>True OR False</returns>
        private static bool SaveContactNotBatch(QueryContact.contact[] contactArr, ref int updateCount)
        {
            string nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime).ToString();
            int contactIndex = 0;//联系人列表索引
            int contactCount = 10000;//每批执行条数
            //contactCount = contactArr.Count();
            int contactSum = contactArr.Count() / contactCount + 1;//执行批数
            //int contactSum = 3;
            bool flag = true;//执行结果
            DateTime startDate = DateTime.Now;
            YuTongDic dic = new YuTongDic();
            YTCustomer ytCustomer = new YTCustomer();
            //联系人
            DataTable dtContacts = DBHelper.GetTable("", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_contacts", "cont_id,cont_crm_guid", "", "", "");
            DataTable dtBaseContacts = DBHelper.GetTable("", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tr_base_contacts", "cont_id,relation_object_id", "relation_object='tb_customer'", "", "");
            #region 生成表列
            DataTable dt = new DataTable();
            List<DataRow> listTb = new List<DataRow>();
            dt.Columns.Add(new DataColumn("cont_id", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_crm_guid", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_name", typeof(string)));
            dt.Columns.Add(new DataColumn("sex", typeof(string)));
            dt.Columns.Add(new DataColumn("nation", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_post", typeof(string)));
            //dt.Columns.Add(new DataColumn("cont_phone", typeof(string)));
            dt.Columns.Add(new DataColumn("cont_phone_back", typeof(string)));
            dt.Columns.Add(new DataColumn("post_remark", typeof(string)));
            dt.Columns.Add(new DataColumn("parent_customer", typeof(string)));
            dt.Columns.Add(new DataColumn("status", typeof(string)));
            dt.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dt.Columns.Add(new DataColumn("create_by", typeof(string)));
            dt.Columns.Add(new DataColumn("create_time", typeof(long)));
            dt.Columns.Add(new DataColumn("data_source", typeof(string)));
            dt.Columns.Add("contacts_type", typeof(string));

            DataTable dtTrContacts = new DataTable();
            List<DataRow> listTrContacts = new List<DataRow>();
            dtTrContacts.Columns.Add("id", typeof(string));
            dtTrContacts.Columns.Add("cont_id", typeof(string));
            dtTrContacts.Columns.Add("relation_object", typeof(string));
            dtTrContacts.Columns.Add("relation_object_id", typeof(string));
            #endregion
            //StringBuilder sbMessage=new StringBuilder ();
            for (int i = 0; i <= contactSum; i++)
            {
                dt.Rows.Clear();
                listTb.Clear();
                listTrContacts.Clear();
                List<SysSQLString> list = new List<SysSQLString>();
                for (int y = contactIndex; y < contactCount; y++)
                {
                    int index = i * contactCount + y;
                    if (index >= contactArr.Count())
                    {
                        break;
                    }
                    QueryContact.contact item = contactArr[index];

                    StringBuilder strSql = new StringBuilder();
                    DataRow[] drsCont = dtContacts.Select("cont_crm_guid='" + item.cont_crm_guid + "'");
                    bool isContactExist = false;
                    //bool isContactExist = DBHelper.IsExist("判断联系人信息是否存在", "tb_contacts", "cont_crm_guid='" + item.cont_crm_guid + "'");
                    string nation = dic.GetLocalDicID("nation", item.nation);//民族
                    string cont_post = dic.GetLocalDicID("cont_post", item.cont_post);//职务
                    int cont_type = 0;
                    if (!string.IsNullOrEmpty(item.doc_type))
                    {
                        cont_type = Convert.ToInt32(item.doc_type);
                        DataSources.ContactType contType = (DataSources.ContactType)cont_type;
                        if (contType != DataSources.ContactType.Contact)
                        {
                            continue;
                        }
                    }
                    if (drsCont.Count() > 0)
                    {
                        isContactExist = true;
                    }
                    if (isContactExist)
                    {
                        #region 更新语句
                        SysSQLString sysSQLString = new SysSQLString();
                        sysSQLString.cmdType = CommandType.Text;
                        sysSQLString.Param = new Dictionary<string, string>();
                        strSql.Append("update tb_contacts set ");
                        strSql.AppendFormat(" cont_name = '{0}' , ", item.cont_name);
                        strSql.AppendFormat(" sex = '{0}' , ", item.sex);
                        strSql.AppendFormat(" nation = '{0}' , ", nation);
                        strSql.AppendFormat(" cont_post = '{0}' , ", item.cont_post);
                        //strSql.Append(" cont_phone = @cont_phone , ");
                        strSql.AppendFormat(" cont_phone = {0} , ", WebServUtil.GetEncField(item.cont_phone));
                        strSql.AppendFormat(" post_remark = '{0}' , ", item.cont_post_remark);
                        strSql.AppendFormat(" parent_customer = '{0}' , ", item.parent_customer);
                        strSql.AppendFormat(" contacts_type={0},", cont_type);
                        strSql.AppendFormat(" status = '{0}' , ", item.status == "0" ? "1" : "0");
//.........这里部分代码省略.........
开发者ID:caocf,项目名称:workspace-kepler,代码行数:101,代码来源:WebServ_YT_BasicData.cs

示例10: adjustTable

        //向table中加入被考评人信息
        private void adjustTable(DataTable dt, ref int num,ref string exception)
        {
            dt.Columns.Add("EvaluatedName");
            dt.Columns.Add("EvaluatedDep");
            dt.Columns.Add("EvaluatedUnit");
            dt.Columns.Add("EvaluatedStartTime");
            dt.Columns.Add("EvaluatedEndTime");
            dt.Columns.Add("EvaluatedJob");
            dt.Columns.Add("EvaluationStatus");
            List<UserInfo> ui = new List<UserInfo>();
            num = 0;
            foreach (DataRow dr in dt.Rows)
            {
                ui.Clear();
                UserInfoBLL.Select(ref ui, dr["EvaluatedID"].ToString(), ref exception);
                dr["EvaluatedName"] = ui[0].UiName;
                dr["EvaluatedDep"] = ui[0].UiDepartment;
                dr["EvaluatedUnit"] = ui[0].UiCompany;
                dr["EvaluatedStartTime"] = ui[0].UiStartTime;
                dr["EvaluatedEndTime"] = ui[0].UiStopTime;
                dr["EvaluatedJob"] = ui[0].UiJob;

                //
                if (dr["Status"].ToString().Equals("1"))
                {
                    dr["EvaluationStatus"] = "已考评";
                    num++;
                }
                else
                {
                    dr["EvaluationStatus"] = "未考评";
                }
            }
        }
开发者ID:cntimothy,项目名称:TJEvaluationSystem,代码行数:35,代码来源:Evaluate.aspx.cs

示例11: adjustTable1

 private void adjustTable1(DataTable dt, ref string exception)
 {
     dt.Columns.Add("Comment");
     dt.Columns.Add("Passed");
     List<Evaluator> evaluators = new List<Evaluator>();
     string comment = "";
     foreach (DataRow dr in dt.Rows)
     {
         if (EvaluatorCommentBLL.SelectComment((string)dr["UiID"], ref comment, ref exception))
         {
             dr["Comment"] = comment;
         }
         else
         {
             dr["Comment"] = "";
         }
         evaluators.Clear();
         if (EvaluatorBLL.SelectByID(evaluators, (string)dr["UiID"], ref exception))
         {
             //0:已提交 1:已审核
             dr["Passed"] = "未审核";
             foreach (Evaluator e in evaluators)
             {
                 if (e.Pass.ToString() == "1")
                 {
                     dr["Passed"] = "已审核";
                     break;
                 }
             }
             //if (evaluators[0].Pass.ToString() == "1")
             //{
             //    dr["Passed"] = "已审核";
             //}
             //else if (evaluators[0].Pass.ToString() == "0")
             //{
             //    dr["Passed"] = "未审核";
             //}
         }
         else
         {
             dr["Passed"] = "未制作";
         }
     }
 }
开发者ID:cntimothy,项目名称:TJEvaluationSystem,代码行数:44,代码来源:CheckEvaluator.aspx.cs

示例12: adjustTable

 private void adjustTable(DataTable dt, ref string exception)
 {
     dt.Columns.Add("EvaluatedName");
     dt.Columns.Add("EvaluatorName");
     dt.Columns.Add("EvaluatorUnit");
     List<UserInfo> ui = new List<UserInfo>();
     List<EvaluatorInfo> evi = new List<EvaluatorInfo>();
     foreach (DataRow dr in dt.Rows)
     {
         evi.Clear();
         EvaluatorInfoBLL.Select(evi, dr["UiID"].ToString(), ref exception);
         dr["EvaluatorName"] = evi[0].EvName;
         dr["EvaluatorUnit"] = evi[0].EvUnit;
         ui.Clear();
         UserInfoBLL.Select(ref ui, dr["EvaluatedID"].ToString(), ref exception);
         dr["EvaluatedName"] = ui[0].UiName;
     }
 }
开发者ID:cntimothy,项目名称:TJEvaluationSystem,代码行数:18,代码来源:CheckEvaluator.aspx.cs

示例13: DrawOperation

        public static void DrawOperation(OpenGL gl, Project testProject, Vector rotation, List<List<double[]>> detailCache)
        {
            var bill = testProject.Settings;

            gl.Translate(bill.Length / 2, bill.Height / 2, bill.Width / 2);//высчитывается из размера заготовки
            gl.Rotate((float)rotation.Y, (float)rotation.X, 0); // вращение с зажатой средней кнопкой мыши
            gl.Translate(-bill.Length / 2, -bill.Height / 2, -bill.Width / 2);

            //var Bill = this.testProject.Settings;
            Billet.Draw(gl, bill.Height, bill.Length, bill.Width); // заготовка

            var operations = testProject.Operations;//колличество операций

            var boltReg = new Regex("BoltHole");
            var pocketReg = new Regex("Pocket");
            if (detailCache.Count != operations.Count) detailCache.Clear();

            for (var i = 0; i < operations.Count; i++)//главный цикл отрисовки
            {
                var shapeName = operations[i].Shape.Name;

                if (boltReg.IsMatch(shapeName))
                {
                    var bolt = (Model.Primitives.BoltHole)operations[i].Shape;
                    var boltlocation = operations[i].Location.LocationsList.GetEnumerator();
                    while (boltlocation.MoveNext())
                    {
                        if (bolt.Modified || boltlocation.Current.Modified || detailCache.Count<=i)
                        {

                            try
                            {
                                detailCache.RemoveAt(i);
                            }
                            catch{}
                            var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
                            detailCache.Insert(i, BoltHole.ReCalc(bolt, 0.5, location)); //здесь уже всё ок, кроме величины шага
                            boltlocation.Current.IsDrawn();
                            bolt.IsDrawn();//значит в кэше лежит актуальная информация
                        }
                        else
                        {
                            var location = new Point(boltlocation.Current.X, boltlocation.Current.Y);
                            BoltHole.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
                        }
                    }
                }

                if (!pocketReg.IsMatch(shapeName)) continue;
                var poc = (Model.Primitives.Pocket)operations[i].Shape;
                var poclocation = operations[i].Location.LocationsList.GetEnumerator();
                while (poclocation.MoveNext())
                {
                    if (poc.Modified || poclocation.Current.Modified || detailCache.Count <= i)
                    {
                        try
                        {
                            detailCache.RemoveAt(i);
                        }
                        catch { }
                        var location = new Point(poclocation.Current.X, poclocation.Current.Y);
                        var p = Pocket.ReCalc(poc, 0.5, location);
                        detailCache.Insert(i, p); //здесь уже всё ок, кроме величины шага
                        poclocation.Current.IsDrawn();
                        poc.IsDrawn();//значит в кэше лежит актуальная информация
                    }
                    else
                    {
                        var location = new Point(poclocation.Current.X, poclocation.Current.Y);
                        Pocket.Draw(gl, detailCache[i]); //здесь уже всё ок, кроме величины шага
                    }
                }
            }

            //отрисовщик траекторий
            gl.Begin(OpenGL.GL_LINE_STRIP);
            gl.Color(1f, 0, 0);

            var trajectorys = GCodeGenerator.TrajectoryStor.GetTrajectorys();
            foreach (var point in trajectorys.SelectMany(operation => operation))
            {
                gl.Vertex(point.GetCoordinates());
            }
        }
开发者ID:KyMaP13,项目名称:sharpcam,代码行数:84,代码来源:OperationDrawer.cs

示例14: createIteration1PatientsAndVisits

        //generate data for iteration 1
        public void createIteration1PatientsAndVisits(int numberOfPatients)
        {
            Random random = new Random();
            List<Patient> patients = new List<Patient>();
            List<Patient> globallySimilarPatients = new List<Patient>();
            List<Patient> globallyNonSimilarPatients = new List<Patient>();
            List<PatientMatchNode> patientMatchNodes = new List<PatientMatchNode>();
            float globallySimilarPatientsThreshold = 0.1f;
            float globallyNonSimilarPatientsThreshold = 0.1f;
            int requiredNumberOfGloballySimilarPatients = (int)((globallySimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int requiredNumberOfGloballyNonSimilarPatients = (int)((globallyNonSimilarPatientsThreshold * numberOfPatients) + 0.5f);
            int currentNumberOfGloballySimilarPatients = 0;
            int currentNumberOfGloballyNonSimilarPatients = 0;
            DateTime maxRangeStart = new DateTime(2011, 01, 01);
            DateTime maxRangeEnd = new DateTime(2011, 12, 31);
            DateTime rangeStart = Util.getRandomDate(maxRangeStart, maxRangeEnd.AddMonths(-1));
            DateTime rangeEnd = rangeStart.AddDays(15);

            int randRationalMin = 1;
            int randRationalMax = 5;

            DbMethods.getInstance().clearTables();

            for (int i = 0; i < numberOfPatients; i++)
            {
                int patientID = i;
                DbMethods.getInstance().InsertPatient();
                Patient patient = new Patient(patientID);
                PatientMatchNode patientNode = new PatientMatchNode(patient);

                int numberOfVisits = random.Next(10, 20);
                bool restart = true;

                do
                {
                    patient.ClearVisits();

                    //generate directed visits
                    for (int j = 0; j < numberOfVisits; j++)
                    {
                        Visit v = new Visit(-1, random.Next(1, 100), random.Next(randRationalMin, randRationalMax), Util.getRandomDate(rangeStart, rangeEnd));
                        if (!patient.HasVisit(v))
                        {
                            patient.AddVisit(v);
                        }
                        else
                        {
                            j--;
                        }
                    }

                    if (requiredNumberOfGloballySimilarPatients > 0)
                    {
                        //SIMILAR PATIENTS

                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.Patient.HasSimilarVisits(patient, 0.5f))
                            {
                                n.addMatch(patient);
                                restart = false;
                            }
                        }

                        List<PatientMatchNode> nodesToRemove = new List<PatientMatchNode>();
                        foreach (PatientMatchNode n in patientMatchNodes)
                        {
                            if (n.getMatchesNumber() >= 4)
                            {
                                requiredNumberOfGloballySimilarPatients--;
                                globallySimilarPatients.Add(n.Patient);
                                nodesToRemove.Add(n);
                            }
                        }

                        foreach (PatientMatchNode n in nodesToRemove)
                        {
                            patientMatchNodes.Remove(n);
                        }

                        nodesToRemove.Clear();

                        if(patientMatchNodes.Count < requiredNumberOfGloballySimilarPatients)
                        {
                            patientMatchNodes.Add(patientNode);
                            restart = false;
                        }

                    }
                    else if (requiredNumberOfGloballyNonSimilarPatients > 0)
                    {
                        //NON-SIMILAR PATIENTS
                        rangeStart = maxRangeStart;
                        rangeEnd = maxRangeEnd;

                        bool hasSimilar = false;
                        foreach (Patient p in patients)
                        {
                            if (!patient.HasNoSimilarVisits(p))
//.........这里部分代码省略.........
开发者ID:patpaquette,项目名称:Cheo-visits,代码行数:101,代码来源:Controller.cs


注:本文中的Model.List.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。